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);
......
...@@ -21,22 +21,39 @@ ...@@ -21,22 +21,39 @@
#include "../dsputil.h" #include "../dsputil.h"
#include "dsputil_altivec.h" #include "dsputil_altivec.h"
#if CONFIG_DARWIN #ifdef CONFIG_DARWIN
#include <sys/sysctl.h> #include <sys/sysctl.h>
#endif #else /* CONFIG_DARWIN */
#include <signal.h>
#include <setjmp.h>
static sigjmp_buf jmpbuf;
static volatile sig_atomic_t canjump = 0;
static void sigill_handler (int sig)
{
if (!canjump) {
signal (sig, SIG_DFL);
raise (sig);
}
canjump = 0;
siglongjmp (jmpbuf, 1);
}
#endif /* CONFIG_DARWIN */
int pix_abs16x16_x2_altivec(uint8_t *pix1, uint8_t *pix2, int line_size) int pix_abs16x16_x2_altivec(uint8_t *pix1, uint8_t *pix2, int line_size)
{ {
int i; int i;
int s __attribute__((aligned(16))); int s __attribute__((aligned(16)));
const vector unsigned char zero = (const vector unsigned char)(0); const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0);
vector unsigned char *tv; vector unsigned char *tv;
vector unsigned char pix1v, pix2v, pix2iv, avgv, t5; vector unsigned char pix1v, pix2v, pix2iv, avgv, t5;
vector unsigned int sad; vector unsigned int sad;
vector signed int sumdiffs; vector signed int sumdiffs;
s = 0; s = 0;
sad = (vector unsigned int)(0); sad = (vector unsigned int)vec_splat_u32(0);
for(i=0;i<16;i++) { for(i=0;i<16;i++) {
/* /*
Read unaligned pixels into our vectors. The vectors are as follows: Read unaligned pixels into our vectors. The vectors are as follows:
...@@ -76,7 +93,7 @@ int pix_abs16x16_y2_altivec(uint8_t *pix1, uint8_t *pix2, int line_size) ...@@ -76,7 +93,7 @@ int pix_abs16x16_y2_altivec(uint8_t *pix1, uint8_t *pix2, int line_size)
{ {
int i; int i;
int s __attribute__((aligned(16))); int s __attribute__((aligned(16)));
const vector unsigned char zero = (const vector unsigned char)(0); const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0);
vector unsigned char *tv; vector unsigned char *tv;
vector unsigned char pix1v, pix2v, pix3v, avgv, t5; vector unsigned char pix1v, pix2v, pix3v, avgv, t5;
vector unsigned int sad; vector unsigned int sad;
...@@ -84,7 +101,7 @@ int pix_abs16x16_y2_altivec(uint8_t *pix1, uint8_t *pix2, int line_size) ...@@ -84,7 +101,7 @@ int pix_abs16x16_y2_altivec(uint8_t *pix1, uint8_t *pix2, int line_size)
uint8_t *pix3 = pix2 + line_size; uint8_t *pix3 = pix2 + line_size;
s = 0; s = 0;
sad = (vector unsigned int)(0); sad = (vector unsigned int)vec_splat_u32(0);
/* /*
Due to the fact that pix3 = pix2 + line_size, the pix3 of one Due to the fact that pix3 = pix2 + line_size, the pix3 of one
...@@ -137,8 +154,8 @@ int pix_abs16x16_xy2_altivec(uint8_t *pix1, uint8_t *pix2, int line_size) ...@@ -137,8 +154,8 @@ int pix_abs16x16_xy2_altivec(uint8_t *pix1, uint8_t *pix2, int line_size)
int i; int i;
int s __attribute__((aligned(16))); int s __attribute__((aligned(16)));
uint8_t *pix3 = pix2 + line_size; uint8_t *pix3 = pix2 + line_size;
const vector unsigned char zero = (const vector unsigned char)(0); const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0);
const vector unsigned short two = (const vector unsigned short)(2); const vector unsigned short two = (const vector unsigned short)vec_splat_u16(2);
vector unsigned char *tv, avgv, t5; vector unsigned char *tv, avgv, t5;
vector unsigned char pix1v, pix2v, pix3v, pix2iv, pix3iv; vector unsigned char pix1v, pix2v, pix3v, pix2iv, pix3iv;
vector unsigned short pix2lv, pix2hv, pix2ilv, pix2ihv; vector unsigned short pix2lv, pix2hv, pix2ilv, pix2ihv;
...@@ -148,7 +165,7 @@ int pix_abs16x16_xy2_altivec(uint8_t *pix1, uint8_t *pix2, int line_size) ...@@ -148,7 +165,7 @@ int pix_abs16x16_xy2_altivec(uint8_t *pix1, uint8_t *pix2, int line_size)
vector unsigned int sad; vector unsigned int sad;
vector signed int sumdiffs; vector signed int sumdiffs;
sad = (vector unsigned int)(0); sad = (vector unsigned int)vec_splat_u32(0);
s = 0; s = 0;
...@@ -237,13 +254,13 @@ int pix_abs16x16_altivec(uint8_t *pix1, uint8_t *pix2, int line_size) ...@@ -237,13 +254,13 @@ int pix_abs16x16_altivec(uint8_t *pix1, uint8_t *pix2, int line_size)
{ {
int i; int i;
int s __attribute__((aligned(16))); int s __attribute__((aligned(16)));
const vector unsigned int zero = (const vector unsigned int)(0); const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
vector unsigned char perm1, perm2, *pix1v, *pix2v; vector unsigned char perm1, perm2, *pix1v, *pix2v;
vector unsigned char t1, t2, t3,t4, t5; vector unsigned char t1, t2, t3,t4, t5;
vector unsigned int sad; vector unsigned int sad;
vector signed int sumdiffs; vector signed int sumdiffs;
sad = (vector unsigned int) (0); sad = (vector unsigned int)vec_splat_u32(0);
for(i=0;i<16;i++) { for(i=0;i<16;i++) {
...@@ -279,14 +296,18 @@ int pix_abs8x8_altivec(uint8_t *pix1, uint8_t *pix2, int line_size) ...@@ -279,14 +296,18 @@ int pix_abs8x8_altivec(uint8_t *pix1, uint8_t *pix2, int line_size)
{ {
int i; int i;
int s __attribute__((aligned(16))); int s __attribute__((aligned(16)));
const vector unsigned int zero = (const vector unsigned int)(0); const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
vector unsigned char perm1, perm2, permclear, *pix1v, *pix2v; vector unsigned char perm1, perm2, permclear, *pix1v, *pix2v;
vector unsigned char t1, t2, t3,t4, t5; vector unsigned char t1, t2, t3,t4, t5;
vector unsigned int sad; vector unsigned int sad;
vector signed int sumdiffs; vector signed int sumdiffs;
sad = (vector unsigned int)(0); sad = (vector unsigned int)vec_splat_u32(0);
permclear = (vector unsigned char) (255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0); #ifdef CONFIG_DARWIN
permclear = (vector unsigned char)(255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0);
#else
permclear = (vector unsigned char){255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0};
#endif
for(i=0;i<8;i++) { for(i=0;i<8;i++) {
/* Read potentially unaligned pixels into t1 and t2 /* Read potentially unaligned pixels into t1 and t2
...@@ -323,13 +344,13 @@ int pix_norm1_altivec(uint8_t *pix, int line_size) ...@@ -323,13 +344,13 @@ int pix_norm1_altivec(uint8_t *pix, int line_size)
{ {
int i; int i;
int s __attribute__((aligned(16))); int s __attribute__((aligned(16)));
const vector unsigned int zero = (const vector unsigned int)(0); const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
vector unsigned char *tv; vector unsigned char *tv;
vector unsigned char pixv; vector unsigned char pixv;
vector unsigned int sv; vector unsigned int sv;
vector signed int sum; vector signed int sum;
sv = (vector unsigned int)(0); sv = (vector unsigned int)vec_splat_u32(0);
s = 0; s = 0;
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
...@@ -359,14 +380,18 @@ int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size) ...@@ -359,14 +380,18 @@ int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size)
{ {
int i; int i;
int s __attribute__((aligned(16))); int s __attribute__((aligned(16)));
const vector unsigned int zero = (const vector unsigned int)(0); const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
vector unsigned char perm1, perm2, permclear, *pix1v, *pix2v; vector unsigned char perm1, perm2, permclear, *pix1v, *pix2v;
vector unsigned char t1, t2, t3,t4, t5; vector unsigned char t1, t2, t3,t4, t5;
vector unsigned int sum; vector unsigned int sum;
vector signed int sumsqr; vector signed int sumsqr;
sum = (vector unsigned int)(0); sum = (vector unsigned int)vec_splat_u32(0);
permclear = (vector unsigned char)(0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00); #ifdef CONFIG_DARWIN
permclear = (vector unsigned char)(255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0);
#else
permclear = (vector unsigned char){255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0};
#endif
for(i=0;i<8;i++) { for(i=0;i<8;i++) {
/* Read potentially unaligned pixels into t1 and t2 /* Read potentially unaligned pixels into t1 and t2
...@@ -413,13 +438,13 @@ int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size) ...@@ -413,13 +438,13 @@ int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size)
{ {
int i; int i;
int s __attribute__((aligned(16))); int s __attribute__((aligned(16)));
const vector unsigned int zero = (const vector unsigned int)(0); const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
vector unsigned char perm1, perm2, *pix1v, *pix2v; vector unsigned char perm1, perm2, *pix1v, *pix2v;
vector unsigned char t1, t2, t3,t4, t5; vector unsigned char t1, t2, t3,t4, t5;
vector unsigned int sum; vector unsigned int sum;
vector signed int sumsqr; vector signed int sumsqr;
sum = (vector unsigned int)(0); sum = (vector unsigned int)vec_splat_u32(0);
for(i=0;i<16;i++) { for(i=0;i<16;i++) {
/* Read potentially unaligned pixels into t1 and t2 */ /* Read potentially unaligned pixels into t1 and t2 */
...@@ -457,7 +482,7 @@ int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size) ...@@ -457,7 +482,7 @@ int sse16_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size)
int pix_sum_altivec(UINT8 * pix, int line_size) int pix_sum_altivec(UINT8 * pix, int line_size)
{ {
const vector unsigned int zero = (const vector unsigned int)(0); const vector unsigned int zero = (const vector unsigned int)vec_splat_u32(0);
vector unsigned char perm, *pixv; vector unsigned char perm, *pixv;
vector unsigned char t1; vector unsigned char t1;
vector unsigned int sad; vector unsigned int sad;
...@@ -466,7 +491,7 @@ int pix_sum_altivec(UINT8 * pix, int line_size) ...@@ -466,7 +491,7 @@ int pix_sum_altivec(UINT8 * pix, int line_size)
int i; int i;
int s __attribute__((aligned(16))); int s __attribute__((aligned(16)));
sad = (vector unsigned int) (0); sad = (vector unsigned int)vec_splat_u32(0);
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
/* Read the potentially unaligned 16 pixels into t1 */ /* Read the potentially unaligned 16 pixels into t1 */
...@@ -492,7 +517,7 @@ void get_pixels_altivec(DCTELEM *restrict block, const UINT8 *pixels, int line_s ...@@ -492,7 +517,7 @@ void get_pixels_altivec(DCTELEM *restrict block, const UINT8 *pixels, int line_s
{ {
int i; int i;
vector unsigned char perm, bytes, *pixv; vector unsigned char perm, bytes, *pixv;
const vector unsigned char zero = (const vector unsigned char) (0); const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0);
vector signed short shorts; vector signed short shorts;
for(i=0;i<8;i++) for(i=0;i<8;i++)
...@@ -519,7 +544,7 @@ void diff_pixels_altivec(DCTELEM *restrict block, const UINT8 *s1, ...@@ -519,7 +544,7 @@ void diff_pixels_altivec(DCTELEM *restrict block, const UINT8 *s1,
{ {
int i; int i;
vector unsigned char perm, bytes, *pixv; vector unsigned char perm, bytes, *pixv;
const vector unsigned char zero = (const vector unsigned char) (0); const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0);
vector signed short shorts1, shorts2; vector signed short shorts1, shorts2;
for(i=0;i<4;i++) for(i=0;i<4;i++)
...@@ -830,8 +855,8 @@ POWERPC_TBL_STOP_COUNT(altivec_put_pixels8_xy2_num, 1); ...@@ -830,8 +855,8 @@ POWERPC_TBL_STOP_COUNT(altivec_put_pixels8_xy2_num, 1);
blockv, temp1, temp2; blockv, temp1, temp2;
register vector unsigned short register vector unsigned short
pixelssum1, pixelssum2, temp3; pixelssum1, pixelssum2, temp3;
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 vctwo = (const vector unsigned short)(2); register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2);
temp1 = vec_ld(0, pixels); temp1 = vec_ld(0, pixels);
temp2 = vec_ld(16, pixels); temp2 = vec_ld(16, pixels);
...@@ -945,9 +970,9 @@ POWERPC_TBL_STOP_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1); ...@@ -945,9 +970,9 @@ POWERPC_TBL_STOP_COUNT(altivec_put_no_rnd_pixels8_xy2_num, 1);
blockv, temp1, temp2; blockv, temp1, temp2;
register vector unsigned short register vector unsigned short
pixelssum1, pixelssum2, temp3; pixelssum1, pixelssum2, temp3;
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 vcone = (const vector unsigned short)(1); register const vector unsigned short vcone = (const vector unsigned short)vec_splat_u16(1);
register const vector unsigned short vctwo = (const vector unsigned short)(2); register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2);
temp1 = vec_ld(0, pixels); temp1 = vec_ld(0, pixels);
temp2 = vec_ld(16, pixels); temp2 = vec_ld(16, pixels);
...@@ -1061,8 +1086,8 @@ POWERPC_TBL_STOP_COUNT(altivec_put_pixels16_xy2_num, 1); ...@@ -1061,8 +1086,8 @@ POWERPC_TBL_STOP_COUNT(altivec_put_pixels16_xy2_num, 1);
register vector unsigned short register vector unsigned short
pixelssum1, pixelssum2, temp3, pixelssum1, pixelssum2, temp3,
pixelssum3, pixelssum4, temp4; pixelssum3, pixelssum4, temp4;
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 vctwo = (const vector unsigned short)(2); register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2);
temp1 = vec_ld(0, pixels); temp1 = vec_ld(0, pixels);
temp2 = vec_ld(16, pixels); temp2 = vec_ld(16, pixels);
...@@ -1181,9 +1206,9 @@ POWERPC_TBL_STOP_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1); ...@@ -1181,9 +1206,9 @@ POWERPC_TBL_STOP_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
register vector unsigned short register vector unsigned short
pixelssum1, pixelssum2, temp3, pixelssum1, pixelssum2, temp3,
pixelssum3, pixelssum4, temp4; pixelssum3, pixelssum4, temp4;
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 vcone = (const vector unsigned short)(1); register const vector unsigned short vcone = (const vector unsigned short)vec_splat_u16(1);
register const vector unsigned short vctwo = (const vector unsigned short)(2); register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2);
temp1 = vec_ld(0, pixels); temp1 = vec_ld(0, pixels);
temp2 = vec_ld(16, pixels); temp2 = vec_ld(16, pixels);
...@@ -1254,7 +1279,7 @@ POWERPC_TBL_STOP_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1); ...@@ -1254,7 +1279,7 @@ POWERPC_TBL_STOP_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
int has_altivec(void) int has_altivec(void)
{ {
#if CONFIG_DARWIN #ifdef CONFIG_DARWIN
int sels[2] = {CTL_HW, HW_VECTORUNIT}; int sels[2] = {CTL_HW, HW_VECTORUNIT};
int has_vu = 0; int has_vu = 0;
size_t len = sizeof(has_vu); size_t len = sizeof(has_vu);
...@@ -1263,6 +1288,25 @@ int has_altivec(void) ...@@ -1263,6 +1288,25 @@ int has_altivec(void)
err = sysctl(sels, 2, &has_vu, &len, NULL, 0); err = sysctl(sels, 2, &has_vu, &len, NULL, 0);
if (err == 0) return (has_vu != 0); if (err == 0) return (has_vu != 0);
#endif #else /* CONFIG_DARWIN */
/* no Darwin, do it the brute-force way */
/* this is borrowed from the libmpeg2 library */
{
signal (SIGILL, sigill_handler);
if (sigsetjmp (jmpbuf, 1)) {
signal (SIGILL, SIG_DFL);
} else {
canjump = 1;
asm volatile ("mtspr 256, %0\n\t"
"vand %%v0, %%v0, %%v0"
:
: "r" (-1));
signal (SIGILL, SIG_DFL);
return 1;
}
}
#endif /* CONFIG_DARWIN */
return 0; return 0;
} }
...@@ -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