moz-libsoundtouch.patch (4798B)
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 4 @@ -37,9 +37,8 @@ 5 6 7 #if defined(SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS) 8 - 9 - #if defined(__GNUC__) && defined(__i386__) 10 - // gcc 11 + #if defined(__GNUC__) && defined(HAVE_CPUID_H) 12 + // gcc and clang 13 #include "cpuid.h" 14 #elif defined(_M_IX86) 15 // windows non-gcc 16 @@ -71,10 +70,18 @@ 17 /// Checks which instruction set extensions are supported by the CPU. 18 uint detectCPUextensions(void) 19 { 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) 23 + uint res = 0; 24 + res = res | SUPPORT_SSE; 25 + res = res | SUPPORT_SSE2; 26 + return res & ~_dwDisabledISA; 27 + 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__)) \ 33 || defined(_M_X64)) \ 34 && defined(SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS) 35 return 0x19 & ~_dwDisabledISA; 36 @@ -89,18 +96,7 @@ 37 38 uint res = 0; 39 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. 43 - 44 - // Check if no cpuid support. 45 - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) return 0; // always disable extensions. 46 - 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; 50 - 51 -#else 52 +#if !defined(__GNUC__) 53 // Window / VS version of cpuid. Notice that Visual Studio 2005 or later required 54 // for __cpuid intrinsic support. 55 int reg[4] = {-1}; 56 @@ -113,7 +109,19 @@ 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. 63 + 64 + // Check if no cpuid support. 65 + if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) return 0; // always disable extensions. 66 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; 70 +#else 71 + // Compatible with GCC but no cpuid.h. 72 + return 0; 73 #endif 74 75 return res & ~_dwDisabledISA; 76 diff -u /src/STTypes.h /src/STTypes.h 77 --- /src/STTypes.h 78 +++ /src/STTypes.h 79 @@ -54,11 +54,7 @@ 80 #define SOUNDTOUCH_ALIGN_POINTER_16(x) ( ( (ulongptr)(x) + 15 ) & ~(ulongptr)15 ) 81 82 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" 87 -#endif 88 +#include "soundtouch_config.h" 89 90 namespace soundtouch 91 { 92 diff -u /src/FIRFilter.cpp /src/FIRFilter.cpp 93 --- /src/FIRFilter.cpp 94 +++ /src/FIRFilter.cpp 95 @@ -291,9 +296,11 @@ 96 97 FIRFilter * FIRFilter::newInstance() 98 { 99 +#if defined(SOUNDTOUCH_ALLOW_MMX) || defined(SOUNDTOUCH_ALLOW_SSE) 100 uint uExtensions; 101 102 uExtensions = detectCPUextensions(); 103 +#endif 104 105 // Check if MMX/SSE instruction set extensions supported by CPU 106 107 diff -u /src/TDStretch.cpp /src/TDStretch.cpp 108 --- /src/TDStretch.cpp 109 +++ /src/TDStretch.cpp 110 @@ -624,9 +624,11 @@ 111 112 TDStretch * TDStretch::newInstance() 113 { 114 +#if defined(SOUNDTOUCH_ALLOW_MMX) || defined(SOUNDTOUCH_ALLOW_SSE) 115 uint uExtensions; 116 117 uExtensions = detectCPUextensions(); 118 +#endif 119 120 // Check if MMX/SSE instruction set extensions supported by CPU 121 122 diff -u /src/AAFilter.cpp /src/AAFilter.cpp 123 --- /src/AAFilter.cpp 124 +++ /src/AAFilter.cpp 125 @@ -42,7 +42,7 @@ 126 127 using namespace soundtouch; 128 129 -#define PI 3.14159265358979323846 130 +#define PI M_PI 131 #define TWOPI (2 * PI) 132 133 // define this to save AA filter coefficients to a file 134 135 136 diff -u /src/sse_optimized.cpp /src/sse_optimized.cpp 137 --- /src/sse_optimized.cpp 138 +++ /src_patched/sse_optimized.cpp 139 @@ -60,7 +60,13 @@ 140 ////////////////////////////////////////////////////////////////////////////// 141 142 #include "TDStretch.h" 143 + 144 +#ifdef SOUNDTOUCH_WASM_SIMD 145 +#include "simde/x86/avx2.h" 146 +#else 147 #include <xmmintrin.h> 148 +#endif 149 + 150 #include <math.h> 151 152 // Calculates cross correlation of two buffers