Open up for do the noise suppressor analysis on the linear AEC output
This CL allows the noise suppressor to use the linear AEC output for analysis whenever that is available. This will potentially lower the risk that the noise suppressor estimates the noise based on echo. The feature is off by default. Bug: webrtc:5298,b:132164318 Change-Id: Idc6c8e197d96209d213819d87a8fb2533b7303ec Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/162900 Reviewed-by: Sam Zackrisson <saza@webrtc.org> Commit-Queue: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30116}
This commit is contained in:
@ -1206,6 +1206,7 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() {
|
||||
1);
|
||||
|
||||
AudioBuffer* capture_buffer = capture_.capture_audio.get(); // For brevity.
|
||||
AudioBuffer* linear_aec_buffer = capture_.linear_aec_output.get();
|
||||
|
||||
if (submodules_.high_pass_filter &&
|
||||
config_.high_pass_filter.apply_in_full_band &&
|
||||
@ -1292,11 +1293,15 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() {
|
||||
RETURN_ON_ERR(submodules_.gain_control->AnalyzeCaptureAudio(*capture_buffer));
|
||||
RTC_DCHECK(
|
||||
!(submodules_.legacy_noise_suppressor && submodules_.noise_suppressor));
|
||||
|
||||
if (!config_.noise_suppression.analyze_linear_aec_output_when_available ||
|
||||
!linear_aec_buffer || submodules_.echo_control_mobile) {
|
||||
if (submodules_.noise_suppressor) {
|
||||
submodules_.noise_suppressor->Analyze(*capture_buffer);
|
||||
} else if (submodules_.legacy_noise_suppressor) {
|
||||
submodules_.legacy_noise_suppressor->AnalyzeCaptureAudio(capture_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
if (submodules_.echo_control_mobile) {
|
||||
// Ensure that the stream delay was set before the call to the
|
||||
@ -1322,11 +1327,20 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() {
|
||||
submodules_.echo_controller->SetAudioBufferDelay(stream_delay_ms());
|
||||
}
|
||||
|
||||
AudioBuffer* linear_aec_buffer = capture_.linear_aec_output.get();
|
||||
submodules_.echo_controller->ProcessCapture(
|
||||
capture_buffer, linear_aec_buffer, capture_.echo_path_gain_change);
|
||||
}
|
||||
|
||||
if (config_.noise_suppression.analyze_linear_aec_output_when_available &&
|
||||
linear_aec_buffer) {
|
||||
if (submodules_.noise_suppressor) {
|
||||
submodules_.noise_suppressor->Analyze(*linear_aec_buffer);
|
||||
} else if (submodules_.legacy_noise_suppressor) {
|
||||
submodules_.legacy_noise_suppressor->AnalyzeCaptureAudio(
|
||||
linear_aec_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
if (submodules_.noise_suppressor) {
|
||||
submodules_.noise_suppressor->Process(capture_buffer);
|
||||
} else if (submodules_.legacy_noise_suppressor) {
|
||||
|
@ -241,6 +241,7 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
|
||||
bool enabled = false;
|
||||
enum Level { kLow, kModerate, kHigh, kVeryHigh };
|
||||
Level level = kModerate;
|
||||
bool analyze_linear_aec_output_when_available = false;
|
||||
// Recommended not to use. Will be removed in the future.
|
||||
bool use_legacy_ns = false;
|
||||
} noise_suppression;
|
||||
|
@ -528,6 +528,10 @@ void AudioProcessingSimulator::CreateAudioProcessor() {
|
||||
apm_config.noise_suppression.level =
|
||||
static_cast<AudioProcessing::Config::NoiseSuppression::Level>(level);
|
||||
}
|
||||
if (settings_.ns_analysis_on_linear_aec_output) {
|
||||
apm_config.noise_suppression.analyze_linear_aec_output_when_available =
|
||||
*settings_.ns_analysis_on_linear_aec_output;
|
||||
}
|
||||
|
||||
RTC_CHECK(ap_builder_);
|
||||
if (echo_control_factory) {
|
||||
|
@ -75,6 +75,7 @@ struct SimulationSettings {
|
||||
agc2_adaptive_level_estimator;
|
||||
absl::optional<float> pre_amplifier_gain_factor;
|
||||
absl::optional<int> ns_level;
|
||||
absl::optional<bool> ns_analysis_on_linear_aec_output;
|
||||
absl::optional<int> maximum_internal_processing_rate;
|
||||
int initial_mic_level;
|
||||
bool simulate_mic_gain = false;
|
||||
|
@ -173,6 +173,11 @@ ABSL_FLAG(int,
|
||||
ns_level,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specify the NS level (0-3)");
|
||||
ABSL_FLAG(int,
|
||||
ns_analysis_on_linear_aec_output,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Specifies whether the noise suppression analysis is done on the "
|
||||
"linear AEC output");
|
||||
ABSL_FLAG(int,
|
||||
maximum_internal_processing_rate,
|
||||
kParameterNotSpecifiedValue,
|
||||
@ -402,6 +407,8 @@ SimulationSettings CreateSettings() {
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_pre_amplifier_gain_factor),
|
||||
&settings.pre_amplifier_gain_factor);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_ns_level), &settings.ns_level);
|
||||
SetSettingIfFlagSet(absl::GetFlag(FLAGS_ns_analysis_on_linear_aec_output),
|
||||
&settings.ns_analysis_on_linear_aec_output);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_maximum_internal_processing_rate),
|
||||
&settings.maximum_internal_processing_rate);
|
||||
SetSettingIfSpecified(absl::GetFlag(FLAGS_stream_delay),
|
||||
|
Reference in New Issue
Block a user