42 #if FF_API_OLD_ENCODE_AUDIO
73 #if FF_API_OLD_ENCODE_AUDIO
100 unsigned int low = 0, high = size - 1;
103 int index = (low + high) >> 1;
107 return table[high] + error > value ? low : high;
126 float num = 0, den = 0;
152 const float *ortho1,
const float *ortho2,
153 const float *
data,
float *score,
float *gain)
165 g += work[i] * work[i];
166 c += data[i] * work[i];
193 vect[lag + i] = cb[i];
208 const float *coefs,
float *
data)
211 float score, gain, best_score,
av_uninit(best_gain);
214 gain = best_score = 0;
218 if (score > best_score) {
234 data[i] -= best_gain * work[i];
235 return best_vect - BLOCKSIZE / 2 + 1;
257 const float *ortho2,
float *
data,
int *idx,
261 float g, score, best_score;
264 *idx = *gain = best_score = 0;
269 if (score > best_score) {
291 int cba_idx,
int *cb1_idx,
int *cb2_idx)
303 memcpy(cba_vect, work,
sizeof(cba_vect));
306 data, cb1_idx, &gain);
319 data[i] -= gain * work[i];
320 memcpy(cb1_vect, work,
sizeof(cb1_vect));
326 ortho_cb1 ? cb1_vect : NULL, data, cb2_idx, &gain);
340 const int16_t *sblock_data,
341 const int16_t *lpc_coefs,
unsigned int rms,
348 int cba_idx, cb1_idx, cb2_idx, gain;
352 float error, best_error;
356 coefs[i] = lpc_coefs[i] * (1/4096.0);
366 zero[i] = work[LPC_ORDER + i];
367 data[i] = sblock_data[i] - zero[i];
375 memset(work, 0, LPC_ORDER *
sizeof(*work));
384 memcpy(cba, work + LPC_ORDER,
sizeof(cba));
387 m[0] = (
ff_irms(cba_vect) * rms) >> 12;
389 fixed_cb_search(work + LPC_ORDER, coefs, data, cba_idx, &cb1_idx, &cb2_idx);
396 memcpy(cb1, work + LPC_ORDER,
sizeof(cb1));
400 memcpy(cb2, work + LPC_ORDER,
sizeof(cb2));
402 best_error = FLT_MAX;
404 for (n = 0; n < 256; n++) {
414 data[i] = zero[i] + g[0] * cba[i] + g[1] * cb1[i] +
416 error += (data[i] - sblock_data[i]) *
417 (data[i] - sblock_data[i]);
421 data[i] = zero[i] + g[1] * cb1[i] + g[2] * cb2[i];
422 error += (data[i] - sblock_data[i]) *
423 (data[i] - sblock_data[i]);
426 if (error < best_error) {
452 unsigned int refl_rms[
NBLOCKS];
453 const int16_t *
samples = frame ? (
const int16_t *)frame->
data[0] :
NULL;
472 energy += (lpc_data[i] * lpc_data[i]) >> 4;
477 lpc_data[i] = samples[j] >> 2;
478 energy += (lpc_data[i] * lpc_data[i]) >> 4;
482 memset(&lpc_data[i], 0, (
NBLOCKS * BLOCKSIZE - i) *
sizeof(*lpc_data));
490 block_coefs[
NBLOCKS - 1][i] = -(lpc_coefs[LPC_ORDER - 1][i] <<
491 (12 - shift[LPC_ORDER - 1]));
505 memset(lpc_refl, 0,
sizeof(lpc_refl));
517 refl_rms[1] =
ff_interp(ractx, block_coefs[1], 2,
518 energy <= ractx->old_energy,
520 refl_rms[2] =
ff_interp(ractx, block_coefs[2], 3, 0, energy);
526 block_coefs[i], refl_rms[i], &pb);
543 (NBLOCKS * BLOCKSIZE - i) *
sizeof(*ractx->
curr_block));
566 .supported_samplerates = (
const int[]){ 8000, 0 },