AEC3: Reseting the ERLE at pre-amplifier gain changes
In this CL the ERLE estimator is reset after a pre-amplifier gain change is communicated to APM. Bug: webrtc:9805 Change-Id: I040f344e4607e862240250f9478d06de0d58a096 Reviewed-on: https://webrtc-review.googlesource.com/103222 Commit-Queue: Per Åhgren <peah@webrtc.org> Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org> Reviewed-by: Alex Loiko <aleloi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24933}
This commit is contained in:
@ -26,6 +26,10 @@
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
bool EnableErleResetsAtGainChanges() {
|
||||
return !field_trial::IsEnabled("WebRTC-Aec3ResetErleAtGainChangesKillSwitch");
|
||||
}
|
||||
|
||||
float ComputeGainRampupIncrease(const EchoCanceller3Config& config) {
|
||||
const auto& c = config.echo_removal_control.gain_rampup;
|
||||
return powf(1.f / c.first_non_zero_gain, 1.f / c.non_zero_gain_blocks);
|
||||
@ -52,7 +56,8 @@ AecState::AecState(const EchoCanceller3Config& config)
|
||||
kBlocksSinceConsistentEstimateInit),
|
||||
echo_audibility_(
|
||||
config.echo_audibility.use_stationarity_properties_at_init),
|
||||
reverb_model_estimator_(config) {}
|
||||
reverb_model_estimator_(config),
|
||||
enable_erle_resets_at_gain_changes_(EnableErleResetsAtGainChanges()) {}
|
||||
|
||||
AecState::~AecState() = default;
|
||||
|
||||
@ -87,7 +92,10 @@ void AecState::HandleEchoPathChange(
|
||||
EchoPathVariability::DelayAdjustment::kNone) {
|
||||
full_reset();
|
||||
}
|
||||
|
||||
if (enable_erle_resets_at_gain_changes_ &&
|
||||
echo_path_variability.gain_change) {
|
||||
erle_estimator_.Reset();
|
||||
}
|
||||
subtractor_output_analyzer_.HandleEchoPathChange();
|
||||
}
|
||||
|
||||
|
@ -207,6 +207,7 @@ class AecState {
|
||||
EchoAudibility echo_audibility_;
|
||||
ReverbModelEstimator reverb_model_estimator_;
|
||||
SubtractorOutputAnalyzer subtractor_output_analyzer_;
|
||||
bool enable_erle_resets_at_gain_changes_ = true;
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(AecState);
|
||||
};
|
||||
|
||||
|
@ -20,6 +20,7 @@ class GainApplier {
|
||||
|
||||
void ApplyGain(AudioFrameView<float> signal);
|
||||
void SetGainFactor(float gain_factor);
|
||||
float GetGainFactor() const { return current_gain_factor_; };
|
||||
|
||||
private:
|
||||
void Initialize(size_t samples_per_channel);
|
||||
|
@ -30,7 +30,14 @@
|
||||
#include "modules/audio_processing/gain_control_for_experimental_agc.h"
|
||||
#include "modules/audio_processing/gain_control_impl.h"
|
||||
#include "modules/audio_processing/gain_controller2.h"
|
||||
#include "modules/audio_processing/level_estimator_impl.h"
|
||||
#include "modules/audio_processing/logging/apm_data_dumper.h"
|
||||
#include "modules/audio_processing/low_cut_filter.h"
|
||||
#include "modules/audio_processing/noise_suppression_impl.h"
|
||||
#include "modules/audio_processing/residual_echo_detector.h"
|
||||
#include "modules/audio_processing/transient/transient_suppressor.h"
|
||||
#include "modules/audio_processing/voice_detection_impl.h"
|
||||
#include "rtc_base/atomicops.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/platform_file.h"
|
||||
@ -38,13 +45,6 @@
|
||||
#include "rtc_base/system/arch.h"
|
||||
#include "rtc_base/timeutils.h"
|
||||
#include "rtc_base/trace_event.h"
|
||||
#include "modules/audio_processing/level_estimator_impl.h"
|
||||
#include "modules/audio_processing/low_cut_filter.h"
|
||||
#include "modules/audio_processing/noise_suppression_impl.h"
|
||||
#include "modules/audio_processing/residual_echo_detector.h"
|
||||
#include "modules/audio_processing/transient/transient_suppressor.h"
|
||||
#include "modules/audio_processing/voice_detection_impl.h"
|
||||
#include "rtc_base/atomicops.h"
|
||||
#include "system_wrappers/include/metrics.h"
|
||||
|
||||
#define RETURN_ON_ERR(expr) \
|
||||
@ -1224,6 +1224,15 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() {
|
||||
capture_.prev_analog_mic_level != -1;
|
||||
capture_.prev_analog_mic_level = analog_mic_level;
|
||||
|
||||
// Detect and flag any change in the pre-amplifier gain.
|
||||
if (private_submodules_->pre_amplifier) {
|
||||
float pre_amp_gain = private_submodules_->pre_amplifier->GetGainFactor();
|
||||
capture_.echo_path_gain_change =
|
||||
capture_.echo_path_gain_change ||
|
||||
(capture_.prev_pre_amp_gain != pre_amp_gain &&
|
||||
capture_.prev_pre_amp_gain < 0.f);
|
||||
capture_.prev_pre_amp_gain = pre_amp_gain;
|
||||
}
|
||||
private_submodules_->echo_controller->AnalyzeCapture(capture_buffer);
|
||||
}
|
||||
|
||||
@ -1785,7 +1794,6 @@ bool AudioProcessingImpl::UpdateActiveSubmoduleStates() {
|
||||
capture_.transient_suppressor_enabled);
|
||||
}
|
||||
|
||||
|
||||
void AudioProcessingImpl::InitializeTransient() {
|
||||
if (capture_.transient_suppressor_enabled) {
|
||||
if (!public_submodules_->transient_suppressor.get()) {
|
||||
@ -2062,7 +2070,8 @@ AudioProcessingImpl::ApmCaptureState::ApmCaptureState(
|
||||
capture_processing_format(kSampleRate16kHz),
|
||||
split_rate(kSampleRate16kHz),
|
||||
echo_path_gain_change(false),
|
||||
prev_analog_mic_level(-1) {}
|
||||
prev_analog_mic_level(-1),
|
||||
prev_pre_amp_gain(-1.f) {}
|
||||
|
||||
AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default;
|
||||
|
||||
|
@ -397,6 +397,7 @@ class AudioProcessingImpl : public AudioProcessing {
|
||||
int split_rate;
|
||||
bool echo_path_gain_change;
|
||||
int prev_analog_mic_level;
|
||||
float prev_pre_amp_gain;
|
||||
} capture_ RTC_GUARDED_BY(crit_capture_);
|
||||
|
||||
struct ApmCaptureNonLockedState {
|
||||
|
Reference in New Issue
Block a user