From e42a08340b85760f83d6c3a63215f397296dabc7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 30 Jan 2016 20:59:25 +0100 Subject: vd_lavc: release surfaces before destroying decoder Commit b53cb8de added a delay queue for decoded frames. This is supposed to be used with copy-back decoders like dxva2-copy and vaapi-copy. Surfaces returned by them can't be referenced after uninitializing the decoders, so they have to be released before destroying the decoder. Move the flush_all() call above decoder uninit accordingly. Also move the destruction of the AVFrame used for decoding (just for being defensive - normally it doesn't hold any reference). --- video/decode/vd_lavc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'video/decode') diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index c7ae13dfc5..1e7324457e 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -481,6 +481,9 @@ static void uninit_avctx(struct dec_video *vd) vd_ffmpeg_ctx *ctx = vd->priv; AVCodecContext *avctx = ctx->avctx; + flush_all(vd); + av_frame_free(&ctx->pic); + if (avctx) { if (avctx->codec && avcodec_close(avctx) < 0) MP_ERR(vd, "Could not close codec.\n"); @@ -494,10 +497,6 @@ static void uninit_avctx(struct dec_video *vd) av_freep(&ctx->avctx); - av_frame_free(&ctx->pic); - - flush_all(vd); - ctx->hwdec_failed = false; ctx->hwdec_fail_count = 0; ctx->max_delay_queue = 0; -- cgit v1.2.3