diff options
author | Peter Ross <pross@xvid.org> | 2011-04-05 20:36:55 +1000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-04-07 17:54:52 +0200 |
commit | 36ffabc4eeab2e4489e83d874c19b86a4b44d25a (patch) | |
tree | 6b8da2f83aafaad5511e65315dfe5217dfd53002 | |
parent | c1309b27d2fc57a18a22336c7812874191b2bdac (diff) | |
download | ffmpeg-36ffabc4eeab2e4489e83d874c19b86a4b44d25a.tar.gz |
move PRI_GUID, ARG_GUID, AVCodecGuid, ff_codec_guid_get_id, MEDIASUBTYPE_BASE_GUID and audio_guids[] to riff.c/h (add FF_ prefix to PRI_GUID, ARG_GUID, and MEDIASUBTYPE_BASE_GUID; rename audio_guids to ff_codec_wav_guids)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/riff.c | 17 | ||||
-rw-r--r-- | libavformat/riff.h | 17 | ||||
-rw-r--r-- | libavformat/wtv.c | 70 |
3 files changed, 54 insertions, 50 deletions
diff --git a/libavformat/riff.c b/libavformat/riff.c index b0a89de7a1..03dda1fc6a 100644 --- a/libavformat/riff.c +++ b/libavformat/riff.c @@ -320,6 +320,13 @@ const AVCodecTag ff_codec_wav_tags[] = { { CODEC_ID_NONE, 0 }, }; +const AVCodecGuid ff_codec_wav_guids[] = { + {CODEC_ID_AC3, {0x2C,0x80,0x6D,0xE0,0x46,0xDB,0xCF,0x11,0xB4,0xD1,0x00,0x80,0x5F,0x6C,0xBB,0xEA}}, + {CODEC_ID_EAC3, {0xAF,0x87,0xFB,0xA7,0x02,0x2D,0xFB,0x42,0xA4,0xD4,0x05,0xCD,0x93,0x84,0x3B,0xDD}}, + {CODEC_ID_MP2, {0x2B,0x80,0x6D,0xE0,0x46,0xDB,0xCF,0x11,0xB4,0xD1,0x00,0x80,0x5F,0x6C,0xBB,0xEA}}, + {CODEC_ID_NONE} +}; + #if CONFIG_MUXERS int64_t ff_start_tag(AVIOContext *pb, const char *tag) { @@ -590,3 +597,13 @@ void ff_get_guid(AVIOContext *s, ff_asf_guid *g) assert(sizeof(*g) == 16); avio_read(s, *g, sizeof(*g)); } + +enum CodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid) +{ + int i; + for (i = 0; guids[i].id != CODEC_ID_NONE; i++) { + if (!ff_guidcmp(guids[i].guid, guid)) + return guids[i].id; + } + return CODEC_ID_NONE; +} diff --git a/libavformat/riff.h b/libavformat/riff.h index c8a47e0af7..d5e1cdf7d8 100644 --- a/libavformat/riff.h +++ b/libavformat/riff.h @@ -56,6 +56,11 @@ void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssiz typedef uint8_t ff_asf_guid[16]; +#define FF_PRI_GUID \ + "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" +#define FF_ARG_GUID(g) \ + g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7],g[8],g[9],g[10],g[11],g[12],g[13],g[14],g[15] + static av_always_inline int ff_guidcmp(const void *g1, const void *g2) { return memcmp(g1, g2, sizeof(ff_asf_guid)); @@ -63,4 +68,16 @@ static av_always_inline int ff_guidcmp(const void *g1, const void *g2) void ff_get_guid(AVIOContext *s, ff_asf_guid *g); +typedef struct { + enum CodecID id; + ff_asf_guid guid; +} AVCodecGuid; + +enum CodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid); + +extern const AVCodecGuid ff_codec_wav_guids[]; + +#define FF_MEDIASUBTYPE_BASE_GUID \ + 0x00,0x00,0x10,0x00,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71 + #endif /* AVFORMAT_RIFF_H */ diff --git a/libavformat/wtv.c b/libavformat/wtv.c index 110366fc1a..756ba93e7a 100644 --- a/libavformat/wtv.c +++ b/libavformat/wtv.c @@ -35,11 +35,6 @@ #include <strings.h> /* Macros for formating GUIDs */ -#define PRI_GUID \ - "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" -#define ARG_GUID(g) \ - g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7],g[8],g[9],g[10],g[11],g[12],g[13],g[14],g[15] - #define PRI_PRETTY_GUID \ "%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x" #define ARG_PRETTY_GUID(g) \ @@ -266,8 +261,8 @@ static AVIOContext * wtvfile_open2(AVFormatContext *s, const uint8_t *buf, int b uint64_t file_length; const uint8_t *name; if (ff_guidcmp(buf, dir_entry_guid)) { - av_log(s, AV_LOG_ERROR, "unknown guid "PRI_GUID", expected dir_entry_guid; " - "remaining directory entries ignored\n", ARG_GUID(buf)); + av_log(s, AV_LOG_ERROR, "unknown guid "FF_PRI_GUID", expected dir_entry_guid; " + "remaining directory entries ignored\n", FF_ARG_GUID(buf)); break; } dir_length = AV_RL16(buf + 16); @@ -328,21 +323,6 @@ typedef struct { unsigned int index_entries_allocated_size; } WtvContext; -typedef struct { - enum CodecID id; - ff_asf_guid guid; -} AVCodecGuid; - -static enum CodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid) -{ - int i; - for (i = 0; guids[i].id != CODEC_ID_NONE; i++) { - if (!ff_guidcmp(guids[i].guid, guid)) - return guids[i].id; - } - return CODEC_ID_NONE; -} - /* WTV GUIDs */ static const ff_asf_guid wtv_guid = {0xB7,0xD8,0x00,0x20,0x37,0x49,0xDA,0x11,0xA6,0x4E,0x00,0x07,0xE9,0x5E,0xAD,0x8D}; @@ -377,14 +357,11 @@ static const ff_asf_guid EVENTID_AudioTypeSpanningEvent = /* Windows media GUIDs */ -#define MEDIASUBTYPE_BASE_GUID \ - 0x00,0x00,0x10,0x00,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71 - /* Media types */ static const ff_asf_guid mediatype_audio = - {'a','u','d','s',MEDIASUBTYPE_BASE_GUID}; + {'a','u','d','s',FF_MEDIASUBTYPE_BASE_GUID}; static const ff_asf_guid mediatype_video = - {'v','i','d','s',MEDIASUBTYPE_BASE_GUID}; + {'v','i','d','s',FF_MEDIASUBTYPE_BASE_GUID}; static const ff_asf_guid mediasubtype_mpeg1payload = {0x81,0xEB,0x36,0xE4,0x4F,0x52,0xCE,0x11,0x9F,0x53,0x00,0x20,0xAF,0x0B,0xA7,0x70}; static const ff_asf_guid mediatype_mpeg2_sections = @@ -423,13 +400,6 @@ static const AVCodecGuid video_guids[] = { {CODEC_ID_NONE} }; -static const AVCodecGuid audio_guids[] = { - {CODEC_ID_AC3, {0x2C,0x80,0x6D,0xE0,0x46,0xDB,0xCF,0x11,0xB4,0xD1,0x00,0x80,0x5F,0x6C,0xBB,0xEA}}, - {CODEC_ID_EAC3, {0xAF,0x87,0xFB,0xA7,0x02,0x2D,0xFB,0x42,0xA4,0xD4,0x05,0xCD,0x93,0x84,0x3B,0xDD}}, - {CODEC_ID_MP2, {0x2B,0x80,0x6D,0xE0,0x46,0xDB,0xCF,0x11,0xB4,0xD1,0x00,0x80,0x5F,0x6C,0xBB,0xEA}}, - {CODEC_ID_NONE} -}; - static int read_probe(AVProbeData *p) { return ff_guidcmp(p->buf, wtv_guid) ? 0 : AVPROBE_SCORE_MAX; @@ -562,8 +532,8 @@ static void parse_legacy_attrib(AVFormatContext *s, AVIOContext *pb) if (!length) break; if (ff_guidcmp(&guid, metadata_guid)) { - av_log(s, AV_LOG_WARNING, "unknown guid "PRI_GUID", expected metadata_guid; " - "remaining metadata entries ignored\n", ARG_GUID(guid)); + av_log(s, AV_LOG_WARNING, "unknown guid "FF_PRI_GUID", expected metadata_guid; " + "remaining metadata entries ignored\n", FF_ARG_GUID(guid)); break; } avio_get_str16le(pb, INT_MAX, key, sizeof(key)); @@ -678,11 +648,11 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid, ff_get_wav_header(pb, st->codec, size); } else { if (ff_guidcmp(formattype, format_none)) - av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype)); + av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype)); avio_skip(pb, size); } - if (!memcmp(subtype + 4, (const uint8_t[]){MEDIASUBTYPE_BASE_GUID}, 12)) { + if (!memcmp(subtype + 4, (const uint8_t[]){FF_MEDIASUBTYPE_BASE_GUID}, 12)) { st->codec->codec_id = ff_wav_codec_get_id(AV_RL32(subtype), st->codec->bits_per_coded_sample); } else if (!ff_guidcmp(subtype, mediasubtype_mpeg1payload)) { if (st->codec->extradata && st->codec->extradata_size >= 22) @@ -690,9 +660,9 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid, else av_log(s, AV_LOG_WARNING, "MPEG1WAVEFORMATEX underflow\n"); } else { - st->codec->codec_id = ff_codec_guid_get_id(audio_guids, subtype); + st->codec->codec_id = ff_codec_guid_get_id(ff_codec_wav_guids, subtype); if (st->codec->codec_id == CODEC_ID_NONE) - av_log(s, AV_LOG_WARNING, "unknown subtype:"PRI_GUID"\n", ARG_GUID(subtype)); + av_log(s, AV_LOG_WARNING, "unknown subtype:"FF_PRI_GUID"\n", FF_ARG_GUID(subtype)); } return st; } else if (!ff_guidcmp(mediatype, mediatype_video)) { @@ -707,17 +677,17 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid, avio_skip(pb, FFMAX(size - consumed, 0)); } else { if (ff_guidcmp(formattype, format_none)) - av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype)); + av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype)); avio_skip(pb, size); } - if (!memcmp(subtype + 4, (const uint8_t[]){MEDIASUBTYPE_BASE_GUID}, 12)) { + if (!memcmp(subtype + 4, (const uint8_t[]){FF_MEDIASUBTYPE_BASE_GUID}, 12)) { st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, AV_RL32(subtype)); } else { st->codec->codec_id = ff_codec_guid_get_id(video_guids, subtype); } if (st->codec->codec_id == CODEC_ID_NONE) - av_log(s, AV_LOG_WARNING, "unknown subtype:"PRI_GUID"\n", ARG_GUID(subtype)); + av_log(s, AV_LOG_WARNING, "unknown subtype:"FF_PRI_GUID"\n", FF_ARG_GUID(subtype)); return st; } else if (!ff_guidcmp(mediatype, mediatype_mpeg2_pes) && !ff_guidcmp(subtype, mediasubtype_dvb_subtitle)) { @@ -725,7 +695,7 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid, if (!st) return NULL; if (ff_guidcmp(formattype, format_none)) - av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype)); + av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype)); avio_skip(pb, size); st->codec->codec_id = CODEC_ID_DVB_SUBTITLE; return st; @@ -735,21 +705,21 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid, if (!st) return NULL; if (ff_guidcmp(formattype, format_none)) - av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype)); + av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype)); avio_skip(pb, size); st->codec->codec_id = CODEC_ID_DVB_TELETEXT; return st; } else if (!ff_guidcmp(mediatype, mediatype_mpeg2_sections) && !ff_guidcmp(subtype, mediasubtype_mpeg2_sections)) { if (ff_guidcmp(formattype, format_none)) - av_log(s, AV_LOG_WARNING, "unknown formattype:"PRI_GUID"\n", ARG_GUID(formattype)); + av_log(s, AV_LOG_WARNING, "unknown formattype:"FF_PRI_GUID"\n", FF_ARG_GUID(formattype)); avio_skip(pb, size); return NULL; } - av_log(s, AV_LOG_WARNING, "unknown media type, mediatype:"PRI_GUID - ", subtype:"PRI_GUID", formattype:"PRI_GUID"\n", - ARG_GUID(mediatype), ARG_GUID(subtype), ARG_GUID(formattype)); + av_log(s, AV_LOG_WARNING, "unknown media type, mediatype:"FF_PRI_GUID + ", subtype:"FF_PRI_GUID", formattype:"FF_PRI_GUID"\n", + FF_ARG_GUID(mediatype), FF_ARG_GUID(subtype), FF_ARG_GUID(formattype)); avio_skip(pb, size); return NULL; } @@ -921,7 +891,7 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p !ff_guidcmp(g, (const ff_asf_guid){0xA1,0xC3,0xD2,0xC2,0x7E,0x9A,0xDA,0x11,0x8B,0xF7,0x00,0x07,0xE9,0x5E,0xAD,0x8D})) { //ignore known guids } else - av_log(s, AV_LOG_WARNING, "unsupported chunk:"PRI_GUID"\n", ARG_GUID(g)); + av_log(s, AV_LOG_WARNING, "unsupported chunk:"FF_PRI_GUID"\n", FF_ARG_GUID(g)); avio_skip(pb, WTV_PAD8(len) - consumed); } |