[Sound-open-firmware] [PATCH] Audio format: Bug fix for erroneous fractional multiplication macro

Seppo Ingalsuo seppo.ingalsuo at linux.intel.com
Tue Jan 30 16:12:39 CET 2018


Due to misplaced parentheses the computation gives half of correct
result and omits rounding. Currently this macro is not used by code
in SOF git repository. Developers who may use format.h macros should
check their code.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo at linux.intel.com>
---
 src/include/reef/audio/format.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/include/reef/audio/format.h b/src/include/reef/audio/format.h
index 8964f33..c9c23ec 100644
--- a/src/include/reef/audio/format.h
+++ b/src/include/reef/audio/format.h
@@ -85,7 +85,8 @@
 /* Fractional multiplication with shift and round
  * Note that the parameters px and py must be cast to (int64_t) if other type.
  */
-#define Q_MULTSR_32X32(px, py, qx, qy, qp) (((px) * (py) >> (((qx)+(qy)-(qp)-1) +1) >> 1))
+#define Q_MULTSR_32X32(px, py, qx, qy, qp) \
+	((((px) * (py) >> ((qx)+(qy)-(qp)-1)) + 1) >> 1)
 
 /* Saturation */
 #define SATP_INT32(x) (((x) > INT32_MAX) ? INT32_MAX : (x))
-- 
2.11.0



More information about the Sound-open-firmware mailing list