| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#ifndef MODULES_AUDIO_PROCESSING_AEC3_AEC3_FFT_H_ |
| 12 |
#define MODULES_AUDIO_PROCESSING_AEC3_AEC3_FFT_H_ |
| 13 |
|
| 14 |
#include <array> |
| 15 |
|
| 16 |
#include "api/array_view.h" |
| 17 |
#include "common_audio/third_party/ooura/fft_size_128/ooura_fft.h" |
| 18 |
#include "modules/audio_processing/aec3/aec3_common.h" |
| 19 |
#include "modules/audio_processing/aec3/fft_data.h" |
| 20 |
#include "rtc_base/checks.h" |
| 21 |
#include "rtc_base/constructor_magic.h" |
| 22 |
|
| 23 |
namespace webrtc { |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
class Aec3Fft { |
| 28 |
public: |
| 29 |
enum class Window { kRectangular, kHanning, kSqrtHanning }; |
| 30 |
|
| 31 |
Aec3Fft(); |
| 32 |
|
| 33 |
|
| 34 |
void Fft(std::array<float, kFftLength>* x, FftData* X) const { |
| 35 |
RTC_DCHECK(x); |
| 36 |
RTC_DCHECK(X); |
| 37 |
ooura_fft_.Fft(x->data()); |
| 38 |
X->CopyFromPackedArray(*x); |
| 39 |
} |
| 40 |
|
| 41 |
void Ifft(const FftData& X, std::array<float, kFftLength>* x) const { |
| 42 |
RTC_DCHECK(x); |
| 43 |
X.CopyToPackedArray(x); |
| 44 |
ooura_fft_.InverseFft(x->data()); |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
void ZeroPaddedFft(rtc::ArrayView<const float> x, |
| 50 |
Window window, |
| 51 |
FftData* X) const; |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
void PaddedFft(rtc::ArrayView<const float> x, |
| 56 |
rtc::ArrayView<const float> x_old, |
| 57 |
FftData* X) const { |
| 58 |
PaddedFft(x, x_old, Window::kRectangular, X); |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
void PaddedFft(rtc::ArrayView<const float> x, |
| 63 |
rtc::ArrayView<const float> x_old, |
| 64 |
Window window, |
| 65 |
FftData* X) const; |
| 66 |
|
| 67 |
private: |
| 68 |
const OouraFft ooura_fft_; |
| 69 |
|
| 70 |
RTC_DISALLOW_COPY_AND_ASSIGN(Aec3Fft); |
| 71 |
}; |
| 72 |
|
| 73 |
} |
| 74 |
|
| 75 |
#endif |