[FFmpeg-devel] [PATCH] lavf/mp3dec: fix mp3 file probe fail
tiejun.peng
tiejun.peng at foxmail.com
Wed Dec 6 11:27:43 EET 2017
fix #6895: https://trac.ffmpeg.org/ticket/6895
stream:https://trac.ffmpeg.org/attachment/ticket/6895/music_mp3
Signed-off-by: tiejun.peng <tiejun.peng at foxmail.com>
---
libavformat/mp3dec.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index a76fe32..286eb68 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -73,6 +73,7 @@ static int mp3_read_probe(AVProbeData *p)
int frames, ret;
uint32_t header;
const uint8_t *buf, *buf0, *buf2, *end;
+ int match_size = 0;
buf0 = p->buf;
end = p->buf + p->buf_size - sizeof(uint32_t);
@@ -92,6 +93,7 @@ static int mp3_read_probe(AVProbeData *p)
if (ret != 0)
break;
buf2 += h.frame_size;
+ match_size += h.frame_size;
}
max_frames = FFMAX(max_frames, frames);
if(buf == buf0) {
@@ -104,6 +106,8 @@ static int mp3_read_probe(AVProbeData *p)
// issues with MPEG-files!
if (first_frames>=7) return AVPROBE_SCORE_EXTENSION + 1;
else if(max_frames>200)return AVPROBE_SCORE_EXTENSION;
+ // over 50% of probe size is valid
+ else if (p->buf_size > 10000 && match_size > (p->buf_size/2)) return AVPROBE_SCORE_EXTENSION;
else if(max_frames>=4 && max_frames >= p->buf_size/10000) return AVPROBE_SCORE_EXTENSION / 2;
else if(ff_id3v2_match(buf0, ID3v2_DEFAULT_MAGIC) && 2*ff_id3v2_tag_len(buf0) >= p->buf_size)
return p->buf_size < PROBE_BUF_MAX ? AVPROBE_SCORE_EXTENSION / 4 : AVPROBE_SCORE_EXTENSION - 2;
--
2.7.4
More information about the ffmpeg-devel
mailing list