Commit 3b991c54 authored by Romain Dolbeau's avatar Romain Dolbeau Committed by Fabrice Bellard

Altivec on non darwin systems patch by Romain Dolbeau

Originally committed as revision 1509 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent a48835b9
...@@ -86,7 +86,11 @@ OBJS += ps2/dsputil_mmi.o ps2/idct_mmi.o ps2/mpegvideo_mmi.o ...@@ -86,7 +86,11 @@ OBJS += ps2/dsputil_mmi.o ps2/idct_mmi.o ps2/mpegvideo_mmi.o
endif endif
ifeq ($(TARGET_ALTIVEC),yes) ifeq ($(TARGET_ALTIVEC),yes)
ifeq ($(TARGET_OS),Darwin)
CFLAGS += -faltivec CFLAGS += -faltivec
else
CFLAGS += -maltivec -mabi=altivec
endif
OBJS += ppc/dsputil_altivec.o ppc/mpegvideo_altivec.o ppc/idct_altivec.o \ OBJS += ppc/dsputil_altivec.o ppc/mpegvideo_altivec.o ppc/idct_altivec.o \
ppc/fft_altivec.o ppc/gmc_altivec.o ppc/fft_altivec.o ppc/gmc_altivec.o
endif endif
......
...@@ -224,6 +224,10 @@ void dsputil_init_alpha(DSPContext* c, unsigned mask); ...@@ -224,6 +224,10 @@ void dsputil_init_alpha(DSPContext* c, unsigned mask);
extern int mm_flags; extern int mm_flags;
#if defined(HAVE_ALTIVEC) && !defined(CONFIG_DARWIN)
#include <altivec.h>
#endif
#define __align8 __attribute__ ((aligned (16))) #define __align8 __attribute__ ((aligned (16)))
void dsputil_init_ppc(DSPContext* c, unsigned mask); void dsputil_init_ppc(DSPContext* c, unsigned mask);
......
This diff is collapsed.
...@@ -63,7 +63,11 @@ extern int has_altivec(void); ...@@ -63,7 +63,11 @@ extern int has_altivec(void);
#define WORD_s2 0x18,0x19,0x1a,0x1b #define WORD_s2 0x18,0x19,0x1a,0x1b
#define WORD_s3 0x1c,0x1d,0x1e,0x1f #define WORD_s3 0x1c,0x1d,0x1e,0x1f
#ifdef CONFIG_DARWIN
#define vcprm(a,b,c,d) (const vector unsigned char)(WORD_ ## a, WORD_ ## b, WORD_ ## c, WORD_ ## d) #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. // vcprmle is used to keep the same index as in the SSE version.
// it's the same as vcprm, with the index inversed // it's the same as vcprm, with the index inversed
...@@ -75,7 +79,12 @@ extern int has_altivec(void); ...@@ -75,7 +79,12 @@ extern int has_altivec(void);
#define FLOAT_n -1. #define FLOAT_n -1.
#define FLOAT_p 1. #define FLOAT_p 1.
#ifdef CONFIG_DARWIN
#define vcii(a,b,c,d) (const vector float)(FLOAT_ ## a, FLOAT_ ## b, FLOAT_ ## c, FLOAT_ ## d) #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
#else /* HAVE_ALTIVEC */ #else /* HAVE_ALTIVEC */
#ifdef ALTIVEC_USE_REFERENCE_C_CODE #ifdef ALTIVEC_USE_REFERENCE_C_CODE
......
...@@ -120,7 +120,6 @@ POWERPC_TBL_START_COUNT(powerpc_clear_blocks_dcbz32, 1); ...@@ -120,7 +120,6 @@ POWERPC_TBL_START_COUNT(powerpc_clear_blocks_dcbz32, 1);
((unsigned long*)blocks)[1] = 0L; ((unsigned long*)blocks)[1] = 0L;
((unsigned long*)blocks)[2] = 0L; ((unsigned long*)blocks)[2] = 0L;
((unsigned long*)blocks)[3] = 0L; ((unsigned long*)blocks)[3] = 0L;
vec_st((vector short)(0), 0, blocks);
i += 16; i += 16;
} }
for ( ; i < sizeof(DCTELEM)*6*64 ; i += 32) { for ( ; i < sizeof(DCTELEM)*6*64 ; i += 32) {
...@@ -142,18 +141,17 @@ POWERPC_TBL_STOP_COUNT(powerpc_clear_blocks_dcbz32, 1); ...@@ -142,18 +141,17 @@ POWERPC_TBL_STOP_COUNT(powerpc_clear_blocks_dcbz32, 1);
/* check dcbz report how many bytes are set to 0 by dcbz */ /* check dcbz report how many bytes are set to 0 by dcbz */
long check_dcbz_effect(void) long check_dcbz_effect(void)
{ {
register char *fakedata = (char*)malloc(1024); register char *fakedata = (char*)av_malloc(1024);
register char *fakedata_middle; register char *fakedata_middle;
register long zero = 0; register long zero = 0;
register long i = 0; register long i = 0;
long count = 0; long count = 0;
if (fakedata == NULL) if (!fakedata)
{ {
return 0L; return 0L;
} }
fakedata_middle = (fakedata + 512); fakedata_middle = (fakedata + 512);
memset(fakedata, 0xFF, 1024); memset(fakedata, 0xFF, 1024);
...@@ -166,7 +164,7 @@ long check_dcbz_effect(void) ...@@ -166,7 +164,7 @@ long check_dcbz_effect(void)
count++; count++;
} }
free(fakedata); av_free(fakedata);
return count; return count;
} }
......
...@@ -138,7 +138,11 @@ POWERPC_TBL_START_COUNT(altivec_fft_num, s->nbits >= 6); ...@@ -138,7 +138,11 @@ POWERPC_TBL_START_COUNT(altivec_fft_num, s->nbits >= 6);
POWERPC_TBL_STOP_COUNT(altivec_fft_num, s->nbits >= 6); POWERPC_TBL_STOP_COUNT(altivec_fft_num, s->nbits >= 6);
#else /* ALTIVEC_USE_REFERENCE_C_CODE */ #else /* ALTIVEC_USE_REFERENCE_C_CODE */
#ifdef CONFIG_DARWIN
register const vector float vczero = (const vector float)(0.); register const vector float vczero = (const vector float)(0.);
#else
register const vector float vczero = (const vector float){0.,0.,0.,0.};
#endif
int ln = s->nbits; int ln = s->nbits;
int j, np, np2; int j, np, np2;
......
...@@ -66,8 +66,8 @@ POWERPC_TBL_STOP_COUNT(altivec_gmc1_num, h == 8); ...@@ -66,8 +66,8 @@ POWERPC_TBL_STOP_COUNT(altivec_gmc1_num, h == 8);
( x16)*( y16), /* D */ ( x16)*( y16), /* D */
0, 0, 0, 0 /* padding */ 0, 0, 0, 0 /* padding */
}; };
register const vector unsigned char vczero = (const vector unsigned char)(0); register const vector unsigned char vczero = (const vector unsigned char)vec_splat_u8(0);
register const vector unsigned short vcsr8 = (const vector unsigned short)(8); register const vector unsigned short vcsr8 = (const vector unsigned short)vec_splat_u16(8);
register vector unsigned char dstv, dstv2, src_0, src_1, srcvA, srcvB, srcvC, srcvD; register vector unsigned char dstv, dstv2, src_0, src_1, srcvA, srcvB, srcvC, srcvD;
register vector unsigned short Av, Bv, Cv, Dv, rounderV, tempA, tempB, tempC, tempD; register vector unsigned short Av, Bv, Cv, Dv, rounderV, tempA, tempB, tempC, tempD;
int i; int i;
......
...@@ -151,6 +151,8 @@ ...@@ -151,6 +151,8 @@
vx6 = vec_sra (vy6, shift); \ vx6 = vec_sra (vy6, shift); \
vx7 = vec_sra (vy7, shift); vx7 = vec_sra (vy7, shift);
#ifdef CONFIG_DARWIN
static const vector_s16_t constants[5] = { static const vector_s16_t constants[5] = {
(vector_s16_t)(23170, 13573, 6518, 21895, -23170, -21895, 32, 31), (vector_s16_t)(23170, 13573, 6518, 21895, -23170, -21895, 32, 31),
(vector_s16_t)(16384, 22725, 21407, 19266, 16384, 19266, 21407, 22725), (vector_s16_t)(16384, 22725, 21407, 19266, 16384, 19266, 21407, 22725),
...@@ -158,6 +160,16 @@ static const vector_s16_t constants[5] = { ...@@ -158,6 +160,16 @@ static const vector_s16_t constants[5] = {
(vector_s16_t)(21407, 29692, 27969, 25172, 21407, 25172, 27969, 29692), (vector_s16_t)(21407, 29692, 27969, 25172, 21407, 25172, 27969, 29692),
(vector_s16_t)(19266, 26722, 25172, 22654, 19266, 22654, 25172, 26722) (vector_s16_t)(19266, 26722, 25172, 22654, 19266, 22654, 25172, 26722)
}; };
#else
// broken gcc
static const vector_s16_t constants[5] = {
(vector_s16_t){23170, 13573, 6518, 21895, -23170, -21895, 32, 31},
(vector_s16_t){16384, 22725, 21407, 19266, 16384, 19266, 21407, 22725},
(vector_s16_t){22725, 31521, 29692, 26722, 22725, 26722, 29692, 31521},
(vector_s16_t){21407, 29692, 27969, 25172, 21407, 25172, 27969, 29692},
(vector_s16_t){19266, 26722, 25172, 22654, 19266, 22654, 25172, 26722}
};
#endif
void idct_put_altivec(uint8_t* dest, int stride, vector_s16_t* block) void idct_put_altivec(uint8_t* dest, int stride, vector_s16_t* block)
{ {
......
...@@ -90,6 +90,13 @@ do { \ ...@@ -90,6 +90,13 @@ do { \
vec = vec_splat(vec, 0); \ vec = vec_splat(vec, 0); \
} }
#ifdef CONFIG_DARWIN
#define FOUROF(a) (a)
#else
// slower, for dumb non-apple GCC
#define FOUROF(a) {a,a,a,a}
#endif
int dct_quantize_altivec(MpegEncContext* s, int dct_quantize_altivec(MpegEncContext* s,
DCTELEM* data, int n, DCTELEM* data, int n,
int qscale, int* overflow) int qscale, int* overflow)
...@@ -97,7 +104,7 @@ int dct_quantize_altivec(MpegEncContext* s, ...@@ -97,7 +104,7 @@ int dct_quantize_altivec(MpegEncContext* s,
int lastNonZero; int lastNonZero;
vector float row0, row1, row2, row3, row4, row5, row6, row7; vector float row0, row1, row2, row3, row4, row5, row6, row7;
vector float alt0, alt1, alt2, alt3, alt4, alt5, alt6, alt7; vector float alt0, alt1, alt2, alt3, alt4, alt5, alt6, alt7;
const vector float zero = (const vector float)(0.0f); const vector float zero = (const vector float)FOUROF(0.);
// Load the data into the row/alt vectors // Load the data into the row/alt vectors
{ {
...@@ -141,18 +148,18 @@ int dct_quantize_altivec(MpegEncContext* s, ...@@ -141,18 +148,18 @@ int dct_quantize_altivec(MpegEncContext* s,
// in the vector local variables, as floats, which we'll use during the // in the vector local variables, as floats, which we'll use during the
// quantize step... // quantize step...
{ {
const vector float vec_0_298631336 = (vector float)(0.298631336f); const vector float vec_0_298631336 = (vector float)FOUROF(0.298631336f);
const vector float vec_0_390180644 = (vector float)(-0.390180644f); const vector float vec_0_390180644 = (vector float)FOUROF(-0.390180644f);
const vector float vec_0_541196100 = (vector float)(0.541196100f); const vector float vec_0_541196100 = (vector float)FOUROF(0.541196100f);
const vector float vec_0_765366865 = (vector float)(0.765366865f); const vector float vec_0_765366865 = (vector float)FOUROF(0.765366865f);
const vector float vec_0_899976223 = (vector float)(-0.899976223f); const vector float vec_0_899976223 = (vector float)FOUROF(-0.899976223f);
const vector float vec_1_175875602 = (vector float)(1.175875602f); const vector float vec_1_175875602 = (vector float)FOUROF(1.175875602f);
const vector float vec_1_501321110 = (vector float)(1.501321110f); const vector float vec_1_501321110 = (vector float)FOUROF(1.501321110f);
const vector float vec_1_847759065 = (vector float)(-1.847759065f); const vector float vec_1_847759065 = (vector float)FOUROF(-1.847759065f);
const vector float vec_1_961570560 = (vector float)(-1.961570560f); const vector float vec_1_961570560 = (vector float)FOUROF(-1.961570560f);
const vector float vec_2_053119869 = (vector float)(2.053119869f); const vector float vec_2_053119869 = (vector float)FOUROF(2.053119869f);
const vector float vec_2_562915447 = (vector float)(-2.562915447f); const vector float vec_2_562915447 = (vector float)FOUROF(-2.562915447f);
const vector float vec_3_072711026 = (vector float)(3.072711026f); const vector float vec_3_072711026 = (vector float)FOUROF(3.072711026f);
int whichPass, whichHalf; int whichPass, whichHalf;
...@@ -306,7 +313,7 @@ int dct_quantize_altivec(MpegEncContext* s, ...@@ -306,7 +313,7 @@ int dct_quantize_altivec(MpegEncContext* s,
// rounding when we convert to int, instead of flooring.) // rounding when we convert to int, instead of flooring.)
{ {
vector signed int biasInt; vector signed int biasInt;
const vector float negOneFloat = (vector float)(-1.0f); const vector float negOneFloat = (vector float)FOUROF(-1.0f);
LOAD4(biasInt, biasAddr); LOAD4(biasInt, biasAddr);
bias = vec_ctf(biasInt, QUANT_BIAS_SHIFT); bias = vec_ctf(biasInt, QUANT_BIAS_SHIFT);
negBias = vec_madd(bias, negOneFloat, zero); negBias = vec_madd(bias, negOneFloat, zero);
...@@ -503,6 +510,7 @@ int dct_quantize_altivec(MpegEncContext* s, ...@@ -503,6 +510,7 @@ int dct_quantize_altivec(MpegEncContext* s,
return lastNonZero; return lastNonZero;
} }
#undef FOUROF
/* /*
AltiVec version of dct_unquantize_h263 AltiVec version of dct_unquantize_h263
...@@ -551,7 +559,7 @@ POWERPC_TBL_START_COUNT(altivec_dct_unquantize_h263_num, 1); ...@@ -551,7 +559,7 @@ POWERPC_TBL_START_COUNT(altivec_dct_unquantize_h263_num, 1);
} }
#else /* ALTIVEC_USE_REFERENCE_C_CODE */ #else /* ALTIVEC_USE_REFERENCE_C_CODE */
{ {
register const vector short vczero = (const vector short)(0); register const vector short vczero = (const vector short)vec_splat_s16(0);
short __attribute__ ((aligned(16))) qmul8[] = short __attribute__ ((aligned(16))) qmul8[] =
{ {
qmul, qmul, qmul, qmul, qmul, qmul, qmul, qmul,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment