Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1435)

Unified Diff: webrtc/modules/audio_processing/agc/legacy/analog_agc.c

Issue 2003623003: Re-enable UBsan on AGC. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/agc/legacy/analog_agc.c
diff --git a/webrtc/modules/audio_processing/agc/legacy/analog_agc.c b/webrtc/modules/audio_processing/agc/legacy/analog_agc.c
index 36c67c282a02a1b9096f01aa8bda572624f8b67b..030077afe30aae60d2a611670cbaf0a0323e3015 100644
--- a/webrtc/modules/audio_processing/agc/legacy/analog_agc.c
+++ b/webrtc/modules/audio_processing/agc/legacy/analog_agc.c
@@ -476,16 +476,20 @@ void WebRtcAgc_ZeroCtrl(LegacyAgc* stt, int32_t* inMicLevel, int32_t* env) {
int16_t i;
int32_t tmp32 = 0;
int32_t midVal;
+ const int kZeroThreshold = 500;
peah-webrtc 2016/05/23 04:59:36 This solution definitely works, but another varian
minyue-webrtc 2016/05/23 07:40:48 Yes, I think early exiting the loop is more effici
peah-webrtc 2016/05/23 12:00:19 I think that this would be a clear case where a 64
kwiberg-webrtc 2016/05/23 12:44:40 Are the operations int64 += int32 and int64 >= int
minyue-webrtc 2016/05/24 01:32:26 Loop in 481-488 is really to check if env[0..9] ar
peah-webrtc 2016/05/24 06:16:20 What I mean by pipelining is that as the loop is s
minyue-webrtc 2016/05/24 07:16:12 I can basically follow your suggestion, but I thin
peah-webrtc 2016/05/24 10:46:29 I don't know this as well as I should do, but I me
minyue-webrtc 2016/05/24 13:05:45 ok, I can do int64 sum.
/* Is the input signal zero? */
for (i = 0; i < 10; i++) {
+ if (env[i] >= kZeroThreshold || tmp32 >= kZeroThreshold) {
+ break;
+ }
tmp32 += env[i];
}
/* Each block is allowed to have a few non-zero
* samples.
*/
- if (tmp32 < 500) {
+ if (i == 10 && tmp32 < kZeroThreshold) {
stt->msZero += 10;
} else {
stt->msZero = 0;

Powered by Google App Engine
This is Rietveld 408576698