[FFmpeg-devel] [PATCH] AAC decoder

Robert Swain robert.swain
Sun Jun 1 23:17:39 CEST 2008


On 1 Jun 2008, at 21:46, Michael Niedermayer wrote:
> On Sun, Jun 01, 2008 at 09:28:27PM +0100, Robert Swain wrote:
>> 2008/4/2 Michael Niedermayer <michaelni at gmx.at>:
>>> On Tue, Apr 01, 2008 at 04:56:48PM +0200, Andreas ?man wrote:
>>>> +    }
>>>> +
>>>> +    dsputil_init(&ac->dsp, avccontext);
>>>> +
>>>> +    /* Initialize RNG dither */
>>>> +    av_init_random(0x1f2e3d4c, &ac->random_state);
>>>> +
>>>> +    // -1024 - compensate wrong IMDCT method
>>>> +    // 32768 - values in AAC build for ready float->int 16 bit  
>>>> audio, using
>>>> +    // BIAS method instead needs values -1<x<1
>>>> +    for (i = 0; i < 256; i++)
>>>> +        ac->intensity_tab[i] = pow(0.5, (i - 100) / 4.);
>>>> +    for (i = 0; i < sizeof(ac->ivquant_tab)/sizeof(ac- 
>>>> >ivquant_tab[0]); i++)
>>>> +        ac->ivquant_tab[i] = pow(i, 4./3);
>>>> +
>>>> +    if(ac->dsp.float_to_int16 == ff_float_to_int16_c) {
>>>> +        ac->add_bias = 385.0f;
>>>> +        ac->sf_scale = 1. / (-1024. * 32768.);
>>>> +    } else {
>>>> +        ac->add_bias = 0.0f;
>>>> +        ac->sf_scale = 1. / -1024.;
>>>> +    }
>>>> +    for (i = 0; i < 256; i++)
>>>> +        ac->pow2sf_tab[i] = pow(2, (i - 100)/4.) * ac->sf_scale;
>>>> +
>>>> +    if(init_vlc(&ac->mainvlc, 7, sizeof(code)/sizeof(code[0]),
>>>> +            bits, sizeof(bits[0]), sizeof(bits[0]),
>>>> +            code, sizeof(code[0]), sizeof(code[0]),
>>>> +            0) < 0)
>>>> +        return -1;
>>>> +
>>>> +#ifdef AAC_SSR
>>>> +    if (ac->audioObjectType == AOT_AAC_SSR) {
>>>> +        ff_mdct_init(&ac->mdct, 9, 1);
>>>> +        ff_mdct_init(&ac->mdct_small, 6, 1);
>>>> +        // windows init
>>>> +        ff_kbd_window_init(ac->kbd_long_1024, 4.0, 256);
>>>> +        ff_kbd_window_init(ac->kbd_short_128, 6.0, 32);
>>>> +        sine_window_init(ac->sine_long_1024, 512);
>>>> +        sine_window_init(ac->sine_short_128, 64);
>>>> +        ssr_context_init(&ac->ssrctx);
>>>> +    } else {
>>>> +#endif /* AAC_SSR */
>>>> +        ff_mdct_init(&ac->mdct, 11, 1);
>>>> +        ff_mdct_init(&ac->mdct_small, 8, 1);
>>>> +        // windows init
>>>> +        ff_kbd_window_init(ac->kbd_long_1024, 4.0, 1024);
>>>> +        ff_kbd_window_init(ac->kbd_short_128, 6.0, 128);
>>>> +        sine_window_init(ac->sine_long_1024, 2048);
>>>> +        sine_window_init(ac->sine_short_128, 256);
>>>
>>> There are 4 different sine windows, why are they duplicated in  
>>> each context?
>>> They should be in static arrays generated at runtime or static  
>>> const tables
>>> hardcoded depening on ENABLE_HARDCODED_TABLES. This applies likely  
>>> to other
>>> tables as well.
>>
>> One could do the same for the tables of Kaiser-Bessel Derived window
>> coefficients as well. I have done this for the 'main' AAC (i.e. not
>> the SSR case) but I'm not sure whether to put the effort into doing
>> the same for SSR and handling the different arrays if we are going to
>> rip out the SSR and LTP code anyway. What are your demands? :)
>
> I do not demand ENABLE_HARDCODED_TABLES for all tables no, its nice to
> have if someone likes to work on that ...
> What i do "demand" is that constant tables should not be in the  
> context
> and that const tables which are identical between codecs should be  
> shared.
> sin, cos, pow2 really are quite common i doubt aac is the only thing  
> using
> them ...

OK, that's reasonable. In that case I'll just make them static for the  
moment rather than working on ENABLE_HARDCODED_TABLES for these as the  
static const names would 'clash' or rather such an issue would need to  
be dealt with. Not major, I know how I'd do it but doing things that  
are nice isn't my aim right now. :)

Rob





More information about the ffmpeg-devel mailing list