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

Unified Diff: webrtc/modules/audio_processing/aec3/suppression_filter.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/suppression_filter.cc
diff --git a/webrtc/modules/audio_processing/aec3/suppression_filter.cc b/webrtc/modules/audio_processing/aec3/suppression_filter.cc
index b172a1d0899264cc5e69a60c33f8c597d7262488..1121c74efed88e72e239078a6b7ad24b01162a91 100644
--- a/webrtc/modules/audio_processing/aec3/suppression_filter.cc
+++ b/webrtc/modules/audio_processing/aec3/suppression_filter.cc
@@ -16,6 +16,7 @@
#include <functional>
#include <numeric>
+#include "webrtc/base/safe_minmax.h"
#include "webrtc/modules/audio_processing/utility/ooura_fft.h"
namespace webrtc {
@@ -122,7 +123,7 @@ void SuppressionFilter::ApplyGain(
std::transform((*e)[0].begin(), (*e)[0].end(), e_extended.begin(),
(*e)[0].begin(), std::plus<float>());
std::for_each((*e)[0].begin(), (*e)[0].end(), [](float& x_k) {
- x_k = std::max(std::min(x_k, 32767.0f), -32768.0f);
+ x_k = rtc::SafeClamp(x_k, -32768.f, 32767.f);
});
std::copy(e_extended.begin() + kFftLengthBy2, e_extended.begin() + kFftLength,
std::begin(e_output_old_[0]));
@@ -154,7 +155,7 @@ void SuppressionFilter::ApplyGain(
if (e->size() > 2) {
RTC_DCHECK_EQ(3, e->size());
std::for_each((*e)[2].begin(), (*e)[2].end(), [&](float& a) {
- a = std::max(std::min(a * high_bands_gain, 32767.0f), -32768.0f);
+ a = rtc::SafeClamp(a * high_bands_gain, -32768.f, 32767.f);
});
}
« no previous file with comments | « webrtc/modules/audio_processing/aec3/subtractor.cc ('k') | webrtc/modules/audio_processing/agc/agc_manager_direct.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698