[FFmpeg-devel] [PATCH] Common ACELP code & G.729 [2/7] - pitch lag decoding

Michael Niedermayer michaelni
Thu Jun 26 21:27:22 CEST 2008


On Fri, Jun 27, 2008 at 12:00:01AM +0700, Vladimir Voroshilov wrote:
> Both  issues (two routines join and extra #define) are fixed.
[...]
> +void ff_acelp_update_past_gain(
> +    int16_t* quant_energy,
> +    int gain_corr_factor,
> +    int log2_ma_pred_order,
> +    int erasure)
> +{
> +    int i;
> +    int avg_gain=quant_energy[(1 << log2_ma_pred_order) - 1]; // (5.10)
> +
> +    for(i=(1 << log2_ma_pred_order) - 1; i>0; i--)
> +    {
> +        avg_gain       += quant_energy[i-1];
> +        quant_energy[i] = quant_energy[i-1];
> +    }
> +
> +    if(erasure)
> +        quant_energy[0] = FFMAX(avg_gain >> log2_ma_pred_order, -10240) - 4096; // -10 and -4 in (5.10)
> +    else
> +        quant_energy[0] = (24660 * ((ff_log2(gain_corr_factor) >> 2) - (13 << 13))) >> 15;

quant_energy[0] = (6165 * ((ff_log2(gain_corr_factor) >> 2) - (13 << 13))) >> 13;


> +}
> +
> +int16_t ff_acelp_decode_gain_code(
> +    int gain_corr_factor,
> +    const int16_t* fc_v,
> +    int mr_energy,
> +    const int16_t* quant_energy,
> +    const int16_t* ma_prediction_coeff,
> +    int subframe_size,
> +    int ma_pred_order)
> +{
> +    int i;
> +    int energy;
> +    int innov_energy;
> +

> +    energy = mr_energy << 10;

redundant variables

> +
> +    for(i=0; i<ma_pred_order; i++)
> +        energy += quant_energy[i] * ma_prediction_coeff[i];
> +
> +    innov_energy = sum_of_squares(fc_v, subframe_size, 0, 0);
> +#ifdef G729_BITEXACT

> +    energy +=  MULL(ff_log2(innov_energy), -24660) << 10;     

s/24660/6165/
and i wonder if a normal * would do with the correctly simplified constant?


> +
> +    energy = (5439 * (energy >> 15)) >> 8;           // (0.15) = (0.15) * (7.23)
> +

> +    return bidir_sal(((ff_exp2(energy & 0x7fff) + 16) >> 5) * (gain_corr_factor >> 1), (energy >> 15) - 25);

I think what i suggested was quite a bit more readable


> +#else
> +    energy = gain_corr_factor * exp(M_LN10 * energy / (20 << 23)) / sqrt(innov_energy);

exp(M_LN10 / (20 << 23) * energy)
that way the compiler can simplify the constants

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

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope
-------------- 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/20080626/2c3e7929/attachment.pgp>



More information about the ffmpeg-devel mailing list