[FFmpeg-devel] [PATCH] Common ACELP code & G.729 [1/7] - filters

Vladimir Voroshilov voroshil
Sat May 3 10:24:54 CEST 2008


Michael Niedermayer wrote: 
> On Fri, May 02, 2008 at 06:32:27PM +0700, Vladimir Voroshilov wrote:
> > Hi, All
> > 
> > This is updated patch set for G.729 decoder and common ACELP routines.
> > 
> > This patch contains common ACELP filters.
> > I've removed FIR filter from it, because it is more likely belongs to
> > vector related
> > routines (it exactly builds pitch vector).
> > 
> > I've also modified high-pass filter to avoid unnecessary shift, but i
> > still don't know
> > how bitexactness can be archived without code under "ifdef".
> [...]
> 
> > +void ff_acelp_high_pass_filter(
> > +        int16_t* out,
> > +        int16_t* hpf_z,
> > +        int* hpf_f,
> > +        const int16_t* in,
> > +        int length)
> > +{
> > +    int i;
> > +
> > +    for(i=0; i<length; i++)
> > +    {
> > +        memmove(hpf_z + 1, hpf_z, 2 * sizeof(hpf_z[0]));
> 
> > +        hpf_z[0] = in[i];
> > +
> > +        /* Note: to make result bitexact with G.729 reference code,
> > +           two least significant bits of each value returned by MULL
> > +           should be cleared */
> > +        hpf_f[0] =  MULL(hpf_f[1], 15836); // (15.14) = (14.14) * (1.13)
> > +#ifdef G729_BITEXACT
> > +        hpf_f[0] &= ~3;
> > +#endif
> > +        hpf_f[0] += MULL(hpf_f[2], -7667); // (14.14) = (14.14) * (0.13)
> > +#ifdef G729_BITEXACT
> > +        hpf_f[0] &= ~3;
> > +#endif
> > +        /* (16.14) = (3.13) * (14.0) */
> > +        hpf_f[0] += 30796 * (hpf_z[0] - 2*hpf_z[1] + hpf_z[2]);
> > +
> > +        /* Multiplication by 2 with rounding can cause short type
> > +           overflow, thus clipping is required. */
> > +
> > +        /* (15.0) = 2 * (14.14) */
> > +        out[i] = av_clip_int16((hpf_f[0] + 0x2000) >> 14);
> 
>         hpf_z[0] = in[i];
> 
>         hpf_f[0] =  MULL(hpf_f[1], 15836);
> 
>         hpf_f[0] += MULL(hpf_f[2], -7667);
> 
>         hpf_f[0] += 7699 * (hpf_z[0] - 2*hpf_z[1] + hpf_z[2]);
>         out[i] = av_clip_int16((hpf_f[0] + 0x800) >> 12);

Heh. I was walking around this solution for a long time
and didn't see such trivial thing. Thanks. Fixed.

> 
> 
> 
> [...]
> > +#ifndef FFMPEG_ACELP_FILTERS_H
> > +#define FFMPEG_ACELP_FILTERS_H
> > +
> 
> > +/**
> > + * \brief Circularly convolve fixed vector with a phase dispersion impulse
> > + *        response filter (D.6.2 of G.729 and 6.1.5 of AMR)
> > + * \param fc_out vector with filter applied
> > + * \param fc_in source vector
> > + * \param filter phase filter coefficients
> > + *
> > + * \note fc_in and fc_out should not overlap!
> > + */
> 
> This really should contain the mathemathical formular this function
> implements.
> fc_out[x] = sum(i,0..n) fc_in[i]*filter[x-i]>>15
> or something like that it is if iam not wrong

Fixed.

> 
> 
> [...]
 
-- 
Regards,
Vladimir Voroshilov mailto:voroshil at gmail.com
Omsk State University
JID: voroshil at jabber.ru
ICQ: 95587719
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 01_acelp_filt_41.diff
Type: text/x-diff
Size: 7720 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080503/54884bb8/attachment.diff>



More information about the ffmpeg-devel mailing list