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

Unified Diff: webrtc/modules/audio_processing/intelligibility/intelligibility_utils.cc

Issue 1925933002: Limit the maximum and minimum gain the IntelligibilityEnhancer can apply (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698