aboutsummaryrefslogtreecommitdiffstats
path: root/libFDK
diff options
context:
space:
mode:
authorFraunhofer IIS FDK <audio-fdk@iis.fraunhofer.de>2019-11-13 16:08:24 +0100
committerJean-Michel Trivi <jmtrivi@google.com>2020-01-16 12:15:04 -0800
commit1020e48d6e76506ac85a7678fe950ce7245d3aea (patch)
treed8d44cea21a91be5298acac5dd6439d5cea71b90 /libFDK
parente3b9058b8b72ccc890014c597b25a7cedfd555e3 (diff)
downloadfdk-aac-1020e48d6e76506ac85a7678fe950ce7245d3aea.tar.gz
fdk-aac-1020e48d6e76506ac85a7678fe950ce7245d3aea.tar.bz2
fdk-aac-1020e48d6e76506ac85a7678fe950ce7245d3aea.zip
Fix IsLessThan() function for certain edge cases.
Bug: 146936613 Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: Idbec38c1df01bd7a6a48ac4b6e5673c30627fc73
Diffstat (limited to 'libFDK')
-rw-r--r--libFDK/include/fixpoint_math.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/libFDK/include/fixpoint_math.h b/libFDK/include/fixpoint_math.h
index 93aea19..373eec1 100644
--- a/libFDK/include/fixpoint_math.h
+++ b/libFDK/include/fixpoint_math.h
@@ -171,6 +171,19 @@ extern const FIXP_DBL invSqrtTab[SQRT_VALUES];
* \return non-zero if (a_m*2^a_e) < (b_m*2^b_e), 0 otherwise
*/
FDK_INLINE INT fIsLessThan(FIXP_DBL a_m, INT a_e, FIXP_DBL b_m, INT b_e) {
+ INT n;
+
+ n = fixnorm_D(a_m);
+ a_m <<= n;
+ a_e -= n;
+
+ n = fixnorm_D(b_m);
+ b_m <<= n;
+ b_e -= n;
+
+ if (a_m == (FIXP_DBL)0) a_e = b_e;
+ if (b_m == (FIXP_DBL)0) b_e = a_e;
+
if (a_e > b_e) {
return ((b_m >> fMin(a_e - b_e, DFRACT_BITS - 1)) > a_m);
} else {
@@ -179,6 +192,19 @@ FDK_INLINE INT fIsLessThan(FIXP_DBL a_m, INT a_e, FIXP_DBL b_m, INT b_e) {
}
FDK_INLINE INT fIsLessThan(FIXP_SGL a_m, INT a_e, FIXP_SGL b_m, INT b_e) {
+ INT n;
+
+ n = fixnorm_S(a_m);
+ a_m <<= n;
+ a_e -= n;
+
+ n = fixnorm_S(b_m);
+ b_m <<= n;
+ b_e -= n;
+
+ if (a_m == (FIXP_SGL)0) a_e = b_e;
+ if (b_m == (FIXP_SGL)0) b_e = a_e;
+
if (a_e > b_e) {
return ((b_m >> fMin(a_e - b_e, FRACT_BITS - 1)) > a_m);
} else {