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
release/0.6
Anton Khirnov 15 years ago committed by Kostya Shishkov
parent c8c0ac6b26
commit 43382b5f13
  1. 13
      libavformat/nut.c
  2. 3
      libavformat/nut.h
  3. 1
      libavformat/nutdec.c
  4. 14
      libavformat/nutenc.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 },
};

@ -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 */

@ -915,5 +915,6 @@ AVInputFormat nut_demuxer = {
nut_read_close,
read_seek,
.extensions = "nut",
.metadata_conv = ff_nut_metadata_conv,
};
#endif

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

Loading…
Cancel
Save