[FFmpeg-devel] [PATCH 1/3] avformat/movenc: allow padding to two bytes in mov_write_int8_metadata()

Moritz Barsnick barsnick at gmx.net
Wed Sep 19 16:58:30 EEST 2018


Padding to four bytes was already possible. This is in preparation for
being able to also write 16-bit integer atoms (and other currently
unneeded scenarios).

Signed-off-by: Moritz Barsnick <barsnick at gmx.net>
---
 libavformat/movenc.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6b9c012bc6..7c326faa49 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3461,7 +3461,7 @@ static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb,
     uint8_t num;
     int size = 24 + len;
 
-    if (len != 1 && len != 4)
+    if (len != 1 && len != 2 && len != 4)
         return -1;
 
     if (!(t = av_dict_get(s->metadata, tag, NULL, 0)))
@@ -3470,12 +3470,14 @@ static int mov_write_int8_metadata(AVFormatContext *s, AVIOContext *pb,
 
     avio_wb32(pb, size);
     ffio_wfourcc(pb, name);
-    avio_wb32(pb, size - 8);
+    avio_wb32(pb, size - 8);  // size
     ffio_wfourcc(pb, "data");
-    avio_wb32(pb, 0x15);
+    avio_wb32(pb, 0x15);      // type specifier
     avio_wb32(pb, 0);
-    if (len==4) avio_wb32(pb, num);
-    else        avio_w8 (pb, num);
+    // data:
+    if      (len == 4) avio_wb32(pb, num);
+    else if (len == 2) avio_wb16(pb, num);
+    else               avio_w8  (pb, num);
 
     return size;
 }
-- 
2.14.4



More information about the ffmpeg-devel mailing list