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

Side by Side Diff: third_party/WebKit/Source/platform/audio/FFTFrame.cpp

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 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 12 matching lines...) Expand all
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #include "platform/audio/FFTFrame.h" 29 #include "platform/audio/FFTFrame.h"
30 #include "platform/audio/VectorMath.h" 30 #include "platform/audio/VectorMath.h"
31 #include "platform/Logging.h" 31 #include "platform/Logging.h"
32 #include "wtf/MathExtras.h" 32 #include "wtf/MathExtras.h"
33 #include "wtf/OwnPtr.h" 33 #include "wtf/PtrUtil.h"
34 #include <complex> 34 #include <complex>
35 #include <memory>
35 36
36 #ifndef NDEBUG 37 #ifndef NDEBUG
37 #include <stdio.h> 38 #include <stdio.h>
38 #endif 39 #endif
39 40
40 namespace blink { 41 namespace blink {
41 42
42 void FFTFrame::doPaddedFFT(const float* data, size_t dataSize) 43 void FFTFrame::doPaddedFFT(const float* data, size_t dataSize)
43 { 44 {
44 // Zero-pad the impulse response 45 // Zero-pad the impulse response
45 AudioFloatArray paddedResponse(fftSize()); // zero-initialized 46 AudioFloatArray paddedResponse(fftSize()); // zero-initialized
46 paddedResponse.copyToRange(data, 0, dataSize); 47 paddedResponse.copyToRange(data, 0, dataSize);
47 48
48 // Get the frequency-domain version of padded response 49 // Get the frequency-domain version of padded response
49 doFFT(paddedResponse.data()); 50 doFFT(paddedResponse.data());
50 } 51 }
51 52
52 PassOwnPtr<FFTFrame> FFTFrame::createInterpolatedFrame(const FFTFrame& frame1, c onst FFTFrame& frame2, double x) 53 std::unique_ptr<FFTFrame> FFTFrame::createInterpolatedFrame(const FFTFrame& fram e1, const FFTFrame& frame2, double x)
53 { 54 {
54 OwnPtr<FFTFrame> newFrame = adoptPtr(new FFTFrame(frame1.fftSize())); 55 std::unique_ptr<FFTFrame> newFrame = wrapUnique(new FFTFrame(frame1.fftSize( )));
55 56
56 newFrame->interpolateFrequencyComponents(frame1, frame2, x); 57 newFrame->interpolateFrequencyComponents(frame1, frame2, x);
57 58
58 // In the time-domain, the 2nd half of the response must be zero, to avoid c ircular convolution aliasing... 59 // In the time-domain, the 2nd half of the response must be zero, to avoid c ircular convolution aliasing...
59 int fftSize = newFrame->fftSize(); 60 int fftSize = newFrame->fftSize();
60 AudioFloatArray buffer(fftSize); 61 AudioFloatArray buffer(fftSize);
61 newFrame->doInverseFFT(buffer.data()); 62 newFrame->doInverseFFT(buffer.data());
62 buffer.zeroRange(fftSize / 2, fftSize); 63 buffer.zeroRange(fftSize / 2, fftSize);
63 64
64 // Put back into frequency domain. 65 // Put back into frequency domain.
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 261
261 VectorMath::zvmul(realP1, imagP1, realP2, imagP2, realP1, imagP1, halfSize); 262 VectorMath::zvmul(realP1, imagP1, realP2, imagP2, realP1, imagP1, halfSize);
262 263
263 // Multiply the packed DC/nyquist component 264 // Multiply the packed DC/nyquist component
264 realP1[0] = real0 * realP2[0]; 265 realP1[0] = real0 * realP2[0];
265 imagP1[0] = imag0 * imagP2[0]; 266 imagP1[0] = imag0 * imagP2[0];
266 } 267 }
267 268
268 } // namespace blink 269 } // namespace blink
269 270
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/audio/FFTFrame.h ('k') | third_party/WebKit/Source/platform/audio/HRTFDatabase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698