Flags and settings for AGC2 in AgcManagerDirect.
This CL adds two flags to audioproc_f. The flags control AgcManagerDirect. The flags are '--experimental_agc_agc2_level_estimator' and '--experimental_agc_agc2_digital_adaptive'. After this CL, the flags are be applied to AgcManagerDirect. The flags have no effect in release-mode. They cause a crash in debug-mode. In an upcoming CL, '--experimental_agc_agc2_level_estimator 1' will replace the speech level estimation in ExperimentalAgc with that of AGC2. '--experimental_agc_agc2_digital_adaptive 1' will replace the digital gain selection and application with that of AGC2. These audioproc_f will activate both new settings: ./out/Target/audioproc_f --agc 1 --experimental_agc 1 --experimental_agc_agc2_digital_adaptive 1 --experimental_agc_agc2_level_estimator 1 --simulate_mic_gain 1 --simulated_mic_kind 2 See also https://webrtc-review.googlesource.com/c/src/+/79360 Bug: webrtc:7494 Change-Id: If0e65893dffdddb312e553787b8cedaf9a334323 Reviewed-on: https://webrtc-review.googlesource.com/86548 Commit-Queue: Alex Loiko <aleloi@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23802}
This commit is contained in:
@ -111,33 +111,37 @@ class DebugFile {
|
||||
AgcManagerDirect::AgcManagerDirect(GainControl* gctrl,
|
||||
VolumeCallbacks* volume_callbacks,
|
||||
int startup_min_level,
|
||||
int clipped_level_min)
|
||||
: data_dumper_(new ApmDataDumper(instance_counter_)),
|
||||
agc_(new Agc()),
|
||||
gctrl_(gctrl),
|
||||
volume_callbacks_(volume_callbacks),
|
||||
frames_since_clipped_(kClippedWaitFrames),
|
||||
level_(0),
|
||||
max_level_(kMaxMicLevel),
|
||||
max_compression_gain_(kMaxCompressionGain),
|
||||
target_compression_(kDefaultCompressionGain),
|
||||
compression_(target_compression_),
|
||||
compression_accumulator_(compression_),
|
||||
capture_muted_(false),
|
||||
check_volume_on_next_process_(true), // Check at startup.
|
||||
startup_(true),
|
||||
startup_min_level_(ClampLevel(startup_min_level)),
|
||||
clipped_level_min_(clipped_level_min),
|
||||
file_preproc_(new DebugFile("agc_preproc.pcm")),
|
||||
file_postproc_(new DebugFile("agc_postproc.pcm")) {
|
||||
instance_counter_++;
|
||||
}
|
||||
int clipped_level_min,
|
||||
bool use_agc2_level_estimation,
|
||||
bool use_agc2_digital_adaptive)
|
||||
: AgcManagerDirect(new Agc(),
|
||||
gctrl,
|
||||
volume_callbacks,
|
||||
startup_min_level,
|
||||
clipped_level_min,
|
||||
use_agc2_level_estimation,
|
||||
use_agc2_digital_adaptive) {}
|
||||
|
||||
AgcManagerDirect::AgcManagerDirect(Agc* agc,
|
||||
GainControl* gctrl,
|
||||
VolumeCallbacks* volume_callbacks,
|
||||
int startup_min_level,
|
||||
int clipped_level_min)
|
||||
: AgcManagerDirect(agc,
|
||||
gctrl,
|
||||
volume_callbacks,
|
||||
startup_min_level,
|
||||
clipped_level_min,
|
||||
false,
|
||||
false) {}
|
||||
|
||||
AgcManagerDirect::AgcManagerDirect(Agc* agc,
|
||||
GainControl* gctrl,
|
||||
VolumeCallbacks* volume_callbacks,
|
||||
int startup_min_level,
|
||||
int clipped_level_min,
|
||||
bool use_agc2_level_estimation,
|
||||
bool use_agc2_digital_adaptive)
|
||||
: data_dumper_(new ApmDataDumper(instance_counter_)),
|
||||
agc_(agc),
|
||||
gctrl_(gctrl),
|
||||
@ -152,11 +156,19 @@ AgcManagerDirect::AgcManagerDirect(Agc* agc,
|
||||
capture_muted_(false),
|
||||
check_volume_on_next_process_(true), // Check at startup.
|
||||
startup_(true),
|
||||
use_agc2_level_estimation_(use_agc2_level_estimation),
|
||||
use_agc2_digital_adaptive_(use_agc2_digital_adaptive),
|
||||
startup_min_level_(ClampLevel(startup_min_level)),
|
||||
clipped_level_min_(clipped_level_min),
|
||||
file_preproc_(new DebugFile("agc_preproc.pcm")),
|
||||
file_postproc_(new DebugFile("agc_postproc.pcm")) {
|
||||
instance_counter_++;
|
||||
if (use_agc2_level_estimation_) {
|
||||
RTC_NOTREACHED() << "Agc2 level estimation not implemented.";
|
||||
}
|
||||
if (use_agc2_digital_adaptive_) {
|
||||
RTC_NOTREACHED() << "Agc2 digital adaptive not implemented.";
|
||||
}
|
||||
}
|
||||
|
||||
AgcManagerDirect::~AgcManagerDirect() {}
|
||||
|
@ -48,7 +48,10 @@ class AgcManagerDirect final {
|
||||
AgcManagerDirect(GainControl* gctrl,
|
||||
VolumeCallbacks* volume_callbacks,
|
||||
int startup_min_level,
|
||||
int clipped_level_min);
|
||||
int clipped_level_min,
|
||||
bool use_agc2_level_estimation,
|
||||
bool use_agc2_digital_adaptive);
|
||||
|
||||
// Dependency injection for testing. Don't delete |agc| as the memory is owned
|
||||
// by the manager.
|
||||
AgcManagerDirect(Agc* agc,
|
||||
@ -56,6 +59,15 @@ class AgcManagerDirect final {
|
||||
VolumeCallbacks* volume_callbacks,
|
||||
int startup_min_level,
|
||||
int clipped_level_min);
|
||||
|
||||
// Most general c-tor.
|
||||
AgcManagerDirect(Agc* agc,
|
||||
GainControl* gctrl,
|
||||
VolumeCallbacks* volume_callbacks,
|
||||
int startup_min_level,
|
||||
int clipped_level_min,
|
||||
bool use_agc2_level_estimation,
|
||||
bool use_agc2_digital_adaptive);
|
||||
~AgcManagerDirect();
|
||||
|
||||
int Initialize();
|
||||
@ -103,6 +115,8 @@ class AgcManagerDirect final {
|
||||
bool capture_muted_;
|
||||
bool check_volume_on_next_process_;
|
||||
bool startup_;
|
||||
const bool use_agc2_level_estimation_;
|
||||
const bool use_agc2_digital_adaptive_;
|
||||
int startup_min_level_;
|
||||
const int clipped_level_min_;
|
||||
|
||||
|
@ -366,9 +366,13 @@ AudioProcessingImpl::AudioProcessingImpl(
|
||||
constants_(config.Get<ExperimentalAgc>().startup_min_volume,
|
||||
config.Get<ExperimentalAgc>().clipped_level_min,
|
||||
#if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
|
||||
false,
|
||||
false,
|
||||
false),
|
||||
#else
|
||||
config.Get<ExperimentalAgc>().enabled),
|
||||
config.Get<ExperimentalAgc>().enabled,
|
||||
config.Get<ExperimentalAgc>().enabled_agc2_level_estimator,
|
||||
config.Get<ExperimentalAgc>().enabled_agc2_digital_adaptive),
|
||||
#endif
|
||||
#if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
|
||||
capture_(false),
|
||||
@ -542,7 +546,9 @@ int AudioProcessingImpl::InitializeLocked() {
|
||||
private_submodules_->agc_manager.reset(new AgcManagerDirect(
|
||||
public_submodules_->gain_control.get(),
|
||||
public_submodules_->gain_control_for_experimental_agc.get(),
|
||||
constants_.agc_startup_min_volume, constants_.agc_clipped_level_min));
|
||||
constants_.agc_startup_min_volume, constants_.agc_clipped_level_min,
|
||||
constants_.use_experimental_agc_agc2_level_estimation,
|
||||
constants_.use_experimental_agc_agc2_digital_adaptive));
|
||||
}
|
||||
private_submodules_->agc_manager->Initialize();
|
||||
private_submodules_->agc_manager->SetCaptureMuted(
|
||||
|
@ -352,14 +352,23 @@ class AudioProcessingImpl : public AudioProcessing {
|
||||
const struct ApmConstants {
|
||||
ApmConstants(int agc_startup_min_volume,
|
||||
int agc_clipped_level_min,
|
||||
bool use_experimental_agc)
|
||||
bool use_experimental_agc,
|
||||
bool use_experimental_agc_agc2_level_estimation,
|
||||
bool use_experimental_agc_agc2_digital_adaptive)
|
||||
: // Format of processing streams at input/output call sites.
|
||||
agc_startup_min_volume(agc_startup_min_volume),
|
||||
agc_clipped_level_min(agc_clipped_level_min),
|
||||
use_experimental_agc(use_experimental_agc) {}
|
||||
use_experimental_agc(use_experimental_agc),
|
||||
use_experimental_agc_agc2_level_estimation(
|
||||
use_experimental_agc_agc2_level_estimation),
|
||||
use_experimental_agc_agc2_digital_adaptive(
|
||||
use_experimental_agc_agc2_digital_adaptive) {}
|
||||
int agc_startup_min_volume;
|
||||
int agc_clipped_level_min;
|
||||
bool use_experimental_agc;
|
||||
bool use_experimental_agc_agc2_level_estimation;
|
||||
bool use_experimental_agc_agc2_digital_adaptive;
|
||||
|
||||
} constants_;
|
||||
|
||||
struct ApmCaptureState {
|
||||
|
@ -122,6 +122,13 @@ static constexpr int kClippedLevelMin = 70;
|
||||
struct ExperimentalAgc {
|
||||
ExperimentalAgc() = default;
|
||||
explicit ExperimentalAgc(bool enabled) : enabled(enabled) {}
|
||||
ExperimentalAgc(bool enabled,
|
||||
bool enabled_agc2_level_estimator,
|
||||
bool enabled_agc2_digital_adaptive)
|
||||
: enabled(enabled),
|
||||
enabled_agc2_level_estimator(enabled_agc2_level_estimator),
|
||||
enabled_agc2_digital_adaptive(enabled_agc2_digital_adaptive) {}
|
||||
|
||||
ExperimentalAgc(bool enabled, int startup_min_volume)
|
||||
: enabled(enabled), startup_min_volume(startup_min_volume) {}
|
||||
ExperimentalAgc(bool enabled, int startup_min_volume, int clipped_level_min)
|
||||
@ -133,6 +140,8 @@ struct ExperimentalAgc {
|
||||
int startup_min_volume = kAgcStartupMinVolume;
|
||||
// Lowest microphone level that will be applied in response to clipping.
|
||||
int clipped_level_min = kClippedLevelMin;
|
||||
bool enabled_agc2_level_estimator = false;
|
||||
bool enabled_agc2_digital_adaptive = false;
|
||||
};
|
||||
|
||||
// Use to enable experimental noise suppression. It can be set in the
|
||||
|
@ -615,7 +615,11 @@ void AudioProcessingSimulator::CreateAudioProcessor() {
|
||||
config.Set<DelayAgnostic>(new DelayAgnostic(!settings_.use_delay_agnostic ||
|
||||
*settings_.use_delay_agnostic));
|
||||
config.Set<ExperimentalAgc>(new ExperimentalAgc(
|
||||
!settings_.use_experimental_agc || *settings_.use_experimental_agc));
|
||||
!settings_.use_experimental_agc || *settings_.use_experimental_agc,
|
||||
!!settings_.use_experimental_agc_agc2_level_estimator &&
|
||||
*settings_.use_experimental_agc_agc2_level_estimator,
|
||||
!!settings_.use_experimental_agc_agc2_digital_adaptive &&
|
||||
*settings_.use_experimental_agc_agc2_digital_adaptive));
|
||||
if (settings_.use_ed) {
|
||||
apm_config.residual_echo_detector.enabled = *settings_.use_ed;
|
||||
}
|
||||
|
@ -66,6 +66,8 @@ struct SimulationSettings {
|
||||
absl::optional<bool> use_drift_compensation;
|
||||
absl::optional<bool> use_aec3;
|
||||
absl::optional<bool> use_experimental_agc;
|
||||
absl::optional<bool> use_experimental_agc_agc2_level_estimator;
|
||||
absl::optional<bool> use_experimental_agc_agc2_digital_adaptive;
|
||||
absl::optional<int> aecm_routing_mode;
|
||||
absl::optional<bool> use_aecm_comfort_noise;
|
||||
absl::optional<int> agc_mode;
|
||||
|
@ -118,6 +118,14 @@ DEFINE_int(aec3,
|
||||
DEFINE_int(experimental_agc,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) the experimental AGC");
|
||||
DEFINE_int(
|
||||
experimental_agc_agc2_level_estimator,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) AGC2 level estimate in experimental AGC");
|
||||
DEFINE_int(experimental_agc_agc2_digital_adaptive,
|
||||
kParameterNotSpecifiedValue,
|
||||
"Activate (1) or deactivate(0) AGC2 digital adaptation in "
|
||||
"experimental AGC");
|
||||
DEFINE_int(
|
||||
refined_adaptive_filter,
|
||||
kParameterNotSpecifiedValue,
|
||||
@ -256,6 +264,11 @@ SimulationSettings CreateSettings() {
|
||||
|
||||
SetSettingIfFlagSet(FLAG_aec3, &settings.use_aec3);
|
||||
SetSettingIfFlagSet(FLAG_experimental_agc, &settings.use_experimental_agc);
|
||||
SetSettingIfFlagSet(FLAG_experimental_agc_agc2_level_estimator,
|
||||
&settings.use_experimental_agc_agc2_level_estimator);
|
||||
SetSettingIfFlagSet(FLAG_experimental_agc_agc2_digital_adaptive,
|
||||
&settings.use_experimental_agc_agc2_digital_adaptive);
|
||||
|
||||
SetSettingIfSpecified(FLAG_aecm_routing_mode, &settings.aecm_routing_mode);
|
||||
SetSettingIfFlagSet(FLAG_aecm_comfort_noise,
|
||||
&settings.use_aecm_comfort_noise);
|
||||
|
Reference in New Issue
Block a user