Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / modules / audio_processing / agc / digital_agc.c
index da087ca..fbcba56 100644 (file)
@@ -116,9 +116,8 @@ int32_t WebRtcAgc_CalculateGainTable(int32_t *gainTable, // Q16
     //  limiterLvlX = analogTarget - limiterOffset
     //  limiterLvl  = targetLevelDbfs + limiterOffset/compRatio
     limiterLvlX = analogTarget - limiterOffset;
-    limiterIdx = 2
-            + WebRtcSpl_DivW32W16ResW16(WEBRTC_SPL_LSHIFT_W32((int32_t)limiterLvlX, 13),
-                                        (kLog10_2 / 2));
+    limiterIdx =
+        2 + WebRtcSpl_DivW32W16ResW16((int32_t)limiterLvlX << 13, kLog10_2 / 2);
     tmp16no1 = WebRtcSpl_DivW32W16ResW16(limiterOffset + (kCompRatio >> 1), kCompRatio);
     limiterLvl = targetLevelDbfs + tmp16no1;
 
@@ -144,18 +143,18 @@ int32_t WebRtcAgc_CalculateGainTable(int32_t *gainTable, // Q16
         inLevel = WebRtcSpl_DivW32W16(tmp32, kCompRatio); // Q14
 
         // Calculate diffGain-inLevel, to map using the genFuncTable
-        inLevel = WEBRTC_SPL_LSHIFT_W32((int32_t)diffGain, 14) - inLevel; // Q14
+        inLevel = ((int32_t)diffGain << 14) - inLevel;  // Q14
 
         // Make calculations on abs(inLevel) and compensate for the sign afterwards.
         absInLevel = (uint32_t)WEBRTC_SPL_ABS_W32(inLevel); // Q14
 
         // LUT with interpolation
-        intPart = (uint16_t)WEBRTC_SPL_RSHIFT_U32(absInLevel, 14);
+        intPart = (uint16_t)(absInLevel >> 14);
         fracPart = (uint16_t)(absInLevel & 0x00003FFF); // extract the fractional part
         tmpU16 = kGenFuncTable[intPart + 1] - kGenFuncTable[intPart]; // Q8
         tmpU32no1 = tmpU16 * fracPart;  // Q22
         tmpU32no1 += (uint32_t)kGenFuncTable[intPart] << 14;  // Q22
-        logApprox = WEBRTC_SPL_RSHIFT_U32(tmpU32no1, 8); // Q14
+        logApprox = tmpU32no1 >> 8;  // Q14
         // Compensate for negative exponent using the relation:
         //  log2(1 + 2^-x) = log2(1 + 2^x) - x
         if (inLevel < 0)
@@ -165,28 +164,28 @@ int32_t WebRtcAgc_CalculateGainTable(int32_t *gainTable, // Q16
             if (zeros < 15)
             {
                 // Not enough space for multiplication
-                tmpU32no2 = WEBRTC_SPL_RSHIFT_U32(absInLevel, 15 - zeros); // Q(zeros-1)
+                tmpU32no2 = absInLevel >> (15 - zeros);  // Q(zeros-1)
                 tmpU32no2 = WEBRTC_SPL_UMUL_32_16(tmpU32no2, kLogE_1); // Q(zeros+13)
                 if (zeros < 9)
                 {
-                    tmpU32no1 = WEBRTC_SPL_RSHIFT_U32(tmpU32no1, 9 - zeros); // Q(zeros+13)
                     zerosScale = 9 - zeros;
+                    tmpU32no1 >>= zerosScale;  // Q(zeros+13)
                 } else
                 {
-                    tmpU32no2 = WEBRTC_SPL_RSHIFT_U32(tmpU32no2, zeros - 9); // Q22
+                    tmpU32no2 >>= zeros - 9;  // Q22
                 }
             } else
             {
                 tmpU32no2 = WEBRTC_SPL_UMUL_32_16(absInLevel, kLogE_1); // Q28
-                tmpU32no2 = WEBRTC_SPL_RSHIFT_U32(tmpU32no2, 6); // Q22
+                tmpU32no2 >>= 6;  // Q22
             }
             logApprox = 0;
             if (tmpU32no2 < tmpU32no1)
             {
-                logApprox = WEBRTC_SPL_RSHIFT_U32(tmpU32no1 - tmpU32no2, 8 - zerosScale); //Q14
+                logApprox = (tmpU32no1 - tmpU32no2) >> (8 - zerosScale);  //Q14
             }
         }
-        numFIX = WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_U16(maxGain, constMaxGain), 6); // Q14
+        numFIX = (maxGain * constMaxGain) << 6;  // Q14
         numFIX -= (int32_t)logApprox * diffGain;  // Q14
 
         // Calculate ratio
@@ -199,56 +198,55 @@ int32_t WebRtcAgc_CalculateGainTable(int32_t *gainTable, // Q16
         {
             zeros = WebRtcSpl_NormW32(den) + 8;
         }
-        numFIX = WEBRTC_SPL_LSHIFT_W32(numFIX, zeros); // Q(14+zeros)
+        numFIX <<= zeros;  // Q(14+zeros)
 
         // Shift den so we end up in Qy1
         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))
         {
             tmp32 = WEBRTC_SPL_MUL_16_U16(i - 1, kLog10_2); // Q14
-            tmp32 -= WEBRTC_SPL_LSHIFT_W32(limiterLvl, 14); // Q14
+            tmp32 -= limiterLvl << 14;  // Q14
             y32 = WebRtcSpl_DivW32W16(tmp32 + 10, 20);
         }
         if (y32 > 39000)
         {
-            tmp32 = WEBRTC_SPL_MUL(y32 >> 1, kLog10) + 4096; // in Q27
-            tmp32 = WEBRTC_SPL_RSHIFT_W32(tmp32, 13); // in Q14
+            tmp32 = (y32 >> 1) * kLog10 + 4096;  // in Q27
+            tmp32 >>= 13;  // In Q14.
         } else
         {
-            tmp32 = WEBRTC_SPL_MUL(y32, kLog10) + 8192; // in Q28
-            tmp32 = WEBRTC_SPL_RSHIFT_W32(tmp32, 14); // in Q14
+            tmp32 = y32 * kLog10 + 8192;  // in Q28
+            tmp32 >>= 14;  // In Q14.
         }
