Change to using the new Ooura constructor

Bug: b/155316201
Change-Id: I40000e30df7a495a0937885abea19caeb599e00a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/176378
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31411}
This commit is contained in:
Per Åhgren
2020-06-02 14:28:25 +02:00
committed by Commit Bot
parent 4b1ab57283
commit a6c70741e7
4 changed files with 25 additions and 2 deletions

View File

@ -15,6 +15,7 @@
#include <iterator>
#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<const float> x,
Window window,

View File

@ -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<float, kFftLength>* x, FftData* X) const {
RTC_DCHECK(x);

View File

@ -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" ]

View File

@ -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<float> 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() {}