43 #if FF_API_OLD_ENCODE_AUDIO
74 #if FF_API_OLD_ENCODE_AUDIO
101 unsigned int low = 0, high = size - 1;
104 int index = (low + high) >> 1;
108 return table[high] + error > value ? low : high;
127 float num = 0, den = 0;
153 const float *ortho1,
const float *ortho2,
154 const float *
data,
float *score,
float *gain)
166 g += work[i] * work[i];
167 c += data[i] * work[i];
194 vect[lag + i] = cb[i];
209 const float *coefs,
float *
data)
212 float score, gain, best_score,
av_uninit(best_gain);
215 gain = best_score = 0;
219 if (score > best_score) {
235 data[i] -= best_gain * work[i];
236 return best_vect - BLOCKSIZE / 2 + 1;
258 const float *ortho2,
float *
data,
int *idx,
262 float g, score, best_score;
265 *idx = *gain = best_score = 0;
270 if (score > best_score) {
292 int cba_idx,
int *cb1_idx,
int *cb2_idx)
304 memcpy(cba_vect, work,
sizeof(cba_vect));
307 data, cb1_idx, &gain);
320 data[i] -= gain * work[i];
321 memcpy(cb1_vect, work,
sizeof(cb1_vect));
327 ortho_cb1 ? cb1_vect : NULL, data, cb2_idx, &gain);
341 const int16_t *sblock_data,
342 const int16_t *lpc_coefs,
unsigned int rms,
349 int cba_idx, cb1_idx, cb2_idx, gain;
353 float error, best_error;
357 coefs[i] = lpc_coefs[i] * (1/4096.0);
367 zero[i] = work[LPC_ORDER + i];
368 data[i] = sblock_data[i] - zero[i];
376 memset(work, 0, LPC_ORDER *
sizeof(*work));
385 memcpy(cba, work + LPC_ORDER,
sizeof(cba));
388 m[0] = (
ff_irms(cba_vect) * rms) >> 12;
390 fixed_cb_search(work + LPC_ORDER, coefs, data, cba_idx, &cb1_idx, &cb2_idx);
397 memcpy(cb1, work + LPC_ORDER,
sizeof(cb1));
401 memcpy(cb2, work + LPC_ORDER,
sizeof(cb2));
403 best_error = FLT_MAX;
405 for (n = 0; n < 256; n++) {
415 data[i] = zero[i] + g[0] * cba[i] + g[1] * cb1[i] +
417 error += (data[i] - sblock_data[i]) *
418 (data[i] - sblock_data[i]);
422 data[i] = zero[i] + g[1] * cb1[i] + g[2] * cb2[i];
423 error += (data[i] - sblock_data[i]) *
424 (data[i] - sblock_data[i]);
427 if (error < best_error) {
453 unsigned int refl_rms[
NBLOCKS];
454 const int16_t *
samples = frame ? (
const int16_t *)frame->
data[0] :
NULL;
473 energy += (lpc_data[i] * lpc_data[i]) >> 4;
478 lpc_data[i] = samples[j] >> 2;
479 energy += (lpc_data[i] * lpc_data[i]) >> 4;
483 memset(&lpc_data[i], 0, (
NBLOCKS * BLOCKSIZE - i) *
sizeof(*lpc_data));
491 block_coefs[
NBLOCKS - 1][i] = -(lpc_coefs[LPC_ORDER - 1][i] <<
492 (12 - shift[LPC_ORDER - 1]));
506 memset(lpc_refl, 0,
sizeof(lpc_refl));
518 refl_rms[1] =
ff_interp(ractx, block_coefs[1], 2,
519 energy <= ractx->old_energy,
521 refl_rms[2] =
ff_interp(ractx, block_coefs[2], 3, 0, energy);
527 block_coefs[i], refl_rms[i], &pb);
544 (NBLOCKS * BLOCKSIZE - i) *
sizeof(*ractx->
curr_block));
567 .supported_samplerates = (
const int[]){ 8000, 0 },