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

Side by Side Diff: Source/platform/audio/ipp/FFTFrameIPP.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
OLDNEW
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 27 matching lines...) Expand all
38 #include "wtf/MathExtras.h" 38 #include "wtf/MathExtras.h"
39 39
40 namespace blink { 40 namespace blink {
41 41
42 const unsigned maximumFFTPower2Size = 24; 42 const unsigned maximumFFTPower2Size = 24;
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_complexData(fftSize)
49 , m_realData(fftSize / 2) 48 , m_realData(fftSize / 2)
50 , m_imagData(fftSize / 2) 49 , m_imagData(fftSize / 2)
50 , m_complexData(fftSize)
51 { 51 {
52 // We only allow power of two. 52 // We only allow power of two.
53 ASSERT(1UL << m_log2FFTSize == m_FFTSize); 53 ASSERT(1UL << m_log2FFTSize == m_FFTSize);
54 ASSERT(m_log2FFTSize <= maximumFFTPower2Size); 54 ASSERT(m_log2FFTSize <= maximumFFTPower2Size);
55 55
56 ippsDFTInitAlloc_R_32f(&m_DFTSpec, m_FFTSize, IPP_FFT_NODIV_BY_ANY, ippAlgHi ntFast); 56 ippsDFTInitAlloc_R_32f(&m_DFTSpec, m_FFTSize, IPP_FFT_NODIV_BY_ANY, ippAlgHi ntFast);
57 int bufferSize = 0; 57 int bufferSize = 0;
58 ippsDFTGetBufSize_R_32f(m_DFTSpec, &bufferSize); 58 ippsDFTGetBufSize_R_32f(m_DFTSpec, &bufferSize);
59 m_buffer = ippsMalloc_8u(bufferSize); 59 m_buffer = ippsMalloc_8u(bufferSize);
60 } 60 }
61 61
62 // Creates a blank/empty frame (interpolate() must later be called). 62 // Creates a blank/empty frame (interpolate() must later be called).
63 FFTFrame::FFTFrame() 63 FFTFrame::FFTFrame()
64 : m_FFTSize(0) 64 : m_FFTSize(0)
65 , m_log2FFTSize(0) 65 , m_log2FFTSize(0)
66 { 66 {
67 } 67 }
68 68
69 // Copy constructor. 69 // Copy constructor.
70 FFTFrame::FFTFrame(const FFTFrame& frame) 70 FFTFrame::FFTFrame(const FFTFrame& frame)
71 : m_FFTSize(frame.m_FFTSize) 71 : m_FFTSize(frame.m_FFTSize)
72 , m_log2FFTSize(frame.m_log2FFTSize) 72 , m_log2FFTSize(frame.m_log2FFTSize)
73 , m_complexData(frame.m_FFTSize)
74 , m_realData(frame.m_FFTSize / 2) 73 , m_realData(frame.m_FFTSize / 2)
75 , m_imagData(frame.m_FFTSize / 2) 74 , m_imagData(frame.m_FFTSize / 2)
75 , m_complexData(frame.m_FFTSize)
76 { 76 {
77 ippsDFTInitAlloc_R_32f(&m_DFTSpec, m_FFTSize, IPP_FFT_NODIV_BY_ANY, ippAlgHi ntFast); 77 ippsDFTInitAlloc_R_32f(&m_DFTSpec, m_FFTSize, IPP_FFT_NODIV_BY_ANY, ippAlgHi ntFast);
78 int bufferSize = 0; 78 int bufferSize = 0;
79 ippsDFTGetBufSize_R_32f(m_DFTSpec, &bufferSize); 79 ippsDFTGetBufSize_R_32f(m_DFTSpec, &bufferSize);
80 m_buffer = ippsMalloc_8u(bufferSize); 80 m_buffer = ippsMalloc_8u(bufferSize);
81 81
82 // Copy/setup frame data. 82 // Copy/setup frame data.
83 unsigned numberOfBytes = sizeof(float) * m_FFTSize; 83 unsigned numberOfBytes = sizeof(float) * m_FFTSize;
84 memcpy(realData(), frame.realData(), numberOfBytes); 84 memcpy(realData(), frame.realData(), numberOfBytes);
85 memcpy(imagData(), frame.imagData(), numberOfBytes); 85 memcpy(imagData(), frame.imagData(), numberOfBytes);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 // Compute inverse transform. 118 // Compute inverse transform.
119 ippsDFTInv_PermToR_32f(complexP, reinterpret_cast<Ipp32f*>(data), m_DFTSpec, m_buffer); 119 ippsDFTInv_PermToR_32f(complexP, reinterpret_cast<Ipp32f*>(data), m_DFTSpec, m_buffer);
120 120
121 // Scale so that a forward then inverse FFT yields exactly the original data . 121 // Scale so that a forward then inverse FFT yields exactly the original data .
122 const float scale = 1.0 / m_FFTSize; 122 const float scale = 1.0 / m_FFTSize;
123 123
124 ippsMulC_32f_I(scale, reinterpret_cast<Ipp32f*>(data), m_FFTSize); 124 ippsMulC_32f_I(scale, reinterpret_cast<Ipp32f*>(data), m_FFTSize);
125 } 125 }
126 126
127 float* FFTFrame::realData() const
128 {
129 return const_cast<float*>(m_realData.data());
130 }
131
132 float* FFTFrame::imagData() const
133 {
134 return const_cast<float*>(m_imagData.data());
135 }
136
137 float* FFTFrame::getUpToDateComplexData() 127 float* FFTFrame::getUpToDateComplexData()
138 { 128 {
139 int len = m_FFTSize >> 1; 129 int len = m_FFTSize >> 1;
140 // Merge the real and imagimary vectors to complex vector. 130 // Merge the real and imagimary vectors to complex vector.
141 Ipp32f* realP = m_realData.data(); 131 Ipp32f* realP = m_realData.data();
142 Ipp32f* imagP = m_imagData.data(); 132 Ipp32f* imagP = m_imagData.data();
143 Ipp32fc* complexP = reinterpret_cast<Ipp32fc*>(m_complexData.data()); 133 Ipp32fc* complexP = reinterpret_cast<Ipp32fc*>(m_complexData.data());
144 ippsRealToCplx_32f(realP, imagP, complexP, len); 134 ippsRealToCplx_32f(realP, imagP, complexP, len);
145 135
146 return const_cast<float*>(m_complexData.data()); 136 return const_cast<float*>(m_complexData.data());
147 } 137 }
148 138
149 } // namespace blink 139 } // namespace blink
150 140
151 #endif // USE(WEBAUDIO_IPP) 141 #endif // USE(WEBAUDIO_IPP)
152 142
153 #endif // ENABLE(WEB_AUDIO) 143 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/platform/audio/ffmpeg/FFTFrameFFMPEG.cpp ('k') | Source/platform/audio/mac/FFTFrameMac.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698