diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index abd7fc0bd3..a5374a1037 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -54,6 +54,8 @@ typedef struct { int is_cbr; } MP3DecContext; +static int check(AVFormatContext *s, int64_t pos); + /* mp3 read */ static int mp3_read_probe(AVProbeData *p) @@ -370,6 +372,16 @@ static int mp3_read_header(AVFormatContext *s) if (ret < 0) return ret; + off = avio_tell(s->pb); + for (i = 0; i < 64 * 1024; i++) { + if (check(s, off + i) >= 0) { + av_log(s, AV_LOG_INFO, "Skipping %d bytes of junk at %lld.\n", i, (long long)off); + avio_seek(s->pb, off + i, SEEK_SET); + break; + } + avio_seek(s->pb, off, SEEK_SET); + } + // the seek index is relative to the end of the xing vbr headers for (i = 0; i < st->nb_index_entries; i++) st->index_entries[i].pos += avio_tell(s->pb);