diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2012-04-25 04:45:04 +0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2012-04-25 04:45:04 +0400 |
commit | 780fbc91f1938386af302125914e7a4684dfc5b6 (patch) | |
tree | c56d459a48cd0870570bd7e9b5e839c355b160d3 /silk/fixed | |
parent | 3af4aa78490505ed04d493dc058cedb189262e2f (diff) |
Fixes a (harmless) numerical overflow in noise_shape_analysis_FIX.c
Actual behaviour was correct on most architectures and breaking that
code would have required a particularly smart compiler.
Diffstat (limited to 'silk/fixed')
-rw-r--r-- | silk/fixed/noise_shape_analysis_FIX.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/silk/fixed/noise_shape_analysis_FIX.c b/silk/fixed/noise_shape_analysis_FIX.c index f31d4efe..b0e35deb 100644 --- a/silk/fixed/noise_shape_analysis_FIX.c +++ b/silk/fixed/noise_shape_analysis_FIX.c @@ -311,9 +311,10 @@ void silk_noise_shape_analysis_FIX( /* Adjust gain for warping */ gain_mult_Q16 = warped_gain( AR2_Q24, warping_Q16, psEnc->sCmn.shapingLPCOrder ); silk_assert( psEncCtrl->Gains_Q16[ k ] >= 0 ); - psEncCtrl->Gains_Q16[ k ] = silk_SMULWW( psEncCtrl->Gains_Q16[ k ], gain_mult_Q16 ); - if( psEncCtrl->Gains_Q16[ k ] < 0 ) { - psEncCtrl->Gains_Q16[ k ] = silk_int32_MAX; + if ( silk_SMULWW( silk_RSHIFT_ROUND( psEncCtrl->Gains_Q16[ k ], 1 ), gain_mult_Q16 ) >= ( silk_int32_MAX >> 1 ) ) { + psEncCtrl->Gains_Q16[ k ] = silk_int32_MAX; + } else { + psEncCtrl->Gains_Q16[ k ] = silk_SMULWW( psEncCtrl->Gains_Q16[ k ], gain_mult_Q16 ); } } |