You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avformat/mp3dec: Check for occurances of headers within frames during probing
Fixes misdetection of zYLx.wav Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
committed by
Michael Niedermayer
parent
e9a335150a
commit
c22665ae69
@@ -71,7 +71,7 @@ static int mp3_read_probe(const AVProbeData *p)
|
|||||||
int frames, ret;
|
int frames, ret;
|
||||||
int framesizes, max_framesizes;
|
int framesizes, max_framesizes;
|
||||||
uint32_t header;
|
uint32_t header;
|
||||||
const uint8_t *buf, *buf0, *buf2, *end;
|
const uint8_t *buf, *buf0, *buf2, *buf3, *end;
|
||||||
|
|
||||||
buf0 = p->buf;
|
buf0 = p->buf;
|
||||||
end = p->buf + p->buf_size - sizeof(uint32_t);
|
end = p->buf + p->buf_size - sizeof(uint32_t);
|
||||||
@@ -86,11 +86,19 @@ static int mp3_read_probe(const AVProbeData *p)
|
|||||||
buf2 = buf;
|
buf2 = buf;
|
||||||
for (framesizes = frames = 0; buf2 < end; frames++) {
|
for (framesizes = frames = 0; buf2 < end; frames++) {
|
||||||
MPADecodeHeader h;
|
MPADecodeHeader h;
|
||||||
|
int header_emu = 0;
|
||||||
|
|
||||||
header = AV_RB32(buf2);
|
header = AV_RB32(buf2);
|
||||||
ret = avpriv_mpegaudio_decode_header(&h, header);
|
ret = avpriv_mpegaudio_decode_header(&h, header);
|
||||||
if (ret != 0 || end - buf2 < h.frame_size)
|
if (ret != 0 || end - buf2 < h.frame_size)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
for (buf3 = buf2 + 4; buf3 < buf2 + h.frame_size; buf3++) {
|
||||||
|
uint32_t next_sync = AV_RB32(buf3);
|
||||||
|
header_emu += (next_sync & MP3_MASK) == (header & MP3_MASK);
|
||||||
|
}
|
||||||
|
if (header_emu > 2)
|
||||||
|
break;
|
||||||
buf2 += h.frame_size;
|
buf2 += h.frame_size;
|
||||||
framesizes += h.frame_size;
|
framesizes += h.frame_size;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user