diff options
author | Aurelien Jacobs <aurel@gnuage.org> | 2010-11-24 20:53:27 +0000 |
---|---|---|
committer | Aurelien Jacobs <aurel@gnuage.org> | 2010-11-24 20:53:27 +0000 |
commit | 8ba5bf5a7c31604ed7b98ffc714898588bc5ccda (patch) | |
tree | b6b333f0a17e203eb1168e3a1bae190effab546b | |
parent | 459b06610ca91122dd8ff6824982d6fa54e23d8b (diff) | |
download | ffmpeg-8ba5bf5a7c31604ed7b98ffc714898588bc5ccda.tar.gz |
avidec: read some of the Nikon specific tags produced by Nikon cameras
Originally committed as revision 25821 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavformat/avidec.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 66c58d921e..d31af67620 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -301,6 +301,42 @@ static void avi_metadata_creation_time(AVMetadata **metadata, char *date) } } +static void avi_read_nikon(AVFormatContext *s, uint64_t end) +{ + while (url_ftell(s->pb) < end) { + uint32_t tag = get_le32(s->pb); + uint32_t size = get_le32(s->pb); + switch (tag) { + case MKTAG('n', 'c', 't', 'g'): { /* Nikon Tags */ + uint64_t tag_end = url_ftell(s->pb) + size; + while (url_ftell(s->pb) < tag_end) { + uint16_t tag = get_le16(s->pb); + uint16_t size = get_le16(s->pb); + const char *name = NULL; + char buffer[64] = {0}; + size -= get_buffer(s->pb, buffer, + FFMIN(size, sizeof(buffer)-1)); + switch (tag) { + case 0x03: name = "maker"; break; + case 0x04: name = "model"; break; + case 0x13: name = "creation_time"; + if (buffer[4] == ':' && buffer[7] == ':') + buffer[4] = buffer[7] = '-'; + break; + } + if (name) + av_metadata_set2(&s->metadata, name, buffer, 0); + url_fskip(s->pb, size); + } + break; + } + default: + url_fskip(s->pb, size); + break; + } + } +} + static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) { AVIContext *avi = s->priv_data; @@ -354,6 +390,8 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) } else if (tag1 == MKTAG('I', 'N', 'F', 'O')) avi_read_info(s, list_end); + else if (tag1 == MKTAG('n', 'c', 'd', 't')) + avi_read_nikon(s, list_end); break; case MKTAG('I', 'D', 'I', 'T'): { |