Skip to content

Commit

Permalink
Audio: DRC: Change DRC to use lookup table based sine function
Browse files Browse the repository at this point in the history
This change saves about 13 MPCS while the .bss RAM usage increases
by 2 kB.

TODO: A 16 bit sine function should cope with smaller lookup
and be friendlier for cache.

Signed-off-by: Seppo Ingalsuo <[email protected]>
  • Loading branch information
singalsu committed Nov 17, 2023
1 parent e4de096 commit 8bc42e4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/audio/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ config COMP_CROSSOVER

config COMP_DRC
bool "Dynamic Range Compressor component"
select LUT_TRIG_FIXED
select CORDIC_FIXED
select NUMBERS_NORM
select MATH_DECIBELS
Expand Down
9 changes: 3 additions & 6 deletions src/include/sof/audio/drc/drc_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <sof/audio/drc/drc_plat_conf.h>
#include <sof/audio/format.h>
#include <sof/math/numbers.h>
#include <sof/math/lut_trig.h>
#include <sof/math/trig.h>

/* Unmark this define to use cordic arc sine implementation. */
Expand Down Expand Up @@ -59,9 +60,7 @@ static inline int32_t drc_sin_fixed(int32_t x)
{
const int32_t lshift = drc_get_lshift(30, 30, 28);
int32_t denorm_x = drc_mult_lshift(x, PI_OVER_TWO_Q30, lshift);
int32_t sin_val = sin_fixed_16b(denorm_x);

return sin_val << 16;
return sofm_lut_sin_fixed_32b(denorm_x);
}

#ifdef DRC_USE_CORDIC_ASIN
Expand All @@ -87,9 +86,7 @@ static inline int32_t drc_asin_fixed(int32_t x)
static inline int32_t drc_sin_fixed(int32_t x)
{
const int32_t PI_OVER_TWO = Q_CONVERT_FLOAT(1.57079632679489661923, 30);
int32_t sin_val = sin_fixed_16b(Q_MULTSR_32X32((int64_t)x, PI_OVER_TWO, 30, 30, 28));

return sin_val << 16;
return sofm_lut_sin_fixed_32b(Q_MULTSR_32X32((int64_t)x, PI_OVER_TWO, 30, 30, 28));
}

#ifdef DRC_USE_CORDIC_ASIN
Expand Down

0 comments on commit 8bc42e4

Please sign in to comment.