-        tmp32 += WEBRTC_SPL_LSHIFT_W32(16, 14); // in Q14 (Make sure final output is in Q16)
+        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 = WEBRTC_SPL_LSHIFT_W16(2, 14) - constLinApprox;
-                tmp32no2 = WEBRTC_SPL_LSHIFT_W32(1, 14) - fracPart;
+                tmp16 = (2 << 14) - constLinApprox;
+                tmp32no2 = (1 << 14) - fracPart;
                 tmp32no2 *= tmp16;
-                tmp32no2 = WEBRTC_SPL_RSHIFT_W32(tmp32no2, 13);
-                tmp32no2 = WEBRTC_SPL_LSHIFT_W32(1, 14) - tmp32no2;
+                tmp32no2 >>= 13;
+                tmp32no2 = (1 << 14) - tmp32no2;
             } else
             {
-                tmp16 = constLinApprox - WEBRTC_SPL_LSHIFT_W16(1, 14);
-                tmp32no2 = fracPart * tmp16;
-                tmp32no2 = WEBRTC_SPL_RSHIFT_W32(tmp32no2, 13);
+                tmp16 = constLinApprox - (1 << 14);
+                tmp32no2 = (fracPart * tmp16) >> 13;
             }
             fracPart = (uint16_t)tmp32no2;
-            gainTable[i] = WEBRTC_SPL_LSHIFT_W32(1, intPart)
-                    + WEBRTC_SPL_SHIFT_W32(fracPart, intPart - 14);
+            gainTable[i] =
+                (1 << intPart) + WEBRTC_SPL_SHIFT_W32(fracPart, intPart - 14);
         } else
         {
             gainTable[i] = 0;
@@ -354,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
@@ -375,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)
@@ -389,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,10 +460,10 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near,
         {
             zeros = 31;
         }
-        tmp32 = (WEBRTC_SPL_LSHIFT_W32(cur_level, zeros) & 0x7FFFFFFF);
-        frac = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32, 19); // Q12
-        tmp32 = WEBRTC_SPL_MUL((stt->gainTable[zeros-1] - stt->gainTable[zeros]), frac);
-        gains[k + 1] = stt->gainTable[zeros] + WEBRTC_SPL_RSHIFT_W32(tmp32, 12);
+        tmp32 = (cur_level << zeros) & 0x7FFFFFFF;
+        frac = (int16_t)(tmp32 >> 19);  // Q12.
+        tmp32 = (stt->gainTable[zeros-1] - stt->gainTable[zeros]) * frac;
+        gains[k + 1] = stt->gainTable[zeros] + (tmp32 >> 12);
 #ifdef WEBRTC_AGC_DEBUG_DUMP
         if (k == 0) {
           fprintf(stt->logFile,
@@ -480,16 +478,16 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near,
     }
 
     // Gate processing (lower gain during absence of speech)
-    zeros = WEBRTC_SPL_LSHIFT_W16(zeros, 9) - WEBRTC_SPL_RSHIFT_W16(frac, 3);
+    zeros = (zeros << 9) - (frac >> 3);
     // find number of leading zeros
     zeros_fast = WebRtcSpl_NormU32((uint32_t)stt->capacitorFast);
     if (stt->capacitorFast == 0)
     {
         zeros_fast = 31;
     }
-    tmp32 = (WEBRTC_SPL_LSHIFT_W32(stt->capacitorFast, zeros_fast) & 0x7FFFFFFF);
-    zeros_fast = WEBRTC_SPL_LSHIFT_W16(zeros_fast, 9);
-    zeros_fast -= (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32, 22);
+    tmp32 = (stt->capacitorFast << zeros_fast) & 0x7FFFFFFF;
+    zeros_fast <<= 9;
+    zeros_fast -= (int16_t)(tmp32 >> 22);
 
     gate = 1000 + zeros_fast - zeros - stt->vadNearend.stdShortTerm;
 
@@ -499,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
@@ -508,7 +506,7 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near,
     {
         if (gate < 2500)
         {
-            gain_adj = WEBRTC_SPL_RSHIFT_W16(2500 - gate, 5);
+            gain_adj = (2500 - gate) >> 5;
         } else
         {
             gain_adj = 0;
@@ -518,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 = WEBRTC_SPL_MUL(tmp32, (178 + gain_adj));
+                tmp32 = (gains[k + 1] - stt->gainTable[0]) >> 8;
+                tmp32 *= 178 + gain_adj;
             } else
             {
-                tmp32 = WEBRTC_SPL_MUL((gains[k+1] - stt->gainTable[0]), (178 + gain_adj));
-                tmp32 = WEBRTC_SPL_RSHIFT_W32(tmp32, 8);
+                tmp32 = (gains[k+1] - stt->gainTable[0]) * (178 + gain_adj);
+                tmp32 >>= 8;
             }
             gains[k + 1] = stt->gainTable[0] + tmp32;
         }
@@ -538,23 +536,23 @@ 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 = WEBRTC_SPL_MUL(gain32, gain32);
+        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
             if (gains[k + 1] > 8388607)
             {
                 // Prevent wrap around
-                gains[k + 1] = WEBRTC_SPL_MUL(WEBRTC_SPL_RSHIFT_W32(gains[k+1], 8), 253);
+                gains[k + 1] = (gains[k+1] / 256) * 253;
             } else
             {
-                gains[k + 1] = WEBRTC_SPL_RSHIFT_W32(WEBRTC_SPL_MUL(gains[k+1], 253), 8);
+                gains[k + 1] = (gains[k+1] * 253) / 256;
             }
-            gain32 = WEBRTC_SPL_RSHIFT_W32(gains[k+1], zeros) + 1;
-            gain32 = WEBRTC_SPL_MUL(gain32, gain32);
+            gain32 = (gains[k + 1] >> zeros) + 1;
+            gain32 *= gain32;
         }
     }
     // gain reductions should be done 1 ms earlier than gain increases
