Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Side by Side Diff: Source/platform/audio/android/FFTFrameOpenMAXDLAndroid.cpp

Issue 536843002: Change members's order and combine duplicated method for FFTFrame. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Separated using VectorMatch::vsmul from FFTFrameMac.cpp Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/platform/audio/FFTFrameStub.cpp ('k') | Source/platform/audio/ffmpeg/FFTFrameFFMPEG.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 27 matching lines...) Expand all
38 namespace blink { 38 namespace blink {
39 39
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)
49 , m_imagData(fftSize / 2)
48 , m_forwardContext(0) 50 , m_forwardContext(0)
49 , m_inverseContext(0) 51 , m_inverseContext(0)
50 , m_complexData(fftSize) 52 , m_complexData(fftSize)
51 , m_realData(fftSize / 2)
52 , m_imagData(fftSize / 2)
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(0)
66 , m_inverseContext(0) 66 , m_inverseContext(0)
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)
75 , m_imagData(frame.m_FFTSize / 2)
74 , m_forwardContext(0) 76 , m_forwardContext(0)
75 , m_inverseContext(0) 77 , m_inverseContext(0)
76 , m_complexData(frame.m_FFTSize) 78 , m_complexData(frame.m_FFTSize)
77 , m_realData(frame.m_FFTSize / 2)
78 , m_imagData(frame.m_FFTSize / 2)
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 }
88 88
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 147 }
148 fftData[0] = real[0]; 148 fftData[0] = real[0];
149 fftData[1] = 0; 149 fftData[1] = 0;
150 fftData[m_FFTSize] = imag[0]; 150 fftData[m_FFTSize] = imag[0];
151 fftData[m_FFTSize + 1] = 0; 151 fftData[m_FFTSize + 1] = 0;
152 152
153 omxSP_FFTInv_CCSToR_F32(fftData, data, m_inverseContext); 153 omxSP_FFTInv_CCSToR_F32(fftData, data, m_inverseContext);
154 } 154 }
155 } 155 }
156 156
157 float* FFTFrame::realData() const
158 {
159 return const_cast<float*>(m_realData.data());
160 }
161
162 float* FFTFrame::imagData() const
163 {
164 return const_cast<float*>(m_imagData.data());
165 }
166
167 OMXFFTSpec_R_F32* FFTFrame::contextForSize(unsigned log2FFTSize) 157 OMXFFTSpec_R_F32* FFTFrame::contextForSize(unsigned log2FFTSize)
168 { 158 {
169 ASSERT(log2FFTSize); 159 ASSERT(log2FFTSize);
170 ASSERT(log2FFTSize <= kMaxFFTPow2Size); 160 ASSERT(log2FFTSize <= kMaxFFTPow2Size);
171 int bufSize; 161 int bufSize;
172 OMXResult status = omxSP_FFTGetBufSize_R_F32(log2FFTSize, &bufSize); 162 OMXResult status = omxSP_FFTGetBufSize_R_F32(log2FFTSize, &bufSize);
173 163
174 if (status == OMX_Sts_NoErr) { 164 if (status == OMX_Sts_NoErr) {
175 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));
176 omxSP_FFTInit_R_F32(context, log2FFTSize); 166 omxSP_FFTInit_R_F32(context, log2FFTSize);
177 return context; 167 return context;
178 } 168 }
179 169
180 return 0; 170 return 0;
181 } 171 }
182 172
183 } // namespace blink 173 } // namespace blink
184 174
185 #endif // #if OS(ANDROID) && !USE(WEBAUDIO_OPENMAX_DL_FFT) 175 #endif // #if OS(ANDROID) && !USE(WEBAUDIO_OPENMAX_DL_FFT)
186 176
187 #endif // ENABLE(WEB_AUDIO) 177 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/platform/audio/FFTFrameStub.cpp ('k') | Source/platform/audio/ffmpeg/FFTFrameFFMPEG.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698