| Index: webrtc/modules/audio_processing/aec3/suppression_gain.cc
 | 
| diff --git a/webrtc/modules/audio_processing/aec3/suppression_gain.cc b/webrtc/modules/audio_processing/aec3/suppression_gain.cc
 | 
| index a25f748edcced09b3c19496a401e400ba71119d1..8e78967e5c7c8165032fb9062bde93a1721ce35d 100644
 | 
| --- a/webrtc/modules/audio_processing/aec3/suppression_gain.cc
 | 
| +++ b/webrtc/modules/audio_processing/aec3/suppression_gain.cc
 | 
| @@ -109,6 +109,7 @@ float UpperBandsGain(
 | 
|  
 | 
|  // Limits the gain increase.
 | 
|  void UpdateMaxGainIncrease(
 | 
| +    const AudioProcessing::Config::EchoCanceller3& config,
 | 
|      size_t no_saturation_counter,
 | 
|      bool low_noise_render,
 | 
|      const std::array<float, kFftLengthBy2Plus1>& last_echo,
 | 
| @@ -123,27 +124,28 @@ void UpdateMaxGainIncrease(
 | 
|    float min_increasing;
 | 
|    float min_decreasing;
 | 
|  
 | 
| +  auto& param = config.param.gain_updates;
 | 
|    if (low_noise_render) {
 | 
| -    max_increasing = 8.f;
 | 
| -    max_decreasing = 8.f;
 | 
| -    rate_increasing = 2.f;
 | 
| -    rate_decreasing = 2.f;
 | 
| -    min_increasing = 4.f;
 | 
| -    min_decreasing = 4.f;
 | 
| +    max_increasing = param.low_noise.max_inc;
 | 
| +    max_decreasing = param.low_noise.max_dec;
 | 
| +    rate_increasing = param.low_noise.rate_inc;
 | 
| +    rate_decreasing = param.low_noise.rate_dec;
 | 
| +    min_increasing = param.low_noise.min_inc;
 | 
| +    min_decreasing = param.low_noise.min_dec;
 | 
|    } else if (no_saturation_counter > 10) {
 | 
| -    max_increasing = 4.f;
 | 
| -    max_decreasing = 4.f;
 | 
| -    rate_increasing = 2.f;
 | 
| -    rate_decreasing = 2.f;
 | 
| -    min_increasing = 1.2f;
 | 
| -    min_decreasing = 2.f;
 | 
| +    max_increasing = param.normal.max_inc;
 | 
| +    max_decreasing = param.normal.max_dec;
 | 
| +    rate_increasing = param.normal.rate_inc;
 | 
| +    rate_decreasing = param.normal.rate_dec;
 | 
| +    min_increasing = param.normal.min_inc;
 | 
| +    min_decreasing = param.normal.min_dec;
 | 
|    } else {
 | 
| -    max_increasing = 1.2f;
 | 
| -    max_decreasing = 1.2f;
 | 
| -    rate_increasing = 1.5f;
 | 
| -    rate_decreasing = 1.5f;
 | 
| -    min_increasing = 1.f;
 | 
| -    min_decreasing = 1.f;
 | 
| +    max_increasing = param.saturation.max_inc;
 | 
| +    max_decreasing = param.saturation.max_dec;
 | 
| +    rate_increasing = param.saturation.rate_inc;
 | 
| +    rate_decreasing = param.saturation.rate_dec;
 | 
| +    min_increasing = param.saturation.min_inc;
 | 
| +    min_decreasing = param.saturation.min_dec;
 | 
|    }
 | 
|  
 | 
|    for (size_t k = 0; k < new_gain.size(); ++k) {
 | 
| @@ -163,6 +165,7 @@ void UpdateMaxGainIncrease(
 | 
|  
 | 
|  // Computes the gain to reduce the echo to a non audible level.
 | 
|  void GainToNoAudibleEcho(
 | 
| +    const AudioProcessing::Config::EchoCanceller3& config,
 | 
|      bool low_noise_render,
 | 
|      bool saturated_echo,
 | 
|      const std::array<float, kFftLengthBy2Plus1>& nearend,
 | 
| @@ -172,16 +175,17 @@ void GainToNoAudibleEcho(
 | 
|      const std::array<float, kFftLengthBy2Plus1>& max_gain,
 | 
|      const std::array<float, kFftLengthBy2Plus1>& one_by_echo,
 | 
|      std::array<float, kFftLengthBy2Plus1>* gain) {
 | 
| -  constexpr float kEchoMaskingMargin = 1.f / 100.f;
 | 
|    const float nearend_masking_margin =
 | 
| -      low_noise_render ? 0.1f : (saturated_echo ? 0.001f : 0.01f);
 | 
| +      low_noise_render ? 0.1f
 | 
| +                       : (saturated_echo ? config.param.gain_mask.m2
 | 
| +                                         : config.param.gain_mask.m3);
 | 
|  
 | 
|    for (size_t k = 0; k < gain->size(); ++k) {
 | 
|      RTC_DCHECK_LE(0.f, nearend_masking_margin * nearend[k]);
 | 
|      if (echo[k] <= nearend_masking_margin * nearend[k]) {
 | 
|        (*gain)[k] = 1.f;
 | 
|      } else {
 | 
| -      (*gain)[k] = kEchoMaskingMargin * masker[k] * one_by_echo[k];
 | 
| +      (*gain)[k] = config.param.gain_mask.m1 * masker[k] * one_by_echo[k];
 | 
|      }
 | 
|  
 | 
|      (*gain)[k] = std::min(std::max((*gain)[k], min_gain[k]), max_gain[k]);
 | 
| @@ -189,7 +193,8 @@ void GainToNoAudibleEcho(
 | 
|  }
 | 
|  
 | 
|  // Computes the signal output power that masks the echo signal.
 | 
| -void MaskingPower(const std::array<float, kFftLengthBy2Plus1>& nearend,
 | 
| +void MaskingPower(const AudioProcessing::Config::EchoCanceller3& config,
 | 
| +                  const std::array<float, kFftLengthBy2Plus1>& nearend,
 | 
|                    const std::array<float, kFftLengthBy2Plus1>& comfort_noise,
 | 
|                    const std::array<float, kFftLengthBy2Plus1>& last_masker,
 | 
|                    const std::array<float, kFftLengthBy2Plus1>& gain,
 | 
| @@ -197,7 +202,8 @@ void MaskingPower(const std::array<float, kFftLengthBy2Plus1>& nearend,
 | 
|    std::array<float, kFftLengthBy2Plus1> side_band_masker;
 | 
|    for (size_t k = 0; k < gain.size(); ++k) {
 | 
|      side_band_masker[k] = nearend[k] * gain[k] + comfort_noise[k];
 | 
| -    (*masker)[k] = comfort_noise[k] + 0.1f * last_masker[k];
 | 
| +    (*masker)[k] =
 | 
| +        comfort_noise[k] + config.param.gain_mask.m4 * last_masker[k];
 | 
|    }
 | 
|    for (size_t k = 1; k < gain.size() - 1; ++k) {
 | 
|      (*masker)[k] += 0.1f * (side_band_masker[k - 1] + side_band_masker[k + 1]);
 | 
| @@ -227,7 +233,9 @@ void SuppressionGain::LowerBandGain(
 | 
|    // Compute the minimum gain as the attenuating gain to put the signal just
 | 
|    // above the zero sample values.
 | 
|    std::array<float, kFftLengthBy2Plus1> min_gain;
 | 
| -  const float min_echo_power = low_noise_render ? 192.f : 64.f;
 | 
| +  const float min_echo_power =
 | 
| +      low_noise_render ? config_.param.echo_audibility.low_render_limit
 | 
| +                       : config_.param.echo_audibility.normal_render_limit;
 | 
|    if (no_saturation_counter_ > 10) {
 | 
|      for (size_t k = 0; k < nearend.size(); ++k) {
 | 
|        const float denom = std::min(nearend[k], echo[k]);
 | 
| @@ -243,7 +251,9 @@ void SuppressionGain::LowerBandGain(
 | 
|    std::array<float, kFftLengthBy2Plus1> max_gain;
 | 
|    for (size_t k = 0; k < gain->size(); ++k) {
 | 
|      max_gain[k] =
 | 
| -        std::min(std::max(last_gain_[k] * gain_increase_[k], 0.001f), 1.f);
 | 
| +        std::min(std::max(last_gain_[k] * gain_increase_[k],
 | 
| +                          config_.param.gain_updates.floor_first_increase),
 | 
| +                 1.f);
 | 
|    }
 | 
|  
 | 
|    // Iteratively compute the gain required to attenuate the echo to a non
 | 
| @@ -251,9 +261,9 @@ void SuppressionGain::LowerBandGain(
 | 
|    gain->fill(0.f);
 | 
|    for (int k = 0; k < 2; ++k) {
 | 
|      std::array<float, kFftLengthBy2Plus1> masker;
 | 
| -    MaskingPower(nearend, comfort_noise, last_masker_, *gain, &masker);
 | 
| -    GainToNoAudibleEcho(low_noise_render, saturated_echo, nearend, echo, masker,
 | 
| -                        min_gain, max_gain, one_by_echo, gain);
 | 
| +    MaskingPower(config_, nearend, comfort_noise, last_masker_, *gain, &masker);
 | 
| +    GainToNoAudibleEcho(config_, low_noise_render, saturated_echo, nearend,
 | 
| +                        echo, masker, min_gain, max_gain, one_by_echo, gain);
 | 
|      AdjustForExternalFilters(gain);
 | 
|      if (narrow_peak_band) {
 | 
|        NarrowBandAttenuation(*narrow_peak_band, gain);
 | 
| @@ -261,18 +271,21 @@ void SuppressionGain::LowerBandGain(
 | 
|    }
 | 
|  
 | 
|    // Update the allowed maximum gain increase.
 | 
| -  UpdateMaxGainIncrease(no_saturation_counter_, low_noise_render, last_echo_,
 | 
| -                        echo, last_gain_, *gain, &gain_increase_);
 | 
| +  UpdateMaxGainIncrease(config_, no_saturation_counter_, low_noise_render,
 | 
| +                        last_echo_, echo, last_gain_, *gain, &gain_increase_);
 | 
|  
 | 
|    // Store data required for the gain computation of the next block.
 | 
|    std::copy(echo.begin(), echo.end(), last_echo_.begin());
 | 
|    std::copy(gain->begin(), gain->end(), last_gain_.begin());
 | 
| -  MaskingPower(nearend, comfort_noise, last_masker_, *gain, &last_masker_);
 | 
| +  MaskingPower(config_, nearend, comfort_noise, last_masker_, *gain,
 | 
| +               &last_masker_);
 | 
|    aec3::VectorMath(optimization_).Sqrt(*gain);
 | 
|  }
 | 
|  
 | 
| -SuppressionGain::SuppressionGain(Aec3Optimization optimization)
 | 
| -    : optimization_(optimization) {
 | 
| +SuppressionGain::SuppressionGain(
 | 
| +    const AudioProcessing::Config::EchoCanceller3& config,
 | 
| +    Aec3Optimization optimization)
 | 
| +    : optimization_(optimization), config_(config) {
 | 
|    last_gain_.fill(1.f);
 | 
|    last_masker_.fill(0.f);
 | 
|    gain_increase_.fill(1.f);
 | 
| 
 |