Skip to content

Commit

Permalink
Audio: Simplify multiband_drc_setup return logic
Browse files Browse the repository at this point in the history
Replaces intermediate variable and redundant comments with a direct
call to return multiband_drc_init_coef function.

Signed-off-by: Shriram Shastry <[email protected]>
  • Loading branch information
ShriramShastry committed Jun 21, 2024
1 parent 41a4892 commit 1fd88f5
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/audio/multiband_drc/multiband_drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static void multiband_drc_reset_state(struct multiband_drc_state *state)
multiband_drc_iir_reset_state_ch(&state->deemphasis[i]);
}

static int multiband_drc_eq_init_coef_ch(struct sof_eq_iir_biquad *coef,
static int multiband_drc_eq_init_coef_ch(struct comp_dev *dev, struct sof_eq_iir_biquad *coef,
struct iir_state_df2t *eq)
{
int ret;
Expand All @@ -77,8 +77,10 @@ static int multiband_drc_eq_init_coef_ch(struct sof_eq_iir_biquad *coef,
/* Coefficients of the first biquad and second biquad */
ret = memcpy_s(eq->coef, sizeof(struct sof_eq_iir_biquad) * SOF_EMP_DEEMP_BIQUADS,
coef, sizeof(struct sof_eq_iir_biquad) * SOF_EMP_DEEMP_BIQUADS);

assert(!ret);


/* EQ filters are two 2nd order filters, so only need 4 delay slots
* delay[0..1] -> state for first biquad
* delay[2..3] -> state for second biquad
Expand Down Expand Up @@ -146,7 +148,7 @@ static int multiband_drc_init_coef(struct processing_module *mod, int16_t nch, u
/* Emphasis: collect the coef array and assign it to every channel */
emphasis = config->emp_coef;
for (ch = 0; ch < nch; ch++) {
ret = multiband_drc_eq_init_coef_ch(emphasis, &state->emphasis[ch]);
ret = multiband_drc_eq_init_coef_ch(dev, emphasis, &state->emphasis[ch]);
/* Free all previously allocated blocks in case of an error */
if (ret < 0) {
comp_err(dev, "multiband_drc_init_coef(), could not assign coeffs to ch %d",
Expand All @@ -160,7 +162,7 @@ static int multiband_drc_init_coef(struct processing_module *mod, int16_t nch, u
/* Deemphasis: collect the coef array and assign it to every channel */
deemphasis = config->deemp_coef;
for (ch = 0; ch < nch; ch++) {
ret = multiband_drc_eq_init_coef_ch(deemphasis, &state->deemphasis[ch]);
ret = multiband_drc_eq_init_coef_ch(dev, deemphasis, &state->deemphasis[ch]);
/* Free all previously allocated blocks in case of an error */
if (ret < 0) {
comp_err(dev, "multiband_drc_init_coef(), could not assign coeffs to ch %d",
Expand Down Expand Up @@ -198,17 +200,12 @@ static int multiband_drc_init_coef(struct processing_module *mod, int16_t nch, u
static int multiband_drc_setup(struct processing_module *mod, int16_t channels, uint32_t rate)
{
struct multiband_drc_comp_data *cd = module_get_private_data(mod);
int ret;

/* Reset any previous state */
multiband_drc_reset_state(&cd->state);

/* Setup Crossover, Emphasis EQ, Deemphasis EQ, and DRC */
ret = multiband_drc_init_coef(mod, channels, rate);
if (ret < 0)
return ret;

return 0;
return multiband_drc_init_coef(mod, channels, rate);
}

/*
Expand Down

0 comments on commit 1fd88f5

Please sign in to comment.