diff options
author | Anton Khirnov <anton@khirnov.net> | 2011-04-05 12:19:35 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2011-04-06 14:10:08 +0200 |
commit | 56a1000917694b2277064c5573b0dd818ad7a379 (patch) | |
tree | 02ae3f76ef06d29c65d6d4cef7dd50204dd3f7de | |
parent | 5371803dd5d9f7bbc62d68274084d25f10a8dc61 (diff) | |
download | ffmpeg-56a1000917694b2277064c5573b0dd818ad7a379.tar.gz |
lavf: if id3v2 tag is present and all else fails, guess by file extension
-rw-r--r-- | libavformat/utils.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 31eddec12a..a5d4a6fb7c 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -371,7 +371,7 @@ AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score { AVProbeData lpd = *pd; AVInputFormat *fmt1 = NULL, *fmt; - int score; + int score, id3 = 0; if (lpd.buf_size > 10 && ff_id3v2_match(lpd.buf, ID3v2_DEFAULT_MAGIC)) { int id3len = ff_id3v2_tag_len(lpd.buf); @@ -379,6 +379,7 @@ AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score lpd.buf += id3len; lpd.buf_size -= id3len; } + id3 = 1; } fmt = NULL; @@ -399,6 +400,16 @@ AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score }else if (score == *score_max) fmt = NULL; } + + /* a hack for files with huge id3v2 tags -- try to guess by file extension. */ + if (!fmt && id3 && *score_max < AVPROBE_SCORE_MAX/4) { + while ((fmt = av_iformat_next(fmt))) + if (fmt->extensions && av_match_ext(lpd.filename, fmt->extensions)) { + *score_max = AVPROBE_SCORE_MAX/4; + break; + } + } + return fmt; } |