changeset 5704:6b9c2a6d8fa4 libavformat

Introduce metadata conversion table for NUT muxer and demuxer. Patch by Anton Khirnov (wyskas, do no evil mail) Thread "[PATCH] nut metadata conversion table"
author kostya
date Wed, 24 Feb 2010 06:27:12 +0000
parents 07214788e1e1
children fabb2eb7d42c
files nut.c nut.h nutdec.c nutenc.c
diffstat 4 files changed, 21 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/nut.c	Tue Feb 23 16:29:57 2010 +0000
+++ b/nut.c	Wed Feb 24 06:27:12 2010 +0000
@@ -79,3 +79,16 @@
     {""            , 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 },
+};
--- a/nut.h	Tue Feb 23 16:29:57 2010 +0000
+++ b/nut.h	Wed Feb 24 06:27:12 2010 +0000
@@ -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 @@
 
 extern const Dispositions ff_nut_dispositions[];
 
+extern const AVMetadataConv ff_nut_metadata_conv[];
+
 #endif /* AVFORMAT_NUT_H */
--- a/nutdec.c	Tue Feb 23 16:29:57 2010 +0000
+++ b/nutdec.c	Wed Feb 24 06:27:12 2010 +0000
@@ -915,5 +915,6 @@
     nut_read_close,
     read_seek,
     .extensions = "nut",
+    .metadata_conv = ff_nut_metadata_conv,
 };
 #endif
--- a/nutenc.c	Tue Feb 23 16:29:57 2010 +0000
+++ b/nutenc.c	Wed Feb 24 06:27:12 2010 +0000
@@ -448,7 +448,7 @@
 
 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 @@
     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 @@
     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,
 };