[MPlayer-dev-eng] [PATCH] Fix wrong runtime and average bitrate for VBR MP3.
Benoît Thébaudeau
benoit.thebaudeau at advansee.com
Fri May 18 22:48:16 CEST 2012
On Fri, May 18, 2012 at 07:29:44PM +0200, Reimar Döffinger wrote:
> On Fri, May 18, 2012 at 06:22:08PM +0200, Benoît Thébaudeau wrote:
> > +int mp_get_mp3_header(unsigned char* hbuf,int* chans, int* srate,
> > int* spf, int* mpa_layer, int* br, int* lsf){
> > + int
> > stereo,ssize,_lsf,framesize,padding,bitrate_index,sampling_frequency,
> > divisor;
>
> I'd prefer that without all the renaming.
> You can name the argument e.g. lsfp or even give it the full name
> and the whole change to this file becomes a one-liner.
http://www.mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm says "Frame size is the
number of samples contained in a frame. It is constant and always 384 samples
for Layer I and 1152 samples for Layer II and Layer III.", which contradicts
http://www.codeproject.com/Articles/8295/MPEG-Audio-Frame-Header#MPEGAudioFrameHeader,
which gives 576 s/f for LSF Layer III. The latter information seems more
reliable, and MPlayer's code is based on it. If we rely on this, [spf < 1152]
and [lsf] are the same for mp3_vbr_frames() since it has checked beforehand that
the layer is III. Hence, you can drop this part of my patch.
BTW, ssize is computed by mp_get_mp3_header(), but never used.
> > - if(srate) {
> > + if(srate)
> > *srate = freqs[sampling_frequency];
> > - if(spf) {
> > - if(layer == 1)
> > - *spf = 384;
> > - else if(layer == 2)
> > - *spf = 1152;
> > - else if(*srate < 32000)
> > - *spf = 576;
> > - else
> > - *spf = 1152;
> > - }
> > + if(spf) {
> > + if(layer == 1)
> > + *spf = 384;
> > + else if(layer == 2)
> > + *spf = 1152;
> > + else if(*srate < 32000)
> > + *spf = 576;
> > + else
> > + *spf = 1152;
>
> Well, that would now crash exactly in the case you are trying to fix.
> I committed a fixed version of that part.
Correct.
Regards,
Benoît
More information about the MPlayer-dev-eng
mailing list