OLD | NEW |
1 /* Copyright (C) 2013 Google Inc. All rights reserved. | 1 /* Copyright (C) 2013 Google Inc. All rights reserved. |
2 * | 2 * |
3 * Redistribution and use in source and binary forms, with or without | 3 * Redistribution and use in source and binary forms, with or without |
4 * modification, are permitted provided that the following conditions | 4 * modification, are permitted provided that the following conditions |
5 * are met: | 5 * are met: |
6 * | 6 * |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 #include "platform/audio/FFTFrame.h" | 29 #include "platform/audio/FFTFrame.h" |
30 | 30 |
31 #include <dl/sp/api/armSP.h> | 31 #include <dl/sp/api/armSP.h> |
32 #include <dl/sp/api/omxSP.h> | 32 #include <dl/sp/api/omxSP.h> |
33 #include "platform/audio/AudioArray.h" | 33 #include "platform/audio/AudioArray.h" |
34 #include "platform/wtf/MathExtras.h" | 34 #include "platform/wtf/MathExtras.h" |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 #if DCHECK_IS_ON() | |
39 const unsigned kMaxFFTPow2Size = 15; | 38 const unsigned kMaxFFTPow2Size = 15; |
40 #endif | |
41 | 39 |
42 // Normal constructor: allocates for a given fftSize. | 40 // Normal constructor: allocates for a given fftSize. |
43 FFTFrame::FFTFrame(unsigned fftSize) | 41 FFTFrame::FFTFrame(unsigned fftSize) |
44 : m_FFTSize(fftSize), | 42 : m_FFTSize(fftSize), |
45 m_log2FFTSize(static_cast<unsigned>(log2(fftSize))), | 43 m_log2FFTSize(static_cast<unsigned>(log2(fftSize))), |
46 m_realData(fftSize / 2), | 44 m_realData(fftSize / 2), |
47 m_imagData(fftSize / 2), | 45 m_imagData(fftSize / 2), |
48 m_forwardContext(nullptr), | 46 m_forwardContext(nullptr), |
49 m_inverseContext(nullptr), | 47 m_inverseContext(nullptr), |
50 m_complexData(fftSize) { | 48 m_complexData(fftSize) { |
51 // We only allow power of two. | 49 // We only allow power of two. |
52 ASSERT(1UL << m_log2FFTSize == m_FFTSize); | 50 DCHECK_EQ(1UL << m_log2FFTSize, m_FFTSize); |
53 | 51 |
54 m_forwardContext = contextForSize(m_log2FFTSize); | 52 m_forwardContext = contextForSize(m_log2FFTSize); |
55 m_inverseContext = contextForSize(m_log2FFTSize); | 53 m_inverseContext = contextForSize(m_log2FFTSize); |
56 } | 54 } |
57 | 55 |
58 // Creates a blank/empty frame (interpolate() must later be called). | 56 // Creates a blank/empty frame (interpolate() must later be called). |
59 FFTFrame::FFTFrame() | 57 FFTFrame::FFTFrame() |
60 : m_FFTSize(0), | 58 : m_FFTSize(0), |
61 m_log2FFTSize(0), | 59 m_log2FFTSize(0), |
62 m_forwardContext(nullptr), | 60 m_forwardContext(nullptr), |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 fftData[1] = 0; | 134 fftData[1] = 0; |
137 fftData[m_FFTSize] = imag[0]; | 135 fftData[m_FFTSize] = imag[0]; |
138 fftData[m_FFTSize + 1] = 0; | 136 fftData[m_FFTSize + 1] = 0; |
139 | 137 |
140 omxSP_FFTInv_CCSToR_F32(fftData, data, m_inverseContext); | 138 omxSP_FFTInv_CCSToR_F32(fftData, data, m_inverseContext); |
141 } | 139 } |
142 } | 140 } |
143 | 141 |
144 OMXFFTSpec_R_F32* FFTFrame::contextForSize(unsigned log2FFTSize) { | 142 OMXFFTSpec_R_F32* FFTFrame::contextForSize(unsigned log2FFTSize) { |
145 DCHECK(log2FFTSize); | 143 DCHECK(log2FFTSize); |
146 ASSERT(log2FFTSize <= kMaxFFTPow2Size); | 144 DCHECK_LE(log2FFTSize, kMaxFFTPow2Size); |
147 int bufSize; | 145 int bufSize; |
148 OMXResult status = omxSP_FFTGetBufSize_R_F32(log2FFTSize, &bufSize); | 146 OMXResult status = omxSP_FFTGetBufSize_R_F32(log2FFTSize, &bufSize); |
149 | 147 |
150 if (status == OMX_Sts_NoErr) { | 148 if (status == OMX_Sts_NoErr) { |
151 OMXFFTSpec_R_F32* context = static_cast<OMXFFTSpec_R_F32*>(malloc(bufSize)); | 149 OMXFFTSpec_R_F32* context = static_cast<OMXFFTSpec_R_F32*>(malloc(bufSize)); |
152 omxSP_FFTInit_R_F32(context, log2FFTSize); | 150 omxSP_FFTInit_R_F32(context, log2FFTSize); |
153 return context; | 151 return context; |
154 } | 152 } |
155 | 153 |
156 return nullptr; | 154 return nullptr; |
157 } | 155 } |
158 | 156 |
159 } // namespace blink | 157 } // namespace blink |
160 | 158 |
161 #endif // #if OS(ANDROID) && !USE(WEBAUDIO_OPENMAX_DL_FFT) | 159 #endif // #if OS(ANDROID) && !USE(WEBAUDIO_OPENMAX_DL_FFT) |
OLD | NEW |