diff -ru tosvcd-0.9-orig/cpu_accel.c tosvcd-0.9/cpu_accel.c --- tosvcd-0.9-orig/cpu_accel.c 2006-01-06 23:49:27.981575000 +0100 +++ tosvcd-0.9/cpu_accel.c 2006-01-06 23:51:02.251466500 +0100 @@ -1,6 +1,6 @@ /* * cpu_accel.c - * Copyright (C) 2000-2001 Michel Lespinasse + * Copyright (C) 2000-2003 Michel Lespinasse * Copyright (C) 1999-2000 Aaron Holtzman * * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. @@ -19,58 +19,61 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Modified for use with MPlayer, see libmpeg-0.4.0.diff for the exact changes. + * detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/ + * $Id: tosvcd-0.9-cpu_accel.diff,v 1.2 2006/01/06 22:58:32 zzam Exp $ */ #include "config.h" #include -#include "mm_accel.h" - -#ifdef ARCH_X86 -static uint32_t arch_accel (void) +#ifdef ACCEL_DETECT +#if defined(ARCH_X86) || defined(ARCH_X86_64) +static inline uint32_t arch_accel (void) { uint32_t eax, ebx, ecx, edx; int AMD; uint32_t caps; -#ifndef PIC +#if !defined(PIC) && !defined(__PIC__) #define cpuid(op,eax,ebx,ecx,edx) \ - asm ("cpuid" \ - : "=a" (eax), \ - "=b" (ebx), \ - "=c" (ecx), \ - "=d" (edx) \ - : "a" (op) \ - : "cc") + __asm__ ("cpuid" \ + : "=a" (eax), \ + "=b" (ebx), \ + "=c" (ecx), \ + "=d" (edx) \ + : "a" (op) \ + : "cc") #else /* PIC version : save ebx */ #define cpuid(op,eax,ebx,ecx,edx) \ - asm ("pushl %%ebx\n\t" \ - "cpuid\n\t" \ - "movl %%ebx,%1\n\t" \ - "popl %%ebx" \ - : "=a" (eax), \ - "=r" (ebx), \ - "=c" (ecx), \ - "=d" (edx) \ - : "a" (op) \ - : "cc") + __asm__ ("push %%ebx\n\t" \ + "cpuid\n\t" \ + "movl %%ebx,%1\n\t" \ + "pop %%ebx" \ + : "=a" (eax), \ + "=r" (ebx), \ + "=c" (ecx), \ + "=d" (edx) \ + : "a" (op) \ + : "cc") #endif - asm ("pushfl\n\t" - "pushfl\n\t" - "popl %0\n\t" - "movl %0,%1\n\t" - "xorl $0x200000,%0\n\t" - "pushl %0\n\t" - "popfl\n\t" - "pushfl\n\t" - "popl %0\n\t" - "popfl" - : "=r" (eax), - "=r" (ebx) - : - : "cc"); + __asm__ ("pushf\n\t" + "pushf\n\t" + "pop %0\n\t" + "movl %0,%1\n\t" + "xorl $0x200000,%0\n\t" + "push %0\n\t" + "popf\n\t" + "pushf\n\t" + "pop %0\n\t" + "popf" + : "=r" (eax), + "=r" (ebx) + : + : "cc"); if (eax == ebx) /* no cpuid */ return 0; @@ -85,9 +88,9 @@ if (! (edx & 0x00800000)) /* no MMX */ return 0; - caps = MM_ACCEL_X86_MMX; + caps = MPEG2_ACCEL_X86_MMX; if (edx & 0x02000000) /* SSE - identical to AMD MMX extensions */ - caps = MM_ACCEL_X86_MMX | MM_ACCEL_X86_MMXEXT; + caps = MPEG2_ACCEL_X86_MMX | MPEG2_ACCEL_X86_MMXEXT; cpuid (0x80000000, eax, ebx, ecx, edx); if (eax < 0x80000001) /* no extended capabilities */ @@ -96,16 +99,16 @@ cpuid (0x80000001, eax, ebx, ecx, edx); if (edx & 0x80000000) - caps |= MM_ACCEL_X86_3DNOW; + caps |= MPEG2_ACCEL_X86_3DNOW; if (AMD && (edx & 0x00400000)) /* AMD MMX extensions */ - caps |= MM_ACCEL_X86_MMXEXT; + caps |= MPEG2_ACCEL_X86_MMXEXT; return caps; } -#endif /* ARCH_X86 */ +#endif /* ARCH_X86 || ARCH_X86_64 */ -#ifdef ARCH_PPC +#if defined(ARCH_PPC) || (defined(ARCH_SPARC) && defined(HAVE_VIS)) #include #include @@ -123,39 +126,99 @@ siglongjmp (jmpbuf, 1); } -static uint32_t arch_accel (void) +#ifdef ARCH_PPC +static inline uint32_t arch_accel (void) { - signal (SIGILL, sigill_handler); + static RETSIGTYPE (* oldsig) (int); + + oldsig = signal (SIGILL, sigill_handler); if (sigsetjmp (jmpbuf, 1)) { - signal (SIGILL, SIG_DFL); + signal (SIGILL, oldsig); return 0; } canjump = 1; +#if defined( __APPLE_CC__ ) && defined( __APPLE_ALTIVEC__ ) /* apple */ +#define VAND(a,b,c) "vand v" #a ",v" #b ",v" #c "\n\t" +#else /* gnu */ +#define VAND(a,b,c) "vand " #a "," #b "," #c "\n\t" +#endif asm volatile ("mtspr 256, %0\n\t" - "vand %%v0, %%v0, %%v0" + VAND (0, 0, 0) : : "r" (-1)); - signal (SIGILL, SIG_DFL); - return MM_ACCEL_PPC_ALTIVEC; + canjump = 0; + + signal (SIGILL, oldsig); + return MPEG2_ACCEL_PPC_ALTIVEC; } #endif /* ARCH_PPC */ -uint32_t mm_accel (void) +#ifdef ARCH_SPARC +static inline uint32_t arch_accel (void) { -#if defined (ARCH_X86) || defined (ARCH_PPC) - static int got_accel = 0; - static uint32_t accel; - - if (!got_accel) { - got_accel = 1; - accel = arch_accel (); + static RETSIGTYPE (* oldsig) (int); + + oldsig = signal (SIGILL, sigill_handler); + if (sigsetjmp (jmpbuf, 1)) { + signal (SIGILL, oldsig); + return 0; } - return accel; + canjump = 1; + + /* pdist %f0, %f0, %f0 */ + __asm__ __volatile__(".word\t0x81b007c0"); + + canjump = 0; + + if (sigsetjmp (jmpbuf, 1)) { + signal (SIGILL, oldsig); + return MPEG2_ACCEL_SPARC_VIS; + } + + canjump = 1; + + /* edge8n %g0, %g0, %g0 */ + __asm__ __volatile__(".word\t0x81b00020"); + + canjump = 0; + + signal (SIGILL, oldsig); + return MPEG2_ACCEL_SPARC_VIS | MPEG2_ACCEL_SPARC_VIS2; +} +#endif /* ARCH_SPARC */ +#endif /* ARCH_PPC || ARCH_SPARC */ + +#ifdef ARCH_ALPHA +static inline uint32_t arch_accel (void) +{ +#ifdef CAN_COMPILE_ALPHA_MVI + uint64_t no_mvi; + + asm volatile ("amask %1, %0" + : "=r" (no_mvi) + : "rI" (256)); /* AMASK_MVI */ + return no_mvi ? MPEG2_ACCEL_ALPHA : (MPEG2_ACCEL_ALPHA | + MPEG2_ACCEL_ALPHA_MVI); #else - return 0; + return MPEG2_ACCEL_ALPHA; #endif } +#endif /* ARCH_ALPHA */ +#endif /* ACCEL_DETECT */ + +uint32_t mm_accel (void) +{ + uint32_t accel; + + accel = 0; +#ifdef ACCEL_DETECT +#if defined (ARCH_X86) || defined (ARCH_X86_64) || defined (ARCH_PPC) || defined (ARCH_ALPHA) || defined (ARCH_SPARC) + accel = arch_accel (); +#endif +#endif + return accel; +} --- tosvcd-0.9-orig/makefile 2006-01-06 23:49:27.981575000 +0100 +++ tosvcd-0.9/makefile 2006-01-06 23:50:29.157398250 +0100 @@ -21,7 +21,6 @@ tosvcd: $(OBJ) $(CC) -o tosvcd $(OBJ) -lpthread - su -c "cp tosvcd /usr/bin" t: ./tosvcd -o mafia /home/ws/videos/Mafia/2002-10-21.00:33.50.50.rec diff -ru tosvcd-0.9-orig/mm_accel.h tosvcd-0.9/mm_accel.h --- tosvcd-0.9-orig/mm_accel.h 2006-01-06 23:49:27.981575000 +0100 +++ tosvcd-0.9/mm_accel.h 2006-01-06 23:57:20.867128500 +0100 @@ -1,36 +1,44 @@ -/***** -* -* This file is part of the OMS program. -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2, or (at your option) -* any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; see the file COPYING. If not, write to -* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -* -*****/ +/* + * mm_accel.h + * Copyright (C) 2000-2001 Michel Lespinasse + * Copyright (C) 1999-2000 Aaron Holtzman + * + * This file is part of a52dec, a free ATSC A-52 stream decoder. + * See http://liba52.sourceforge.net/ for updates. + * + * a52dec is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * a52dec is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ -#ifndef __MM_ACCEL_H__ -#define __MM_ACCEL_H__ +#ifndef MM_ACCEL_H +#define MM_ACCEL_H #include -// generic accelerations +/* generic accelerations */ #define MM_ACCEL_MLIB 0x00000001 -// x86 accelerations +/* x86 accelerations */ #define MM_ACCEL_X86_MMX 0x80000000 #define MM_ACCEL_X86_3DNOW 0x40000000 +#define MM_ACCEL_X86_3DNOWEXT 0x08000000 #define MM_ACCEL_X86_MMXEXT 0x20000000 +#define MM_ACCEL_X86_SSE 0x10000000 + +/* PPC accelerations */ +#define MM_ACCEL_PPC_ALTIVEC 0x00010000 uint32_t mm_accel (void); -#endif +#endif /* MM_ACCEL_H */