Increase headroom to avoid overflow in silk_pitch_analysis_core()
authorJean-Marc Valin <jmvalin@jmvalin.ca>
Fri, 22 Jul 2016 18:25:03 +0000 (14:25 -0400)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Fri, 22 Jul 2016 19:57:01 +0000 (15:57 -0400)
silk/fixed/pitch_analysis_core_FIX.c

index 7cd303d..03ea28d 100644 (file)
@@ -141,7 +141,7 @@ opus_int silk_pitch_analysis_core(                  /* O    Voicing estimate: 0
 
     /* Downscale input if necessary */
     silk_sum_sqr_shift( &energy, &shift, frame_unscaled, frame_length );
-    shift += 2 - silk_CLZ32( energy );        /* at least one bit headroom */
+    shift += 3 - silk_CLZ32( energy );        /* at least two bits headroom */
     ALLOC( frame_scaled, frame_length, opus_int16 );
     if( shift > 0 ) {
         shift = silk_RSHIFT( shift + 1, 1 );