diff options
author | wm4 <wm4@nowhere> | 2015-10-19 17:49:30 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-10-19 17:49:30 +0200 |
commit | 0ab6031d76df43a8204e2bbc7eae2a93eb1cc383 (patch) | |
tree | e05596953f5f100b755c8c23bb0c6635c5eb1b78 | |
parent | 667b968939fc3dea63e010c3b64e465225a2321a (diff) | |
download | mpv-0ab6031d76df43a8204e2bbc7eae2a93eb1cc383.tar.bz2 mpv-0ab6031d76df43a8204e2bbc7eae2a93eb1cc383.tar.xz |
vd_lavc: continue decoding properly after decoding failure
Commit 12cd48a8 started setting the hwdec_failed field even if hwdec was
not active, and because it also checked this field even if hwdec was not
active, broke decoding forever.
Fix this, and also avoid a memory leak or API misuse by releasing the
decoded picture. Passing an unreleased frame to the decoder has as far
as I know no defined effects.
-rw-r--r-- | video/decode/vd_lavc.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 3d00fa6c41..6fdd1b2cfd 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -625,9 +625,8 @@ static void decode(struct dec_video *vd, struct demux_packet *packet, ret = avcodec_decode_video2(avctx, ctx->pic, &got_picture, &pkt); hwdec_unlock(ctx); - if (ctx->hwdec_failed || ret < 0) { - if (ret < 0) - MP_WARN(vd, "Error while decoding frame!\n"); + if (ret < 0) { + MP_WARN(vd, "Error while decoding frame!\n"); ctx->hwdec_failed = true; return; } @@ -636,6 +635,11 @@ static void decode(struct dec_video *vd, struct demux_packet *packet, if (!got_picture) return; + if (ctx->hwdec && ctx->hwdec_failed) { + av_frame_unref(ctx->pic); + return; + } + struct mp_image_params params; update_image_params(vd, ctx->pic, ¶ms); vd->codec_pts = mp_pts_from_av(ctx->pic->pkt_pts, NULL); |