aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReynaldo H. Verdejo Pinochet <reynaldo@opendot.cl>2009-03-04 01:28:07 +0000
committerReynaldo H. Verdejo Pinochet <reynaldo@opendot.cl>2009-03-04 01:28:07 +0000
commit77bd18e117176213bdb4e7cbcf7b17662ab99300 (patch)
treebfce0c558bbecd861d41a28ae4e24d6506e03fa2
parente1374c06d6f68629573b1c79b2f57cc4bb12e768 (diff)
downloadffmpeg-77bd18e117176213bdb4e7cbcf7b17662ab99300.tar.gz
Part 1 of 2 of Kenan Gillet's 'make ff_qcelp_lspf2lpc
more general' changeset. This one splits ff_qcelp_lspf2lpc into the QCELP-especific ff_qcelp_lspf2lpc + the more general ff_qcelp_lspf2lpc. Originally committed as revision 17799 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/qcelp_lsp.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/libavcodec/qcelp_lsp.c b/libavcodec/qcelp_lsp.c
index a29f26263c..7f920f5f1d 100644
--- a/libavcodec/qcelp_lsp.c
+++ b/libavcodec/qcelp_lsp.c
@@ -48,16 +48,16 @@
*
* TIA/EIA/IS-733 2.4.3.3.5-1/2
*/
-static void lsp2polyf(const float *lspf, double *f, int lp_half_order)
+static void lsp2polyf(const double *lspf, double *f, int lp_half_order)
{
int i, j;
f[0] = 1.0;
- f[1] = -2 * cos(M_PI * lspf[0]);
+ f[1] = -2 * lspf[0];
lspf -= 2;
for(i=2; i<=lp_half_order; i++)
{
- double val = -2 * cos(M_PI * lspf[2*i]);
+ double val = -2 * lspf[2*i];
f[i] = val * f[i-1] + 2*f[i-2];
for(j=i-1; j>1; j--)
f[j] += f[j-1] * val + f[j-2];
@@ -66,22 +66,15 @@ static void lsp2polyf(const float *lspf, double *f, int lp_half_order)
}
/**
- * Reconstructs LPC coefficients from the line spectral pair frequencies
- * and performs bandwidth expansion.
+ * Reconstructs LPC coefficients from the line spectral pair frequencies.
*
* @param lspf line spectral pair frequencies
* @param lpc linear predictive coding coefficients
- *
- * @note: bandwith_expansion_coeff could be precalculated into a table
- * but it seems to be slower on x86
- *
- * TIA/EIA/IS-733 2.4.3.3.5
*/
-void ff_qcelp_lspf2lpc(const float *lspf, float *lpc)
+void ff_celp_lspf2lpc(const double *lspf, float *lpc)
{
double pa[6], qa[6];
int i;
- double bandwith_expansion_coeff = QCELP_BANDWITH_EXPANSION_COEFF * 0.5;
lsp2polyf(lspf, pa, 5);
lsp2polyf(lspf + 1, qa, 5);
@@ -91,9 +84,34 @@ void ff_qcelp_lspf2lpc(const float *lspf, float *lpc)
double paf = pa[i+1] + pa[i];
double qaf = qa[i+1] - qa[i];
- lpc[i ] = paf + qaf;
- lpc[9-i] = paf - qaf;
+ lpc[i ] = 0.5 * (paf+qaf);
+ lpc[9-i] = 0.5 * (paf-qaf);
}
+}
+
+/**
+ * Reconstructs LPC coefficients from the line spectral pair frequencies
+ * and performs bandwidth expansion.
+ *
+ * @param lspf line spectral pair frequencies
+ * @param lpc linear predictive coding coefficients
+ *
+ * @note: bandwith_expansion_coeff could be precalculated into a table
+ * but it seems to be slower on x86
+ *
+ * TIA/EIA/IS-733 2.4.3.3.5
+ */
+void ff_qcelp_lspf2lpc(const float *lspf, float *lpc)
+{
+ double lsf[10];
+ double bandwith_expansion_coeff = QCELP_BANDWITH_EXPANSION_COEFF;
+ int i;
+
+ for (i=0; i<10; i++)
+ lsf[i] = cos(M_PI * lspf[i]);
+
+ ff_celp_lspf2lpc(lsf, lpc);
+
for (i=0; i<10; i++)
{
lpc[i] *= bandwith_expansion_coeff;