From 6c7c7f3576e3c2f2aad864e1da0404b21c33b492 Mon Sep 17 00:00:00 2001 From: Johan Pascal Date: Thu, 17 Sep 2020 23:28:20 +0200 Subject: [PATCH] Fix infinite loop bug in VAD Thanks Frederic Boiteux --- src/vad.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vad.c b/src/vad.c index 91bb400..b985df4 100644 --- a/src/vad.c +++ b/src/vad.c @@ -187,7 +187,7 @@ uint8_t bcg729_vad(bcg729VADChannelContextStruct *VADChannelContext, word32_t re /*** parameters extraction B3.1 ***/ /* full band energy Ef (eq B1) = 10*log10(autoCorrelationCoefficient[0]/240), we compute Ef/10 in Q11 */ - acc = SUB32(g729Log2_Q0Q16(autoCorrelationCoefficients[0]), (((int32_t)autoCorrelationCoefficientsScale)<<16)); /* acc = log2(R(0)) in Q16*/ + acc = SUB32(g729Log2_Q0Q16(autoCorrelationCoefficients[0]+1), (((int32_t)autoCorrelationCoefficientsScale)<<16)); /* acc = log2(R(0)) in Q16 +1 is to avoid sending 0 to the log function */ acc = SHR32(SUB32(acc, LOG2_240_Q16),1); /* acc = log2(R(0)/240) in Q15 */ acc = MULT16_32_Q15(INV_LOG2_10_Q15, acc); /* acc Ef in Q15 */ Ef = (word16_t)(PSHR(acc,4)); @@ -200,6 +200,9 @@ uint8_t bcg729_vad(bcg729VADChannelContextStruct *VADChannelContext, word32_t re for (i=1; i