Introduce metadata conversion table for NUT muxer and demuxer.
authorAnton Khirnov <wyskas@gmail.com>
Wed, 24 Feb 2010 06:27:12 +0000 (06:27 +0000)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Wed, 24 Feb 2010 06:27:12 +0000 (06:27 +0000)
Patch by Anton Khirnov (wyskas, do no evil mail)
Thread "[PATCH] nut metadata conversion table"

Originally committed as revision 22015 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavformat/nut.c
libavformat/nut.h
libavformat/nutdec.c
libavformat/nutenc.c

index 6fdc298f8e9fbddc7183c8e664da5c850943fe33..be6bcf6a42af28e1e005c8d4138ca76373245d06 100644 (file)
@@ -79,3 +79,16 @@ const Dispositions ff_nut_dispositions[] = {
     {""            , 0}
 };
 
+const AVMetadataConv ff_nut_metadata_conv[] = {
+    { "Author",         "artist"      },
+    { "X-CreationTime", "date"        },
+    { "CreationTime",   "date"        },
+    { "SourceFilename", "filename"    },
+    { "X-Language",     "language"    },
+    { "X-Disposition",  "disposition" },
+    { "X-Replaces",     "replaces"    },
+    { "X-Depends",      "depends"     },
+    { "X-Uses",         "uses"        },
+    { "X-UsesFont",     "usesfont"    },
+    { 0 },
+};
index a1081ed34cbed5903d1df7f68e0473e8d6740b05..35593e97b7b7291309a65d6652447cc342ded90e 100644 (file)
@@ -27,6 +27,7 @@
 //#include "libavcodec/mpegaudio.h"
 #include "avformat.h"
 #include "riff.h"
+#include "metadata.h"
 
 #define      MAIN_STARTCODE (0x7A561F5F04ADULL + (((uint64_t)('N'<<8) + 'M')<<48))
 #define    STREAM_STARTCODE (0x11405BF2F9DBULL + (((uint64_t)('N'<<8) + 'S')<<48))
@@ -112,4 +113,6 @@ void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts);
 
 extern const Dispositions ff_nut_dispositions[];
 
+extern const AVMetadataConv ff_nut_metadata_conv[];
+
 #endif /* AVFORMAT_NUT_H */
index 564faf2030ac0a4e64b442e3abc802da2d112a24..ea2ac865549c3b81f2a55085ac71f15a2f4cac08 100644 (file)
@@ -915,5 +915,6 @@ AVInputFormat nut_demuxer = {
     nut_read_close,
     read_seek,
     .extensions = "nut",
+    .metadata_conv = ff_nut_metadata_conv,
 };
 #endif
index 47d2dc5f3d8ecb3ea6b7d70720c338796e1946db..03d3712638b478393a4f882df609f4188da99edf 100644 (file)
@@ -448,7 +448,7 @@ static int add_info(ByteIOContext *bc, const char *type, const char *value){
 
 static int write_globalinfo(NUTContext *nut, ByteIOContext *bc){
     AVFormatContext *s= nut->avf;
-    AVMetadataTag *title, *author, *copyright;
+    AVMetadataTag *t = NULL;
     ByteIOContext *dyn_bc;
     uint8_t *dyn_buf=NULL;
     int count=0, dyn_size;
@@ -456,15 +456,8 @@ static int write_globalinfo(NUTContext *nut, ByteIOContext *bc){
     if(ret < 0)
         return ret;
 
-    title     = av_metadata_get(s->metadata, "Title"    , NULL, 0);
-    author    = av_metadata_get(s->metadata, "Author"   , NULL, 0);
-    copyright = av_metadata_get(s->metadata, "Copyright", NULL, 0);
-
-    if(title    ) count+= add_info(dyn_bc, "Title"    , title->value);
-    if(author   ) count+= add_info(dyn_bc, "Author"   , author->value);
-    if(copyright) count+= add_info(dyn_bc, "Copyright", copyright->value);
-    if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
-                        count+= add_info(dyn_bc, "Encoder"  , LIBAVFORMAT_IDENT);
+    while ((t = av_metadata_get(s->metadata, "", t, AV_METADATA_IGNORE_SUFFIX)))
+        count += add_info(dyn_bc, t->key, t->value);
 
     put_v(bc, 0); //stream_if_plus1
     put_v(bc, 0); //chapter_id
@@ -827,4 +820,5 @@ AVOutputFormat nut_muxer = {
     write_trailer,
     .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
     .codec_tag= (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, ff_nut_subtitle_tags, 0},
+    .metadata_conv = ff_nut_metadata_conv,
 };