[FFmpeg-devel] [PATCH] fix parsing of broken mp3 streams

Zdenek Kabelac zdenek.kabelac
Mon Apr 20 21:37:25 CEST 2009

2009/4/19 Michael Niedermayer <michaelni at gmx.at>:
> On Sun, Apr 19, 2009 at 11:18:06PM +0200, Zdenek Kabelac wrote:
>> Hi
>> Here is a small patch that fixes of running out-of-buffer in parsing
>> broken mp3 data stream.
>> This solution is rather a hotfix - better solution would be to check
>> at least one or two next mp3
>> frames in sequence whether they are part of the same audio stream or
>> some random junk
>> which has 0xfffx header inside. With this patch ugly noise could be
>> sometimes noticed.
>> Also questionable is whether it should return -1 if no header is found
>> or rather return skipped
>> bytes and out_size = 0 - as then usually such packet is rescaned
>> multiple times with
>> one-byte step forward...
>> Zdenek
>> - Fix buffer overrun
>> - Properly return parsed bytes together with skipped bytes
> please provide a sample so we can confirm the bugfix, the patch
> looks mostly correct though

I've upload just one mp3 dumped stream upload.ffmpeg.org as
junk_at_mp3stream  directory - together with short text and two patch
- I'm attaching patch for api-example.c  to easily compare results.

Also ffplay seems to skip whole such data chunk it finds broken mp3
chunk in stream and makes then seeking somehow impossible - but fixing
properly this isn't an easy one-liner fix,

-------------- next part --------------
A non-text attachment was scrubbed...
Name: junk_at_mp3stream_api-example.patch
Type: text/x-patch
Size: 1830 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090420/27f3fa7a/attachment.bin>

More information about the ffmpeg-devel mailing list