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

Unified Diff: webrtc/tools/agc/activity_metric.cc

Issue 2808513003: Add SafeClamp(), which accepts args of different types (Closed)
Patch Set: rebase Created 3 years, 6 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
« no previous file with comments | « webrtc/p2p/base/pseudotcp.cc ('k') | webrtc/voice_engine/channel_proxy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/tools/agc/activity_metric.cc
diff --git a/webrtc/tools/agc/activity_metric.cc b/webrtc/tools/agc/activity_metric.cc
index 599777c3be81d757c145e559a3fa3ac1cb9e0ea9..9715d62060c9d9c08cfe3c9a330cae327da5f9b4 100644
--- a/webrtc/tools/agc/activity_metric.cc
+++ b/webrtc/tools/agc/activity_metric.cc
@@ -17,6 +17,7 @@
#include <memory>
#include "webrtc/base/flags.h"
+#include "webrtc/base/safe_minmax.h"
#include "webrtc/modules/audio_processing/agc/agc.h"
#include "webrtc/modules/audio_processing/agc/loudness_histogram.h"
#include "webrtc/modules/audio_processing/agc/utility.h"
@@ -121,9 +122,7 @@ class AgcStat {
for (size_t n = 0; n < features.num_frames; n++) {
double p_active = p[n] * video_vad_[n];
double p_passive = (1 - p[n]) * (1 - video_vad_[n]);
- p[n] = p_active / (p_active + p_passive);
- // Limit probabilities.
- p[n] = std::min(std::max(p[n], 0.01), 0.99);
+ p[n] = rtc::SafeClamp(p_active / (p_active + p_passive), 0.01, 0.99);
}
if (vad_->VoicingProbability(features, p) < 0)
return -1;
« no previous file with comments | « webrtc/p2p/base/pseudotcp.cc ('k') | webrtc/voice_engine/channel_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698