Add ability to adjust the suppressor smoothing in AEC3
Bug: b/177359044 Change-Id: I5eddb6fa6f01aa14426161204e37a9097b182234 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217889 Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org> Commit-Queue: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34203}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
bd933ee29a
commit
cbdbb8c166
@ -230,16 +230,20 @@ void SuppressionGain::GetMinGain(
|
||||
min_gain[k] = std::min(min_gain[k], 1.f);
|
||||
}
|
||||
|
||||
const bool is_nearend_state = dominant_nearend_detector_->IsNearendState();
|
||||
for (size_t k = 0; k < 6; ++k) {
|
||||
const auto& dec = is_nearend_state ? nearend_params_.max_dec_factor_lf
|
||||
: normal_params_.max_dec_factor_lf;
|
||||
if (!initial_state_ ||
|
||||
config_.suppressor.lf_smoothing_during_initial_phase) {
|
||||
const float& dec = dominant_nearend_detector_->IsNearendState()
|
||||
? nearend_params_.max_dec_factor_lf
|
||||
: normal_params_.max_dec_factor_lf;
|
||||
|
||||
// Make sure the gains of the low frequencies do not decrease too
|
||||
// quickly after strong nearend.
|
||||
if (last_nearend[k] > last_echo[k]) {
|
||||
min_gain[k] = std::max(min_gain[k], last_gain_[k] * dec);
|
||||
min_gain[k] = std::min(min_gain[k], 1.f);
|
||||
for (int k = 0; k <= config_.suppressor.last_lf_smoothing_band; ++k) {
|
||||
// Make sure the gains of the low frequencies do not decrease too
|
||||
// quickly after strong nearend.
|
||||
if (last_nearend[k] > last_echo[k] ||
|
||||
k <= config_.suppressor.last_permanent_lf_smoothing_band) {
|
||||
min_gain[k] = std::max(min_gain[k], last_gain_[k] * dec);
|
||||
min_gain[k] = std::min(min_gain[k], 1.f);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -333,8 +337,12 @@ SuppressionGain::SuppressionGain(const EchoCanceller3Config& config,
|
||||
num_capture_channels_,
|
||||
aec3::MovingAverage(kFftLengthBy2Plus1,
|
||||
config.suppressor.nearend_average_blocks)),
|
||||
nearend_params_(config_.suppressor.nearend_tuning),
|
||||
normal_params_(config_.suppressor.normal_tuning) {
|
||||
nearend_params_(config_.suppressor.last_lf_band,
|
||||
config_.suppressor.first_hf_band,
|
||||
config_.suppressor.nearend_tuning),
|
||||
normal_params_(config_.suppressor.last_lf_band,
|
||||
config_.suppressor.first_hf_band,
|
||||
config_.suppressor.normal_tuning) {
|
||||
RTC_DCHECK_LT(0, state_change_duration_blocks_);
|
||||
last_gain_.fill(1.f);
|
||||
if (config_.suppressor.use_subband_nearend_detection) {
|
||||
@ -419,23 +427,23 @@ bool SuppressionGain::LowNoiseRenderDetector::Detect(
|
||||
}
|
||||
|
||||
SuppressionGain::GainParameters::GainParameters(
|
||||
int last_lf_band,
|
||||
int first_hf_band,
|
||||
const EchoCanceller3Config::Suppressor::Tuning& tuning)
|
||||
: max_inc_factor(tuning.max_inc_factor),
|
||||
max_dec_factor_lf(tuning.max_dec_factor_lf) {
|
||||
// Compute per-band masking thresholds.
|
||||
constexpr size_t kLastLfBand = 5;
|
||||
constexpr size_t kFirstHfBand = 8;
|
||||
RTC_DCHECK_LT(kLastLfBand, kFirstHfBand);
|
||||
RTC_DCHECK_LT(last_lf_band, first_hf_band);
|
||||
auto& lf = tuning.mask_lf;
|
||||
auto& hf = tuning.mask_hf;
|
||||
RTC_DCHECK_LT(lf.enr_transparent, lf.enr_suppress);
|
||||
RTC_DCHECK_LT(hf.enr_transparent, hf.enr_suppress);
|
||||
for (size_t k = 0; k < kFftLengthBy2Plus1; k++) {
|
||||
for (int k = 0; k < static_cast<int>(kFftLengthBy2Plus1); k++) {
|
||||
float a;
|
||||
if (k <= kLastLfBand) {
|
||||
if (k <= last_lf_band) {
|
||||
a = 0.f;
|
||||
} else if (k < kFirstHfBand) {
|
||||
a = (k - kLastLfBand) / static_cast<float>(kFirstHfBand - kLastLfBand);
|
||||
} else if (k < first_hf_band) {
|
||||
a = (k - last_lf_band) / static_cast<float>(first_hf_band - last_lf_band);
|
||||
} else {
|
||||
a = 1.f;
|
||||
}
|
||||
|
||||
@ -103,6 +103,8 @@ class SuppressionGain {
|
||||
|
||||
struct GainParameters {
|
||||
explicit GainParameters(
|
||||
int last_lf_band,
|
||||
int first_hf_band,
|
||||
const EchoCanceller3Config::Suppressor::Tuning& tuning);
|
||||
const float max_inc_factor;
|
||||
const float max_dec_factor_lf;
|
||||
|
||||
Reference in New Issue
Block a user