[FFmpeg-devel] [PATCH] Common ACELP routines (2/3) - filters

Michael Niedermayer michaelni
Sun Apr 27 00:08:55 CEST 2008


On Sun, Apr 27, 2008 at 03:12:39AM +0700, Vladimir Voroshilov wrote:
> On Sun, Apr 27, 2008 at 1:14 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> >
> > On Sun, Apr 27, 2008 at 01:05:32AM +0700, Vladimir Voroshilov wrote:
> >  > On Sun, Apr 27, 2008 at 12:41 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> >  > > On Sat, Apr 26, 2008 at 11:11:56PM +0700, Vladimir Voroshilov wrote:
> >  > >
> >  > > > On Fri, Apr 25, 2008 at 6:16 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> >  > >  >
> >  > >  > [...]
> >  > >  >
> >  > >  > >  Yes thats also what i thought at first but vladimirs insistance made
> >  > >  > >  me belive that the output of this function would be the final audio
> >  > >  > >  samples returned from "decode_audio". In which cases one of course
> >  > >  > >  cannot have 10 samples before it.
> >  > >  > >  Now after looking at the actual code its clear that there are always
> >  > >  > >  some other filters applied afterwards. So i agree, none of this makes
> >  > >  > >  sense, no double writing, no special case for the first "10" samples
> >  > >  > >  nor a memcpy() should be needed. Except a memcpy to move the first
> >  > >  > >  "10" samples to the buffer start.
> >  > >  >
> >  > >  > To tell the truth i didn't understand should i fix patch somehow or
> >  > >  > not according to above.
> >  > >
> >  > >  ff_acelp_lp_synthesis_filter_inplace() is exactly what we need,
> >  > >  ff_acelp_lp_synthesis_filter() is unneeded, please remove it.
> >  > >
> >  > >
> >  > >
> >  > >  >
> >  > >  > After splitting ff_acelp_lp_synthesis_filter, one of routines still
> >  > >  > requires additional 10 items in filter data. It is possible to avoid
> >  > >  > such requirement in cost of additional 20 bytes long memcpy.
> >  > >  > But i don't know will this improve something or not.
> >  > >
> >  > >  Only a single memcpy() of 10 elements is needed.
> >  > >
> >  > >  memcpy(buf, buf+N, 10);
> >  > >  overflow= acelp_lp_synthesis_filter(buf+10, input, N);
> >  > >  if(overflow){
> >  > >     for(i=0; i<N; i++)
> >  > >         input[i]>>=123;
> >  > >     acelp_lp_synthesis_filter(buf+10, input, N);
> >  > >  }
> >  >
> >  > buf is subframe_size+10 long as i see.
> >  > And this will require copy from buf to output_data
> >  > (explicit via memcpy or implicit, e.g. high-pass filter should put
> >  > data directly to output_data instead of it's input buffer)
> >  > Second is preferred, right?
> 
> Fixed in attached patch.
> I've removed second lp_synthesis routine (with additional memcpy).
> Now lp synthesis filter is used as in your sample (but memcpy is made
> right after call to routines, because saved data should not be
> affected by postfilter).
> 
> I've also added additional parameter (instead of hardcoded "11") -
> filter_length.
> Now code can be potentially used for non-10th order filters too.
> I think this will make things a bit more clear to undestand.

[...]
> +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));
> +
> +    for(i=0; i<subframe_size; i++)
> +    {
> +        if(fc_in[i])
> +        {
> +            for(k=0; k<i; k++)
> +                fc_out[k] += (fc_in[i] * filter[subframe_size + k - i]) >> 15;
> +
> +            for(k=i; k<subframe_size; k++)
> +                fc_out[k] += (fc_in[i] * filter[k - i]) >> 15;
> +        }
> +    }
> +}

where is this used? I cant find it in g729dec_18.diff


> +
> +int ff_acelp_lp_synthesis_filter(
> +        int16_t *out,
> +        const int16_t* filter_coeffs,
> +        const int16_t* in,
> +        int buffer_length,
> +        int filter_length,
> +        int stop_on_overflow)
> +{
> +    int i,n;
> +    int sum;
> +
> +    for(n=0; n<buffer_length; n++)
> +    {

> +        sum = in[n] << 12;
> +        for(i=1; i<filter_length; i++)
> +            sum -= filter_coeffs[i] * out[n-i];
> +
> +        sum = (sum + 0x800) >> 12;

sum= 0x800;
for(i=1; i<filter_length; i++)
    sum -= filter_coeffs[i] * out[n-i];
sum = (sum >> 12) + in[n];


[...]
> +void ff_acelp_weighted_filter(
> +        int16_t *out, 
> +        const int16_t* in,
> +        int16_t weight,
> +        int filter_length)
> +{
> +    int weight_pow = 1 << 15;
> +    int n;
> +
> +    for(n=0; n<filter_length; n++)
> +    {

> +        // (0.15) * (3.12) -> (3.12) with rounding

please write the comment in the same order as the calculation:
(3.12) = (0.15) * (3.12) or whatever


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

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact
-------------- 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/20080427/3cc24e95/attachment.pgp>



More information about the ffmpeg-devel mailing list