[FFmpeg-devel] [PATCH 1/3] mp3enc: fix Xing sample rate selection.

Michael Niedermayer michaelni at gmx.at
Thu May 10 19:06:00 CEST 2012


On Wed, May 09, 2012 at 10:41:18PM +0200, Clément Bœsch wrote:
> On Tue, Mar 20, 2012 at 07:22:58PM +0100, Michael Niedermayer wrote:
> > On Tue, Mar 20, 2012 at 04:38:12PM +0100, Clément Bœsch wrote:
> > > From: Clément Bœsch <clement.boesch at smartjog.com>
> > > 
> > > This at least avoid raising an unsupported sample rate warning when
> > > sample rate is different than the sampling rate allowed in MPEG-1.
> > > 
> > > ex: ffmpeg -f lavfi -i aevalsrc=0 -ar 22050 -y /tmp/out.mp3
> > > ---
> > >  libavformat/mp3enc.c |    4 +++-
> > >  1 files changed, 3 insertions(+), 1 deletions(-)
> > > 
> > > diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
> > > index b2c1b42..d28e95c 100644
> > > --- a/libavformat/mp3enc.c
> > > +++ b/libavformat/mp3enc.c
> > > @@ -126,7 +126,9 @@ static int mp3_write_xing(AVFormatContext *s)
> > >          return 0;
> > >  
> > >      for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++)
> > > -        if (avpriv_mpa_freq_tab[i] == codec->sample_rate) {
> > > +        if (codec->sample_rate == avpriv_mpa_freq_tab[i]      ||    // MPEG 1
> > > +            codec->sample_rate == avpriv_mpa_freq_tab[i] >> 1 ||    // MPEG 2 (LSF)
> > > +            codec->sample_rate == avpriv_mpa_freq_tab[i] >> 2) {    // MPEG 2.5 (LSF)
> > >              srate_idx = i;
> > >              break;
> > 
> > is the srate_idx correct for all cases ?
> > 
> 
> The sample rate index should be correct (according to
> http://www.codeproject.com/Articles/8295/MPEG-Audio-Frame-Header#SamplingRate
> at least).
> 

> Though, the audio version was incorrect. The attached patch should be
> better.

i hope mixing audio versions has no sideeffects otherwise patch ok
if it passes your tests


> 
> Any idea how I could check if the rest of the header is correctly set?

i guess try some things that can read mp3 and see if adding the xing
header causes a difference in their output

[...]


-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120510/40f33edd/attachment.asc>


More information about the ffmpeg-devel mailing list