diff mbox series

[FFmpeg-devel,v2,3/3] avcodec/movtextenc: Remove redundant function parameters

Message ID 20201016031758.214795-3-andreas.rheinhardt@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel,v2,1/3] avcodec/movtextenc: Fix potential use of uninitialized value | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make warning Make failed

Commit Message

Andreas Rheinhardt Oct. 16, 2020, 3:17 a.m. UTC
It makes no sense to call the functions to write styl, hlit or hclr boxes
with a different box name than "styl", "hlit" or "hclr". Therefore this
commit inlines these values in the functions, removes the function
parameter containing the box's name and removes the (non obsolete) box
names from the list of boxes.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/movtextenc.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 3d0328d332..67d29a09ca 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -91,8 +91,7 @@  typedef struct {
 } MovTextContext;
 
 typedef struct {
-    uint32_t type;
-    void (*encode)(MovTextContext *s, uint32_t tsmb_type);
+    void (*encode)(MovTextContext *s);
 } Box;
 
 static void mov_text_cleanup(MovTextContext *s)
@@ -109,7 +108,7 @@  static void mov_text_cleanup(MovTextContext *s)
     }
 }
 
-static void encode_styl(MovTextContext *s, uint32_t tsmb_type)
+static void encode_styl(MovTextContext *s)
 {
     int j;
 
@@ -117,7 +116,7 @@  static void encode_styl(MovTextContext *s, uint32_t tsmb_type)
         uint8_t buf[12], *p = buf;
 
         bytestream_put_be32(&p, s->count * STYLE_RECORD_SIZE + SIZE_ADD);
-        bytestream_put_be32(&p, tsmb_type);
+        bytestream_put_be32(&p, MKBETAG('s','t','y','l'));
         bytestream_put_be16(&p, s->count);
         /*The above three attributes are hard coded for now
         but will come from ASS style in the future*/
@@ -139,13 +138,13 @@  static void encode_styl(MovTextContext *s, uint32_t tsmb_type)
     mov_text_cleanup(s);
 }
 
-static void encode_hlit(MovTextContext *s, uint32_t tsmb_type)
+static void encode_hlit(MovTextContext *s)
 {
     if (s->box_flags & HLIT_BOX) {
         uint8_t buf[12], *p = buf;
 
         bytestream_put_be32(&p, 12);
-        bytestream_put_be32(&p, tsmb_type);
+        bytestream_put_be32(&p, MKBETAG('h','l','i','t'));
         bytestream_put_be16(&p, s->hlit.start);
         bytestream_put_be16(&p, s->hlit.end);
 
@@ -153,13 +152,13 @@  static void encode_hlit(MovTextContext *s, uint32_t tsmb_type)
     }
 }
 
-static void encode_hclr(MovTextContext *s, uint32_t tsmb_type)
+static void encode_hclr(MovTextContext *s)
 {
     if (s->box_flags & HCLR_BOX) {
         uint8_t buf[12], *p = buf;
 
         bytestream_put_be32(&p, 12);
-        bytestream_put_be32(&p, tsmb_type);
+        bytestream_put_be32(&p, MKBETAG('h','c','l','r'));
         bytestream_put_be32(&p, s->hclr.color);
 
         av_bprint_append_any(&s->buffer, buf, 12);
@@ -167,9 +166,9 @@  static void encode_hclr(MovTextContext *s, uint32_t tsmb_type)
 }
 
 static const Box box_types[] = {
-    { MKBETAG('s','t','y','l'), encode_styl },
-    { MKBETAG('h','l','i','t'), encode_hlit },
-    { MKBETAG('h','c','l','r'), encode_hclr },
+    { encode_styl },
+    { encode_hlit },
+    { encode_hclr },
 };
 
 const static size_t box_count = FF_ARRAY_ELEMS(box_types);
@@ -702,7 +701,7 @@  static int mov_text_encode_frame(AVCodecContext *avctx, unsigned char *buf,
 #endif
 
         for (j = 0; j < box_count; j++) {
-            box_types[j].encode(s, box_types[j].type);
+            box_types[j].encode(s);
         }
     }