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

Unified Diff: webrtc/modules/audio_processing/aec3/adaptive_fir_filter_unittest.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/adaptive_fir_filter_unittest.cc
diff --git a/webrtc/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc b/webrtc/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc
index 4560958bfd0ef350e46d97a5a3ddcb34484627d0..2402d91d0e9e938113d391bdfc30fd406d4fff15 100644
--- a/webrtc/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc
+++ b/webrtc/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc
@@ -20,6 +20,7 @@
#endif
#include "webrtc/base/arraysize.h"
#include "webrtc/base/random.h"
+#include "webrtc/base/safe_minmax.h"
#include "webrtc/modules/audio_processing/aec3/aec3_fft.h"
#include "webrtc/modules/audio_processing/aec3/aec_state.h"
#include "webrtc/modules/audio_processing/aec3/cascaded_biquad_filter.h"
@@ -350,9 +351,8 @@ TEST(AdaptiveFirFilter, FilterAndAdapt) {
fft.Ifft(S, &s);
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);
gain.Compute(render_buffer, render_signal_analyzer, E,

Powered by Google App Engine
This is Rietveld 408576698