[FFmpeg-devel] [PATCH] Common ACELP routines (3/3) - LPC decoding routines

Robert Swain robert.swain
Wed Apr 23 16:45:11 CEST 2008

On 23 Apr 2008, at 14:42, Michael Niedermayer wrote:
> On Wed, Apr 23, 2008 at 02:02:50PM +0100, Robert Swain wrote:
>> On 23 Apr 2008, at 01:38, Michael Niedermayer wrote:
>>> On Tue, Apr 22, 2008 at 01:21:24AM +0700, Vladimir Voroshilov wrote:
>>>> This patch contains several routines related to LP filter
>>>> coefficients
>>>> decoding (not all, but those which
>>>> looks like AMR's).
>>> [...]
>>>> diff --git a/libavcodec/acelp_lpc.c b/libavcodec/acelp_lpc.c
>>>> new file mode 100644
>>>> index 0000000..65b870d
>>>> --- /dev/null
>>>> +++ b/libavcodec/acelp_lpc.c
>>> lsp.c
>> I'd prefer *lpc.* as the code relates to linear predictive coding
>> functions and not just line spectral pairs. But as you please - what
>> is in a name? :)
> they could also be split in lsp.c lpc.c :)

I don't think it's worth splitting that much.

>> Isn't there some LPC code in FLAC? Is any of that useful?

No comment?

>>> [...]
>>>> +void ff_acelp_reorder_lsf(int16_t* lsfq, int16_t
>>>> lsfq_min_distance, int16_t lsfq_min, int16_t lsfq_max)
>>>> +{
>>>> +    int i;
>>>> +
>>>> +    lsfq[0] = FFMAX(lsfq[0], lsfq_min); //Is warning required ?
>>>> +
>>>> +    for(i=0;i<9; i++)
>>>> +        lsfq[i+1] = FFMAX(lsfq[i+1], lsfq[i] + lsfq_min_distance);
>>> simplification stolen from soc/amrnbdec.c:
>>> for(i=0; i<10; i++){
>>>   lsf[i] = FFMAX(lsf[i], lsf_min);
>>>   lsf_min = lsf[i] + min_distance;
>>> }
>>> also id make lsfq_min_distance and lsfq_min/max int
>>> ahh, and reorder_lsf() in soc/amrnbdec.c is buggy (uninitalized var)
>> Fixed. :)
>> I haven't looked at these patches yet. I'll try to take a look now.
>> I've forgotten the fixed point code because I didn't like fixed  
>> point,
>> gave up on it, rewrote the spec on the wiki and wrote a float version
>> which is in the debugging phase. I'll see if I have any useful
>> comments on the patches though as I would like to have shared  
>> code. :)
> great :)

I had a look through them and sent Vladimir an e-mail with a couple of  
things to take a look at. Most of it looks good to me and I'm glad the  
code has been annotated with the powers of two quantisation for  
variables. Fixed point without such notes is a serious headache to read.

AMR NB uses 1/3rd and 1/6th resolution pitch lags so maybe when AMR  
returns to being my priority some extra stuff can be added to this  
shared code. AMR-WB uses something slightly different (ISFs vs LSFs,  
though I'm not sure how they differ yet) and, uses different sized  
subframes and such I think so more items can be added then too.

With code like this I'm sure we can soon be churning out LPC speech  
decoder implementations as there isn't all that much to them. Then  
we'll just have to do the same for encoding. :)

I suppose it would be a good test of the shared code if AMR-NB were to  
be implemented using them. Maybe I'll revisit the fixed point code  
sometime. :)


More information about the ffmpeg-devel mailing list