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

Unified Diff: webrtc/modules/audio_processing/aec3/subtractor.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
Index: webrtc/modules/audio_processing/aec3/subtractor.cc
diff --git a/webrtc/modules/audio_processing/aec3/subtractor.cc b/webrtc/modules/audio_processing/aec3/subtractor.cc
index 3897d947e1a39a00f02cbb6661296065c331d609..dc3ec0688e310181878a75345ae0811a7cb8131c 100644
--- a/webrtc/modules/audio_processing/aec3/subtractor.cc
+++ b/webrtc/modules/audio_processing/aec3/subtractor.cc
@@ -14,6 +14,7 @@
#include "webrtc/base/array_view.h"
#include "webrtc/base/checks.h"
+#include "webrtc/base/safe_minmax.h"
#include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
namespace webrtc {
@@ -30,9 +31,8 @@ void PredictionError(const Aec3Fft& fft,
constexpr float kScale = 1.0f / kFftLengthBy2;
std::transform(y.begin(), y.end(), s.begin() + kFftLengthBy2, e->begin(),
[&](float a, float b) { return a - b * kScale; });
- std::for_each(e->begin(), e->end(), [](float& a) {
- a = std::max(std::min(a, 32767.0f), -32768.0f);
- });
+ std::for_each(e->begin(), e->end(),
+ [](float& a) { a = rtc::SafeClamp(a, -32768.f, 32767.f); });
fft.ZeroPaddedFft(*e, E);
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698