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

Side by Side Diff: Source/core/platform/audio/Biquad.cpp

Issue 14107015: Rename OS(DARWIN) to OS(MACOSX). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 7 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/core/platform/audio/Biquad.h ('k') | Source/core/platform/audio/DirectConvolver.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 /* 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 19 matching lines...) Expand all
30 30
31 #if ENABLE(WEB_AUDIO) 31 #if ENABLE(WEB_AUDIO)
32 32
33 #include "core/platform/audio/Biquad.h" 33 #include "core/platform/audio/Biquad.h"
34 34
35 #include <stdio.h> 35 #include <stdio.h>
36 #include <algorithm> 36 #include <algorithm>
37 #include "core/platform/audio/DenormalDisabler.h" 37 #include "core/platform/audio/DenormalDisabler.h"
38 #include "wtf/MathExtras.h" 38 #include "wtf/MathExtras.h"
39 39
40 #if OS(DARWIN) 40 #if OS(MACOSX)
41 #include <Accelerate/Accelerate.h> 41 #include <Accelerate/Accelerate.h>
42 #endif 42 #endif
43 43
44 namespace WebCore { 44 namespace WebCore {
45 45
46 const int kBufferSize = 1024; 46 const int kBufferSize = 1024;
47 47
48 Biquad::Biquad() 48 Biquad::Biquad()
49 { 49 {
50 #if OS(DARWIN) 50 #if OS(MACOSX)
51 // Allocate two samples more for filter history 51 // Allocate two samples more for filter history
52 m_inputBuffer.allocate(kBufferSize + 2); 52 m_inputBuffer.allocate(kBufferSize + 2);
53 m_outputBuffer.allocate(kBufferSize + 2); 53 m_outputBuffer.allocate(kBufferSize + 2);
54 #endif 54 #endif
55 55
56 #if USE(WEBAUDIO_IPP) 56 #if USE(WEBAUDIO_IPP)
57 int bufferSize; 57 int bufferSize;
58 ippsIIRGetStateSize64f_BiQuad_32f(1, &bufferSize); 58 ippsIIRGetStateSize64f_BiQuad_32f(1, &bufferSize);
59 m_ippInternalBuffer = ippsMalloc_8u(bufferSize); 59 m_ippInternalBuffer = ippsMalloc_8u(bufferSize);
60 #endif // USE(WEBAUDIO_IPP) 60 #endif // USE(WEBAUDIO_IPP)
61 61
62 // Initialize as pass-thru (straight-wire, no filter effect) 62 // Initialize as pass-thru (straight-wire, no filter effect)
63 setNormalizedCoefficients(1, 0, 0, 1, 0, 0); 63 setNormalizedCoefficients(1, 0, 0, 1, 0, 0);
64 64
65 reset(); // clear filter memory 65 reset(); // clear filter memory
66 } 66 }
67 67
68 Biquad::~Biquad() 68 Biquad::~Biquad()
69 { 69 {
70 #if USE(WEBAUDIO_IPP) 70 #if USE(WEBAUDIO_IPP)
71 ippsFree(m_ippInternalBuffer); 71 ippsFree(m_ippInternalBuffer);
72 #endif // USE(WEBAUDIO_IPP) 72 #endif // USE(WEBAUDIO_IPP)
73 } 73 }
74 74
75 void Biquad::process(const float* sourceP, float* destP, size_t framesToProcess) 75 void Biquad::process(const float* sourceP, float* destP, size_t framesToProcess)
76 { 76 {
77 #if OS(DARWIN) 77 #if OS(MACOSX)
78 // Use vecLib if available 78 // Use vecLib if available
79 processFast(sourceP, destP, framesToProcess); 79 processFast(sourceP, destP, framesToProcess);
80 80
81 #elif USE(WEBAUDIO_IPP) 81 #elif USE(WEBAUDIO_IPP)
82 ippsIIR64f_32f(sourceP, destP, static_cast<int>(framesToProcess), m_biquadSt ate); 82 ippsIIR64f_32f(sourceP, destP, static_cast<int>(framesToProcess), m_biquadSt ate);
83 #else // USE(WEBAUDIO_IPP) 83 #else // USE(WEBAUDIO_IPP)
84 84
85 int n = framesToProcess; 85 int n = framesToProcess;
86 86
87 // Create local copies of member variables 87 // Create local copies of member variables
(...skipping 30 matching lines...) Expand all
118 m_y2 = DenormalDisabler::flushDenormalFloatToZero(y2); 118 m_y2 = DenormalDisabler::flushDenormalFloatToZero(y2);
119 119
120 m_b0 = b0; 120 m_b0 = b0;
121 m_b1 = b1; 121 m_b1 = b1;
122 m_b2 = b2; 122 m_b2 = b2;
123 m_a1 = a1; 123 m_a1 = a1;
124 m_a2 = a2; 124 m_a2 = a2;
125 #endif 125 #endif
126 } 126 }
127 127
128 #if OS(DARWIN) 128 #if OS(MACOSX)
129 129
130 // Here we have optimized version using Accelerate.framework 130 // Here we have optimized version using Accelerate.framework
131 131
132 void Biquad::processFast(const float* sourceP, float* destP, size_t framesToProc ess) 132 void Biquad::processFast(const float* sourceP, float* destP, size_t framesToProc ess)
133 { 133 {
134 double filterCoefficients[5]; 134 double filterCoefficients[5];
135 filterCoefficients[0] = m_b0; 135 filterCoefficients[0] = m_b0;
136 filterCoefficients[1] = m_b1; 136 filterCoefficients[1] = m_b1;
137 filterCoefficients[2] = m_b2; 137 filterCoefficients[2] = m_b2;
138 filterCoefficients[3] = m_a1; 138 filterCoefficients[3] = m_a1;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 // Save history. Note that sourceP and destP reference m_inputBuffer and m_ outputBuffer respectively. 173 // Save history. Note that sourceP and destP reference m_inputBuffer and m_ outputBuffer respectively.
174 // These buffers are allocated (in the constructor) with space for two extra samples so it's OK to access 174 // These buffers are allocated (in the constructor) with space for two extra samples so it's OK to access
175 // array values two beyond framesToProcess. 175 // array values two beyond framesToProcess.
176 sourceP[0] = sourceP[framesToProcess - 2 + 2]; 176 sourceP[0] = sourceP[framesToProcess - 2 + 2];
177 sourceP[1] = sourceP[framesToProcess - 1 + 2]; 177 sourceP[1] = sourceP[framesToProcess - 1 + 2];
178 destP[0] = destP[framesToProcess - 2 + 2]; 178 destP[0] = destP[framesToProcess - 2 + 2];
179 destP[1] = destP[framesToProcess - 1 + 2]; 179 destP[1] = destP[framesToProcess - 1 + 2];
180 } 180 }
181 181
182 #endif // OS(DARWIN) 182 #endif // OS(MACOSX)
183 183
184 184
185 void Biquad::reset() 185 void Biquad::reset()
186 { 186 {
187 #if OS(DARWIN) 187 #if OS(MACOSX)
188 // Two extra samples for filter history 188 // Two extra samples for filter history
189 double* inputP = m_inputBuffer.data(); 189 double* inputP = m_inputBuffer.data();
190 inputP[0] = 0; 190 inputP[0] = 0;
191 inputP[1] = 0; 191 inputP[1] = 0;
192 192
193 double* outputP = m_outputBuffer.data(); 193 double* outputP = m_outputBuffer.data();
194 outputP[0] = 0; 194 outputP[0] = 0;
195 outputP[1] = 0; 195 outputP[1] = 0;
196 196
197 #elif USE(WEBAUDIO_IPP) 197 #elif USE(WEBAUDIO_IPP)
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 Complex denominator = Complex(1, 0) + (a1 + a2 * z) * z; 578 Complex denominator = Complex(1, 0) + (a1 + a2 * z) * z;
579 Complex response = numerator / denominator; 579 Complex response = numerator / denominator;
580 magResponse[k] = static_cast<float>(abs(response)); 580 magResponse[k] = static_cast<float>(abs(response));
581 phaseResponse[k] = static_cast<float>(atan2(imag(response), real(respons e))); 581 phaseResponse[k] = static_cast<float>(atan2(imag(response), real(respons e)));
582 } 582 }
583 } 583 }
584 584
585 } // namespace WebCore 585 } // namespace WebCore
586 586
587 #endif // ENABLE(WEB_AUDIO) 587 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/core/platform/audio/Biquad.h ('k') | Source/core/platform/audio/DirectConvolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698