52 #define LSFQ_MAX 25681
58 #define LSFQ_DIFF_MIN 321
61 #define INTERPOL_LEN 11
67 #define SHARP_MIN 3277
76 #define SHARP_MAX 13017
81 #define MR_ENERGY 1018156
83 #define DECISION_NOISE 0
84 #define DECISION_INTERMEDIATE 1
85 #define DECISION_VOICE 2
113 int16_t past_quantizer_output_buf[
MA_NP + 1][10];
114 int16_t* past_quantizer_outputs[
MA_NP + 1];
117 int16_t lsp_buf[2][10];
120 int16_t quant_energy[4];
123 int16_t syn_filter_data[10];
136 int16_t past_gain_pitch[6];
139 int16_t past_gain_code[2];
164 .fc_indexes_bits = 13,
173 .fc_indexes_bits = 9,
181 return 31821 * value + 13849;
189 return (0x6996966996696996ULL >> (value >> 2)) & 1;
202 int16_t ma_predictor,
203 int16_t vq_1st, int16_t vq_2nd_low, int16_t vq_2nd_high)
206 static const uint8_t min_distance[2]={10, 5};
207 int16_t* quantizer_output = past_quantizer_outputs[
MA_NP];
209 for (i = 0; i < 5; i++) {
211 quantizer_output[i + 5] =
cb_lsp_1st[vq_1st][i + 5] + cb_lsp_2nd[vq_2nd_high][i + 5];
214 for (j = 0; j < 2; j++) {
215 for (i = 1; i < 10; i++) {
216 int diff = (quantizer_output[i - 1] - quantizer_output[i] + min_distance[j]) >> 1;
218 quantizer_output[i - 1] -=
diff;
219 quantizer_output[i ] +=
diff;
224 for (i = 0; i < 10; i++) {
226 for (j = 0; j <
MA_NP; j++)
227 sum += past_quantizer_outputs[j][i] *
cb_ma_predictor[ma_predictor][j][i];
243 int16_t* past_quantizer_outputs[
MA_NP + 1],
244 int ma_predictor_prev)
246 int16_t* quantizer_output = past_quantizer_outputs[
MA_NP];
249 for (i = 0; i < 10; i++) {
250 int tmp = lsfq[i] << 15;
252 for (k = 0; k <
MA_NP; k++)
253 tmp -= past_quantizer_outputs[k][i] *
cb_ma_predictor[ma_predictor_prev][k][i];
270 const int16_t* fc_cur,
280 for(i=0; i<subframe_size; i++)
283 out[i] -= (gain_code * fc_cur[i] + 0x2000) >> 14;
284 out[i] += (gain_code * fc_new[i] + 0x2000) >> 14;
297 if((past_gain_code[0] >> 1) > past_gain_code[1])
300 return FFMAX(past_onset-1, 0);
313 int i, low_gain_pitch_cnt, voice_decision;
315 if(past_gain_pitch[0] >= 14745)
317 else if (past_gain_pitch[0] <= 9830)
322 for(i=0, low_gain_pitch_cnt=0; i<6; i++)
323 if(past_gain_pitch[i] < 9830)
324 low_gain_pitch_cnt++;
326 if(low_gain_pitch_cnt > 2 && !onset)
329 if(!onset && voice_decision > prev_voice_decision + 1)
335 return voice_decision;
343 res += *v1++ * *v2++;
364 for (k = 0; k <
MA_NP + 1; k++) {
366 for (i = 1; i < 11; i++)
372 memcpy(ctx->
lsp[0],
lsp_init, 10 *
sizeof(int16_t));
398 int buf_size = avpkt->
size;
414 int pitch_delay_int[2];
419 int gain_before, gain_after;
427 out_frame = (int16_t*) ctx->
frame.
data[0];
429 if (buf_size == 10) {
436 }
else if (buf_size == 8) {
445 for (i=0; i < buf_size; i++)
446 frame_erasure |= buf[i];
462 quantizer_1st, quantizer_2nd_lo, quantizer_2nd_hi);
468 MA_NP *
sizeof(int16_t*));
477 for (i = 0; i < 2; i++) {
478 int gain_corr_factor;
512 pitch_delay_int[i] = (pitch_delay_3x + 1) / 3;
528 switch (packet_type) {
532 fc_indexes, pulses_signs, 3, 3);
537 fc_indexes, pulses_signs, 1, 4);
550 fc + pitch_delay_int[i],
554 SUBFRAME_SIZE - pitch_delay_int[i]);
563 gain_corr_factor = 0;
569 cb_gain_2nd_6k4[gc_2nd_index][1];
574 gain_corr_factor =
FFMAX(gain_corr_factor, 1024);
575 #ifndef G729_BITEXACT
576 gain_corr_factor >>= 1;
582 cb_gain_2nd_8k[gc_2nd_index][1];
602 gain_corr_factor >>= 1;
611 ctx->
exc + i * SUBFRAME_SIZE - pitch_delay_3x / 3,
613 (pitch_delay_3x % 3) << 1,
617 ctx->
exc + i * SUBFRAME_SIZE, fc,
620 1 << 13, 14, SUBFRAME_SIZE);
627 ctx->
exc + i * SUBFRAME_SIZE,
659 ctx->
exc + i * SUBFRAME_SIZE,
667 memcpy(ctx->
syn_filter_data, synth+SUBFRAME_SIZE, 10 *
sizeof(int16_t));
672 gain_before +=
FFABS(synth[j+10]);
690 gain_after +=
FFABS(synth[j+10]);
704 memcpy(synth+8, ctx->
hpf_z, 2*
sizeof(int16_t));
706 out_frame + i*SUBFRAME_SIZE,
710 memcpy(ctx->
hpf_z, synth+8+SUBFRAME_SIZE, 2*
sizeof(int16_t));