diff options
-rw-r--r-- | libavformat/asf.h | 2 | ||||
-rw-r--r-- | libavformat/asfdec.c | 84 |
2 files changed, 44 insertions, 42 deletions
diff --git a/libavformat/asf.h b/libavformat/asf.h index 0867755f46..f3705e946a 100644 --- a/libavformat/asf.h +++ b/libavformat/asf.h @@ -231,5 +231,7 @@ extern const AVMetadataConv ff_asf_metadata_conv[]; extern AVInputFormat asf_demuxer; int ff_put_str16_nolen(ByteIOContext *s, const char *tag); +int ff_guidcmp(const void *g1, const void *g2); +void ff_get_guid(ByteIOContext *s, ff_asf_guid *g); #endif /* AVFORMAT_ASF_H */ diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 36876fa1fd..6ae4e99326 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -49,14 +49,14 @@ static const ff_asf_guid stream_bitrate_guid = { /* (http://get.to/sdp) */ /**********************************/ /* decoding */ -static int guidcmp(const void *g1, const void *g2) +int ff_guidcmp(const void *g1, const void *g2) { return memcmp(g1, g2, sizeof(ff_asf_guid)); } #ifdef DEBUG #define PRINT_IF_GUID(g,cmp) \ -if (!guidcmp(g, &cmp)) \ +if (!ff_guidcmp(g, &cmp)) \ dprintf(NULL, "(GUID: %s) ", #cmp) static void print_guid(const ff_asf_guid *g) @@ -97,7 +97,7 @@ static void print_guid(const ff_asf_guid *g) #define print_guid(g) #endif -static void get_guid(ByteIOContext *s, ff_asf_guid *g) +void ff_get_guid(ByteIOContext *s, ff_asf_guid *g) { assert(sizeof(*g) == 16); get_buffer(s, *g, sizeof(*g)); @@ -139,7 +139,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 (!guidcmp(pd->buf, &ff_asf_header)) + if (!ff_guidcmp(pd->buf, &ff_asf_header)) return AVPROBE_SCORE_MAX; else return 0; @@ -196,8 +196,8 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) memset(dar, 0, sizeof(dar)); memset(bitrate, 0, sizeof(bitrate)); - get_guid(pb, &g); - if (guidcmp(&g, &ff_asf_header)) + ff_get_guid(pb, &g); + if (ff_guidcmp(&g, &ff_asf_header)) return -1; get_le64(pb); get_le32(pb); @@ -206,12 +206,12 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) memset(&asf->asfid2avid, -1, sizeof(asf->asfid2avid)); for(;;) { uint64_t gpos= url_ftell(pb); - get_guid(pb, &g); + ff_get_guid(pb, &g); gsize = get_le64(pb); dprintf(s, "%08"PRIx64": ", gpos); print_guid(&g); dprintf(s, " size=0x%"PRIx64"\n", gsize); - if (!guidcmp(&g, &ff_asf_data_header)) { + if (!ff_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) { @@ -223,8 +223,8 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) } if (gsize < 24) return -1; - if (!guidcmp(&g, &ff_asf_file_header)) { - get_guid(pb, &asf->hdr.guid); + if (!ff_guidcmp(&g, &ff_asf_file_header)) { + ff_get_guid(pb, &asf->hdr.guid); asf->hdr.file_size = get_le64(pb); asf->hdr.create_time = get_le64(pb); asf->nb_packets = get_le64(pb); @@ -237,7 +237,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) asf->hdr.max_pktsize = get_le32(pb); asf->hdr.max_bitrate = get_le32(pb); s->packet_size = asf->hdr.max_pktsize; - } else if (!guidcmp(&g, &ff_asf_stream_header)) { + } else if (!ff_guidcmp(&g, &ff_asf_stream_header)) { enum AVMediaType type; int type_specific_size, sizeX; uint64_t total_size; @@ -268,25 +268,25 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) st->duration = asf->hdr.play_time / (10000000 / 1000) - start_time; } - get_guid(pb, &g); + ff_get_guid(pb, &g); test_for_ext_stream_audio = 0; - if (!guidcmp(&g, &ff_asf_audio_stream)) { + if (!ff_guidcmp(&g, &ff_asf_audio_stream)) { type = AVMEDIA_TYPE_AUDIO; - } else if (!guidcmp(&g, &ff_asf_video_stream)) { + } else if (!ff_guidcmp(&g, &ff_asf_video_stream)) { type = AVMEDIA_TYPE_VIDEO; - } else if (!guidcmp(&g, &ff_asf_jfif_media)) { + } else if (!ff_guidcmp(&g, &ff_asf_jfif_media)) { type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_MJPEG; - } else if (!guidcmp(&g, &ff_asf_command_stream)) { + } else if (!ff_guidcmp(&g, &ff_asf_command_stream)) { type = AVMEDIA_TYPE_DATA; - } else if (!guidcmp(&g, &ff_asf_ext_stream_embed_stream_header)) { + } else if (!ff_guidcmp(&g, &ff_asf_ext_stream_embed_stream_header)) { test_for_ext_stream_audio = 1; type = AVMEDIA_TYPE_UNKNOWN; } else { return -1; } - get_guid(pb, &g); + ff_get_guid(pb, &g); total_size = get_le64(pb); type_specific_size = get_le32(pb); get_le32(pb); @@ -297,15 +297,15 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) get_le32(pb); if (test_for_ext_stream_audio) { - get_guid(pb, &g); - if (!guidcmp(&g, &ff_asf_ext_stream_audio_stream)) { + ff_get_guid(pb, &g); + if (!ff_guidcmp(&g, &ff_asf_ext_stream_audio_stream)) { type = AVMEDIA_TYPE_AUDIO; is_dvr_ms_audio=1; - get_guid(pb, &g); + ff_get_guid(pb, &g); get_le32(pb); get_le32(pb); get_le32(pb); - get_guid(pb, &g); + ff_get_guid(pb, &g); get_le32(pb); } } @@ -413,7 +413,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) } pos2 = url_ftell(pb); url_fskip(pb, gsize - (pos2 - pos1 + 24)); - } else if (!guidcmp(&g, &ff_asf_comment_header)) { + } else if (!ff_guidcmp(&g, &ff_asf_comment_header)) { int len1, len2, len3, len4, len5; len1 = get_le16(pb); @@ -426,7 +426,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 (!guidcmp(&g, &stream_bitrate_guid)) { + } else if (!ff_guidcmp(&g, &stream_bitrate_guid)) { int stream_count = get_le16(pb); int j; @@ -441,7 +441,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 (!guidcmp(&g, &ff_asf_language_guid)) { + } else if (!ff_guidcmp(&g, &ff_asf_language_guid)) { int j; int stream_count = get_le16(pb); for(j = 0; j < stream_count; j++) { @@ -451,7 +451,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) if (j < 128) av_strlcpy(asf->stream_languages[j], lang, sizeof(*asf->stream_languages)); } - } else if (!guidcmp(&g, &ff_asf_extended_content_header)) { + } else if (!ff_guidcmp(&g, &ff_asf_extended_content_header)) { int desc_count, i; desc_count = get_le16(pb); @@ -478,7 +478,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) } else get_tag(s, name, value_type, value_len); } - } else if (!guidcmp(&g, &ff_asf_metadata_header)) { + } else if (!ff_guidcmp(&g, &ff_asf_metadata_header)) { int n, stream_num, name_len, value_len, value_type, value_num; n = get_le16(pb); @@ -501,7 +501,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) else if(!strcmp(name, "AspectRatioY")) dar[stream_num].den= value_num; } } - } else if (!guidcmp(&g, &ff_asf_ext_stream_header)) { + } else if (!ff_guidcmp(&g, &ff_asf_ext_stream_header)) { int ext_len, payload_ext_ct, stream_ct; uint32_t ext_d, leak_rate, stream_num; unsigned int stream_languageid_index; @@ -536,7 +536,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) } for (i=0; i<payload_ext_ct; i++){ - get_guid(pb, &g); + ff_get_guid(pb, &g); ext_d=get_le16(pb); ext_len=get_le32(pb); url_fseek(pb, ext_len, SEEK_CUR); @@ -545,13 +545,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 continue; - } else if (!guidcmp(&g, &ff_asf_head1_guid)) { + } else if (!ff_guidcmp(&g, &ff_asf_head1_guid)) { int v1, v2; - get_guid(pb, &g); + ff_get_guid(pb, &g); v1 = get_le32(pb); v2 = get_le16(pb); continue; - } else if (!guidcmp(&g, &ff_asf_marker_header)) { + } else if (!ff_guidcmp(&g, &ff_asf_marker_header)) { int i, count, name_len; char name[1024]; @@ -578,12 +578,12 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) ff_new_chapter(s, i, (AVRational){1, 10000000}, pres_time, AV_NOPTS_VALUE, name ); } #if 0 - } else if (!guidcmp(&g, &ff_asf_codec_comment_header)) { + } else if (!ff_guidcmp(&g, &ff_asf_codec_comment_header)) { int len, v1, n, num; char str[256], *q; char tag[16]; - get_guid(pb, &g); + ff_get_guid(pb, &g); print_guid(&g); n = get_le32(pb); @@ -606,11 +606,11 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) return -1; } else { if (!s->keylen) { - if (!guidcmp(&g, &ff_asf_content_encryption)) { + if (!ff_guidcmp(&g, &ff_asf_content_encryption)) { av_log(s, AV_LOG_WARNING, "DRM protected stream detected, decoding will likely fail!\n"); - } else if (!guidcmp(&g, &ff_asf_ext_content_encryption)) { + } else if (!ff_guidcmp(&g, &ff_asf_ext_content_encryption)) { av_log(s, AV_LOG_WARNING, "Ext DRM protected stream detected, decoding will likely fail!\n"); - } else if (!guidcmp(&g, &ff_asf_digital_signature)) { + } else if (!ff_guidcmp(&g, &ff_asf_digital_signature)) { av_log(s, AV_LOG_WARNING, "Digital signature detected, decoding will likely fail!\n"); } } @@ -619,7 +619,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) av_log(s, AV_LOG_DEBUG, "gpos mismatch our pos=%"PRIu64", end=%"PRIu64"\n", url_ftell(pb)-gpos, gsize); url_fseek(pb, gpos + gsize, SEEK_SET); } - get_guid(pb, &g); + ff_get_guid(pb, &g); get_le64(pb); get_byte(pb); get_byte(pb); @@ -1153,25 +1153,25 @@ static void asf_build_simple_index(AVFormatContext *s, int stream_index) int i; url_fseek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET); - get_guid(s->pb, &g); + ff_get_guid(s->pb, &g); /* the data object can be followed by other top-level objects, skip them until the simple index object is reached */ - while (guidcmp(&g, &index_guid)) { + while (ff_guidcmp(&g, &index_guid)) { int64_t gsize= get_le64(s->pb); if (gsize < 24 || url_feof(s->pb)) { url_fseek(s->pb, current_pos, SEEK_SET); return; } url_fseek(s->pb, gsize-24, SEEK_CUR); - get_guid(s->pb, &g); + ff_get_guid(s->pb, &g); } { int64_t itime, last_pos=-1; int pct, ict; int64_t av_unused gsize= get_le64(s->pb); - get_guid(s->pb, &g); + ff_get_guid(s->pb, &g); itime=get_le64(s->pb); pct=get_le32(s->pb); ict=get_le32(s->pb); |