From 1afbdc7555b4bcf9da3bc12ed60e32a0ac0dd297 Mon Sep 17 00:00:00 2001 From: "bjornv@webrtc.org" Date: Tue, 10 Mar 2015 06:37:47 +0000 Subject: [PATCH] Refactor audio_processing/agc: Removes usage of macro WEBRTC_SPL_MUL_16_16_RSFT The macro is defined as #define WEBRTC_SPL_MUL_16_16_RSFT(a, b, c) \ (WEBRTC_SPL_MUL_16_16(a, b) >> (c)) where the latter macro is in C defined as #define WEBRTC_SPL_MUL_16_16(a, b) \ ((int32_t) (((int16_t)(a)) * ((int16_t)(b)))) (For definitions on ARMv7 and MIPS, see common_audio/signal_processing/include/spl_inl_{armv7,mips}.h) The replacement consists of - avoiding casts to int16_t if inputs already are int16_t - adding explicit cast to if result is assigned to (other than int or int32_t) - minor cleanups like remove of unnecessary parentheses and style changes BUG=3348,3353 TESTED=locally on Mac and trybots R=kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/47449004 Cr-Commit-Position: refs/heads/master@{#8664} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8664 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../audio_processing/agc/legacy/analog_agc.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/webrtc/modules/audio_processing/agc/legacy/analog_agc.c b/webrtc/modules/audio_processing/agc/legacy/analog_agc.c index 1559aeb565..17e06fe139 100644 --- a/webrtc/modules/audio_processing/agc/legacy/analog_agc.c +++ b/webrtc/modules/audio_processing/agc/legacy/analog_agc.c @@ -493,8 +493,7 @@ void WebRtcAgc_SaturationCtrl(LegacyAgc* stt, } /* stt->envSum *= 0.99; */ - stt->envSum = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(stt->envSum, - (int16_t)32440, 15); + stt->envSum = (int16_t)((stt->envSum * 32440) >> 15); } void WebRtcAgc_ZeroCtrl(LegacyAgc* stt, int32_t* inMicLevel, int32_t* env) { @@ -975,9 +974,8 @@ int32_t WebRtcAgc_ProcessAnalog(void *state, int32_t inMicLevel, WebRtcAgc_ExpCurve(volNormFIX, &index); /* Compute weighting factor for the volume increase, 32^(-2*X)/2+1.05 */ - weightFIX = kOffset1[index] - - (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(kSlope1[index], - volNormFIX, 13); + weightFIX = kOffset1[index] - + (int16_t)((kSlope1[index] * volNormFIX) >> 13); /* stt->Rxx160_LPw32 *= 1.047 [~0.2 dB]; */ stt->Rxx160_LPw32 = (stt->Rxx160_LPw32 / 64) * 67; @@ -1035,9 +1033,8 @@ int32_t WebRtcAgc_ProcessAnalog(void *state, int32_t inMicLevel, WebRtcAgc_ExpCurve(volNormFIX, &index); /* Compute weighting factor for the volume increase, (3.^(-2.*X))/8+1 */ - weightFIX = kOffset2[index] - - (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(kSlope2[index], - volNormFIX, 13); + weightFIX = kOffset2[index] - + (int16_t)((kSlope2[index] * volNormFIX) >> 13); /* stt->Rxx160_LPw32 *= 1.047 [~0.2 dB]; */ stt->Rxx160_LPw32 = (stt->Rxx160_LPw32 / 64) * 67;