Skip to content

Commit

Permalink
various components: Remove default/stub init_alignment_constants usage
Browse files Browse the repository at this point in the history
Traditionally audio_stream has failed to initialize its computed
alignment fields, forcing components to do this themselves even when
they don't actually have special alignment requirements.

Remove all the code that was merely setting default values, leaving
only a handful of spots with special equirements (e.g. eq/aria need to
treat pairs of samples, a few others have HiFi-optimized variants
which need SIMD alignment).

Signed-off-by: Andy Ross <andyross@google.com>
  • Loading branch information
andyross committed Dec 23, 2023
1 parent 1e46295 commit bc43097
Show file tree
Hide file tree
Showing 11 changed files with 4 additions and 87 deletions.
4 changes: 1 addition & 3 deletions src/audio/aria/aria.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,7 @@ static void aria_set_stream_params(struct comp_buffer *buffer,
const struct ipc4_audio_format *audio_fmt = &mod->priv.cfg.base_cfg.audio_fmt;

ipc4_update_buffer_format(buffer, audio_fmt);
#ifdef ARIA_GENERIC
audio_stream_init_alignment_constants(1, 1, &buffer->stream);
#else
#ifndef ARIA_GENERIC
audio_stream_init_alignment_constants(8, 1, &buffer->stream);
#endif
}
Expand Down
3 changes: 0 additions & 3 deletions src/audio/asrc/asrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,6 @@ static int asrc_prepare(struct processing_module *mod,
sinkb = list_first_item(&dev->bsink_list,
struct comp_buffer, source_list);

audio_stream_init_alignment_constants(1, 1, &sourceb->stream);
audio_stream_init_alignment_constants(1, 1, &sinkb->stream);

/* get source data format and period bytes */
cd->source_format = audio_stream_get_frm_fmt(&sourceb->stream);
source_period_bytes = audio_stream_period_bytes(&sourceb->stream,
Expand Down
5 changes: 1 addition & 4 deletions src/audio/crossover/crossover.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,14 +733,11 @@ static int crossover_prepare(struct processing_module *mod,
/* Get source data format */
cd->source_format = audio_stream_get_frm_fmt(&source->stream);
channels = audio_stream_get_channels(&source->stream);
audio_stream_init_alignment_constants(1, 1, &source->stream);

/* Validate frame format and buffer size of sinks */
list_for_item(sink_list, &dev->bsink_list) {
sink = container_of(sink_list, struct comp_buffer, source_list);
if (cd->source_format == audio_stream_get_frm_fmt(&sink->stream)) {
audio_stream_init_alignment_constants(1, 1, &sink->stream);
} else {
if (cd->source_format != audio_stream_get_frm_fmt(&sink->stream)) {
comp_err(dev, "crossover_prepare(): Source fmt %d and sink fmt %d are different.",
cd->source_format, audio_stream_get_frm_fmt(&sink->stream));
ret = -EINVAL;
Expand Down
13 changes: 0 additions & 13 deletions src/audio/dcblock/dcblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,6 @@ static int dcblock_process(struct processing_module *mod,
return 0;
}

/* init and calculate the aligned setting for available frames and free frames retrieve*/
static inline void dcblock_set_frame_alignment(struct audio_stream *source,
struct audio_stream *sink)
{
const uint32_t byte_align = 1;
const uint32_t frame_align_req = 1;

audio_stream_init_alignment_constants(byte_align, frame_align_req, source);
audio_stream_init_alignment_constants(byte_align, frame_align_req, sink);
}

/**
* \brief Prepares DC Blocking Filter component for processing.
* \param[in,out] dev DC Blocking Filter base component device.
Expand Down Expand Up @@ -221,8 +210,6 @@ static int dcblock_prepare(struct processing_module *mod,
/* get sink data format and period bytes */
cd->sink_format = audio_stream_get_frm_fmt(&sinkb->stream);

dcblock_set_frame_alignment(&sourceb->stream, &sinkb->stream);

dcblock_init_state(cd);
cd->dcblock_func = dcblock_find_func(cd->source_format);
if (!cd->dcblock_func) {
Expand Down
9 changes: 0 additions & 9 deletions src/audio/drc/drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,6 @@ static int drc_get_config(struct processing_module *mod,
return comp_data_blob_get_cmd(cd->model_handler, cdata, fragment_size);
}

static void drc_set_alignment(struct audio_stream *source,
struct audio_stream *sink)
{
/* Currently no optimizations those would use wider loads and stores */
audio_stream_init_alignment_constants(1, 1, source);
audio_stream_init_alignment_constants(1, 1, sink);
}

static int drc_process(struct processing_module *mod,
struct input_stream_buffer *input_buffers,
int num_input_buffers,
Expand Down Expand Up @@ -344,7 +336,6 @@ static int drc_prepare(struct processing_module *mod,
/* DRC component will only ever have 1 source and 1 sink buffer */
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);
drc_set_alignment(&sourceb->stream, &sinkb->stream);

/* get source data format */
cd->source_format = audio_stream_get_frm_fmt(&sourceb->stream);
Expand Down
4 changes: 0 additions & 4 deletions src/audio/kpb.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,16 +893,12 @@ static int kpb_prepare(struct comp_dev *dev)
*/
if (kpb->ipc4_cfg.base_cfg.ibs != kpb->ipc4_cfg.base_cfg.obs) {
struct list_item *sink_list;
const uint32_t byte_align = 1;
const uint32_t frame_align_req = 1;
uint32_t sink_id;

list_for_item(sink_list, &dev->bsink_list) {
struct comp_buffer *sink =
container_of(sink_list, struct comp_buffer, source_list);

audio_stream_init_alignment_constants(byte_align, frame_align_req,
&sink->stream);
sink_id = buf_get_id(sink);

if (sink_id == 0)
Expand Down
12 changes: 0 additions & 12 deletions src/audio/mfcc/mfcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,6 @@ static int mfcc_process(struct processing_module *mod,
return 0;
}

static void mfcc_set_alignment(struct audio_stream *source, struct audio_stream *sink)
{
const uint32_t byte_align = 1;
const uint32_t frame_align_req = 1;

audio_stream_init_alignment_constants(byte_align, frame_align_req, source);
audio_stream_init_alignment_constants(byte_align, frame_align_req, sink);
}

static int mfcc_prepare(struct processing_module *mod,
struct sof_source **sources, int num_of_sources,
struct sof_sink **sinks, int num_of_sinks)
Expand All @@ -208,9 +199,6 @@ static int mfcc_prepare(struct processing_module *mod,
/* get source data format */
source_format = audio_stream_get_frm_fmt(&sourceb->stream);

/* set align requirements */
mfcc_set_alignment(&sourceb->stream, &sinkb->stream);

/* get sink data format and period bytes */
sink_format = audio_stream_get_frm_fmt(&sinkb->stream);
sink_period_bytes = audio_stream_period_bytes(&sinkb->stream, dev->frames);
Expand Down
11 changes: 1 addition & 10 deletions src/audio/mixer/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,8 @@ static inline void mixer_set_frame_alignment(struct audio_stream *source)
/*There is no limit for frame number, so set it as 1*/
const uint32_t frame_align_req = 1;

#else

/* Since the generic version process signal sample by sample, so there is no
* limit for it, then set the byte_align and frame_align_req to be 1.
*/
const uint32_t byte_align = 1;
const uint32_t frame_align_req = 1;

#endif

audio_stream_init_alignment_constants(byte_align, frame_align_req, source);
#endif
}

static int mixer_prepare(struct processing_module *mod,
Expand Down
10 changes: 0 additions & 10 deletions src/audio/multiband_drc/multiband_drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,6 @@ static int multiband_drc_get_config(struct processing_module *mod,
return multiband_drc_get_ipc_config(mod, cdata, fragment_size);
}

static void multiband_drc_set_alignment(struct audio_stream *source,
struct audio_stream *sink)
{
/* Currently no optimizations those would use wider loads and stores */
audio_stream_init_alignment_constants(1, 1, source);
audio_stream_init_alignment_constants(1, 1, sink);
}

static int multiband_drc_process(struct processing_module *mod,
struct input_stream_buffer *input_buffers, int num_input_buffers,
struct output_stream_buffer *output_buffers,
Expand Down Expand Up @@ -371,8 +363,6 @@ static int multiband_drc_prepare(struct processing_module *mod,
sourceb = list_first_item(&dev->bsource_list, struct comp_buffer, sink_list);
sinkb = list_first_item(&dev->bsink_list, struct comp_buffer, source_list);

multiband_drc_set_alignment(&sourceb->stream, &sinkb->stream);

/* get source data format */
cd->source_format = audio_stream_get_frm_fmt(&sourceb->stream);
channels = audio_stream_get_channels(&sourceb->stream);
Expand Down
8 changes: 0 additions & 8 deletions src/audio/mux/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ static int mux_prepare(struct processing_module *mod,
struct comp_data *cd = module_get_private_data(mod);
struct list_item *blist;
struct comp_buffer *source;
struct comp_buffer *sink;
struct sof_mux_config *config;
size_t blob_size;
int state;
Expand Down Expand Up @@ -414,19 +413,12 @@ static int mux_prepare(struct processing_module *mod,
list_for_item(blist, &dev->bsource_list) {
source = container_of(blist, struct comp_buffer, sink_list);
state = source->source->state;
audio_stream_init_alignment_constants(1, 1, &source->stream);

/* only prepare downstream if we have no active sources */
if (state == COMP_STATE_PAUSED || state == COMP_STATE_ACTIVE)
return PPL_STATUS_PATH_STOP;
}

/* set sink align to 1 byte, 1 frame */
list_for_item(blist, &dev->bsink_list) {
sink = container_of(blist, struct comp_buffer, source_list);
audio_stream_init_alignment_constants(1, 1, &sink->stream);
}

/* prepare downstream */
return 0;
}
Expand Down
12 changes: 1 addition & 11 deletions src/audio/volume/volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,6 @@ static void volume_set_alignment(struct audio_stream *source,
struct audio_stream *sink)
{
#if XCHAL_HAVE_HIFI3 || XCHAL_HAVE_HIFI4

/* Both source and sink buffer in HiFi 3 or HiFi4 processing version,
* xtensa intrinsics ask for 8-byte aligned. 5.1 format SSE audio
* requires 16-byte aligned.
Expand All @@ -633,18 +632,9 @@ static void volume_set_alignment(struct audio_stream *source,
/*There is no limit for frame number, so both source and sink set it to be 1*/
const uint32_t frame_align_req = 1;

#else

/* Since the generic version process signal sample by sample, so there is no
* limit for it, then set the byte_align and frame_align_req to be 1.
*/
const uint32_t byte_align = 1;
const uint32_t frame_align_req = 1;

#endif

audio_stream_init_alignment_constants(byte_align, frame_align_req, source);
audio_stream_init_alignment_constants(byte_align, frame_align_req, sink);
#endif
}

/**
Expand Down

0 comments on commit bc43097

Please sign in to comment.