32 #define BITSTREAM_READER_LE
42 #define MAX_SUBFRAME_COUNT 5
72 .bits_per_frame = 160,
74 .frames_per_packet = 1,
75 .pitch_sharp_factor = 0.00,
77 .number_of_fc_indexes = 10,
78 .ma_predictor_bits = 1,
79 .vq_indexes_bits = {7, 8, 7, 7, 7},
80 .pitch_delay_bits = {9, 6},
82 .fc_index_bits = {4, 5, 4, 5, 4, 5, 4, 5, 4, 5},
88 .bits_per_frame = 152,
90 .frames_per_packet = 1,
91 .pitch_sharp_factor = 0.8,
93 .number_of_fc_indexes = 3,
94 .ma_predictor_bits = 0,
95 .vq_indexes_bits = {6, 7, 7, 7, 5},
96 .pitch_delay_bits = {8, 5, 5},
98 .fc_index_bits = {9, 9, 9},
104 .bits_per_frame = 232,
106 .frames_per_packet = 2,
107 .pitch_sharp_factor = 0.8,
109 .number_of_fc_indexes = 3,
110 .ma_predictor_bits = 0,
111 .vq_indexes_bits = {6, 7, 7, 7, 5},
112 .pitch_delay_bits = {8, 5, 5},
114 .fc_index_bits = {5, 5, 5},
120 .bits_per_frame = 296,
122 .frames_per_packet = 2,
123 .pitch_sharp_factor = 0.85,
125 .number_of_fc_indexes = 1,
126 .ma_predictor_bits = 0,
127 .vq_indexes_bits = {6, 7, 7, 7, 5},
128 .pitch_delay_bits = {8, 5, 8, 5, 5},
130 .fc_index_bits = {10},
136 1.0/(1 << 1), 1.0/(1 << 2), 1.0/(1 << 3), 1.0/(1 << 4),
137 1.0/(1 << 5), 1.0/(1 << 6), 1.0/(1 << 7), 1.0/(1 << 8),
138 1.0/(1 << 9), 1.0/(1 << 10), 1.0/(1 << 11), 1.0/(1 << 12),
139 1.0/(1 << 13), 1.0/(1 << 14), 1.0/(1 << 15), 1.0/(1 << 16)
142 static void dequant(
float *
out,
const int *idx,
const float *
const cbs[])
148 for (i = 0; i < num_vec; i++)
149 memcpy(out + stride*i, cbs[i] + stride*idx[i], stride*
sizeof(
float));
162 lsfnew[i] = lsf_history[i] * 0.33 + lsf_tmp[i] +
mean_lsf[i];
169 lsfnew[9] =
FFMIN(lsfnew[LP_FILTER_ORDER - 1], 1.3 *
M_PI);
171 memcpy(lsf_history, lsf_tmp, LP_FILTER_ORDER *
sizeof(*lsf_history));
173 for (i = 0; i < LP_FILTER_ORDER - 1; i++)
174 lsfnew[i] = cos(lsfnew[i]);
175 lsfnew[LP_FILTER_ORDER - 1] *= 6.153848 /
M_PI;
185 fixed_vector[i] += beta * fixed_vector[i - pitch_lag_int];
201 for (i = 0; i < 5; i++)
221 float t,
t0 = 1.0 / num_subfr;
224 for (i = 0; i < num_subfr; i++) {
226 lsfint[j] = lsfold[j] * (1 - t) + t * lsfnew[j];
237 static void eval_ir(
const float *Az,
int pitch_lag,
float *freq,
238 float pitch_sharp_factor)
248 memset(tmp1 + 11, 0, 37 *
sizeof(
float));
260 const float *shape,
int length)
264 memset(out, 0, length*
sizeof(
float));
265 for (i = 0; i < pulses->
n; i++)
266 for (j = pulses->
x[i]; j < length; j++)
267 out[j] += pulses->
y[i] * shape[j - pulses->
x[i]];
287 LP_FILTER_ORDER*
sizeof(
float));
293 LP_FILTER_ORDER*
sizeof(
float));
298 LP_FILTER_ORDER*
sizeof(*pole_out));
301 LP_FILTER_ORDER*
sizeof(*pole_out));
315 for (i = 0; i < 3; i++) {
316 fixed_sparse->
x[i] = 3 * (pulses[i] & 0xf) + i;
317 fixed_sparse->
y[i] = pulses[i] & 0x10 ? -1 : 1;
322 for (i = 0; i < 3; i++) {
323 fixed_sparse->
x[2*i ] = 3 * ((pulses[i] >> 4) & 0xf) + i;
324 fixed_sparse->
x[2*i + 1] = 3 * ( pulses[i] & 0xf) + i;
326 fixed_sparse->
y[2*i ] = (pulses[i] & 0x100) ? -1.0: 1.0;
328 fixed_sparse->
y[2*i + 1] =
329 (fixed_sparse->
x[2*i + 1] < fixed_sparse->
x[2*i]) ?
330 -fixed_sparse->
y[2*i ] : fixed_sparse->
y[2*i];
338 int offset = (pulses[0] & 0x200) ? 2 : 0;
341 for (i = 0; i < 3; i++) {
342 int index = (val & 0x7) * 6 + 4 - i*2;
344 fixed_sparse->
y[i] = (offset +
index) & 0x3 ? -1 : 1;
345 fixed_sparse->
x[i] =
index;
351 int pulse_subset = (pulses[0] >> 8) & 1;
353 fixed_sparse->
x[0] = ((pulses[0] >> 4) & 15) * 3 + pulse_subset;
354 fixed_sparse->
x[1] = ( pulses[0] & 15) * 3 + pulse_subset + 1;
356 fixed_sparse->
y[0] = pulses[0] & 0x200 ? -1 : 1;
357 fixed_sparse->
y[1] = -fixed_sparse->
y[0];
380 memset(ir_buf, 0, LP_FILTER_ORDER *
sizeof(
float));
385 memcpy(ctx->
lsp_history, lsf_new, LP_FILTER_ORDER *
sizeof(
float));
389 for (i = 0; i < subframe_count; i++) {
393 float pitch_gain, gain_code, avg_energy;
403 2 * ((2 + T0_frac)%3 + 1), LP_FILTER_ORDER,
427 pitch_gain, gain_code, SUBFR_SIZE);
429 pitch_gain *= 0.5 * pitch_gain;
430 pitch_gain =
FFMIN(pitch_gain, 0.4);
437 fixed_vector[j] = excitation[j] - gain_code * fixed_vector[j];
443 pAz, excitation, SUBFR_SIZE,
448 SUBFR_SIZE, LP_FILTER_ORDER);
453 memcpy(synth - LP_FILTER_ORDER, synth + frame_size - LP_FILTER_ORDER,
454 LP_FILTER_ORDER *
sizeof(
float));
457 for (i = 0; i < subframe_count; i++) {
462 &synth[i * SUBFR_SIZE], energy,
467 LP_FILTER_ORDER*
sizeof(
float));
473 (
const float[2]) {-1.99997 , 1.000000000},
474 (
const float[2]) {-1.93307352, 0.935891986},
496 "Invalid block_align: %d. Mode %s guessed based on bitrate: %d\n",
512 for (i = 0; i < 4; i++)
523 int *got_frame_ptr,
AVPacket *avpkt)
538 "Error processing packet: packet size (%d) too small\n",
548 samples = (
float *)frame->
data[0];