Skip to content

Commit

Permalink
Merge commit 'e544782623caf1eb4b2429e9c4f35d6b627accba'
Browse files Browse the repository at this point in the history
* commit 'e544782623caf1eb4b2429e9c4f35d6b627accba':
  riff: Move guid structs and helper functions into riff

Conflicts:
	libavformat/asf.h
	libavformat/riff.c
	libavformat/wtv.c

Merged-by: Michael Niedermayer <[email protected]>
  • Loading branch information
michaelni committed Apr 22, 2013
2 parents 369e5dc + e544782 commit 52e4015
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 44 deletions.
43 changes: 21 additions & 22 deletions libavformat/riff.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,11 @@ const AVCodecTag ff_codec_wav_tags[] = {
};

const AVCodecGuid ff_codec_wav_guids[] = {
{AV_CODEC_ID_AC3, {0x2C,0x80,0x6D,0xE0,0x46,0xDB,0xCF,0x11,0xB4,0xD1,0x00,0x80,0x5F,0x6C,0xBB,0xEA}},
{AV_CODEC_ID_ATRAC3P, {0xBF,0xAA,0x23,0xE9,0x58,0xCB,0x71,0x44,0xA1,0x19,0xFF,0xFA,0x01,0xE4,0xCE,0x62}},
{AV_CODEC_ID_EAC3, {0xAF,0x87,0xFB,0xA7,0x02,0x2D,0xFB,0x42,0xA4,0xD4,0x05,0xCD,0x93,0x84,0x3B,0xDD}},
{AV_CODEC_ID_MP2, {0x2B,0x80,0x6D,0xE0,0x46,0xDB,0xCF,0x11,0xB4,0xD1,0x00,0x80,0x5F,0x6C,0xBB,0xEA}},
{AV_CODEC_ID_NONE}
{ AV_CODEC_ID_AC3, { 0x2C, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB, 0xEA } },
{ AV_CODEC_ID_ATRAC3P, { 0xBF, 0xAA, 0x23, 0xE9, 0x58, 0xCB, 0x71, 0x44, 0xA1, 0x19, 0xFF, 0xFA, 0x01, 0xE4, 0xCE, 0x62 } },
{ AV_CODEC_ID_EAC3, { 0xAF, 0x87, 0xFB, 0xA7, 0x02, 0x2D, 0xFB, 0x42, 0xA4, 0xD4, 0x05, 0xCD, 0x93, 0x84, 0x3B, 0xDD } },
{ AV_CODEC_ID_MP2, { 0x2B, 0x80, 0x6D, 0xE0, 0x46, 0xDB, 0xCF, 0x11, 0xB4, 0xD1, 0x00, 0x80, 0x5F, 0x6C, 0xBB, 0xEA } },
{ AV_CODEC_ID_NONE }
};

const AVMetadataConv ff_riff_info_conv[] = {
Expand All @@ -443,6 +443,22 @@ const AVMetadataConv ff_riff_info_conv[] = {
{ 0 },
};

void ff_get_guid(AVIOContext *s, ff_asf_guid *g)
{
av_assert0(sizeof(*g) == 16); //compiler will optimize this out
if (avio_read(s, *g, sizeof(*g)) < (int)sizeof(*g))
memset(*g, 0, sizeof(*g));
}

enum AVCodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid)
{
int i;
for (i = 0; guids[i].id != AV_CODEC_ID_NONE; i++)
if (!ff_guidcmp(guids[i].guid, guid))
return guids[i].id;
return AV_CODEC_ID_NONE;
}

#if CONFIG_MUXERS
int64_t ff_start_tag(AVIOContext *pb, const char *tag)
{
Expand Down Expand Up @@ -841,23 +857,6 @@ int ff_get_bmp_header(AVIOContext *pb, AVStream *st, unsigned *esize)
return tag1;
}

void ff_get_guid(AVIOContext *s, ff_asf_guid *g)
{
av_assert0(sizeof(*g) == 16); //compiler will optimize this out
if (avio_read(s, *g, sizeof(*g)) < (int)sizeof(*g))
memset(*g, 0, sizeof(*g));
}

enum AVCodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid)
{
int i;
for (i = 0; guids[i].id != AV_CODEC_ID_NONE; i++) {
if (!ff_guidcmp(guids[i].guid, guid))
return guids[i].id;
}
return AV_CODEC_ID_NONE;
}

int ff_read_riff_info(AVFormatContext *s, int64_t size)
{
int64_t start, end, cur;
Expand Down
46 changes: 24 additions & 22 deletions libavformat/riff.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,36 @@ extern const AVCodecTag ff_codec_wav_tags[];

void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale);

int ff_read_riff_info(AVFormatContext *s, int64_t size);

/**
* Write all recognized RIFF tags from s->metadata
*/
void ff_riff_write_info(AVFormatContext *s);

/**
* Write a single RIFF info tag
*/
void ff_riff_write_info_tag(AVIOContext *pb, const char *tag, const char *str);

typedef uint8_t ff_asf_guid[16];

int ff_read_riff_info(AVFormatContext *s, int64_t size);
typedef struct AVCodecGuid {
enum AVCodecID id;
ff_asf_guid guid;
} AVCodecGuid;

extern const AVCodecGuid ff_codec_wav_guids[];

#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]
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 FF_MEDIASUBTYPE_BASE_GUID \
0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71

static av_always_inline int ff_guidcmp(const void *g1, const void *g2)
{
Expand All @@ -72,26 +94,6 @@ 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 AVCodecID id;
ff_asf_guid guid;
} AVCodecGuid;

enum AVCodecID 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

/**
* Write all recognized RIFF tags from s->metadata
*/
void ff_riff_write_info(AVFormatContext *s);

/**
* Write a single RIFF info tag
*/
void ff_riff_write_info_tag(AVIOContext *pb, const char *tag, const char *str);

#endif /* AVFORMAT_RIFF_H */

0 comments on commit 52e4015

Please sign in to comment.