OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * Copyright (C) 2012 Intel Inc. All rights reserved. | 3 * Copyright (C) 2012 Intel Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 17 matching lines...) Expand all Loading... |
28 // suitable for use on Linux. | 28 // suitable for use on Linux. |
29 | 29 |
30 #include "config.h" | 30 #include "config.h" |
31 | 31 |
32 #if ENABLE(WEB_AUDIO) | 32 #if ENABLE(WEB_AUDIO) |
33 | 33 |
34 #if USE(WEBAUDIO_IPP) | 34 #if USE(WEBAUDIO_IPP) |
35 | 35 |
36 #include "platform/audio/FFTFrame.h" | 36 #include "platform/audio/FFTFrame.h" |
37 | 37 |
38 #include "platform/audio/VectorMath.h" | |
39 | |
40 #include "wtf/MathExtras.h" | 38 #include "wtf/MathExtras.h" |
41 | 39 |
42 namespace WebCore { | 40 namespace WebCore { |
43 | 41 |
44 const unsigned maximumFFTPower2Size = 24; | 42 const unsigned maximumFFTPower2Size = 24; |
45 | 43 |
46 // Normal constructor: allocates for a given fftSize. | 44 // Normal constructor: allocates for a given fftSize. |
47 FFTFrame::FFTFrame(unsigned fftSize) | 45 FFTFrame::FFTFrame(unsigned fftSize) |
48 : m_FFTSize(fftSize) | 46 : m_FFTSize(fftSize) |
49 , m_log2FFTSize(static_cast<unsigned>(log2(fftSize))) | 47 , m_log2FFTSize(static_cast<unsigned>(log2(fftSize))) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 void FFTFrame::cleanup() | 92 void FFTFrame::cleanup() |
95 { | 93 { |
96 } | 94 } |
97 | 95 |
98 FFTFrame::~FFTFrame() | 96 FFTFrame::~FFTFrame() |
99 { | 97 { |
100 ippsFree(m_buffer); | 98 ippsFree(m_buffer); |
101 ippsDFTFree_R_32f(m_DFTSpec); | 99 ippsDFTFree_R_32f(m_DFTSpec); |
102 } | 100 } |
103 | 101 |
104 void FFTFrame::multiply(const FFTFrame& frame) | |
105 { | |
106 FFTFrame& frame1 = *this; | |
107 FFTFrame& frame2 = const_cast<FFTFrame&>(frame); | |
108 | |
109 float* realP1 = frame1.realData(); | |
110 float* imagP1 = frame1.imagData(); | |
111 const float* realP2 = frame2.realData(); | |
112 const float* imagP2 = frame2.imagData(); | |
113 | |
114 unsigned halfSize = fftSize() / 2; | |
115 float real0 = realP1[0]; | |
116 float imag0 = imagP1[0]; | |
117 | |
118 VectorMath::zvmul(realP1, imagP1, realP2, imagP2, realP1, imagP1, halfSize); | |
119 | |
120 // Multiply the packed DC/nyquist component | |
121 realP1[0] = real0 * realP2[0]; | |
122 imagP1[0] = imag0 * imagP2[0]; | |
123 } | |
124 | |
125 void FFTFrame::doFFT(const float* data) | 102 void FFTFrame::doFFT(const float* data) |
126 { | 103 { |
127 Ipp32f* complexP = m_complexData.data(); | 104 Ipp32f* complexP = m_complexData.data(); |
128 | 105 |
129 // Compute Forward transform to perm format. | 106 // Compute Forward transform to perm format. |
130 ippsDFTFwd_RToPerm_32f(reinterpret_cast<Ipp32f*>(const_cast<float*>(data)),
complexP, m_DFTSpec, m_buffer); | 107 ippsDFTFwd_RToPerm_32f(reinterpret_cast<Ipp32f*>(const_cast<float*>(data)),
complexP, m_DFTSpec, m_buffer); |
131 | 108 |
132 Ipp32f* realP = m_realData.data(); | 109 Ipp32f* realP = m_realData.data(); |
133 Ipp32f* imagP = m_imagData.data(); | 110 Ipp32f* imagP = m_imagData.data(); |
134 ippsCplxToReal_32fc(reinterpret_cast<Ipp32fc*>(complexP), realP, imagP, m_FF
TSize >> 1); | 111 ippsCplxToReal_32fc(reinterpret_cast<Ipp32fc*>(complexP), realP, imagP, m_FF
TSize >> 1); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 ippsRealToCplx_32f(realP, imagP, complexP, len); | 144 ippsRealToCplx_32f(realP, imagP, complexP, len); |
168 | 145 |
169 return const_cast<float*>(m_complexData.data()); | 146 return const_cast<float*>(m_complexData.data()); |
170 } | 147 } |
171 | 148 |
172 } // namespace WebCore | 149 } // namespace WebCore |
173 | 150 |
174 #endif // USE(WEBAUDIO_IPP) | 151 #endif // USE(WEBAUDIO_IPP) |
175 | 152 |
176 #endif // ENABLE(WEB_AUDIO) | 153 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |