From edbb4b0a14f6ba252592a34cb95f2c9ace89b80e Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Fri, 29 Jun 2018 16:31:23 +0200 Subject: [PATCH] Fix SATURATE_LEFT_SHIFT_ALT() since it returned 0x80000000 in certain cases Bug: 112661911 Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: I16e522c975ad45ff8d47d4cabe44f1f2bf95b73b --- libFDK/include/scale.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libFDK/include/scale.h b/libFDK/include/scale.h index 07bd3af..30fa089 100644 --- a/libFDK/include/scale.h +++ b/libFDK/include/scale.h @@ -268,11 +268,11 @@ inline void scaleValueInPlace(FIXP_DBL *value, /*!< Value */ * to avoid problems when inverting the sign of the result. */ #ifndef SATURATE_LEFT_SHIFT_ALT -#define SATURATE_LEFT_SHIFT_ALT(src, scale, dBits) \ - (((LONG)(src) > ((LONG)(((1U) << ((dBits)-1)) - 1) >> (scale))) \ - ? (LONG)(((1U) << ((dBits)-1)) - 1) \ - : ((LONG)(src) < ~((LONG)(((1U) << ((dBits)-1)) - 2) >> (scale))) \ - ? ~((LONG)(((1U) << ((dBits)-1)) - 2)) \ +#define SATURATE_LEFT_SHIFT_ALT(src, scale, dBits) \ + (((LONG)(src) > ((LONG)(((1U) << ((dBits)-1)) - 1) >> (scale))) \ + ? (LONG)(((1U) << ((dBits)-1)) - 1) \ + : ((LONG)(src) <= ~((LONG)(((1U) << ((dBits)-1)) - 1) >> (scale))) \ + ? ~((LONG)(((1U) << ((dBits)-1)) - 2)) \ : ((LONG)(src) << (scale))) #endif