diff options
| author | Xin Li <delphij@google.com> | 2020-08-27 10:16:06 -0700 | 
|---|---|---|
| committer | Xin Li <delphij@google.com> | 2020-08-27 10:16:06 -0700 | 
| commit | 7a0dde5d5dc4d24095c0391e7fa8297de3c7cd45 (patch) | |
| tree | 0e353968c34e8c9699663a9b252836b70847c30b /libFDK/include/fixpoint_math.h | |
| parent | 946a672b0f5b8481eb3a429f854fcb34d847d692 (diff) | |
| parent | e0624f4c05df8b171555bc8c8748ee93655f5b3e (diff) | |
| download | fdk-aac-7a0dde5d5dc4d24095c0391e7fa8297de3c7cd45.tar.gz fdk-aac-7a0dde5d5dc4d24095c0391e7fa8297de3c7cd45.tar.bz2 fdk-aac-7a0dde5d5dc4d24095c0391e7fa8297de3c7cd45.zip | |
Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507
Merged-In: I9bd31724ae68b9a0b3eb4bb5be3782359824aa1f
Change-Id: Idcdb13a8c37b0b4b5446169c3e80dfe55586bc77
Diffstat (limited to 'libFDK/include/fixpoint_math.h')
| -rw-r--r-- | libFDK/include/fixpoint_math.h | 43 | 
1 files changed, 37 insertions, 6 deletions
| diff --git a/libFDK/include/fixpoint_math.h b/libFDK/include/fixpoint_math.h index 3805892..51df4d7 100644 --- a/libFDK/include/fixpoint_math.h +++ b/libFDK/include/fixpoint_math.h @@ -1,7 +1,7 @@  /* -----------------------------------------------------------------------------  Software License for The Fraunhofer FDK AAC Codec Library for Android -© Copyright  1995 - 2018 Fraunhofer-Gesellschaft zur Förderung der angewandten +© Copyright  1995 - 2019 Fraunhofer-Gesellschaft zur Förderung der angewandten  Forschung e.V. All rights reserved.   1.    INTRODUCTION @@ -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 { @@ -545,15 +571,20 @@ inline INT fMultIceil(FIXP_DBL a, INT b) {    m = fMultNorm(a, (FIXP_DBL)b, &m_e);    if (m_e < (INT)0) { -    if (m_e > (INT)-DFRACT_BITS) { +    if (m_e > (INT) - (DFRACT_BITS - 1)) {        mi = (m >> (-m_e));        if ((LONG)m & ((1 << (-m_e)) - 1)) {          mi = mi + (FIXP_DBL)1;        }      } else { -      mi = (FIXP_DBL)1; -      if (m < (FIXP_DBL)0) { -        mi = (FIXP_DBL)0; +      if (m > (FIXP_DBL)0) { +        mi = (FIXP_DBL)1; +      } else { +        if ((m_e == -(DFRACT_BITS - 1)) && (m == (FIXP_DBL)MINVAL_DBL)) { +          mi = (FIXP_DBL)-1; +        } else { +          mi = (FIXP_DBL)0; +        }        }      }    } else { @@ -744,7 +775,7 @@ FIXP_DBL fPow(FIXP_DBL base_m, INT base_e, FIXP_DBL exp_m, INT exp_e,  /**   * \brief return (base_m * 2^base_e) ^ N - * \param base_m mantissa of the base + * \param base_m mantissa of the base. Must not be negative.   * \param base_e exponent of the base   * \param N power to be calculated of the base   * \param result_e pointer to a INT where the exponent of the result will be | 
