xmos / lib_src

Sample rate conversion library
Other
16 stars 19 forks source link

Stack sizes for ASRC and SSRC in tests/examples seem incorrect. #101

Open xross opened 1 year ago

xross commented 1 year ago

Stack sizes set as, for example:

int iSSRCStack[SRC_CHANNELS_PER_INSTANCE][SSRC_STACK_LENGTH_MULT * SRC_N_IN_SAMPLES]; // Buffers between processing stages

e.g. https://github.com/xmos/lib_src/blob/693ae0f301587b97a47d5690e7658a601b3fefb8/tests/ssrc_test/dut/ssrc_test.xc#L40

Based on

https://github.com/xmos/lib_src/blob/693ae0f301587b97a47d5690e7658a601b3fefb8/lib_src/src/multirate_hifi/ssrc/src_mrhf_ssrc.h#L34

I think they should just be:

int iSSRCStack[SRC_CHANNELS_PER_INSTANCE][SSRC_STACK_LENGTH_MULT]; // Buffers between processing stages

@ed-xmos any thoughts? I wonder if this crept in when adding support for multiple instances. Its unclear to me why each instance would need stack space related to the total channel count, not just the instance channel count.

xross commented 1 year ago

Following from this,

https://github.com/xmos/lib_src/blob/693ae0f301587b97a47d5690e7658a601b3fefb8/tests/ssrc_test/dut/ssrc_test.xc#L14

Should be set to CHANNELS_PER_INSTANCE as a separate define should be used for total SRC channel count.

ed-xmos commented 12 months ago

Stack sizes set as, for example:

int iSSRCStack[SRC_CHANNELS_PER_INSTANCE][SSRC_STACK_LENGTH_MULT * SRC_N_IN_SAMPLES]; // Buffers between processing stages

e.g.

https://github.com/xmos/lib_src/blob/693ae0f301587b97a47d5690e7658a601b3fefb8/tests/ssrc_test/dut/ssrc_test.xc#L40

Based on

https://github.com/xmos/lib_src/blob/693ae0f301587b97a47d5690e7658a601b3fefb8/lib_src/src/multirate_hifi/ssrc/src_mrhf_ssrc.h#L34

I think they should just be:

int iSSRCStack[SRC_CHANNELS_PER_INSTANCE][SSRC_STACK_LENGTH_MULT]; // Buffers between processing stages

@ed-xmos any thoughts? I wonder if this crept in when adding support for multiple instances. Its unclear to me why each instance would need stack space related to the total channel count, not just the instance channel count.

I think you are right. Making the buffers too big silently cost some memory without causing any logical problems.