Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiband_drc: instantaneous enabled state switch on processing #8922

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 21 additions & 24 deletions src/audio/multiband_drc/multiband_drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ static int multiband_drc_init_coef(struct multiband_drc_comp_data *cd, int16_t n
"multiband_drc_init_coef(), initializing %i-way crossover",
config->num_bands);

/* Crossover: determine the split function */
cd->crossover_split = crossover_find_split_func(config->num_bands);
if (!cd->crossover_split) {
comp_cl_err(&comp_multiband_drc,
"multiband_drc_init_coef(), No crossover_split for band num %i",
config->num_bands);
ret = -EINVAL;
goto err;
}

/* Crossover: collect the coef array and assign it to every channel */
crossover = config->crossover_coef;
for (ch = 0; ch < nch; ch++) {
Expand Down Expand Up @@ -456,7 +466,10 @@ static void multiband_drc_process(struct comp_dev *dev, struct comp_buffer *sour

buffer_stream_invalidate(source, source_bytes);

cd->multiband_drc_func(dev, &source->stream, &sink->stream, frames);
if (cd->process_enabled)
cd->multiband_drc_func(dev, &source->stream, &sink->stream, frames);
else
multiband_drc_default_pass(dev, &source->stream, &sink->stream, frames);

buffer_stream_writeback(sink, sink_bytes);

Expand Down Expand Up @@ -530,35 +543,19 @@ static int multiband_drc_prepare(struct comp_dev *dev)
comp_dbg(dev, "multiband_drc_prepare(), source_format=%d, sink_format=%d",
cd->source_format, cd->source_format);
cd->config = comp_get_data_blob(cd->model_handler, NULL, NULL);
if (cd->config && cd->process_enabled) {
if (cd->config) {
ret = multiband_drc_setup(cd, sourceb->stream.channels, sourceb->stream.rate);
if (ret < 0) {
comp_err(dev, "multiband_drc_prepare() error: multiband_drc_setup failed.");
goto err;
}
}

cd->multiband_drc_func = multiband_drc_find_proc_func(cd->source_format);
if (!cd->multiband_drc_func) {
comp_err(dev, "multiband_drc_prepare(), No proc func");
ret = -EINVAL;
goto err;
}

cd->crossover_split = crossover_find_split_func(cd->config->num_bands);
if (!cd->crossover_split) {
comp_err(dev, "multiband_drc_prepare(), No crossover_split for band num %i",
cd->config->num_bands);
ret = -EINVAL;
goto err;
}
} else {
comp_info(dev, "multiband_drc_prepare(), DRC is in passthrough mode");
cd->multiband_drc_func = multiband_drc_find_proc_func_pass(cd->source_format);
if (!cd->multiband_drc_func) {
comp_err(dev, "multiband_drc_prepare(), No proc func passthrough");
ret = -EINVAL;
goto err;
}
cd->multiband_drc_func = multiband_drc_find_proc_func(cd->source_format);
if (!cd->multiband_drc_func) {
comp_err(dev, "multiband_drc_prepare(), No proc func");
ret = -EINVAL;
goto err;
}

/* validate sink data format and period bytes */
Expand Down
8 changes: 4 additions & 4 deletions src/audio/multiband_drc/multiband_drc_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#include <sof/audio/multiband_drc/multiband_drc.h>
#include <sof/math/iir_df2t.h>

static void multiband_drc_default_pass(const struct comp_dev *dev,
const struct audio_stream *source,
struct audio_stream *sink,
uint32_t frames)
void multiband_drc_default_pass(const struct comp_dev *dev,
const struct audio_stream *source,
struct audio_stream *sink,
uint32_t frames)
{
audio_stream_copy(source, 0, sink, 0, source->channels * frames);
}
Expand Down
5 changes: 5 additions & 0 deletions src/include/sof/audio/multiband_drc/multiband_drc.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ extern const struct multiband_drc_proc_fnmap multiband_drc_proc_fnmap[];
extern const struct multiband_drc_proc_fnmap multiband_drc_proc_fnmap_pass[];
extern const size_t multiband_drc_proc_fncount;

void multiband_drc_default_pass(const struct comp_dev *dev,
const struct audio_stream *source,
struct audio_stream *sink,
uint32_t frames);

/**
* \brief Returns Multiband DRC processing function.
*/
Expand Down
Loading