aboutsummaryrefslogtreecommitdiff
path: root/encoder/drc_src
diff options
context:
space:
mode:
authorAkshay Ragir <akshay.ragir@ittiam.com>2023-10-03 11:02:53 +0530
committerDivya B M <89966460+divya-bm@users.noreply.github.com>2023-10-03 19:14:29 +0530
commitaeaaaf49457b590a699eab5e85ae3a51715ea95c (patch)
tree183b60ad5a3fd2adc98c961cdc0e152b4a78017d /encoder/drc_src
parentd8e8f980aec577c740e285c79a6da632d791bc79 (diff)
downloadlibxaac-aeaaaf49457b590a699eab5e85ae3a51715ea95c.tar.gz
Minor bug fixes
Diffstat (limited to 'encoder/drc_src')
-rw-r--r--encoder/drc_src/impd_drc_api.c22
-rw-r--r--encoder/drc_src/impd_drc_gain_calculator.c24
2 files changed, 37 insertions, 9 deletions
diff --git a/encoder/drc_src/impd_drc_api.c b/encoder/drc_src/impd_drc_api.c
index 6525dbb..fac98ff 100644
--- a/encoder/drc_src/impd_drc_api.c
+++ b/encoder/drc_src/impd_drc_api.c
@@ -40,8 +40,9 @@
var = MAX(var, lower_bound); \
}
-static VOID impd_drc_validate_config_params(ia_drc_input_config *pstr_inp_config) {
+static IA_ERRORCODE impd_drc_validate_config_params(ia_drc_input_config *pstr_inp_config) {
LOOPIDX i, j, k;
+ WORD32 curr_start_subband_idx, next_start_subband_idx;
ia_drc_uni_drc_config_struct *pstr_uni_drc_config = &pstr_inp_config->str_uni_drc_config;
ia_drc_loudness_info_set_struct *pstr_enc_loudness_info_set =
&pstr_inp_config->str_enc_loudness_info_set;
@@ -126,6 +127,19 @@ static VOID impd_drc_validate_config_params(ia_drc_input_config *pstr_inp_config
.start_sub_band_index,
0, STFT256_HOP_SIZE - 1);
}
+ for (k = 0; k <
+ pstr_uni_drc_config->str_drc_coefficients_uni_drc[i].str_gain_set_params[j].band_count
+ - 1; k++) {
+ curr_start_subband_idx = pstr_uni_drc_config->str_drc_coefficients_uni_drc[i].
+ str_gain_set_params[j].gain_params[k].start_sub_band_index;
+ next_start_subband_idx = pstr_uni_drc_config->str_drc_coefficients_uni_drc[i].
+ str_gain_set_params[j].gain_params[k + 1].start_sub_band_index;
+ /* It is assumed that the start index of a subband is greater than
+ the start index of its previous subbands for a multiband */
+ if (next_start_subband_idx <= curr_start_subband_idx) {
+ return IA_EXHEAACE_EXE_NONFATAL_USAC_INVALID_SUBBAND_INDEX;
+ }
+ }
}
}
IMPD_DRC_BOUND_CHECK(pstr_uni_drc_config->downmix_instructions_count, 0,
@@ -198,6 +212,7 @@ static VOID impd_drc_validate_config_params(ia_drc_input_config *pstr_inp_config
0, MAX_RELIABILITY_TYPE);
}
}
+ return IA_NO_ERROR;
}
static IA_ERRORCODE impd_drc_validate_drc_instructions(
@@ -267,7 +282,10 @@ IA_ERRORCODE impd_drc_enc_init(VOID *pstr_drc_state, VOID *ptr_drc_scratch,
pstr_drc_state_local->str_bit_buf_out.impd_drc_jmp_buf = &drc_enc_init_jmp_buf;
#endif // ENABLE_SET_JUMP
- impd_drc_validate_config_params(pstr_inp_config);
+ err_code = impd_drc_validate_config_params(pstr_inp_config);
+ if (err_code) {
+ return err_code;
+ }
err_code = impd_drc_gain_enc_init(
&pstr_drc_state_local->str_gain_enc, &pstr_inp_config->str_uni_drc_config,
diff --git a/encoder/drc_src/impd_drc_gain_calculator.c b/encoder/drc_src/impd_drc_gain_calculator.c
index bbc5b98..5a1305a 100644
--- a/encoder/drc_src/impd_drc_gain_calculator.c
+++ b/encoder/drc_src/impd_drc_gain_calculator.c
@@ -334,7 +334,7 @@ IA_ERRORCODE impd_drc_stft_drc_gain_calc_init(ia_drc_gain_enc_struct *pstr_drc_g
WORD32 gain_set_idx, WORD32 band_idx) {
ULOOPIDX i, j;
UWORD32 num_points;
- FLOAT32 width_e;
+ FLOAT32 width_e, tmp;
FLOAT64 g1, g2;
FLOAT64 x, y, cx, cy, r;
FLOAT64 inp_1, inp_2, out_1, out_2, theta, len;
@@ -477,13 +477,23 @@ IA_ERRORCODE impd_drc_stft_drc_gain_calc_init(ia_drc_gain_enc_struct *pstr_drc_g
pstr_drc_stft_gain_handle->yl_z1[i] = 0.0f;
}
- pstr_drc_stft_gain_handle->alpha_a =
- expf(-1.0f / ((pstr_drc_stft_gain_handle->attack_ms / (FLOAT32)STFT256_HOP_SIZE) *
- (FLOAT32)pstr_drc_gain_enc->sample_rate * 0.001f));
+ tmp = (pstr_drc_stft_gain_handle->attack_ms / STFT256_HOP_SIZE) *
+ pstr_drc_gain_enc->sample_rate * 0.001f;
+ if ((fabs(tmp) < FLT_EPSILON) && (tmp >= 0.0f)) {
+ pstr_drc_stft_gain_handle->alpha_a = 0;
+ }
+ else {
+ pstr_drc_stft_gain_handle->alpha_a = expf(ixheaace_div32(-1.0f, tmp));
+ }
- pstr_drc_stft_gain_handle->alpha_r =
- expf(-1.0f / ((pstr_drc_stft_gain_handle->release_ms / (FLOAT32)STFT256_HOP_SIZE) *
- (FLOAT32)pstr_drc_gain_enc->sample_rate * 0.001f));
+ tmp = (pstr_drc_stft_gain_handle->release_ms / STFT256_HOP_SIZE) *
+ pstr_drc_gain_enc->sample_rate * 0.001f;
+ if ((fabs(tmp) < FLT_EPSILON) && (tmp >= 0.0f)) {
+ pstr_drc_stft_gain_handle->alpha_r = 0;
+ }
+ else {
+ pstr_drc_stft_gain_handle->alpha_r = expf(ixheaace_div32(-1.0f, tmp));
+ }
return IA_NO_ERROR;
}