[FFmpeg-devel] [PATCH 2/5] avcodec/mpeg4videodec: Split decode_studio_vol_header() out of decode_studiovisualobject()

Michael Niedermayer michael at niedermayer.cc
Sun Apr 29 22:19:15 EEST 2018


Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/mpeg4videodec.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 27602e8542..9ee2f37c69 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -2983,18 +2983,26 @@ static int decode_studio_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb)
 static int decode_studiovisualobject(Mpeg4DecContext *ctx, GetBitContext *gb)
 {
     MpegEncContext *s = &ctx->m;
-    int visual_object_type, width, height;
+    int visual_object_type;
 
         skip_bits(gb, 4); /* visual_object_verid */
         visual_object_type = get_bits(gb, 4);
+        if (visual_object_type != VOT_VIDEO_ID) {
+            avpriv_request_sample(s->avctx, "VO type %u", visual_object_type);
+            return AVERROR_PATCHWELCOME;
+        }
 
         next_start_code_studio(gb);
         extension_and_user_data(s, gb, 1);
 
-        if (visual_object_type == VOT_VIDEO_ID) {
-            /* StudioVideoObjectLayer */
-            skip_bits_long(gb, 32); /* video_object_start_code */
-            skip_bits_long(gb, 32); /* video_object_layer_start_code */
+    return 0;
+}
+
+static int decode_studio_vol_header(Mpeg4DecContext *ctx, GetBitContext *gb)
+{
+    MpegEncContext *s = &ctx->m;
+    int width, height;
+
             skip_bits1(gb); /* random_accessible_vol */
             skip_bits(gb, 8); /* video_object_type_indication */
             skip_bits(gb, 4); /* video_object_layer_verid */
@@ -3063,7 +3071,6 @@ static int decode_studiovisualobject(Mpeg4DecContext *ctx, GetBitContext *gb)
 
             next_start_code_studio(gb);
             extension_and_user_data(s, gb, 2);
-        }
 
     return 0;
 }
@@ -3173,8 +3180,14 @@ int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb)
                 continue;
             }
             vol++;
-            if ((ret = decode_vol_header(ctx, gb)) < 0)
-                return ret;
+            if (s->studio_profile) {
+                if ((ret = decode_studio_vol_header(ctx, gb)) < 0)
+                    return ret;
+                break;
+            } else {
+                if ((ret = decode_vol_header(ctx, gb)) < 0)
+                    return ret;
+            }
         } else if (startcode == USER_DATA_STARTCODE) {
             decode_user_data(ctx, gb);
         } else if (startcode == GOP_STARTCODE) {
@@ -3191,7 +3204,6 @@ int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb)
             if (s->studio_profile) {
                 if ((ret = decode_studiovisualobject(ctx, gb)) < 0)
                     return ret;
-                break;
             } else
                 mpeg4_decode_visual_object(s, gb);
         } else if (startcode == VOP_STARTCODE) {
-- 
2.17.0



More information about the ffmpeg-devel mailing list