| 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..70c5ea6227b5cf2d915c39b3fa1a8ea75fa020f4 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(1 - limit, 1 + limit, gain);
|
| + return rtc::SafeClamp(kMinFactor, kMaxFactor, current * clamped_gain);
|
| }
|
|
|
| } // namespace
|
|
|