diff mbox series

[FFmpeg-devel,44/57] avcodec/mpeg4videoenc: Simplify writing startcodes

Message ID AS8P250MB07443B6C3D661CDD0D09DCAD8F1B2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State New
Headers show
Series [FFmpeg-devel,01/14] avcodec/get_buffer: Remove redundant check | expand

Commit Message

Andreas Rheinhardt April 29, 2024, 9:14 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpeg4videoenc.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c
index 31307cc8dd..f89f29690a 100644
--- a/libavcodec/mpeg4videoenc.c
+++ b/libavcodec/mpeg4videoenc.c
@@ -886,8 +886,7 @@  static void mpeg4_encode_gop_header(MpegEncContext *s)
     int64_t hours, minutes, seconds;
     int64_t time;
 
-    put_bits(&s->pb, 16, 0);
-    put_bits(&s->pb, 16, GOP_STARTCODE);
+    put_bits32(&s->pb, GOP_STARTCODE);
 
     time = s->cur_pic.ptr->f->pts;
     if (s->reordered_input_picture[1])
@@ -936,13 +935,11 @@  static void mpeg4_encode_visual_object_header(MpegEncContext *s)
 
     // FIXME levels
 
-    put_bits(&s->pb, 16, 0);
-    put_bits(&s->pb, 16, VOS_STARTCODE);
+    put_bits32(&s->pb, VOS_STARTCODE);
 
     put_bits(&s->pb, 8, profile_and_level_indication);
 
-    put_bits(&s->pb, 16, 0);
-    put_bits(&s->pb, 16, VISUAL_OBJ_STARTCODE);
+    put_bits32(&s->pb, VISUAL_OBJ_STARTCODE);
 
     put_bits(&s->pb, 1, 1);
     put_bits(&s->pb, 4, vo_ver_id);
@@ -969,10 +966,8 @@  static void mpeg4_encode_vol_header(MpegEncContext *s,
         vo_type = SIMPLE_VO_TYPE;
     }
 
-    put_bits(&s->pb, 16, 0);
-    put_bits(&s->pb, 16, 0x100 + vo_number);        /* video obj */
-    put_bits(&s->pb, 16, 0);
-    put_bits(&s->pb, 16, 0x120 + vol_number);       /* video obj layer */
+    put_bits32(&s->pb, 0x100 + vo_number);        /* video obj */
+    put_bits32(&s->pb, 0x120 + vol_number);       /* video obj layer */
 
     put_bits(&s->pb, 1, 0);             /* random access vol */
     put_bits(&s->pb, 8, vo_type);       /* video obj type indication */
@@ -1049,8 +1044,7 @@  static void mpeg4_encode_vol_header(MpegEncContext *s,
 
     /* user data */
     if (!(s->avctx->flags & AV_CODEC_FLAG_BITEXACT)) {
-        put_bits(&s->pb, 16, 0);
-        put_bits(&s->pb, 16, 0x1B2);    /* user_data */
+        put_bits32(&s->pb, USER_DATA_STARTCODE);
         ff_put_string(&s->pb, LIBAVCODEC_IDENT, 0);
     }
 }
@@ -1074,8 +1068,7 @@  int ff_mpeg4_encode_picture_header(MpegEncContext *s)
 
     s->partitioned_frame = s->data_partitioning && s->pict_type != AV_PICTURE_TYPE_B;
 
-    put_bits(&s->pb, 16, 0);                /* vop header */
-    put_bits(&s->pb, 16, VOP_STARTCODE);    /* vop header */
+    put_bits32(&s->pb, VOP_STARTCODE);      /* vop header */
     put_bits(&s->pb, 2, s->pict_type - 1);  /* pict type: I = 0 , P = 1 */
 
     time_div  = FFUDIV(s->time, s->avctx->time_base.den);