summaryrefslogtreecommitdiff
blob: a0f787c038645f47af2ee6bebb3c3019c32c3f1c (plain)
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
https://bugs.gentoo.org/475266

From 07ccc514dc688f0dd53f603d206894023e65ab20 Mon Sep 17 00:00:00 2001
From: Jose Quinteiro <gentoo@quinteiro.org>
Date: Sat, 27 Apr 2013 11:29:51 -0700
Subject: [PATCH] Detect SSE2 support

Compilation on an older 32-bit Athlon XP chip fails with the error
"./Utils/AEUtil.h:50:12: error: '__m128i' does not name a type"
This is because the __m128i type is only available on SSE2 platforms.
Modify the preprocessor logic to detect SSE and SSE2 support separately.

The "emmintrin.h" header should only be included on SSE2 platforms as
well.
---
 xbmc/cores/AudioEngine/Utils/AEConvert.cpp | 25 ++++++++++---------------
 xbmc/cores/AudioEngine/Utils/AEUtil.cpp    |  4 ++--
 xbmc/cores/AudioEngine/Utils/AEUtil.h      |  9 ++++++++-
 3 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/xbmc/cores/AudioEngine/Utils/AEConvert.cpp b/xbmc/cores/AudioEngine/Utils/AEConvert.cpp
index 0b0b646..7cfde5e 100644
--- a/xbmc/cores/AudioEngine/Utils/AEConvert.cpp
+++ b/xbmc/cores/AudioEngine/Utils/AEConvert.cpp
@@ -33,11 +33,6 @@
 #include <math.h>
 #include <string.h>
 
-#ifdef __SSE__
-#include <xmmintrin.h>
-#include <emmintrin.h>
-#endif
-
 #ifdef __ARM_NEON__
 #include <arm_neon.h>
 #endif