@@ -570,14 +568,14 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near,
 
     // Apply gain
     // handle first sub frame separately
-    delta = WEBRTC_SPL_LSHIFT_W32(gains[1] - gains[0], (4 - L2));
-    gain32 = WEBRTC_SPL_LSHIFT_W32(gains[0], 4);
+    delta = (gains[1] - gains[0]) << (4 - L2);
+    gain32 = gains[0] << 4;
     // iterate over samples
     for (n = 0; n < L; n++)
     {
         // For lower band
-        tmp32 = WEBRTC_SPL_MUL((int32_t)out[n], WEBRTC_SPL_RSHIFT_W32(gain32 + 127, 7));
-        out_tmp = WEBRTC_SPL_RSHIFT_W32(tmp32 , 16);
+        tmp32 = out[n] * ((gain32 + 127) >> 7);
+        out_tmp = tmp32 >> 16;
         if (out_tmp > 4095)
         {
             out[n] = (int16_t)32767;
@@ -586,15 +584,14 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near,
             out[n] = (int16_t)-32768;
         } else
         {
-            tmp32 = WEBRTC_SPL_MUL((int32_t)out[n], WEBRTC_SPL_RSHIFT_W32(gain32, 4));
-            out[n] = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32 , 16);
+            tmp32 = out[n] * (gain32 >> 4);
+            out[n] = (int16_t)(tmp32 >> 16);
         }
         // For higher band
         if (FS == 32000)
         {
-            tmp32 = WEBRTC_SPL_MUL((int32_t)out_H[n],
-                                   WEBRTC_SPL_RSHIFT_W32(gain32 + 127, 7));
-            out_tmp = WEBRTC_SPL_RSHIFT_W32(tmp32 , 16);
+            tmp32 = out_H[n] * ((gain32 + 127) >> 7);
+            out_tmp = tmp32 >> 16;
             if (out_tmp > 4095)
             {
                 out_H[n] = (int16_t)32767;
@@ -603,9 +600,8 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near,
                 out_H[n] = (int16_t)-32768;
             } else
             {
-                tmp32 = WEBRTC_SPL_MUL((int32_t)out_H[n],
-                                       WEBRTC_SPL_RSHIFT_W32(gain32, 4));
-                out_H[n] = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32 , 16);
+                tmp32 = out_H[n] * (gain32 >> 4);
+                out_H[n] = (int16_t)(tmp32 >> 16);
             }
         }
         //
