[FFmpeg-devel] [PATCH] movenc.c: fix metadata writing.

Ronald S. Bultje rsbultje
Fri Mar 4 03:31:26 CET 2011


Fix metadata writing, broken in commit:
0abdb2931719d96dee725e555e9b46b2b2f8a6be
because some characters in the string are >=0x80 and therefore the
shift on characters in the fourcc broke down because of sign extension.
---
 libavformat/movenc.c |   58 +++++++++++++++++++++++++-------------------------
 1 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 231976b..1e6aec9 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1472,12 +1472,12 @@ static int mov_write_string_data_tag(AVIOContext *pb, const char *data, int lang
     }
 }
 
-static int mov_write_string_tag(AVIOContext *pb, const char *name, const char *value, int lang, int long_style){
+static int mov_write_string_tag(AVIOContext *pb, uint32_t name, const char *value, int lang, int long_style){
     int size = 0;
     if (value && value[0]) {
         int64_t pos = url_ftell(pb);
         avio_wb32(pb, 0); /* size */
-        ffio_wfourcc(pb, name);
+        avio_wl32(pb, name);
         mov_write_string_data_tag(pb, value, lang, long_style);
         size= updateSize(pb, pos);
     }
@@ -1485,7 +1485,7 @@ static int mov_write_string_tag(AVIOContext *pb, const char *name, const char *v
 }
 
 static int mov_write_string_metadata(AVFormatContext *s, AVIOContext *pb,
-                                     const char *name, const char *tag,
+                                     uint32_t name, const char *tag,
                                      int long_style)
 {
     int l, lang = 0, len, len2;
@@ -1537,23 +1537,23 @@ static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov,
     int64_t pos = url_ftell(pb);
     avio_wb32(pb, 0); /* size */
     ffio_wfourcc(pb, "ilst");
-    mov_write_string_metadata(s, pb, "\251nam", "title"    , 1);
-    mov_write_string_metadata(s, pb, "\251ART", "artist"   , 1);
-    mov_write_string_metadata(s, pb, "aART", "album_artist", 1);
-    mov_write_string_metadata(s, pb, "\251wrt", "composer" , 1);
-    mov_write_string_metadata(s, pb, "\251alb", "album"    , 1);
-    mov_write_string_metadata(s, pb, "\251day", "date"     , 1);
-    mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 0, 1);
-    mov_write_string_metadata(s, pb, "\251cmt", "comment"  , 1);
-    mov_write_string_metadata(s, pb, "\251gen", "genre"    , 1);
-    mov_write_string_metadata(s, pb, "\251cpy", "copyright", 1);
-    mov_write_string_metadata(s, pb, "\251grp", "grouping" , 1);
-    mov_write_string_metadata(s, pb, "\251lyr", "lyrics"   , 1);
-    mov_write_string_metadata(s, pb, "desc",    "description",1);
-    mov_write_string_metadata(s, pb, "ldes",    "synopsis" , 1);
-    mov_write_string_metadata(s, pb, "tvsh",    "show"     , 1);
-    mov_write_string_metadata(s, pb, "tven",    "episode_id",1);
-    mov_write_string_metadata(s, pb, "tvnn",    "network"  , 1);
+    mov_write_string_metadata(s, pb, MKTAG(0xa9,'n','a','m'), "title"    , 1);
+    mov_write_string_metadata(s, pb, MKTAG(0xa9,'A','R','T'), "artist"   , 1);
+    mov_write_string_metadata(s, pb, MKTAG('a' ,'A','R','T'), "album_artist", 1);
+    mov_write_string_metadata(s, pb, MKTAG(0xa9,'w','r','t'), "composer" , 1);
+    mov_write_string_metadata(s, pb, MKTAG(0xa9,'a','l','b'), "album"    , 1);
+    mov_write_string_metadata(s, pb, MKTAG(0xa9,'d','a','y'), "date"     , 1);
+    mov_write_string_tag(pb, MKTAG(0xa9,'t','o','o'), LIBAVFORMAT_IDENT, 0, 1);
+    mov_write_string_metadata(s, pb, MKTAG(0xa9,'c','m','t'), "comment"  , 1);
+    mov_write_string_metadata(s, pb, MKTAG(0xa9,'g','e','n'), "genre"    , 1);
+    mov_write_string_metadata(s, pb, MKTAG(0xa9,'c','p','y'), "copyright", 1);
+    mov_write_string_metadata(s, pb, MKTAG(0xa9,'g','r','p'), "grouping" , 1);
+    mov_write_string_metadata(s, pb, MKTAG(0xa9,'l','y','r'), "lyrics"   , 1);
+    mov_write_string_metadata(s, pb, MKTAG('d' ,'e','s','c'), "description",1);
+    mov_write_string_metadata(s, pb, MKTAG('l' ,'d','e','s'), "synopsis" , 1);
+    mov_write_string_metadata(s, pb, MKTAG('t' ,'v','s','h'), "show"     , 1);
+    mov_write_string_metadata(s, pb, MKTAG('t' ,'v','e','n'), "episode_id",1);
+    mov_write_string_metadata(s, pb, MKTAG('t' ,'v','n','n'), "network"  , 1);
     mov_write_trkn_tag(pb, mov, s);
     return updateSize(pb, pos);
 }
@@ -1674,15 +1674,15 @@ static int mov_write_udta_tag(AVIOContext *pb, MOVMuxContext *mov,
             mov_write_3gp_udta_tag(pb_buf, s, "cprt", "copyright");
             mov_write_3gp_udta_tag(pb_buf, s, "yrrc", "date");
         } else if (mov->mode == MODE_MOV) { // the title field breaks gtkpod with mp4 and my suspicion is that stuff is not valid in mp4
-            mov_write_string_metadata(s, pb_buf, "\251ART", "artist"     , 0);
-            mov_write_string_metadata(s, pb_buf, "\251nam", "title"      , 0);
-            mov_write_string_metadata(s, pb_buf, "\251aut", "author"     , 0);
-            mov_write_string_metadata(s, pb_buf, "\251alb", "album"      , 0);
-            mov_write_string_metadata(s, pb_buf, "\251day", "date"       , 0);
-            mov_write_string_metadata(s, pb_buf, "\251swr", "encoder"    , 0);
-            mov_write_string_metadata(s, pb_buf, "\251des", "comment"    , 0);
-            mov_write_string_metadata(s, pb_buf, "\251gen", "genre"      , 0);
-            mov_write_string_metadata(s, pb_buf, "\251cpy", "copyright"  , 0);
+            mov_write_string_metadata(s, pb_buf, MKTAG(0xa9,'A','R','T'), "artist"     , 0);
+            mov_write_string_metadata(s, pb_buf, MKTAG(0xa9,'n','a','m'), "title"      , 0);
+            mov_write_string_metadata(s, pb_buf, MKTAG(0xa9,'a','u','t'), "author"     , 0);
+            mov_write_string_metadata(s, pb_buf, MKTAG(0xa9,'a','l','b'), "album"      , 0);
+            mov_write_string_metadata(s, pb_buf, MKTAG(0xa9,'d','a','y'), "date"       , 0);
+            mov_write_string_metadata(s, pb_buf, MKTAG(0xa9,'s','w','r'), "encoder"    , 0);
+            mov_write_string_metadata(s, pb_buf, MKTAG(0xa9,'d','e','s'), "comment"    , 0);
+            mov_write_string_metadata(s, pb_buf, MKTAG(0xa9,'g','e','n'), "genre"      , 0);
+            mov_write_string_metadata(s, pb_buf, MKTAG(0xa9,'c','p','y'), "copyright"  , 0);
         } else {
             /* iTunes meta data */
             mov_write_meta_tag(pb_buf, mov, s);
-- 
1.7.2.1




More information about the ffmpeg-devel mailing list