30 #define BITSTREAM_READER_LE
41 #define MAX_SUBFRAME_COUNT 5
58 uint8_t vq_indexes_bits[5];
61 uint8_t pitch_delay_bits[5];
64 uint8_t fc_index_bits[10];
71 .bits_per_frame = 160,
73 .frames_per_packet = 1,
74 .pitch_sharp_factor = 0.00,
76 .number_of_fc_indexes = 10,
77 .ma_predictor_bits = 1,
78 .vq_indexes_bits = {7, 8, 7, 7, 7},
79 .pitch_delay_bits = {9, 6},
81 .fc_index_bits = {4, 5, 4, 5, 4, 5, 4, 5, 4, 5},
87 .bits_per_frame = 152,
89 .frames_per_packet = 1,
90 .pitch_sharp_factor = 0.8,
92 .number_of_fc_indexes = 3,
93 .ma_predictor_bits = 0,
94 .vq_indexes_bits = {6, 7, 7, 7, 5},
95 .pitch_delay_bits = {8, 5, 5},
97 .fc_index_bits = {9, 9, 9},
103 .bits_per_frame = 232,
105 .frames_per_packet = 2,
106 .pitch_sharp_factor = 0.8,
108 .number_of_fc_indexes = 3,
109 .ma_predictor_bits = 0,
110 .vq_indexes_bits = {6, 7, 7, 7, 5},
111 .pitch_delay_bits = {8, 5, 5},
113 .fc_index_bits = {5, 5, 5},
119 .bits_per_frame = 296,
121 .frames_per_packet = 2,
122 .pitch_sharp_factor = 0.85,
124 .number_of_fc_indexes = 1,
125 .ma_predictor_bits = 0,
126 .vq_indexes_bits = {6, 7, 7, 7, 5},
127 .pitch_delay_bits = {8, 5, 8, 5, 5},
129 .fc_index_bits = {10},
135 1.0/(1 << 1), 1.0/(1 << 2), 1.0/(1 << 3), 1.0/(1 << 4),
136 1.0/(1 << 5), 1.0/(1 << 6), 1.0/(1 << 7), 1.0/(1 << 8),
137 1.0/(1 << 9), 1.0/(1 << 10), 1.0/(1 << 11), 1.0/(1 << 12),
138 1.0/(1 << 13), 1.0/(1 << 14), 1.0/(1 << 15), 1.0/(1 << 16)
141 static void dequant(
float *out,
const int *idx,
const float *cbs[])
147 for (i = 0; i < num_vec; i++)
148 memcpy(out + stride*i, cbs[i] + stride*idx[i], stride*
sizeof(
float));
161 lsfnew[i] = lsf_history[i] * 0.33 + lsf_tmp[i] +
mean_lsf[i];
168 lsfnew[9] =
FFMIN(lsfnew[LP_FILTER_ORDER - 1], 1.3 *
M_PI);
170 memcpy(lsf_history, lsf_tmp, LP_FILTER_ORDER *
sizeof(*lsf_history));
172 for (i = 0; i < LP_FILTER_ORDER - 1; i++)
173 lsfnew[i] = cos(lsfnew[i]);
174 lsfnew[LP_FILTER_ORDER - 1] *= 6.153848 /
M_PI;
184 fixed_vector[i] += beta * fixed_vector[i - pitch_lag_int];
200 for (i = 0; i < 5; i++)
220 float t,
t0 = 1.0 / num_subfr;
223 for (i = 0; i < num_subfr; i++) {
225 lsfint[j] = lsfold[j] * (1 - t) + t * lsfnew[j];
236 static void eval_ir(
const float *Az,
int pitch_lag,
float *freq,
237 float pitch_sharp_factor)
247 memset(tmp1 + 11, 0, 37 *
sizeof(
float));
259 const float *shape,
int length)
263 memset(out, 0, length*
sizeof(
float));
264 for (i = 0; i < pulses->
n; i++)
265 for (j = pulses->
x[i]; j < length; j++)
266 out[j] += pulses->
y[i] * shape[j - pulses->
x[i]];
286 LP_FILTER_ORDER*
sizeof(
float));
292 LP_FILTER_ORDER*
sizeof(
float));
297 LP_FILTER_ORDER*
sizeof(*pole_out));
300 LP_FILTER_ORDER*
sizeof(*pole_out));
314 for (i = 0; i < 3; i++) {
315 fixed_sparse->
x[i] = 3 * (pulses[i] & 0xf) + i;
316 fixed_sparse->
y[i] = pulses[i] & 0x10 ? -1 : 1;
321 for (i = 0; i < 3; i++) {
322 fixed_sparse->
x[2*i ] = 3 * ((pulses[i] >> 4) & 0xf) + i;
323 fixed_sparse->
x[2*i + 1] = 3 * ( pulses[i] & 0xf) + i;
325 fixed_sparse->
y[2*i ] = (pulses[i] & 0x100) ? -1.0: 1.0;
327 fixed_sparse->
y[2*i + 1] =
328 (fixed_sparse->
x[2*i + 1] < fixed_sparse->
x[2*i]) ?
329 -fixed_sparse->
y[2*i ] : fixed_sparse->
y[2*i];
337 int offset = (pulses[0] & 0x200) ? 2 : 0;
340 for (i = 0; i < 3; i++) {
341 int index = (val & 0x7) * 6 + 4 - i*2;
343 fixed_sparse->
y[i] = (offset +
index) & 0x3 ? -1 : 1;
344 fixed_sparse->
x[i] =
index;
350 int pulse_subset = (pulses[0] >> 8) & 1;
352 fixed_sparse->
x[0] = ((pulses[0] >> 4) & 15) * 3 + pulse_subset;
353 fixed_sparse->
x[1] = ( pulses[0] & 15) * 3 + pulse_subset + 1;
355 fixed_sparse->
y[0] = pulses[0] & 0x200 ? -1 : 1;
356 fixed_sparse->
y[1] = -fixed_sparse->
y[0];
379 memset(ir_buf, 0, LP_FILTER_ORDER *
sizeof(
float));
384 memcpy(ctx->
lsp_history, lsf_new, LP_FILTER_ORDER *
sizeof(
float));
388 for (i = 0; i < subframe_count; i++) {
392 float pitch_gain, gain_code, avg_energy;
402 2 * ((2 + T0_frac)%3 + 1), LP_FILTER_ORDER,
425 pitch_gain, gain_code, SUBFR_SIZE);
427 pitch_gain *= 0.5 * pitch_gain;
428 pitch_gain =
FFMIN(pitch_gain, 0.4);
435 fixed_vector[j] = excitation[j] - gain_code * fixed_vector[j];
441 pAz, excitation, SUBFR_SIZE,
446 SUBFR_SIZE, LP_FILTER_ORDER);
451 memcpy(synth - LP_FILTER_ORDER, synth + frame_size - LP_FILTER_ORDER,
452 LP_FILTER_ORDER *
sizeof(
float));
455 for (i = 0; i < subframe_count; i++) {
460 &synth[i * SUBFR_SIZE], energy,
465 LP_FILTER_ORDER*
sizeof(
float));
471 (
const float[2]) {-1.99997 , 1.000000000},
472 (
const float[2]) {-1.93307352, 0.935891986},
494 "Invalid block_align: %d. Mode %s guessed based on bitrate: %d\n",
510 for (i = 0; i < 4; i++)
522 int *got_frame_ptr,
AVPacket *avpkt)
525 const uint8_t *buf=avpkt->
data;
536 "Error processing packet: packet size (%d) too small\n",