peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_FFT_H_ |
| 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_FFT_H_ |
| 13 | |
| 14 | #include <array> |
| 15 | |
kwiberg | 529662a | 2017-09-04 05:43:17 -0700 | [diff] [blame] | 16 | #include "webrtc/api/array_view.h" |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 17 | #include "webrtc/modules/audio_processing/aec3/aec3_common.h" |
| 18 | #include "webrtc/modules/audio_processing/aec3/fft_data.h" |
| 19 | #include "webrtc/modules/audio_processing/utility/ooura_fft.h" |
Edward Lemur | c20978e | 2017-07-06 19:44:34 +0200 | [diff] [blame] | 20 | #include "webrtc/rtc_base/constructormagic.h" |
peah | 522d71b | 2017-02-23 05:16:26 -0800 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | // Wrapper class that provides 128 point real valued FFT functionality with the |
| 25 | // FftData type. |
| 26 | class Aec3Fft { |
| 27 | public: |
| 28 | Aec3Fft() = default; |
| 29 | // Computes the FFT. Note that both the input and output are modified. |
| 30 | void Fft(std::array<float, kFftLength>* x, FftData* X) const { |
| 31 | RTC_DCHECK(x); |
| 32 | RTC_DCHECK(X); |
| 33 | ooura_fft_.Fft(x->data()); |
| 34 | X->CopyFromPackedArray(*x); |
| 35 | } |
| 36 | // Computes the inverse Fft. |
| 37 | void Ifft(const FftData& X, std::array<float, kFftLength>* x) const { |
| 38 | RTC_DCHECK(x); |
| 39 | X.CopyToPackedArray(x); |
| 40 | ooura_fft_.InverseFft(x->data()); |
| 41 | } |
| 42 | |
| 43 | // Pads the input with kFftLengthBy2 initial zeros before computing the Fft. |
| 44 | void ZeroPaddedFft(rtc::ArrayView<const float> x, FftData* X) const; |
| 45 | |
| 46 | // Concatenates the kFftLengthBy2 values long x and x_old before computing the |
| 47 | // Fft. After that, x is copied to x_old. |
| 48 | void PaddedFft(rtc::ArrayView<const float> x, |
| 49 | rtc::ArrayView<float> x_old, |
| 50 | FftData* X) const; |
| 51 | |
| 52 | private: |
| 53 | const OouraFft ooura_fft_; |
| 54 | |
| 55 | RTC_DISALLOW_COPY_AND_ASSIGN(Aec3Fft); |
| 56 | }; |
| 57 | |
| 58 | } // namespace webrtc |
| 59 | |
| 60 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_AEC3_FFT_H_ |