43 for(
i=0;
i<lp_order-1;
i++)
44 for(j=
i; j>=0 && lsfq[j] > lsfq[j+1]; j--)
45 FFSWAP(int16_t, lsfq[j], lsfq[j+1]);
47 for(
i=0;
i<lp_order;
i++)
49 lsfq[
i] =
FFMAX(lsfq[
i], lsfq_min);
50 lsfq_min = lsfq[
i] + lsfq_min_distance;
52 lsfq[lp_order-1] =
FFMIN(lsfq[lp_order-1], lsfq_max);
60 prev = lsf[
i] =
FFMAX(lsf[
i], prev + min_spacing);
67 32767, 32738, 32617, 32421, 32145, 31793, 31364, 30860,
68 30280, 29629, 28905, 28113, 27252, 26326, 25336, 24285,
69 23176, 22011, 20793, 19525, 18210, 16851, 15451, 14014,
70 12543, 11043, 9515, 7965, 6395, 4810, 3214, 1609,
71 1, -1607, -3211, -4808, -6393, -7962, -9513, -11040,
72 -12541, -14012, -15449, -16848, -18207, -19523, -20791, -22009,
73 -23174, -24283, -25334, -26324, -27250, -28111, -28904, -29627,
74 -30279, -30858, -31363, -31792, -32144, -32419, -32616, -32736, -32768,
80 uint8_t ind =
arg >> 8;
92 for(
i=0;
i<lp_order;
i++)
94 lsp[
i] =
ff_cos(lsf[
i] * 20861 >> 15);
101 for(
i = 0;
i < lp_order;
i++)
102 lsp[
i] = cos(2.0 *
M_PI * lsf[
i]);
110 static void lsp2poly(
int*
f,
const int16_t* lsp,
int lp_half_order)
115 f[1] = -lsp[0] * 256;
117 for(
i=2;
i<=lp_half_order;
i++)
123 f[1] -= lsp[2*
i-2] * 256;
138 static void lsp2polyf(
const double *lsp,
double *
f,
int lp_half_order)
143 for (
int i = 2;
i <= lp_half_order;
i++) {
144 double val = -2 * lsp[2*
i];
146 for (
int j =
i-1; j > 1; j--)
147 f[j] +=
f[j-1] *
val +
f[j-2];
164 for(
i=1;
i<lp_half_order+1;
i++)
166 int ff1 = f1[
i] + f1[
i-1];
167 int ff2 = f2[
i] - f2[
i-1];
170 lp[
i] = (ff1 + ff2) >> 11;
171 lp[(lp_half_order << 1) + 1 -
i] = (ff1 - ff2) >> 11;
177 int lp_half_order = lp_order >> 1;
180 double *qa = buf + 1;
186 lsp2polyf(lsp + 1, qa, lp_half_order - 1);
188 for (
i = 1, j = lp_order - 1;
i < lp_half_order;
i++, j--) {
189 double paf = pa[
i] * (1 + lsp[lp_order - 1]);
190 double qaf = (qa[
i] - qa[
i-2]) * (1 - lsp[lp_order - 1]);
191 lp[
i-1] = (paf + qaf) * 0.5;
192 lp[j-1] = (paf - qaf) * 0.5;
195 lp[lp_half_order - 1] = (1.0 + lsp[lp_order - 1]) *
196 pa[lp_half_order] * 0.5;
198 lp[lp_order - 1] = lsp[lp_order - 1];
201 void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd,
const int16_t* lsp_2nd,
const int16_t* lsp_prev,
int lp_order)
207 for(
i=0;
i<lp_order;
i++)
209 lsp_1st[
i] = (lsp_2nd[
i] >> 1) + (lsp_prev[
i] >> 1);
211 lsp_1st[
i] = (lsp_2nd[
i] + lsp_prev[
i]) >> 1;
223 float *lpc2 = lpc + (lp_half_order << 1) - 1;
230 while (lp_half_order--) {
231 double paf = pa[lp_half_order+1] + pa[lp_half_order];
232 double qaf = qa[lp_half_order+1] - qa[lp_half_order];
234 lpc [ lp_half_order] = 0.5*(paf+qaf);
235 lpc2[-lp_half_order] = 0.5*(paf-qaf);
243 for (
i = 0;
i <
len - 1;
i++)
244 for (j =
i; j >= 0 && vals[j] > vals[j+1]; j--)
245 FFSWAP(
float, vals[j], vals[j+1]);