Merge commit 'b869eea7ea8f5d8331fcd6355f848bb6a6e06b14'
[ffmpeg.git] / libavcodec / h263dec.c
index 74e4be43a1afa5b5ea49c04c724d1b6a985ac64e..40d98142c49496ae33e4087e756fd02067896509 100644 (file)
@@ -456,21 +456,9 @@ retry:
     if (ret < 0)
         return ret;
 
-    if (!s->context_initialized) {
+    if (!s->context_initialized)
         // we need the idct permutaton for reading a custom matrix
         ff_mpv_idct_init(s);
-        if ((ret = ff_MPV_common_init(s)) < 0)
-            return ret;
-    }
-
-    /* We need to set current_picture_ptr before reading the header,
-     * otherwise we cannot store anyting in there */
-    if (s->current_picture_ptr == NULL || s->current_picture_ptr->f->data[0]) {
-        int i = ff_find_unused_picture(s, 0);
-        if (i < 0)
-            return i;
-        s->current_picture_ptr = &s->picture[i];
-    }
 
     /* let's go :-) */
     if (CONFIG_WMV2_DECODER && s->msmpeg4_version == 5) {
@@ -510,6 +498,17 @@ retry:
         return ret;
     }
 
+    if (!s->context_initialized)
+        if ((ret = ff_MPV_common_init(s)) < 0)
+            return ret;
+
+    if (s->current_picture_ptr == NULL || s->current_picture_ptr->f->data[0]) {
+        int i = ff_find_unused_picture(s, 0);
+        if (i < 0)
+            return i;
+        s->current_picture_ptr = &s->picture[i];
+    }
+
     avctx->has_b_frames = !s->low_delay;
 
     if (CONFIG_MPEG4_DECODER && avctx->codec_id == AV_CODEC_ID_MPEG4) {