Using cpudetect code instead of d_cpu.s

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4263 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
nick 2002-01-19 18:22:22 +00:00
parent 20e408a606
commit ff4cca939b
4 changed files with 31 additions and 330 deletions

View File

@ -9,8 +9,8 @@ OPTFLAGS := $(OPTFLAGS:-O4=-O0)
endif
CFLAGS = $(OPTFLAGS) $(EXTRA_INC)
ifeq ($(TARGET_ARCH_X86),yes)
SRCS += d_cpu.s decode_i586.c
OBJS += d_cpu.o decode_i586.o
SRCS += decode_i586.c
OBJS += decode_i586.o
ifeq ($(TARGET_MMX),yes)
CFLAGS += -fomit-frame-pointer
SRCS += decode_MMX.c dct64_MMX.c tabinit_MMX.c

View File

@ -1,21 +0,0 @@
// --------------------------------------------------------------------------
// Cpu function detect by Pontscho/fresh!mindworkz
// --------------------------------------------------------------------------
#ifndef __MY_CPUIDENT
#define __MY_CPUIDENT
unsigned int _CpuID;
unsigned int _i586;
unsigned int _3dnow;
unsigned int _isse;
unsigned int _has_mmx;
extern unsigned long CpuDetect( void );
extern unsigned long ipentium( void );
extern unsigned long isse( void );
extern unsigned long a3dnow( void );
#endif

View File

@ -1,156 +0,0 @@
/ ---------------------------------------------------------------------------
/ Cpu function detect by Pontscho/fresh!mindworkz (c) 2000 - 2000
/ 3dnow-dsp detection by Nick Kurshev (C) 2001
/ ---------------------------------------------------------------------------
.text
.globl CpuDetect
.globl ipentium
.globl a3dnow
.globl isse
/ ---------------------------------------------------------------------------
/ in C: unsigned long CpuDetect( void );
/ return: cpu ident number.
/ ---------------------------------------------------------------------------
CpuDetect:
pushl %ebx
pushl %ecx
pushl %edx
pushfl
popl %eax
movl %eax,%ebx
xorl $0x00200000,%eax
pushl %eax
popfl
pushfl
popl %eax
cmpl %eax,%ebx
jz no_cpuid_cpudetect
movl $1,%eax
cpuid
jmp exit_cpudetect
no_cpuid_cpudetect:
xorl %eax,%eax
exit_cpudetect:
popl %edx
popl %ecx
popl %ebx
ret
/ ---------------------------------------------------------------------------
/ in C: unsigled long ipentium( void );
/ return: 0 if this processor i386 or i486
/ 1 otherwise
/ 3 if this cpu supports mmx
/ ---------------------------------------------------------------------------
ipentium:
pushl %ebx
pushl %ecx
pushl %edx
pushfl
popl %eax
movl %eax,%ebx
xorl $0x00200000,%eax
pushl %eax
popfl
pushfl
popl %eax
cmpl %eax,%ebx
jz no_cpuid
movl $1,%eax
cpuid
movl %eax, %ecx
xorl %eax, %eax
shrl $8,%ecx
cmpl $5,%ecx
jb exit
incl %eax
test $0x00800000, %edx
jz exit
orl $2, %eax
jmp exit
no_cpuid:
xorl %eax,%eax
exit:
popl %edx
popl %ecx
popl %ebx
ret
/ ---------------------------------------------------------------------------
/ in C: unsigned long a3dnow( void );
/ return: 0 if this processor does not support 3dnow!
/ 1 otherwise
/ 3 if this cpu supports 3dnow-dsp extension
/ ---------------------------------------------------------------------------
a3dnow:
pushl %ebx
pushl %edx
pushl %ecx
call ipentium
testl %eax,%eax
jz exit2
movl $0x80000000,%eax
cpuid
cmpl $0x80000000,%eax
jbe no3dnow
movl $0x80000001,%eax
cpuid
xorl %eax,%eax
testl $0x80000000,%edx
jz no3dnow
/// eax=1 - K6 3DNow!
inc %eax
testl $0x40000000,%edx
jz exit2
/// eax=2 - K7 3DNowEx!
orl $2, %eax
jmp exit2
no3dnow:
xorl %eax,%eax
exit2:
popl %ecx
popl %edx
popl %ebx
ret
/ ---------------------------------------------------------------------------
/ in C: unsigned long isse( void );
/ return: 0 if this processor does not support sse
/ 1 otherwise
/ 3 if this cpu supports sse2 extension
/ ---------------------------------------------------------------------------
isse:
pushl %ebx
pushl %edx
pushl %ecx
call ipentium
testl %eax,%eax
jz exit3
movl $1,%eax
cpuid
xorl %eax, %eax
testl $0x02000000,%edx
jz exit3
incl %eax
testl $0x04000000,%edx
jz exit3
orl $2, %eax
exit3:
popl %ecx
popl %edx
popl %ebx
ret

