From: Aurelien Jacobs Date: Wed, 24 Nov 2010 20:53:27 +0000 (+0000) Subject: avidec: read some of the Nikon specific tags produced by Nikon cameras X-Git-Tag: v0.7b1~1525 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8ba5bf5a7c31604ed7b98ffc714898588bc5ccda;p=platform%2Fupstream%2Flibav.git avidec: read some of the Nikon specific tags produced by Nikon cameras Originally committed as revision 25821 to svn://svn.ffmpeg.org/ffmpeg/trunk --- diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 66c58d9..d31af67 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'): {