Skip to content

audio: src: use size_t for processing counts and unsigned channel counts - #11338

Open
softwarecki wants to merge 3 commits into
thesofproject:mainfrom
softwarecki:p20-src
Open

softwarecki wants to merge 3 commits into
thesofproject:mainfrom
softwarecki:p20-src

Conversation

@softwarecki

Copy link
Copy Markdown
Collaborator

Convert stream-boundary counts, polyphase sample and address offset counters, and per-stage block sizes to size_t. Use unsigned channel counts throughout setup and processing while retaining signed byte strides for the Xtensa intrinsics and keeping filter geometry constants as int.

Convert the source and sink frame, sample container and byte counters
exchanged with the sink/source API to size_t. The internal polyphase
block accounting is left unchanged.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Store the channel count as unsigned int across the parameter and stage
structures and the setup path, matching the stream channel count type.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Convert the word, sample and address offset counters in the polyphase
kernels, and the per-stage block sizes, to size_t. The signed byte
strides used by the Xtensa intrinsics and the filter geometry
constants stay int.

Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open issues
What changed in this PR

Updates SRC processing and configuration types to use size_t for counts/sizes and unsigned for channel counts, reducing signed overflow risk and improving type correctness across SRC implementations.

Changes:

  • Converted block sizes, tap/count variables, and frame counters from int to size_t in generic and HiFi implementations.
  • Updated channel count fields to unsigned int in shared SRC structs and several call sites.
  • Adjusted logging format specifier for size_t (%zu) where updated types are logged.
File Description
src/​audio/​src/​src_hifi5.c Switches internal loop/counter variables and derived block sizes to size_t.
src/​audio/​src/​src_hifi4.c Mirrors HiFi5 changes for size/count variables to size_t.
src/​audio/​src/​src_hifi3.c Updates loop/counter variables and derived sizes to size_t.
src/​audio/​src/​src_hifi2ep.c Uses size_t for counters and derived block sizes in HiFi2EP path.
src/​audio/​src/​src_generic.c Converts FIR tap/count math and stage counters to size_t.
src/​audio/​src/​src_common.h Changes shared SRC struct fields (blk_in/out, nch, frames/bytes) to size_t/unsigned.
src/​audio/​src/​src_common.c Propagates size_t/unsigned into runtime sizing, fragment sizing, and debug logging.

Review effort: Lite

Comment on lines +245 to +249
size_t avail_b = source_get_data_available(source);
size_t free_b = sink_get_free_size(sink);
size_t sz = cd->sample_container_bytes;
size_t source_frag_size = cd->param.blk_in * source_get_frame_bytes(source);
size_t sink_frag_size = cd->param.blk_out * sink_get_frame_bytes(sink);
Comment on lines +232 to +238
const size_t nch_x_odm = cfg->odm * nch;
const size_t blk_in_words = nch * cfg->blk_in;
const size_t blk_out_words = nch * cfg->num_of_subfilters;
const size_t rewind = nch * (cfg->blk_in + (cfg->num_of_subfilters - 1) * cfg->idm);
const size_t nch_x_idm = nch * cfg->idm;
const size_t fir_size = fir->fir_delay_size * sizeof(int32_t);
const int taps_x_nch = cfg->subfilter_length * nch;
const size_t taps_x_nch = cfg->subfilter_length * nch;
Comment thread src/audio/src/src_hifi5.c
Comment on lines 353 to +356
const int nch = s->nch;
const int nch_x_odm = cfg->odm * nch;
const int blk_in_words = nch * cfg->blk_in;
const int blk_out_words = nch * cfg->num_of_subfilters;
const size_t nch_x_odm = cfg->odm * nch;
const size_t blk_in_words = nch * cfg->blk_in;
const size_t blk_out_words = nch * cfg->num_of_subfilters;
Comment on lines +25 to 26
const size_t taps_x_nch,
const int shift, const int nch)
@intel-sofci

Copy link
Copy Markdown

PR 11338: test results

Run date: 2026-10-22 21:31 UTC

Tested commit: cd38b54024e920fb0689fbe70f967b23ae90781d

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants