annotate libmpeg2/cpu_accel.c @ 24471:516c6a2277b1

Greatly simplify IsValidAudioPacket, though this might break something
author reimar
date Fri, 14 Sep 2007 18:54:14 +0000
parents 60a39d71e247
children 11181df06389
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
1 /*
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
2 * cpu_accel.c
10303
2c0b6ec77d39 sync with libmpeg2 cvs
alex
parents: 9857
diff changeset
3 * Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
5 *
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
6 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
7 * See http://libmpeg2.sourceforge.net/ for updates.
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
8 *
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
9 * mpeg2dec is free software; you can redistribute it and/or modify
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
12 * (at your option) any later version.
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
13 *
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
14 * mpeg2dec is distributed in the hope that it will be useful,
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
17 * GNU General Public License for more details.
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
18 *
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14732
1385ec491ffb Mark locally modified files as such to comply more closely with GPL 2a.
diego
parents: 13864
diff changeset
22 *
21526
60a39d71e247 sync to libmpeg2-0.4.1
henry
parents: 18783
diff changeset
23 * Modified for use with MPlayer, see libmpeg-0.4.1.diff for the exact changes.
18783
0783dd397f74 CVS --> Subversion in copyright notices
diego
parents: 18727
diff changeset
24 * detailed changelog at http://svn.mplayerhq.hu/mplayer/trunk/
14732
1385ec491ffb Mark locally modified files as such to comply more closely with GPL 2a.
diego
parents: 13864
diff changeset
25 * $Id$
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
26 */
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
27
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
28 #include "config.h"
18727
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
29 #include "cpudetect.h"
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
30
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
31 #include <inttypes.h>
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
32
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
33 #include "mpeg2.h"
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
34 #include "attributes.h"
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
35 #include "mpeg2_internal.h"
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
36
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
37 #ifdef ACCEL_DETECT
13864
96259a2f2142 enable mmx support on x86_64 in libmpeg2
aurel
parents: 13018
diff changeset
38 #if defined(ARCH_X86) || defined(ARCH_X86_64)
18727
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
39
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
40 /* MPlayer imports libmpeg2 as decoder, which detects MMX / 3DNow!
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
41 * instructions via assembly. However, it is regarded as duplicaed work
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
42 * in MPlayer, so that we enforce to use MPlayer's implementation.
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
43 */
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
44 #define USE_MPLAYER_CPUDETECT
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
45
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
46 static inline uint32_t arch_accel (void)
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
47 {
18727
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
48 #if !defined(USE_MPLAYER_CPUDETECT)
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
49 uint32_t eax, ebx, ecx, edx;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
50 int AMD;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
51 uint32_t caps;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
52
21526
60a39d71e247 sync to libmpeg2-0.4.1
henry
parents: 18783
diff changeset
53 #if defined(__x86_64__) || (!defined(PIC) && !defined(__PIC__))
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
54 #define cpuid(op,eax,ebx,ecx,edx) \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
55 __asm__ ("cpuid" \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
56 : "=a" (eax), \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
57 "=b" (ebx), \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
58 "=c" (ecx), \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
59 "=d" (edx) \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
60 : "a" (op) \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
61 : "cc")
21526
60a39d71e247 sync to libmpeg2-0.4.1
henry
parents: 18783
diff changeset
62 #else /* PIC version : save ebx (not needed on x86_64) */
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
63 #define cpuid(op,eax,ebx,ecx,edx) \
21526
60a39d71e247 sync to libmpeg2-0.4.1
henry
parents: 18783
diff changeset
64 __asm__ ("pushl %%ebx\n\t" \
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
65 "cpuid\n\t" \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
66 "movl %%ebx,%1\n\t" \
21526
60a39d71e247 sync to libmpeg2-0.4.1
henry
parents: 18783
diff changeset
67 "popl %%ebx" \
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
68 : "=a" (eax), \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
69 "=r" (ebx), \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
70 "=c" (ecx), \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
71 "=d" (edx) \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
72 : "a" (op) \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
73 : "cc")
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
74 #endif
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
75
21526
60a39d71e247 sync to libmpeg2-0.4.1
henry
parents: 18783
diff changeset
76 #ifndef __x86_64__ /* x86_64 supports the cpuid op */
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
77 __asm__ ("pushf\n\t"
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
78 "pushf\n\t"
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
79 "pop %0\n\t"
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
80 "movl %0,%1\n\t"
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
81 "xorl $0x200000,%0\n\t"
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
82 "push %0\n\t"
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
83 "popf\n\t"
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
84 "pushf\n\t"
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
85 "pop %0\n\t"
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
86 "popf"
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
87 : "=r" (eax),
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
88 "=r" (ebx)
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
89 :
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
90 : "cc");
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
91
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
92 if (eax == ebx) /* no cpuid */
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
93 return 0;
21526
60a39d71e247 sync to libmpeg2-0.4.1
henry
parents: 18783
diff changeset
94 #endif
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
95
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
96 cpuid (0x00000000, eax, ebx, ecx, edx);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
97 if (!eax) /* vendor string only */
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
98 return 0;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
99
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
100 AMD = (ebx == 0x68747541) && (ecx == 0x444d4163) && (edx == 0x69746e65);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
101
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
102 cpuid (0x00000001, eax, ebx, ecx, edx);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
103 if (! (edx & 0x00800000)) /* no MMX */
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
104 return 0;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
105
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
106 caps = MPEG2_ACCEL_X86_MMX;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
107 if (edx & 0x02000000) /* SSE - identical to AMD MMX extensions */
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
108 caps = MPEG2_ACCEL_X86_MMX | MPEG2_ACCEL_X86_MMXEXT;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
109
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
110 cpuid (0x80000000, eax, ebx, ecx, edx);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
111 if (eax < 0x80000001) /* no extended capabilities */
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
112 return caps;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
113
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
114 cpuid (0x80000001, eax, ebx, ecx, edx);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
115
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
116 if (edx & 0x80000000)
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
117 caps |= MPEG2_ACCEL_X86_3DNOW;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
118
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
119 if (AMD && (edx & 0x00400000)) /* AMD MMX extensions */
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
120 caps |= MPEG2_ACCEL_X86_MMXEXT;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
121
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
122 return caps;
18727
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
123 #else /* USE_MPLAYER_CPUDETECT: Use MPlayer's cpu capability property */
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
124 caps = 0;
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
125 if (gCpuCaps.hasMMX)
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
126 caps |= MPEG2_ACCEL_X86_MMX;
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
127 if (gCpuCaps.hasSSE2)
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
128 caps |= MPEG2_ACCEL_X86_SSE2;
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
129 if (gCpuCaps.hasMMX2)
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
130 caps |= MPEG2_ACCEL_X86_MMXEXT;
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
131 if (gCpuCaps.has3DNow)
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
132 caps |= MPEG2_ACCEL_X86_3DNOW;
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
133
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
134 return caps;
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
135
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
136 #endif /* USE_MPLAYER_CPUDETECT */
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
137 }
13864
96259a2f2142 enable mmx support on x86_64 in libmpeg2
aurel
parents: 13018
diff changeset
138 #endif /* ARCH_X86 || ARCH_X86_64 */
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
139
13018
adb93ef6b07f Improved SPARC CPU detection and SPARC compilation fixes.
diego
parents: 12932
diff changeset
140 #if defined(ARCH_PPC) || (defined(ARCH_SPARC) && defined(HAVE_VIS))
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
141 #include <signal.h>
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
142 #include <setjmp.h>
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
143
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
144 static sigjmp_buf jmpbuf;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
145 static volatile sig_atomic_t canjump = 0;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
146
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
147 static RETSIGTYPE sigill_handler (int sig)
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
148 {
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
149 if (!canjump) {
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
150 signal (sig, SIG_DFL);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
151 raise (sig);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
152 }
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
153
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
154 canjump = 0;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
155 siglongjmp (jmpbuf, 1);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
156 }
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
157
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
158 #ifdef ARCH_PPC
21526
60a39d71e247 sync to libmpeg2-0.4.1
henry
parents: 18783
diff changeset
159 static uint32_t arch_accel (void)
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
160 {
10303
2c0b6ec77d39 sync with libmpeg2 cvs
alex
parents: 9857
diff changeset
161 static RETSIGTYPE (* oldsig) (int);
2c0b6ec77d39 sync with libmpeg2 cvs
alex
parents: 9857
diff changeset
162
2c0b6ec77d39 sync with libmpeg2 cvs
alex
parents: 9857
diff changeset
163 oldsig = signal (SIGILL, sigill_handler);
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
164 if (sigsetjmp (jmpbuf, 1)) {
10303
2c0b6ec77d39 sync with libmpeg2 cvs
alex
parents: 9857
diff changeset
165 signal (SIGILL, oldsig);
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
166 return 0;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
167 }
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
168
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
169 canjump = 1;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
170
15483
52838f825747 set define for apple gcc altivec
nplourde
parents: 14732
diff changeset
171 #if defined( __APPLE_CC__ ) && defined( __APPLE_ALTIVEC__ ) /* apple */
52838f825747 set define for apple gcc altivec
nplourde
parents: 14732
diff changeset
172 #define VAND(a,b,c) "vand v" #a ",v" #b ",v" #c "\n\t"
52838f825747 set define for apple gcc altivec
nplourde
parents: 14732
diff changeset
173 #else /* gnu */
10303
2c0b6ec77d39 sync with libmpeg2 cvs
alex
parents: 9857
diff changeset
174 #define VAND(a,b,c) "vand " #a "," #b "," #c "\n\t"
2c0b6ec77d39 sync with libmpeg2 cvs
alex
parents: 9857
diff changeset
175 #endif
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
176 asm volatile ("mtspr 256, %0\n\t"
10303
2c0b6ec77d39 sync with libmpeg2 cvs
alex
parents: 9857
diff changeset
177 VAND (0, 0, 0)
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
178 :
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
179 : "r" (-1));
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
180
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
181 canjump = 0;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
182
10303
2c0b6ec77d39 sync with libmpeg2 cvs
alex
parents: 9857
diff changeset
183 signal (SIGILL, oldsig);
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
184 return MPEG2_ACCEL_PPC_ALTIVEC;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
185 }
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
186 #endif /* ARCH_PPC */
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
187
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
188 #ifdef ARCH_SPARC
21526
60a39d71e247 sync to libmpeg2-0.4.1
henry
parents: 18783
diff changeset
189 static uint32_t arch_accel (void)
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
190 {
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
191 static RETSIGTYPE (* oldsig) (int);
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
192
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
193 oldsig = signal (SIGILL, sigill_handler);
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
194 if (sigsetjmp (jmpbuf, 1)) {
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
195 signal (SIGILL, oldsig);
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
196 return 0;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
197 }
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
198
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
199 canjump = 1;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
200
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
201 /* pdist %f0, %f0, %f0 */
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
202 __asm__ __volatile__(".word\t0x81b007c0");
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
203
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
204 canjump = 0;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
205
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
206 if (sigsetjmp (jmpbuf, 1)) {
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
207 signal (SIGILL, oldsig);
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
208 return MPEG2_ACCEL_SPARC_VIS;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
209 }
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
210
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
211 canjump = 1;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
212
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
213 /* edge8n %g0, %g0, %g0 */
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
214 __asm__ __volatile__(".word\t0x81b00020");
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
215
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
216 canjump = 0;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
217
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
218 signal (SIGILL, oldsig);
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
219 return MPEG2_ACCEL_SPARC_VIS | MPEG2_ACCEL_SPARC_VIS2;
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
220 }
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
221 #endif /* ARCH_SPARC */
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
222 #endif /* ARCH_PPC || ARCH_SPARC */
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
223
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
224 #ifdef ARCH_ALPHA
21526
60a39d71e247 sync to libmpeg2-0.4.1
henry
parents: 18783
diff changeset
225 static uint32_t arch_accel (void)
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
226 {
10488
ec04f41e2480 gcc2.95.x has no support for mvi instructions
alex
parents: 10303
diff changeset
227 #ifdef CAN_COMPILE_ALPHA_MVI
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
228 uint64_t no_mvi;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
229
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
230 asm volatile ("amask %1, %0"
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
231 : "=r" (no_mvi)
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
232 : "rI" (256)); /* AMASK_MVI */
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
233 return no_mvi ? MPEG2_ACCEL_ALPHA : (MPEG2_ACCEL_ALPHA |
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
234 MPEG2_ACCEL_ALPHA_MVI);
10488
ec04f41e2480 gcc2.95.x has no support for mvi instructions
alex
parents: 10303
diff changeset
235 #else
ec04f41e2480 gcc2.95.x has no support for mvi instructions
alex
parents: 10303
diff changeset
236 return MPEG2_ACCEL_ALPHA;
ec04f41e2480 gcc2.95.x has no support for mvi instructions
alex
parents: 10303
diff changeset
237 #endif
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
238 }
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
239 #endif /* ARCH_ALPHA */
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
240 #endif /* ACCEL_DETECT */
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
241
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
242 uint32_t mpeg2_detect_accel (void)
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
243 {
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
244 uint32_t accel;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
245
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
246 accel = 0;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
247 #ifdef ACCEL_DETECT
13864
96259a2f2142 enable mmx support on x86_64 in libmpeg2
aurel
parents: 13018
diff changeset
248 #if defined (ARCH_X86) || defined (ARCH_X86_64) || defined (ARCH_PPC) || defined (ARCH_ALPHA) || defined (ARCH_SPARC)
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
249 accel = arch_accel ();
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
250 #endif
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
251 #endif
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
252 return accel;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
253 }