Allow audioproc_f to override the pre-amp gain in aecdumps
This CL allows audioproc_f to overrule any runtime settings for the pre-amplifier gain that are present in the aecdump file. Bug: webrtc:10546 Change-Id: I74dbf8d043f59b516bf0abc80f266e965af0754d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132558 Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Commit-Queue: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27598}
This commit is contained in:
parent
14696c23d9
commit
ef3496095d
@ -15,7 +15,6 @@
|
|||||||
#include "modules/audio_processing/echo_control_mobile_impl.h"
|
#include "modules/audio_processing/echo_control_mobile_impl.h"
|
||||||
#include "modules/audio_processing/test/aec_dump_based_simulator.h"
|
#include "modules/audio_processing/test/aec_dump_based_simulator.h"
|
||||||
#include "modules/audio_processing/test/protobuf_utils.h"
|
#include "modules/audio_processing/test/protobuf_utils.h"
|
||||||
#include "modules/audio_processing/test/runtime_setting_util.h"
|
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
#include "rtc_base/numerics/safe_conversions.h"
|
#include "rtc_base/numerics/safe_conversions.h"
|
||||||
@ -448,8 +447,10 @@ void AecDumpBasedSimulator::HandleMessage(
|
|||||||
? *settings_.use_pre_amplifier
|
? *settings_.use_pre_amplifier
|
||||||
: msg.pre_amplifier_enabled();
|
: msg.pre_amplifier_enabled();
|
||||||
apm_config.pre_amplifier.enabled = enable;
|
apm_config.pre_amplifier.enabled = enable;
|
||||||
|
if (settings_.pre_amplifier_gain_factor) {
|
||||||
apm_config.pre_amplifier.fixed_gain_factor =
|
apm_config.pre_amplifier.fixed_gain_factor =
|
||||||
settings_.pre_amplifier_gain_factor;
|
*settings_.pre_amplifier_gain_factor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings_.use_verbose_logging && msg.has_experiments_description() &&
|
if (settings_.use_verbose_logging && msg.has_experiments_description() &&
|
||||||
@ -549,7 +550,13 @@ void AecDumpBasedSimulator::HandleMessage(
|
|||||||
void AecDumpBasedSimulator::HandleMessage(
|
void AecDumpBasedSimulator::HandleMessage(
|
||||||
const webrtc::audioproc::RuntimeSetting& msg) {
|
const webrtc::audioproc::RuntimeSetting& msg) {
|
||||||
RTC_CHECK(ap_.get());
|
RTC_CHECK(ap_.get());
|
||||||
ReplayRuntimeSetting(ap_.get(), msg);
|
// Handle capture pre-gain runtime setting only if not overridden.
|
||||||
|
if ((!settings_.use_pre_amplifier || !(*settings_.use_pre_amplifier)) &&
|
||||||
|
!settings_.pre_amplifier_gain_factor) {
|
||||||
|
ap_->SetRuntimeSetting(
|
||||||
|
AudioProcessing::RuntimeSetting::CreateCapturePreGain(
|
||||||
|
msg.capture_pre_gain()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AecDumpBasedSimulator::MaybeOpenCallOrderFile() {
|
void AecDumpBasedSimulator::MaybeOpenCallOrderFile() {
|
||||||
|
|||||||
@ -384,8 +384,10 @@ void AudioProcessingSimulator::CreateAudioProcessor() {
|
|||||||
}
|
}
|
||||||
if (settings_.use_pre_amplifier) {
|
if (settings_.use_pre_amplifier) {
|
||||||
apm_config.pre_amplifier.enabled = *settings_.use_pre_amplifier;
|
apm_config.pre_amplifier.enabled = *settings_.use_pre_amplifier;
|
||||||
|
if (settings_.pre_amplifier_gain_factor) {
|
||||||
apm_config.pre_amplifier.fixed_gain_factor =
|
apm_config.pre_amplifier.fixed_gain_factor =
|
||||||
settings_.pre_amplifier_gain_factor;
|
*settings_.pre_amplifier_gain_factor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool use_legacy_aec = settings_.use_aec && *settings_.use_aec &&
|
const bool use_legacy_aec = settings_.use_aec && *settings_.use_aec &&
|
||||||
|
|||||||
@ -78,7 +78,7 @@ struct SimulationSettings {
|
|||||||
float agc2_fixed_gain_db;
|
float agc2_fixed_gain_db;
|
||||||
AudioProcessing::Config::GainController2::LevelEstimator
|
AudioProcessing::Config::GainController2::LevelEstimator
|
||||||
agc2_adaptive_level_estimator;
|
agc2_adaptive_level_estimator;
|
||||||
float pre_amplifier_gain_factor;
|
absl::optional<float> pre_amplifier_gain_factor;
|
||||||
absl::optional<int> vad_likelihood;
|
absl::optional<int> vad_likelihood;
|
||||||
absl::optional<int> ns_level;
|
absl::optional<int> ns_level;
|
||||||
absl::optional<bool> use_refined_adaptive_filter;
|
absl::optional<bool> use_refined_adaptive_filter;
|
||||||
|
|||||||
@ -163,7 +163,7 @@ WEBRTC_DEFINE_string(
|
|||||||
"AGC2 adaptive digital level estimator to use [RMS, peak]");
|
"AGC2 adaptive digital level estimator to use [RMS, peak]");
|
||||||
|
|
||||||
WEBRTC_DEFINE_float(pre_amplifier_gain_factor,
|
WEBRTC_DEFINE_float(pre_amplifier_gain_factor,
|
||||||
1.f,
|
kParameterNotSpecifiedValue,
|
||||||
"Pre-amplifier gain factor (linear) to apply");
|
"Pre-amplifier gain factor (linear) to apply");
|
||||||
WEBRTC_DEFINE_int(vad_likelihood,
|
WEBRTC_DEFINE_int(vad_likelihood,
|
||||||
kParameterNotSpecifiedValue,
|
kParameterNotSpecifiedValue,
|
||||||
@ -241,6 +241,14 @@ void SetSettingIfSpecified(int value, absl::optional<int>* parameter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetSettingIfSpecified(float value, absl::optional<float>* parameter) {
|
||||||
|
constexpr float kFloatParameterNotSpecifiedValue =
|
||||||
|
kParameterNotSpecifiedValue;
|
||||||
|
if (value != kFloatParameterNotSpecifiedValue) {
|
||||||
|
*parameter = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SetSettingIfFlagSet(int32_t flag, absl::optional<bool>* parameter) {
|
void SetSettingIfFlagSet(int32_t flag, absl::optional<bool>* parameter) {
|
||||||
if (flag == 0) {
|
if (flag == 0) {
|
||||||
*parameter = false;
|
*parameter = false;
|
||||||
@ -339,7 +347,8 @@ SimulationSettings CreateSettings() {
|
|||||||
settings.agc2_fixed_gain_db = FLAG_agc2_fixed_gain_db;
|
settings.agc2_fixed_gain_db = FLAG_agc2_fixed_gain_db;
|
||||||
settings.agc2_adaptive_level_estimator =
|
settings.agc2_adaptive_level_estimator =
|
||||||
MapAgc2AdaptiveLevelEstimator(FLAG_agc2_adaptive_level_estimator);
|
MapAgc2AdaptiveLevelEstimator(FLAG_agc2_adaptive_level_estimator);
|
||||||
settings.pre_amplifier_gain_factor = FLAG_pre_amplifier_gain_factor;
|
SetSettingIfSpecified(FLAG_pre_amplifier_gain_factor,
|
||||||
|
&settings.pre_amplifier_gain_factor);
|
||||||
SetSettingIfSpecified(FLAG_vad_likelihood, &settings.vad_likelihood);
|
SetSettingIfSpecified(FLAG_vad_likelihood, &settings.vad_likelihood);
|
||||||
SetSettingIfSpecified(FLAG_ns_level, &settings.ns_level);
|
SetSettingIfSpecified(FLAG_ns_level, &settings.ns_level);
|
||||||
SetSettingIfSpecified(FLAG_stream_delay, &settings.stream_delay);
|
SetSettingIfSpecified(FLAG_stream_delay, &settings.stream_delay);
|
||||||
@ -531,6 +540,12 @@ void PerformBasicParameterSanityChecks(const SimulationSettings& settings) {
|
|||||||
!settings.aec_dump_input_filename &&
|
!settings.aec_dump_input_filename &&
|
||||||
settings.call_order_output_filename.has_value(),
|
settings.call_order_output_filename.has_value(),
|
||||||
"Error: --output_custom_call_order_file needs an AEC dump input file.\n");
|
"Error: --output_custom_call_order_file needs an AEC dump input file.\n");
|
||||||
|
|
||||||
|
ReportConditionalErrorAndExit(
|
||||||
|
(!settings.use_pre_amplifier || !(*settings.use_pre_amplifier)) &&
|
||||||
|
settings.pre_amplifier_gain_factor.has_value(),
|
||||||
|
"Error: --pre_amplifier_gain_factor needs --pre_amplifier to be "
|
||||||
|
"specified and set.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user