From 5f2de711a0f8be5d564fc8bf81599d5e439d56c6 Mon Sep 17 00:00:00 2001 From: Pin-chih Lin Date: Thu, 4 Feb 2021 17:45:50 +0800 Subject: [PATCH] sof: drc: fix drc_pow_fixed function The proposed calculation doesn't take negative or zero input-x into consideration, and we also don't need such use cases. Just return 0 for those input-x. Signed-off-by: Pin-chih Lin --- src/audio/drc/drc_math_generic.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/audio/drc/drc_math_generic.c b/src/audio/drc/drc_math_generic.c index 3bf5989bc..47f23c3be 100644 --- a/src/audio/drc/drc_math_generic.c +++ b/src/audio/drc/drc_math_generic.c @@ -183,6 +183,10 @@ inline int32_t drc_asin_fixed(int32_t x) */ inline int32_t drc_pow_fixed(int32_t x, int32_t y) { + /* Negative or zero input x is not supported, just return 0. */ + if (x <= 0) + return 0; + /* x^y = expf(y * log(x)) */ return exp_fixed(q_mult(y, drc_log_fixed(x), 30, 26, 27)); }