SSE2 and NEON kill switches for AGC2

Bug: webrtc:7494
Change-Id: I221b717b5cf3c41b7b637e9234d1e339a0e6c7e5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/199967
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32918}
diff --git a/modules/audio_processing/agc2/adaptive_agc.cc b/modules/audio_processing/agc2/adaptive_agc.cc
index 4df3b58..e72942a 100644
--- a/modules/audio_processing/agc2/adaptive_agc.cc
+++ b/modules/audio_processing/agc2/adaptive_agc.cc
@@ -33,12 +33,19 @@
 constexpr float kMaxGainChangePerSecondDb = 3.f;
 constexpr float kMaxOutputNoiseLevelDbfs = -50.f;
 
-// Detects the available CPU features and applies a kill-switch to AVX2.
-AvailableCpuFeatures GetAllowedCpuFeatures(bool avx2_allowed) {
+// Detects the available CPU features and applies any kill-switches.
+AvailableCpuFeatures GetAllowedCpuFeatures(
+    const AudioProcessing::Config::GainController2::AdaptiveDigital& config) {
   AvailableCpuFeatures features = GetAvailableCpuFeatures();
-  if (!avx2_allowed) {
+  if (!config.sse2_allowed) {
+    features.sse2 = false;
+  }
+  if (!config.avx2_allowed) {
     features.avx2 = false;
   }
+  if (!config.neon_allowed) {
+    features.neon = false;
+  }
   return features;
 }
 
@@ -65,7 +72,7 @@
           config.adaptive_digital.initial_saturation_margin_db,
           config.adaptive_digital.extra_saturation_margin_db),
       vad_(config.adaptive_digital.vad_probability_attack,
-           GetAllowedCpuFeatures(config.adaptive_digital.avx2_allowed)),
+           GetAllowedCpuFeatures(config.adaptive_digital)),
       gain_applier_(
           apm_data_dumper,
           config.adaptive_digital.gain_applier_adjacent_speech_frames_threshold,
diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h
index 802ff9d..5a0e1df 100644
--- a/modules/audio_processing/include/audio_processing.h
+++ b/modules/audio_processing/include/audio_processing.h
@@ -365,7 +365,9 @@
         int gain_applier_adjacent_speech_frames_threshold = 1;
         float max_gain_change_db_per_second = 3.f;
         float max_output_noise_level_dbfs = -50.f;
+        bool sse2_allowed = true;
         bool avx2_allowed = true;
+        bool neon_allowed = true;
       } adaptive_digital;
     } gain_controller2;