Backed out changeset 56443a56b418 (bug 1853840) for causing build bustages related...
[gecko.git] / media / libsoundtouch / moz-libsoundtouch.patch
blob02e8bd0d93db5ca0a8f6b1ef257581a4cb46d1f9
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 @@
7 #if defined(SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS)
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)
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;
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 @@
38 uint res = 0;
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;
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.
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;
70 +#else
71 + // Compatible with GCC but no cpuid.h.
72 + return 0;
73 #endif
75 return res & ~_dwDisabledISA;
76 diff -u /src/STTypes.h /src/STTypes.h
77 --- /src/STTypes.h
78 +++ /src/STTypes.h
79 @@ -54,12 +54,17 @@
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"
87 -#endif
88 +#include "soundtouch_config.h"
90 +#if defined(WIN32)
91 +#if defined(BUILDING_SOUNDTOUCH)
92 +#define SOUNDTOUCH_API __declspec(dllexport)
93 +#else
94 +#define SOUNDTOUCH_API __declspec(dllimport)
95 +#endif
96 +#else
97 +#define SOUNDTOUCH_API
98 +#endif
100 namespace soundtouch
102 diff -u /src/SoundTouch.h /src/SoundTouch.h
103 --- /src/SoundTouch.h
104 +++ /src/SoundTouch.h
105 @@ -141,7 +141,7 @@
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
112 private:
113 /// Rate transposer class instance
114 diff -u /src/FIRFilter.cpp /src/FIRFilter.cpp
115 --- /src/FIRFilter.cpp
116 +++ /src/FIRFilter.cpp
117 @@ -291,9 +296,11 @@
119 FIRFilter * FIRFilter::newInstance()
121 +#if defined(SOUNDTOUCH_ALLOW_MMX) || defined(SOUNDTOUCH_ALLOW_SSE)
122 uint uExtensions;
124 uExtensions = detectCPUextensions();
125 +#endif
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
132 @@ -624,9 +624,11 @@
134 TDStretch * TDStretch::newInstance()
136 +#if defined(SOUNDTOUCH_ALLOW_MMX) || defined(SOUNDTOUCH_ALLOW_SSE)
137 uint uExtensions;
139 uExtensions = detectCPUextensions();
140 +#endif
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
147 @@ -42,7 +42,7 @@
149 using namespace soundtouch;
151 -#define PI 3.14159265358979323846
152 +#define PI M_PI
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
161 @@ -60,7 +60,13 @@
162 //////////////////////////////////////////////////////////////////////////////
164 #include "TDStretch.h"
166 +#ifdef SOUNDTOUCH_WASM_SIMD
167 +#include "simde/x86/avx2.h"
168 +#else
169 #include <xmmintrin.h>
170 +#endif
172 #include <math.h>
174 // Calculates cross correlation of two buffers