[FFmpeg-devel] [PATCH] fixes in mpeg audio parsing

Yoav Steinberg yoav
Thu Nov 13 18:06:18 CET 2008


Michael Niedermayer wrote:

> On Thu, Nov 13, 2008 at 05:15:25PM +0200, Yoav Steinberg wrote:
>>
>> Michael Niedermayer wrote:
>>>> Index: mp3.c
>>>> ===================================================================
>>>> --- mp3.c	(revision 15776)
>>>> +++ mp3.c	(working copy)
>>>> @@ -402,18 +402,21 @@
>>>>  /**
>>>>   * Try to find Xing/Info/VBRI tags and compute duration from info 
>>>> therein
>>>>   */
>>>> -static void mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t 
>>>> base)
>>>> +static void mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st)
>>>>  {
>>>>      uint32_t v, spf;
>>>>      int frames = -1; /* Total number of frames in file */
>>>>      const int64_t xing_offtbl[2][2] = {{32, 17}, {17,9}};
>>>>      MPADecodeContext c;
>>>> +    int vbrtag_size = 0;
>>>> +    int64_t base = url_ftell(s->pb);
>>>>       v = get_be32(s->pb);
>>>>      if(ff_mpa_check_header(v) < 0)
>>>>        return;
>>> a return here will randomize the file position, and similarly will
>>> for other returns
>> take 2.
> 
> [...]
> 
>> @@ -439,11 +441,15 @@
>>      }
>>  
>>      if(frames < 0)
>> -        return;
>> +        return -1;
>>  
>> +    /* Skip the vbr tag frame */
>> +    url_fseek(s->pb, base + vbrtag_size, SEEK_SET);
> 
> why does this not use c.frame_size directly?
> 

Because c.frame_size isn't guaranteed to be set. It is calculated in 
ff_mpegaudio_decode_header() in certain conditions. By checking 
ff_mpegaudio_decode_header's return value I know if there's a valid 
frame size calculated. In case no frame size could be found we have no 
choice but to default to the base position.





More information about the ffmpeg-devel mailing list