Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCasimir666 <casimir666@users.sourceforge.net>2009-10-23 21:43:11 +0400
committerCasimir666 <casimir666@users.sourceforge.net>2009-10-23 21:43:11 +0400
commitc797388b39dd73f0f8937b490e93f56948ae8da7 (patch)
tree2c55039af7cfdb69861c8932da265ad4a29b00af /src/filters/renderer/MpcAudioRenderer/SoundTouch
parentab8bf4d43690e7ac03d4ef5e34ccf9478da73f7e (diff)
Fixed : x64 compilation error for MpcAudioRenderer
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1303 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/renderer/MpcAudioRenderer/SoundTouch')
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/include/STTypes.h4
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/3dnow_win.cpp8
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect_x86_win.cpp108
3 files changed, 62 insertions, 58 deletions
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/include/STTypes.h b/src/filters/renderer/MpcAudioRenderer/SoundTouch/include/STTypes.h
index 641720f13..1e1a5b71b 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/include/STTypes.h
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/include/STTypes.h
@@ -87,7 +87,7 @@ namespace soundtouch
#endif
- #if (WIN32 || __i386__ || __x86_64__)
+ #if defined(WIN32) || defined(__i386__) || defined(__x86_64__)
/// Define this to allow X86-specific assembler/intrinsic optimizations.
/// Notice that library contains also usual C++ versions of each of these
/// these routines, so if you're having difficulties getting the optimized
@@ -129,7 +129,7 @@ namespace soundtouch
#ifdef ALLOW_X86_OPTIMIZATIONS
// Allow 3DNow! and SSE optimizations
- #if WIN32
+ #if defined(WIN32)
#define ALLOW_3DNOW 1
#endif
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/3dnow_win.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/3dnow_win.cpp
index 68243cd4e..9da06c613 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/3dnow_win.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/3dnow_win.cpp
@@ -66,13 +66,15 @@
#include "cpu_detect.h"
#include "STTypes.h"
-#ifndef WIN32
-#error "wrong platform - this source code file is exclusively for Win32 platform"
-#endif
using namespace soundtouch;
#ifdef ALLOW_3DNOW
+
+#ifndef WIN32
+#error "wrong platform - this source code file is exclusively for Win32 platform"
+#endif
+
// 3DNow! routines available only with float sample type
//////////////////////////////////////////////////////////////////////////////
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect_x86_win.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect_x86_win.cpp
index 9eabd5575..d9287b613 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect_x86_win.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect_x86_win.cpp
@@ -41,10 +41,15 @@
////////////////////////////////////////////////////////////////////////////////
#include "cpu_detect.h"
+#include "intrin.h"
+
+typedef enum PROCESSOR_TYPE
+{
+ PROCESSOR_AMD,
+ PROCESSOR_INTEL,
+ PROCESSOR_UNKNOWN
+};
-#ifndef WIN32
-#error wrong platform - this source code file is exclusively for Win32 platform
-#endif
//////////////////////////////////////////////////////////////////////////////
//
@@ -71,56 +76,53 @@ uint detectCPUextensions(void)
if (_dwDisabledISA == 0xffffffff) return 0;
- _asm
- {
- ; check if 'cpuid' instructions is available by toggling eflags bit 21
- ;
- xor esi, esi ; clear esi = result register
-
- pushfd ; save eflags to stack
- pop eax ; load eax from stack (with eflags)
- mov ecx, eax ; save the original eflags values to ecx
- xor eax, 0x00200000 ; toggle bit 21
- push eax ; store toggled eflags to stack
- popfd ; load eflags from stack
- pushfd ; save updated eflags to stack
- pop eax ; load from stack
- xor edx, edx ; clear edx for defaulting no mmx
- cmp eax, ecx ; compare to original eflags values
- jz end ; jumps to 'end' if cpuid not present
-
- ; cpuid instruction available, test for presence of mmx instructions
- mov eax, 1
- cpuid
- test edx, 0x00800000
- jz end ; branch if MMX not available
-
- or esi, SUPPORT_MMX ; otherwise add MMX support bit
-
- test edx, 0x02000000
- jz test3DNow ; branch if SSE not available
-
- or esi, SUPPORT_SSE ; otherwise add SSE support bit
-
- test3DNow:
- ; test for precense of AMD extensions
- mov eax, 0x80000000
- cpuid
- cmp eax, 0x80000000
- jbe end ; branch if no AMD extensions detected
-
- ; test for precense of 3DNow! extension
- mov eax, 0x80000001
- cpuid
- test edx, 0x80000000
- jz end ; branch if 3DNow! not detected
-
- or esi, SUPPORT_3DNOW ; otherwise add 3DNow support bit
-
- end:
-
- mov res, esi
- }
+unsigned nHighestFeature;
+unsigned nHighestFeatureEx;
+int nBuff[4];
+char szMan[13];
+char szFeatures[256];
+PROCESSOR_TYPE nType;
+
+ // Get CPU manufacturer and highest CPUID
+ __cpuid(nBuff, 0);
+ nHighestFeature = (unsigned)nBuff[0];
+ *(int*)&szMan[0] = nBuff[1];
+ *(int*)&szMan[4] = nBuff[3];
+ *(int*)&szMan[8] = nBuff[2];
+ szMan[12] = 0;
+ if(strcmp(szMan, "AuthenticAMD") == 0)
+ nType = PROCESSOR_AMD;
+ else if(strcmp(szMan, "GenuineIntel") == 0)
+ nType = PROCESSOR_INTEL;
+ else
+ nType = PROCESSOR_UNKNOWN;
+
+ // Get highest extended feature
+ __cpuid(nBuff, 0x80000000);
+ nHighestFeatureEx = (unsigned)nBuff[0];
+
+ // Get CPU features
+ szFeatures[0] = 0;
+ if(nHighestFeature >= 1)
+ {
+ __cpuid(nBuff, 1);
+ if(nBuff[3] & 1<<23) res|=SUPPORT_MMX;
+ if(nBuff[3] & 1<<25) res|=SUPPORT_SSE;
+ if(nBuff[3] & 1<<26) res|=SUPPORT_SSE2;
+ }
+
+ // AMD specific:
+ if(nType == PROCESSOR_AMD)
+ {
+ // Get extended features
+ __cpuid(nBuff, 0x80000000);
+ if(nHighestFeatureEx >= 0x80000001)
+ {
+ __cpuid(nBuff, 0x80000001);
+ if(nBuff[3] & 1<<31) res|=SUPPORT_3DNOW;
+ }
+ }
+
return res & ~_dwDisabledISA;
}