90 unsigned int low = 0, high = size - 1;
93 int index = (low + high) >> 1;
97 return table[high] + error > value ? low : high;
116 float num = 0, den = 0;
142 const float *ortho1,
const float *ortho2,
143 const float *
data,
float *score,
float *gain)
155 g += work[i] * work[i];
156 c += data[i] * work[i];
183 vect[lag + i] = cb[i];
198 const float *coefs,
float *
data)
201 float score, gain, best_score,
av_uninit(best_gain);
204 gain = best_score = 0;
208 if (score > best_score) {
224 data[i] -= best_gain * work[i];
225 return best_vect - BLOCKSIZE / 2 + 1;
247 const float *ortho2,
float *
data,
int *idx,
251 float g, score, best_score;
254 *idx = *gain = best_score = 0;
259 if (score > best_score) {
281 int cba_idx,
int *cb1_idx,
int *cb2_idx)
293 memcpy(cba_vect, work,
sizeof(cba_vect));
296 data, cb1_idx, &gain);
309 data[i] -= gain * work[i];
310 memcpy(cb1_vect, work,
sizeof(cb1_vect));
316 ortho_cb1 ? cb1_vect : NULL, data, cb2_idx, &gain);
330 const int16_t *sblock_data,
331 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));
377 m[0] = (
ff_irms(cba_vect) * rms) >> 12;
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 },