[FFmpeg-cvslog] avcodec/mpeg4videodec: Split decode_studio_vol_header() out of decode_studiovisualobject()

Michael Niedermayer git at videolan.org
Sat Jun 16 01:30:58 EEST 2018


ffmpeg | branch: release/4.0 | Michael Niedermayer <michael at niedermayer.cc> | Sun Apr 29 21:19:15 2018 +0200| [60e408f252e2073b239569c4d40866db27c24ec5] | committer: Michael Niedermayer

avcodec/mpeg4videodec: Split decode_studio_vol_header() out of decode_studiovisualobject()

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 177133a0f4b41b3c98b9cbc7f8f45755412c537b)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=60e408f252e2073b239569c4d40866db27c24ec5
---

 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) {



More information about the ffmpeg-cvslog mailing list