
We are using the Ooura FFT in a few places: - AGC - Transient suppression - Noise suppression The optimized OpenMAX DL FFT is considerably faster, but currently does not compile everywhere, notably on iOS. This change will allow us to use Openmax when possible and otherwise fall back to Ooura. (Unfortunately, noise suppression won't be able to take advantage of it since it's not C++. Upgrade time?) R=aluebs@webrtc.org, mgraczyk@chromium.org Review URL: https://webrtc-codereview.appspot.com/45789004 Cr-Commit-Position: refs/heads/master@{#8798} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8798 4adac7df-926f-26a2-2b94-8c16560cd09d
70 lines
1.9 KiB
C++
70 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#include "webrtc/common_audio/real_fourier_openmax.h"
|
|
|
|
#include <cstdlib>
|
|
|
|
#include "dl/sp/api/omxSP.h"
|
|
#include "webrtc/base/checks.h"
|
|
|
|
namespace webrtc {
|
|
|
|
using std::complex;
|
|
|
|
namespace {
|
|
|
|
// Creates and initializes the Openmax state. Transfers ownership to caller.
|
|
OMXFFTSpec_R_F32* CreateOpenmaxState(int order) {
|
|
CHECK_GE(order, 1);
|
|
// The omx implementation uses this macro to check order validity.
|
|
CHECK_LE(order, TWIDDLE_TABLE_ORDER);
|
|
|
|
OMX_INT buffer_size;
|
|
OMXResult r = omxSP_FFTGetBufSize_R_F32(order, &buffer_size);
|
|
CHECK_EQ(r, OMX_Sts_NoErr);
|
|
|
|
OMXFFTSpec_R_F32* omx_spec = malloc(buffer_size);
|
|
DCHECK(omx_spec);
|
|
|
|
r = omxSP_FFTInit_R_F32(omx_spec, order);
|
|
CHECK_EQ(r, OMX_Sts_NoErr);
|
|
return omx_spec;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
RealFourierOpenmax::RealFourierOpenmax(int fft_order)
|
|
: order_(fft_order),
|
|
omx_spec_(CreateOpenmaxState(order_)) {
|
|
}
|
|
|
|
RealFourierOpenmax::~RealFourierOpenmax() {
|
|
free(omx_spec_);
|
|
}
|
|
|
|
void RealFourierOpenmax::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
|
|
OMXResult r =
|
|
omxSP_FFTFwd_RToCCS_F32(src, reinterpret_cast<OMX_F32*>(dest), omx_spec_);
|
|
CHECK_EQ(r, OMX_Sts_NoErr);
|
|
}
|
|
|
|
void RealFourierOpenmax::Inverse(const complex<float>* src, float* dest) const {
|
|
OMXResult r =
|
|
omxSP_FFTInv_CCSToR_F32(reinterpret_cast<const OMX_F32*>(src), dest,
|
|
omx_spec_);
|
|
CHECK_EQ(r, OMX_Sts_NoErr);
|
|
}
|
|
|
|
} // namespace webrtc
|
|
|