diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h index 0e01458c89..f638480b24 100644 --- a/libavcodec/vc1.h +++ b/libavcodec/vc1.h @@ -396,6 +396,8 @@ typedef struct VC1Context{ int parse_only; ///< Context is used within parser int resync_marker; ///< could this stream contain resync markers + + int recovered; } VC1Context; /** diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 3ca478e82a..5338d94889 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -1045,6 +1045,13 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict, goto err; } + if (!v->recovered && !(avctx->flags2 & AV_CODEC_FLAG2_SHOW_ALL)) { + if (s->pict_type == AV_PICTURE_TYPE_I) + v->recovered = 1; + else + goto err; + } + /* skip B-frames if we don't have reference frames */ if (!s->last_picture_ptr && s->pict_type == AV_PICTURE_TYPE_B) { av_log(v->s.avctx, AV_LOG_DEBUG, "Skipping B frame without reference frames\n"); @@ -1381,6 +1388,14 @@ err: return ret; } +static void vc1_decode_flush(AVCodecContext *avctx) +{ + VC1Context *v = avctx->priv_data; + + ff_mpeg_flush(avctx); + + v->recovered = 0; +} const FFCodec ff_vc1_decoder = { .p.name = "vc1", @@ -1391,7 +1406,7 @@ const FFCodec ff_vc1_decoder = { .init = vc1_decode_init, .close = ff_vc1_decode_end, FF_CODEC_DECODE_CB(vc1_decode_frame), - .flush = ff_mpeg_flush, + .flush = vc1_decode_flush, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .hw_configs = (const AVCodecHWConfigInternal *const []) { #if CONFIG_VC1_DXVA2_HWACCEL @@ -1430,7 +1445,7 @@ const FFCodec ff_wmv3_decoder = { .init = vc1_decode_init, .close = ff_vc1_decode_end, FF_CODEC_DECODE_CB(vc1_decode_frame), - .flush = ff_mpeg_flush, + .flush = vc1_decode_flush, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .hw_configs = (const AVCodecHWConfigInternal *const []) { #if CONFIG_WMV3_DXVA2_HWACCEL