1
0
mirror of https://github.com/mstorsjo/fdk-aac.git synced 2025-02-15 19:00:47 +01:00

Fix IsLessThan() function for certain edge cases.

Bug: 146936613
Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc
Change-Id: Idbec38c1df01bd7a6a48ac4b6e5673c30627fc73
This commit is contained in:
Fraunhofer IIS FDK 2019-11-13 16:08:24 +01:00 committed by Jean-Michel Trivi
parent e3b9058b8b
commit 1020e48d6e

View File

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