summaryrefslogtreecommitdiff
path: root/libavcodec/amrnbdec.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2021-10-03 11:37:50 +0200
committerPaul B Mahol <onemda@gmail.com>2021-10-03 11:42:15 +0200
commitd2cf2cb0bd3ebfeabab6663b59a82f2c69a75e87 (patch)
treef7fbbdcc2fffe1f5208fdd22daefd1d93ad85510 /libavcodec/amrnbdec.c
parentf282c34c009e3653ec160c3880e64fc1a9300d0e (diff)
avcodec/amr*dec: reindent
Diffstat (limited to 'libavcodec/amrnbdec.c')
-rw-r--r--libavcodec/amrnbdec.c228
1 files changed, 114 insertions, 114 deletions
diff --git a/libavcodec/amrnbdec.c b/libavcodec/amrnbdec.c
index 472fa85f87..5efaa7d1fc 100644
--- a/libavcodec/amrnbdec.c
+++ b/libavcodec/amrnbdec.c
@@ -181,21 +181,21 @@ static av_cold int amrnb_decode_init(AVCodecContext *avctx)
for (int ch = 0; ch < avctx->channels; ch++) {
AMRContext *p = &s->ch[ch];
- // p->excitation always points to the same position in p->excitation_buf
- p->excitation = &p->excitation_buf[PITCH_DELAY_MAX + LP_FILTER_ORDER + 1];
+ // p->excitation always points to the same position in p->excitation_buf
+ p->excitation = &p->excitation_buf[PITCH_DELAY_MAX + LP_FILTER_ORDER + 1];
- for (i = 0; i < LP_FILTER_ORDER; i++) {
- p->prev_lsp_sub4[i] = lsp_sub4_init[i] * 1000 / (float)(1 << 15);
- p->lsf_avg[i] = p->lsf_q[3][i] = lsp_avg_init[i] / (float)(1 << 15);
- }
+ for (i = 0; i < LP_FILTER_ORDER; i++) {
+ p->prev_lsp_sub4[i] = lsp_sub4_init[i] * 1000 / (float)(1 << 15);
+ p->lsf_avg[i] = p->lsf_q[3][i] = lsp_avg_init[i] / (float)(1 << 15);
+ }
- for (i = 0; i < 4; i++)
- p->prediction_error[i] = MIN_ENERGY;
+ for (i = 0; i < 4; i++)
+ p->prediction_error[i] = MIN_ENERGY;
- ff_acelp_filter_init(&p->acelpf_ctx);
- ff_acelp_vectors_init(&p->acelpv_ctx);
- ff_celp_filter_init(&p->celpf_ctx);
- ff_celp_math_init(&p->celpm_ctx);
+ ff_acelp_filter_init(&p->acelpf_ctx);
+ ff_acelp_vectors_init(&p->acelpv_ctx);
+ ff_celp_filter_init(&p->celpf_ctx);
+ ff_celp_math_init(&p->celpm_ctx);
}
return 0;
@@ -980,112 +980,112 @@ static int amrnb_decode_frame(AVCodecContext *avctx, void *data,
int channel_size;
int i, subframe;
- p->cur_frame_mode = unpack_bitstream(p, buf, buf_size);
+ p->cur_frame_mode = unpack_bitstream(p, buf, buf_size);
channel_size = frame_sizes_nb[p->cur_frame_mode] + 1; // +7 for rounding and +8 for TOC
- if (p->cur_frame_mode == NO_DATA) {
- av_log(avctx, AV_LOG_ERROR, "Corrupt bitstream\n");
- return AVERROR_INVALIDDATA;
- }
- if (p->cur_frame_mode == MODE_DTX) {
- avpriv_report_missing_feature(avctx, "dtx mode");
- av_log(avctx, AV_LOG_INFO, "Note: libopencore_amrnb supports dtx\n");
- return AVERROR_PATCHWELCOME;
- }
-
- if (p->cur_frame_mode == MODE_12k2) {
- lsf2lsp_5(p);
- } else
- lsf2lsp_3(p);
-
- for (i = 0; i < 4; i++)
- ff_acelp_lspd2lpc(p->lsp[i], p->lpc[i], 5);
-
- for (subframe = 0; subframe < 4; subframe++) {
- const AMRNBSubframe *amr_subframe = &p->frame.subframe[subframe];
-
- decode_pitch_vector(p, amr_subframe, subframe);
-
- decode_fixed_sparse(&fixed_sparse, amr_subframe->pulses,
- p->cur_frame_mode, subframe);
-
- // The fixed gain (section 6.1.3) depends on the fixed vector
- // (section 6.1.2), but the fixed vector calculation uses
- // pitch sharpening based on the on the pitch gain (section 6.1.3).
- // So the correct order is: pitch gain, pitch sharpening, fixed gain.
- decode_gains(p, amr_subframe, p->cur_frame_mode, subframe,
- &fixed_gain_factor);
-
- pitch_sharpening(p, subframe, p->cur_frame_mode, &fixed_sparse);
-
- if (fixed_sparse.pitch_lag == 0) {
- av_log(avctx, AV_LOG_ERROR, "The file is corrupted, pitch_lag = 0 is not allowed\n");
+ if (p->cur_frame_mode == NO_DATA) {
+ av_log(avctx, AV_LOG_ERROR, "Corrupt bitstream\n");
return AVERROR_INVALIDDATA;
}
- ff_set_fixed_vector(p->fixed_vector, &fixed_sparse, 1.0,
- AMR_SUBFRAME_SIZE);
-
- p->fixed_gain[4] =
- ff_amr_set_fixed_gain(fixed_gain_factor,
- p->celpm_ctx.dot_productf(p->fixed_vector,
- p->fixed_vector,
- AMR_SUBFRAME_SIZE) /
- AMR_SUBFRAME_SIZE,
- p->prediction_error,
- energy_mean[p->cur_frame_mode], energy_pred_fac);
-
- // The excitation feedback is calculated without any processing such
- // as fixed gain smoothing. This isn't mentioned in the specification.
- for (i = 0; i < AMR_SUBFRAME_SIZE; i++)
- p->excitation[i] *= p->pitch_gain[4];
- ff_set_fixed_vector(p->excitation, &fixed_sparse, p->fixed_gain[4],
- AMR_SUBFRAME_SIZE);
-
- // In the ref decoder, excitation is stored with no fractional bits.
- // This step prevents buzz in silent periods. The ref encoder can
- // emit long sequences with pitch factor greater than one. This
- // creates unwanted feedback if the excitation vector is nonzero.
- // (e.g. test sequence T19_795.COD in 3GPP TS 26.074)
- for (i = 0; i < AMR_SUBFRAME_SIZE; i++)
- p->excitation[i] = truncf(p->excitation[i]);
-
- // Smooth fixed gain.
- // The specification is ambiguous, but in the reference source, the
- // smoothed value is NOT fed back into later fixed gain smoothing.
- synth_fixed_gain = fixed_gain_smooth(p, p->lsf_q[subframe],
- p->lsf_avg, p->cur_frame_mode);
-
- synth_fixed_vector = anti_sparseness(p, &fixed_sparse, p->fixed_vector,
- synth_fixed_gain, spare_vector);
-
- if (synthesis(p, p->lpc[subframe], synth_fixed_gain,
- synth_fixed_vector, &p->samples_in[LP_FILTER_ORDER], 0))
- // overflow detected -> rerun synthesis scaling pitch vector down
- // by a factor of 4, skipping pitch vector contribution emphasis
- // and adaptive gain control
- synthesis(p, p->lpc[subframe], synth_fixed_gain,
- synth_fixed_vector, &p->samples_in[LP_FILTER_ORDER], 1);
-
- postfilter(p, p->lpc[subframe], buf_out + subframe * AMR_SUBFRAME_SIZE);
-
- // update buffers and history
- ff_clear_fixed_vector(p->fixed_vector, &fixed_sparse, AMR_SUBFRAME_SIZE);
- update_state(p);
- }
+ if (p->cur_frame_mode == MODE_DTX) {
+ avpriv_report_missing_feature(avctx, "dtx mode");
+ av_log(avctx, AV_LOG_INFO, "Note: libopencore_amrnb supports dtx\n");
+ return AVERROR_PATCHWELCOME;
+ }
+
+ if (p->cur_frame_mode == MODE_12k2) {
+ lsf2lsp_5(p);
+ } else
+ lsf2lsp_3(p);
+
+ for (i = 0; i < 4; i++)
+ ff_acelp_lspd2lpc(p->lsp[i], p->lpc[i], 5);
+
+ for (subframe = 0; subframe < 4; subframe++) {
+ const AMRNBSubframe *amr_subframe = &p->frame.subframe[subframe];
+
+ decode_pitch_vector(p, amr_subframe, subframe);
+
+ decode_fixed_sparse(&fixed_sparse, amr_subframe->pulses,
+ p->cur_frame_mode, subframe);
+
+ // The fixed gain (section 6.1.3) depends on the fixed vector
+ // (section 6.1.2), but the fixed vector calculation uses
+ // pitch sharpening based on the on the pitch gain (section 6.1.3).
+ // So the correct order is: pitch gain, pitch sharpening, fixed gain.
+ decode_gains(p, amr_subframe, p->cur_frame_mode, subframe,
+ &fixed_gain_factor);
+
+ pitch_sharpening(p, subframe, p->cur_frame_mode, &fixed_sparse);
+
+ if (fixed_sparse.pitch_lag == 0) {
+ av_log(avctx, AV_LOG_ERROR, "The file is corrupted, pitch_lag = 0 is not allowed\n");
+ return AVERROR_INVALIDDATA;
+ }
+ ff_set_fixed_vector(p->fixed_vector, &fixed_sparse, 1.0,
+ AMR_SUBFRAME_SIZE);
+
+ p->fixed_gain[4] =
+ ff_amr_set_fixed_gain(fixed_gain_factor,
+ p->celpm_ctx.dot_productf(p->fixed_vector,
+ p->fixed_vector,
+ AMR_SUBFRAME_SIZE) /
+ AMR_SUBFRAME_SIZE,
+ p->prediction_error,
+ energy_mean[p->cur_frame_mode], energy_pred_fac);
+
+ // The excitation feedback is calculated without any processing such
+ // as fixed gain smoothing. This isn't mentioned in the specification.
+ for (i = 0; i < AMR_SUBFRAME_SIZE; i++)
+ p->excitation[i] *= p->pitch_gain[4];
+ ff_set_fixed_vector(p->excitation, &fixed_sparse, p->fixed_gain[4],
+ AMR_SUBFRAME_SIZE);
+
+ // In the ref decoder, excitation is stored with no fractional bits.
+ // This step prevents buzz in silent periods. The ref encoder can
+ // emit long sequences with pitch factor greater than one. This
+ // creates unwanted feedback if the excitation vector is nonzero.
+ // (e.g. test sequence T19_795.COD in 3GPP TS 26.074)
+ for (i = 0; i < AMR_SUBFRAME_SIZE; i++)
+ p->excitation[i] = truncf(p->excitation[i]);
+
+ // Smooth fixed gain.
+ // The specification is ambiguous, but in the reference source, the
+ // smoothed value is NOT fed back into later fixed gain smoothing.
+ synth_fixed_gain = fixed_gain_smooth(p, p->lsf_q[subframe],
+ p->lsf_avg, p->cur_frame_mode);
+
+ synth_fixed_vector = anti_sparseness(p, &fixed_sparse, p->fixed_vector,
+ synth_fixed_gain, spare_vector);
+
+ if (synthesis(p, p->lpc[subframe], synth_fixed_gain,
+ synth_fixed_vector, &p->samples_in[LP_FILTER_ORDER], 0))
+ // overflow detected -> rerun synthesis scaling pitch vector down
+ // by a factor of 4, skipping pitch vector contribution emphasis
+ // and adaptive gain control
+ synthesis(p, p->lpc[subframe], synth_fixed_gain,
+ synth_fixed_vector, &p->samples_in[LP_FILTER_ORDER], 1);
+
+ postfilter(p, p->lpc[subframe], buf_out + subframe * AMR_SUBFRAME_SIZE);
+
+ // update buffers and history
+ ff_clear_fixed_vector(p->fixed_vector, &fixed_sparse, AMR_SUBFRAME_SIZE);
+ update_state(p);
+ }
- p->acelpf_ctx.acelp_apply_order_2_transfer_function(buf_out,
- buf_out, highpass_zeros,
- highpass_poles,
- highpass_gain * AMR_SAMPLE_SCALE,
- p->high_pass_mem, AMR_BLOCK_SIZE);
-
- /* Update averaged lsf vector (used for fixed gain smoothing).
- *
- * Note that lsf_avg should not incorporate the current frame's LSFs
- * for fixed_gain_smooth.
- * The specification has an incorrect formula: the reference decoder uses
- * qbar(n-1) rather than qbar(n) in section 6.1(4) equation 71. */
- p->acelpv_ctx.weighted_vector_sumf(p->lsf_avg, p->lsf_avg, p->lsf_q[3],
- 0.84, 0.16, LP_FILTER_ORDER);
+ p->acelpf_ctx.acelp_apply_order_2_transfer_function(buf_out,
+ buf_out, highpass_zeros,
+ highpass_poles,
+ highpass_gain * AMR_SAMPLE_SCALE,
+ p->high_pass_mem, AMR_BLOCK_SIZE);
+
+ /* Update averaged lsf vector (used for fixed gain smoothing).
+ *
+ * Note that lsf_avg should not incorporate the current frame's LSFs
+ * for fixed_gain_smooth.
+ * The specification has an incorrect formula: the reference decoder uses
+ * qbar(n-1) rather than qbar(n) in section 6.1(4) equation 71. */
+ p->acelpv_ctx.weighted_vector_sumf(p->lsf_avg, p->lsf_avg, p->lsf_q[3],
+ 0.84, 0.16, LP_FILTER_ORDER);
buf += channel_size;
buf_size -= channel_size;
}