diff --git a/modules/audio_processing/aec3/aec3_fft.cc b/modules/audio_processing/aec3/aec3_fft.cc index 1832101855..d1d4f7da06 100644 --- a/modules/audio_processing/aec3/aec3_fft.cc +++ b/modules/audio_processing/aec3/aec3_fft.cc @@ -15,6 +15,7 @@ #include #include "rtc_base/checks.h" +#include "system_wrappers/include/cpu_features_wrapper.h" namespace webrtc { @@ -70,8 +71,18 @@ const float kSqrtHanning128[kFftLength] = { 0.19509032201613f, 0.17096188876030f, 0.14673047445536f, 0.12241067519922f, 0.09801714032956f, 0.07356456359967f, 0.04906767432742f, 0.02454122852291f}; +bool IsSse2Available() { +#if defined(WEBRTC_ARCH_X86_FAMILY) + return WebRtc_GetCPUInfo(kSSE2) != 0; +#else + return false; +#endif +} + } // namespace +Aec3Fft::Aec3Fft() : ooura_fft_(IsSse2Available()) {} + // TODO(peah): Change x to be std::array once the rest of the code allows this. void Aec3Fft::ZeroPaddedFft(rtc::ArrayView x, Window window, diff --git a/modules/audio_processing/aec3/aec3_fft.h b/modules/audio_processing/aec3/aec3_fft.h index 7a2e024d75..6f7fbe4d0e 100644 --- a/modules/audio_processing/aec3/aec3_fft.h +++ b/modules/audio_processing/aec3/aec3_fft.h @@ -28,7 +28,8 @@ class Aec3Fft { public: enum class Window { kRectangular, kHanning, kSqrtHanning }; - Aec3Fft() = default; + Aec3Fft(); + // Computes the FFT. Note that both the input and output are modified. void Fft(std::array* x, FftData* X) const { RTC_DCHECK(x); diff --git a/modules/audio_processing/agc2/BUILD.gn b/modules/audio_processing/agc2/BUILD.gn index 8d9bb14731..bfef2252c3 100644 --- a/modules/audio_processing/agc2/BUILD.gn +++ b/modules/audio_processing/agc2/BUILD.gn @@ -153,6 +153,7 @@ rtc_library("noise_level_estimator") { "../../../common_audio/third_party/ooura:fft_size_128", "../../../rtc_base:checks", "../../../rtc_base:macromagic", + "../../../system_wrappers:cpu_features_api", ] configs += [ "..:apm_debug_dump" ] diff --git a/modules/audio_processing/agc2/signal_classifier.cc b/modules/audio_processing/agc2/signal_classifier.cc index 8778c49426..38334f7ec5 100644 --- a/modules/audio_processing/agc2/signal_classifier.cc +++ b/modules/audio_processing/agc2/signal_classifier.cc @@ -19,10 +19,19 @@ #include "modules/audio_processing/agc2/noise_spectrum_estimator.h" #include "modules/audio_processing/logging/apm_data_dumper.h" #include "rtc_base/checks.h" +#include "system_wrappers/include/cpu_features_wrapper.h" namespace webrtc { namespace { +bool IsSse2Available() { +#if defined(WEBRTC_ARCH_X86_FAMILY) + return WebRtc_GetCPUInfo(kSSE2) != 0; +#else + return false; +#endif +} + void RemoveDcLevel(rtc::ArrayView x) { RTC_DCHECK_LT(0, x.size()); float mean = std::accumulate(x.data(), x.data() + x.size(), 0.f); @@ -109,7 +118,8 @@ void SignalClassifier::FrameExtender::ExtendFrame( SignalClassifier::SignalClassifier(ApmDataDumper* data_dumper) : data_dumper_(data_dumper), down_sampler_(data_dumper_), - noise_spectrum_estimator_(data_dumper_) { + noise_spectrum_estimator_(data_dumper_), + ooura_fft_(IsSse2Available()) { Initialize(48000); } SignalClassifier::~SignalClassifier() {}