[Ffmpeg-devel] [RFC] faad/rtsp/aac bug...

bond b-o-n-d
Wed Nov 1 16:12:12 CET 2006


> Date: Tue, 31 Oct 2006 02:03:35 +0100
> From: Michael Niedermayer <michaelni at gmx.at>
> Subject: Re: [Ffmpeg-devel] [RFC] faad/rtsp/aac bug...
> To: FFmpeg development discussions and patches
> <ffmpeg-devel at mplayerhq.hu>
> Message-ID: <20061031010334.GG22553 at MichaelsNB>
> Content-Type: text/plain; charset=us-ascii
>
> Hi
>
> On Mon, Oct 30, 2006 at 06:38:44PM -0600, Ryan Martell wrote:
> > Hi--
> >
> > So there's a bug in rtsp.c/faad, that I could use a suggestion on
> > fixing.
> >
> > 1) in rtsp.c:
> >                     codec->sample_rate = i;
> >                     get_word_sep(buf, sizeof(buf), "/", &p);
> >                     i = atoi(buf);
> >                     if (i > 0)
> >                         codec->channels = i;
> >                     // TODO: there is a bug here; if it is a mono
> > stream, and less than 22000Hz, faad upconverts to stereo and twice the
> >                     //  frequency.  No problem, but the sample rate
> > is being set here by the sdp line.  Upcoming patch forthcoming. (rdm)
> >
> > 2) In faad.c:
> >     if (avctx->extradata){
> >         r = s->faacDecInit2(s->faac_handle, (uint8_t*) avctx-
> > >extradata,
> >                             avctx->extradata_size,
> >                             &samplerate, &channels);
> >         if (r < 0){
> >             av_log(avctx, AV_LOG_ERROR,
> >                    "faacDecInit2 failed r:%d   sr:%ld  ch:%ld  s:%d\n",
> >                    r, samplerate, (long)channels, avctx-
> > >extradata_size);
> >         } else {
> >             avctx->sample_rate = samplerate;
> >             avctx->channels = channels;
> >             s->init = 1;
> >         }
> >     }
> >
> > 3) The extradata specifies the channel count and the frequency.  In
> > my case, it specifies it as a 22050/1, which is also what the SDP
> > line says.
> >
> > 4) in the faad code, if the frequency is lower than a 22000Hz, it
> > doubles the frequency, and if it is a mono channel, it doubles it to
> > stereo.
> >
> > The hardware buffers are opened in ffplay, after the rtsp stuff is
> > parsed but before the aac code is called that tells it to
> > upconvert.   As a result, if it is a 22050 mono stream, it is really
> > slow sounding.
> >
> > I could include the logic from aac that talks about how to do this
> > (based on the extradata), but I believe that the upconversion/
> > doubling of channels might just be a faad thing, and put that in the
> > rtp code, but that seems potentially buggy.
> >
> > Any advice on where/how to fix this cleanly would be appreciated.
>
> the bug is clearly in faad, if the stream is 22khz mono faad should
> output that and nothing else
> id suggest to simply discard every second sample and the second chanel
> in libavcodec/faad.c if faad messes with the samplingrate (but first
> check that there is no parameter to faad which disables this silly
> behavior and second confirm that the stream really is 22kz and not 44khz)

this is not a bug in faad2, but a feature ;)

according to menno, the faad2 dev, the mpeg aac standard does not define the
necessity to explicitely signal the useage of sbr/he-aac (aka fake double
frequency) in an aac stream. to still be able to play streams not signalling
sbr with sbr, faad2 simply doubles the frequency for all low frequency
streams (like 22khz) using sbr if its available

same goes for the useage of ps (aka fake stereo), where faad2 plays a mono
stream as stereo using the ps info if available





More information about the ffmpeg-devel mailing list