Make AEC3 the default desktop AEC option in WebRTC
Bug: webrtc:10366 Change-Id: I854ed62df1da489fdab43e9157dff79b7287cacb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/125081 Reviewed-by: Sam Zackrisson <saza@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26983}
This commit is contained in:
parent
359c9b958e
commit
200feba1c0
@ -57,15 +57,33 @@ rtc_source_set("api") {
|
||||
"../../rtc_base:macromagic",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"../../rtc_base/system:rtc_export",
|
||||
"//third_party/abseil-cpp/absl/memory:memory",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_static_library("audio_buffer") {
|
||||
visibility = [ "*" ]
|
||||
|
||||
configs += [ ":apm_debug_dump" ]
|
||||
|
||||
sources = [
|
||||
"audio_buffer_placeholder.cc",
|
||||
"audio_buffer_placeholder.h",
|
||||
"audio_buffer.cc",
|
||||
"audio_buffer.h",
|
||||
"splitting_filter.cc",
|
||||
"splitting_filter.h",
|
||||
"three_band_filter_bank.cc",
|
||||
"three_band_filter_bank.h",
|
||||
]
|
||||
|
||||
defines = []
|
||||
|
||||
deps = [
|
||||
":api",
|
||||
"../../api/audio:audio_frame_api",
|
||||
"../../common_audio:common_audio",
|
||||
"../../common_audio:common_audio_c",
|
||||
"../../rtc_base:checks",
|
||||
]
|
||||
}
|
||||
|
||||
@ -73,8 +91,6 @@ rtc_static_library("audio_processing") {
|
||||
visibility = [ "*" ]
|
||||
configs += [ ":apm_debug_dump" ]
|
||||
sources = [
|
||||
"audio_buffer.cc",
|
||||
"audio_buffer.h",
|
||||
"audio_processing_impl.cc",
|
||||
"audio_processing_impl.h",
|
||||
"common.h",
|
||||
@ -109,10 +125,6 @@ rtc_static_library("audio_processing") {
|
||||
"residual_echo_detector.h",
|
||||
"rms_level.cc",
|
||||
"rms_level.h",
|
||||
"splitting_filter.cc",
|
||||
"splitting_filter.h",
|
||||
"three_band_filter_bank.cc",
|
||||
"three_band_filter_bank.h",
|
||||
"transient/common.h",
|
||||
"transient/daubechies_8_wavelet_coeffs.h",
|
||||
"transient/dyadic_decimator.h",
|
||||
@ -164,6 +176,7 @@ rtc_static_library("audio_processing") {
|
||||
"../../system_wrappers:metrics",
|
||||
"aec:aec",
|
||||
"aec:aec_core",
|
||||
"aec3:aec3",
|
||||
"aecm:aecm_core",
|
||||
"agc",
|
||||
"agc:agc_legacy_c",
|
||||
@ -171,6 +184,7 @@ rtc_static_library("audio_processing") {
|
||||
"agc2:fixed_digital",
|
||||
"agc2:gain_applier",
|
||||
"vad",
|
||||
"//third_party/abseil-cpp/absl/memory:memory",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
|
||||
|
||||
@ -133,7 +133,7 @@ rtc_static_library("aec3") {
|
||||
|
||||
deps = [
|
||||
"..:apm_logging",
|
||||
"..:audio_processing",
|
||||
"..:audio_buffer",
|
||||
"../../../api:array_view",
|
||||
"../../../api/audio:aec3_config",
|
||||
"../../../api/audio:echo_control",
|
||||
@ -169,6 +169,7 @@ if (rtc_include_tests) {
|
||||
deps = [
|
||||
":aec3",
|
||||
"..:apm_logging",
|
||||
"..:audio_buffer",
|
||||
"..:audio_processing",
|
||||
"..:audio_processing_unittests",
|
||||
"../../../api:array_view",
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
#include "api/audio/audio_frame.h"
|
||||
#include "common_audio/channel_buffer.h"
|
||||
#include "modules/audio_processing/include/audio_processing.h"
|
||||
#include "rtc_base/gtest_prod_util.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "modules/audio_processing/audio_buffer_placeholder.h"
|
||||
|
||||
// TODO(peah): Remove this file once the audio buffer has been moved to the
|
||||
// audio_buffer build target. The purpose of this file is to ensure that the
|
||||
// audio_buffer build target is not empty as that causes the compiler to
|
||||
// complain.
|
||||
@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef MODULES_AUDIO_PROCESSING_AUDIO_BUFFER_PLACEHOLDER_H_
|
||||
#define MODULES_AUDIO_PROCESSING_AUDIO_BUFFER_PLACEHOLDER_H_
|
||||
|
||||
// TODO(peah): Remove this file once the audio buffer has been moved to the
|
||||
// audio_buffer build target. The purpose of this file is to ensure that the
|
||||
// audio_buffer build target is not empty as that causes the compiler to
|
||||
// complain.
|
||||
struct AudioBufferPlaceholder {
|
||||
public:
|
||||
int dummy;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif // MODULES_AUDIO_PROCESSING_AUDIO_BUFFER_PLACEHOLDER_H_
|
||||
@ -16,10 +16,12 @@
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "common_audio/audio_converter.h"
|
||||
#include "common_audio/include/audio_util.h"
|
||||
#include "modules/audio_processing/aec3/echo_canceller3.h"
|
||||
#include "modules/audio_processing/agc/agc_manager_direct.h"
|
||||
#include "modules/audio_processing/agc2/gain_applier.h"
|
||||
#include "modules/audio_processing/audio_buffer.h"
|
||||
@ -669,17 +671,20 @@ void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
|
||||
rtc::CritScope cs_render(&crit_render_);
|
||||
rtc::CritScope cs_capture(&crit_capture_);
|
||||
|
||||
const bool aec_config_changed =
|
||||
config_.echo_canceller.enabled != config.echo_canceller.enabled ||
|
||||
config_.echo_canceller.use_legacy_aec !=
|
||||
config.echo_canceller.use_legacy_aec ||
|
||||
config_.echo_canceller.mobile_mode != config.echo_canceller.mobile_mode ||
|
||||
(config_.echo_canceller.enabled && config.echo_canceller.use_legacy_aec &&
|
||||
config_.echo_canceller.legacy_moderate_suppression_level !=
|
||||
config.echo_canceller.legacy_moderate_suppression_level);
|
||||
|
||||
config_ = config;
|
||||
|
||||
private_submodules_->echo_cancellation->Enable(
|
||||
config_.echo_canceller.enabled && !config_.echo_canceller.mobile_mode);
|
||||
private_submodules_->echo_control_mobile->Enable(
|
||||
config_.echo_canceller.enabled && config_.echo_canceller.mobile_mode);
|
||||
|
||||
private_submodules_->echo_cancellation->set_suppression_level(
|
||||
config.echo_canceller.legacy_moderate_suppression_level
|
||||
? EchoCancellationImpl::SuppressionLevel::kModerateSuppression
|
||||
: EchoCancellationImpl::SuppressionLevel::kHighSuppression);
|
||||
if (aec_config_changed) {
|
||||
InitializeEchoController();
|
||||
}
|
||||
|
||||
public_submodules_->noise_suppression->Enable(
|
||||
config.noise_suppression.enabled);
|
||||
@ -1342,6 +1347,7 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() {
|
||||
capture_buffer->split_bands_const(0)[kBand0To8kHz],
|
||||
capture_buffer->num_frames_per_band(), capture_nonlocked_.split_rate);
|
||||
}
|
||||
// TODO(peah): Add reporting from AEC3 whether there is echo.
|
||||
RETURN_ON_ERR(public_submodules_->gain_control->ProcessCaptureAudio(
|
||||
capture_buffer,
|
||||
private_submodules_->echo_cancellation->stream_has_echo()));
|
||||
@ -1770,11 +1776,31 @@ void AudioProcessingImpl::InitializeLowCutFilter() {
|
||||
}
|
||||
|
||||
void AudioProcessingImpl::InitializeEchoController() {
|
||||
if (echo_control_factory_) {
|
||||
private_submodules_->echo_controller =
|
||||
echo_control_factory_->Create(proc_sample_rate_hz());
|
||||
if (echo_control_factory_ ||
|
||||
(config_.echo_canceller.enabled && !config_.echo_canceller.mobile_mode &&
|
||||
!config_.echo_canceller.use_legacy_aec)) {
|
||||
if (echo_control_factory_) {
|
||||
private_submodules_->echo_controller =
|
||||
echo_control_factory_->Create(proc_sample_rate_hz());
|
||||
} else {
|
||||
private_submodules_->echo_controller = absl::make_unique<EchoCanceller3>(
|
||||
EchoCanceller3Config(), proc_sample_rate_hz(), true);
|
||||
}
|
||||
|
||||
capture_nonlocked_.echo_controller_enabled = true;
|
||||
} else {
|
||||
private_submodules_->echo_cancellation->Enable(
|
||||
config_.echo_canceller.enabled && !config_.echo_canceller.mobile_mode);
|
||||
private_submodules_->echo_control_mobile->Enable(
|
||||
config_.echo_canceller.enabled && config_.echo_canceller.mobile_mode);
|
||||
|
||||
private_submodules_->echo_cancellation->set_suppression_level(
|
||||
config_.echo_canceller.legacy_moderate_suppression_level
|
||||
? EchoCancellationImpl::SuppressionLevel::kModerateSuppression
|
||||
: EchoCancellationImpl::SuppressionLevel::kHighSuppression);
|
||||
|
||||
private_submodules_->echo_controller.reset();
|
||||
capture_nonlocked_.echo_controller_enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1915,7 +1941,7 @@ void AudioProcessingImpl::WriteAecDumpConfigMessage(bool forced) {
|
||||
|
||||
InternalAPMConfig apm_config;
|
||||
|
||||
apm_config.aec_enabled = private_submodules_->echo_cancellation->is_enabled();
|
||||
apm_config.aec_enabled = config_.echo_canceller.enabled;
|
||||
apm_config.aec_delay_agnostic_enabled =
|
||||
private_submodules_->echo_cancellation->is_delay_agnostic_enabled();
|
||||
apm_config.aec_drift_compensation_enabled =
|
||||
|
||||
@ -182,10 +182,11 @@ void EnableAllAPComponents(AudioProcessing* ap) {
|
||||
apm_config.echo_canceller.enabled = true;
|
||||
#if defined(WEBRTC_AUDIOPROC_FIXED_PROFILE)
|
||||
apm_config.echo_canceller.mobile_mode = true;
|
||||
|
||||
EXPECT_NOERR(ap->gain_control()->set_mode(GainControl::kAdaptiveDigital));
|
||||
EXPECT_NOERR(ap->gain_control()->Enable(true));
|
||||
#elif defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE)
|
||||
// TODO(peah): Update tests to instead use AEC3.
|
||||
apm_config.echo_canceller.use_legacy_aec = true;
|
||||
apm_config.echo_canceller.mobile_mode = false;
|
||||
apm_config.echo_canceller.legacy_moderate_suppression_level = true;
|
||||
|
||||
@ -720,28 +721,24 @@ void ApmTest::StreamParametersTest(Format format) {
|
||||
|
||||
// -- Missing delay --
|
||||
EXPECT_EQ(apm_->kNoError, ProcessStreamChooser(format));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError,
|
||||
ProcessStreamChooser(format));
|
||||
EXPECT_EQ(apm_->kNoError, ProcessStreamChooser(format));
|
||||
|
||||
// Resets after successful ProcessStream().
|
||||
EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(100));
|
||||
EXPECT_EQ(apm_->kNoError, ProcessStreamChooser(format));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError,
|
||||
ProcessStreamChooser(format));
|
||||
EXPECT_EQ(apm_->kNoError, ProcessStreamChooser(format));
|
||||
|
||||
// Other stream parameters set correctly.
|
||||
EXPECT_EQ(apm_->kNoError, apm_->gain_control()->Enable(true));
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
apm_->gain_control()->set_stream_analog_level(127));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError,
|
||||
ProcessStreamChooser(format));
|
||||
EXPECT_EQ(apm_->kNoError, ProcessStreamChooser(format));
|
||||
EXPECT_EQ(apm_->kNoError, apm_->gain_control()->Enable(false));
|
||||
|
||||
// -- No stream parameters --
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
AnalyzeReverseStreamChooser(format));
|
||||
EXPECT_EQ(apm_->kStreamParameterNotSetError,
|
||||
ProcessStreamChooser(format));
|
||||
EXPECT_EQ(apm_->kNoError, ProcessStreamChooser(format));
|
||||
|
||||
// -- All there --
|
||||
EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(100));
|
||||
@ -873,6 +870,8 @@ TEST_F(ApmTest, DISABLED_EchoCancellationReportsCorrectDelays) {
|
||||
// Enable AEC only.
|
||||
AudioProcessing::Config apm_config = apm_->GetConfig();
|
||||
apm_config.echo_canceller.enabled = true;
|
||||
// TODO(peah): Update tests to instead use AEC3.
|
||||
apm_config.echo_canceller.use_legacy_aec = true;
|
||||
apm_config.echo_canceller.mobile_mode = false;
|
||||
apm_->ApplyConfig(apm_config);
|
||||
Config config;
|
||||
@ -1430,6 +1429,8 @@ TEST_F(ApmTest, SplittingFilter) {
|
||||
// Check the test is valid. We should have distortion from the filter
|
||||
// when AEC is enabled (which won't affect the audio).
|
||||
apm_config.echo_canceller.enabled = true;
|
||||
// TODO(peah): Update tests to instead use AEC3.
|
||||
apm_config.echo_canceller.use_legacy_aec = true;
|
||||
apm_config.echo_canceller.mobile_mode = false;
|
||||
apm_->ApplyConfig(apm_config);
|
||||
frame_->samples_per_channel_ = 320;
|
||||
@ -2443,11 +2444,11 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
std::make_tuple(44100, 16000, 16000, 16000, 25, 0),
|
||||
|
||||
std::make_tuple(32000, 48000, 48000, 48000, 30, 0),
|
||||
std::make_tuple(32000, 48000, 32000, 48000, 35, 30),
|
||||
std::make_tuple(32000, 48000, 32000, 48000, 32, 30),
|
||||
std::make_tuple(32000, 48000, 16000, 48000, 30, 20),
|
||||
std::make_tuple(32000, 44100, 48000, 44100, 20, 20),
|
||||
std::make_tuple(32000, 44100, 32000, 44100, 20, 15),
|
||||
std::make_tuple(32000, 44100, 16000, 44100, 20, 15),
|
||||
std::make_tuple(32000, 44100, 48000, 44100, 19, 20),
|
||||
std::make_tuple(32000, 44100, 32000, 44100, 19, 15),
|
||||
std::make_tuple(32000, 44100, 16000, 44100, 19, 15),
|
||||
std::make_tuple(32000, 32000, 48000, 32000, 40, 35),
|
||||
std::make_tuple(32000, 32000, 32000, 32000, 0, 0),
|
||||
std::make_tuple(32000, 32000, 16000, 32000, 40, 20),
|
||||
@ -2455,16 +2456,16 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
std::make_tuple(32000, 16000, 32000, 16000, 25, 20),
|
||||
std::make_tuple(32000, 16000, 16000, 16000, 25, 0),
|
||||
|
||||
std::make_tuple(16000, 48000, 48000, 48000, 25, 0),
|
||||
std::make_tuple(16000, 48000, 32000, 48000, 25, 30),
|
||||
std::make_tuple(16000, 48000, 16000, 48000, 25, 20),
|
||||
std::make_tuple(16000, 48000, 48000, 48000, 24, 0),
|
||||
std::make_tuple(16000, 48000, 32000, 48000, 24, 30),
|
||||
std::make_tuple(16000, 48000, 16000, 48000, 24, 20),
|
||||
std::make_tuple(16000, 44100, 48000, 44100, 15, 20),
|
||||
std::make_tuple(16000, 44100, 32000, 44100, 15, 15),
|
||||
std::make_tuple(16000, 44100, 16000, 44100, 15, 15),
|
||||
std::make_tuple(16000, 32000, 48000, 32000, 25, 35),
|
||||
std::make_tuple(16000, 32000, 32000, 32000, 25, 0),
|
||||
std::make_tuple(16000, 32000, 16000, 32000, 25, 20),
|
||||
std::make_tuple(16000, 16000, 48000, 16000, 40, 20),
|
||||
std::make_tuple(16000, 16000, 48000, 16000, 39, 20),
|
||||
std::make_tuple(16000, 16000, 32000, 16000, 40, 20),
|
||||
std::make_tuple(16000, 16000, 16000, 16000, 0, 0)));
|
||||
|
||||
@ -2684,12 +2685,14 @@ std::unique_ptr<AudioProcessing> CreateApm(bool use_AEC2) {
|
||||
}
|
||||
|
||||
// Disable all components except for an AEC and the residual echo detector.
|
||||
// TODO(peah): Update this to also work on AEC3.
|
||||
AudioProcessing::Config apm_config;
|
||||
apm_config.residual_echo_detector.enabled = true;
|
||||
apm_config.high_pass_filter.enabled = false;
|
||||
apm_config.gain_controller2.enabled = false;
|
||||
apm_config.echo_canceller.enabled = true;
|
||||
apm_config.echo_canceller.mobile_mode = !use_AEC2;
|
||||
apm_config.echo_canceller.use_legacy_aec = use_AEC2;
|
||||
apm->ApplyConfig(apm_config);
|
||||
EXPECT_EQ(apm->gain_control()->Enable(false), 0);
|
||||
EXPECT_EQ(apm->level_estimator()->Enable(false), 0);
|
||||
@ -2708,6 +2711,11 @@ TEST(MAYBE_ApmStatistics, AEC2EnabledTest) {
|
||||
// Set up APM with AEC2 and process some audio.
|
||||
std::unique_ptr<AudioProcessing> apm = CreateApm(true);
|
||||
ASSERT_TRUE(apm);
|
||||
AudioProcessing::Config apm_config;
|
||||
apm_config.echo_canceller.enabled = true;
|
||||
// TODO(peah): Update tests to instead use AEC3.
|
||||
apm_config.echo_canceller.use_legacy_aec = true;
|
||||
apm->ApplyConfig(apm_config);
|
||||
|
||||
// Set up an audioframe.
|
||||
AudioFrame frame;
|
||||
|
||||
@ -322,7 +322,12 @@ bool EchoCancellationImpl::is_delay_agnostic_enabled() const {
|
||||
}
|
||||
|
||||
std::string EchoCancellationImpl::GetExperimentsDescription() {
|
||||
return refined_adaptive_filter_enabled_ ? "RefinedAdaptiveFilter;" : "";
|
||||
if (enabled_) {
|
||||
return refined_adaptive_filter_enabled_
|
||||
? "Legacy AEC;RefinedAdaptiveFilter;"
|
||||
: "Legacy AEC;";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
bool EchoCancellationImpl::is_refined_adaptive_filter_enabled() const {
|
||||
|
||||
@ -370,27 +370,33 @@ void AudioProcessingSimulator::CreateAudioProcessor() {
|
||||
settings_.pre_amplifier_gain_factor;
|
||||
}
|
||||
|
||||
bool use_aec2 = settings_.use_aec && *settings_.use_aec;
|
||||
bool use_aec3 = settings_.use_aec3 && *settings_.use_aec3;
|
||||
bool use_aecm = settings_.use_aecm && *settings_.use_aecm;
|
||||
if (use_aec2 || use_aec3 || use_aecm) {
|
||||
const bool use_legacy_aec = settings_.use_aec && *settings_.use_aec &&
|
||||
settings_.use_legacy_aec &&
|
||||
*settings_.use_legacy_aec;
|
||||
const bool use_aec = settings_.use_aec && *settings_.use_aec;
|
||||
const bool use_aecm = settings_.use_aecm && *settings_.use_aecm;
|
||||
if (use_legacy_aec || use_aec || use_aecm) {
|
||||
apm_config.echo_canceller.enabled = true;
|
||||
apm_config.echo_canceller.mobile_mode = use_aecm;
|
||||
apm_config.echo_canceller.use_legacy_aec = use_legacy_aec;
|
||||
}
|
||||
|
||||
if (settings_.use_aec3 && *settings_.use_aec3) {
|
||||
EchoCanceller3Config cfg;
|
||||
if (settings_.aec3_settings_filename) {
|
||||
if (settings_.use_verbose_logging) {
|
||||
std::cout << "Reading AEC3 Parameters from JSON input." << std::endl;
|
||||
}
|
||||
cfg = ReadAec3ConfigFromJsonFile(*settings_.aec3_settings_filename);
|
||||
}
|
||||
echo_control_factory.reset(new EchoCanceller3Factory(cfg));
|
||||
RTC_CHECK(!(use_legacy_aec && settings_.aec_settings_filename))
|
||||
<< "The legacy AEC cannot be configured using settings";
|
||||
|
||||
if (settings_.print_aec3_parameter_values) {
|
||||
if (use_aec && !use_legacy_aec) {
|
||||
EchoCanceller3Config cfg;
|
||||
if (settings_.aec_settings_filename) {
|
||||
if (settings_.use_verbose_logging) {
|
||||
std::cout << "Reading AEC Parameters from JSON input." << std::endl;
|
||||
}
|
||||
cfg = ReadAec3ConfigFromJsonFile(*settings_.aec_settings_filename);
|
||||
echo_control_factory.reset(new EchoCanceller3Factory(cfg));
|
||||
}
|
||||
|
||||
if (settings_.print_aec_parameter_values) {
|
||||
if (!settings_.use_quiet_output) {
|
||||
std::cout << "AEC3 settings:" << std::endl;
|
||||
std::cout << "AEC settings:" << std::endl;
|
||||
}
|
||||
std::cout << Aec3ConfigToJsonString(cfg) << std::endl;
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ struct SimulationSettings {
|
||||
absl::optional<bool> use_delay_agnostic;
|
||||
absl::optional<bool> use_extended_filter;
|
||||
absl::optional<bool> use_drift_compensation;
|
||||
absl::optional<bool> use_aec3;
|
||||
absl::optional<bool> use_legacy_aec;
|
||||
absl::optional<bool> use_experimental_agc;
|
||||
absl::optional<bool> use_experimental_agc_agc2_level_estimator;
|
||||
absl::optional<bool> experimental_agc_disable_digital_adaptive;
|
||||
@ -93,11 +93,11 @@ struct SimulationSettings {
|
||||
absl::optional<std::string> aec_dump_output_filename;
|
||||
bool fixed_interface = false;
|
||||
bool store_intermediate_output = false;
|
||||
bool print_aec3_parameter_values = false;
|
||||
bool print_aec_parameter_values = false;
|
||||
bool dump_internal_data = false;
|
||||
absl::optional<std::string> dump_internal_data_output_dir;
|
||||
absl::optional<std::string> custom_call_order_filename;
|
||||
absl::optional<std::string> aec3_settings_filename;
|
||||
absl::optional<std::string> aec_settings_filename;
|
||||
};
|
||||
|
||||
// Holds a few statistics about a series of TickIntervals.
|
||||
|
||||
@ -113,10 +113,9 @@ WEBRTC_DEFINE_int(delay_agnostic,
|
||||
WEBRTC_DEFINE_int(extended_filter,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the AEC extended filter mode");
|
||||
WEBRTC_DEFINE_int(
|
||||
aec3,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the experimental AEC mode AEC3");
|
||||
WEBRTC_DEFINE_int(use_legacy_aec,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the legacy AEC");
|
||||
WEBRTC_DEFINE_int(experimental_agc,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the experimental AGC");
|
||||
@ -207,12 +206,12 @@ WEBRTC_DEFINE_bool(store_intermediate_output,
|
||||
WEBRTC_DEFINE_string(custom_call_order_file,
|
||||
"",
|
||||
"Custom process API call order file");
|
||||
WEBRTC_DEFINE_bool(print_aec3_parameter_values,
|
||||
WEBRTC_DEFINE_bool(print_aec_parameter_values,
|
||||
false,
|
||||
"Print parameter values used in AEC3 in JSON-format");
|
||||
WEBRTC_DEFINE_string(aec3_settings,
|
||||
"Print parameter values used in AEC in JSON-format");
|
||||
WEBRTC_DEFINE_string(aec_settings,
|
||||
"",
|
||||
"File in JSON-format with custom AEC3 settings");
|
||||
"File in JSON-format with custom AEC settings");
|
||||
WEBRTC_DEFINE_bool(dump_data,
|
||||
false,
|
||||
"Dump internal data during the call (requires build flag)");
|
||||
@ -314,7 +313,7 @@ SimulationSettings CreateSettings() {
|
||||
SetSettingIfFlagSet(FLAG_refined_adaptive_filter,
|
||||
&settings.use_refined_adaptive_filter);
|
||||
|
||||
SetSettingIfFlagSet(FLAG_aec3, &settings.use_aec3);
|
||||
SetSettingIfFlagSet(FLAG_use_legacy_aec, &settings.use_legacy_aec);
|
||||
SetSettingIfFlagSet(FLAG_experimental_agc, &settings.use_experimental_agc);
|
||||
SetSettingIfFlagSet(FLAG_experimental_agc_disable_digital_adaptive,
|
||||
&settings.experimental_agc_disable_digital_adaptive);
|
||||
@ -341,7 +340,7 @@ SimulationSettings CreateSettings() {
|
||||
&settings.stream_drift_samples);
|
||||
SetSettingIfSpecified(FLAG_custom_call_order_file,
|
||||
&settings.custom_call_order_filename);
|
||||
SetSettingIfSpecified(FLAG_aec3_settings, &settings.aec3_settings_filename);
|
||||
SetSettingIfSpecified(FLAG_aec_settings, &settings.aec_settings_filename);
|
||||
settings.initial_mic_level = FLAG_initial_mic_level;
|
||||
settings.simulate_mic_gain = FLAG_simulate_mic_gain;
|
||||
SetSettingIfSpecified(FLAG_simulated_mic_kind, &settings.simulated_mic_kind);
|
||||
@ -352,7 +351,7 @@ SimulationSettings CreateSettings() {
|
||||
settings.discard_all_settings_in_aecdump = FLAG_discard_settings_in_aecdump;
|
||||
settings.fixed_interface = FLAG_fixed_interface;
|
||||
settings.store_intermediate_output = FLAG_store_intermediate_output;
|
||||
settings.print_aec3_parameter_values = FLAG_print_aec3_parameter_values;
|
||||
settings.print_aec_parameter_values = FLAG_print_aec_parameter_values;
|
||||
settings.dump_internal_data = FLAG_dump_data;
|
||||
SetSettingIfSpecified(FLAG_dump_data_output_dir,
|
||||
&settings.dump_internal_data_output_dir);
|
||||
|
||||
@ -48,14 +48,9 @@ class DebugDumpGenerator {
|
||||
int reverse_channels,
|
||||
const Config& config,
|
||||
const std::string& dump_file_name,
|
||||
bool enable_aec3,
|
||||
bool enable_pre_amplifier);
|
||||
|
||||
// Constructor that uses default input files.
|
||||
explicit DebugDumpGenerator(const Config& config,
|
||||
const AudioProcessing::Config& apm_config,
|
||||
bool enable_aec3);
|
||||
|
||||
explicit DebugDumpGenerator(const Config& config,
|
||||
const AudioProcessing::Config& apm_config);
|
||||
|
||||
@ -129,7 +124,6 @@ DebugDumpGenerator::DebugDumpGenerator(const std::string& input_file_name,
|
||||
int reverse_channels,
|
||||
const Config& config,
|
||||
const std::string& dump_file_name,
|
||||
bool enable_aec3,
|
||||
bool enable_pre_amplifier)
|
||||
: input_config_(input_rate_hz, input_channels),
|
||||
reverse_config_(reverse_rate_hz, reverse_channels),
|
||||
@ -148,17 +142,12 @@ DebugDumpGenerator::DebugDumpGenerator(const std::string& input_file_name,
|
||||
worker_queue_("debug_dump_generator_worker_queue"),
|
||||
dump_file_name_(dump_file_name) {
|
||||
AudioProcessingBuilder apm_builder;
|
||||
if (enable_aec3) {
|
||||
apm_builder.SetEchoControlFactory(
|
||||
std::unique_ptr<EchoControlFactory>(new EchoCanceller3Factory()));
|
||||
}
|
||||
apm_.reset(apm_builder.Create(config));
|
||||
}
|
||||
|
||||
DebugDumpGenerator::DebugDumpGenerator(
|
||||
const Config& config,
|
||||
const AudioProcessing::Config& apm_config,
|
||||
bool enable_aec3)
|
||||
const AudioProcessing::Config& apm_config)
|
||||
: DebugDumpGenerator(ResourcePath("near32_stereo", "pcm"),
|
||||
32000,
|
||||
2,
|
||||
@ -167,18 +156,10 @@ DebugDumpGenerator::DebugDumpGenerator(
|
||||
2,
|
||||
config,
|
||||
TempFilename(OutputPath(), "debug_aec"),
|
||||
enable_aec3,
|
||||
apm_config.pre_amplifier.enabled) {
|
||||
apm_->ApplyConfig(apm_config);
|
||||
}
|
||||
|
||||
DebugDumpGenerator::DebugDumpGenerator(
|
||||
const Config& config,
|
||||
const AudioProcessing::Config& apm_config)
|
||||
: DebugDumpGenerator(config, apm_config, false) {
|
||||
apm_->ApplyConfig(apm_config);
|
||||
}
|
||||
|
||||
DebugDumpGenerator::~DebugDumpGenerator() {
|
||||
remove(dump_file_name_.c_str());
|
||||
}
|
||||
@ -360,22 +341,7 @@ TEST_F(DebugDumpTest, ChangeOutputFormat) {
|
||||
TEST_F(DebugDumpTest, ToggleAec) {
|
||||
Config config;
|
||||
AudioProcessing::Config apm_config;
|
||||
DebugDumpGenerator generator(config, apm_config);
|
||||
generator.StartRecording();
|
||||
generator.Process(100);
|
||||
|
||||
apm_config.echo_canceller.enabled = true;
|
||||
generator.apm()->ApplyConfig(apm_config);
|
||||
|
||||
generator.Process(100);
|
||||
generator.StopRecording();
|
||||
VerifyDebugDump(generator.dump_file_name());
|
||||
}
|
||||
|
||||
TEST_F(DebugDumpTest, ToggleDelayAgnosticAec) {
|
||||
Config config;
|
||||
config.Set<DelayAgnostic>(new DelayAgnostic(true));
|
||||
AudioProcessing::Config apm_config;
|
||||
DebugDumpGenerator generator(config, apm_config);
|
||||
generator.StartRecording();
|
||||
generator.Process(100);
|
||||
@ -390,8 +356,11 @@ TEST_F(DebugDumpTest, ToggleDelayAgnosticAec) {
|
||||
|
||||
TEST_F(DebugDumpTest, VerifyRefinedAdaptiveFilterExperimentalString) {
|
||||
Config config;
|
||||
AudioProcessing::Config apm_config;
|
||||
apm_config.echo_canceller.enabled = true;
|
||||
apm_config.echo_canceller.use_legacy_aec = true;
|
||||
config.Set<RefinedAdaptiveFilter>(new RefinedAdaptiveFilter(true));
|
||||
DebugDumpGenerator generator(config, AudioProcessing::Config());
|
||||
DebugDumpGenerator generator(config, apm_config);
|
||||
generator.StartRecording();
|
||||
generator.Process(100);
|
||||
generator.StopRecording();
|
||||
@ -408,6 +377,8 @@ TEST_F(DebugDumpTest, VerifyRefinedAdaptiveFilterExperimentalString) {
|
||||
ASSERT_TRUE(msg->has_experiments_description());
|
||||
EXPECT_PRED_FORMAT2(testing::IsSubstring, "RefinedAdaptiveFilter",
|
||||
msg->experiments_description().c_str());
|
||||
EXPECT_PRED_FORMAT2(testing::IsSubstring, "Legacy AEC",
|
||||
msg->experiments_description().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -416,11 +387,9 @@ TEST_F(DebugDumpTest, VerifyCombinedExperimentalStringInclusive) {
|
||||
Config config;
|
||||
AudioProcessing::Config apm_config;
|
||||
apm_config.echo_canceller.enabled = true;
|
||||
config.Set<RefinedAdaptiveFilter>(new RefinedAdaptiveFilter(true));
|
||||
// Arbitrarily set clipping gain to 17, which will never be the default.
|
||||
config.Set<ExperimentalAgc>(new ExperimentalAgc(true, 0, 17));
|
||||
bool enable_aec3 = true;
|
||||
DebugDumpGenerator generator(config, apm_config, enable_aec3);
|
||||
DebugDumpGenerator generator(config, apm_config);
|
||||
generator.StartRecording();
|
||||
generator.Process(100);
|
||||
generator.StopRecording();
|
||||
@ -435,10 +404,10 @@ TEST_F(DebugDumpTest, VerifyCombinedExperimentalStringInclusive) {
|
||||
if (event->type() == audioproc::Event::CONFIG) {
|
||||
const audioproc::Config* msg = &event->config();
|
||||
ASSERT_TRUE(msg->has_experiments_description());
|
||||
EXPECT_PRED_FORMAT2(testing::IsSubstring, "RefinedAdaptiveFilter",
|
||||
msg->experiments_description().c_str());
|
||||
EXPECT_PRED_FORMAT2(testing::IsSubstring, "EchoController",
|
||||
msg->experiments_description().c_str());
|
||||
EXPECT_PRED_FORMAT2(testing::IsNotSubstring, "Legacy AEC",
|
||||
msg->experiments_description().c_str());
|
||||
EXPECT_PRED_FORMAT2(testing::IsSubstring, "AgcClippingLevelExperiment",
|
||||
msg->experiments_description().c_str());
|
||||
}
|
||||
@ -447,8 +416,10 @@ TEST_F(DebugDumpTest, VerifyCombinedExperimentalStringInclusive) {
|
||||
|
||||
TEST_F(DebugDumpTest, VerifyCombinedExperimentalStringExclusive) {
|
||||
Config config;
|
||||
config.Set<RefinedAdaptiveFilter>(new RefinedAdaptiveFilter(true));
|
||||
DebugDumpGenerator generator(config, AudioProcessing::Config());
|
||||
AudioProcessing::Config apm_config;
|
||||
apm_config.echo_canceller.enabled = true;
|
||||
apm_config.echo_canceller.use_legacy_aec = true;
|
||||
DebugDumpGenerator generator(config, apm_config);
|
||||
generator.StartRecording();
|
||||
generator.Process(100);
|
||||
generator.StopRecording();
|
||||
@ -463,9 +434,7 @@ TEST_F(DebugDumpTest, VerifyCombinedExperimentalStringExclusive) {
|
||||
if (event->type() == audioproc::Event::CONFIG) {
|
||||
const audioproc::Config* msg = &event->config();
|
||||
ASSERT_TRUE(msg->has_experiments_description());
|
||||
EXPECT_PRED_FORMAT2(testing::IsSubstring, "RefinedAdaptiveFilter",
|
||||
msg->experiments_description().c_str());
|
||||
EXPECT_PRED_FORMAT2(testing::IsNotSubstring, "AEC3",
|
||||
EXPECT_PRED_FORMAT2(testing::IsNotSubstring, "EchoController",
|
||||
msg->experiments_description().c_str());
|
||||
EXPECT_PRED_FORMAT2(testing::IsNotSubstring, "AgcClippingLevelExperiment",
|
||||
msg->experiments_description().c_str());
|
||||
@ -477,7 +446,7 @@ TEST_F(DebugDumpTest, VerifyAec3ExperimentalString) {
|
||||
Config config;
|
||||
AudioProcessing::Config apm_config;
|
||||
apm_config.echo_canceller.enabled = true;
|
||||
DebugDumpGenerator generator(config, apm_config, true);
|
||||
DebugDumpGenerator generator(config, apm_config);
|
||||
generator.StartRecording();
|
||||
generator.Process(100);
|
||||
generator.StopRecording();
|
||||
@ -492,6 +461,8 @@ TEST_F(DebugDumpTest, VerifyAec3ExperimentalString) {
|
||||
if (event->type() == audioproc::Event::CONFIG) {
|
||||
const audioproc::Config* msg = &event->config();
|
||||
ASSERT_TRUE(msg->has_experiments_description());
|
||||
EXPECT_PRED_FORMAT2(testing::IsNotSubstring, "Legacy AEC",
|
||||
msg->experiments_description().c_str());
|
||||
EXPECT_PRED_FORMAT2(testing::IsSubstring, "EchoController",
|
||||
msg->experiments_description().c_str());
|
||||
}
|
||||
@ -545,23 +516,6 @@ TEST_F(DebugDumpTest, VerifyEmptyExperimentalString) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DebugDumpTest, ToggleAecLevel) {
|
||||
Config config;
|
||||
AudioProcessing::Config apm_config;
|
||||
apm_config.echo_canceller.enabled = true;
|
||||
apm_config.echo_canceller.mobile_mode = false;
|
||||
apm_config.echo_canceller.legacy_moderate_suppression_level = true;
|
||||
DebugDumpGenerator generator(config, apm_config);
|
||||
generator.StartRecording();
|
||||
generator.Process(100);
|
||||
|
||||
apm_config.echo_canceller.legacy_moderate_suppression_level = false;
|
||||
generator.apm()->ApplyConfig(apm_config);
|
||||
generator.Process(100);
|
||||
generator.StopRecording();
|
||||
VerifyDebugDump(generator.dump_file_name());
|
||||
}
|
||||
|
||||
// AGC is not supported on Android or iOS.
|
||||
#if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
|
||||
#define MAYBE_ToggleAgc DISABLED_ToggleAgc
|
||||
|
||||
@ -485,6 +485,7 @@ webrtc_fuzzer_test("audio_processing_fuzzer") {
|
||||
"../../api/audio:aec3_factory",
|
||||
"../../modules/audio_processing",
|
||||
"../../modules/audio_processing:api",
|
||||
"../../modules/audio_processing:audio_buffer",
|
||||
"../../modules/audio_processing/aec3",
|
||||
"../../modules/audio_processing/aec_dump",
|
||||
"../../modules/audio_processing/aec_dump:aec_dump_impl",
|
||||
@ -505,6 +506,7 @@ webrtc_fuzzer_test("agc_fuzzer") {
|
||||
":fuzz_data_helper",
|
||||
"../../modules/audio_processing",
|
||||
"../../modules/audio_processing:api",
|
||||
"../../modules/audio_processing:audio_buffer",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"../../rtc_base:safe_minmax",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user