Skip to content

Commit

Permalink
SSE2 and NEON kill switches for AGC2
Browse files Browse the repository at this point in the history
Bug: webrtc:7494
Change-Id: I221b717b5cf3c41b7b637e9234d1e339a0e6c7e5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/199967
Reviewed-by: Sam Zackrisson <[email protected]>
Commit-Queue: Alessio Bazzica <[email protected]>
Cr-Commit-Position: refs/heads/master@{#32918}
  • Loading branch information
alebzk authored and Commit Bot committed Jan 7, 2021
1 parent b8f32c4 commit 524f682
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 11 additions & 4 deletions modules/audio_processing/agc2/adaptive_agc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@ constexpr int kGainApplierAdjacentSpeechFramesThreshold = 1;
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;
}

Expand All @@ -65,7 +72,7 @@ AdaptiveAgc::AdaptiveAgc(ApmDataDumper* apm_data_dumper,
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,
Expand Down
2 changes: 2 additions & 0 deletions modules/audio_processing/include/audio_processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,9 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
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;

Expand Down

0 comments on commit 524f682

Please sign in to comment.