WebRTC AGC Hybrid experiment: wire-up AGC2 params
ConfigAutomaticGainControl now supports two additional AGC2 params that
are needed for experimentation.
Tested: checked feature activation via AECdump using appr.tc
$ out/Default/Chromium.app/Contents/MacOS/Chromium \
--enable-features=WebrtcHybridAgc
(cherry picked from commit b94bc46084bf09c9e57c9cc0fcbfe770a64bbbe1)
Bug: chromium:1135177
Change-Id: I81225ebc05a66ca18e5c4b2edc350cd42f19c31a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2446052
Commit-Queue: Ale Bzk <[email protected]>
Reviewed-by: Henrik Boström <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#813741}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2462085
Cr-Commit-Position: refs/branch-heads/4280@{#189}
Cr-Branched-From: ea420fb963f9658c9969b6513c56b8f47efa1a2a-refs/heads/master@{#812852}
diff --git a/third_party/blink/renderer/modules/mediastream/media_stream_audio_processor.cc b/third_party/blink/renderer/modules/mediastream/media_stream_audio_processor.cc
index baa1e425..868b1729 100644
--- a/third_party/blink/renderer/modules/mediastream/media_stream_audio_processor.cc
+++ b/third_party/blink/renderer/modules/mediastream/media_stream_audio_processor.cc
@@ -607,6 +607,12 @@
base::GetFieldTrialParamByFeatureAsInt(
features::kWebRtcHybridAgc,
"gain_applier_speech_frames_threshold", 1);
+ agc2_properties->max_gain_change_db_per_second =
+ base::GetFieldTrialParamByFeatureAsInt(
+ features::kWebRtcHybridAgc, "max_gain_change_db_per_second", 3);
+ agc2_properties->max_output_noise_level_dbfs =
+ base::GetFieldTrialParamByFeatureAsInt(
+ features::kWebRtcHybridAgc, "max_output_noise_level_dbfs", -50);
}
blink::ConfigAutomaticGainControl(
properties.goog_auto_gain_control,
diff --git a/third_party/blink/renderer/platform/mediastream/media_stream_audio_processor_options.cc b/third_party/blink/renderer/platform/mediastream/media_stream_audio_processor_options.cc
index 1f7ad74..d4aaea5 100644
--- a/third_party/blink/renderer/platform/mediastream/media_stream_audio_processor_options.cc
+++ b/third_party/blink/renderer/platform/mediastream/media_stream_audio_processor_options.cc
@@ -240,6 +240,12 @@
adaptive_digital.gain_applier_adjacent_speech_frames_threshold =
agc2_properties->gain_applier_speech_frames_threshold;
+
+ adaptive_digital.max_gain_change_db_per_second =
+ agc2_properties->max_gain_change_db_per_second;
+
+ adaptive_digital.max_output_noise_level_dbfs =
+ agc2_properties->max_output_noise_level_dbfs;
}
} else if (use_fixed_digital_agc2) {
// Experimental AGC is disabled, thus hybrid AGC is disabled. Config AGC2
diff --git a/third_party/blink/renderer/platform/mediastream/media_stream_audio_processor_options.h b/third_party/blink/renderer/platform/mediastream/media_stream_audio_processor_options.h
index 15779e8c..a5c2b19 100644
--- a/third_party/blink/renderer/platform/mediastream/media_stream_audio_processor_options.h
+++ b/third_party/blink/renderer/platform/mediastream/media_stream_audio_processor_options.h
@@ -123,6 +123,8 @@
int initial_saturation_margin_db;
int extra_saturation_margin_db;
int gain_applier_speech_frames_threshold;
+ int max_gain_change_db_per_second;
+ int max_output_noise_level_dbfs;
};
// Configures automatic gain control in `apm_config`. If `agc_enabled` is true
diff --git a/third_party/blink/renderer/platform/mediastream/media_stream_audio_processor_options_test.cc b/third_party/blink/renderer/platform/mediastream/media_stream_audio_processor_options_test.cc
index 84d942f..5075bba 100644
--- a/third_party/blink/renderer/platform/mediastream/media_stream_audio_processor_options_test.cc
+++ b/third_party/blink/renderer/platform/mediastream/media_stream_audio_processor_options_test.cc
@@ -49,6 +49,8 @@
agc2_properties.initial_saturation_margin_db = 10;
agc2_properties.extra_saturation_margin_db = 10;
agc2_properties.gain_applier_speech_frames_threshold = 5;
+ agc2_properties.max_gain_change_db_per_second = 4;
+ agc2_properties.max_output_noise_level_dbfs = -22;
const double compression_gain_db = 10.0;
ConfigAutomaticGainControl(
@@ -82,6 +84,10 @@
agc2_properties.extra_saturation_margin_db);
EXPECT_EQ(adaptive_digital.gain_applier_adjacent_speech_frames_threshold,
agc2_properties.gain_applier_speech_frames_threshold);
+ EXPECT_FLOAT_EQ(adaptive_digital.max_gain_change_db_per_second,
+ agc2_properties.max_gain_change_db_per_second);
+ EXPECT_FLOAT_EQ(adaptive_digital.max_output_noise_level_dbfs,
+ agc2_properties.max_output_noise_level_dbfs);
}
TEST(PopulateApmConfigTest, DefaultWithoutConfigJson) {