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 3a9433b47684364f188da877275f548d928b7d80..3675f66cafef384a5b1450b2326730e637ecdf75 100644 |
--- a/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
+++ b/webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc |
@@ -22,16 +22,15 @@ namespace intelligibility { |
namespace { |
+const float kMinFactor = 0.01f; |
+const float kMaxFactor = 1000.f; |
peah-webrtc
2016/04/28 18:43:24
It is a bit weird to have a limit on the max and m
aluebs-webrtc
2016/04/28 20:05:23
I don't see why they should be symmetric.
|
+ |
// 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()); |
- if (gain < 1.f - limit) { |
- gain = 1.f - limit; |
- } else if (gain > 1.f + limit) { |
- gain = 1.f + limit; |
- } |
- return current * gain + 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);; |
} |
} // namespace |