| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #if ENABLE(ASSERT) | 47 #if ENABLE(ASSERT) |
| 48 const int kMaxFFTPow2Size = 24; | 48 const int kMaxFFTPow2Size = 24; |
| 49 #endif | 49 #endif |
| 50 | 50 |
| 51 // Normal constructor: allocates for a given fftSize. | 51 // Normal constructor: allocates for a given fftSize. |
| 52 FFTFrame::FFTFrame(unsigned fftSize) | 52 FFTFrame::FFTFrame(unsigned fftSize) |
| 53 : m_FFTSize(fftSize) | 53 : m_FFTSize(fftSize) |
| 54 , m_log2FFTSize(static_cast<unsigned>(log2(fftSize))) | 54 , m_log2FFTSize(static_cast<unsigned>(log2(fftSize))) |
| 55 , m_realData(fftSize / 2) | 55 , m_realData(fftSize / 2) |
| 56 , m_imagData(fftSize / 2) | 56 , m_imagData(fftSize / 2) |
| 57 , m_forwardContext(0) | 57 , m_forwardContext(nullptr) |
| 58 , m_inverseContext(0) | 58 , m_inverseContext(nullptr) |
| 59 , m_complexData(fftSize) | 59 , m_complexData(fftSize) |
| 60 { | 60 { |
| 61 // We only allow power of two. | 61 // We only allow power of two. |
| 62 ASSERT(1UL << m_log2FFTSize == m_FFTSize); | 62 ASSERT(1UL << m_log2FFTSize == m_FFTSize); |
| 63 | 63 |
| 64 m_forwardContext = contextForSize(fftSize, DFT_R2C); | 64 m_forwardContext = contextForSize(fftSize, DFT_R2C); |
| 65 m_inverseContext = contextForSize(fftSize, IDFT_C2R); | 65 m_inverseContext = contextForSize(fftSize, IDFT_C2R); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Creates a blank/empty frame (interpolate() must later be called). | 68 // Creates a blank/empty frame (interpolate() must later be called). |
| 69 FFTFrame::FFTFrame() | 69 FFTFrame::FFTFrame() |
| 70 : m_FFTSize(0) | 70 : m_FFTSize(0) |
| 71 , m_log2FFTSize(0) | 71 , m_log2FFTSize(0) |
| 72 , m_forwardContext(0) | 72 , m_forwardContext(nullptr) |
| 73 , m_inverseContext(0) | 73 , m_inverseContext(nullptr) |
| 74 { | 74 { |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Copy constructor. | 77 // Copy constructor. |
| 78 FFTFrame::FFTFrame(const FFTFrame& frame) | 78 FFTFrame::FFTFrame(const FFTFrame& frame) |
| 79 : m_FFTSize(frame.m_FFTSize) | 79 : m_FFTSize(frame.m_FFTSize) |
| 80 , m_log2FFTSize(frame.m_log2FFTSize) | 80 , m_log2FFTSize(frame.m_log2FFTSize) |
| 81 , m_realData(frame.m_FFTSize / 2) | 81 , m_realData(frame.m_FFTSize / 2) |
| 82 , m_imagData(frame.m_FFTSize / 2) | 82 , m_imagData(frame.m_FFTSize / 2) |
| 83 , m_forwardContext(0) | 83 , m_forwardContext(nullptr) |
| 84 , m_inverseContext(0) | 84 , m_inverseContext(nullptr) |
| 85 , m_complexData(frame.m_FFTSize) | 85 , m_complexData(frame.m_FFTSize) |
| 86 { | 86 { |
| 87 m_forwardContext = contextForSize(m_FFTSize, DFT_R2C); | 87 m_forwardContext = contextForSize(m_FFTSize, DFT_R2C); |
| 88 m_inverseContext = contextForSize(m_FFTSize, IDFT_C2R); | 88 m_inverseContext = contextForSize(m_FFTSize, IDFT_C2R); |
| 89 | 89 |
| 90 // Copy/setup frame data. | 90 // Copy/setup frame data. |
| 91 unsigned nbytes = sizeof(float) * (m_FFTSize / 2); | 91 unsigned nbytes = sizeof(float) * (m_FFTSize / 2); |
| 92 memcpy(realData(), frame.realData(), nbytes); | 92 memcpy(realData(), frame.realData(), nbytes); |
| 93 memcpy(imagData(), frame.imagData(), nbytes); | 93 memcpy(imagData(), frame.imagData(), nbytes); |
| 94 } | 94 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 RDFTContext* context = av_rdft_init(pow2size, (RDFTransformType)trans); | 173 RDFTContext* context = av_rdft_init(pow2size, (RDFTransformType)trans); |
| 174 return context; | 174 return context; |
| 175 } | 175 } |
| 176 | 176 |
| 177 } // namespace blink | 177 } // namespace blink |
| 178 | 178 |
| 179 #endif // USE(WEBAUDIO_FFMPEG) | 179 #endif // USE(WEBAUDIO_FFMPEG) |
| 180 | 180 |
| 181 #endif // ENABLE(WEB_AUDIO) | 181 #endif // ENABLE(WEB_AUDIO) |
| OLD | NEW |