annotate libmpeg2/cpu_accel.c @ 34457:220497708307

propagate the pts to vf_next_put_image(); fixes playback with -correct-pts when reencoding is necessary
author nicodvb
date Thu, 12 Jan 2012 13:36:20 +0000
parents e83eef58b30a
children
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
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
3 * Copyright (C) 2000-2004 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 *
27571
fd18fa10de53 libmpeg-0.4.1.diff was renamed to libmpeg2_changes.diff.
diego
parents: 27340
diff changeset
23 * Modified for use with MPlayer, see libmpeg2_changes.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"
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
29
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
30 #include <inttypes.h>
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
31
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
32 #include "mpeg2.h"
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
33 #include "attributes.h"
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
34 #include "mpeg2_internal.h"
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
35
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
36 #include "cpudetect.h"
18727
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
37
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27572
diff changeset
38 #if ARCH_X86 || ARCH_X86_64
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
39 static inline uint32_t arch_accel (uint32_t accel)
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
40 {
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
41 /* Use MPlayer CPU detection instead of libmpeg2 variant. */
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
42 #if 0
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
43 if (accel & (MPEG2_ACCEL_X86_3DNOW | MPEG2_ACCEL_X86_MMXEXT))
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
44 accel |= MPEG2_ACCEL_X86_MMX;
29264
e83eef58b30a Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents: 28290
diff changeset
45
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
46 if (accel & (MPEG2_ACCEL_X86_SSE2 | MPEG2_ACCEL_X86_SSE3))
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
47 accel |= MPEG2_ACCEL_X86_MMXEXT;
29264
e83eef58b30a Remove all kind of trailing whitespaces from all MPlayer's files.
bircoph
parents: 28290
diff changeset
48
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
49 if (accel & (MPEG2_ACCEL_X86_SSE3))
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
50 accel |= MPEG2_ACCEL_X86_SSE2;
18727
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
51
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
52 #ifdef ACCEL_DETECT
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
53 if (accel & MPEG2_ACCEL_DETECT) {
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
54 uint32_t eax, ebx, ecx, edx;
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
55 int AMD;
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
56
21526
60a39d71e247 sync to libmpeg2-0.4.1
henry
parents: 18783
diff changeset
57 #if defined(__x86_64__) || (!defined(PIC) && !defined(__PIC__))
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
58 #define cpuid(op,eax,ebx,ecx,edx) \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
59 __asm__ ("cpuid" \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
60 : "=a" (eax), \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
61 "=b" (ebx), \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
62 "=c" (ecx), \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
63 "=d" (edx) \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
64 : "a" (op) \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
65 : "cc")
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
66 #else /* PIC version : save ebx (not needed on x86_64) */
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
67 #define cpuid(op,eax,ebx,ecx,edx) \
21526
60a39d71e247 sync to libmpeg2-0.4.1
henry
parents: 18783
diff changeset
68 __asm__ ("pushl %%ebx\n\t" \
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
69 "cpuid\n\t" \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
70 "movl %%ebx,%1\n\t" \
21526
60a39d71e247 sync to libmpeg2-0.4.1
henry
parents: 18783
diff changeset
71 "popl %%ebx" \
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
72 : "=a" (eax), \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
73 "=r" (ebx), \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
74 "=c" (ecx), \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
75 "=d" (edx) \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
76 : "a" (op) \
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
77 : "cc")
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
78 #endif
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
79
21526
60a39d71e247 sync to libmpeg2-0.4.1
henry
parents: 18783
diff changeset
80 #ifndef __x86_64__ /* x86_64 supports the cpuid op */
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
81 __asm__ ("pushf\n\t"
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
82 "pushf\n\t"
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
83 "pop %0\n\t"
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
84 "movl %0,%1\n\t"
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
85 "xorl $0x200000,%0\n\t"
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
86 "push %0\n\t"
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
87 "popf\n\t"
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
88 "pushf\n\t"
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
89 "pop %0\n\t"
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
90 "popf"
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
91 : "=r" (eax),
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
92 "=r" (ebx)
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
93 :
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
94 : "cc");
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
95
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
96 if (eax == ebx) /* no cpuid */
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
97 return accel;
21526
60a39d71e247 sync to libmpeg2-0.4.1
henry
parents: 18783
diff changeset
98 #endif
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
99
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
100 cpuid (0x00000000, eax, ebx, ecx, edx);
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
101 if (!eax) /* vendor string only */
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
102 return accel;
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
103
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
104 AMD = (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65);
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
105
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
106 cpuid (0x00000001, eax, ebx, ecx, edx);
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
107 if (! (edx & 0x00800000)) /* no MMX */
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
108 return accel;
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
109
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
110 accel |= MPEG2_ACCEL_X86_MMX;
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
111 if (edx & 0x02000000) /* SSE - identical to AMD MMX ext. */
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
112 accel |= MPEG2_ACCEL_X86_MMXEXT;
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
113
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
114 if (edx & 0x04000000) /* SSE2 */
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
115 accel |= MPEG2_ACCEL_X86_SSE2;
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
116
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
117 if (ecx & 0x00000001) /* SSE3 */
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
118 accel |= MPEG2_ACCEL_X86_SSE3;
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
119
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
120 cpuid (0x80000000, eax, ebx, ecx, edx);
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
121 if (eax < 0x80000001) /* no extended capabilities */
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
122 return accel;
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
123
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
124 cpuid (0x80000001, eax, ebx, ecx, edx);
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
125
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
126 if (edx & 0x80000000)
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
127 accel |= MPEG2_ACCEL_X86_3DNOW;
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
128
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
129 if (AMD && (edx & 0x00400000)) /* AMD MMX extensions */
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
130 accel |= MPEG2_ACCEL_X86_MMXEXT;
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
131 }
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
132 #endif /* ACCEL_DETECT */
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
133
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
134 return accel;
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
135
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
136 #else /* 0 */
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
137 accel = 0;
18727
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
138 if (gCpuCaps.hasMMX)
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
139 accel |= MPEG2_ACCEL_X86_MMX;
18727
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
140 if (gCpuCaps.hasSSE2)
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
141 accel |= MPEG2_ACCEL_X86_SSE2;
18727
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
142 if (gCpuCaps.hasMMX2)
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
143 accel |= MPEG2_ACCEL_X86_MMXEXT;
18727
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
144 if (gCpuCaps.has3DNow)
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
145 accel |= MPEG2_ACCEL_X86_3DNOW;
18727
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
146
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
147 return accel;
18727
24b2d27f2407 Use MPlayer's CPU detection module instead of libmpeg2's,
gpoirier
parents: 15483
diff changeset
148
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
149 #endif /* 0 */
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
150 }
13864
96259a2f2142 enable mmx support on x86_64 in libmpeg2
aurel
parents: 13018
diff changeset
151 #endif /* ARCH_X86 || ARCH_X86_64 */
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
152
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27572
diff changeset
153 #if defined(ACCEL_DETECT) && (ARCH_PPC || ARCH_SPARC)
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
154 #include <signal.h>
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
155 #include <setjmp.h>
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 static sigjmp_buf jmpbuf;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
158 static volatile sig_atomic_t canjump = 0;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
159
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
160 static RETSIGTYPE sigill_handler (int sig)
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
161 {
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
162 if (!canjump) {
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
163 signal (sig, SIG_DFL);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
164 raise (sig);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
165 }
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
166
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
167 canjump = 0;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
168 siglongjmp (jmpbuf, 1);
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
169 }
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
170 #endif /* ACCEL_DETECT && (ARCH_PPC || ARCH_SPARC) */
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
171
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27572
diff changeset
172 #if ARCH_PPC
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
173 static uint32_t arch_accel (uint32_t accel)
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
174 {
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
175 #ifdef ACCEL_DETECT
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
176 if ((accel & (MPEG2_ACCEL_PPC_ALTIVEC | MPEG2_ACCEL_DETECT)) ==
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
177 MPEG2_ACCEL_DETECT) {
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
178 static RETSIGTYPE (* oldsig) (int);
10303
2c0b6ec77d39 sync with libmpeg2 cvs
alex
parents: 9857
diff changeset
179
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
180 oldsig = signal (SIGILL, sigill_handler);
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
181 if (sigsetjmp (jmpbuf, 1)) {
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
182 signal (SIGILL, oldsig);
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
183 return accel;
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
184 }
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
185
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
186 canjump = 1;
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
187
25980
11181df06389 Do not check for __APPLE_ALTIVEC__, just check for __APPLE_CC__.
diego
parents: 21526
diff changeset
188 #if defined(__APPLE_CC__) /* apple */
15483
52838f825747 set define for apple gcc altivec
nplourde
parents: 14732
diff changeset
189 #define VAND(a,b,c) "vand v" #a ",v" #b ",v" #c "\n\t"
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
190 #else /* gnu */
10303
2c0b6ec77d39 sync with libmpeg2 cvs
alex
parents: 9857
diff changeset
191 #define VAND(a,b,c) "vand " #a "," #b "," #c "\n\t"
2c0b6ec77d39 sync with libmpeg2 cvs
alex
parents: 9857
diff changeset
192 #endif
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
193 asm volatile ("mtspr 256, %0\n\t"
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
194 VAND (0, 0, 0)
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
195 :
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
196 : "r" (-1));
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
197
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
198 canjump = 0;
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
199 accel |= MPEG2_ACCEL_PPC_ALTIVEC;
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
200
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
201 signal (SIGILL, oldsig);
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
202 }
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
203 #endif /* ACCEL_DETECT */
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
204
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
205 return accel;
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
206 }
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
207 #endif /* ARCH_PPC */
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
208
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27572
diff changeset
209 #if ARCH_SPARC
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
210 static uint32_t arch_accel (uint32_t accel)
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
211 {
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
212 if (accel & MPEG2_ACCEL_SPARC_VIS2)
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
213 accel |= MPEG2_ACCEL_SPARC_VIS;
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
214
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
215 #ifdef ACCEL_DETECT
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
216 if ((accel & (MPEG2_ACCEL_SPARC_VIS2 | MPEG2_ACCEL_DETECT)) ==
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
217 MPEG2_ACCEL_DETECT) {
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
218 static RETSIGTYPE (* oldsig) (int);
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
219
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
220 oldsig = signal (SIGILL, sigill_handler);
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
221 if (sigsetjmp (jmpbuf, 1)) {
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
222 signal (SIGILL, oldsig);
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
223 return accel;
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
224 }
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
225
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
226 canjump = 1;
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
227
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
228 /* pdist %f0, %f0, %f0 */
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
229 __asm__ __volatile__(".word\t0x81b007c0");
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
230
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
231 canjump = 0;
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
232 accel |= MPEG2_ACCEL_SPARC_VIS;
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
233
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
234 if (sigsetjmp (jmpbuf, 1)) {
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
235 signal (SIGILL, oldsig);
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
236 return accel;
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
237 }
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
238
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
239 canjump = 1;
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
240
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
241 /* edge8n %g0, %g0, %g0 */
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
242 __asm__ __volatile__(".word\t0x81b00020");
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
243
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
244 canjump = 0;
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
245 accel |= MPEG2_ACCEL_SPARC_VIS2;
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
246
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
247 signal (SIGILL, oldsig);
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
248 }
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
249 #endif /* ACCEL_DETECT */
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
250
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
251 return accel;
12932
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
252 }
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
253 #endif /* ARCH_SPARC */
d0a8810e155c Importing libmpeg2 from mpeg2dec-0.4.0b
henry
parents: 10488
diff changeset
254
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27572
diff changeset
255 #if ARCH_ALPHA
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
256 static inline uint32_t arch_accel (uint32_t accel)
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
257 {
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
258 if (accel & MPEG2_ACCEL_ALPHA_MVI)
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
259 accel |= MPEG2_ACCEL_ALPHA;
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
260
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
261 #ifdef ACCEL_DETECT
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
262 if (accel & MPEG2_ACCEL_DETECT) {
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
263 uint64_t no_mvi;
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
264
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
265 asm volatile ("amask %1, %0"
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
266 : "=r" (no_mvi)
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
267 : "rI" (256)); /* AMASK_MVI */
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
268 accel |= no_mvi ? MPEG2_ACCEL_ALPHA : (MPEG2_ACCEL_ALPHA |
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
269 MPEG2_ACCEL_ALPHA_MVI);
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
270 }
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
271 #endif /* ACCEL_DETECT */
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
272
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
273 return accel;
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
274 }
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
275 #endif /* ARCH_ALPHA */
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
276
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
277 uint32_t mpeg2_detect_accel (uint32_t accel)
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
278 {
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 27572
diff changeset
279 #if ARCH_X86 || ARCH_X86_64 || ARCH_PPC || ARCH_ALPHA || ARCH_SPARC
27572
da2271c341ee Update internal libmpeg2 copy to version 0.5.1.
diego
parents: 27571
diff changeset
280 accel = arch_accel (accel);
9857
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
281 #endif
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
282 return accel;
89b48bc6c441 Importing libmpeg2 from mpeg2dec-0.3.1
arpi
parents:
diff changeset
283 }