[FFmpeg-devel] [PATCH] fixes in mpeg audio parsing
Michael Niedermayer
michaelni
Thu Nov 13 15:12:40 CET 2008
On Thu, Nov 13, 2008 at 09:16:24AM +0200, Yoav Steinberg wrote:
>
>
> Michael Niedermayer wrote:
>> On Wed, Nov 12, 2008 at 07:02:55PM +0200, Yoav Steinberg wrote:
>>> Hi,
>>> Attached are patches witch make some improvements for mp3 parsing.
>>> skip_vbrtag_and_id3v1.patch:
>>> - When file contains ID3v1 tag at the end don't attempt to read it as
>>> part of a packet. In some cases there are mp3 files where the ID3v1 tag
>>> was stuck forcefully at the end of the file inside the last frame
>>> boundary. In those cases the patch eliminates attempts to parse/decode
>>> the ID3 tag.
>>> - If we find a VBR tag at the beginning of the file don't attempt to
>>> parse it as a valid frame.
>> These are 2 seperate things which must be in seperate patches.
> Attached is a single patch for the prevention of reading ID3v1 as part of a
> packet.
>
>>> @@ -505,10 +515,20 @@
>>> static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt)
>>> {
>>> int ret, size;
>>> + int64_t size_left;
>>> // AVStream *st = s->streams[0];
>>> size= MP3_PACKET_SIZE;
>>> + /* if we're nearing the end of the input and there's an
>>> + ID3v1 tag then make sure we don't read it as a packet */
>>> + if (((MPAContext*)s->priv_data)->found_id3v1 && s->file_size && +
>>> (size_left = s->file_size - url_ftell(s->pb) - ID3v1_TAG_SIZE) <
>>> size) {
>>> + size = size_left;
>>> + if (size <= 0)
>>> + return AVERROR(EIO);
>>> + }
>>> +
>>> ret= av_get_packet(s->pb, pkt, size);
>>> pkt->stream_index = 0;
>> file_size is not known for stdin/pipes
>
> That's why I put the '&& s->file_size' so that this logic will be avoided
> when file size is not known. In any case the found_id3v1 will be false in
> such cases. But for future compatibility in case the tag will somehow be
> known but not the file size I added the '&& s->file_size' (which is set to
> 0 if file size is not known).
Fixing a bug just for seekable input _requires_ a proof that it cannot be
fixed for non seekable or that a complete fix would be too messy.
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Everything should be made as simple as possible, but not simpler.
-- Albert Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081113/a679240e/attachment.pgp>
More information about the ffmpeg-devel
mailing list