[FFmpeg-devel] [PATCH/RFC] Remove triplication of compute_lpc_coefs() function

Michael Niedermayer michaelni
Tue Sep 2 03:25:32 CEST 2008


On Mon, Sep 01, 2008 at 07:03:23AM +0200, Vitor Sessak wrote:
> Michael Niedermayer wrote:
>> On Sun, Aug 31, 2008 at 05:08:26AM +0200, Vitor Sessak wrote:
>>> Michael Niedermayer wrote:
>>>> On Thu, Aug 28, 2008 at 02:28:50PM +0200, Vitor Sessak wrote:
>>>>> Hi all.
>>>>>
>>>>> I've finally found a more or less clean way of doing $subj. 
[...]
>> [...]
>>> Index: libavcodec/lpc.h
>>> ===================================================================
>>> --- libavcodec/lpc.h	(revision 15050)
>>> +++ libavcodec/lpc.h	(working copy)
>>> @@ -45,4 +45,66 @@
>>>                        int32_t coefs[][MAX_LPC_ORDER], int *shift, int 
>>> use_lpc,
>>>                        int omethod, int max_shift, int zero_shift);
>>>  +
>>> +#ifdef LPC_USE_DOUBLE
>>> +#define LPC_type double
>>> +#else
>>> +#define LPC_type float
>>> +#endif
>>> +
>>> +/**
>>> + * Levinson-Durbin recursion.
>>> + * Produces LPC coefficients from autocorrelation data.
>>> + */
>>> +static inline int compute_lpc_coefs(const LPC_type *autoc,
>>> +                                    int max_order,
>>> +                                    LPC_type lpc[][MAX_LPC_ORDER],
>>> +                                    LPC_type *ref,
>>> +                                    LPC_type lpc_tmp[MAX_LPC_ORDER],
>>> +                                    int fail, int normalize)
>>> +{
>>> +    int i, j;
>>> +    LPC_type err = autoc[0];
>>> +
>>> +    if (fail && (autoc[max_order] == 0 || autoc[0] <= 0))
>>> +        return -1;
>>> +
>>> +    for(i=0; i<max_order; i++) {
>>> +        LPC_type r;
>>> +        if (normalize) {
>>> +            r = -autoc[i+1];
>>> +
>>> +            for(j=0; j<i; j++)
>>> +                r -= lpc_tmp[j] * autoc[i-j];
>>> +
>>> +            r /= err;
>>> +        } else
>>> +            r = -autoc[i];
>> This can be factored out of the loop when autoc+1 is passed as argument
>> instead of autoc for !normalize
>
> I don't like it because I'll need to check autoc[-1] in the beginning...

i meant autoc-1
and there is no check for the !normalize case so no change to it because
fail implicates normalize

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

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable
-------------- 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/20080902/ce8ae9f9/attachment.pgp>



More information about the ffmpeg-devel mailing list