| 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 29 matching lines...) Expand all Loading... |
| 40 #if ENABLE(ASSERT) | 40 #if ENABLE(ASSERT) |
| 41 const unsigned kMaxFFTPow2Size = 15; | 41 const unsigned kMaxFFTPow2Size = 15; |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 // Normal constructor: allocates for a given fftSize. | 44 // Normal constructor: allocates for a given fftSize. |
| 45 FFTFrame::FFTFrame(unsigned fftSize) | 45 FFTFrame::FFTFrame(unsigned fftSize) |
| 46 : m_FFTSize(fftSize) | 46 : m_FFTSize(fftSize) |
| 47 , m_log2FFTSize(static_cast<unsigned>(log2(fftSize))) | 47 , m_log2FFTSize(static_cast<unsigned>(log2(fftSize))) |
| 48 , m_realData(fftSize / 2) | 48 , m_realData(fftSize / 2) |
| 49 , m_imagData(fftSize / 2) | 49 , m_imagData(fftSize / 2) |
| 50 , m_forwardContext(0) | 50 , m_forwardContext(nullptr) |
| 51 , m_inverseContext(0) | 51 , m_inverseContext(nullptr) |
| 52 , m_complexData(fftSize) | 52 , m_complexData(fftSize) |
| 53 { | 53 { |
| 54 // We only allow power of two. | 54 // We only allow power of two. |
| 55 ASSERT(1UL << m_log2FFTSize == m_FFTSize); | 55 ASSERT(1UL << m_log2FFTSize == m_FFTSize); |
| 56 | 56 |
| 57 m_forwardContext = contextForSize(m_log2FFTSize); | 57 m_forwardContext = contextForSize(m_log2FFTSize); |
| 58 m_inverseContext = contextForSize(m_log2FFTSize); | 58 m_inverseContext = contextForSize(m_log2FFTSize); |
| 59 } | 59 } |
| 60 | 60 |
| 61 // Creates a blank/empty frame (interpolate() must later be called). | 61 // Creates a blank/empty frame (interpolate() must later be called). |
| 62 FFTFrame::FFTFrame() | 62 FFTFrame::FFTFrame() |
| 63 : m_FFTSize(0) | 63 : m_FFTSize(0) |
| 64 , m_log2FFTSize(0) | 64 , m_log2FFTSize(0) |
| 65 , m_forwardContext(0) | 65 , m_forwardContext(nullptr) |
| 66 , m_inverseContext(0) | 66 , m_inverseContext(nullptr) |
| 67 { | 67 { |
| 68 } | 68 } |
| 69 | 69 |
| 70 // Copy constructor. | 70 // Copy constructor. |
| 71 FFTFrame::FFTFrame(const FFTFrame& frame) | 71 FFTFrame::FFTFrame(const FFTFrame& frame) |
| 72 : m_FFTSize(frame.m_FFTSize) | 72 : m_FFTSize(frame.m_FFTSize) |
| 73 , m_log2FFTSize(frame.m_log2FFTSize) | 73 , m_log2FFTSize(frame.m_log2FFTSize) |
| 74 , m_realData(frame.m_FFTSize / 2) | 74 , m_realData(frame.m_FFTSize / 2) |
| 75 , m_imagData(frame.m_FFTSize / 2) | 75 , m_imagData(frame.m_FFTSize / 2) |
| 76 , m_forwardContext(0) | 76 , m_forwardContext(nullptr) |
| 77 , m_inverseContext(0) | 77 , m_inverseContext(nullptr) |
| 78 , m_complexData(frame.m_FFTSize) | 78 , m_complexData(frame.m_FFTSize) |
| 79 { | 79 { |
| 80 m_forwardContext = contextForSize(m_log2FFTSize); | 80 m_forwardContext = contextForSize(m_log2FFTSize); |
| 81 m_inverseContext = contextForSize(m_log2FFTSize); | 81 m_inverseContext = contextForSize(m_log2FFTSize); |
| 82 | 82 |
| 83 // Copy/setup frame data. | 83 // Copy/setup frame data. |
| 84 unsigned nbytes = sizeof(float) * (m_FFTSize / 2); | 84 unsigned nbytes = sizeof(float) * (m_FFTSize / 2); |
| 85 memcpy(realData(), frame.realData(), nbytes); | 85 memcpy(realData(), frame.realData(), nbytes); |
| 86 memcpy(imagData(), frame.imagData(), nbytes); | 86 memcpy(imagData(), frame.imagData(), nbytes); |
| 87 } | 87 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 ASSERT(log2FFTSize <= kMaxFFTPow2Size); | 160 ASSERT(log2FFTSize <= kMaxFFTPow2Size); |
| 161 int bufSize; | 161 int bufSize; |
| 162 OMXResult status = omxSP_FFTGetBufSize_R_F32(log2FFTSize, &bufSize); | 162 OMXResult status = omxSP_FFTGetBufSize_R_F32(log2FFTSize, &bufSize); |
| 163 | 163 |
| 164 if (status == OMX_Sts_NoErr) { | 164 if (status == OMX_Sts_NoErr) { |
| 165 OMXFFTSpec_R_F32* context = static_cast<OMXFFTSpec_R_F32*>(malloc(bufSiz
e)); | 165 OMXFFTSpec_R_F32* context = static_cast<OMXFFTSpec_R_F32*>(malloc(bufSiz
e)); |
| 166 omxSP_FFTInit_R_F32(context, log2FFTSize); | 166 omxSP_FFTInit_R_F32(context, log2FFTSize); |
| 167 return context; | 167 return context; |
| 168 } | 168 } |
| 169 | 169 |
| 170 return 0; | 170 return nullptr; |
| 171 } | 171 } |
| 172 | 172 |
| 173 } // namespace blink | 173 } // namespace blink |
| 174 | 174 |
| 175 #endif // #if OS(ANDROID) && !USE(WEBAUDIO_OPENMAX_DL_FFT) | 175 #endif // #if OS(ANDROID) && !USE(WEBAUDIO_OPENMAX_DL_FFT) |
| 176 | 176 |
| 177 #endif // ENABLE(WEB_AUDIO) | 177 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |