sof: drc: fix drc_sin_fixed function

drc_sin_fixed() utilized sin_fixed() while its input range is
non-negative. This commit fixes drc_siz_fixed() for negative input by
using ABS(input) to sin_fixed() and then inverting the output sign.

Signed-off-by: Pin-chih Lin <johnylin@google.com>
This commit is contained in:
Pin-chih Lin 2021-01-11 14:42:41 +08:00 committed by Liam Girdwood
parent d5840a9200
commit 9b0209ba8b
1 changed files with 3 additions and 1 deletions

View File

@ -112,7 +112,9 @@ inline int32_t drc_sin_fixed(int32_t x)
{ {
const int32_t PI_OVER_TWO = Q_CONVERT_FLOAT(1.57079632679489661923f, 30); const int32_t PI_OVER_TWO = Q_CONVERT_FLOAT(1.57079632679489661923f, 30);
return sin_fixed(q_mult(x, PI_OVER_TWO, 30, 30, 28)); /* input range of sin_fixed() is non-negative */
int32_t abs_sin_val = sin_fixed(q_mult(ABS(x), PI_OVER_TWO, 30, 30, 28));
return SGN(x) < 0 ? -abs_sin_val : abs_sin_val;
} }
/* /*