Index: webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
diff --git a/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc b/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
index fa8d1704c6775e31673c07a460d2e835fa5f1a58..deaeb27f44fd157e415c6eb1d94f296d62af6752 100644 |
--- a/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
+++ b/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
@@ -16,6 +16,8 @@ |
#include <algorithm> |
#include <limits> |
+#include "webrtc/base/safe_minmax.h" |
+ |
namespace webrtc { |
namespace intelligibility { |
@@ -28,9 +30,9 @@ const float kMaxFactor = 100.f; |
// Return |current| changed towards |target|, with the relative change being at |
// most |limit|. |
float UpdateFactor(float target, float current, float limit) { |
- float gain = target / (current + std::numeric_limits<float>::epsilon()); |
- gain = std::min(std::max(gain, 1.f - limit), 1.f + limit); |
- return std::min(std::max(current * gain, kMinFactor), kMaxFactor);; |
+ const float gain = target / (current + std::numeric_limits<float>::epsilon()); |
+ const float clamped_gain = rtc::SafeClamp(gain, 1 - limit, 1 + limit); |
+ return rtc::SafeClamp(current * clamped_gain, kMinFactor, kMaxFactor); |
} |
} // namespace |