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

Michael Niedermayer michaelni
Mon Feb 22 00:44:59 CET 2010


On Sun, Feb 21, 2010 at 11:08:08PM +0100, Vladimir Pantelic wrote:
> Michael Niedermayer wrote:
>> On Sun, Feb 21, 2010 at 09:36:10PM +0100, Vladimir Pantelic wrote:
>>> 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()..
>>
>> anything is better than duplicating code (with its bugs)
>
> right. btw, is the place I perform the change of sample rate the right one?

almost certainly not
theres the issue of a race between the user cycling channels (which
opens/closes the stuff) and you doing something quite similar

also if you dont drop the que the reinit has to be done when the end of the
que indicates so.
See how its done for video changing size


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

Avoid a single point of failure, be that a person or equipment.
-------------- 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/20100222/29431a87/attachment.pgp>



More information about the ffmpeg-devel mailing list