Limit the maximum and minimum gain the IntelligibilityEnhancer can apply
Although the algorithm should generate the optimal gains, these limits are in place so that it doesn't go bananas in extreme noise situations or if there are some errors on the noise estimate. The limits were chosen as the extreme values from recordings with -3dB SNR, which is the minimum where the POLQA metric increases when processed. Review-Url: https://codereview.webrtc.org/1925933002 Cr-Commit-Position: refs/heads/master@{#12550}
This commit is contained in:
parent
11d4a42ce5
commit
4896aaa9e4
@ -22,16 +22,15 @@ namespace intelligibility {
|
||||
|
||||
namespace {
|
||||
|
||||
const float kMinFactor = 0.01f;
|
||||
const float kMaxFactor = 1000.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());
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user