From 5817595983c62f616fb31a6d3f297d47a9b20519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sat, 17 Jun 2006 12:45:51 +0000 Subject: Fix Altivec libmpeg2 decoding, thanks to Luca Barbato (lu_zero@gentoo.org) and Christer Palm (palm@nogui.se). CVS patchset: 8045 CVS date: 2006/06/17 12:45:51 --- src/libmpeg2/idct_altivec.c | 502 ++---------------------------------------- src/libmpeg2/mpeg2_internal.h | 9 +- src/libmpeg2/slice.c | 10 +- src/libmpeg2/slice_xvmc.c | 12 +- 4 files changed, 28 insertions(+), 505 deletions(-) (limited to 'src') diff --git a/src/libmpeg2/idct_altivec.c b/src/libmpeg2/idct_altivec.c index 2ebdd3241..ed8b58cfd 100644 --- a/src/libmpeg2/idct_altivec.c +++ b/src/libmpeg2/idct_altivec.c @@ -25,493 +25,13 @@ #if defined (ARCH_PPC) && defined (ENABLE_ALTIVEC) +#include + #include #include "mpeg2_internal.h" #include "xineutils.h" -#ifndef HOST_OS_DARWIN - -/* - * The asm code is generated with: - * - * gcc-2.95 -fvec -D__ALTIVEC__ -O9 -fomit-frame-pointer -mregnames -S - * idct_altivec.c - * - * awk '{args=""; len=split ($2, arg, ","); - * for (i=1; i<=len; i++) { a=arg[i]; if (i> 3) | ((j & 7) << 3); - j = mpeg2_scan_alt[i]; - mpeg2_scan_alt[i] = (j >> 3) | ((j & 7) << 3); - } -} - -#else /* HOST_OS_DARWIN */ - #define vector_s16_t vector signed short #define vector_u16_t vector unsigned short #define vector_s8_t vector signed char @@ -622,12 +142,18 @@ void mpeg2_idct_altivec_init (void) vx6 = vec_sra (vy6, shift); \ vx7 = vec_sra (vy7, shift); +#if defined( __APPLE_CC__ ) && defined( __APPLE_ALTIVEC__ ) /* apple */ +#define VEC_S16(a,b,c,d,e,f,g,h) (vector_s16_t) (a, b, c, d, e, f, g, h) +#else /* gnu */ +#define VEC_S16(a,b,c,d,e,f,g,h) (vector_s16_t) {a, b, c, d, e, f, g, h} +#endif + static 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) + VEC_S16(23170, 13573, 6518, 21895, -23170, -21895, 32, 31), + VEC_S16(16384, 22725, 21407, 19266, 16384, 19266, 21407, 22725), + VEC_S16(22725, 31521, 29692, 26722, 22725, 26722, 29692, 31521), + VEC_S16(21407, 29692, 27969, 25172, 21407, 25172, 27969, 29692), + VEC_S16(19266, 26722, 25172, 22654, 19266, 22654, 25172, 26722) }; void mpeg2_idct_copy_altivec (vector_s16_t * block, unsigned char * dest, @@ -703,7 +229,5 @@ void mpeg2_idct_altivec_init (void) } } -#endif /* HOST_OS_DARWIN */ - #endif /* ARCH_PPC && ENABLED_ALTIVEC */ diff --git a/src/libmpeg2/mpeg2_internal.h b/src/libmpeg2/mpeg2_internal.h index 915bece2c..c2ffbf909 100644 --- a/src/libmpeg2/mpeg2_internal.h +++ b/src/libmpeg2/mpeg2_internal.h @@ -27,6 +27,10 @@ #include "video_out.h" #include "accel_xvmc.h" +#ifdef ENABLE_ALTIVEC +#include +#endif + /* macroblock modes */ #define MACROBLOCK_INTRA XINE_MACROBLOCK_INTRA #define MACROBLOCK_PATTERN XINE_MACROBLOCK_PATTERN @@ -243,10 +247,6 @@ void mpeg2_zero_block_mmx (int16_t * block); void mpeg2_idct_mmx_init (void); /* idct_altivec.c */ -#ifndef HOST_OS_DARWIN -void mpeg2_idct_copy_altivec (int16_t * block, uint8_t * dest, int stride); -void mpeg2_idct_add_altivec (int16_t * block, uint8_t * dest, int stride); -#else /* HOST_OS_DARWIN */ # ifdef ENABLE_ALTIVEC void mpeg2_idct_copy_altivec (vector signed short * block, unsigned char * dest, int stride); @@ -258,7 +258,6 @@ void mpeg2_idct_copy_altivec (signed short * block, unsigned char * dest, void mpeg2_idct_add_altivec (signed short * block, unsigned char * dest, int stride); # endif /* ENABLE_ALTIVEC */ -#endif /* HOST_OS_DARWIN */ void mpeg2_idct_altivec_init (void); /* motion_comp.c */ diff --git a/src/libmpeg2/slice.c b/src/libmpeg2/slice.c index 50d7b4caf..f214f1f25 100644 --- a/src/libmpeg2/slice.c +++ b/src/libmpeg2/slice.c @@ -205,7 +205,7 @@ static inline int get_motion_delta (picture_t * picture, int f_code) #undef bit_ptr } -static inline int bound_motion_vector (int vector, int f_code) +static inline int bound_motion_vector (int vec, int f_code) { #if 1 unsigned int limit; @@ -213,11 +213,11 @@ static inline int bound_motion_vector (int vector, int f_code) limit = 16 << f_code; - if ((unsigned int)(vector + limit) < 2 * limit) - return vector; + if ((unsigned int)(vec + limit) < 2 * limit) + return vec; else { - sign = ((int32_t)vector) >> 31; - return vector - ((2 * limit) ^ sign) + sign; + sign = ((int32_t)vec) >> 31; + return vec - ((2 * limit) ^ sign) + sign; } #else return ((int32_t)vector << (27 - f_code)) >> (27 - f_code); diff --git a/src/libmpeg2/slice_xvmc.c b/src/libmpeg2/slice_xvmc.c index fb0fab1e9..4aa383b9a 100644 --- a/src/libmpeg2/slice_xvmc.c +++ b/src/libmpeg2/slice_xvmc.c @@ -256,7 +256,7 @@ static inline int get_xvmc_motion_delta (picture_t * picture, int f_code) #undef bit_ptr } -static inline int bound_motion_vector (int vector, int f_code) +static inline int bound_motion_vector (int vec, int f_code) { #if 1 unsigned int limit; @@ -264,14 +264,14 @@ static inline int bound_motion_vector (int vector, int f_code) limit = 16 << f_code; - if ((unsigned int)(vector + limit) < 2 * limit) - return vector; + if ((unsigned int)(vec + limit) < 2 * limit) + return vec; else { - sign = ((int32_t)vector) >> 31; - return vector - ((2 * limit) ^ sign) + sign; + sign = ((int32_t)vec) >> 31; + return vec - ((2 * limit) ^ sign) + sign; } #else - return ((int32_t)vector << (27 - f_code)) >> (27 - f_code); + return ((int32_t)vec << (27 - f_code)) >> (27 - f_code); #endif } -- cgit v1.2.3