Fixes the transient detector on silence
authorJean-Marc Valin <jmvalin@jmvalin.ca>
Thu, 3 Dec 2015 19:12:01 +0000 (14:12 -0500)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Fri, 4 Dec 2015 18:45:57 +0000 (13:45 -0500)
Previously silence would cause the divide approximation on 0/0 to return a
very large value, which would be interpreted as a transient

celt/celt_encoder.c

index 1c9dbcb..1bb4680 100644 (file)
@@ -343,9 +343,9 @@ static int transient_analysis(const opus_val32 * OPUS_RESTRICT in, int len, int
       {
          int id;
 #ifdef FIXED_POINT
-         id = IMAX(0,IMIN(127,MULT16_32_Q15(tmp[i],norm))); /* Do not round to nearest */
+         id = MAX32(0,MIN32(127,MULT16_32_Q15(tmp[i]+EPSILON,norm))); /* Do not round to nearest */
 #else
-         id = IMAX(0,IMIN(127,(int)floor(64*norm*tmp[i]))); /* Do not round to nearest */
+         id = (int)MAX32(0,MIN32(127,floor(64*norm*(tmp[i]+EPSILON)))); /* Do not round to nearest */
 #endif
          unmask += inv_table[id];
       }