#ifndef FFTFrame_h
#define FFTFrame_h
#include "platform/PlatformExport.h"
#include "platform/audio/AudioArray.h"
#if OS(MACOSX)
#include <Accelerate/Accelerate.h>
#elif USE(WEBAUDIO_OPENMAX_DL_FFT)
#include <dl/sp/api/omxSP.h>
#elif USE(WEBAUDIO_FFMPEG)
struct RDFTContext;
#endif
#if USE(WEBAUDIO_IPP)
#include <ipps.h>
#endif
#include "wtf/Forward.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/Threading.h"
namespace WebCore {
class PLATFORM_EXPORT FFTFrame {
public:
FFTFrame(unsigned fftSize);
FFTFrame();
FFTFrame(const FFTFrame& frame);
~FFTFrame();
static void initialize();
static void cleanup();
void doFFT(const float* data);
void doInverseFFT(float* data);
float* realData() const;
float* imagData() const;
void print();
static PassOwnPtr<FFTFrame> createInterpolatedFrame(const FFTFrame& frame1, const FFTFrame& frame2, double x);
void doPaddedFFT(const float* data, size_t dataSize);
double extractAverageGroupDelay();
void addConstantGroupDelay(double sampleFrameDelay);
void multiply(const FFTFrame&);
unsigned fftSize() const { return m_FFTSize; }
unsigned log2FFTSize() const { return m_log2FFTSize; }
private:
unsigned m_FFTSize;
unsigned m_log2FFTSize;
void interpolateFrequencyComponents(const FFTFrame& frame1, const FFTFrame& frame2, double x);
#if OS(MACOSX)
DSPSplitComplex& dspSplitComplex() { return m_frame; }
DSPSplitComplex dspSplitComplex() const { return m_frame; }
static FFTSetup fftSetupForSize(unsigned fftSize);
static FFTSetup* fftSetups;
FFTSetup m_FFTSetup;
DSPSplitComplex m_frame;
AudioFloatArray m_realData;
AudioFloatArray m_imagData;
#else
#if USE(WEBAUDIO_FFMPEG)
static RDFTContext* contextForSize(unsigned fftSize, int trans);
RDFTContext* m_forwardContext;
RDFTContext* m_inverseContext;
float* getUpToDateComplexData();
AudioFloatArray m_complexData;
AudioFloatArray m_realData;
AudioFloatArray m_imagData;
#endif
#if USE(WEBAUDIO_IPP)
Ipp8u* m_buffer;
IppsDFTSpec_R_32f* m_DFTSpec;
float* getUpToDateComplexData();
AudioFloatArray m_complexData;
AudioFloatArray m_realData;
AudioFloatArray m_imagData;
#endif
#if USE(WEBAUDIO_OPENMAX_DL_FFT)
static OMXFFTSpec_R_F32* contextForSize(unsigned log2FFTSize);
OMXFFTSpec_R_F32* m_forwardContext;
OMXFFTSpec_R_F32* m_inverseContext;
AudioFloatArray m_complexData;
AudioFloatArray m_realData;
AudioFloatArray m_imagData;
#endif
#endif
};
}
#endif