From b40e2fe115df5465851de8194a3b414241f1104b Mon Sep 17 00:00:00 2001 From: Jose Quinteiro Date: Mon, 8 Apr 2013 22:26:22 -0700 Subject: [PATCH 1/1] 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 | 6 +++++- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/xbmc/cores/AudioEngine/Utils/AEConvert.cpp b/xbmc/cores/AudioEngine/Utils/AEConvert.cpp index 97ec87b..211ec10 100644 --- a/xbmc/cores/AudioEngine/Utils/AEConvert.cpp +++ b/xbmc/cores/AudioEngine/Utils/AEConvert.cpp @@ -33,11 +33,6 @@ #include #include -#ifdef __SSE__ -#include -#include -#endif - #ifdef __ARM_NEON__ #include #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 @@ -925,7 +920,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((float)INT32_MAX); unsigned int count = samples; @@ -985,7 +980,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] * (float)INT32_MAX); @@ -1034,7 +1029,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((float)INT32_MAX); unsigned int count = samples; @@ -1093,7 +1088,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] * (float)INT32_MAX); 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 458dc00..112c180 100644 --- a/xbmc/cores/AudioEngine/Utils/AEUtil.h +++ b/xbmc/cores/AudioEngine/Utils/AEUtil.h @@ -36,6 +36,10 @@ #define __m128 void #endif +#ifdef __SSE2__ +#include +#endif + #ifdef __GNUC__ #define MEMALIGN(b, x) x __attribute__((aligned(b))) #else @@ -46,7 +50,7 @@ class CAEUtil { private: static unsigned int m_seed; - #ifdef __SSE__ + #ifdef __SSE2__ static __m128i m_sseSeed; #endif -- 1.8.1.5