diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-11-28 01:07:11 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-11-28 01:07:11 +0100 |
commit | 1e19927f12a2a65954aabf38b584025beff15cc3 (patch) | |
tree | 33c88297cb164490ebe38b67cf353029d9fb83f2 /libavformat/riff.c | |
parent | ca55606a5127a9ddb10e4c1971c56e3e69bfd864 (diff) | |
parent | 1f948745c3cbe45c4ccd5d8996fc885d826bf3ff (diff) | |
download | ffmpeg-1e19927f12a2a65954aabf38b584025beff15cc3.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
vc1: use an enum for Frame Coding Mode
doc: cleanup filter section
indeo3: error out if no motion vector is set.
x86inc: Flag shufps as an floating-point instruction for the AVX emulation code.
mpegaudio: do not use init_static_data() for initializing tables.
musepack: fix signed shift overflow in mpc_read_packet()
mov: Make format string match variable type.
wmavoice: Make format string match variable type.
vc1: select interlaced scan table by FCM element
Generalize RIFF INFO tag support; support reading INFO tag in wav
pthread: track thread existence in a separate variable.
Conflicts:
doc/filters.texi
libavcodec/pthread.c
libavformat/avi.c
libavformat/riff.c
libavformat/riff.h
libavformat/wav.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/riff.c')
-rw-r--r-- | libavformat/riff.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/libavformat/riff.c b/libavformat/riff.c index 3acf80bb89..6c8d8abe40 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -357,6 +357,28 @@ const AVCodecGuid ff_codec_wav_guids[] = { {CODEC_ID_NONE} }; +const AVMetadataConv ff_riff_info_conv[] = { + { "IART", "artist" }, + { "ICMT", "comment" }, + { "ICOP", "copyright" }, + { "ICRD", "date" }, + { "IGNR", "genre" }, + { "ILNG", "language" }, + { "INAM", "title" }, + { "IPRD", "album" }, + { "IPRT", "track" }, + { "ISFT", "encoder" }, + { "ITCH", "encoded_by"}, + { 0 }, +}; + +const char ff_riff_tags[][5] = { + "IARL", "IART", "ICMS", "ICMT", "ICOP", "ICRD", "ICRP", "IDIM", "IDPI", + "IENG", "IGNR", "IKEY", "ILGT", "ILNG", "IMED", "INAM", "IPLT", "IPRD", + "IPRT", "ISBJ", "ISFT", "ISHP", "ISRC", "ISRF", "ITCH", + {0} +}; + #if CONFIG_MUXERS int64_t ff_start_tag(AVIOContext *pb, const char *tag) { @@ -656,3 +678,49 @@ enum CodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid) } return CODEC_ID_NONE; } + +int ff_read_riff_info(AVFormatContext *s, int64_t size) +{ + int64_t start, end, cur; + AVIOContext *pb = s->pb; + + start = avio_tell(pb); + end = start + size; + + while ((cur = avio_tell(pb)) >= 0 && cur <= end - 8 /* = tag + size */) { + uint32_t chunk_code; + int64_t chunk_size; + char key[5] = {0}; + char *value; + + chunk_code = avio_rl32(pb); + chunk_size = avio_rl32(pb); + if (chunk_size > end || end - chunk_size < cur || chunk_size == UINT_MAX) { + av_log(s, AV_LOG_ERROR, "too big INFO subchunk\n"); + return AVERROR_INVALIDDATA; + } + + chunk_size += (chunk_size & 1); + + value = av_malloc(chunk_size + 1); + if (!value) { + av_log(s, AV_LOG_ERROR, "out of memory, unable to read INFO tag\n"); + return AVERROR(ENOMEM); + } + + AV_WL32(key, chunk_code); + + if (avio_read(pb, value, chunk_size) != chunk_size) { + av_freep(key); + av_freep(value); + av_log(s, AV_LOG_ERROR, "premature end of file while reading INFO tag\n"); + return AVERROR_INVALIDDATA; + } + + value[chunk_size] = 0; + + av_dict_set(&s->metadata, key, value, AV_DICT_DONT_STRDUP_VAL); + } + + return 0; +} |