summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-01-30 20:59:25 +0100
committerwm4 <wm4@nowhere>2016-01-30 20:59:25 +0100
commite42a08340b85760f83d6c3a63215f397296dabc7 (patch)
tree68acff4bd513b584ea8686f3071782eb2b394800 /video
parenteffc466222d1c1c63340b5245d7ebe48403214d6 (diff)
downloadmpv-e42a08340b85760f83d6c3a63215f397296dabc7.tar.bz2
mpv-e42a08340b85760f83d6c3a63215f397296dabc7.tar.xz
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).
Diffstat (limited to 'video')
-rw-r--r--video/decode/vd_lavc.c7
1 files changed, 3 insertions, 4 deletions
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;