[1/3,WIP] rv40: fix threaded decode of clip starting with a bframe

Message ID 1407964439-21283-2-git-send-email-stebbins@jetheaddev.com
State New
Headers show

Commit Message

John Stebbins Aug. 13, 2014, 9:13 p.m.
ff_mpeg_update_thread_context fails if a picture has not been allocated
by the decoder.  So force allocate a picture on data errors that would
result in no picture.
---
 libavcodec/rv34.c | 6 ++++++
 1 file changed, 6 insertions(+)

Patch

diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 7411f6f..f270f43 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1652,6 +1652,12 @@  int ff_rv34_decode_frame(AVCodecContext *avctx,
         si.type == AV_PICTURE_TYPE_B) {
         av_log(avctx, AV_LOG_ERROR, "Invalid decoder state: B-frame without "
                "reference data.\n");
+        // In order for initialization to complete properly, it is required
+        // that we allocate a picture, even though it is not used.
+        ff_MPV_frame_start(s, s->avctx);
+        ff_mpeg_er_frame_start(s);
+        ff_er_frame_end(&s->er);
+        ff_MPV_frame_end(s);
         return AVERROR_INVALIDDATA;
     }
     if(   (avctx->skip_frame >= AVDISCARD_NONREF && si.type==AV_PICTURE_TYPE_B)