[FFmpeg-devel] [PATCH] HE-AAC v1 decoder try 4

Michael Niedermayer michaelni
Sat Feb 20 18:56:38 CET 2010


On Wed, Feb 17, 2010 at 07:06:44PM +0100, Vladimir Pantelic wrote:
> Vladimir Pantelic wrote:
>> Alexander Strange wrote:
>>>
>>>  On Feb 16, 2010, at 6:19 PM, Alex Converse wrote:
>>>
>>>>   On Tue, Feb 16, 2010 at 6:01 PM, Alex 
>>>> Converse<alex.converse at gmail.com>wrote:
>>>>
>>>>>   Notes:
>>>>>   *All the computation time is spent in ff_sbr_apply() and it's
>>>>>   children. If it isn't called from ff_sbr_apply() making it 100% 
>>>>> faster
>>>>>   isn't going to buy us anything.
>>>>>   *Right now the synthesis filterbank is written on top on an MDCT. 
>>>>> With
>>>>>   appropriate SIMD functions it may make sense to move it to an FFT.
>>>>>   Right now the MDCT version is much faster.
>>>>>   *SIMD placeholder patch not included
>>>>>
>>>>
>>>>   Wrong patch.
>>>>   try 4.1 :)
>>>>   <sbr.diff>
>>>
>>>  I tried it with ffplay and it plays 2x too slow. If ffplay needs to be 
>>> fixed, I wonder if other players will too? Well, it's unavoidable anyway.
>>>  ffmpeg to wav sounds fine.
>>
>> guess its the issue that the container signals the smaller (non-sbr) 
>> sample rate, e.g. 24khz and the decoder applies SBR
>> and returns 48kHz. I had to fix my player to switch to the decoder 
>> returned sample rate too...
>
> ok, it is more the fact that avctx->sample_rate is 0
> after we perform avcodec_open(), so SDL defaults to
> 22050.

i guess unconditionally setting it to 0 in avcodec_open() is not ideal


>
> it is correct before the avcodec_open() call, but that
> might not always be the case I guess.
>
> totally lame patch attached to detects any change in
> sample_rate by the decoder and re-open SDL audio...
>
> (my first patch (yay), more for RFC than an attempt to
> get instant fame...)

>  ffplay.c |   33 ++++++++++++++++++++++++++++++++-
>  1 file changed, 32 insertions(+), 1 deletion(-)
> 8951327565cd5e449a94c431caa46767cfc84ae2  ffplay_he_aac_sample_rate.diff
> Index: ffplay.c
> ===================================================================
> --- ffplay.c	(revision 21861)
> +++ ffplay.c	(working copy)
> @@ -146,6 +146,8 @@
>      AVPacket audio_pkt_temp;
>      AVPacket audio_pkt;
>      enum SampleFormat audio_src_fmt;
> +    int audio_sample_rate;
> +    int audio_sample_rate_changed;
>      AVAudioConvert *reformat_ctx;
>  
>      int show_audio; /* if true, display audio samples */
> @@ -1670,7 +1672,10 @@
>              pkt_temp->size -= len1;
>              if (data_size <= 0)
>                  continue;
> -
> +            if (dec->sample_rate != is->audio_sample_rate) {
> +                is->audio_sample_rate = dec->sample_rate;
> +                is->audio_sample_rate_changed = 1;
> +            }
>              if (dec->sample_fmt != is->audio_src_fmt) {
>                  if (is->reformat_ctx)
>                      av_audio_convert_free(is->reformat_ctx);
> @@ -1848,6 +1853,8 @@
>          }
>          is->audio_hw_buf_size = spec.size;
>          is->audio_src_fmt= SAMPLE_FMT_S16;
> +        is->audio_sample_rate = spec.freq;
> +        is->audio_sample_rate_changed = 0;
>      }
>  
>      ic->streams[stream_index]->discard = AVDISCARD_DEFAULT;
> @@ -2136,6 +2143,30 @@
>              eof= 0;
>          }
>  
> +        if( is->audio_sample_rate_changed ) {
> +            SDL_AudioSpec wanted_spec, spec;
> +fprintf(stderr, "sample rate changed to: %d\n", is->audio_sample_rate);
> +            is->audio_sample_rate_changed = 0;
> +
> +            SDL_CloseAudio();
> +	    

indention is off, trailing whitespace and you maybe could use
 stream_component_open()

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100220/cdfd6551/attachment.pgp>



More information about the ffmpeg-devel mailing list