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:
parent
26945ef9d2
commit
c06b891c2b
5
codec.c
5
codec.c
@ -310,7 +310,7 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
|
||||
deint = 2;
|
||||
#endif
|
||||
#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)) {
|
||||
Debug(3, "codec: auto threads enabled");
|
||||
// decoder->VideoCtx->thread_count = 0;
|
||||
@ -516,7 +516,6 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
|
||||
*pkt = *avpkt; // use copy
|
||||
ret = avcodec_send_packet(video_ctx, pkt);
|
||||
if (ret < 0) {
|
||||
Debug(4, "codec: sending video packet failed");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -524,7 +523,7 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
|
||||
usleep(1000);
|
||||
|
||||
ret = 0;
|
||||
while (ret >= 0) {
|
||||
while (ret >= 0 && CuvidTestSurfaces()) {
|
||||
frame = av_frame_alloc();
|
||||
ret = avcodec_receive_frame(video_ctx, frame);
|
||||
|
||||
|
32
drm.c
32
drm.c
@ -183,6 +183,38 @@ static int SetPropertyRequest(drmModeAtomicReqPtr ModeReq, int fd_drm,
|
||||
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)
|
||||
{
|
||||
drmVersion *version;
|
||||
|
12
video.c
12
video.c
@ -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",
|
||||
size_x, size_y);
|
||||
|
||||
#ifdef USE_DRM
|
||||
//set_video_mode(size_x,size_y); // switch Mode here (highly experimental)
|
||||
#endif
|
||||
|
||||
#ifdef CUVID
|
||||
glXMakeCurrent(XlibDisplay, VideoWindow, glxSharedContext);
|
||||
GlxCheck();
|
||||
@ -2780,9 +2784,11 @@ static int init_generic_hwaccel(CuvidDecoder * decoder, enum AVPixelFormat hw_fm
|
||||
new_fctx->width != old_fctx->width ||
|
||||
new_fctx->height != old_fctx->height ||
|
||||
new_fctx->initial_pool_size != old_fctx->initial_pool_size) {
|
||||
Debug(3,"delete old cache");
|
||||
av_buffer_unref(&decoder->cached_hw_frames_ctx);
|
||||
}
|
||||
Debug(3,"delete old cache");
|
||||
if (decoder->filter_graph)
|
||||
avfilter_graph_free(&decoder->filter_graph);
|
||||
av_buffer_unref(&decoder->cached_hw_frames_ctx);
|
||||
}
|
||||
}
|
||||
|
||||
if (!decoder->cached_hw_frames_ctx) {
|
||||
|
Loading…
Reference in New Issue
Block a user