Repository navigation
audio: src: use size_t for processing counts and unsigned channel counts - #11338
softwarecki wants to merge 3 commits into
Conversation
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>
There was a problem hiding this comment.
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
Please align these local types with the actual return types ofsource_get_data_available()/… · New These assignments store intosize_t, but most expressions are still evaluated in (signed)int… · News->nchis nowunsigned int(persrc_common.h), but it’s assigned into a signedinthere.… · New Channel count is being standardized tounsignedin the shared structs, butfir_filter_generic()… · New
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
inttosize_tin generic and HiFi implementations. - Updated channel count fields to
unsigned intin 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
| 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); |
| 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; |
| 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; |
| const size_t taps_x_nch, | ||
| const int shift, const int nch) |
PR 11338: test resultsRun date: 2026-10-22 21:31 UTC Tested commit: cd38b54024e920fb0689fbe70f967b23ae90781d |
|
@softwarecki Can you comment on the github comments? It seems this is snowballing to the filter interface - do you plan to tackle those separately...? |


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