Commit 26bb5b2a authored by Alessio Bazzica's avatar Alessio Bazzica Committed by Chromium LUCI CQ

WebRtcHybridAgc experiment: wire up AGC2 SIMD kill switches

AGC2 includes SIMD optimizations for different platforms.
Recently, SSE2 and NEON code has been added (see [1]) and kill switches
have been added to the GainController2 configuration in APM.
When `(sse2|neon)_allowed` is set to false, the corresponding SIMD code
path won't be used even if available.

Tested: appr.tc call made

[1] third_party/webrtc/modules/audio_processing/agc2/rnn_vad/vector_math.h

Bug: webrtc:7494
Change-Id: I2c10b09210914dfe8362c8d8b7fd434c6e4043fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2620801Reviewed-by: default avatarOlga Sharonova <olka@chromium.org>
Commit-Queue: Ale Bzk <alessiob@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842012}
parent 89bd4cfc
...@@ -613,8 +613,12 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule( ...@@ -613,8 +613,12 @@ void MediaStreamAudioProcessor::InitializeAudioProcessingModule(
agc2_properties->max_output_noise_level_dbfs = agc2_properties->max_output_noise_level_dbfs =
base::GetFieldTrialParamByFeatureAsInt( base::GetFieldTrialParamByFeatureAsInt(
features::kWebRtcHybridAgc, "max_output_noise_level_dbfs", -50); features::kWebRtcHybridAgc, "max_output_noise_level_dbfs", -50);
agc2_properties->sse2_allowed = base::GetFieldTrialParamByFeatureAsBool(
features::kWebRtcHybridAgc, "sse2_allowed", true);
agc2_properties->avx2_allowed = base::GetFieldTrialParamByFeatureAsBool( agc2_properties->avx2_allowed = base::GetFieldTrialParamByFeatureAsBool(
features::kWebRtcHybridAgc, "avx2_allowed", true); features::kWebRtcHybridAgc, "avx2_allowed", true);
agc2_properties->neon_allowed = base::GetFieldTrialParamByFeatureAsBool(
features::kWebRtcHybridAgc, "neon_allowed", true);
} }
blink::ConfigAutomaticGainControl( blink::ConfigAutomaticGainControl(
properties.goog_auto_gain_control, properties.goog_auto_gain_control,
......
...@@ -122,7 +122,7 @@ class MODULES_EXPORT MediaStreamAudioProcessor ...@@ -122,7 +122,7 @@ class MODULES_EXPORT MediaStreamAudioProcessor
FRIEND_TEST_ALL_PREFIXES(MediaStreamAudioProcessorTest, FRIEND_TEST_ALL_PREFIXES(MediaStreamAudioProcessorTest,
TestAgcEnableHybridAgc); TestAgcEnableHybridAgc);
FRIEND_TEST_ALL_PREFIXES(MediaStreamAudioProcessorTest, FRIEND_TEST_ALL_PREFIXES(MediaStreamAudioProcessorTest,
TestAgcEnableHybridAgcAvx2NotAllowed); TestAgcEnableHybridAgcSimdNotAllowed);
// WebRtcPlayoutDataSource::Sink implementation. // WebRtcPlayoutDataSource::Sink implementation.
void OnPlayoutData(media::AudioBus* audio_bus, void OnPlayoutData(media::AudioBus* audio_bus,
......
...@@ -434,7 +434,9 @@ TEST_F(MediaStreamAudioProcessorTest, TestAgcEnableHybridAgc) { ...@@ -434,7 +434,9 @@ TEST_F(MediaStreamAudioProcessorTest, TestAgcEnableHybridAgc) {
{"gain_applier_speech_frames_threshold", "5"}, {"gain_applier_speech_frames_threshold", "5"},
{"max_gain_change_db_per_second", "4"}, {"max_gain_change_db_per_second", "4"},
{"max_output_noise_level_dbfs", "-22"}, {"max_output_noise_level_dbfs", "-22"},
{"avx2_allowed", "true"}}); {"sse2_allowed", "true"},
{"avx2_allowed", "true"},
{"neon_allowed", "true"}});
blink::AudioProcessingProperties properties; blink::AudioProcessingProperties properties;
properties.goog_auto_gain_control = true; properties.goog_auto_gain_control = true;
...@@ -475,13 +477,17 @@ TEST_F(MediaStreamAudioProcessorTest, TestAgcEnableHybridAgc) { ...@@ -475,13 +477,17 @@ TEST_F(MediaStreamAudioProcessorTest, TestAgcEnableHybridAgc) {
EXPECT_EQ(adaptive_digital.gain_applier_adjacent_speech_frames_threshold, 5); EXPECT_EQ(adaptive_digital.gain_applier_adjacent_speech_frames_threshold, 5);
EXPECT_FLOAT_EQ(adaptive_digital.max_gain_change_db_per_second, 4); EXPECT_FLOAT_EQ(adaptive_digital.max_gain_change_db_per_second, 4);
EXPECT_FLOAT_EQ(adaptive_digital.max_output_noise_level_dbfs, -22); EXPECT_FLOAT_EQ(adaptive_digital.max_output_noise_level_dbfs, -22);
EXPECT_TRUE(adaptive_digital.sse2_allowed);
EXPECT_TRUE(adaptive_digital.avx2_allowed); EXPECT_TRUE(adaptive_digital.avx2_allowed);
EXPECT_TRUE(adaptive_digital.neon_allowed);
} }
TEST_F(MediaStreamAudioProcessorTest, TestAgcEnableHybridAgcAvx2NotAllowed) { TEST_F(MediaStreamAudioProcessorTest, TestAgcEnableHybridAgcSimdNotAllowed) {
::base::test::ScopedFeatureList feature_list; ::base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeatureWithParameters(features::kWebRtcHybridAgc, feature_list.InitAndEnableFeatureWithParameters(features::kWebRtcHybridAgc,
{{"avx2_allowed", "false"}}); {{"sse2_allowed", "false"},
{"avx2_allowed", "false"},
{"neon_allowed", "false"}});
blink::AudioProcessingProperties properties; blink::AudioProcessingProperties properties;
properties.goog_auto_gain_control = true; properties.goog_auto_gain_control = true;
...@@ -497,7 +503,9 @@ TEST_F(MediaStreamAudioProcessorTest, TestAgcEnableHybridAgcAvx2NotAllowed) { ...@@ -497,7 +503,9 @@ TEST_F(MediaStreamAudioProcessorTest, TestAgcEnableHybridAgcAvx2NotAllowed) {
audio_processor->GetAudioProcessingModuleConfig(); audio_processor->GetAudioProcessingModuleConfig();
ASSERT_TRUE(apm_config); ASSERT_TRUE(apm_config);
EXPECT_FALSE(apm_config->gain_controller2.adaptive_digital.sse2_allowed);
EXPECT_FALSE(apm_config->gain_controller2.adaptive_digital.avx2_allowed); EXPECT_FALSE(apm_config->gain_controller2.adaptive_digital.avx2_allowed);
EXPECT_FALSE(apm_config->gain_controller2.adaptive_digital.neon_allowed);
} }
} // namespace blink } // namespace blink
...@@ -247,7 +247,9 @@ void ConfigAutomaticGainControl( ...@@ -247,7 +247,9 @@ void ConfigAutomaticGainControl(
adaptive_digital.max_output_noise_level_dbfs = adaptive_digital.max_output_noise_level_dbfs =
agc2_properties->max_output_noise_level_dbfs; agc2_properties->max_output_noise_level_dbfs;
adaptive_digital.sse2_allowed = agc2_properties->sse2_allowed;
adaptive_digital.avx2_allowed = agc2_properties->avx2_allowed; adaptive_digital.avx2_allowed = agc2_properties->avx2_allowed;
adaptive_digital.neon_allowed = agc2_properties->neon_allowed;
} }
} else if (use_fixed_digital_agc2) { } else if (use_fixed_digital_agc2) {
// Experimental AGC is disabled, thus hybrid AGC is disabled. Config AGC2 // Experimental AGC is disabled, thus hybrid AGC is disabled. Config AGC2
......
...@@ -125,7 +125,9 @@ struct PLATFORM_EXPORT AdaptiveGainController2Properties { ...@@ -125,7 +125,9 @@ struct PLATFORM_EXPORT AdaptiveGainController2Properties {
int gain_applier_speech_frames_threshold; int gain_applier_speech_frames_threshold;
int max_gain_change_db_per_second; int max_gain_change_db_per_second;
int max_output_noise_level_dbfs; int max_output_noise_level_dbfs;
bool sse2_allowed;
bool avx2_allowed; bool avx2_allowed;
bool neon_allowed;
}; };
// Configures automatic gain control in `apm_config`. If `agc_enabled` is true // Configures automatic gain control in `apm_config`. If `agc_enabled` is true
......
...@@ -51,7 +51,9 @@ TEST(ConfigAutomaticGainControlTest, EnableHybridAGC) { ...@@ -51,7 +51,9 @@ TEST(ConfigAutomaticGainControlTest, EnableHybridAGC) {
agc2_properties.gain_applier_speech_frames_threshold = 5; agc2_properties.gain_applier_speech_frames_threshold = 5;
agc2_properties.max_gain_change_db_per_second = 4; agc2_properties.max_gain_change_db_per_second = 4;
agc2_properties.max_output_noise_level_dbfs = -22; agc2_properties.max_output_noise_level_dbfs = -22;
agc2_properties.sse2_allowed = true;
agc2_properties.avx2_allowed = true; agc2_properties.avx2_allowed = true;
agc2_properties.neon_allowed = true;
const double compression_gain_db = 10.0; const double compression_gain_db = 10.0;
ConfigAutomaticGainControl( ConfigAutomaticGainControl(
...@@ -89,7 +91,9 @@ TEST(ConfigAutomaticGainControlTest, EnableHybridAGC) { ...@@ -89,7 +91,9 @@ TEST(ConfigAutomaticGainControlTest, EnableHybridAGC) {
agc2_properties.max_gain_change_db_per_second); agc2_properties.max_gain_change_db_per_second);
EXPECT_FLOAT_EQ(adaptive_digital.max_output_noise_level_dbfs, EXPECT_FLOAT_EQ(adaptive_digital.max_output_noise_level_dbfs,
agc2_properties.max_output_noise_level_dbfs); agc2_properties.max_output_noise_level_dbfs);
EXPECT_TRUE(adaptive_digital.sse2_allowed);
EXPECT_TRUE(adaptive_digital.avx2_allowed); EXPECT_TRUE(adaptive_digital.avx2_allowed);
EXPECT_TRUE(adaptive_digital.neon_allowed);
} }
TEST(PopulateApmConfigTest, DefaultWithoutConfigJson) { TEST(PopulateApmConfigTest, DefaultWithoutConfigJson) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment