simplify checks for enabling SSE2 code

also fixes build issues under vs11 which has a native arm compiler for
windows 8 targets

Change-Id: Id76c2deae9fc9de147d13ad0d34edffcb5a726c4
This commit is contained in:
James Zern 2011-12-15 17:03:57 -08:00
parent 7937b409e7
commit f06817aaea
8 changed files with 26 additions and 12 deletions

View File

@ -37,11 +37,11 @@ static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) {
: "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) : "=a"(cpu_info[0]), "=b"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3])
: "a"(info_type)); : "a"(info_type));
} }
#elif defined(_MSC_VER) // Visual C++ #elif defined(WEBP_MSC_SSE2)
#define GetCPUInfo __cpuid #define GetCPUInfo __cpuid
#endif #endif
#if defined(__i386__) || defined(__x86_64__) || defined(_MSC_VER) #if defined(__i386__) || defined(__x86_64__) || defined(WEBP_MSC_SSE2)
static int x86CPUInfo(CPUFeature feature) { static int x86CPUInfo(CPUFeature feature) {
int cpu_info[4]; int cpu_info[4];
GetCPUInfo(cpu_info, 1); GetCPUInfo(cpu_info, 1);

View File

@ -715,7 +715,7 @@ void VP8DspInit(void) {
// If defined, use CPUInfo() to overwrite some pointers with faster versions. // If defined, use CPUInfo() to overwrite some pointers with faster versions.
if (VP8GetCPUInfo) { if (VP8GetCPUInfo) {
#if defined(__SSE2__) || defined(_MSC_VER) #if defined(WEBP_USE_SSE2)
if (VP8GetCPUInfo(kSSE2)) { if (VP8GetCPUInfo(kSSE2)) {
VP8DspInitSSE2(); VP8DspInitSSE2();
} }

View File

@ -10,7 +10,9 @@
// Author: somnath@google.com (Somnath Banerjee) // Author: somnath@google.com (Somnath Banerjee)
// cduvivier@google.com (Christian Duvivier) // cduvivier@google.com (Christian Duvivier)
#if defined(__SSE2__) || defined(_MSC_VER) #include "./dsp.h"
#if defined(WEBP_USE_SSE2)
#include <emmintrin.h> #include <emmintrin.h>
#include "../dec/vp8i.h" #include "../dec/vp8i.h"
@ -898,4 +900,4 @@ void VP8DspInitSSE2(void) {
} // extern "C" } // extern "C"
#endif #endif
#endif //__SSE2__ || _MSC_VER #endif // WEBP_USE_SSE2

View File

@ -21,6 +21,14 @@ extern "C" {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// CPU detection // CPU detection
#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86))
#define WEBP_MSC_SSE2 // Visual C++ SSE2 targets
#endif
#if defined(__SSE2__) || defined(WEBP_MSC_SSE2)
#define WEBP_USE_SSE2
#endif
typedef enum { typedef enum {
kSSE2, kSSE2,
kSSE3, kSSE3,

View File

@ -9,6 +9,7 @@
// //
// Author: Skal (pascal.massimino@gmail.com) // Author: Skal (pascal.massimino@gmail.com)
#include "./dsp.h"
#include "../enc/vp8enci.h" #include "../enc/vp8enci.h"
#if defined(__cplusplus) || defined(c_plusplus) #if defined(__cplusplus) || defined(c_plusplus)
@ -734,7 +735,7 @@ void VP8EncDspInit(void) {
// If defined, use CPUInfo() to overwrite some pointers with faster versions. // If defined, use CPUInfo() to overwrite some pointers with faster versions.
if (VP8GetCPUInfo) { if (VP8GetCPUInfo) {
#if defined(__SSE2__) || defined(_MSC_VER) #if defined(WEBP_USE_SSE2)
if (VP8GetCPUInfo(kSSE2)) { if (VP8GetCPUInfo(kSSE2)) {
VP8EncDspInitSSE2(); VP8EncDspInitSSE2();
} }

View File

@ -9,7 +9,9 @@
// //
// Author: Christian Duvivier (cduvivier@google.com) // Author: Christian Duvivier (cduvivier@google.com)
#if defined(__SSE2__) || defined(_MSC_VER) #include "./dsp.h"
#if defined(WEBP_USE_SSE2)
#include <emmintrin.h> #include <emmintrin.h>
#include "../enc/vp8enci.h" #include "../enc/vp8enci.h"
@ -831,4 +833,4 @@ void VP8EncDspInitSSE2(void) {
} // extern "C" } // extern "C"
#endif #endif
#endif //__SSE2__ #endif // WEBP_USE_SSE2

View File

@ -227,7 +227,7 @@ void WebPInitUpsamplers(void) {
// If defined, use CPUInfo() to overwrite some pointers with faster versions. // If defined, use CPUInfo() to overwrite some pointers with faster versions.
if (VP8GetCPUInfo) { if (VP8GetCPUInfo) {
#if defined(__SSE2__) || defined(_MSC_VER) #if defined(WEBP_USE_SSE2)
if (VP8GetCPUInfo(kSSE2)) { if (VP8GetCPUInfo(kSSE2)) {
WebPInitUpsamplersSSE2(); WebPInitUpsamplersSSE2();
} }

View File

@ -9,12 +9,13 @@
// //
// Author: somnath@google.com (Somnath Banerjee) // Author: somnath@google.com (Somnath Banerjee)
#if defined(__SSE2__) || defined(_MSC_VER) #include "./dsp.h"
#if defined(WEBP_USE_SSE2)
#include <assert.h> #include <assert.h>
#include <emmintrin.h> #include <emmintrin.h>
#include <string.h> #include <string.h>
#include "./dsp.h"
#include "./yuv.h" #include "./yuv.h"
#include "../dec/webpi.h" #include "../dec/webpi.h"
@ -212,4 +213,4 @@ void WebPInitUpsamplersSSE2(void) {
} // extern "C" } // extern "C"
#endif #endif
#endif //__SSE2__ || _MSC_VER #endif // WEBP_USE_SSE2