Fix SATURATE_LEFT_SHIFT_ALT() since it returned 0x80000000 in certain cases

Bug: 112661911
Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc
Change-Id: I16e522c975ad45ff8d47d4cabe44f1f2bf95b73b
This commit is contained in:
Fraunhofer IIS FDK 2018-06-29 16:31:23 +02:00 committed by Jean-Michel Trivi
parent f59fd73d44
commit edbb4b0a14
1 changed files with 5 additions and 5 deletions

View File

@ -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