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

Michael Niedermayer michaelni
Tue May 6 22:42:17 CEST 2008


On Tue, May 06, 2008 at 11:24:38PM +0700, Vladimir Voroshilov wrote:
> On Mon, May 5, 2008 at 3:42 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Sun, May 04, 2008 at 01:19:10PM +0700, Vladimir Voroshilov wrote:
> >  > On Sat, May 3, 2008 at 7:23 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> >  > > On Sat, May 03, 2008 at 03:24:54PM +0700, Vladimir Voroshilov wrote:
> >  > >  > Michael Niedermayer wrote:
> >  > >  [...]
> >  > >  > +void ff_acelp_convolve_circ(
> >  > >  > +        int16_t* fc_out,
> >  > >  > +        const int16_t* fc_in,
> >  > >  > +        const int16_t* filter,
> >  > >  > +        int subframe_size)
> >  > >  > +{
> >  > >  > +    int i, k;
> >  > >  > +
> >  > >  > +    memset(fc_out, 0, subframe_size * sizeof(int16_t));
> >  > >
> >  > > > +
> >  > >  > +    /* Since there are few pulses over all subframe (i.e. almost all
> >  > >
> >  > > > +       fc_in[i] are zero, in case of G.729D it is only two non-zero
> >  > >  > +       samples of total 40), it is faster to swap two loops and process
> >  > >  > +       non-zero samples only. This will reduce number of multiplications
> >  > >
> >  > > > +       from 40*40 to 2*40 for G.729D */
> >  > >
> >  > >  doesnt ff_acelp_fc_enchance_harmonics() increase the number of non 0
> >  > >  elements above 2 ?
> >  >
> >  > Perhaps i misspelled sentence.
> >  > I meant that using swapped loops with checking for non-zero will
> >  > require 2*40 multiplications,
> >
> >  The sentance is fine.
> >  What i meant is that ff_acelp_fc_enchance_harmonics() can increase the number
> >  of non zero samples above 2. Or do i miss somehing that prevents this?
> 
> This is exactly what this filter intended to do.
> It get buffer with few pulses and smooth them over all subframe.
> In reference code it is caller "pitch_shrp" ("pitch sharpening" i guess).

What iam trying to say is, if ff_acelp_fc_enchance_harmonics() increases the
number of non zero samples above 2 then the comment is no longer correct.
As its no longer exactly 2 for g729d


[...]
> +
> +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];
> +        hpf_f[0] =  MULL(hpf_f[1], 15836);                     /* (14.13) = (13.13) * (1.13) */
> +        hpf_f[0] += MULL(hpf_f[2], -7667);                     /* (13.13) = (13.13) * (0.13) */
> +        hpf_f[0] += 7699 * (hpf_z[0] - 2*hpf_z[1] + hpf_z[2]); /* (14.13) =  (0.13) * (14.0) */
> +
> +        /* Multiplication by 2 with rounding can cause short type
> +           overflow, thus clipping is required. */
> +
> +        out[i] = av_clip_int16((hpf_f[0] + 0x800) >> 12);      /* (15.0) = 2 * (13.13) = (14.13) */
> +
> +        memmove(hpf_f + 1, hpf_f, 2 * sizeof(hpf_f[0]));
> +    }


t =  MULL(hpf_f[0], 15836);                     /* (14.13) = (13.13) * (1.13) */
   + MULL(hpf_f[1], -7667);                     /* (13.13) = (13.13) * (0.13) */
   + 7699 * (in[i] - 2*in[i-1] + in[i-2]);      /* (14.13) =  (0.13) * (14.0) */

out[i] = av_clip_int16((t + 0x800) >> 12);      /* (15.0) = 2 * (13.13) = (14.13) */

hpf_f[1]= hpf_f[0];
hpf_f[0]= t;


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- 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/20080506/95f70ed2/attachment.pgp>



More information about the ffmpeg-devel mailing list