#include "modules/audio_processing/aec3/suppression_gain.h"
#include <math.h>
#include <stddef.h>
#include <algorithm>
#include <numeric>
#include "modules/audio_processing/aec3/dominant_nearend_detector.h"
#include "modules/audio_processing/aec3/moving_average.h"
#include "modules/audio_processing/aec3/subband_nearend_detector.h"
#include "modules/audio_processing/aec3/vector_math.h"
#include "modules/audio_processing/logging/apm_data_dumper.h"
#include "rtc_base/checks.h"
#include "system_wrappers/include/field_trial.h"
namespace webrtc {
namespace {
void LimitLowFrequencyGains(std::array<float, kFftLengthBy2Plus1>* gain) { … }
void LimitHighFrequencyGains(bool conservative_hf_suppression,
std::array<float, kFftLengthBy2Plus1>* gain) { … }
void WeightEchoForAudibility(const EchoCanceller3Config& config,
rtc::ArrayView<const float> echo,
rtc::ArrayView<float> weighted_echo) { … }
}
std::atomic<int> SuppressionGain::instance_count_(0);
float SuppressionGain::UpperBandsGain(
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>> echo_spectrum,
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>>
comfort_noise_spectrum,
const absl::optional<int>& narrow_peak_band,
bool saturated_echo,
const Block& render,
const std::array<float, kFftLengthBy2Plus1>& low_band_gain) const { … }
void SuppressionGain::GainToNoAudibleEcho(
const std::array<float, kFftLengthBy2Plus1>& nearend,
const std::array<float, kFftLengthBy2Plus1>& echo,
const std::array<float, kFftLengthBy2Plus1>& masker,
std::array<float, kFftLengthBy2Plus1>* gain) const { … }
void SuppressionGain::GetMinGain(
rtc::ArrayView<const float> weighted_residual_echo,
rtc::ArrayView<const float> last_nearend,
rtc::ArrayView<const float> last_echo,
bool low_noise_render,
bool saturated_echo,
rtc::ArrayView<float> min_gain) const { … }
void SuppressionGain::GetMaxGain(rtc::ArrayView<float> max_gain) const { … }
void SuppressionGain::LowerBandGain(
bool low_noise_render,
const AecState& aec_state,
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>>
suppressor_input,
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>> residual_echo,
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>> comfort_noise,
bool clock_drift,
std::array<float, kFftLengthBy2Plus1>* gain) { … }
SuppressionGain::SuppressionGain(const EchoCanceller3Config& config,
Aec3Optimization optimization,
int sample_rate_hz,
size_t num_capture_channels)
: … { … }
SuppressionGain::~SuppressionGain() = default;
void SuppressionGain::GetGain(
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>>
nearend_spectrum,
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>> echo_spectrum,
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>>
residual_echo_spectrum,
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>>
residual_echo_spectrum_unbounded,
rtc::ArrayView<const std::array<float, kFftLengthBy2Plus1>>
comfort_noise_spectrum,
const RenderSignalAnalyzer& render_signal_analyzer,
const AecState& aec_state,
const Block& render,
bool clock_drift,
float* high_bands_gain,
std::array<float, kFftLengthBy2Plus1>* low_band_gain) { … }
void SuppressionGain::SetInitialState(bool state) { … }
bool SuppressionGain::LowNoiseRenderDetector::Detect(const Block& render) { … }
SuppressionGain::GainParameters::GainParameters(
int last_lf_band,
int first_hf_band,
const EchoCanceller3Config::Suppressor::Tuning& tuning)
: … { … }
}