Commit 3445f4a3 authored by reimar's avatar reimar

Add a special guidcmp function to compare ASF guids, to avoid the many

duplicated sizeof(GUID).


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@18030 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent abd68544
......@@ -48,7 +48,7 @@ static const GUID stream_bitrate_guid = { /* (http://get.to/sdp) */
#ifdef DEBUG
#define PRINT_IF_GUID(g,cmp) \
if (!memcmp(g, &cmp, sizeof(GUID))) \
if (!guidcmp(g, &cmp)) \
dprintf(NULL, "(GUID: %s) ", #cmp)
static void print_guid(const GUID *g)
......@@ -87,6 +87,11 @@ static void print_guid(const GUID *g)
#define print_guid(g)
#endif
static int guidcmp(const void *g1, const void *g2)
{
return memcmp(g1, g2, sizeof(GUID));
}
static void get_guid(ByteIOContext *s, GUID *g)
{
assert(sizeof(*g) == 16);
......@@ -125,7 +130,7 @@ static void get_str16_nolen(ByteIOContext *pb, int len, char *buf, int buf_size)
static int asf_probe(AVProbeData *pd)
{
/* check file header */
if (!memcmp(pd->buf, &ff_asf_header, sizeof(GUID)))
if (!guidcmp(pd->buf, &ff_asf_header))
return AVPROBE_SCORE_MAX;
else
return 0;
......@@ -174,7 +179,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
memset(bitrate, 0, sizeof(bitrate));
get_guid(pb, &g);
if (memcmp(&g, &ff_asf_header, sizeof(GUID)))
if (guidcmp(&g, &ff_asf_header))
return -1;
get_le64(pb);
get_le32(pb);
......@@ -187,7 +192,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
dprintf(s, "%08"PRIx64": ", url_ftell(pb) - 24);
print_guid(&g);
dprintf(s, " size=0x%"PRIx64"\n", gsize);
if (!memcmp(&g, &ff_asf_data_header, sizeof(GUID))) {
if (!guidcmp(&g, &ff_asf_data_header)) {
asf->data_object_offset = url_ftell(pb);
// if not streaming, gsize is not unlimited (how?), and there is enough space in the file..
if (!(asf->hdr.flags & 0x01) && gsize >= 100) {
......@@ -199,7 +204,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
if (gsize < 24)
return -1;
if (!memcmp(&g, &ff_asf_file_header, sizeof(GUID))) {
if (!guidcmp(&g, &ff_asf_file_header)) {
get_guid(pb, &asf->hdr.guid);
asf->hdr.file_size = get_le64(pb);
asf->hdr.create_time = get_le64(pb);
......@@ -213,7 +218,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
asf->hdr.max_pktsize = get_le32(pb);
asf->hdr.max_bitrate = get_le32(pb);
asf->packet_size = asf->hdr.max_pktsize;
} else if (!memcmp(&g, &ff_asf_stream_header, sizeof(GUID))) {
} else if (!guidcmp(&g, &ff_asf_stream_header)) {
enum CodecType type;
int type_specific_size, sizeX;
uint64_t total_size;
......@@ -240,13 +245,13 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
get_guid(pb, &g);
test_for_ext_stream_audio = 0;
if (!memcmp(&g, &ff_asf_audio_stream, sizeof(GUID))) {
if (!guidcmp(&g, &ff_asf_audio_stream)) {
type = CODEC_TYPE_AUDIO;
} else if (!memcmp(&g, &ff_asf_video_stream, sizeof(GUID))) {
} else if (!guidcmp(&g, &ff_asf_video_stream)) {
type = CODEC_TYPE_VIDEO;
} else if (!memcmp(&g, &ff_asf_command_stream, sizeof(GUID))) {
} else if (!guidcmp(&g, &ff_asf_command_stream)) {
type = CODEC_TYPE_DATA;
} else if (!memcmp(&g, &ff_asf_ext_stream_embed_stream_header, sizeof(GUID))) {
} else if (!guidcmp(&g, &ff_asf_ext_stream_embed_stream_header)) {
test_for_ext_stream_audio = 1;
type = CODEC_TYPE_UNKNOWN;
} else {
......@@ -264,7 +269,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (test_for_ext_stream_audio) {
get_guid(pb, &g);
if (!memcmp(&g, &ff_asf_ext_stream_audio_stream, sizeof(GUID))) {
if (!guidcmp(&g, &ff_asf_ext_stream_audio_stream)) {
type = CODEC_TYPE_AUDIO;
is_dvr_ms_audio=1;
get_guid(pb, &g);
......@@ -370,7 +375,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
pos2 = url_ftell(pb);
url_fskip(pb, gsize - (pos2 - pos1 + 24));
} else if (!memcmp(&g, &ff_asf_comment_header, sizeof(GUID))) {
} else if (!guidcmp(&g, &ff_asf_comment_header)) {
int len1, len2, len3, len4, len5;
len1 = get_le16(pb);
......@@ -383,7 +388,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
get_tag(s, "copyright", 0, len3);
get_tag(s, "comment" , 0, len4);
url_fskip(pb, len5);
} else if (!memcmp(&g, &stream_bitrate_guid, sizeof(GUID))) {
} else if (!guidcmp(&g, &stream_bitrate_guid)) {
int stream_count = get_le16(pb);
int j;
......@@ -398,7 +403,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
// av_log(s, AV_LOG_ERROR, "flags: 0x%x stream id %d, bitrate %d\n", flags, stream_id, bitrate);
asf->stream_bitrates[stream_id]= bitrate;
}
} else if (!memcmp(&g, &ff_asf_extended_content_header, sizeof(GUID))) {
} else if (!guidcmp(&g, &ff_asf_extended_content_header)) {
int desc_count, i;
desc_count = get_le16(pb);
......@@ -412,7 +417,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
value_len = get_le16(pb);
get_tag(s, name, value_type, value_len);
}
} else if (!memcmp(&g, &ff_asf_metadata_header, sizeof(GUID))) {
} else if (!guidcmp(&g, &ff_asf_metadata_header)) {
int n, stream_num, name_len, value_len, value_type, value_num;
n = get_le16(pb);
......@@ -435,7 +440,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
else if(!strcmp(name, "AspectRatioY")) dar[stream_num].den= value_num;
}
}
} else if (!memcmp(&g, &ff_asf_ext_stream_header, sizeof(GUID))) {
} else if (!guidcmp(&g, &ff_asf_ext_stream_header)) {
int ext_len, payload_ext_ct, stream_ct;
uint32_t ext_d, leak_rate, stream_num;
int64_t pos_ex_st;
......@@ -475,13 +480,13 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
// there could be a optional stream properties object to follow
// if so the next iteration will pick it up
} else if (!memcmp(&g, &ff_asf_head1_guid, sizeof(GUID))) {
} else if (!guidcmp(&g, &ff_asf_head1_guid)) {
int v1, v2;
get_guid(pb, &g);
v1 = get_le32(pb);
v2 = get_le16(pb);
#if 0
} else if (!memcmp(&g, &ff_asf_codec_comment_header, sizeof(GUID))) {
} else if (!guidcmp(&g, &ff_asf_codec_comment_header)) {
int len, v1, n, num;
char str[256], *q;
char tag[16];
......@@ -990,7 +995,7 @@ static void asf_build_simple_index(AVFormatContext *s, int stream_index)
url_fseek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET);
get_guid(s->pb, &g);
if (!memcmp(&g, &index_guid, sizeof(GUID))) {
if (!guidcmp(&g, &index_guid)) {
gsize = get_le64(s->pb);
get_guid(s->pb, &g);
itime=get_le64(s->pb);
......
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