AGC2 config operator= and unit tests update
Bug: webrtc:7494 Change-Id: I7957602d60658b84175a617f9c283ea44eafe57d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/216260 Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Reviewed-by: Sam Zackrisson <saza@google.com> Cr-Commit-Position: refs/heads/master@{#33876}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
d66a60597d
commit
a2efd15627
@ -3039,50 +3039,50 @@ TEST(AudioProcessing, GainController1ConfigNotEqual) {
|
||||
|
||||
Toggle(a.enabled);
|
||||
EXPECT_NE(a, b);
|
||||
a.enabled = b.enabled;
|
||||
a = b;
|
||||
|
||||
a.mode = AudioProcessing::Config::GainController1::Mode::kAdaptiveDigital;
|
||||
EXPECT_NE(a, b);
|
||||
a.mode = b.mode;
|
||||
a = b;
|
||||
|
||||
a.target_level_dbfs++;
|
||||
EXPECT_NE(a, b);
|
||||
a.target_level_dbfs = b.target_level_dbfs;
|
||||
a = b;
|
||||
|
||||
a.compression_gain_db++;
|
||||
EXPECT_NE(a, b);
|
||||
a.compression_gain_db = b.compression_gain_db;
|
||||
a = b;
|
||||
|
||||
Toggle(a.enable_limiter);
|
||||
EXPECT_NE(a, b);
|
||||
a.enable_limiter = b.enable_limiter;
|
||||
a = b;
|
||||
|
||||
a.analog_level_minimum++;
|
||||
EXPECT_NE(a, b);
|
||||
a.analog_level_minimum = b.analog_level_minimum;
|
||||
a = b;
|
||||
|
||||
a.analog_level_maximum--;
|
||||
EXPECT_NE(a, b);
|
||||
a.analog_level_maximum = b.analog_level_maximum;
|
||||
a = b;
|
||||
|
||||
auto& a_analog = a.analog_gain_controller;
|
||||
const auto& b_analog = b.analog_gain_controller;
|
||||
|
||||
Toggle(a_analog.enabled);
|
||||
EXPECT_NE(a, b);
|
||||
a_analog.enabled = b_analog.enabled;
|
||||
a_analog = b_analog;
|
||||
|
||||
a_analog.startup_min_volume++;
|
||||
EXPECT_NE(a, b);
|
||||
a_analog.startup_min_volume = b_analog.startup_min_volume;
|
||||
a_analog = b_analog;
|
||||
|
||||
a_analog.clipped_level_min++;
|
||||
EXPECT_NE(a, b);
|
||||
a_analog.clipped_level_min = b_analog.clipped_level_min;
|
||||
a_analog = b_analog;
|
||||
|
||||
Toggle(a_analog.enable_digital_adaptive);
|
||||
EXPECT_NE(a, b);
|
||||
a_analog.enable_digital_adaptive = b_analog.enable_digital_adaptive;
|
||||
a_analog = b_analog;
|
||||
}
|
||||
|
||||
TEST(AudioProcessing, GainController2ConfigEqual) {
|
||||
@ -3094,7 +3094,7 @@ TEST(AudioProcessing, GainController2ConfigEqual) {
|
||||
b.enabled = a.enabled;
|
||||
EXPECT_EQ(a, b);
|
||||
|
||||
a.fixed_digital.gain_db += 1.f;
|
||||
a.fixed_digital.gain_db += 1.0f;
|
||||
b.fixed_digital.gain_db = a.fixed_digital.gain_db;
|
||||
EXPECT_EQ(a, b);
|
||||
|
||||
@ -3105,47 +3105,45 @@ TEST(AudioProcessing, GainController2ConfigEqual) {
|
||||
b_adaptive.enabled = a_adaptive.enabled;
|
||||
EXPECT_EQ(a, b);
|
||||
|
||||
a_adaptive.vad_probability_attack += 1.f;
|
||||
b_adaptive.vad_probability_attack = a_adaptive.vad_probability_attack;
|
||||
Toggle(a_adaptive.dry_run);
|
||||
b_adaptive.dry_run = a_adaptive.dry_run;
|
||||
EXPECT_EQ(a, b);
|
||||
|
||||
a_adaptive.level_estimator =
|
||||
AudioProcessing::Config::GainController2::LevelEstimator::kPeak;
|
||||
b_adaptive.level_estimator = a_adaptive.level_estimator;
|
||||
a_adaptive.noise_estimator = AudioProcessing::Config::GainController2::
|
||||
NoiseEstimator::kStationaryNoise;
|
||||
b_adaptive.noise_estimator = a_adaptive.noise_estimator;
|
||||
EXPECT_EQ(a, b);
|
||||
|
||||
a_adaptive.level_estimator_adjacent_speech_frames_threshold++;
|
||||
b_adaptive.level_estimator_adjacent_speech_frames_threshold =
|
||||
a_adaptive.level_estimator_adjacent_speech_frames_threshold;
|
||||
a_adaptive.vad_reset_period_ms++;
|
||||
b_adaptive.vad_reset_period_ms = a_adaptive.vad_reset_period_ms;
|
||||
EXPECT_EQ(a, b);
|
||||
|
||||
Toggle(a_adaptive.use_saturation_protector);
|
||||
b_adaptive.use_saturation_protector = a_adaptive.use_saturation_protector;
|
||||
a_adaptive.adjacent_speech_frames_threshold++;
|
||||
b_adaptive.adjacent_speech_frames_threshold =
|
||||
a_adaptive.adjacent_speech_frames_threshold;
|
||||
EXPECT_EQ(a, b);
|
||||
|
||||
a_adaptive.initial_saturation_margin_db += 1.f;
|
||||
b_adaptive.initial_saturation_margin_db =
|
||||
a_adaptive.initial_saturation_margin_db;
|
||||
EXPECT_EQ(a, b);
|
||||
|
||||
a_adaptive.extra_saturation_margin_db += 1.f;
|
||||
b_adaptive.extra_saturation_margin_db = a_adaptive.extra_saturation_margin_db;
|
||||
EXPECT_EQ(a, b);
|
||||
|
||||
a_adaptive.gain_applier_adjacent_speech_frames_threshold++;
|
||||
b_adaptive.gain_applier_adjacent_speech_frames_threshold =
|
||||
a_adaptive.gain_applier_adjacent_speech_frames_threshold;
|
||||
EXPECT_EQ(a, b);
|
||||
|
||||
a_adaptive.max_gain_change_db_per_second += 1.f;
|
||||
a_adaptive.max_gain_change_db_per_second += 1.0f;
|
||||
b_adaptive.max_gain_change_db_per_second =
|
||||
a_adaptive.max_gain_change_db_per_second;
|
||||
EXPECT_EQ(a, b);
|
||||
|
||||
a_adaptive.max_output_noise_level_dbfs -= 1.f;
|
||||
a_adaptive.max_output_noise_level_dbfs += 1.0f;
|
||||
b_adaptive.max_output_noise_level_dbfs =
|
||||
a_adaptive.max_output_noise_level_dbfs;
|
||||
EXPECT_EQ(a, b);
|
||||
|
||||
Toggle(a_adaptive.sse2_allowed);
|
||||
b_adaptive.sse2_allowed = a_adaptive.sse2_allowed;
|
||||
EXPECT_EQ(a, b);
|
||||
|
||||
Toggle(a_adaptive.avx2_allowed);
|
||||
b_adaptive.avx2_allowed = a_adaptive.avx2_allowed;
|
||||
EXPECT_EQ(a, b);
|
||||
|
||||
Toggle(a_adaptive.neon_allowed);
|
||||
b_adaptive.neon_allowed = a_adaptive.neon_allowed;
|
||||
EXPECT_EQ(a, b);
|
||||
}
|
||||
|
||||
// Checks that one differing parameter is sufficient to make two configs
|
||||
@ -3156,60 +3154,55 @@ TEST(AudioProcessing, GainController2ConfigNotEqual) {
|
||||
|
||||
Toggle(a.enabled);
|
||||
EXPECT_NE(a, b);
|
||||
a.enabled = b.enabled;
|
||||
a = b;
|
||||
|
||||
a.fixed_digital.gain_db += 1.f;
|
||||
a.fixed_digital.gain_db += 1.0f;
|
||||
EXPECT_NE(a, b);
|
||||
a.fixed_digital.gain_db = b.fixed_digital.gain_db;
|
||||
a.fixed_digital = b.fixed_digital;
|
||||
|
||||
auto& a_adaptive = a.adaptive_digital;
|
||||
const auto& b_adaptive = b.adaptive_digital;
|
||||
|
||||
Toggle(a_adaptive.enabled);
|
||||
EXPECT_NE(a, b);
|
||||
a_adaptive.enabled = b_adaptive.enabled;
|
||||
a_adaptive = b_adaptive;
|
||||
|
||||
a_adaptive.vad_probability_attack += 1.f;
|
||||
Toggle(a_adaptive.dry_run);
|
||||
EXPECT_NE(a, b);
|
||||
a_adaptive.vad_probability_attack = b_adaptive.vad_probability_attack;
|
||||
a_adaptive = b_adaptive;
|
||||
|
||||
a_adaptive.level_estimator =
|
||||
AudioProcessing::Config::GainController2::LevelEstimator::kPeak;
|
||||
a_adaptive.noise_estimator = AudioProcessing::Config::GainController2::
|
||||
NoiseEstimator::kStationaryNoise;
|
||||
EXPECT_NE(a, b);
|
||||
a_adaptive.level_estimator = b_adaptive.level_estimator;
|
||||
a_adaptive = b_adaptive;
|
||||
|
||||
a_adaptive.level_estimator_adjacent_speech_frames_threshold++;
|
||||
a_adaptive.vad_reset_period_ms++;
|
||||
EXPECT_NE(a, b);
|
||||
a_adaptive.level_estimator_adjacent_speech_frames_threshold =
|
||||
b_adaptive.level_estimator_adjacent_speech_frames_threshold;
|
||||
a_adaptive = b_adaptive;
|
||||
|
||||
Toggle(a_adaptive.use_saturation_protector);
|
||||
a_adaptive.adjacent_speech_frames_threshold++;
|
||||
EXPECT_NE(a, b);
|
||||
a_adaptive.use_saturation_protector = b_adaptive.use_saturation_protector;
|
||||
a_adaptive = b_adaptive;
|
||||
|
||||
a_adaptive.initial_saturation_margin_db += 1.f;
|
||||
a_adaptive.max_gain_change_db_per_second += 1.0f;
|
||||
EXPECT_NE(a, b);
|
||||
a_adaptive.initial_saturation_margin_db =
|
||||
b_adaptive.initial_saturation_margin_db;
|
||||
a_adaptive = b_adaptive;
|
||||
|
||||
a_adaptive.extra_saturation_margin_db += 1.f;
|
||||
a_adaptive.max_output_noise_level_dbfs += 1.0f;
|
||||
EXPECT_NE(a, b);
|
||||
a_adaptive.extra_saturation_margin_db = b_adaptive.extra_saturation_margin_db;
|
||||
a_adaptive = b_adaptive;
|
||||
|
||||
a_adaptive.gain_applier_adjacent_speech_frames_threshold++;
|
||||
Toggle(a_adaptive.sse2_allowed);
|
||||
EXPECT_NE(a, b);
|
||||
a_adaptive.gain_applier_adjacent_speech_frames_threshold =
|
||||
b_adaptive.gain_applier_adjacent_speech_frames_threshold;
|
||||
a_adaptive = b_adaptive;
|
||||
|
||||
a_adaptive.max_gain_change_db_per_second += 1.f;
|
||||
Toggle(a_adaptive.avx2_allowed);
|
||||
EXPECT_NE(a, b);
|
||||
a_adaptive.max_gain_change_db_per_second =
|
||||
b_adaptive.max_gain_change_db_per_second;
|
||||
a_adaptive = b_adaptive;
|
||||
|
||||
a_adaptive.max_output_noise_level_dbfs -= 1.f;
|
||||
Toggle(a_adaptive.neon_allowed);
|
||||
EXPECT_NE(a, b);
|
||||
a_adaptive.max_output_noise_level_dbfs =
|
||||
b_adaptive.max_output_noise_level_dbfs;
|
||||
a_adaptive = b_adaptive;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -80,30 +80,23 @@ bool Agc1Config::operator==(const Agc1Config& rhs) const {
|
||||
analog_rhs.enable_digital_adaptive;
|
||||
}
|
||||
|
||||
bool Agc2Config::operator==(const Agc2Config& rhs) const {
|
||||
const auto& adaptive_lhs = adaptive_digital;
|
||||
const auto& adaptive_rhs = rhs.adaptive_digital;
|
||||
bool Agc2Config::AdaptiveDigital::operator==(
|
||||
const Agc2Config::AdaptiveDigital& rhs) const {
|
||||
return enabled == rhs.enabled && dry_run == rhs.dry_run &&
|
||||
noise_estimator == rhs.noise_estimator &&
|
||||
vad_reset_period_ms == rhs.vad_reset_period_ms &&
|
||||
adjacent_speech_frames_threshold ==
|
||||
rhs.adjacent_speech_frames_threshold &&
|
||||
max_gain_change_db_per_second == rhs.max_gain_change_db_per_second &&
|
||||
max_output_noise_level_dbfs == rhs.max_output_noise_level_dbfs &&
|
||||
sse2_allowed == rhs.sse2_allowed && avx2_allowed == rhs.avx2_allowed &&
|
||||
neon_allowed == rhs.neon_allowed;
|
||||
}
|
||||
|
||||
bool Agc2Config::operator==(const Agc2Config& rhs) const {
|
||||
return enabled == rhs.enabled &&
|
||||
fixed_digital.gain_db == rhs.fixed_digital.gain_db &&
|
||||
adaptive_lhs.enabled == adaptive_rhs.enabled &&
|
||||
adaptive_lhs.vad_probability_attack ==
|
||||
adaptive_rhs.vad_probability_attack &&
|
||||
adaptive_lhs.level_estimator == adaptive_rhs.level_estimator &&
|
||||
adaptive_lhs.level_estimator_adjacent_speech_frames_threshold ==
|
||||
adaptive_rhs.level_estimator_adjacent_speech_frames_threshold &&
|
||||
adaptive_lhs.use_saturation_protector ==
|
||||
adaptive_rhs.use_saturation_protector &&
|
||||
adaptive_lhs.initial_saturation_margin_db ==
|
||||
adaptive_rhs.initial_saturation_margin_db &&
|
||||
adaptive_lhs.extra_saturation_margin_db ==
|
||||
adaptive_rhs.extra_saturation_margin_db &&
|
||||
adaptive_lhs.gain_applier_adjacent_speech_frames_threshold ==
|
||||
adaptive_rhs.gain_applier_adjacent_speech_frames_threshold &&
|
||||
adaptive_lhs.max_gain_change_db_per_second ==
|
||||
adaptive_rhs.max_gain_change_db_per_second &&
|
||||
adaptive_lhs.max_output_noise_level_dbfs ==
|
||||
adaptive_rhs.max_output_noise_level_dbfs;
|
||||
adaptive_digital == rhs.adaptive_digital;
|
||||
}
|
||||
|
||||
bool AudioProcessing::Config::CaptureLevelAdjustment::operator==(
|
||||
@ -160,7 +153,9 @@ std::string AudioProcessing::Config::ToString() const {
|
||||
<< ", fixed_digital: { gain_db: "
|
||||
<< gain_controller2.fixed_digital.gain_db
|
||||
<< " }, adaptive_digital: { enabled: "
|
||||
<< gain_controller2.adaptive_digital.enabled << ", noise_estimator: "
|
||||
<< gain_controller2.adaptive_digital.enabled
|
||||
<< ", dry_run: " << gain_controller2.adaptive_digital.dry_run
|
||||
<< ", noise_estimator: "
|
||||
<< GainController2NoiseEstimatorToString(
|
||||
gain_controller2.adaptive_digital.noise_estimator)
|
||||
<< ", vad_reset_period_ms: "
|
||||
|
@ -357,7 +357,13 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
|
||||
float gain_db = 0.0f;
|
||||
} fixed_digital;
|
||||
struct AdaptiveDigital {
|
||||
bool operator==(const AdaptiveDigital& rhs) const;
|
||||
bool operator!=(const AdaptiveDigital& rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
bool enabled = false;
|
||||
// Run the adaptive digital controller but the signal is not modified.
|
||||
bool dry_run = false;
|
||||
NoiseEstimator noise_estimator = kNoiseFloor;
|
||||
int vad_reset_period_ms = 1500;
|
||||
|
Reference in New Issue
Block a user