summaryrefslogtreecommitdiff
path: root/thirdparty/opus/silk/VAD.c
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/opus/silk/VAD.c')
-rw-r--r--thirdparty/opus/silk/VAD.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/thirdparty/opus/silk/VAD.c b/thirdparty/opus/silk/VAD.c
index d0cda52162..0a782af2f1 100644
--- a/thirdparty/opus/silk/VAD.c
+++ b/thirdparty/opus/silk/VAD.c
@@ -101,9 +101,9 @@ opus_int silk_VAD_GetSA_Q8_c( /* O Return v
/* Safety checks */
silk_assert( VAD_N_BANDS == 4 );
- celt_assert( MAX_FRAME_LENGTH >= psEncC->frame_length );
- celt_assert( psEncC->frame_length <= 512 );
- celt_assert( psEncC->frame_length == 8 * silk_RSHIFT( psEncC->frame_length, 3 ) );
+ silk_assert( MAX_FRAME_LENGTH >= psEncC->frame_length );
+ silk_assert( psEncC->frame_length <= 512 );
+ silk_assert( psEncC->frame_length == 8 * silk_RSHIFT( psEncC->frame_length, 3 ) );
/***********************/
/* Filter and Decimate */
@@ -252,14 +252,15 @@ 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 < 16384 ) {
- speech_nrg = silk_LSHIFT32( speech_nrg, 16 );
+ } 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 );
+ }
/* square-root */
speech_nrg = silk_SQRT_APPROX( speech_nrg );
@@ -312,8 +313,6 @@ void silk_VAD_GetNoiseLevels(
/* Initially faster smoothing */
if( psSilk_VAD->counter < 1000 ) { /* 1000 = 20 sec */
min_coef = silk_DIV32_16( silk_int16_MAX, silk_RSHIFT( psSilk_VAD->counter, 4 ) + 1 );
- /* Increment frame counter */
- psSilk_VAD->counter++;
} else {
min_coef = 0;
}
@@ -357,4 +356,7 @@ void silk_VAD_GetNoiseLevels(
/* Store as part of state */
psSilk_VAD->NL[ k ] = nl;
}
+
+ /* Increment frame counter */
+ psSilk_VAD->counter++;
}