webrtc/modules/audio_processing/agc/legacy
Alex Loiko 7cfbf3a0ff Make energy calculation in AGC not overflow.
An energy value is calculated by summing squares of processed audio
samples. The expression 'out*out >> 6' could overflow. In this CL we
change it to 'out*(out>>6) + out*(out*(out%(1<<6))>>6)'.

The which is verified and proven to be equal, but doesn't
overflow. The change also passes our change-detection tests in
GainControlBitExactnessTest.*

We verified with Godbolt that the modulo and divisions are converted
into branch-free bitwise operations.

NOTRY=True # changing comment, tests just passed.

Bug: chromium:780638, chromium:780376
Change-Id: I415535193433a2fbc275c643fb4e4026ba3e0bdd
Reviewed-on: https://webrtc-review.googlesource.com/20867
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20589}
2017-11-07 15:37:55 +00:00
..
analog_agc.c Fixing WebRTC after moving from src/webrtc to src/ 2017-09-15 05:02:56 +00:00
analog_agc.h Adding NOLINT for typedefs.h and common_types.h 2017-09-15 13:03:51 +00:00
digital_agc.c Make energy calculation in AGC not overflow. 2017-11-07 15:37:55 +00:00
digital_agc.h Adding NOLINT for typedefs.h and common_types.h 2017-09-15 13:03:51 +00:00
gain_control.h Adding NOLINT for typedefs.h and common_types.h 2017-09-15 13:03:51 +00:00