Commit 36ffabc4 authored by Peter Ross's avatar Peter Ross Committed by Michael Niedermayer

move PRI_GUID, ARG_GUID, AVCodecGuid, ff_codec_guid_get_id,...

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: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent c1309b27
...@@ -320,6 +320,13 @@ const AVCodecTag ff_codec_wav_tags[] = { ...@@ -320,6 +320,13 @@ const AVCodecTag ff_codec_wav_tags[] = {
{ CODEC_ID_NONE, 0 }, { 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 #if CONFIG_MUXERS
int64_t ff_start_tag(AVIOContext *pb, const char *tag) int64_t ff_start_tag(AVIOContext *pb, const char *tag)
{ {
...@@ -590,3 +597,13 @@ void ff_get_guid(AVIOContext *s, ff_asf_guid *g) ...@@ -590,3 +597,13 @@ void ff_get_guid(AVIOContext *s, ff_asf_guid *g)
assert(sizeof(*g) == 16); assert(sizeof(*g) == 16);
avio_read(s, *g, sizeof(*g)); 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;
}
...@@ -56,6 +56,11 @@ void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssiz ...@@ -56,6 +56,11 @@ void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssiz
typedef uint8_t ff_asf_guid[16]; 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) static av_always_inline int ff_guidcmp(const void *g1, const void *g2)
{ {
return memcmp(g1, g2, sizeof(ff_asf_guid)); 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) ...@@ -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); 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 */ #endif /* AVFORMAT_RIFF_H */
...@@ -35,11 +35,6 @@ ...@@ -35,11 +35,6 @@
#include <strings.h> #include <strings.h>
/* Macros for formating GUIDs */ /* 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 \ #define PRI_PRETTY_GUID \
"%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x" "%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x"
#define ARG_PRETTY_GUID(g) \ #define ARG_PRETTY_GUID(g) \
...@@ -266,8 +261,8 @@ static AVIOContext * wtvfile_open2(AVFormatContext *s, const uint8_t *buf, int b ...@@ -266,8 +261,8 @@ static AVIOContext * wtvfile_open2(AVFormatContext *s, const uint8_t *buf, int b
uint64_t file_length; uint64_t file_length;
const uint8_t *name; const uint8_t *name;
if (ff_guidcmp(buf, dir_entry_guid)) { if (ff_guidcmp(buf, dir_entry_guid)) {
av_log(s, AV_LOG_ERROR, "unknown guid "PRI_GUID", expected dir_entry_guid; " av_log(s, AV_LOG_ERROR, "unknown guid "FF_PRI_GUID", expected dir_entry_guid; "
"remaining directory entries ignored\n", ARG_GUID(buf)); "remaining directory entries ignored\n", FF_ARG_GUID(buf));
break; break;
} }
dir_length = AV_RL16(buf + 16); dir_length = AV_RL16(buf + 16);
...@@ -328,21 +323,6 @@ typedef struct { ...@@ -328,21 +323,6 @@ typedef struct {
unsigned int index_entries_allocated_size; unsigned int index_entries_allocated_size;
} WtvContext; } 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 */ /* WTV GUIDs */
static const ff_asf_guid wtv_guid = static const ff_asf_guid wtv_guid =
{0xB7,0xD8,0x00,0x20,0x37,0x49,0xDA,0x11,0xA6,0x4E,0x00,0x07,0xE9,0x5E,0xAD,0x8D}; {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 = ...@@ -377,14 +357,11 @@ static const ff_asf_guid EVENTID_AudioTypeSpanningEvent =
/* Windows media GUIDs */ /* Windows media GUIDs */
#define MEDIASUBTYPE_BASE_GUID \
0x00,0x00,0x10,0x00,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71
/* Media types */ /* Media types */
static const ff_asf_guid mediatype_audio = 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 = 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 = static const ff_asf_guid mediasubtype_mpeg1payload =
{0x81,0xEB,0x36,0xE4,0x4F,0x52,0xCE,0x11,0x9F,0x53,0x00,0x20,0xAF,0x0B,0xA7,0x70}; {0x81,0xEB,0x36,0xE4,0x4F,0x52,0xCE,0x11,0x9F,0x53,0x00,0x20,0xAF,0x0B,0xA7,0x70};
static const ff_asf_guid mediatype_mpeg2_sections = static const ff_asf_guid mediatype_mpeg2_sections =
...@@ -423,13 +400,6 @@ static const AVCodecGuid video_guids[] = { ...@@ -423,13 +400,6 @@ static const AVCodecGuid video_guids[] = {
{CODEC_ID_NONE} {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) static int read_probe(AVProbeData *p)
{ {
return ff_guidcmp(p->buf, wtv_guid) ? 0 : AVPROBE_SCORE_MAX; return ff_guidcmp(p->buf, wtv_guid) ? 0 : AVPROBE_SCORE_MAX;
...@@ -562,8 +532,8 @@ static void parse_legacy_attrib(AVFormatContext *s, AVIOContext *pb) ...@@ -562,8 +532,8 @@ static void parse_legacy_attrib(AVFormatContext *s, AVIOContext *pb)
if (!length) if (!length)
break; break;
if (ff_guidcmp(&guid, metadata_guid)) { if (ff_guidcmp(&guid, metadata_guid)) {
av_log(s, AV_LOG_WARNING, "unknown guid "PRI_GUID", expected metadata_guid; " av_log(s, AV_LOG_WARNING, "unknown guid "FF_PRI_GUID", expected metadata_guid; "
"remaining metadata entries ignored\n", ARG_GUID(guid)); "remaining metadata entries ignored\n", FF_ARG_GUID(guid));
break; break;
} }
avio_get_str16le(pb, INT_MAX, key, sizeof(key)); avio_get_str16le(pb, INT_MAX, key, sizeof(key));
...@@ -678,11 +648,11 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid, ...@@ -678,11 +648,11 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
ff_get_wav_header(pb, st->codec, size); ff_get_wav_header(pb, st->codec, size);
} else { } else {
if (ff_guidcmp(formattype, format_none)) 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); 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); 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)) { } else if (!ff_guidcmp(subtype, mediasubtype_mpeg1payload)) {
if (st->codec->extradata && st->codec->extradata_size >= 22) if (st->codec->extradata && st->codec->extradata_size >= 22)
...@@ -690,9 +660,9 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid, ...@@ -690,9 +660,9 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
else else
av_log(s, AV_LOG_WARNING, "MPEG1WAVEFORMATEX underflow\n"); av_log(s, AV_LOG_WARNING, "MPEG1WAVEFORMATEX underflow\n");
} else { } 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) 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; return st;
} else if (!ff_guidcmp(mediatype, mediatype_video)) { } else if (!ff_guidcmp(mediatype, mediatype_video)) {
...@@ -707,17 +677,17 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid, ...@@ -707,17 +677,17 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
avio_skip(pb, FFMAX(size - consumed, 0)); avio_skip(pb, FFMAX(size - consumed, 0));
} else { } else {
if (ff_guidcmp(formattype, format_none)) 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); 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)); st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, AV_RL32(subtype));
} else { } else {
st->codec->codec_id = ff_codec_guid_get_id(video_guids, subtype); st->codec->codec_id = ff_codec_guid_get_id(video_guids, subtype);
} }
if (st->codec->codec_id == CODEC_ID_NONE) 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; return st;
} else if (!ff_guidcmp(mediatype, mediatype_mpeg2_pes) && } else if (!ff_guidcmp(mediatype, mediatype_mpeg2_pes) &&
!ff_guidcmp(subtype, mediasubtype_dvb_subtitle)) { !ff_guidcmp(subtype, mediasubtype_dvb_subtitle)) {
...@@ -725,7 +695,7 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid, ...@@ -725,7 +695,7 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
if (!st) if (!st)
return NULL; return NULL;
if (ff_guidcmp(formattype, format_none)) 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); avio_skip(pb, size);
st->codec->codec_id = CODEC_ID_DVB_SUBTITLE; st->codec->codec_id = CODEC_ID_DVB_SUBTITLE;
return st; return st;
...@@ -735,21 +705,21 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid, ...@@ -735,21 +705,21 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
if (!st) if (!st)
return NULL; return NULL;
if (ff_guidcmp(formattype, format_none)) 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); avio_skip(pb, size);
st->codec->codec_id = CODEC_ID_DVB_TELETEXT; st->codec->codec_id = CODEC_ID_DVB_TELETEXT;
return st; return st;
} else if (!ff_guidcmp(mediatype, mediatype_mpeg2_sections) && } else if (!ff_guidcmp(mediatype, mediatype_mpeg2_sections) &&
!ff_guidcmp(subtype, mediasubtype_mpeg2_sections)) { !ff_guidcmp(subtype, mediasubtype_mpeg2_sections)) {
if (ff_guidcmp(formattype, format_none)) 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); avio_skip(pb, size);
return NULL; return NULL;
} }
av_log(s, AV_LOG_WARNING, "unknown media type, mediatype:"PRI_GUID av_log(s, AV_LOG_WARNING, "unknown media type, mediatype:"FF_PRI_GUID
", subtype:"PRI_GUID", formattype:"PRI_GUID"\n", ", subtype:"FF_PRI_GUID", formattype:"FF_PRI_GUID"\n",
ARG_GUID(mediatype), ARG_GUID(subtype), ARG_GUID(formattype)); FF_ARG_GUID(mediatype), FF_ARG_GUID(subtype), FF_ARG_GUID(formattype));
avio_skip(pb, size); avio_skip(pb, size);
return NULL; return NULL;
} }
...@@ -921,7 +891,7 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p ...@@ -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})) { !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 //ignore known guids
} else } 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); avio_skip(pb, WTV_PAD8(len) - consumed);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment