comparison qcelp_lsp.c @ 9123:36a5caff8540 libavcodec

Part 2 of 2 of Kenan Gillet's 'make ff_qcelp_lspf2lpc more general' changeset. This one relocates the QCELP especific code to the qcelpdec.* files.
author reynaldo
date Wed, 04 Mar 2009 01:33:56 +0000
parents 0613e9b5514c
children 18dab2b47db7
comparison
equal deleted inserted replaced
9122:0613e9b5514c 9123:36a5caff8540
26 * @remark FFmpeg merging spearheaded by Kenan Gillet 26 * @remark FFmpeg merging spearheaded by Kenan Gillet
27 * @remark Development mentored by Benjamin Larson 27 * @remark Development mentored by Benjamin Larson
28 */ 28 */
29 29
30 #include "libavutil/mathematics.h" 30 #include "libavutil/mathematics.h"
31
32 /**
33 * initial coefficient to perform bandwidth expansion on LPC
34 *
35 * @note: 0.9883 looks like an approximation of 253/256.
36 *
37 * TIA/EIA/IS-733 2.4.3.3.6 6
38 */
39 #define QCELP_BANDWITH_EXPANSION_COEFF 0.9883
40 31
41 /** 32 /**
42 * Computes the Pa / (1 + z(-1)) or Qa / (1 - z(-1)) coefficients 33 * Computes the Pa / (1 + z(-1)) or Qa / (1 - z(-1)) coefficients
43 * needed for LSP to LPC conversion. 34 * needed for LSP to LPC conversion.
44 * We only need to calculate the 6 first elements of the polynomial. 35 * We only need to calculate the 6 first elements of the polynomial.
82 for (i=4; i>=0; i--) 73 for (i=4; i>=0; i--)
83 { 74 {
84 double paf = pa[i+1] + pa[i]; 75 double paf = pa[i+1] + pa[i];
85 double qaf = qa[i+1] - qa[i]; 76 double qaf = qa[i+1] - qa[i];
86 77
87 lpc[i ] = 0.5 * (paf+qaf); 78 lpc[i ] = 0.5*(paf+qaf);
88 lpc[9-i] = 0.5 * (paf-qaf); 79 lpc[9-i] = 0.5*(paf-qaf);
89 } 80 }
90 } 81 }
91
92 /**
93 * Reconstructs LPC coefficients from the line spectral pair frequencies
94 * and performs bandwidth expansion.
95 *
96 * @param lspf line spectral pair frequencies
97 * @param lpc linear predictive coding coefficients
98 *
99 * @note: bandwith_expansion_coeff could be precalculated into a table
100 * but it seems to be slower on x86
101 *
102 * TIA/EIA/IS-733 2.4.3.3.5
103 */
104 void ff_qcelp_lspf2lpc(const float *lspf, float *lpc)
105 {
106 double lsf[10];
107 double bandwith_expansion_coeff = QCELP_BANDWITH_EXPANSION_COEFF;
108 int i;
109
110 for (i=0; i<10; i++)
111 lsf[i] = cos(M_PI * lspf[i]);
112
113 ff_celp_lspf2lpc(lsf, lpc);
114
115 for (i=0; i<10; i++)
116 {
117 lpc[i] *= bandwith_expansion_coeff;
118 bandwith_expansion_coeff *= QCELP_BANDWITH_EXPANSION_COEFF;
119 }
120 }