[FFmpeg-devel] [PATCH] add fixed coeff LPC mode to alac encoder

Justin Ruggles justin.ruggles
Mon Oct 5 02:53:03 CEST 2009


Michael Niedermayer wrote:

> On Thu, Oct 01, 2009 at 08:03:09PM -0400, Justin Ruggles wrote:
>> Hi,
>>
>> We currently do not have a regression test for the ALAC encoder like we
>> do for FLAC.  The ALAC encoder has 2 compression levels, one
>> uncompressed, which does not cover much of the code, and one which uses
>> floating point when calculating LPC coefficients, which does not lend
>> itself to reliable regression tests across all test platforms.
>>
>> The way we do regression testing with FLAC is to use the fixed LPC
>> coefficient mode, which skips the floating-point parts but still covers
>> prediction, entropy coding, and other parts in the regression test.
>>
>> Here is a patch to the ALAC encoder to add a fixed-coeff LPC mode using
>> compression_level == 1.  This will allow us to add a round-trip
>> encode/decode regression test.  The default compression level is changed
>> to 2 and keeps the same behavior.  The fixed-coeff mode is about 20%
>> faster but has about 6% worse compression (about the same as FLAC with
>> compression level 2).
>>
>> Thanks,
>> Justin
>>
> 
>>  alacenc.c |   13 +++++++++++--
>>  1 file changed, 11 insertions(+), 2 deletions(-)
>> f1f4235083438379b9b828846668c463de9addf2  alac_compr1.patch
>> Index: libavcodec/alacenc.c
>> ===================================================================
>> --- libavcodec/alacenc.c	(revision 20134)
>> +++ libavcodec/alacenc.c	(working copy)
>> @@ -132,12 +132,21 @@
>>      int shift[MAX_LPC_ORDER];
>>      int opt_order;
>>  
>> +    if (s->avctx->compression_level > 1) {
>>      opt_order = ff_lpc_calc_coefs(&s->dspctx, s->sample_buf[ch], s->avctx->frame_size, s->min_prediction_order, s->max_prediction_order,
>>                                     ALAC_MAX_LPC_PRECISION, coefs, shift, 1, ORDER_METHOD_EST, ALAC_MAX_LPC_SHIFT, 1);
>>  
>>      s->lpc[ch].lpc_order = opt_order;
>>      s->lpc[ch].lpc_quant = shift[opt_order-1];
>>      memcpy(s->lpc[ch].lpc_coeff, coefs[opt_order-1], opt_order*sizeof(int));
>> +    } else {
>> +        s->lpc[ch].lpc_order = 4;
>> +        s->lpc[ch].lpc_quant = 3;
>> +        s->lpc[ch].lpc_coeff[0] = -4;
>> +        s->lpc[ch].lpc_coeff[0] =  6;
>> +        s->lpc[ch].lpc_coeff[0] = -4;
>> +        s->lpc[ch].lpc_coeff[0] =  1;
> 
> these coefficients do not look optimal, did you generate them using the LPC
> code over a large number of audio samples? You should IMHO!

you're right.  i did some more testing and found coeffs that come within
about 1% of compression level 2 with most samples tested.

> besides, are you sure you want to assign them all to lpc_coeff[0] ?

oops... yeah, that would help. :)

new patch attached.

-Justin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: alac_compr1_v2.patch
Type: text/x-diff
Size: 1564 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091004/a844b6da/attachment.patch>



More information about the ffmpeg-devel mailing list