Skip to content

Commit

Permalink
Audio: Copier: Use SOF_DIV_ROUND_UP() instead of ROUND_UP()
Browse files Browse the repository at this point in the history
The ROUND_UP() is provided by Zephyr headers and can't be used
in testbench (IPC4) build.

The ROUND_UP is defined in util.h as:

"#define ROUND_UP(x, align)                                   \
	(((unsigned long)(x) + ((unsigned long)(align) - 1)) & \
	 ~((unsigned long)(align) - 1))"

and SOF_DIV_ROUND_UP in common.h as:

"#define SOF_DIV_ROUND_UP(val, div) (((val) + (div) - 1) / (div))"

The round up and divide by shift in original code can be replaced
with the rounding divide macro from SOF. There is no code speed
impact from division since it's done in C pre-processor.

The MAX_GAIN_COEFFS_CNT is much less than default 32 bit integer
range, so these compute the same.

Signed-off-by: Seppo Ingalsuo <[email protected]>
  • Loading branch information
singalsu authored and kv2019i committed Oct 17, 2024
1 parent 735cf0a commit 5ee1757
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/audio/copier/copier_gain.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ enum copier_gain_envelope_dir {
struct copier_gain_params {
#if SOF_USE_HIFI(3, COPIER) || SOF_USE_HIFI(4, COPIER) || SOF_USE_HIFI(5, COPIER)
/**< Input gain coefficients in Q10 format */
ae_int16x4 gain_coeffs[ROUND_UP(MAX_GAIN_COEFFS_CNT, 4) >> 2];
ae_int16x4 gain_coeffs[SOF_DIV_ROUND_UP(MAX_GAIN_COEFFS_CNT, 4)];
/**< Step for fade-in lower precision */
ae_f16x4 step_f16;
/**< Initial gain depending on the number of channels */
Expand Down

0 comments on commit 5ee1757

Please sign in to comment.