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

Michael Niedermayer michaelni
Tue Oct 31 02:03:35 CET 2006


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)

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is




More information about the ffmpeg-devel mailing list