[FFmpeg-devel] AAC decoder round 9

Robert Swain robert.swain
Wed Aug 20 20:44:24 CEST 2008


2008/8/20 Robert Swain <robert.swain at gmail.com>:
> 2008/8/20 Vitor Sessak <vitor1001 at gmail.com>:
>> Robert Swain wrote:
>>>
>>> 2008/8/19 Robert Swain <robert.swain at gmail.com>:
>>>>
>>>> 2008/8/18 Michael Niedermayer <michaelni at gmx.at>:
>>>>>
>>>>> On Mon, Aug 18, 2008 at 08:42:53PM +0100, Robert Swain wrote:
>
> [...]
>
>>>>>> +            // tns_decode_coef
>>>>>> +            lpc[0] = 1;
>>>>>> +            for (m = 1; m <= order; m++) {
>>>>>> +                lpc[m] = tns->coef[w][filt][m - 1];
>>>>>> +                for (i = 1; i < m; i++)
>>>>>> +                    b[i] = lpc[i] + lpc[m] * lpc[m-i];
>>>>>> +                for (i = 1; i < m; i++)
>>>>>> +                    lpc[i] = b[i];
>>>>>> +            }
>>>>>
>>>>> This loop looks oddly similar to the end of compute_lpc_coefs()
>>>>> and eval_lpc_coeffs() can something be factored out here?
>>>>
>>>> Indeed, the 3GPP ref source calls this code the conversion of PARCOR
>>>> (PARtial autoCORrelation, according to a quick google) coefficients to
>>>> LPC coefficients. It doesn't, however, say what algorithm is used.
>>>>
>>>> Short of fully unrolling the Levinson-Durbin algorithm functions you
>>>> mentioned and comparing to the aac.c code, it's not easy to see if
>>>> they're identical or not, nor which should be used. I'll try comparing
>>>> the results of some conversions before I resort to manual unrolling
>>>> with pen and paper. :)
>>>
>>> Hrm. I can't get eval_lpc_coeffs() to work with a coef input vector
>>> populated from tns_tmp2_map.
>
> [...]
>
>>> It seems the various conditions on in[] and f0 cause it to exit with
>>> an error with the coef[] vectors I've tried and as they're potentially
>>> valid, that's disconcerting for using this code.
>>>
>>> compute_lpc_coefs() accepts a two dimensional lpc array as an
>>> argument. I'm guessing this so that the coefficients are available for
>>> various orders ready for testing to choose which is best or something
>>> like that.
>>>
>>> Do you have any advice for how to proceed? I'm going to keep prodding
>>> eval_lpc_coeffs() in the mean time.
>>
>> Can the following patch be modified to work with AAC too?
>
> I don't like the patch as it is, but you've helped me quite a bit to
> figure this out. :)
>
> lpc[0] = 1 isn't used so I'd like to remove it and start the useful
> coefficients from index 0. With this, the above-quoted loop can be
> rewritten to use part of compute_lpc_coefs():
>
> // tns_decode_coef
> for (m = 0; m < order; m++) {
>    float tmp;
>    lpc[m] = tns->coef[w][filt][m];
>    for (i = 0; i < m/2; i++) {
>        tmp = lpc[i];
>        lpc[i]     += lpc[m] * lpc[m-1-i];
>        lpc[m-1-i] += lpc[m] * tmp;
>    }
>    if(m & 1)
>        lpc[i]     += lpc[m] * lpc[i];
> }
>
> Doing it this way avoids the need for the b[] temporary array and
> produces identical output I think. You should be able to see clearly
> that this is the same as the main loops within compute_lpc_coefs().
> So, now the question is how to refactor this code to satisfy everyone.
>
> Michael - would you like a single generic macro like the one Vitor
> proposes? Or maybe two macros, one for this inner set of loops and one
> for the extra autocorrelation function return value normalisation to
> convert to autocorrelation coefficients and checks that are needed for
> the other implementations? Or something else?

Actually, I think an inline function will be better. I'll have a look
a go at implementing this after I've eaten.

Rob




More information about the ffmpeg-devel mailing list