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).
This commit is contained in:
wm4 2016-01-30 20:59:25 +01:00
parent effc466222
commit e42a08340b
1 changed files with 3 additions and 4 deletions

View File

@ -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;