1
0
mirror of https://github.com/jojo61/vdr-plugin-softhdcuvid.git synced 2023-10-10 13:37:41 +02:00

Final fix for memory leak

This commit is contained in:
jojo61 2020-01-31 12:28:18 +01:00
parent 26945ef9d2
commit c06b891c2b
3 changed files with 44 additions and 7 deletions

View File

@ -310,7 +310,7 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
deint = 2; deint = 2;
#endif #endif
#if defined VAAPI && !defined RASPI #if defined VAAPI && !defined RASPI
decoder->VideoCtx->extra_hw_frames = 8; // VIDEO_SURFACES_MAX +1 // decoder->VideoCtx->extra_hw_frames = 8; // VIDEO_SURFACES_MAX +1
if (video_codec->capabilities & (AV_CODEC_CAP_AUTO_THREADS)) { if (video_codec->capabilities & (AV_CODEC_CAP_AUTO_THREADS)) {
Debug(3, "codec: auto threads enabled"); Debug(3, "codec: auto threads enabled");
// decoder->VideoCtx->thread_count = 0; // decoder->VideoCtx->thread_count = 0;
@ -516,7 +516,6 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
*pkt = *avpkt; // use copy *pkt = *avpkt; // use copy
ret = avcodec_send_packet(video_ctx, pkt); ret = avcodec_send_packet(video_ctx, pkt);
if (ret < 0) { if (ret < 0) {
Debug(4, "codec: sending video packet failed");
return; return;
} }
@ -524,7 +523,7 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
usleep(1000); usleep(1000);
ret = 0; ret = 0;
while (ret >= 0) { while (ret >= 0 && CuvidTestSurfaces()) {
frame = av_frame_alloc(); frame = av_frame_alloc();
ret = avcodec_receive_frame(video_ctx, frame); ret = avcodec_receive_frame(video_ctx, frame);

32
drm.c
View File

@ -183,6 +183,38 @@ static int SetPropertyRequest(drmModeAtomicReqPtr ModeReq, int fd_drm,
return drmModeAtomicAddProperty(ModeReq, objectID, id, value); return drmModeAtomicAddProperty(ModeReq, objectID, id, value);
} }
static void CuvidSetVideoMode(void);
void set_video_mode(int width, int height)
{
drmModeConnector *connector;
drmModeModeInfo *mode;
int ii;
if (height != 1080 && height != 2160)
return;
connector = drmModeGetConnector(render->fd_drm, render->connector_id);
for (ii = 0; ii < connector->count_modes; ii++) {
mode = &connector->modes[ii];
printf("Mode %d %dx%d Rate %d\n",ii,mode->hdisplay,mode->vdisplay,mode->vrefresh);
if (width == mode->hdisplay &&
height == mode->vdisplay &&
mode->vrefresh == DRMRefresh &&
render->mode.hdisplay != width &&
render->mode.vdisplay != height &&
!(mode->flags & DRM_MODE_FLAG_INTERLACE)) {
memcpy(&render->mode, mode, sizeof(drmModeModeInfo));
VideoWindowWidth = mode->hdisplay;
VideoWindowHeight = mode->vdisplay;
eglDestroySurface (eglDisplay, eglSurface);
EglCheck();
gbm_surface_destroy (gbm.surface);
InitBo(render->bpp);
CuvidSetVideoMode();
Debug(3,"Set new mode %d:%d\n",mode->hdisplay,mode->vdisplay);
break;
}
}
}
static int FindDevice(VideoRender * render) static int FindDevice(VideoRender * render)
{ {
drmVersion *version; drmVersion *version;

12
video.c
View File

@ -2413,6 +2413,10 @@ void createTextureDst(CuvidDecoder * decoder, int anz, unsigned int size_x, unsi
Debug(3, "video: create %d Textures Format %s w %d h %d \n", anz, PixFmt == AV_PIX_FMT_NV12 ? "NV12" : "P010", Debug(3, "video: create %d Textures Format %s w %d h %d \n", anz, PixFmt == AV_PIX_FMT_NV12 ? "NV12" : "P010",
size_x, size_y); size_x, size_y);
#ifdef USE_DRM
//set_video_mode(size_x,size_y); // switch Mode here (highly experimental)
#endif
#ifdef CUVID #ifdef CUVID
glXMakeCurrent(XlibDisplay, VideoWindow, glxSharedContext); glXMakeCurrent(XlibDisplay, VideoWindow, glxSharedContext);
GlxCheck(); GlxCheck();
@ -2780,9 +2784,11 @@ static int init_generic_hwaccel(CuvidDecoder * decoder, enum AVPixelFormat hw_fm
new_fctx->width != old_fctx->width || new_fctx->width != old_fctx->width ||
new_fctx->height != old_fctx->height || new_fctx->height != old_fctx->height ||
new_fctx->initial_pool_size != old_fctx->initial_pool_size) { new_fctx->initial_pool_size != old_fctx->initial_pool_size) {
Debug(3,"delete old cache"); Debug(3,"delete old cache");
av_buffer_unref(&decoder->cached_hw_frames_ctx); if (decoder->filter_graph)
} avfilter_graph_free(&decoder->filter_graph);
av_buffer_unref(&decoder->cached_hw_frames_ctx);
}
} }
if (!decoder->cached_hw_frames_ctx) { if (!decoder->cached_hw_frames_ctx) {