Mercurial > mplayer.hg
comparison libmpeg2/cpu_state.c @ 9857:89b48bc6c441
Importing libmpeg2 from mpeg2dec-0.3.1
author | arpi |
---|---|
date | Sun, 06 Apr 2003 16:41:49 +0000 |
parents | |
children | 4053e9c22c88 |
comparison
equal
deleted
inserted
replaced
9856:08496327b7ec | 9857:89b48bc6c441 |
---|---|
1 /* | |
2 * cpu_state.c | |
3 * Copyright (C) 2000-2002 Michel Lespinasse <walken@zoy.org> | |
4 * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> | |
5 * | |
6 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. | |
7 * See http://libmpeg2.sourceforge.net/ for updates. | |
8 * | |
9 * mpeg2dec is free software; you can redistribute it and/or modify | |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * mpeg2dec is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 */ | |
23 | |
24 #include "config.h" | |
25 | |
26 #include <stdlib.h> | |
27 #include <inttypes.h> | |
28 | |
29 #include "mpeg2.h" | |
30 #include "mpeg2_internal.h" | |
31 #include "attributes.h" | |
32 #ifdef ARCH_X86 | |
33 #include "mmx.h" | |
34 #endif | |
35 | |
36 void (* mpeg2_cpu_state_save) (cpu_state_t * state) = NULL; | |
37 void (* mpeg2_cpu_state_restore) (cpu_state_t * state) = NULL; | |
38 | |
39 #ifdef ARCH_X86 | |
40 static void state_restore_mmx (cpu_state_t * state) | |
41 { | |
42 emms (); | |
43 } | |
44 #endif | |
45 | |
46 #ifdef ARCH_PPC | |
47 static void state_save_altivec (cpu_state_t * state) | |
48 { | |
49 asm (" \n" | |
50 " li %r9, 16 \n" | |
51 " stvx %v20, 0, %r3 \n" | |
52 " li %r11, 32 \n" | |
53 " stvx %v21, %r9, %r3 \n" | |
54 " li %r9, 48 \n" | |
55 " stvx %v22, %r11, %r3 \n" | |
56 " li %r11, 64 \n" | |
57 " stvx %v23, %r9, %r3 \n" | |
58 " li %r9, 80 \n" | |
59 " stvx %v24, %r11, %r3 \n" | |
60 " li %r11, 96 \n" | |
61 " stvx %v25, %r9, %r3 \n" | |
62 " li %r9, 112 \n" | |
63 " stvx %v26, %r11, %r3 \n" | |
64 " li %r11, 128 \n" | |
65 " stvx %v27, %r9, %r3 \n" | |
66 " li %r9, 144 \n" | |
67 " stvx %v28, %r11, %r3 \n" | |
68 " li %r11, 160 \n" | |
69 " stvx %v29, %r9, %r3 \n" | |
70 " li %r9, 176 \n" | |
71 " stvx %v30, %r11, %r3 \n" | |
72 " stvx %v31, %r9, %r3 \n" | |
73 ); | |
74 } | |
75 | |
76 static void state_restore_altivec (cpu_state_t * state) | |
77 { | |
78 asm (" \n" | |
79 " li %r9, 16 \n" | |
80 " lvx %v20, 0, %r3 \n" | |
81 " li %r11, 32 \n" | |
82 " lvx %v21, %r9, %r3 \n" | |
83 " li %r9, 48 \n" | |
84 " lvx %v22, %r11, %r3 \n" | |
85 " li %r11, 64 \n" | |
86 " lvx %v23, %r9, %r3 \n" | |
87 " li %r9, 80 \n" | |
88 " lvx %v24, %r11, %r3 \n" | |
89 " li %r11, 96 \n" | |
90 " lvx %v25, %r9, %r3 \n" | |
91 " li %r9, 112 \n" | |
92 " lvx %v26, %r11, %r3 \n" | |
93 " li %r11, 128 \n" | |
94 " lvx %v27, %r9, %r3 \n" | |
95 " li %r9, 144 \n" | |
96 " lvx %v28, %r11, %r3 \n" | |
97 " li %r11, 160 \n" | |
98 " lvx %v29, %r9, %r3 \n" | |
99 " li %r9, 176 \n" | |
100 " lvx %v30, %r11, %r3 \n" | |
101 " lvx %v31, %r9, %r3 \n" | |
102 ); | |
103 } | |
104 #endif | |
105 | |
106 void mpeg2_cpu_state_init (uint32_t accel) | |
107 { | |
108 #ifdef ARCH_X86 | |
109 if (accel & MPEG2_ACCEL_X86_MMX) { | |
110 mpeg2_cpu_state_restore = state_restore_mmx; | |
111 } | |
112 #endif | |
113 #ifdef ARCH_PPC | |
114 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) { | |
115 mpeg2_cpu_state_save = state_save_altivec; | |
116 mpeg2_cpu_state_restore = state_restore_altivec; | |
117 } | |
118 #endif | |
119 } |