64 float predictor_lspf[10];
65 float pitch_synthesis_filter_mem[303];
66 float pitch_pre_filter_mem[303];
67 float rnd_fir_filter_mem[180];
68 float formant_mem[170];
78 float postfilter_synth_mem[10];
97 for (i = 0; i < 10; i++)
120 float tmp_lspf, smooth, erasure_coeff;
121 const float *predictors;
131 for (i = 0; i < 10; i++) {
147 for (i = 0; i < 10; i++) {
149 lspf[i] = (i + 1) * (1 - erasure_coeff) / 11 +
150 erasure_coeff * predictors[i];
157 for (i = 1; i < 10; i++)
161 for (i = 9; i > 0; i--)
170 for (i = 0; i < 5; i++) {
177 if (lspf[9] <= .70 || lspf[9] >= .97)
179 for (i = 3; i < 10; i++)
180 if (fabs(lspf[i] - lspf[i - 2]) < .08)
183 if (lspf[9] <= .66 || lspf[9] >= .985)
185 for (i = 4; i < 10; i++)
186 if (fabs(lspf[i] - lspf[i - 4]) < .0931)
203 int i, subframes_count, g1[16];
208 case RATE_FULL: subframes_count = 16;
break;
209 case RATE_HALF: subframes_count = 4;
break;
210 default: subframes_count = 5;
212 for (i = 0; i < subframes_count; i++) {
215 g1[i] += av_clip((g1[i - 1] + g1[i - 2] + g1[i - 3]) / 3 - 6, 0, 32);
233 gain[6] = 0.4 * gain[3] + 0.6 * gain[4];
235 gain[4] = 0.8 * gain[2] + 0.2 * gain[3];
236 gain[3] = 0.2 * gain[1] + 0.8 * gain[2];
238 gain[1] = 0.6 * gain[0] + 0.4 * gain[1];
251 case 2 : g1[0] -= 1;
break;
252 case 3 : g1[0] -= 2;
break;
261 for (i = 1; i <= subframes_count; i++)
281 int i,
diff, prev_diff = 0;
283 for (i = 1; i < 5; i++) {
284 diff = cbgain[i] - cbgain[i-1];
285 if (
FFABS(diff) > 10)
287 else if (
FFABS(diff - prev_diff) > 12)
319 uint16_t cbseed, cindex;
320 float *rnd, tmp_gain, fir_filter_value;
324 for (i = 0; i < 16; i++) {
327 for (j = 0; j < 10; j++)
332 for (i = 0; i < 4; i++) {
335 for (j = 0; j < 40; j++)
340 cbseed = (0x0003 & q->
frame.
lspv[4]) << 14 |
346 for (i = 0; i < 8; i++) {
348 for (k = 0; k < 20; k++) {
349 cbseed = 521 * cbseed + 259;
350 *rnd = (int16_t) cbseed;
353 fir_filter_value = 0.0;
354 for (j = 0; j < 10; j++)
356 (rnd[-j] + rnd[-20+j]);
359 *cdn_vector++ = tmp_gain * fir_filter_value;
368 for (i = 0; i < 8; i++) {
370 for (j = 0; j < 20; j++) {
371 cbseed = 521 * cbseed + 259;
372 *cdn_vector++ = tmp_gain * (int16_t) cbseed;
378 for (i = 0; i < 4; i++) {
380 for (j = 0; j < 40; j++)
385 memset(cdn_vector, 0, 160 *
sizeof(
float));
403 for (i = 0; i < 160; i += 40)
429 const float gain[4],
const uint8_t *lag,
433 float *v_lag, *v_out;
436 v_out = memory + 143;
438 for (i = 0; i < 4; i++) {
440 v_lag = memory + 143 + 40 * i - lag[i];
441 for (v_len = v_in + 40; v_in < v_len; v_in++) {
443 for (j = 0, *v_out = 0.; j < 4; j++)
448 *v_out = *v_in + gain[i] * *v_out;
454 memcpy(v_out, v_in, 40 *
sizeof(
float));
460 memmove(memory, memory + 160, 143 *
sizeof(
float));
474 const float *v_synthesis_filtered, *v_pre_filtered;
481 for (i = 0; i < 4; i++) {
487 float max_pitch_gain;
493 max_pitch_gain = 0.0;
496 max_pitch_gain = 1.0;
498 for (i = 0; i < 4; i++)
510 for (i = 0; i < 4; i++)
514 v_synthesis_filtered,
539 static void lspf2lpc(
const float *lspf,
float *lpc)
545 for (i = 0; i < 10; i++)
546 lsp[i] = cos(
M_PI * lspf[i]);
550 for (i = 0; i < 10; i++) {
551 lpc[i] *= bandwidth_expansion_coeff;
568 float *lpc,
const int subframe_num)
570 float interpolated_lspf[10];
574 weight = 0.25 * (subframe_num + 1);
582 weight, 1.0 - weight, 10);
623 if (bitrate > **buf) {
627 "Claimed bitrate and buffer size mismatch.\n");
631 }
else if (bitrate < **buf) {
633 "Buffer is too small for the claimed bitrate.\n");
639 "Bitrate byte is missing, guessing the bitrate from packet size.\n");
659 static const float pow_0_775[10] = {
660 0.775000, 0.600625, 0.465484, 0.360750, 0.279582,
661 0.216676, 0.167924, 0.130141, 0.100859, 0.078166
663 0.625000, 0.390625, 0.244141, 0.152588, 0.095367,
664 0.059605, 0.037253, 0.023283, 0.014552, 0.009095
666 float lpc_s[10], lpc_p[10], pole_out[170], zero_out[160];
669 for (n = 0; n < 10; n++) {
670 lpc_s[n] = lpc[n] * pow_0_625[n];
671 lpc_p[n] = lpc[n] * pow_0_775[n];
689 int *got_frame_ptr,
AVPacket *avpkt)
692 int buf_size = avpkt->
size;
696 float quantized_lspf[10], lpc[10];
729 for (; bitmaps < bitmaps_end; bitmaps++)
744 for (i = 0; i < 4; i++) {
775 for (i = 0; i < 4; i++) {