1 diff -u /src/cpu_detect_x86.cpp /src/cpu_detect_x86.cpp
2 --- /src/cpu_detect_x86.cpp
3 +++ /src/cpu_detect_x86.cpp
7 #if defined(SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS)
9 - #if defined(__GNUC__) && defined(__i386__)
11 + #if defined(__GNUC__) && defined(HAVE_CPUID_H)
14 #elif defined(_M_IX86)
17 /// Checks which instruction set extensions are supported by the CPU.
18 uint detectCPUextensions(void)
20 +/// If building for RLBox, we enable the SSE code that will be
21 +/// translated to WASMSIMD with SIMD-everywhere.
22 +#if defined(SOUNDTOUCH_WASM_SIMD)
24 + res = res | SUPPORT_SSE;
25 + res = res | SUPPORT_SSE2;
26 + return res & ~_dwDisabledISA;
28 /// If building for a 64bit system (no Itanium) and the user wants optimizations.
29 /// Return the OR of SUPPORT_{MMX,SSE,SSE2}. 11001 or 0x19.
30 /// Keep the _dwDisabledISA test (2 more operations, could be eliminated).
31 -#if ((defined(__GNUC__) && defined(__x86_64__)) \
32 +#elif ((defined(__GNUC__) && defined(__x86_64__)) \
34 && defined(SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS)
35 return 0x19 & ~_dwDisabledISA;
40 -#if defined(__GNUC__)
41 - // GCC version of cpuid. Requires GCC 4.3.0 or later for __cpuid intrinsic support.
42 - uint eax, ebx, ecx, edx; // unsigned int is the standard type. uint is defined by the compiler and not guaranteed to be portable.
44 - // Check if no cpuid support.
45 - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) return 0; // always disable extensions.
47 - if (edx & bit_MMX) res = res | SUPPORT_MMX;
48 - if (edx & bit_SSE) res = res | SUPPORT_SSE;
49 - if (edx & bit_SSE2) res = res | SUPPORT_SSE2;
52 +#if !defined(__GNUC__)
53 // Window / VS version of cpuid. Notice that Visual Studio 2005 or later required
54 // for __cpuid intrinsic support.
57 if ((unsigned int)reg[3] & bit_MMX) res = res | SUPPORT_MMX;
58 if ((unsigned int)reg[3] & bit_SSE) res = res | SUPPORT_SSE;
59 if ((unsigned int)reg[3] & bit_SSE2) res = res | SUPPORT_SSE2;
60 +#elif defined(HAVE_CPUID_H)
61 + // GCC version of cpuid. Requires GCC 4.3.0 or later for __cpuid intrinsic support.
62 + uint eax, ebx, ecx, edx; // unsigned int is the standard type. uint is defined by the compiler and not guaranteed to be portable.
64 + // Check if no cpuid support.
65 + if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) return 0; // always disable extensions.
67 + if (edx & bit_MMX) res = res | SUPPORT_MMX;
68 + if (edx & bit_SSE) res = res | SUPPORT_SSE;
69 + if (edx & bit_SSE2) res = res | SUPPORT_SSE2;
71 + // Compatible with GCC but no cpuid.h.
75 return res & ~_dwDisabledISA;
76 diff -u /src/STTypes.h /src/STTypes.h
80 #define SOUNDTOUCH_ALIGN_POINTER_16(x) ( ( (ulongptr)(x) + 15 ) & ~(ulongptr)15 )
83 -#if (defined(__GNUC__) && !defined(ANDROID))
84 - // In GCC, include soundtouch_config.h made by config scritps.
85 - // Skip this in Android compilation that uses GCC but without configure scripts.
86 - #include "soundtouch_config.h"
88 +#include "soundtouch_config.h"
91 +#if defined(BUILDING_SOUNDTOUCH)
92 +#define SOUNDTOUCH_API __declspec(dllexport)
94 +#define SOUNDTOUCH_API __declspec(dllimport)
97 +#define SOUNDTOUCH_API
102 diff -u /src/SoundTouch.h /src/SoundTouch.h
103 --- /src/SoundTouch.h
104 +++ /src/SoundTouch.h
106 /// tempo/pitch/rate/samplerate settings.
107 #define SETTING_NOMINAL_OUTPUT_SEQUENCE 7
109 -class SoundTouch : public FIFOProcessor
110 +class SOUNDTOUCH_API SoundTouch : public FIFOProcessor
113 /// Rate transposer class instance
114 diff -u /src/FIRFilter.cpp /src/FIRFilter.cpp
115 --- /src/FIRFilter.cpp
116 +++ /src/FIRFilter.cpp
119 FIRFilter * FIRFilter::newInstance()
121 +#if defined(SOUNDTOUCH_ALLOW_MMX) || defined(SOUNDTOUCH_ALLOW_SSE)
124 uExtensions = detectCPUextensions();
127 // Check if MMX/SSE instruction set extensions supported by CPU
129 diff -u /src/TDStretch.cpp /src/TDStretch.cpp
130 --- /src/TDStretch.cpp
131 +++ /src/TDStretch.cpp
134 TDStretch * TDStretch::newInstance()
136 +#if defined(SOUNDTOUCH_ALLOW_MMX) || defined(SOUNDTOUCH_ALLOW_SSE)
139 uExtensions = detectCPUextensions();
142 // Check if MMX/SSE instruction set extensions supported by CPU
144 diff -u /src/AAFilter.cpp /src/AAFilter.cpp
145 --- /src/AAFilter.cpp
146 +++ /src/AAFilter.cpp
149 using namespace soundtouch;
151 -#define PI 3.14159265358979323846
153 #define TWOPI (2 * PI)
155 // define this to save AA filter coefficients to a file
158 diff -u /src/sse_optimized.cpp /src/sse_optimized.cpp
159 --- /src/sse_optimized.cpp
160 +++ /src_patched/sse_optimized.cpp
162 //////////////////////////////////////////////////////////////////////////////
164 #include "TDStretch.h"
166 +#ifdef SOUNDTOUCH_WASM_SIMD
167 +#include "simde/x86/avx2.h"
169 #include <xmmintrin.h>
174 // Calculates cross correlation of two buffers