Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/silk
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2018-02-16 20:36:44 +0300
committerJean-Marc Valin <jmvalin@jmvalin.ca>2018-02-18 10:17:07 +0300
commit4b6af2da93379da6ea4778889d678ee6cea964d8 (patch)
tree7f9b7436148fe8cf2fe7731a9e8bbc2edc34829e /silk
parent4503261d0f055a4a2ba7bd1c05035a5759912857 (diff)
Fixes integer overflow in SILK VAD for 10-ms frames
Reported by Chandrakala Madhira on the mailing list
Diffstat (limited to 'silk')
-rw-r--r--silk/VAD.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/silk/VAD.c b/silk/VAD.c
index 0a782af2..8b929654 100644
--- a/silk/VAD.c
+++ b/silk/VAD.c
@@ -252,15 +252,14 @@ opus_int silk_VAD_GetSA_Q8_c( /* O Return v
speech_nrg += ( b + 1 ) * silk_RSHIFT( Xnrg[ b ] - psSilk_VAD->NL[ b ], 4 );
}
+ if( psEncC->frame_length == 20 * psEncC->fs_kHz ) {
+ speech_nrg = silk_RSHIFT32( speech_nrg, 1 );
+ }
/* Power scaling */
if( speech_nrg <= 0 ) {
SA_Q15 = silk_RSHIFT( SA_Q15, 1 );
- } else if( speech_nrg < 32768 ) {
- if( psEncC->frame_length == 10 * psEncC->fs_kHz ) {
- speech_nrg = silk_LSHIFT_SAT32( speech_nrg, 16 );
- } else {
- speech_nrg = silk_LSHIFT_SAT32( speech_nrg, 15 );
- }
+ } else if( speech_nrg < 16384 ) {
+ speech_nrg = silk_LSHIFT32( speech_nrg, 16 );
/* square-root */
speech_nrg = silk_SQRT_APPROX( speech_nrg );