63 float predictor_lspf[10];
64 float pitch_synthesis_filter_mem[303];
65 float pitch_pre_filter_mem[303];
66 float rnd_fir_filter_mem[180];
67 float formant_mem[170];
77 float postfilter_synth_mem[10];
96 for (i = 0; i < 10; i++)
116 float tmp_lspf, smooth, erasure_coeff;
117 const float *predictors;
127 for (i = 0; i < 10; i++) {
143 for (i = 0; i < 10; i++) {
145 lspf[i] = (i + 1) * (1 - erasure_coeff) / 11 +
146 erasure_coeff * predictors[i];
153 for (i = 1; i < 10; i++)
157 for (i = 9; i > 0; i--)
166 for (i = 0; i < 5; i++) {
173 if (lspf[9] <= .70 || lspf[9] >= .97)
175 for (i = 3; i < 10; i++)
176 if (fabs(lspf[i] - lspf[i - 2]) < .08)
179 if (lspf[9] <= .66 || lspf[9] >= .985)
181 for (i = 4; i < 10; i++)
182 if (fabs(lspf[i] - lspf[i - 4]) < .0931)
199 int i, subframes_count, g1[16];
204 case RATE_FULL: subframes_count = 16;
break;
205 case RATE_HALF: subframes_count = 4;
break;
206 default: subframes_count = 5;
208 for (i = 0; i < subframes_count; i++) {
211 g1[i] += av_clip((g1[i - 1] + g1[i - 2] + g1[i - 3]) / 3 - 6, 0, 32);
229 gain[6] = 0.4 * gain[3] + 0.6 * gain[4];
231 gain[4] = 0.8 * gain[2] + 0.2 * gain[3];
232 gain[3] = 0.2 * gain[1] + 0.8 * gain[2];
234 gain[1] = 0.6 * gain[0] + 0.4 * gain[1];
247 case 2 : g1[0] -= 1;
break;
248 case 3 : g1[0] -= 2;
break;
257 for (i = 1; i <= subframes_count; i++)
277 int i,
diff, prev_diff = 0;
279 for (i = 1; i < 5; i++) {
280 diff = cbgain[i] - cbgain[i-1];
281 if (
FFABS(diff) > 10)
283 else if (
FFABS(diff - prev_diff) > 12)
315 uint16_t cbseed, cindex;
316 float *rnd, tmp_gain, fir_filter_value;
320 for (i = 0; i < 16; i++) {
323 for (j = 0; j < 10; j++)
328 for (i = 0; i < 4; i++) {
331 for (j = 0; j < 40; j++)
336 cbseed = (0x0003 & q->
frame.
lspv[4]) << 14 |
342 for (i = 0; i < 8; i++) {
344 for (k = 0; k < 20; k++) {
345 cbseed = 521 * cbseed + 259;
346 *rnd = (int16_t) cbseed;
349 fir_filter_value = 0.0;
350 for (j = 0; j < 10; j++)
352 (rnd[-j] + rnd[-20+j]);
355 *cdn_vector++ = tmp_gain * fir_filter_value;
364 for (i = 0; i < 8; i++) {
366 for (j = 0; j < 20; j++) {
367 cbseed = 521 * cbseed + 259;
368 *cdn_vector++ = tmp_gain * (int16_t) cbseed;
374 for (i = 0; i < 4; i++) {
376 for (j = 0; j < 40; j++)
381 memset(cdn_vector, 0, 160 *
sizeof(
float));
399 for (i = 0; i < 160; i += 40) {
423 const float gain[4],
const uint8_t *lag,
427 float *v_lag, *v_out;
430 v_out = memory + 143;
432 for (i = 0; i < 4; i++) {
434 v_lag = memory + 143 + 40 * i - lag[i];
435 for (v_len = v_in + 40; v_in < v_len; v_in++) {
437 for (j = 0, *v_out = 0.; j < 4; j++)
442 *v_out = *v_in + gain[i] * *v_out;
448 memcpy(v_out, v_in, 40 *
sizeof(
float));
454 memmove(memory, memory + 160, 143 *
sizeof(
float));
468 const float *v_synthesis_filtered, *v_pre_filtered;
475 for (i = 0; i < 4; i++) {
481 float max_pitch_gain;
487 max_pitch_gain = 0.0;
490 max_pitch_gain = 1.0;
492 for (i = 0; i < 4; i++)
504 for (i = 0; i < 4; i++)
508 v_synthesis_filtered,
533 static void lspf2lpc(
const float *lspf,
float *lpc)
539 for (i = 0; i < 10; i++)
540 lsp[i] = cos(
M_PI * lspf[i]);
544 for (i = 0; i < 10; i++) {
545 lpc[i] *= bandwidth_expansion_coeff;
562 float *lpc,
const int subframe_num)
564 float interpolated_lspf[10];
568 weight = 0.25 * (subframe_num + 1);
576 weight, 1.0 - weight, 10);
617 if (bitrate > **buf) {
621 "Claimed bitrate and buffer size mismatch.\n");
625 }
else if (bitrate < **buf) {
627 "Buffer is too small for the claimed bitrate.\n");
633 "Bitrate byte is missing, guessing the bitrate from packet size.\n");
653 static const float pow_0_775[10] = {
654 0.775000, 0.600625, 0.465484, 0.360750, 0.279582,
655 0.216676, 0.167924, 0.130141, 0.100859, 0.078166
657 0.625000, 0.390625, 0.244141, 0.152588, 0.095367,
658 0.059605, 0.037253, 0.023283, 0.014552, 0.009095
660 float lpc_s[10], lpc_p[10], pole_out[170], zero_out[160];
663 for (n = 0; n < 10; n++) {
664 lpc_s[
n] = lpc[
n] * pow_0_625[
n];
665 lpc_p[
n] = lpc[
n] * pow_0_775[
n];
684 int *got_frame_ptr,
AVPacket *avpkt)
687 int buf_size = avpkt->
size;
692 float quantized_lspf[10], lpc[10];
700 outbuffer = (
float *)frame->
data[0];
723 for (; bitmaps < bitmaps_end; bitmaps++)
738 for (i = 0; i < 4; i++) {
769 for (i = 0; i < 4; i++) {