From 43382b5f13d18c75ec284a48bd7352766810ed90 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Wed, 24 Feb 2010 06:27:12 +0000 Subject: Introduce metadata conversion table for NUT muxer and demuxer. 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 | 13 +++++++++++++ libavformat/nut.h | 3 +++ libavformat/nutdec.c | 1 + libavformat/nutenc.c | 14 ++++---------- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/libavformat/nut.c b/libavformat/nut.c index 6fdc298f8e..be6bcf6a42 100644 --- a/libavformat/nut.c +++ b/libavformat/nut.c @@ -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 }, +}; diff --git a/libavformat/nut.h b/libavformat/nut.h index a1081ed34c..35593e97b7 100644 --- a/libavformat/nut.h +++ b/libavformat/nut.h @@ -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 */ diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 564faf2030..ea2ac86554 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -915,5 +915,6 @@ AVInputFormat nut_demuxer = { nut_read_close, read_seek, .extensions = "nut", + .metadata_conv = ff_nut_metadata_conv, }; #endif diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c index 47d2dc5f3d..03d3712638 100644 --- a/libavformat/nutenc.c +++ b/libavformat/nutenc.c @@ -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, }; -- cgit v1.2.3