91 unsigned int low = 0, high = size - 1;
94 int index = (low + high) >> 1;
98 return table[high] + error > value ? low : high;
117 float num = 0, den = 0;
143 const float *ortho1,
const float *ortho2,
144 const float *
data,
float *score,
float *gain)
156 g += work[i] * work[i];
157 c += data[i] * work[i];
184 vect[lag + i] = cb[i];
199 const float *coefs,
float *
data)
202 float score, gain, best_score,
av_uninit(best_gain);
205 gain = best_score = 0;
209 if (score > best_score) {
225 data[i] -= best_gain * work[i];
226 return best_vect - BLOCKSIZE / 2 + 1;
248 const float *ortho2,
float *
data,
int *idx,
252 float g, score, best_score;
255 *idx = *gain = best_score = 0;
260 if (score > best_score) {
282 int cba_idx,
int *cb1_idx,
int *cb2_idx)
294 memcpy(cba_vect, work,
sizeof(cba_vect));
297 data, cb1_idx, &gain);
310 data[i] -= gain * work[i];
311 memcpy(cb1_vect, work,
sizeof(cb1_vect));
317 ortho_cb1 ? cb1_vect : NULL, data, cb2_idx, &gain);
331 const int16_t *sblock_data,
332 const int16_t *lpc_coefs,
unsigned int rms,
338 int cba_idx, cb1_idx, cb2_idx, gain;
342 float error, best_error;
346 coefs[i] = lpc_coefs[i] * (1/4096.0);
356 zero[i] = work[LPC_ORDER + i];
357 data[i] = sblock_data[i] - zero[i];
365 memset(work, 0, LPC_ORDER *
sizeof(*work));
374 memcpy(cba, work + LPC_ORDER,
sizeof(cba));
379 fixed_cb_search(work + LPC_ORDER, coefs, data, cba_idx, &cb1_idx, &cb2_idx);
386 memcpy(cb1, work + LPC_ORDER,
sizeof(cb1));
390 memcpy(cb2, work + LPC_ORDER,
sizeof(cb2));
392 best_error = FLT_MAX;
394 for (n = 0; n < 256; n++) {
404 data[i] = zero[i] + g[0] * cba[i] + g[1] * cb1[i] +
406 error += (data[i] - sblock_data[i]) *
407 (data[i] - sblock_data[i]);
411 data[i] = zero[i] + g[1] * cb1[i] + g[2] * cb2[i];
412 error += (data[i] - sblock_data[i]) *
413 (data[i] - sblock_data[i]);
416 if (error < best_error) {
442 unsigned int refl_rms[
NBLOCKS];
443 const int16_t *samples = frame ? (
const int16_t *)frame->
data[0] : NULL;
462 energy += (lpc_data[i] * lpc_data[i]) >> 4;
467 lpc_data[i] = samples[j] >> 2;
468 energy += (lpc_data[i] * lpc_data[i]) >> 4;
472 memset(&lpc_data[i], 0, (
NBLOCKS * BLOCKSIZE - i) *
sizeof(*lpc_data));
480 block_coefs[
NBLOCKS - 1][i] = -(lpc_coefs[LPC_ORDER - 1][i] <<
481 (12 - shift[LPC_ORDER - 1]));
495 memset(lpc_refl, 0,
sizeof(lpc_refl));
507 refl_rms[1] =
ff_interp(ractx, block_coefs[1], 2,
508 energy <= ractx->old_energy,
510 refl_rms[2] =
ff_interp(ractx, block_coefs[2], 3, 0, energy);
516 block_coefs[i], refl_rms[i], &pb);
533 (NBLOCKS * BLOCKSIZE - i) *
sizeof(*ractx->
curr_block));
557 .supported_samplerates = (
const int[]){ 8000, 0 },