37 for (i = 0; i <
length; i++)
38 max |=
FFABS(vector[i]);
43 for (i = 0; i <
length; i++)
44 dst[i] = vector[i] << bits >> 3;
51 return width -
av_log2(num) - 1;
57 return av_sat_add32(sum, sum);
66 residual[0] = prev_excitation[
offset];
67 residual[1] = prev_excitation[offset + 1];
71 residual[i] = prev_excitation[offset + (i - 2) % lag];
81 for (j = 0; j < SUBFRAME_LEN - i; j++)
82 buf[i + j] += vector[j];
91 const int16_t *cb_ptr;
92 int lag = pitch_lag + subfrm->
ad_cb_lag - 1;
109 vector[i] = av_sat_dadd32(1 << 15, av_sat_add32(sum, sum)) >> 16;
126 int index = (lpc[j] >> 7) & 0x1FF;
127 int offset = lpc[j] & 0x7f;
130 ((offset << 8) + 0x80) << 1;
132 lpc[j] = -(av_sat_dadd32(1 << 15, temp1 + temp2) >> 16);
141 f1[1] = (lpc[0] << 14) + (lpc[2] << 14);
142 f1[2] = lpc[0] * lpc[2] + (2 << 28);
145 f2[1] = (lpc[1] << 14) + (lpc[3] << 14);
146 f2[2] = lpc[1] * lpc[3] + (2 << 28);
152 for (i = 2; i < LPC_ORDER / 2; i++) {
153 f1[i + 1] = f1[i - 1] +
MULL2(f1[i], lpc[2 * i]);
154 f2[i + 1] = f2[i - 1] +
MULL2(f2[i], lpc[2 * i + 1]);
156 for (j = i; j >= 2; j--) {
157 f1[j] =
MULL2(f1[j - 1], lpc[2 * i]) +
158 (f1[j] >> 1) + (f1[j - 2] >> 1);
159 f2[j] =
MULL2(f2[j - 1], lpc[2 * i + 1]) +
160 (f2[j] >> 1) + (f2[j - 2] >> 1);
165 f1[1] = ((lpc[2 * i] << 16 >> i) + f1[1]) >> 1;
166 f2[1] = ((lpc[2 * i + 1] << 16 >> i) + f2[1]) >> 1;
170 for (i = 0; i < LPC_ORDER / 2; i++) {
171 int64_t ff1 = f1[i + 1] + f1[i];
172 int64_t ff2 = f2[i + 1] - f2[i];
174 lpc[i] = av_clipl_int32(((ff1 + ff2) << 3) + (1 << 15)) >> 16;
175 lpc[LPC_ORDER - i - 1] = av_clipl_int32(((ff1 - ff2) << 3) +
184 int16_t *lpc_ptr = lpc;
202 uint8_t *lsp_index,
int bad_frame)
205 int i, j,
temp, stable;
214 lsp_index[0] = lsp_index[1] = lsp_index[2] = 0;
231 temp = ((prev_lsp[i] -
dc_lsp[i]) * pred + (1 << 14)) >> 15;
236 cur_lsp[0] =
FFMAX(cur_lsp[0], 0x180);
237 cur_lsp[LPC_ORDER - 1] =
FFMIN(cur_lsp[LPC_ORDER - 1], 0x7e00);
241 temp = min_dist + cur_lsp[j - 1] - cur_lsp[j];
244 cur_lsp[j - 1] -=
temp;
250 temp = cur_lsp[j - 1] + min_dist - cur_lsp[j] - 4;
260 memcpy(cur_lsp, prev_lsp, LPC_ORDER *
sizeof(*cur_lsp));
static void lsp2lpc(int16_t *lpc)
Convert LSP frequencies to LPC coefficients.
G723.1 unpacked data subframe.
static float cos_tab[256]
static const int16_t lsp_band0[LSP_CB_SIZE][3]
LSP VQ tables.
int av_log2_16bit(unsigned v)
void ff_g723_1_inverse_quant(int16_t *cur_lsp, int16_t *prev_lsp, uint8_t *lsp_index, int bad_frame)
Perform inverse quantization of LSP frequencies.
static const int16_t adaptive_cb_gain85[85 *20]
void ff_g723_1_lsp_interpolate(int16_t *lpc, int16_t *cur_lsp, int16_t *prev_lsp)
Quantize LSP frequencies by interpolation and convert them to the corresponding LPC coefficients...
static const int16_t lsp_band2[LSP_CB_SIZE][4]
static const int16_t lsp_band1[LSP_CB_SIZE][3]
static const int16_t adaptive_cb_gain170[170 *20]
int ff_g723_1_normalize_bits(int num, int width)
Calculate the number of left-shifts required for normalizing the input.
void ff_g723_1_gen_dirac_train(int16_t *buf, int pitch_lag)
Generate a train of dirac functions with period as pitch lag.
int64_t ff_dot_product(const int16_t *a, const int16_t *b, int length)
Calculate the dot product of 2 int16_t vectors.
static const uint8_t offset[127][2]
void ff_g723_1_gen_acb_excitation(int16_t *vector, int16_t *prev_excitation, int pitch_lag, G723_1_Subframe *subfrm, enum Rate cur_rate)
Generate adaptive codebook excitation.
void ff_acelp_weighted_vector_sum(int16_t *out, const int16_t *in_a, const int16_t *in_b, int16_t weight_coeff_a, int16_t weight_coeff_b, int16_t rounder, int shift, int length)
weighted sum of two vectors with rounding.
void ff_g723_1_get_residual(int16_t *residual, int16_t *prev_excitation, int lag)
Get delayed contribution from the previous excitation vector.
int ff_g723_1_dot_product(const int16_t *a, const int16_t *b, int length)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static const float pred[4]
int ff_g723_1_scale_vector(int16_t *dst, const int16_t *vector, int length)
Scale vector contents based on the largest of their absolutes.
Libavcodec external API header.
static const int16_t dc_lsp[LPC_ORDER]
LSP DC component.
G.723.1 types, functions and data tables.
common internal and external API header
#define MULL2(a, b)
Bitexact implementation of 2ab scaled by 1/2^16.
int ad_cb_lag
adaptive codebook lag