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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // Normal constructor: allocates for a given fftSize. | 42 // Normal constructor: allocates for a given fftSize. |
43 FFTFrame::FFTFrame(unsigned fftSize) | 43 FFTFrame::FFTFrame(unsigned fftSize) |
44 : m_FFTSize(fftSize), | 44 : m_FFTSize(fftSize), |
45 m_log2FFTSize(static_cast<unsigned>(log2(fftSize))), | 45 m_log2FFTSize(static_cast<unsigned>(log2(fftSize))), |
46 m_realData(fftSize / 2), | 46 m_realData(fftSize / 2), |
47 m_imagData(fftSize / 2), | 47 m_imagData(fftSize / 2), |
48 m_forwardContext(nullptr), | 48 m_forwardContext(nullptr), |
49 m_inverseContext(nullptr), | 49 m_inverseContext(nullptr), |
50 m_complexData(fftSize) { | 50 m_complexData(fftSize) { |
51 // We only allow power of two. | 51 // We only allow power of two. |
52 DCHECK_EQ(1UL << m_log2FFTSize, m_FFTSize); | 52 ASSERT(1UL << m_log2FFTSize == m_FFTSize); |
53 | 53 |
54 m_forwardContext = contextForSize(m_log2FFTSize); | 54 m_forwardContext = contextForSize(m_log2FFTSize); |
55 m_inverseContext = contextForSize(m_log2FFTSize); | 55 m_inverseContext = contextForSize(m_log2FFTSize); |
56 } | 56 } |
57 | 57 |
58 // Creates a blank/empty frame (interpolate() must later be called). | 58 // Creates a blank/empty frame (interpolate() must later be called). |
59 FFTFrame::FFTFrame() | 59 FFTFrame::FFTFrame() |
60 : m_FFTSize(0), | 60 : m_FFTSize(0), |
61 m_log2FFTSize(0), | 61 m_log2FFTSize(0), |
62 m_forwardContext(nullptr), | 62 m_forwardContext(nullptr), |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 fftData[1] = 0; | 136 fftData[1] = 0; |
137 fftData[m_FFTSize] = imag[0]; | 137 fftData[m_FFTSize] = imag[0]; |
138 fftData[m_FFTSize + 1] = 0; | 138 fftData[m_FFTSize + 1] = 0; |
139 | 139 |
140 omxSP_FFTInv_CCSToR_F32(fftData, data, m_inverseContext); | 140 omxSP_FFTInv_CCSToR_F32(fftData, data, m_inverseContext); |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 OMXFFTSpec_R_F32* FFTFrame::contextForSize(unsigned log2FFTSize) { | 144 OMXFFTSpec_R_F32* FFTFrame::contextForSize(unsigned log2FFTSize) { |
145 DCHECK(log2FFTSize); | 145 DCHECK(log2FFTSize); |
146 DCHECK_LE(log2FFTSize, kMaxFFTPow2Size); | 146 ASSERT(log2FFTSize <= kMaxFFTPow2Size); |
147 int bufSize; | 147 int bufSize; |
148 OMXResult status = omxSP_FFTGetBufSize_R_F32(log2FFTSize, &bufSize); | 148 OMXResult status = omxSP_FFTGetBufSize_R_F32(log2FFTSize, &bufSize); |
149 | 149 |
150 if (status == OMX_Sts_NoErr) { | 150 if (status == OMX_Sts_NoErr) { |
151 OMXFFTSpec_R_F32* context = static_cast<OMXFFTSpec_R_F32*>(malloc(bufSize)); | 151 OMXFFTSpec_R_F32* context = static_cast<OMXFFTSpec_R_F32*>(malloc(bufSize)); |
152 omxSP_FFTInit_R_F32(context, log2FFTSize); | 152 omxSP_FFTInit_R_F32(context, log2FFTSize); |
153 return context; | 153 return context; |
154 } | 154 } |
155 | 155 |
156 return nullptr; | 156 return nullptr; |
157 } | 157 } |
158 | 158 |
159 } // namespace blink | 159 } // namespace blink |
160 | 160 |
161 #endif // #if OS(ANDROID) && !USE(WEBAUDIO_OPENMAX_DL_FFT) | 161 #endif // #if OS(ANDROID) && !USE(WEBAUDIO_OPENMAX_DL_FFT) |
OLD | NEW |