View File

@ -25,9 +25,15 @@
#include "huffman.h"
#include "mp3.h"
#include "bswap.h"
#include "d_cpu.h"
#include "../cpudetect.h"
#include "../liba52/mm_accel.h"
#include "fastmemcpy.h"
#ifdef ARCH_X86
#define CAN_COMPILE_X86_ASM
#endif
//static FILE* mp3_file=NULL;
int MP3_frames=0;
@ -354,6 +360,8 @@ retry1:
return frames;
}
int _has_mmx = 0;
#include "layer2.c"
#include "layer3.c"
@ -378,12 +386,19 @@ void MP3_Init(int fakemono){
#else
void MP3_Init(){
#endif
int accel=0;
#if 0
#ifdef RUNTIME_CPUDETECT
#ifdef CAN_COMPILE_X86_ASM
if (gCpuCaps.hasMMX)
GetCpuCaps(&gCpuCaps);
if(gCpuCaps.hasMMX) accel |= MM_ACCEL_X86_MMX;
if(gCpuCaps.hasMMX2) accel |= MM_ACCEL_X86_MMXEXT;
if(gCpuCaps.hasSSE) accel |= MM_ACCEL_X86_SSE;
if(gCpuCaps.has3DNow) accel |= MM_ACCEL_X86_3DNOW;
if(gCpuCaps.has3DNowExt) accel |= MM_ACCEL_X86_3DNOWEXT;
if (accel & MM_ACCEL_X86_MMX)
{
_has_mmx = 1;
make_decode_tables_MMX(outscale);
printf("mp3lib: made decode tables with MMX optimization\n");
}
@ -392,14 +407,6 @@ void MP3_Init(){
#else
make_decode_tables(outscale);
#endif
#else /* RUNTIME_CPUDETECT */
#ifdef HAVE_MMX
make_decode_tables_MMX(outscale);
printf("mp3lib: made decode tables with MMX optimization\n");
#else
make_decode_tables(outscale);
#endif
#endif /* RUNTIME_CPUDTECT */
#ifdef USE_FAKE_MONO
if (fakemono == 1)
@ -421,10 +428,9 @@ void MP3_Init(){
dct36_func = dct36;
printf("init layer2&3 finished, tables done\n");
#ifdef RUNTIME_CPUDETECT
#ifdef CAN_COMPILE_X86_ASM
#if 0
if(gCpuCaps.hasSSE)
if(accel & MM_ACCEL_X86_SSE)
{
/* SSE version is buggy */
synth_func = synth_1to1_MMX;
@ -433,24 +439,24 @@ void MP3_Init(){
}
else
#endif
if (gCpuCaps.has3DNowExt)
if (accel & MM_ACCEL_X86_3DNOWEXT)
{
synth_func = synth_1to1_MMX;
dct36_func = dct36_3dnowex;
dct64_MMX_func = dct64_MMX_3dnowex;
synth_func=synth_1to1_MMX;
dct36_func=dct36_3dnowex;
dct64_MMX_func=dct64_MMX_3dnowex;
printf("mp3lib: using 3DNow!Ex optimized decore!\n");
}
else
if (gCpuCaps.has3DNow)
if (accel & MM_ACCEL_X86_3DNOW)
{
synth_func = synth_1to1_MMX;
dct36_func = dct36_3dnow;
dct64_MMX_func = dct64_MMX_3dnow;
printf("mp3lib: using 3DNow! optimized decore!\n");
}
else
if (gCpuCaps.hasMMX)
{
}
else
if (accel & MM_ACCEL_X86_MMX)
{
synth_func = synth_1to1_MMX;
dct64_MMX_func = dct64_MMX;
printf("mp3lib: using MMX optimized decore!\n");
@ -470,88 +476,7 @@ void MP3_Init(){
synth_func = NULL;
printf("mp3lib: using generic decore!\n");
#endif
#else /* RUNTIME_CPUDETECT */
#if 0
/* SSE version is buggy */
synth_func = synth_1to1_MMX;
dct64_MMX_func = dct64_MMX_sse;
printf("mp3lib: using SSE optimized decore!\n");
#endif
#ifdef HAVE_3DNOWEX
synth_func = synth_1to1_MMX;
dct36_func = dct36_3dnowex;
dct64_MMX_func = dct64_MMX_3dnowex;
printf("mp3lib: using 3DNow!Ex optimized decore!\n");
#elif defined(HAVE_3DNOW)
synth_func = synth_1to1_MMX;
dct36_func = dct36_3dnow;
dct64_MMX_func = dct64_MMX_3dnow;
printf("mp3lib: using 3DNow! optimized decore!\n");
#elif defined(HAVE_MMX)
synth_func = synth_1to1_MMX;
dct64_MMX_func = dct64_MMX;
printf("mp3lib: using MMX optimized decore!\n");
#elif defined(__CPU__ > 586)
synth_func = synth_1to1_pent;
printf("mp3lib: using Pentium optimized decore!\n");
#else
synth_func = NULL; /* use default c version */
printf("mp3lib: using generic decore!\n");
#endif
#endif /* RUNTIME_CPUDETECT */
#else
#ifdef ARCH_X86
_CpuID=CpuDetect();
_i586=ipentium();
#ifndef HAVE_MMX
_i586 &= 1;
#endif
_3dnow=a3dnow();
#ifndef HAVE_3DNOW
_3dnow = 0;
#endif
#ifndef HAVE_3DNOWEX
_3dnow &= 1;
#endif
_isse=isse();
#ifndef HAVE_SSE
_isse = 0;
#endif
#ifndef HAVE_SSE2
_isse &= 1;
#endif
_has_mmx=_i586>1||_3dnow||_isse;
printf( "mp3lib: Processor ID: %x\n",_CpuID );
if(_i586&&!_3dnow&&!_isse)
printf( "mp3lib: Using Pentium%s optimized decore.\n",(_i586>1?"-MMX":""));
else
if(_isse)
/*
Note: It's ok, Since K8 will have SSE2 support and will much faster
of P4 ;)
*/
// printf( "mp3lib: Using SSE%s! optimized decore.\n",(_isse>1?"2":""));
printf( "mp3lib: Using Pentium%s optimized decore.\n",(_i586>1?"-MMX":""));
else
if(_3dnow)
printf( "mp3lib: Using AMD 3dnow%s! optimized decore.\n",(_3dnow>1?"-dsp(k7)":""));
#else
_CpuID = _i586 = _3dnow = _isse = _has_mmx = 0;
printf( "mp3lib: Using generic decore.\n");
#endif
#ifdef HAVE_MMX
/* Use it for any MMX cpu */
if(_has_mmx)
{
make_decode_tables_MMX(outscale);
printf("mp3lib: made decode tables with MMX optimization\n");
}
else
#endif
make_decode_tables(outscale);
#ifdef USE_FAKE_MONO
if (fakemono == 1)
fr.synth=synth_1to1_l;
@ -568,53 +493,6 @@ void MP3_Init(){
init_layer2();
init_layer3(fr.down_sample_sblimit);
tables_done_flag=1;
dct36_func=dct36;
/*#ifdef HAVE_SSE
if(_isse)
{
synth_func=synth_1to1_MMX;
dct64_MMX_func=dct64_MMX_sse;
}
else
#endif*/
#ifdef HAVE_3DNOWEX
if ( _3dnow > 1 )
{
synth_func=synth_1to1_MMX;
dct36_func=dct36_3dnowex;
dct64_MMX_func=dct64_MMX_3dnowex;
}
else
#endif
#ifdef HAVE_3DNOW
if ( _3dnow )
{
synth_func=synth_1to1_MMX;
dct36_func=dct36_3dnow;
dct64_MMX_func=dct64_MMX_3dnow;
}
else
#endif
#ifdef HAVE_MMX
if ( _i586 > 1)
{
synth_func=synth_1to1_MMX;
dct64_MMX_func=dct64_MMX;
}
else
#endif
#ifdef ARCH_X86
if ( _i586 )
{
synth_func=synth_1to1_pent;
}
else
#endif
{
synth_func = NULL;
}
#endif
}
#if 0