From 54cbe5eec30a3ad956fd4cc4c25e81dc64d265b6 Mon Sep 17 00:00:00 2001 From: arpi Date: Mon, 27 Jan 2003 21:47:25 +0000 Subject: The two attached patches *should* allow for proper compilation of the AltiVec stuff on both Darwin and non-Darwin system. They've only been tested for compilation on Debian using Debian's gcc-3.2. Romain Dolbeau git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9123 b3059339-0415-0410-9bf9-f77b7e298cf2 --- Makefile | 4 ++++ cpudetect.c | 2 +- liba52/Makefile | 4 ++++ liba52/imdct.c | 23 +++++++++++++++++++++-- mp3lib/Makefile | 4 ++++ mp3lib/dct64_altivec.c | 22 ++++++++++++++++++++-- 6 files changed, 54 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 8e6860b874..88849a90e3 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,11 @@ COMMON_LIBS = libmpcodecs/libmpcodecs.a mp3lib/libMP3.a liba52/liba52.a libmpeg2 CFLAGS = $(OPTFLAGS) -Ilibmpdemux -Iloader -Ilibvo $(FREETYPE_INC) $(EXTRA_INC) $(CDPARANOIA_INC) $(SDL_INC) # -Wall ifeq ($(TARGET_ALTIVEC),yes) +ifeq ($(TARGET_OS),Darwin) CFLAGS += -faltivec +else +CFLAGS += -maltivec -mabi=altivec +endif endif PARTS = libmpdemux libmpcodecs mp3lib liba52 libmpeg2 libavcodec libao2 drivers linux postproc input libvo libaf diff --git a/cpudetect.c b/cpudetect.c index ba5a0d0adc..acd291265e 100644 --- a/cpudetect.c +++ b/cpudetect.c @@ -492,7 +492,7 @@ void GetCpuCaps( CpuCaps *caps) canjump = 1; asm volatile ("mtspr 256, %0\n\t" - "vand v0, v0, v0" + "vand %%v0, %%v0, %%v0" : : "r" (-1)); diff --git a/liba52/Makefile b/liba52/Makefile index b8c0b71311..d09e2e7378 100644 --- a/liba52/Makefile +++ b/liba52/Makefile @@ -8,7 +8,11 @@ OBJS = $(SRCS:.c=.o) CFLAGS = $(MLIB_INC) $(OPTFLAGS) ifeq ($(TARGET_ALTIVEC),yes) +ifeq ($(TARGET_OS),Darwin) CFLAGS+= -faltivec +else + CFLAGS+= -maltivec -mabi=altivec +endif endif .SUFFIXES: .c .o diff --git a/liba52/imdct.c b/liba52/imdct.c index f287094678..2b3b850269 100644 --- a/liba52/imdct.c +++ b/liba52/imdct.c @@ -387,6 +387,10 @@ imdct_do_512(sample_t data[],sample_t delay[], sample_t bias) #ifdef HAVE_ALTIVEC +#ifndef SYS_DARWIN +#include +#endif + // used to build registers permutation vectors (vcprm) // the 's' are for words in the _s_econd vector #define WORD_0 0x00,0x01,0x02,0x03 @@ -398,7 +402,11 @@ imdct_do_512(sample_t data[],sample_t delay[], sample_t bias) #define WORD_s2 0x18,0x19,0x1a,0x1b #define WORD_s3 0x1c,0x1d,0x1e,0x1f +#ifdef SYS_DARWIN #define vcprm(a,b,c,d) (const vector unsigned char)(WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d) +#else +#define vcprm(a,b,c,d) (const vector unsigned char){WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d} +#endif // vcprmle is used to keep the same index as in the SSE version. // it's the same as vcprm, with the index inversed @@ -410,7 +418,18 @@ imdct_do_512(sample_t data[],sample_t delay[], sample_t bias) #define FLOAT_n -1. #define FLOAT_p 1. +#ifdef SYS_DARWIN #define vcii(a,b,c,d) (const vector float)(FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d) +#else +#define vcii(a,b,c,d) (const vector float){FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d} +#endif + +#ifdef SYS_DARWIN +#define FOUROF(a) (a) +#else +#define FOUROF(a) {a,a,a,a} +#endif + void imdct_do_512_altivec(sample_t data[],sample_t delay[], sample_t bias) @@ -601,7 +620,7 @@ imdct_do_512_altivec(sample_t data[],sample_t delay[], sample_t bias) int p = k + i; int q = p + two_m; vector float vecp, vecq, vecw, temp1, temp2, temp3, temp4; - const vector float vczero = (const vector float)(0); + const vector float vczero = (const vector float)FOUROF(0.); // first compute buf[q] and buf[q+1] vecq = vec_ld(q << 3, (float*)buf); vecw = vec_ld(0, (float*)&(w[m][k])); @@ -658,7 +677,7 @@ imdct_do_512_altivec(sample_t data[],sample_t delay[], sample_t bias) #else vector float bufv_0, bufv_2, cosv, sinv, temp1, temp2; vector float temp0022, temp1133, tempCS01; - const vector float vczero = (const vector float)(0); + const vector float vczero = (const vector float)FOUROF(0.); bufv_0 = vec_ld((i + 0) << 3, (float*)buf); bufv_2 = vec_ld((i + 2) << 3, (float*)buf); diff --git a/mp3lib/Makefile b/mp3lib/Makefile index 592691a32f..389da3af3e 100644 --- a/mp3lib/Makefile +++ b/mp3lib/Makefile @@ -26,7 +26,11 @@ ifeq ($(TARGET_ARCH_POWERPC),yes) ifeq ($(TARGET_ALTIVEC),yes) SRCS += dct64_altivec.c OBJS += dct64_altivec.o +ifeq ($(TARGET_OS),Darwin) CFLAGS += -faltivec +else +CFLAGS += -maltivec -mabi=altivec +endif endif endif diff --git a/mp3lib/dct64_altivec.c b/mp3lib/dct64_altivec.c index fa252da20c..62299e274a 100644 --- a/mp3lib/dct64_altivec.c +++ b/mp3lib/dct64_altivec.c @@ -13,6 +13,10 @@ #ifdef HAVE_ALTIVEC +#ifndef SYS_DARWIN +#include +#endif + // used to build registers permutation vectors (vcprm) // the 's' are for words in the _s_econd vector #define WORD_0 0x00,0x01,0x02,0x03 @@ -24,7 +28,11 @@ #define WORD_s2 0x18,0x19,0x1a,0x1b #define WORD_s3 0x1c,0x1d,0x1e,0x1f +#ifdef SYS_DARWIN #define vcprm(a,b,c,d) (const vector unsigned char)(WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d) +#else +#define vcprm(a,b,c,d) (const vector unsigned char){WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d} +#endif // vcprmle is used to keep the same index as in the SSE version. // it's the same as vcprm, with the index inversed @@ -36,7 +44,17 @@ #define FLOAT_n -1. #define FLOAT_p 1. +#ifdef SYS_DARWIN #define vcii(a,b,c,d) (const vector float)(FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d) +#else +#define vcii(a,b,c,d) (const vector float){FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d} +#endif + +#ifdef SYS_DARWIN +#define FOUROF(a) (a) +#else +#define FOUROF(a) {a,a,a,a} +#endif void dct64_altivec(real *a,real *b,real *c) { @@ -47,7 +65,7 @@ void dct64_altivec(real *a,real *b,real *c) real *out1 = b; real *samples = c; - const vector float vczero = (const vector float)(0.); + const vector float vczero = (const vector float)FOUROF(0.); const vector unsigned char reverse = (const vector unsigned char)vcprm(3,2,1,0); @@ -521,5 +539,5 @@ void dct64_altivec(real *a,real *b,real *c) out1[0x10*15] = b1[0x1F]; } -#endif HAVE_ALTIVEC +#endif /* HAVE_ALTIVEC */ -- cgit v1.2.3