summaryrefslogtreecommitdiff
path: root/webrtc/common_audio/real_fourier_ooura.cc
diff options
context:
space:
mode:
Diffstat (limited to 'webrtc/common_audio/real_fourier_ooura.cc')
-rw-r--r--webrtc/common_audio/real_fourier_ooura.cc26
1 files changed, 16 insertions, 10 deletions
diff --git a/webrtc/common_audio/real_fourier_ooura.cc b/webrtc/common_audio/real_fourier_ooura.cc
index 8cd4c86..9acda54 100644
--- a/webrtc/common_audio/real_fourier_ooura.cc
+++ b/webrtc/common_audio/real_fourier_ooura.cc
@@ -8,13 +8,13 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "webrtc/common_audio/real_fourier_ooura.h"
+#include "common_audio/real_fourier_ooura.h"
-#include <cmath>
#include <algorithm>
+#include <cmath>
-#include "webrtc/base/checks.h"
-#include "webrtc/common_audio/fft4g.h"
+#include "common_audio/third_party/ooura/fft_size_256/fft4g.h"
+#include "rtc_base/checks.h"
namespace webrtc {
@@ -28,8 +28,8 @@ void Conjugate(complex<float>* array, size_t complex_length) {
}
size_t ComputeWorkIpSize(size_t fft_length) {
- return static_cast<size_t>(2 + std::ceil(std::sqrt(
- static_cast<float>(fft_length))));
+ return static_cast<size_t>(
+ 2 + std::ceil(std::sqrt(static_cast<float>(fft_length))));
}
} // namespace
@@ -45,11 +45,13 @@ RealFourierOoura::RealFourierOoura(int fft_order)
RTC_CHECK_GE(fft_order, 1);
}
+RealFourierOoura::~RealFourierOoura() = default;
+
void RealFourierOoura::Forward(const float* src, complex<float>* dest) const {
{
// This cast is well-defined since C++11. See "Non-static data members" at:
// http://en.cppreference.com/w/cpp/numeric/complex
- auto dest_float = reinterpret_cast<float*>(dest);
+ auto* dest_float = reinterpret_cast<float*>(dest);
std::copy(src, src + length_, dest_float);
WebRtc_rdft(length_, 1, dest_float, work_ip_.get(), work_w_.get());
}
@@ -63,7 +65,7 @@ void RealFourierOoura::Forward(const float* src, complex<float>* dest) const {
void RealFourierOoura::Inverse(const complex<float>* src, float* dest) const {
{
- auto dest_complex = reinterpret_cast<complex<float>*>(dest);
+ auto* dest_complex = reinterpret_cast<complex<float>*>(dest);
// The real output array is shorter than the input complex array by one
// complex element.
const size_t dest_complex_length = complex_length_ - 1;
@@ -71,8 +73,8 @@ void RealFourierOoura::Inverse(const complex<float>* src, float* dest) const {
// Restore Ooura's conjugate definition.
Conjugate(dest_complex, dest_complex_length);
// Restore real[n/2] to imag[0].
- dest_complex[0] = complex<float>(dest_complex[0].real(),
- src[complex_length_ - 1].real());
+ dest_complex[0] =
+ complex<float>(dest_complex[0].real(), src[complex_length_ - 1].real());
}
WebRtc_rdft(length_, -1, dest, work_ip_.get(), work_w_.get());
@@ -82,4 +84,8 @@ void RealFourierOoura::Inverse(const complex<float>* src, float* dest) const {
std::for_each(dest, dest + length_, [scale](float& v) { v *= scale; });
}
+int RealFourierOoura::order() const {
+ return order_;
+}
+
} // namespace webrtc