Fixes a (harmless) float overflow in the pitch search
authorJean-Marc Valin <jmvalin@jmvalin.ca>
Tue, 8 May 2012 17:58:57 +0000 (13:58 -0400)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Tue, 8 May 2012 17:58:57 +0000 (13:58 -0400)
celt/pitch.c

index 29e4bd1..c01ea55 100644 (file)
@@ -74,6 +74,11 @@ static void find_best_pitch(opus_val32 *xcorr, opus_val16 *y, int len,
          opus_val16 num;
          opus_val32 xcorr16;
          xcorr16 = EXTRACT16(VSHR32(xcorr[i], xshift));
          opus_val16 num;
          opus_val32 xcorr16;
          xcorr16 = EXTRACT16(VSHR32(xcorr[i], xshift));
+#ifndef FIXED_POINT
+         /* Considering the range of xcorr16, this should avoid both underflows
+            and overflows (inf) when squaring xcorr16 */
+         xcorr16 *= 1e-12;
+#endif
          num = MULT16_16_Q15(xcorr16,xcorr16);
          if (MULT16_32_Q15(num,best_den[1]) > MULT16_32_Q15(best_num[1],Syy))
          {
          num = MULT16_16_Q15(xcorr16,xcorr16);
          if (MULT16_32_Q15(num,best_den[1]) > MULT16_32_Q15(best_num[1],Syy))
          {