AEC3: Removing more dead code from the suppressor

This CL removes the UpdateGainIncrease code that is not used anymore.
The CL has been tested for bit exactness.

Bug: webrtc:8671
Change-Id: I4fcf26c3b4b5bba760ee139416ddefac86a36c2e
Reviewed-on: https://webrtc-review.googlesource.com/95940
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24425}
This commit is contained in:
Gustaf Ullberg
2018-08-24 11:27:23 +02:00
committed by Commit Bot
parent fc1acd2364
commit 41dd22b15d
4 changed files with 0 additions and 165 deletions

View File

@ -113,21 +113,6 @@ struct EchoCanceller3Config {
} render_levels;
struct GainUpdates {
struct GainChanges {
float max_inc;
float max_dec;
float rate_inc;
float rate_dec;
float min_inc;
float min_dec;
};
GainChanges low_noise = {2.f, 2.f, 1.4f, 1.4f, 1.1f, 1.1f};
GainChanges initial = {2.f, 2.f, 1.5f, 1.5f, 1.2f, 1.2f};
GainChanges normal = {2.f, 2.f, 1.5f, 1.5f, 1.2f, 1.2f};
GainChanges saturation = {1.2f, 1.2f, 1.5f, 1.5f, 1.f, 1.f};
GainChanges nonlinear = {1.5f, 1.5f, 1.2f, 1.2f, 1.1f, 1.1f};
float max_inc_factor = 2.0f;
float max_dec_factor_lf = 0.25f;
float floor_first_increase = 0.00001f;

View File

@ -11,12 +11,6 @@
#include "modules/audio_processing/aec3/suppression_gain.h"
// Defines WEBRTC_ARCH_X86_FAMILY, used below.
#include "rtc_base/system/arch.h"
#if defined(WEBRTC_ARCH_X86_FAMILY)
#include <emmintrin.h>
#endif
#include <math.h>
#include <algorithm>
#include <functional>
@ -320,10 +314,6 @@ void SuppressionGain::LowerBandGain(
// Adjust the gain for frequencies which have not yet converged.
AdjustNonConvergedFrequencies(gain);
// Update the allowed maximum gain increase.
UpdateGainIncrease(low_noise_render, linear_echo_estimate, saturated_echo,
weighted_echo, *gain);
// Store data required for the gain computation of the next block.
std::copy(nearend.begin(), nearend.end(), last_nearend_.begin());
std::copy(weighted_echo.begin(), weighted_echo.end(), last_echo_.begin());
@ -351,7 +341,6 @@ SuppressionGain::SuppressionGain(const EchoCanceller3Config& config,
RTC_DCHECK_LT(0, state_change_duration_blocks_);
one_by_state_change_duration_blocks_ = 1.f / state_change_duration_blocks_;
last_gain_.fill(1.f);
gain_increase_.fill(1.f);
last_nearend_.fill(0.f);
last_echo_.fill(0.f);
@ -436,102 +425,6 @@ void SuppressionGain::SetInitialState(bool state) {
}
}
void SuppressionGain::UpdateGainIncrease(
bool low_noise_render,
bool linear_echo_estimate,
bool saturated_echo,
const std::array<float, kFftLengthBy2Plus1>& echo,
const std::array<float, kFftLengthBy2Plus1>& new_gain) {
float max_inc;
float max_dec;
float rate_inc;
float rate_dec;
float min_inc;
float min_dec;
RTC_DCHECK_GE(state_change_duration_blocks_, initial_state_change_counter_);
if (initial_state_change_counter_ > 0) {
if (--initial_state_change_counter_ == 0) {
initial_state_ = false;
}
}
RTC_DCHECK_LE(0, initial_state_change_counter_);
// EchoCanceller3Config::GainUpdates
auto& p = config_.gain_updates;
if (!linear_echo_estimate) {
max_inc = p.nonlinear.max_inc;
max_dec = p.nonlinear.max_dec;
rate_inc = p.nonlinear.rate_inc;
rate_dec = p.nonlinear.rate_dec;
min_inc = p.nonlinear.min_inc;
min_dec = p.nonlinear.min_dec;
} else if (initial_state_ && !saturated_echo) {
if (initial_state_change_counter_ > 0) {
float change_factor =
initial_state_change_counter_ * one_by_state_change_duration_blocks_;
auto average = [](float from, float to, float from_weight) {
return from * from_weight + to * (1.f - from_weight);
};
max_inc = average(p.initial.max_inc, p.normal.max_inc, change_factor);
max_dec = average(p.initial.max_dec, p.normal.max_dec, change_factor);
rate_inc = average(p.initial.rate_inc, p.normal.rate_inc, change_factor);
rate_dec = average(p.initial.rate_dec, p.normal.rate_dec, change_factor);
min_inc = average(p.initial.min_inc, p.normal.min_inc, change_factor);
min_dec = average(p.initial.min_dec, p.normal.min_dec, change_factor);
} else {
max_inc = p.initial.max_inc;
max_dec = p.initial.max_dec;
rate_inc = p.initial.rate_inc;
rate_dec = p.initial.rate_dec;
min_inc = p.initial.min_inc;
min_dec = p.initial.min_dec;
}
} else if (low_noise_render) {
max_inc = p.low_noise.max_inc;
max_dec = p.low_noise.max_dec;
rate_inc = p.low_noise.rate_inc;
rate_dec = p.low_noise.rate_dec;
min_inc = p.low_noise.min_inc;
min_dec = p.low_noise.min_dec;
} else if (!saturated_echo) {
max_inc = p.normal.max_inc;
max_dec = p.normal.max_dec;
rate_inc = p.normal.rate_inc;
rate_dec = p.normal.rate_dec;
min_inc = p.normal.min_inc;
min_dec = p.normal.min_dec;
} else {
max_inc = p.saturation.max_inc;
max_dec = p.saturation.max_dec;
rate_inc = p.saturation.rate_inc;
rate_dec = p.saturation.rate_dec;
min_inc = p.saturation.min_inc;
min_dec = p.saturation.min_dec;
}
for (size_t k = 0; k < new_gain.size(); ++k) {
auto increase_update = [](float new_gain, float last_gain,
float current_inc, float max_inc, float min_inc,
float change_rate) {
return new_gain > last_gain ? std::min(max_inc, current_inc * change_rate)
: min_inc;
};
if (echo[k] > last_echo_[k]) {
gain_increase_[k] =
increase_update(new_gain[k], last_gain_[k], gain_increase_[k],
max_inc, min_inc, rate_inc);
} else {
gain_increase_[k] =
increase_update(new_gain[k], last_gain_[k], gain_increase_[k],
max_dec, min_dec, rate_dec);
}
}
}
// Detects when the render signal can be considered to have low power and
// consist of stationary noise.
bool SuppressionGain::LowNoiseRenderDetector::Detect(

View File

@ -60,14 +60,6 @@ class SuppressionGain {
const std::array<float, kFftLengthBy2Plus1>& comfort_noise,
std::array<float, kFftLengthBy2Plus1>* gain);
// Limits the gain increase.
void UpdateGainIncrease(
bool low_noise_render,
bool linear_echo_estimate,
bool saturated_echo,
const std::array<float, kFftLengthBy2Plus1>& echo,
const std::array<float, kFftLengthBy2Plus1>& new_gain);
class LowNoiseRenderDetector {
public:
bool Detect(const std::vector<std::vector<float>>& render);
@ -83,7 +75,6 @@ class SuppressionGain {
const int state_change_duration_blocks_;
float one_by_state_change_duration_blocks_;
std::array<float, kFftLengthBy2Plus1> last_gain_;
std::array<float, kFftLengthBy2Plus1> gain_increase_;
std::array<float, kFftLengthBy2Plus1> last_nearend_;
std::array<float, kFftLengthBy2Plus1> last_echo_;
std::array<float, kFftLengthBy2Plus1> enr_transparent_;

View File

@ -152,35 +152,6 @@ class Aec3ParametersParser {
}
}
void ReadParam(const Json::Value& root,
std::string param_name,
EchoCanceller3Config::GainUpdates::GainChanges* param) const {
RTC_CHECK(param);
Json::Value json_array;
if (rtc::GetValueFromJsonObject(root, param_name, &json_array)) {
std::vector<double> v;
rtc::JsonArrayToDoubleVector(json_array, &v);
if (v.size() != 6) {
std::cout << "Incorrect array size for " << param_name << std::endl;
RTC_CHECK(false);
}
param->max_inc = static_cast<float>(v[0]);
param->max_dec = static_cast<float>(v[1]);
param->rate_inc = static_cast<float>(v[2]);
param->rate_dec = static_cast<float>(v[3]);
param->min_inc = static_cast<float>(v[4]);
param->min_dec = static_cast<float>(v[5]);
if (verbose_output_) {
std::cout << param_name << ":"
<< "[" << param->max_inc << "," << param->max_dec << ","
<< param->rate_inc << "," << param->rate_dec << ","
<< param->min_inc << "," << param->min_dec << "]"
<< std::endl;
}
}
}
void ReadParam(
const Json::Value& root,
std::string param_name,
@ -320,11 +291,6 @@ class Aec3ParametersParser {
}
if (rtc::GetValueFromJsonObject(root, "gain_updates", &section)) {
ReadParam(section, "low_noise", &cfg.gain_updates.low_noise);
ReadParam(section, "initial", &cfg.gain_updates.initial);
ReadParam(section, "normal", &cfg.gain_updates.normal);
ReadParam(section, "saturation", &cfg.gain_updates.saturation);
ReadParam(section, "nonlinear", &cfg.gain_updates.nonlinear);
ReadParam(section, "max_inc_factor", &cfg.gain_updates.max_inc_factor);
ReadParam(section, "max_dec_factor_lf",
&cfg.gain_updates.max_dec_factor_lf);