[FFmpeg-devel] [PATCH] fixes in mpeg audio parsing
Yoav Steinberg
yoav
Thu Nov 13 08:16:24 CET 2008
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).
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: skip_id3v1_parse.patch
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081113/d4536ab3/attachment.txt>
More information about the ffmpeg-devel
mailing list