[FFmpeg-devel] [PATCH] QCELP decoder

Michael Niedermayer michaelni
Sun Oct 5 02:16:18 CEST 2008


On Fri, Oct 03, 2008 at 03:48:52PM -0700, Kenan Gillet wrote:
> Hi,
> 
> here is a round 2 of the patch based on feedback from Vitor and Diego.
> It includes:
> - some spelling/grammar fixes,
> - some cosmetics,
> - changes to output float instead of int,
> - bug fixes uncovered from the change of output,
> - improvements to the pitch pre/synthesis filters.
[...]
> +/**
> + * Linear convolution of two vectors v1 and [1, cos, 1]
> + *
> + * @param v_out the result of the convolution, needs to be able to hold v_in_len + 2 elements
> + * @param v_in the input vector
> + * @param cos
> + * @param v_in_len the dimension of v_in assumed to be in  {2,4,6,8,10}
> + */
> +static void convolve(float *v_out, const float *v_in, const float cos, const int v_in_len) {
> +    int   i;
> +
> +    v_out[0] = v_in[0];
> +    v_out[1] = v_in[1] + v_in[0] * cos;
> +    for (i = 2; i < v_in_len; i++) {
> +        v_out[i] = v_in[i]
> +                 + v_in[i - 1] * cos
> +                 + v_in[i - 2];
> +    }
> +    v_out[v_in_len    ] = v_in[v_in_len - 1] * cos + v_in[v_in_len - 2];
> +    v_out[v_in_len + 1] = v_in[v_in_len - 1];
> +}
> +
> +/**
> + * Computes the Pa and Qa coefficients needed for LSP to LPC conversion.
> + *
> + * TIA/EIA/IS-733 2.4.3.3.5-1/2
> + */
> +static void lsp2poly(float *poly, const float *lspf, float *v_in, float *v_buf, const int odd) {
> +    int   i;
> +    float *v1 = v_in, *v2 = v_buf;
> +
> +    for (i = 0; i < 10; i += 2) {
> +        convolve(v2, v1, -2*cos(M_PI*lspf[i + odd]), i + 2);
> +        FFSWAP(float *, v1, v2);
> +    }
> +    memcpy(poly, v1 + 1, 5 * sizeof(float));
> +}
> +
> +/**
> + * Reconstructs LPC coefficients from the line spectral pairs frequencies.
> + *
> + * TIA/EIA/IS-733 2.4.3.3.5
> + */
> +static void lspf2lpc(const float *lspf, float *lpc) {
> +    float pa[5],qa[5];
> +    float v1[12], v2[12];
> +    float beta = 0.9883;
> +    int   i;
> +
> +    v1[0] = 1.0;
> +    v1[1] = 1.0;
> +    lsp2poly(pa, lspf, v1, v2, 0);
> +
> +    v1[0] =  1.0;
> +    v1[1] = -1.0;
> +    lsp2poly(qa, lspf, v1, v2, 1);
> +
> +    for (i=0; i< 5; i++) {
> +        lpc[i]=-(pa[i]+qa[i])/2.0*beta;
> +        beta *= 0.9883;
> +    }
> +    for (i=5; i<10; i++) {
> +        lpc[i]=-(pa[9-i]-qa[9-i])/2.0*beta;
> +        beta *= 0.9883;
> +    }
> +}

the lsp code belongs in a seperate file as it will be usefull for
other celp codecs
also check it against wma_lsp_to_curve() and the code in vorbis
they might do something similar

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

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
-------------- 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/20081005/beff8527/attachment.pgp>



More information about the ffmpeg-devel mailing list