Changeset 268559 in webkit
- Timestamp:
- Oct 15, 2020 3:27:21 PM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r268558 r268559 1 2020-10-15 Chris Dumez <cdumez@apple.com> 2 3 [Cocoa] Simplify logic for caching FFTSetups in FFTFrame 4 https://bugs.webkit.org/show_bug.cgi?id=217782 5 6 Reviewed by Eric Carlson. 7 8 Simplify logic for caching FFTSetups in FFTFrame: 9 - Use a local static (NeverDestroyed) to cache the FFTSetups to avoid 10 heap allocation and simplify logic a bit. 11 - Drop FFTFrame::cleanup() since it is dead code. 12 13 No new tests, no Web-facing behavior change. 14 15 * platform/audio/FFTFrame.h: 16 * platform/audio/FFTFrameStub.cpp: 17 * platform/audio/gstreamer/FFTFrameGStreamer.cpp: 18 * platform/audio/mac/FFTFrameMac.cpp: 19 (WebCore::FFTFrame::fftSetupForSize): 20 1 21 2020-10-15 Chris Dumez <cdumez@apple.com> 2 22 -
trunk/Source/WebCore/platform/audio/FFTFrame.h
r266492 r268559 63 63 64 64 static void initialize(); 65 static void cleanup();66 65 void doFFT(const float* data); 67 66 void doInverseFFT(float* data); … … 102 101 static FFTSetup fftSetupForSize(unsigned fftSize); 103 102 104 static FFTSetup* fftSetups;105 106 103 FFTSetup m_FFTSetup; 107 104 -
trunk/Source/WebCore/platform/audio/FFTFrameStub.cpp
r267471 r268559 79 79 } 80 80 81 void FFTFrame::cleanup()82 {83 ASSERT_NOT_REACHED();84 }85 86 81 float* FFTFrame::realData() const 87 82 { -
trunk/Source/WebCore/platform/audio/gstreamer/FFTFrameGStreamer.cpp
r268026 r268559 88 88 } 89 89 90 void FFTFrame::cleanup()91 {92 }93 94 90 FFTFrame::~FFTFrame() 95 91 { -
trunk/Source/WebCore/platform/audio/mac/FFTFrameMac.cpp
r268026 r268559 38 38 39 39 #include "VectorMath.h" 40 #include <wtf/NeverDestroyed.h> 41 #include <wtf/Vector.h> 40 42 41 43 namespace WebCore { 42 44 43 const int kMinFFTPow2Size = 2; 44 const int kMaxFFTPow2Size = 24; 45 46 FFTSetup* FFTFrame::fftSetups = 0; 45 constexpr unsigned kMinFFTPow2Size = 2; 46 constexpr unsigned kMaxFFTPow2Size = 24; 47 47 48 48 // Normal constructor: allocates for a given fftSize … … 124 124 FFTSetup FFTFrame::fftSetupForSize(unsigned fftSize) 125 125 { 126 if (!fftSetups) { 127 fftSetups = (FFTSetup*)fastMalloc(sizeof(FFTSetup) * kMaxFFTPow2Size); 128 memset(fftSetups, 0, sizeof(FFTSetup) * kMaxFFTPow2Size); 129 } 126 static NeverDestroyed<Vector<FFTSetup>> fftSetups(kMaxFFTPow2Size, nullptr); 130 127 131 int pow2size = static_cast<int>(log2(fftSize));128 auto pow2size = static_cast<size_t>(log2(fftSize)); 132 129 ASSERT(pow2size < kMaxFFTPow2Size); 133 if (!fftSetups[pow2size]) 134 fftSetups[pow2size] = vDSP_create_fftsetup(pow2size, FFT_RADIX2); 130 auto& fftSetup = fftSetups->at(pow2size); 131 if (!fftSetup) 132 fftSetup = vDSP_create_fftsetup(pow2size, FFT_RADIX2); 135 133 136 return fftSetup s[pow2size];134 return fftSetup; 137 135 } 138 136 … … 149 147 void FFTFrame::initialize() 150 148 { 151 }152 153 void FFTFrame::cleanup()154 {155 if (!fftSetups)156 return;157 158 for (int i = 0; i < kMaxFFTPow2Size; ++i) {159 if (fftSetups[i])160 vDSP_destroy_fftsetup(fftSetups[i]);161 }162 163 fastFree(fftSetups);164 fftSetups = 0;165 149 } 166 150
Note: See TracChangeset
for help on using the changeset viewer.