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

Liam Girdwood liam.r.girdwood at linux.intel.com
Tue Feb 6 17:11:32 CET 2018


On Tue, 2018-01-30 at 17:12 +0200, Seppo Ingalsuo wrote:
> 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))

Apllied.

Thanks

Liam


More information about the Sound-open-firmware mailing list