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

Submitted by Moritz Barsnick on Sept. 19, 2018, 1:58 p.m.

Details

Message ID 34079525021f9afa22dfbae674203b85968be872.1537349317.git.barsnick@gmx.net
State New
Headers show

Commit Message

Moritz Barsnick Sept. 19, 2018, 1:58 p.m.
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@gmx.net>
---
 libavformat/movenc.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

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;
 }