@@ -517,7 +512,7 @@ unsigned int CAEConvert::Float_S8(float *data, const unsigned int samples, uint8
 unsigned int CAEConvert::Float_S16LE(float *data, const unsigned int samples, uint8_t *dest)
 {
   int16_t *dst = (int16_t*)dest;
-  #ifdef __SSE__
+  #ifdef __SSE2__
 
   unsigned int count     = samples;
   unsigned int unaligned = (0x10 - ((uintptr_t)data & 0xF)) >> 2;
@@ -623,7 +618,7 @@ unsigned int CAEConvert::Float_S16LE(float *data, const unsigned int samples, ui
   /* cleanup */
   _mm_empty();
 
-  #else /* no SSE */
+  #else /* no SSE2 */
 
   uint32_t i    = 0;
   uint32_t even = samples & ~0x3;
@@ -651,7 +646,7 @@ unsigned int CAEConvert::Float_S16LE(float *data, const unsigned int samples, ui
 unsigned int CAEConvert::Float_S16BE(float *data, const unsigned int samples, uint8_t *dest)
 {
   int16_t *dst = (int16_t*)dest;
-  #ifdef __SSE__
+  #ifdef __SSE2__
 
   unsigned int count     = samples;
   unsigned int unaligned = (0x10 - ((uintptr_t)data & 0xF)) >> 2;
@@ -757,7 +752,7 @@ unsigned int CAEConvert::Float_S16BE(float *data, const unsigned int samples, ui
   /* cleanup */
   _mm_empty();
 
-  #else /* no SSE */
+  #else /* no SSE2 */
 
   uint32_t i    = 0;
   uint32_t even = samples & ~0x3;
@@ -785,7 +780,7 @@ unsigned int CAEConvert::Float_S16BE(float *data, const unsigned int samples, ui
 unsigned int CAEConvert::Float_S24NE4(float *data, const unsigned int samples, uint8_t *dest)
 {
   int32_t *dst = (int32_t*)dest;
-  #ifdef __SSE__
+  #ifdef __SSE2__
 
   const __m128 mul = _mm_set_ps1((float)INT24_MAX+.5f);
   unsigned int count = samples;
@@ -835,7 +830,7 @@ unsigned int CAEConvert::Float_S24NE4(float *data, const unsigned int samples, u
     }
   }
   _mm_empty();
-  #else /* no SSE */
+  #else /* no SSE2 */
   for (uint32_t i = 0; i < samples; ++i)
     *dst++ = (safeRound(*data++ * ((float)INT24_MAX+.5f)) & 0xFFFFFF) << 8;
   #endif
@@ -929,7 +924,7 @@ unsigned int CAEConvert::Float_S24NE3(float *data, const unsigned int samples, u
 unsigned int CAEConvert::Float_S32LE(float *data, const unsigned int samples, uint8_t *dest)
 {
   int32_t *dst = (int32_t*)dest;
-  #ifdef __SSE__
+  #ifdef __SSE2__
   const __m128 mul = _mm_set_ps1(MUL32);
   unsigned int count = samples;
 
@@ -989,7 +984,7 @@ unsigned int CAEConvert::Float_S32LE(float *data, const unsigned int samples, ui
   _mm_empty();
   #else
 
-  /* no SIMD */
+  /* no SSE2 */
   for (uint32_t i = 0; i < samples; ++i, ++data, ++dst)
   {
     dst[0] = safeRound(data[0] * MUL32);
@@ -1038,7 +1033,7 @@ unsigned int CAEConvert::Float_S32LE_Neon(float *data, const unsigned int sample
 unsigned int CAEConvert::Float_S32BE(float *data, const unsigned int samples, uint8_t *dest)
 {
   int32_t *dst = (int32_t*)dest;
-  #ifdef __SSE__
+  #ifdef __SSE2__
   const __m128 mul = _mm_set_ps1(MUL32);
   unsigned int count = samples;
 
@@ -1097,7 +1092,7 @@ unsigned int CAEConvert::Float_S32BE(float *data, const unsigned int samples, ui
   }
   _mm_empty();
   #else
-  /* no SIMD */
+  /* no SSE2 */
   for (uint32_t i = 0; i < samples; ++i, ++data, ++dst)
   {
     dst[0] = safeRound(data[0] * MUL32);
diff --git a/xbmc/cores/AudioEngine/Utils/AEUtil.cpp b/xbmc/cores/AudioEngine/Utils/AEUtil.cpp
index 6de84dc..2b6e0cd 100644
--- a/xbmc/cores/AudioEngine/Utils/AEUtil.cpp
+++ b/xbmc/cores/AudioEngine/Utils/AEUtil.cpp
@@ -30,7 +30,7 @@ using namespace std;
 
 /* declare the rng seed and initialize it */
 unsigned int CAEUtil::m_seed = (unsigned int)(CurrentHostCounter() / 1000.0f);
-#ifdef __SSE__
+#ifdef __SSE2__
   /* declare the SSE seed and initialize it */
   MEMALIGN(16, __m128i CAEUtil::m_sseSeed) = _mm_set_epi32(CAEUtil::m_seed, CAEUtil::m_seed+1, CAEUtil::m_seed, CAEUtil::m_seed+1);
 #endif
@@ -386,7 +386,7 @@ float CAEUtil::FloatRand1(const float min, const float max)
 
 void CAEUtil::FloatRand4(const float min, const float max, float result[4], __m128 *sseresult/* = NULL */)
 {
-  #ifdef __SSE__
+  #ifdef __SSE2__
     /*
       this method may be called from other SSE code, we need
       to calculate the delta & factor using SSE as the FPU
diff --git a/xbmc/cores/AudioEngine/Utils/AEUtil.h b/xbmc/cores/AudioEngine/Utils/AEUtil.h
index 48cbc3b..6fdb7f2 100644
--- a/xbmc/cores/AudioEngine/Utils/AEUtil.h
+++ b/xbmc/cores/AudioEngine/Utils/AEUtil.h
@@ -27,6 +27,9 @@
 #ifdef TARGET_WINDOWS
 #if _M_IX86_FP>0 && !defined(__SSE__)
 #define __SSE__
+#if _M_IX86_FP>1 && !defined(__SSE2__)
+#define __SSE2__
+#endif
 #endif
 #endif
 
@@ -36,6 +39,10 @@
 #define __m128 void
 #endif
 
+#ifdef __SSE2__
+#include <emmintrin.h>
+#endif
+
 #ifdef __GNUC__
   #define MEMALIGN(b, x) x __attribute__((aligned(b)))
 #else
@@ -63,7 +70,7 @@ class CAEUtil
 {
 private:
   static unsigned int m_seed;
-  #ifdef __SSE__
+  #ifdef __SSE2__
     static __m128i m_sseSeed;
   #endif
 
-- 
1.8.4.3