[FFmpeg-devel] AMR-NB decoder

Michael Niedermayer michaelni
Sat Aug 8 14:54:11 CEST 2009


On Fri, Aug 07, 2009 at 08:23:53PM +0100, Colin McQuillan wrote:
> 2009/8/6 Michael Niedermayer <michaelni at gmx.at>:
> > On Wed, Aug 05, 2009 at 05:51:36PM +0100, Colin McQuillan wrote:
> >> Attached is a patch for an AMR-NB decoder.
> 
> [...]
> 
> >>
> >> +void ff_celp_convolve_circf(float* fc_out,
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ?const float* fc_in,
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ?const float* filter,
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ?int len)
> >> +{
> >> + ? ?int i, k;
> >> +
> >> + ? ?memset(fc_out, 0, len * sizeof(float));
> >> +
> >> + ? ?/* Since there are few pulses over an entire subframe (i.e. almost
> >> + ? ? ? all fc_in[i] are zero) it is faster to loop over fc_in first. */
> >> + ? ?for (i = 0; i < len; i++) {
> >> + ? ? ? ?if (fc_in[i]) {
> >> + ? ? ? ? ? ?for (k = 0; k < i; k++)
> >> + ? ? ? ? ? ? ? ?fc_out[k] += fc_in[i] * filter[len + k - i];
> >> +
> >> + ? ? ? ? ? ?for (k = i; k < len; k++)
> >> + ? ? ? ? ? ? ? ?fc_out[k] += fc_in[i] * filter[ ? ? ?k - i];
> >> + ? ? ? ?}
> >> + ? ?}
> >> +}
> >> +
> >> ?int ff_celp_lp_synthesis_filter(int16_t *out,
> >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const int16_t* filter_coeffs,
> >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const int16_t* in,
> >> Index: libavcodec/celp_filters.h
> >> ===================================================================
> >> --- libavcodec/celp_filters.h (revision 19598)
> >> +++ libavcodec/celp_filters.h (working copy)
> >> @@ -42,6 +42,22 @@
> >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? int len);
> >>
> >> ?/**
> >> + * 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
> >> + *
> >> + * ?fc_out[n] = sum(i,0,len-1){ fc_in[i] * filter[(len + n - i)%len] }
> >> + *
> >> + * \note fc_in and fc_out should not overlap!
> >> + */
> >> +void ff_celp_convolve_circf(float* fc_out,
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ?const float* fc_in,
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ?const float* filter,
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ?int len);
> >> +
> >> +/**
> >> ? * LP synthesis filter.
> >> ? * @param out [out] pointer to output buffer
> >> ? * @param filter_coeffs filter coefficients (-0x8000 <= (3.12) < 0x8000)
> >
> > that should e a seperate patch
> 
> I'll leave this one until I investigate a version for sparse vectors. Attached:
> 
> 1. Helper functions for gain control in floating-point codecs
> I couldn't find a similar fixed point function to copy the function name.
> 
> 2. Floating-point version of ff_acelp_high_pass_filter

>  acelp_vectors.c |   22 ++++++++++++++++++++++
>  acelp_vectors.h |   27 +++++++++++++++++++++++++++
>  2 files changed, 49 insertions(+)
> f1abbee9b62c1779fd5fb1c634d4ab4294d8611d  get-set-energyf.patch
> Index: libavcodec/acelp_vectors.c
> ===================================================================
> --- libavcodec/acelp_vectors.c	(revision 19606)
> +++ libavcodec/acelp_vectors.c	(working copy)
> @@ -155,3 +155,25 @@
>          out[i] = weight_coeff_a * in_a[i]
>                 + weight_coeff_b * in_b[i];
>  }
> +
> +float ff_energyf(const float *v, int length)
> +{
> +    float sum = 0;
> +    int i;
> +
> +    for (i = 0; i < length; i++)
> +        sum += v[i] * v[i];
> +
> +    return sum;
> +}

ff_dot_productf)(


> +
> +void ff_set_energyf(float *v_out, const float *v_in, float energy,
> +                    const int length)
> +{
> +    int i;
> +    float scalefactor = ff_energyf(v_in, length);
> +    if (scalefactor)
> +        scalefactor = sqrt(energy / scalefactor);
> +    for (i = 0; i < length; i++)
> +        v_out[i] = v_in[i] * scalefactor;
> +}

somehow this looks similar to apply_gain_ctrl() in qcelp


[...]
-- 
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/20090808/88d7a141/attachment.pgp>



More information about the ffmpeg-devel mailing list