[FFmpeg-devel] [PATCH] Common ACELP code & G.729 [1/7] - filters
Michael Niedermayer
michaelni
Fri May 2 20:20:34 CEST 2008
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);
[...]
> +#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
[...]
--
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/20080502/89bb9919/attachment.pgp>
More information about the ffmpeg-devel
mailing list