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

Unified Diff: webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc

Issue 2808513003: Add SafeClamp(), which accepts args of different types (Closed)
Patch Set: Created 3 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/remote_bitrate_estimator/test/bwe_test_framework.cc
diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc
index f9313a6724dd8908b0aa7cd7dc99bd9d8109d9c3..e86d5dba02f5547a48c29f315741eb074f2a9943 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc
+++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc
@@ -15,6 +15,7 @@
#include <sstream>
#include "webrtc/base/constructormagic.h"
+#include "webrtc/base/safe_minmax.h"
namespace webrtc {
namespace testing {
@@ -398,8 +399,8 @@ namespace {
inline int64_t TruncatedNSigmaGaussian(Random* const random,
int64_t mean,
int64_t std_dev) {
- int64_t gaussian_random = random->Gaussian(mean, std_dev);
- return std::max(std::min(gaussian_random, kN * std_dev), -kN * std_dev);
+ const int64_t gaussian_random = random->Gaussian(mean, std_dev);
+ return rtc::SafeClamp(-kN * std_dev, kN * std_dev, gaussian_random);
}
}

Powered by Google App Engine
This is Rietveld 408576698