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

Vladimir Pantelic pan
Sun Feb 21 21:36:10 CET 2010


Michael Niedermayer wrote:
> 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()

that I tried 1st, but stream_component_open() drops the whole audio packet
queue, so the sound is totally off afterwards. But of course I could factor
out the SDL audio related pieces and use them here and in
stream_component_open()..






More information about the ffmpeg-devel mailing list