44 0, 31650, 28469, 23705, 18050, 12266, 7041, 2873,
45 0, -1597, -2147, -1992, -1492, -933, -484, -188,
53 0, 31915, 29436, 25569, 20676, 15206, 9639, 4439,
54 0, -3390, -5579, -6549, -6414, -5392, -3773, -1874,
55 0, 1595, 2727, 3303, 3319, 2850, 2030, 1023,
56 0, -887, -1527, -1860, -1876, -1614, -1150, -579,
57 0, 501, 859, 1041, 1044, 892, 631, 315,
58 0, -266, -453, -543, -538, -455, -317, -156,
59 0, 130, 218, 258, 253, 212, 147, 72,
60 0, -59, -101, -122, -123, -106, -77, -40,
68 18022, 9912, 5451, 2998, 1649, 907, 499, 274, 151, 83
76 22938, 16057, 11240, 7868, 5508, 3856, 2699, 1889, 1322, 925
94 for (n = subframe_size - 1; n >= 0; n--) {
96 for (
i = 0;
i < 10;
i++)
97 sum += filter_coeffs[
i] * in[n -
i - 1];
99 out[n] = in[n] + (sum >> 12);
114 const int16_t* residual, int16_t *residual_filt,
124 int corr_int_num, corr_int_den;
129 int16_t gain_num,gain_den;
130 int16_t sh_gain_num, sh_gain_den;
133 int16_t gain_long_num,gain_long_den;
134 int16_t sh_gain_long_num, sh_gain_long_den;
136 int16_t best_delay_int, best_delay_frac;
138 int16_t delayed_signal_offset;
139 int lt_filt_factor_a, lt_filt_factor_b;
141 int16_t * selected_signal;
142 const int16_t * selected_signal_const;
159 sig_scaled[
i] = residual[
i] >>
shift;
162 sig_scaled[
i] = (
unsigned)residual[
i] << -
shift;
172 sh_ener =
FFMAX(sh_ener, 0);
195 best_delay_int = pitch_delay_int - 1;
196 for (
i = pitch_delay_int - 1;
i <= pitch_delay_int + 1;
i++) {
200 if (sum > corr_int_num) {
235 &delayed_signal[k][1],
237 corr_den[k][0] = sum + delayed_signal[k][0 ] * delayed_signal[k][0 ];
238 corr_den[k][1] = sum + delayed_signal[k][subframe_size] * delayed_signal[k][subframe_size];
244 if (sh_gain_den >= 0) {
246 sh_gain_num =
FFMAX(sh_gain_den, sh_ener);
251 delayed_signal_offset = 1;
253 gain_den = corr_int_den >> sh_gain_den;
254 gain_num = corr_int_num >> sh_gain_num;
255 gain_num_square = gain_num * gain_num;
257 for (
i = 0;
i < 2;
i++) {
258 int16_t gain_num_short, gain_den_short;
259 int gain_num_short_square;
265 gain_num_short =
FFMAX(sum >> sh_gain_num, 0);
272 gain_num_short_square = gain_num_short * gain_num_short;
273 gain_den_short = corr_den[k][
i] >> sh_gain_den;
280 gain_num = gain_num_short;
281 gain_den = gain_den_short;
282 gain_num_square = gain_num_short_square;
283 delayed_signal_offset =
i;
284 best_delay_frac = k + 1;
294 L64_temp0 = (
int64_t)gain_num_square << ((sh_gain_num << 1) + 1);
295 L64_temp1 = ((
int64_t)gain_den * ener) << (sh_gain_den + sh_ener);
296 if (L64_temp0 < L64_temp1)
304 memcpy(residual_filt, residual +
RES_PREV_DATA_SIZE, subframe_size *
sizeof(int16_t));
309 if (best_delay_frac) {
325 sh_gain_long_num = 0;
331 sh_gain_long_num =
tmp;
341 sh_gain_long_den =
tmp;
346 L_temp0 = gain_num * gain_num;
349 L_temp1 = gain_long_num * gain_long_num;
352 tmp = ((sh_gain_long_num - sh_gain_num) * 2) - (sh_gain_long_den - sh_gain_den);
359 if (L_temp1 > L_temp0) {
361 selected_signal = residual_filt;
362 gain_num = gain_long_num;
363 gain_den = gain_long_den;
364 sh_gain_num = sh_gain_long_num;
365 sh_gain_den = sh_gain_long_den;
368 selected_signal = &delayed_signal[best_delay_frac-1][delayed_signal_offset];
372 for (
i = 0;
i < subframe_size;
i++)
373 selected_signal[
i] *= 1 <<
shift;
375 for (
i = 0;
i < subframe_size;
i++)
376 selected_signal[
i] >>= -
shift;
379 selected_signal_const = selected_signal;
382 selected_signal_const = residual +
RES_PREV_DATA_SIZE - (best_delay_int + 1 - delayed_signal_offset);
384 tmp = sh_gain_num - sh_gain_den;
390 if (gain_num > gain_den)
395 lt_filt_factor_a = (gain_den << 15) / (gain_den + gain_num);
398 L64_temp0 = (((
int64_t)gain_num) << sh_gain_num) >> 1;
399 L64_temp1 = ((
int64_t)gain_den) << sh_gain_den;
404 lt_filt_factor_b = 32767 - lt_filt_factor_a + 1;
407 selected_signal_const,
408 lt_filt_factor_a, lt_filt_factor_b,
409 1<<14, 15, subframe_size);
431 const int16_t *lp_gd, int16_t* speech,
456 if (
FFABS(rh1) > rh0 || !rh0)
460 for (
i = 0;
i < 20;
i++)
461 gain_term +=
FFABS(lp_gn[
i + 10]);
464 if (gain_term > 0x400) {
465 temp = 0x2000000 / gain_term;
466 for (
i = 0;
i < subframe_size;
i++)
467 speech[
i] = (speech[
i] *
temp + 0x4000) >> 15;
470 return -(rh1 * (1 << 15)) / rh0;
483 int subframe_size, int16_t ht_prev_data)
490 if (refl_coeff > 0) {
503 tmp = res_pst[subframe_size - 1];
505 for (
i = subframe_size - 1;
i >= 1;
i--) {
506 tmp2 = (gt * res_pst[
i-1]) * 2 + 0x4000;
507 tmp2 = res_pst[
i] + (tmp2 >> 15);
509 tmp2 = (tmp2 * ga +
fact) >> sh_fact;
512 tmp2 = (gt * ht_prev_data) * 2 + 0x4000;
513 tmp2 = res_pst[0] + (tmp2 >> 15);
514 tmp2 = (tmp2 * ga +
fact) >> sh_fact;
521 const int16_t *lp_filter_coeffs,
int pitch_delay_int,
522 int16_t* residual, int16_t* res_filter_data,
523 int16_t* pos_filter_data, int16_t *speech,
int subframe_size)
532 memset(lp_gn, 0, 33 *
sizeof(int16_t));
535 for (
i = 0;
i < 10;
i++)
539 for (
i = 0;
i < 10;
i++)
543 memcpy(speech - 10, res_filter_data, 10 *
sizeof(int16_t));
546 memcpy(res_filter_data, speech + subframe_size - 10, 10 *
sizeof(int16_t));
551 residual, residual_filt_buf + 10,
553 *voicing =
FFMAX(*voicing,
i);
559 tilt_comp_coeff =
get_tilt_comp(adsp, lp_gn, lp_gd, residual_filt_buf + 10, subframe_size);
563 residual_filt_buf + 10,
564 subframe_size, 10, 0, 0, 0x800);
565 memcpy(pos_filter_data, pos_filter_data + subframe_size, 10 *
sizeof(int16_t));
567 *ht_prev_data =
apply_tilt_comp(speech, pos_filter_data + 10, tilt_comp_coeff,
568 subframe_size, *ht_prev_data);
582 int subframe_size, int16_t gain_prev)
586 int exp_before, exp_after;
588 if(!gain_after && gain_before)
593 exp_before = 14 -
av_log2(gain_before);
594 gain_before =
bidir_sal(gain_before, exp_before);
596 exp_after = 14 -
av_log2(gain_after);
597 gain_after =
bidir_sal(gain_after, exp_after);
599 if (gain_before < gain_after) {
600 gain = (gain_before << 15) / gain_after;
601 gain =
bidir_sal(gain, exp_after - exp_before - 1);
603 gain = ((gain_before - gain_after) << 14) / gain_after + 0x4000;
604 gain =
bidir_sal(gain, exp_after - exp_before);
606 gain =
FFMIN(gain, 32767);
611 for (n = 0; n < subframe_size; n++) {
615 speech[n] =
av_clip_int16((speech[n] * gain_prev + 0x2000) >> 14);