39 for(i=0; i<lp_order-1; i++)
40 for(j=i; j>=0 && lsfq[j] > lsfq[j+1]; j--)
41 FFSWAP(int16_t, lsfq[j], lsfq[j+1]);
43 for(i=0; i<lp_order; i++)
45 lsfq[i] =
FFMAX(lsfq[i], lsfq_min);
46 lsfq_min = lsfq[i] + lsfq_min_distance;
48 lsfq[lp_order-1] =
FFMIN(lsfq[lp_order-1], lsfq_max);
55 for (i = 0; i <
size; i++)
56 prev = lsf[i] =
FFMAX(lsf[i], prev + min_spacing);
63 32767, 32738, 32617, 32421, 32145, 31793, 31364, 30860,
64 30280, 29629, 28905, 28113, 27252, 26326, 25336, 24285,
65 23176, 22011, 20793, 19525, 18210, 16851, 15451, 14014,
66 12543, 11043, 9515, 7965, 6395, 4810, 3214, 1609,
67 1, -1607, -3211, -4808, -6393, -7962, -9513, -11040,
68 -12541, -14012, -15449, -16848, -18207, -19523, -20791, -22009,
69 -23174, -24283, -25334, -26324, -27250, -28111, -28904, -29627,
70 -30279, -30858, -31363, -31792, -32144, -32419, -32616, -32736, -32768,
88 for(i=0; i<lp_order; i++)
90 lsp[i] =
ff_cos(lsf[i] * 20861 >> 15);
97 for(i = 0; i < lp_order; i++)
98 lsp[i] = cos(2.0 *
M_PI * lsf[i]);
106 static void lsp2poly(
int* f,
const int16_t* lsp,
int lp_half_order)
113 for(i=2; i<=lp_half_order; i++)
119 f[1] -= lsp[2*i-2] << 8;
134 for(i=1; i<lp_half_order+1; i++)
136 int ff1 = f1[i] + f1[i-1];
137 int ff2 = f2[i] - f2[i-1];
140 lp[i] = (ff1 + ff2) >> 11;
141 lp[(lp_half_order << 1) + 1 - i] = (ff1 - ff2) >> 11;
147 int lp_half_order = lp_order >> 1;
150 double *qa = buf + 1;
158 for (i = 1, j = lp_order - 1; i < lp_half_order; i++, j--) {
159 double paf = pa[i] * (1 + lsp[lp_order - 1]);
160 double qaf = (qa[i] - qa[i-2]) * (1 - lsp[lp_order - 1]);
161 lp[i-1] = (paf + qaf) * 0.5;
162 lp[j-1] = (paf - qaf) * 0.5;
165 lp[lp_half_order - 1] = (1.0 + lsp[lp_order - 1]) *
166 pa[lp_half_order] * 0.5;
168 lp[lp_order - 1] = lsp[lp_order - 1];
171 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)
177 for(i=0; i<lp_order; i++)
179 lsp_1st[i] = (lsp_2nd[i] >> 1) + (lsp_prev[i] >> 1);
181 lsp_1st[i] = (lsp_2nd[i] + lsp_prev[i]) >> 1;
198 for(i=2; i<=lp_half_order; i++)
200 double val = -2 * lsp[2*i];
201 f[i] = val * f[i-1] + 2*f[i-2];
203 f[j] += f[j-1] * val + f[j-2];
212 float *lpc2 = lpc + (lp_half_order << 1) - 1;
219 while (lp_half_order--) {
220 double paf = pa[lp_half_order+1] + pa[lp_half_order];
221 double qaf = qa[lp_half_order+1] - qa[lp_half_order];
223 lpc [ lp_half_order] = 0.5*(paf+qaf);
224 lpc2[-lp_half_order] = 0.5*(paf-qaf);
232 for (i = 0; i < len - 1; i++)
233 for (j = i; j >= 0 && vals[j] > vals[j+1]; j--)
234 FFSWAP(
float, vals[j], vals[j+1]);
static const int16_t tab_cos[65]
const char const char void * val
static void lsp2poly(int *f, const int16_t *lsp, int lp_half_order)
decodes polynomial coefficients from LSP
void ff_acelp_lsf2lsp(int16_t *lsp, const int16_t *lsf, int lp_order)
Convert LSF to LSP.
static int16_t ff_cos(uint16_t arg)
void ff_acelp_reorder_lsf(int16_t *lsfq, int lsfq_min_distance, int lsfq_min, int lsfq_max, int lp_order)
(I.F) means fixed-point value with F fractional and I integer bits
void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order)
Compute the Pa / (1 + z(-1)) or Qa / (1 - z(-1)) coefficients needed for LSP to LPC conversion...
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
void ff_amrwb_lsp2lpc(const double *lsp, float *lp, int lp_order)
LSP to LP conversion (5.2.4 of AMR-WB)
simple assert() macros that are a bit more flexible than ISO C assert().
static const uint8_t offset[127][2]
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)
Interpolate LSP for the first subframe and convert LSP -> LP for both subframes (3.2.5 and 3.2.6 of G.729)
void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order)
Reconstruct LPC coefficients from the line spectral pair frequencies.
Libavcodec external API header.
void ff_acelp_lsp2lpc(int16_t *lp, const int16_t *lsp, int lp_half_order)
LSP to LP conversion (3.2.6 of G.729)
#define MAX_LP_HALF_ORDER
void ff_acelp_lsf2lspd(double *lsp, const float *lsf, int lp_order)
Floating point version of ff_acelp_lsf2lsp()
Reference: libavcodec/lsp.c.
void ff_set_min_dist_lsf(float *lsf, double min_spacing, int size)
Adjust the quantized LSFs so they are increasing and not too close.
void ff_sort_nearly_sorted_floats(float *vals, int len)
Sort values in ascending order.
#define FFSWAP(type, a, b)