comparison lsp.c @ 10011:c1cfa4679371 libavcodec

Expose QCELP's floating-point LSP-to-LPC function qcelp_lsp exported a single function, ff_acelp_lspd2lpc, which was not specific to qcelp. It can be kept with its fixed-point version ff_acelp_lsp2lpc in lpc.c. Patch by Colin McQuillan ( m.niloc googlemail com )
author superdump
date Mon, 03 Aug 2009 08:37:02 +0000
parents c6e2ffef3797
children 9f35b262d3f0
comparison
equal deleted inserted replaced
10010:18dab2b47db7 10011:c1cfa4679371
1 /* 1 /*
2 * LSP routines for ACELP-based codecs 2 * LSP routines for ACELP-based codecs
3 * 3 *
4 * Copyright (c) 2007 Reynaldo H. Verdejo Pinochet (QCELP decoder)
4 * Copyright (c) 2008 Vladimir Voroshilov 5 * Copyright (c) 2008 Vladimir Voroshilov
5 * 6 *
6 * This file is part of FFmpeg. 7 * This file is part of FFmpeg.
7 * 8 *
8 * FFmpeg is free software; you can redistribute it and/or 9 * FFmpeg is free software; you can redistribute it and/or
116 ff_acelp_lsp2lpc(lp_1st, lsp_1st, lp_order >> 1); 117 ff_acelp_lsp2lpc(lp_1st, lsp_1st, lp_order >> 1);
117 118
118 /* LSP values for second subframe (3.2.5 of G.729)*/ 119 /* LSP values for second subframe (3.2.5 of G.729)*/
119 ff_acelp_lsp2lpc(lp_2nd, lsp_2nd, lp_order >> 1); 120 ff_acelp_lsp2lpc(lp_2nd, lsp_2nd, lp_order >> 1);
120 } 121 }
122
123 /**
124 * Computes the Pa / (1 + z(-1)) or Qa / (1 - z(-1)) coefficients
125 * needed for LSP to LPC conversion.
126 * We only need to calculate the 6 first elements of the polynomial.
127 *
128 * @param lsp line spectral pairs in cosine domain
129 * @param f [out] polynomial input/output as a vector
130 *
131 * TIA/EIA/IS-733 2.4.3.3.5-1/2
132 */
133 static void lsp2polyf(const double *lsp, double *f, int lp_half_order)
134 {
135 int i, j;
136
137 f[0] = 1.0;
138 f[1] = -2 * lsp[0];
139 lsp -= 2;
140 for(i=2; i<=lp_half_order; i++)
141 {
142 double val = -2 * lsp[2*i];
143 f[i] = val * f[i-1] + 2*f[i-2];
144 for(j=i-1; j>1; j--)
145 f[j] += f[j-1] * val + f[j-2];
146 f[1] += val;
147 }
148 }
149
150 void ff_acelp_lspd2lpc(const double *lsp, float *lpc)
151 {
152 double pa[6], qa[6];
153 int i;
154
155 lsp2polyf(lsp, pa, 5);
156 lsp2polyf(lsp + 1, qa, 5);
157
158 for (i=4; i>=0; i--)
159 {
160 double paf = pa[i+1] + pa[i];
161 double qaf = qa[i+1] - qa[i];
162
163 lpc[i ] = 0.5*(paf+qaf);
164 lpc[9-i] = 0.5*(paf-qaf);
165 }
166 }