1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
diff -u /src/cpu_detect_x86.cpp /src/cpu_detect_x86.cpp
--- /src/cpu_detect_x86.cpp
+++ /src/cpu_detect_x86.cpp
@@ -37,9 +37,8 @@
#if defined(SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS)
-
- #if defined(__GNUC__) && defined(__i386__)
- // gcc
+ #if defined(__GNUC__) && defined(HAVE_CPUID_H)
+ // gcc and clang
#include "cpuid.h"
#elif defined(_M_IX86)
// windows non-gcc
@@ -71,10 +70,18 @@
/// Checks which instruction set extensions are supported by the CPU.
uint detectCPUextensions(void)
{
+/// If building for RLBox, we enable the SSE code that will be
+/// translated to WASMSIMD with SIMD-everywhere.
+#if defined(SOUNDTOUCH_WASM_SIMD)
+ uint res = 0;
+ res = res | SUPPORT_SSE;
+ res = res | SUPPORT_SSE2;
+ return res & ~_dwDisabledISA;
+
/// If building for a 64bit system (no Itanium) and the user wants optimizations.
/// Return the OR of SUPPORT_{MMX,SSE,SSE2}. 11001 or 0x19.
/// Keep the _dwDisabledISA test (2 more operations, could be eliminated).
-#if ((defined(__GNUC__) && defined(__x86_64__)) \
+#elif ((defined(__GNUC__) && defined(__x86_64__)) \
|| defined(_M_X64)) \
&& defined(SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS)
return 0x19 & ~_dwDisabledISA;
@@ -89,18 +96,7 @@
uint res = 0;
-#if defined(__GNUC__)
- // GCC version of cpuid. Requires GCC 4.3.0 or later for __cpuid intrinsic support.
- uint eax, ebx, ecx, edx; // unsigned int is the standard type. uint is defined by the compiler and not guaranteed to be portable.
-
- // Check if no cpuid support.
- if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) return 0; // always disable extensions.
-
- if (edx & bit_MMX) res = res | SUPPORT_MMX;
- if (edx & bit_SSE) res = res | SUPPORT_SSE;
- if (edx & bit_SSE2) res = res | SUPPORT_SSE2;
-
-#else
+#if !defined(__GNUC__)
// Window / VS version of cpuid. Notice that Visual Studio 2005 or later required
// for __cpuid intrinsic support.
int reg[4] = {-1};
@@ -113,7 +109,19 @@
if ((unsigned int)reg[3] & bit_MMX) res = res | SUPPORT_MMX;
if ((unsigned int)reg[3] & bit_SSE) res = res | SUPPORT_SSE;
if ((unsigned int)reg[3] & bit_SSE2) res = res | SUPPORT_SSE2;
+#elif defined(HAVE_CPUID_H)
+ // GCC version of cpuid. Requires GCC 4.3.0 or later for __cpuid intrinsic support.
+ uint eax, ebx, ecx, edx; // unsigned int is the standard type. uint is defined by the compiler and not guaranteed to be portable.
+
+ // Check if no cpuid support.
+ if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) return 0; // always disable extensions.
+ if (edx & bit_MMX) res = res | SUPPORT_MMX;
+ if (edx & bit_SSE) res = res | SUPPORT_SSE;
+ if (edx & bit_SSE2) res = res | SUPPORT_SSE2;
+#else
+ // Compatible with GCC but no cpuid.h.
+ return 0;
#endif
return res & ~_dwDisabledISA;
diff -u /src/STTypes.h /src/STTypes.h
--- /src/STTypes.h
+++ /src/STTypes.h
@@ -54,11 +54,7 @@
#define SOUNDTOUCH_ALIGN_POINTER_16(x) ( ( (ulongptr)(x) + 15 ) & ~(ulongptr)15 )
-#if (defined(__GNUC__) && !defined(ANDROID))
- // In GCC, include soundtouch_config.h made by config scritps.
- // Skip this in Android compilation that uses GCC but without configure scripts.
- #include "soundtouch_config.h"
-#endif
+#include "soundtouch_config.h"
namespace soundtouch
{
diff -u /src/FIRFilter.cpp /src/FIRFilter.cpp
--- /src/FIRFilter.cpp
+++ /src/FIRFilter.cpp
@@ -291,9 +296,11 @@
FIRFilter * FIRFilter::newInstance()
{
+#if defined(SOUNDTOUCH_ALLOW_MMX) || defined(SOUNDTOUCH_ALLOW_SSE)
uint uExtensions;
uExtensions = detectCPUextensions();
+#endif
// Check if MMX/SSE instruction set extensions supported by CPU
diff -u /src/TDStretch.cpp /src/TDStretch.cpp
--- /src/TDStretch.cpp
+++ /src/TDStretch.cpp
@@ -624,9 +624,11 @@
TDStretch * TDStretch::newInstance()
{
+#if defined(SOUNDTOUCH_ALLOW_MMX) || defined(SOUNDTOUCH_ALLOW_SSE)
uint uExtensions;
uExtensions = detectCPUextensions();
+#endif
// Check if MMX/SSE instruction set extensions supported by CPU
diff -u /src/AAFilter.cpp /src/AAFilter.cpp
--- /src/AAFilter.cpp
+++ /src/AAFilter.cpp
@@ -42,7 +42,7 @@
using namespace soundtouch;
-#define PI 3.14159265358979323846
+#define PI M_PI
#define TWOPI (2 * PI)
// define this to save AA filter coefficients to a file
diff -u /src/sse_optimized.cpp /src/sse_optimized.cpp
--- /src/sse_optimized.cpp
+++ /src_patched/sse_optimized.cpp
@@ -60,7 +60,13 @@
//////////////////////////////////////////////////////////////////////////////
#include "TDStretch.h"
+
+#ifdef SOUNDTOUCH_WASM_SIMD
+#include "simde/x86/avx2.h"
+#else
#include <xmmintrin.h>
+#endif
+
#include <math.h>
// Calculates cross correlation of two buffers
|