Commit 011c9112 authored by Carl Eugen Hoyos's avatar Carl Eugen Hoyos

lavc/g729dec: Cosmetics, fix indentation after last commit.

parent 641d5215
...@@ -272,8 +272,7 @@ static void g729d_get_new_exc( ...@@ -272,8 +272,7 @@ static void g729d_get_new_exc(
ff_celp_convolve_circ(fc_new, fc_cur, phase_filter[dstate], subframe_size); ff_celp_convolve_circ(fc_new, fc_cur, phase_filter[dstate], subframe_size);
for(i=0; i<subframe_size; i++) for (i = 0; i < subframe_size; i++) {
{
out[i] = in[i]; out[i] = in[i];
out[i] -= (gain_code * fc_cur[i] + 0x2000) >> 14; out[i] -= (gain_code * fc_cur[i] + 0x2000) >> 14;
out[i] += (gain_code * fc_new[i] + 0x2000) >> 14; out[i] += (gain_code * fc_new[i] + 0x2000) >> 14;
...@@ -289,9 +288,9 @@ static void g729d_get_new_exc( ...@@ -289,9 +288,9 @@ static void g729d_get_new_exc(
*/ */
static int g729d_onset_decision(int past_onset, const int16_t* past_gain_code) static int g729d_onset_decision(int past_onset, const int16_t* past_gain_code)
{ {
if((past_gain_code[0] >> 1) > past_gain_code[1]) if ((past_gain_code[0] >> 1) > past_gain_code[1])
return 2; return 2;
else
return FFMAX(past_onset-1, 0); return FFMAX(past_onset-1, 0);
} }
...@@ -307,24 +306,25 @@ static int16_t g729d_voice_decision(int onset, int prev_voice_decision, const in ...@@ -307,24 +306,25 @@ static int16_t g729d_voice_decision(int onset, int prev_voice_decision, const in
{ {
int i, low_gain_pitch_cnt, voice_decision; int i, low_gain_pitch_cnt, voice_decision;
if(past_gain_pitch[0] >= 14745) // 0.9 if (past_gain_pitch[0] >= 14745) { // 0.9
voice_decision = DECISION_VOICE; voice_decision = DECISION_VOICE;
else if (past_gain_pitch[0] <= 9830) // 0.6 } else if (past_gain_pitch[0] <= 9830) { // 0.6
voice_decision = DECISION_NOISE; voice_decision = DECISION_NOISE;
else } else {
voice_decision = DECISION_INTERMEDIATE; voice_decision = DECISION_INTERMEDIATE;
}
for(i=0, low_gain_pitch_cnt=0; i<6; i++) for (i = 0, low_gain_pitch_cnt = 0; i < 6; i++)
if(past_gain_pitch[i] < 9830) if (past_gain_pitch[i] < 9830)
low_gain_pitch_cnt++; low_gain_pitch_cnt++;
if(low_gain_pitch_cnt > 2 && !onset) if (low_gain_pitch_cnt > 2 && !onset)
voice_decision = DECISION_NOISE; voice_decision = DECISION_NOISE;
if(!onset && voice_decision > prev_voice_decision + 1) if (!onset && voice_decision > prev_voice_decision + 1)
voice_decision--; voice_decision--;
if(onset && voice_decision < DECISION_VOICE) if (onset && voice_decision < DECISION_VOICE)
voice_decision++; voice_decision++;
return voice_decision; return voice_decision;
...@@ -381,7 +381,7 @@ static av_cold int decoder_init(AVCodecContext * avctx) ...@@ -381,7 +381,7 @@ static av_cold int decoder_init(AVCodecContext * avctx)
ctx->rand_value = 21845; ctx->rand_value = 21845;
/* quantized prediction error */ /* quantized prediction error */
for(i=0; i<4; i++) for (i = 0; i < 4; i++)
ctx->quant_energy[i] = -14336; // -14 in (5.10) ctx->quant_energy[i] = -14336; // -14 in (5.10)
ctx++; ctx++;
...@@ -446,7 +446,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, ...@@ -446,7 +446,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
int is_periodic = 0; ///< whether one of the subframes is declared as periodic or not int is_periodic = 0; ///< whether one of the subframes is declared as periodic or not
out_frame = (int16_t*)frame->data[c]; out_frame = (int16_t*)frame->data[c];
for (i=0; i < buf_size; i++) for (i = 0; i < buf_size; i++)
frame_erasure |= buf[i]; frame_erasure |= buf[i];
frame_erasure = !frame_erasure; frame_erasure = !frame_erasure;
...@@ -457,10 +457,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, ...@@ -457,10 +457,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
quantizer_2nd_lo = get_bits(&gb, VQ_2ND_BITS); quantizer_2nd_lo = get_bits(&gb, VQ_2ND_BITS);
quantizer_2nd_hi = get_bits(&gb, VQ_2ND_BITS); quantizer_2nd_hi = get_bits(&gb, VQ_2ND_BITS);
if(frame_erasure) if (frame_erasure) {
lsf_restore_from_previous(ctx->lsfq, ctx->past_quantizer_outputs, lsf_restore_from_previous(ctx->lsfq, ctx->past_quantizer_outputs,
ctx->ma_predictor_prev); ctx->ma_predictor_prev);
else { } else {
lsf_decode(ctx->lsfq, ctx->past_quantizer_outputs, lsf_decode(ctx->lsfq, ctx->past_quantizer_outputs,
ma_predictor, ma_predictor,
quantizer_1st, quantizer_2nd_lo, quantizer_2nd_hi); quantizer_1st, quantizer_2nd_lo, quantizer_2nd_hi);
...@@ -488,29 +488,31 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, ...@@ -488,29 +488,31 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
uint8_t gc_2nd_index; ///< gain codebook (second stage) index uint8_t gc_2nd_index; ///< gain codebook (second stage) index
ac_index = get_bits(&gb, format->ac_index_bits[i]); ac_index = get_bits(&gb, format->ac_index_bits[i]);
if(!i && format->parity_bit) if (!i && format->parity_bit)
bad_pitch = av_parity(ac_index >> 2) == get_bits1(&gb); bad_pitch = av_parity(ac_index >> 2) == get_bits1(&gb);
fc_indexes = get_bits(&gb, format->fc_indexes_bits); fc_indexes = get_bits(&gb, format->fc_indexes_bits);
pulses_signs = get_bits(&gb, format->fc_signs_bits); pulses_signs = get_bits(&gb, format->fc_signs_bits);
gc_1st_index = get_bits(&gb, format->gc_1st_index_bits); gc_1st_index = get_bits(&gb, format->gc_1st_index_bits);
gc_2nd_index = get_bits(&gb, format->gc_2nd_index_bits); gc_2nd_index = get_bits(&gb, format->gc_2nd_index_bits);
if (frame_erasure) if (frame_erasure) {
pitch_delay_3x = 3 * ctx->pitch_delay_int_prev; pitch_delay_3x = 3 * ctx->pitch_delay_int_prev;
else if(!i) { } else if (!i) {
if (bad_pitch) if (bad_pitch) {
pitch_delay_3x = 3 * ctx->pitch_delay_int_prev; pitch_delay_3x = 3 * ctx->pitch_delay_int_prev;
else } else {
pitch_delay_3x = ff_acelp_decode_8bit_to_1st_delay3(ac_index); pitch_delay_3x = ff_acelp_decode_8bit_to_1st_delay3(ac_index);
}
} else { } else {
int pitch_delay_min = av_clip(ctx->pitch_delay_int_prev - 5, int pitch_delay_min = av_clip(ctx->pitch_delay_int_prev - 5,
PITCH_DELAY_MIN, PITCH_DELAY_MAX - 9); PITCH_DELAY_MIN, PITCH_DELAY_MAX - 9);
if(packet_type == FORMAT_G729D_6K4) if (packet_type == FORMAT_G729D_6K4) {
pitch_delay_3x = ff_acelp_decode_4bit_to_2nd_delay3(ac_index, pitch_delay_min); pitch_delay_3x = ff_acelp_decode_4bit_to_2nd_delay3(ac_index, pitch_delay_min);
else } else {
pitch_delay_3x = ff_acelp_decode_5_6_bit_to_2nd_delay3(ac_index, pitch_delay_min); pitch_delay_3x = ff_acelp_decode_5_6_bit_to_2nd_delay3(ac_index, pitch_delay_min);
} }
}
/* Round pitch delay to nearest (used everywhere except ff_acelp_interpolate). */ /* Round pitch delay to nearest (used everywhere except ff_acelp_interpolate). */
pitch_delay_int[i] = (pitch_delay_3x + 1) / 3; pitch_delay_int[i] = (pitch_delay_3x + 1) / 3;
...@@ -576,9 +578,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, ...@@ -576,9 +578,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
It is not issue for G.729, because gain_corr_factor in it's case is always It is not issue for G.729, because gain_corr_factor in it's case is always
greater than 1024, while in G.729D it can be even zero. */ greater than 1024, while in G.729D it can be even zero. */
gain_corr_factor = FFMAX(gain_corr_factor, 1024); gain_corr_factor = FFMAX(gain_corr_factor, 1024);
#ifndef G729_BITEXACT #ifndef G729_BITEXACT
gain_corr_factor >>= 1; gain_corr_factor >>= 1;
#endif #endif
} else { } else {
ctx->past_gain_pitch[0] = cb_gain_1st_8k[gc_1st_index][0] + ctx->past_gain_pitch[0] = cb_gain_1st_8k[gc_1st_index][0] +
cb_gain_2nd_8k[gc_2nd_index][0]; cb_gain_2nd_8k[gc_2nd_index][0];
...@@ -592,7 +594,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, ...@@ -592,7 +594,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
ctx->quant_energy, ctx->quant_energy,
ma_prediction_coeff, ma_prediction_coeff,
SUBFRAME_SIZE, 4); SUBFRAME_SIZE, 4);
#ifdef G729_BITEXACT #ifdef G729_BITEXACT
/* /*
This correction required to get bit-exact result with This correction required to get bit-exact result with
reference code, because gain_corr_factor in G.729D is reference code, because gain_corr_factor in G.729D is
...@@ -606,7 +608,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, ...@@ -606,7 +608,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
gain_corr_factor >>= 1; gain_corr_factor >>= 1;
ctx->past_gain_code[0] >>= 1; ctx->past_gain_code[0] >>= 1;
} }
#endif #endif
} }
ff_acelp_update_past_gain(ctx->quant_energy, gain_corr_factor, 2, frame_erasure); ff_acelp_update_past_gain(ctx->quant_energy, gain_corr_factor, 2, frame_erasure);
...@@ -690,7 +692,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, ...@@ -690,7 +692,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
/* Calculate gain of filtered signal for use in AGC. */ /* Calculate gain of filtered signal for use in AGC. */
gain_after = 0; gain_after = 0;
for(j=0; j<SUBFRAME_SIZE; j++) for (j = 0; j < SUBFRAME_SIZE; j++)
gain_after += FFABS(synth[j+10]); gain_after += FFABS(synth[j+10]);
ctx->gain_coeff = ff_g729_adaptive_gain_control( ctx->gain_coeff = ff_g729_adaptive_gain_control(
...@@ -700,10 +702,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, ...@@ -700,10 +702,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
SUBFRAME_SIZE, SUBFRAME_SIZE,
ctx->gain_coeff); ctx->gain_coeff);
if (frame_erasure) if (frame_erasure) {
ctx->pitch_delay_int_prev = FFMIN(ctx->pitch_delay_int_prev + 1, PITCH_DELAY_MAX); ctx->pitch_delay_int_prev = FFMIN(ctx->pitch_delay_int_prev + 1, PITCH_DELAY_MAX);
else } else {
ctx->pitch_delay_int_prev = pitch_delay_int[i]; ctx->pitch_delay_int_prev = pitch_delay_int[i];
}
memcpy(synth+8, ctx->hpf_z, 2*sizeof(int16_t)); memcpy(synth+8, ctx->hpf_z, 2*sizeof(int16_t));
ff_acelp_high_pass_filter( ff_acelp_high_pass_filter(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment