From f02ba9be546fcc16df1d5d78b36e383048d9f0b1 Mon Sep 17 00:00:00 2001 From: "bjornv@webrtc.org" Date: Wed, 15 Oct 2014 11:16:48 +0000 Subject: [PATCH] audio_processing/agc: Replaced macro WEBRTC_SPL_RSHIFT_W32 with >> Affects AGC only. BUG=3348,3353 TESTED=locally on linux and trybots R=kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/31709004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7455 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../modules/audio_processing/agc/analog_agc.c | 63 +++++++--------- .../audio_processing/agc/digital_agc.c | 71 +++++++++---------- 2 files changed, 59 insertions(+), 75 deletions(-) diff --git a/webrtc/modules/audio_processing/agc/analog_agc.c b/webrtc/modules/audio_processing/agc/analog_agc.c index 93fe987e3..127d455b8 100644 --- a/webrtc/modules/audio_processing/agc/analog_agc.c +++ b/webrtc/modules/audio_processing/agc/analog_agc.c @@ -228,8 +228,7 @@ int WebRtcAgc_AddMic(void *state, int16_t *in_mic, int16_t *in_mic_H, for (i = 0; i < samples; i++) { // For lower band - tmp32 = WEBRTC_SPL_MUL_16_U16(in_mic[i], gain); - sample = WEBRTC_SPL_RSHIFT_W32(tmp32, 12); + sample = (in_mic[i] * gain) >> 12; if (sample > 32767) { in_mic[i] = 32767; @@ -244,8 +243,7 @@ int WebRtcAgc_AddMic(void *state, int16_t *in_mic, int16_t *in_mic_H, // For higher band if (stt->fs == 32000) { - tmp32 = WEBRTC_SPL_MUL_16_U16(in_mic_H[i], gain); - sample = WEBRTC_SPL_RSHIFT_W32(tmp32, 12); + sample = (in_mic_H[i] * gain) >> 12; if (sample > 32767) { in_mic_H[i] = 32767; @@ -482,7 +480,7 @@ int WebRtcAgc_VirtualMic(void *agcInst, int16_t *in_near, int16_t *in_near_H, } for (ii = 0; ii < samples; ii++) { - tmpFlt = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_U16(in_near[ii], gain), 10); + tmpFlt = (in_near[ii] * gain) >> 10; if (tmpFlt > 32767) { tmpFlt = 32767; @@ -510,8 +508,7 @@ int WebRtcAgc_VirtualMic(void *agcInst, int16_t *in_near, int16_t *in_near_H, in_near[ii] = (int16_t)tmpFlt; if (stt->fs == 32000) { - tmpFlt = WEBRTC_SPL_MUL_16_U16(in_near_H[ii], gain); - tmpFlt = WEBRTC_SPL_RSHIFT_W32(tmpFlt, 10); + tmpFlt = (in_near_H[ii] * gain) >> 10; if (tmpFlt > 32767) { tmpFlt = 32767; @@ -526,7 +523,7 @@ int WebRtcAgc_VirtualMic(void *agcInst, int16_t *in_near, int16_t *in_near_H, /* Set the level we (finally) used */ stt->micGainIdx = gainIdx; // *micLevelOut = stt->micGainIdx; - *micLevelOut = WEBRTC_SPL_RSHIFT_W32(stt->micGainIdx, stt->scale); + *micLevelOut = stt->micGainIdx >> stt->scale; /* Add to Mic as if it was the output from a true microphone */ if (WebRtcAgc_AddMic(agcInst, in_near, in_near_H, samples) != 0) { @@ -594,7 +591,7 @@ void WebRtcAgc_SaturationCtrl(Agc_t *stt, uint8_t *saturated, int32_t *env) /* Check if the signal is saturated */ for (i = 0; i < 10; i++) { - tmpW16 = (int16_t)WEBRTC_SPL_RSHIFT_W32(env[i], 20); + tmpW16 = (int16_t)(env[i] >> 20); if (tmpW16 > 875) { stt->envSum += tmpW16; @@ -645,12 +642,11 @@ void WebRtcAgc_ZeroCtrl(Agc_t *stt, int32_t *inMicLevel, int32_t *env) stt->msZero = 0; /* Increase microphone level only if it's less than 50% */ - midVal = WEBRTC_SPL_RSHIFT_W32(stt->maxAnalog + stt->minLevel + 1, 1); + midVal = (stt->maxAnalog + stt->minLevel + 1) / 2; if (*inMicLevel < midVal) { /* *inMicLevel *= 1.1; */ - tmp32 = 1126 * *inMicLevel; - *inMicLevel = WEBRTC_SPL_RSHIFT_W32(tmp32, 10); + *inMicLevel = (1126 * *inMicLevel) >> 10; /* Reduces risk of a muted mic repeatedly triggering excessive levels due * to zero signal detection. */ *inMicLevel = WEBRTC_SPL_MIN(*inMicLevel, stt->zeroCtrlMax); @@ -702,7 +698,7 @@ void WebRtcAgc_SpeakerInactiveCtrl(Agc_t *stt) /* stt->vadThreshold = (31 * stt->vadThreshold + vadThresh) / 32; */ tmp32 = (int32_t)vadThresh; tmp32 += WEBRTC_SPL_MUL_16_16((int16_t)31, stt->vadThreshold); - stt->vadThreshold = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32, 5); + stt->vadThreshold = (int16_t)(tmp32 >> 5); } } @@ -793,7 +789,7 @@ int32_t WebRtcAgc_ProcessAnalog(void *state, int32_t inMicLevel, { int32_t tmpVol; stt->firstCall = 1; - tmp32 = WEBRTC_SPL_RSHIFT_W32((stt->maxLevel - stt->minLevel) * (int32_t)51, 9); + tmp32 = ((stt->maxLevel - stt->minLevel) * 51) >> 9; tmpVol = (stt->minLevel + tmp32); /* If the mic level is very low at start, increase it! */ @@ -813,7 +809,7 @@ int32_t WebRtcAgc_ProcessAnalog(void *state, int32_t inMicLevel, /* If the mic level was manually changed to a very low value raise it! */ if ((inMicLevelTmp != stt->micVol) && (inMicLevelTmp < stt->minOutput)) { - tmp32 = WEBRTC_SPL_RSHIFT_W32((stt->maxLevel - stt->minLevel) * (int32_t)51, 9); + tmp32 = ((stt->maxLevel - stt->minLevel) * 51) >> 9; inMicLevelTmp = (stt->minLevel + tmp32); stt->micVol = inMicLevelTmp; #ifdef MIC_LEVEL_FEEDBACK @@ -935,7 +931,7 @@ int32_t WebRtcAgc_ProcessAnalog(void *state, int32_t inMicLevel, Rxx16w32 = stt->Rxx16w32_array[0][i]; /* Rxx160w32 in Q(-7) */ - tmp32 = WEBRTC_SPL_RSHIFT_W32(Rxx16w32 - stt->Rxx16_vectorw32[stt->Rxx16pos], 3); + tmp32 = (Rxx16w32 - stt->Rxx16_vectorw32[stt->Rxx16pos]) >> 3; stt->Rxx160w32 = stt->Rxx160w32 + tmp32; stt->Rxx16_vectorw32[stt->Rxx16pos] = Rxx16w32; @@ -947,7 +943,7 @@ int32_t WebRtcAgc_ProcessAnalog(void *state, int32_t inMicLevel, } /* Rxx16_LPw32 in Q(-4) */ - tmp32 = WEBRTC_SPL_RSHIFT_W32(Rxx16w32 - stt->Rxx16_LPw32, kAlphaShortTerm); + tmp32 = (Rxx16w32 - stt->Rxx16_LPw32) >> kAlphaShortTerm; stt->Rxx16_LPw32 = (stt->Rxx16_LPw32) + tmp32; if (vadLogRatio > stt->vadThreshold) @@ -969,11 +965,11 @@ int32_t WebRtcAgc_ProcessAnalog(void *state, int32_t inMicLevel, } else if (stt->activeSpeech == 250) { stt->activeSpeech += 2; - tmp32 = WEBRTC_SPL_RSHIFT_W32(stt->Rxx16_LPw32Max, 3); + tmp32 = stt->Rxx16_LPw32Max >> 3; stt->Rxx160_LPw32 = tmp32 * RXX_BUFFER_LEN; } - tmp32 = WEBRTC_SPL_RSHIFT_W32(stt->Rxx160w32 - stt->Rxx160_LPw32, kAlphaLongTerm); + tmp32 = (stt->Rxx160w32 - stt->Rxx160_LPw32) >> kAlphaLongTerm; stt->Rxx160_LPw32 = stt->Rxx160_LPw32 + tmp32; if (stt->Rxx160_LPw32 > stt->upperSecondaryLimit) @@ -988,15 +984,13 @@ int32_t WebRtcAgc_ProcessAnalog(void *state, int32_t inMicLevel, /* Lower the recording level */ /* Multiply by 0.828125 which corresponds to decreasing ~0.8dB */ - tmp32 = WEBRTC_SPL_RSHIFT_W32(stt->Rxx160_LPw32, 6); + tmp32 = stt->Rxx160_LPw32 >> 6; stt->Rxx160_LPw32 = tmp32 * 53; /* Reduce the max gain to avoid excessive oscillation * (but never drop below the maximum analog level). - * stt->maxLevel = (15 * stt->maxLevel + stt->micVol) / 16; */ - tmp32 = (15 * stt->maxLevel) + stt->micVol; - stt->maxLevel = WEBRTC_SPL_RSHIFT_W32(tmp32, 4); + stt->maxLevel = (15 * stt->maxLevel + stt->micVol) / 16; stt->maxLevel = WEBRTC_SPL_MAX(stt->maxLevel, stt->maxAnalog); stt->zeroCtrlMax = stt->micVol; @@ -1039,15 +1033,12 @@ int32_t WebRtcAgc_ProcessAnalog(void *state, int32_t inMicLevel, /* Lower the recording level */ stt->msTooHigh = 0; /* Multiply by 0.828125 which corresponds to decreasing ~0.8dB */ - tmp32 = WEBRTC_SPL_RSHIFT_W32(stt->Rxx160_LPw32, 6); - stt->Rxx160_LPw32 = tmp32 * 53; + stt->Rxx160_LPw32 = (stt->Rxx160_LPw32 / 64) * 53; /* Reduce the max gain to avoid excessive oscillation * (but never drop below the maximum analog level). - * stt->maxLevel = (15 * stt->maxLevel + stt->micVol) / 16; */ - tmp32 = (15 * stt->maxLevel) + stt->micVol; - stt->maxLevel = WEBRTC_SPL_RSHIFT_W32(tmp32, 4); + stt->maxLevel = (15 * stt->maxLevel + stt->micVol) / 16; stt->maxLevel = WEBRTC_SPL_MAX(stt->maxLevel, stt->maxAnalog); stt->zeroCtrlMax = stt->micVol; @@ -1104,8 +1095,7 @@ int32_t WebRtcAgc_ProcessAnalog(void *state, int32_t inMicLevel, volNormFIX, 13); /* stt->Rxx160_LPw32 *= 1.047 [~0.2 dB]; */ - tmp32 = WEBRTC_SPL_RSHIFT_W32(stt->Rxx160_LPw32, 6); - stt->Rxx160_LPw32 = tmp32 * 67; + stt->Rxx160_LPw32 = (stt->Rxx160_LPw32 / 64) * 67; tmp32 = inMicLevelTmp - stt->minLevel; tmpU32 = ((uint32_t)weightFIX * (uint32_t)(inMicLevelTmp - stt->minLevel)); @@ -1165,8 +1155,7 @@ int32_t WebRtcAgc_ProcessAnalog(void *state, int32_t inMicLevel, volNormFIX, 13); /* stt->Rxx160_LPw32 *= 1.047 [~0.2 dB]; */ - tmp32 = WEBRTC_SPL_RSHIFT_W32(stt->Rxx160_LPw32, 6); - stt->Rxx160_LPw32 = tmp32 * 67; + stt->Rxx160_LPw32 = (stt->Rxx160_LPw32 / 64) * 67; tmp32 = inMicLevelTmp - stt->minLevel; tmpU32 = ((uint32_t)weightFIX * (uint32_t)(inMicLevelTmp - stt->minLevel)); @@ -1255,11 +1244,7 @@ int32_t WebRtcAgc_ProcessAnalog(void *state, int32_t inMicLevel, stt->micVol = stt->minOutput; } - *outMicLevel = WEBRTC_SPL_RSHIFT_W32(stt->micVol, stt->scale); - if (*outMicLevel > WEBRTC_SPL_RSHIFT_W32(stt->maxAnalog, stt->scale)) - { - *outMicLevel = WEBRTC_SPL_RSHIFT_W32(stt->maxAnalog, stt->scale); - } + *outMicLevel = WEBRTC_SPL_MIN(stt->micVol, stt->maxAnalog) >> stt->scale; return 0; } @@ -1624,7 +1609,7 @@ int WebRtcAgc_Init(void *agcInst, int32_t minLevel, int32_t maxLevel, } /* The maximum supplemental volume range is based on a vague idea * of how much lower the gain will be than the real analog gain. */ - max_add = WEBRTC_SPL_RSHIFT_W32(maxLevel - minLevel, 2); + max_add = (maxLevel - minLevel) / 4; /* Minimum/maximum volume level that can be set */ stt->minLevel = minLevel; @@ -1656,7 +1641,7 @@ int WebRtcAgc_Init(void *agcInst, int32_t minLevel, int32_t maxLevel, #endif /* Minimum output volume is 4% higher than the available lowest volume level */ - tmp32 = WEBRTC_SPL_RSHIFT_W32((stt->maxLevel - stt->minLevel) * (int32_t)10, 8); + tmp32 = ((stt->maxLevel - stt->minLevel) * 10) >> 8; stt->minOutput = (stt->minLevel + tmp32); stt->msTooLow = 0; diff --git a/webrtc/modules/audio_processing/agc/digital_agc.c b/webrtc/modules/audio_processing/agc/digital_agc.c index c99a78c25..fbcba5690 100644 --- a/webrtc/modules/audio_processing/agc/digital_agc.c +++ b/webrtc/modules/audio_processing/agc/digital_agc.c @@ -204,10 +204,10 @@ int32_t WebRtcAgc_CalculateGainTable(int32_t *gainTable, // Q16 tmp32no1 = WEBRTC_SPL_SHIFT_W32(den, zeros - 8); // Q(zeros) if (numFIX < 0) { - numFIX -= WEBRTC_SPL_RSHIFT_W32(tmp32no1, 1); + numFIX -= tmp32no1 / 2; } else { - numFIX += WEBRTC_SPL_RSHIFT_W32(tmp32no1, 1); + numFIX += tmp32no1 / 2; } y32 = numFIX / tmp32no1; // in Q14 if (limiterEnable && (i < limiterIdx)) @@ -219,31 +219,30 @@ int32_t WebRtcAgc_CalculateGainTable(int32_t *gainTable, // Q16 if (y32 > 39000) { tmp32 = (y32 >> 1) * kLog10 + 4096; // in Q27 - tmp32 = WEBRTC_SPL_RSHIFT_W32(tmp32, 13); // in Q14 + tmp32 >>= 13; // In Q14. } else { tmp32 = y32 * kLog10 + 8192; // in Q28 - tmp32 = WEBRTC_SPL_RSHIFT_W32(tmp32, 14); // in Q14 + tmp32 >>= 14; // In Q14. } tmp32 += 16 << 14; // in Q14 (Make sure final output is in Q16) // Calculate power if (tmp32 > 0) { - intPart = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32, 14); + intPart = (int16_t)(tmp32 >> 14); fracPart = (uint16_t)(tmp32 & 0x00003FFF); // in Q14 - if (WEBRTC_SPL_RSHIFT_W32(fracPart, 13)) + if ((fracPart >> 13) != 0) { tmp16 = (2 << 14) - constLinApprox; tmp32no2 = (1 << 14) - fracPart; tmp32no2 *= tmp16; - tmp32no2 = WEBRTC_SPL_RSHIFT_W32(tmp32no2, 13); + tmp32no2 >>= 13; tmp32no2 = (1 << 14) - tmp32no2; } else { tmp16 = constLinApprox - (1 << 14); - tmp32no2 = fracPart * tmp16; - tmp32no2 = WEBRTC_SPL_RSHIFT_W32(tmp32no2, 13); + tmp32no2 = (fracPart * tmp16) >> 13; } fracPart = (uint16_t)tmp32no2; gainTable[i] = @@ -353,7 +352,7 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near, if (stt->vadFarend.counter > 10) { tmp32 = WEBRTC_SPL_MUL_16_16(3, logratio); - logratio = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32 - stt->vadFarend.logRatio, 2); + logratio = (int16_t)((tmp32 - stt->vadFarend.logRatio) >> 2); } // Determine decay factor depending on VAD @@ -374,7 +373,7 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near, // * (2^27/(DecayTime*(upper_thr-lower_thr)))) >> 10); // SUBSTITUTED: 2^27/(DecayTime*(upper_thr-lower_thr)) -> 65 tmp32 = WEBRTC_SPL_MUL_16_16((lower_thr - logratio), 65); - decay = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32, 10); + decay = (int16_t)(tmp32 >> 10); } // adjust decay factor for long silence (detected as low standard deviation) @@ -388,7 +387,7 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near, { // decay = (int16_t)(((stt->vadNearend.stdLongTerm - 4000) * decay) >> 12); tmp32 = WEBRTC_SPL_MUL_16_16((stt->vadNearend.stdLongTerm - 4000), decay); - decay = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32, 12); + decay = (int16_t)(tmp32 >> 12); } if (lowlevelSignal != 0) @@ -462,9 +461,9 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near, zeros = 31; } tmp32 = (cur_level << zeros) & 0x7FFFFFFF; - frac = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32, 19); // Q12 + frac = (int16_t)(tmp32 >> 19); // Q12. tmp32 = (stt->gainTable[zeros-1] - stt->gainTable[zeros]) * frac; - gains[k + 1] = stt->gainTable[zeros] + WEBRTC_SPL_RSHIFT_W32(tmp32, 12); + gains[k + 1] = stt->gainTable[zeros] + (tmp32 >> 12); #ifdef WEBRTC_AGC_DEBUG_DUMP if (k == 0) { fprintf(stt->logFile, @@ -488,7 +487,7 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near, } tmp32 = (stt->capacitorFast << zeros_fast) & 0x7FFFFFFF; zeros_fast <<= 9; - zeros_fast -= (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32, 22); + zeros_fast -= (int16_t)(tmp32 >> 22); gate = 1000 + zeros_fast - zeros - stt->vadNearend.stdShortTerm; @@ -498,7 +497,7 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near, } else { tmp32 = WEBRTC_SPL_MUL_16_16(stt->gatePrevious, 7); - gate = (int16_t)WEBRTC_SPL_RSHIFT_W32((int32_t)gate + tmp32, 3); + gate = (int16_t)((gate + tmp32) >> 3); stt->gatePrevious = gate; } // gate < 0 -> no gate @@ -517,12 +516,12 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near, if ((gains[k + 1] - stt->gainTable[0]) > 8388608) { // To prevent wraparound - tmp32 = WEBRTC_SPL_RSHIFT_W32((gains[k+1] - stt->gainTable[0]), 8); + tmp32 = (gains[k + 1] - stt->gainTable[0]) >> 8; tmp32 *= 178 + gain_adj; } else { tmp32 = (gains[k+1] - stt->gainTable[0]) * (178 + gain_adj); - tmp32 = WEBRTC_SPL_RSHIFT_W32(tmp32, 8); + tmp32 >>= 8; } gains[k + 1] = stt->gainTable[0] + tmp32; } @@ -537,10 +536,10 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near, { zeros = 16 - WebRtcSpl_NormW32(gains[k + 1]); } - gain32 = WEBRTC_SPL_RSHIFT_W32(gains[k+1], zeros) + 1; + gain32 = (gains[k + 1] >> zeros) + 1; gain32 *= gain32; // check for overflow - while (AGC_MUL32(WEBRTC_SPL_RSHIFT_W32(env[k], 12) + 1, gain32) + while (AGC_MUL32((env[k] >> 12) + 1, gain32) > WEBRTC_SPL_SHIFT_W32((int32_t)32767, 2 * (1 - zeros + 10))) { // multiply by 253/256 ==> -0.1 dB @@ -552,7 +551,7 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near, { gains[k + 1] = (gains[k+1] * 253) / 256; } - gain32 = WEBRTC_SPL_RSHIFT_W32(gains[k+1], zeros) + 1; + gain32 = (gains[k + 1] >> zeros) + 1; gain32 *= gain32; } } @@ -576,7 +575,7 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near, { // For lower band tmp32 = out[n] * ((gain32 + 127) >> 7); - out_tmp = WEBRTC_SPL_RSHIFT_W32(tmp32 , 16); + out_tmp = tmp32 >> 16; if (out_tmp > 4095) { out[n] = (int16_t)32767; @@ -586,13 +585,13 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near, } else { tmp32 = out[n] * (gain32 >> 4); - out[n] = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32 , 16); + out[n] = (int16_t)(tmp32 >> 16); } // For higher band if (FS == 32000) { tmp32 = out_H[n] * ((gain32 + 127) >> 7); - out_tmp = WEBRTC_SPL_RSHIFT_W32(tmp32 , 16); + out_tmp = tmp32 >> 16; if (out_tmp > 4095) { out_H[n] = (int16_t)32767; @@ -602,7 +601,7 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near, } else { tmp32 = out_H[n] * (gain32 >> 4); - out_H[n] = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32 , 16); + out_H[n] = (int16_t)(tmp32 >> 16); } } // @@ -619,12 +618,12 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near, { // For lower band tmp32 = out[k * L + n] * (gain32 >> 4); - out[k * L + n] = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32 , 16); + out[k * L + n] = (int16_t)(tmp32 >> 16); // For higher band if (FS == 32000) { tmp32 = out_H[k * L + n] * (gain32 >> 4); - out_H[k * L + n] = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32 , 16); + out_H[k * L + n] = (int16_t)(tmp32 >> 16); } gain32 += delta; } @@ -684,7 +683,7 @@ int16_t WebRtcAgc_ProcessVad(AgcVad_t *state, // (i) VAD state for (k = 0; k < 8; k++) { tmp32 = (int32_t)in[2 * k] + (int32_t)in[2 * k + 1]; - tmp32 = WEBRTC_SPL_RSHIFT_W32(tmp32, 1); + tmp32 >>= 1; buf1[k] = (int16_t)tmp32; } in += 16; @@ -701,8 +700,8 @@ int16_t WebRtcAgc_ProcessVad(AgcVad_t *state, // (i) VAD state { out = buf2[k] + HPstate; tmp32 = 600 * out; - HPstate = (int16_t)(WEBRTC_SPL_RSHIFT_W32(tmp32, 10) - buf2[k]); - nrg += WEBRTC_SPL_RSHIFT_W32(out * out, 6); + HPstate = (int16_t)((tmp32 >> 10) - buf2[k]); + nrg += (out * out) >> 6; } } state->HPstate = HPstate; @@ -745,12 +744,12 @@ int16_t WebRtcAgc_ProcessVad(AgcVad_t *state, // (i) VAD state // update short-term estimate of mean energy level (Q10) tmp32 = (WEBRTC_SPL_MUL_16_16(state->meanShortTerm, 15) + (int32_t)dB); - state->meanShortTerm = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32, 4); + state->meanShortTerm = (int16_t)(tmp32 >> 4); // update short-term estimate of variance in energy level (Q8) - tmp32 = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(dB, dB), 12); + tmp32 = (dB * dB) >> 12; tmp32 += state->varianceShortTerm * 15; - state->varianceShortTerm = WEBRTC_SPL_RSHIFT_W32(tmp32, 4); + state->varianceShortTerm = tmp32 / 16; // update short-term estimate of standard deviation in energy level (Q10) tmp32 = WEBRTC_SPL_MUL_16_16(state->meanShortTerm, state->meanShortTerm); @@ -763,7 +762,7 @@ int16_t WebRtcAgc_ProcessVad(AgcVad_t *state, // (i) VAD state tmp32, WebRtcSpl_AddSatW16(state->counter, 1)); // update long-term estimate of variance in energy level (Q8) - tmp32 = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL_16_16(dB, dB), 12); + tmp32 = (dB * dB) >> 12; tmp32 += state->varianceLongTerm * state->counter; state->varianceLongTerm = WebRtcSpl_DivW32W16( tmp32, WebRtcSpl_AddSatW16(state->counter, 1)); @@ -779,9 +778,9 @@ int16_t WebRtcAgc_ProcessVad(AgcVad_t *state, // (i) VAD state tmp32 = WebRtcSpl_DivW32W16(tmp32, state->stdLongTerm); tmpU16 = (13 << 12); tmp32b = WEBRTC_SPL_MUL_16_U16(state->logRatio, tmpU16); - tmp32 += WEBRTC_SPL_RSHIFT_W32(tmp32b, 10); + tmp32 += tmp32b >> 10; - state->logRatio = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32, 6); + state->logRatio = (int16_t)(tmp32 >> 6); // limit if (state->logRatio > 2048)