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

Side by Side Diff: Source/platform/audio/mac/VectorMathMac.cpp

Issue 715753002: [WIP] support arm_neon_optional flag in blink. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month 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/cpu/arm/VectorMathNEON.cpp ('k') | Source/platform/blink_platform.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2010, Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25 #include "config.h"
26
27 #if ENABLE(WEB_AUDIO)
28
29 #include "platform/audio/VectorMath.h"
30
31 #include "wtf/Assertions.h"
32 #include "wtf/CPU.h"
33 #include <stdint.h>
34
35 #if OS(MACOSX)
36 // On the Mac we use the highly optimized versions in Accelerate.framework
37 // In 32-bit mode (__ppc__ or __i386__) <Accelerate/Accelerate.h> includes <vecL ib/vDSP_translate.h> which defines macros of the same name as
38 // our namespaced function names, so we must handle this case differently. Other architectures (64bit, ARM, etc.) do not include this header file.
39 #include <Accelerate/Accelerate.h>
40 #endif
41
42 #if CPU(X86) || CPU(X86_64)
43 #include <emmintrin.h>
44 #endif
45
46 #include <algorithm>
47 #include <math.h>
48
49 namespace blink {
50
51 namespace VectorMath {
52
53 void vsmul(const float* sourceP, int sourceStride, const float* scale, float* de stP, int destStride, size_t framesToProcess)
54 {
55 #if CPU(X86)
56 ::vsmul(sourceP, sourceStride, scale, destP, destStride, framesToProcess);
57 #else
58 vDSP_vsmul(sourceP, sourceStride, scale, destP, destStride, framesToProcess) ;
59 #endif
60 }
61
62 void vadd(const float* source1P, int sourceStride1, const float* source2P, int s ourceStride2, float* destP, int destStride, size_t framesToProcess)
63 {
64 #if CPU(X86)
65 ::vadd(source1P, sourceStride1, source2P, sourceStride2, destP, destStride, framesToProcess);
66 #else
67 vDSP_vadd(source1P, sourceStride1, source2P, sourceStride2, destP, destStrid e, framesToProcess);
68 #endif
69 }
70
71 void vmul(const float* source1P, int sourceStride1, const float* source2P, int s ourceStride2, float* destP, int destStride, size_t framesToProcess)
72 {
73 #if CPU(X86)
74 ::vmul(source1P, sourceStride1, source2P, sourceStride2, destP, destStride, framesToProcess);
75 #else
76 vDSP_vmul(source1P, sourceStride1, source2P, sourceStride2, destP, destStrid e, framesToProcess);
77 #endif
78 }
79
80 void zvmul(const float* real1P, const float* imag1P, const float* real2P, const float* imag2P, float* realDestP, float* imagDestP, size_t framesToProcess)
81 {
82 DSPSplitComplex sc1;
83 DSPSplitComplex sc2;
84 DSPSplitComplex dest;
85 sc1.realp = const_cast<float*>(real1P);
86 sc1.imagp = const_cast<float*>(imag1P);
87 sc2.realp = const_cast<float*>(real2P);
88 sc2.imagp = const_cast<float*>(imag2P);
89 dest.realp = realDestP;
90 dest.imagp = imagDestP;
91 #if CPU(X86)
92 ::zvmul(&sc1, 1, &sc2, 1, &dest, 1, framesToProcess, 1);
93 #else
94 vDSP_zvmul(&sc1, 1, &sc2, 1, &dest, 1, framesToProcess, 1);
95 #endif
96 }
97
98 void vsma(const float* sourceP, int sourceStride, const float* scale, float* des tP, int destStride, size_t framesToProcess)
99 {
100 vDSP_vsma(sourceP, sourceStride, scale, destP, destStride, destP, destStride , framesToProcess);
101 }
102
103 void vmaxmgv(const float* sourceP, int sourceStride, float* maxP, size_t framesT oProcess)
104 {
105 vDSP_maxmgv(sourceP, sourceStride, maxP, framesToProcess);
106 }
107
108 void vsvesq(const float* sourceP, int sourceStride, float* sumP, size_t framesTo Process)
109 {
110 vDSP_svesq(const_cast<float*>(sourceP), sourceStride, sumP, framesToProcess) ;
111 }
112
113 void vclip(const float* sourceP, int sourceStride, const float* lowThresholdP, c onst float* highThresholdP, float* destP, int destStride, size_t framesToProcess )
114 {
115 vDSP_vclip(const_cast<float*>(sourceP), sourceStride, const_cast<float*>(low ThresholdP), const_cast<float*>(highThresholdP), destP, destStride, framesToProc ess);
116 }
117
118 } // namespace VectorMath
119
120 } // namespace blink
121
122 #endif // ENABLE(WEB_AUDIO)
OLDNEW
« no previous file with comments | « Source/platform/audio/cpu/arm/VectorMathNEON.cpp ('k') | Source/platform/blink_platform.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698