@@ -615,21 +611,19 @@ int32_t WebRtcAgc_ProcessDigital(DigitalAgc_t *stt, const int16_t *in_near,
     // iterate over subframes
     for (k = 1; k < 10; k++)
     {
-        delta = WEBRTC_SPL_LSHIFT_W32(gains[k+1] - gains[k], (4 - L2));
-        gain32 = WEBRTC_SPL_LSHIFT_W32(gains[k], 4);
+        delta = (gains[k+1] - gains[k]) << (4 - L2);
+        gain32 = gains[k] << 4;
         // iterate over samples
         for (n = 0; n < L; n++)
         {
             // For lower band
-            tmp32 = WEBRTC_SPL_MUL((int32_t)out[k * L + n],
-                                   WEBRTC_SPL_RSHIFT_W32(gain32, 4));
-            out[k * L + n] = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32 , 16);
+            tmp32 = out[k * L + n] * (gain32 >> 4);
+            out[k * L + n] = (int16_t)(tmp32 >> 16);
             // For higher band
             if (FS == 32000)
             {
-                tmp32 = WEBRTC_SPL_MUL((int32_t)out_H[k * L + n],
-                                       WEBRTC_SPL_RSHIFT_W32(gain32, 4));
-                out_H[k * L + n] = (int16_t)WEBRTC_SPL_RSHIFT_W32(tmp32 , 16);
+                tmp32 = out_H[k * L + n] * (gain32 >> 4);
+                out_H[k * L + n] = (int16_t)(tmp32 >> 16);
             }
             gain32 += delta;
         }
@@ -645,17 +639,17 @@ void WebRtcAgc_InitVad(AgcVad_t *state)
     state->HPstate = 0; // state of high pass filter
     state->logRatio = 0; // log( P(active) / P(inactive) )
     // average input level (Q10)
-    state->meanLongTerm = WEBRTC_SPL_LSHIFT_W16(15, 10);
+    state->meanLongTerm = 15 << 10;
 
     // variance of input level (Q8)
-    state->varianceLongTerm = WEBRTC_SPL_LSHIFT_W32(500, 8);
+    state->varianceLongTerm = 500 << 8;
 
     state->stdLongTerm = 0; // standard deviation of input level in dB
     // short-term average input level (Q10)
-    state->meanShortTerm = WEBRTC_SPL_LSHIFT_W16(15, 10);
+    state->meanShortTerm = 15 << 10;
 
     // short-term variance of input level (Q8)
-    state->varianceShortTerm = WEBRTC_SPL_LSHIFT_W32(500, 8);
+    state->varianceShortTerm = 500 << 8;
 
     state->stdShortTerm = 0; // short-term standard deviation of input level in dB
     state->counter = 3; // counts updates
@@ -689,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;
@@ -705,10 +699,9 @@ int16_t WebRtcAgc_ProcessVad(AgcVad_t *state, // (i) VAD state
         for (k = 0; k < 4; k++)
         {
             out = buf2[k] + HPstate;
-            tmp32 = WEBRTC_SPL_MUL(600, out);
-            HPstate = (int16_t)(WEBRTC_SPL_RSHIFT_W32(tmp32, 10) - buf2[k]);
-            tmp32 = WEBRTC_SPL_MUL(out, out);
-            nrg += WEBRTC_SPL_RSHIFT_W32(tmp32, 6);
+            tmp32 = 600 * out;
+            HPstate = (int16_t)((tmp32 >> 10) - buf2[k]);
+            nrg += (out * out) >> 6;
         }
     }
     state->HPstate = HPstate;
@@ -739,7 +732,7 @@ int16_t WebRtcAgc_ProcessVad(AgcVad_t *state, // (i) VAD state
     }
 
     // energy level (range {-32..30}) (Q10)
-    dB = WEBRTC_SPL_LSHIFT_W16(15 - zeros, 11);
+    dB = (15 - zeros) << 11;
 
     // Update statistics
 
@@ -751,16 +744,16 @@ 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 += WEBRTC_SPL_MUL(state->varianceShortTerm, 15);
-    state->varianceShortTerm = WEBRTC_SPL_RSHIFT_W32(tmp32, 4);
+    tmp32 = (dB * dB) >> 12;
+    tmp32 += state->varianceShortTerm * 15;
+    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);
-    tmp32 = WEBRTC_SPL_LSHIFT_W32(state->varianceShortTerm, 12) - tmp32;
+    tmp32 = (state->varianceShortTerm << 12) - tmp32;
     state->stdShortTerm = (int16_t)WebRtcSpl_Sqrt(tmp32);
 
     // update long-term estimate of mean energy level (Q10)
@@ -769,25 +762,25 @@ 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 += WEBRTC_SPL_MUL(state->varianceLongTerm, state->counter);
+    tmp32 = (dB * dB) >> 12;
+    tmp32 += state->varianceLongTerm * state->counter;
     state->varianceLongTerm = WebRtcSpl_DivW32W16(
         tmp32, WebRtcSpl_AddSatW16(state->counter, 1));
 
     // update long-term estimate of standard deviation in energy level (Q10)
     tmp32 = WEBRTC_SPL_MUL_16_16(state->meanLongTerm, state->meanLongTerm);
-    tmp32 = WEBRTC_SPL_LSHIFT_W32(state->varianceLongTerm, 12) - tmp32;
+    tmp32 = (state->varianceLongTerm << 12) - tmp32;
     state->stdLongTerm = (int16_t)WebRtcSpl_Sqrt(tmp32);
 
     // update voice activity measure (Q10)
-    tmp16 = WEBRTC_SPL_LSHIFT_W16(3, 12);
+    tmp16 = 3 << 12;
     tmp32 = WEBRTC_SPL_MUL_16_16(tmp16, (dB - state->meanLongTerm));
     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)