summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-04-14 16:35:44 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-04-14 16:35:44 +0000
commitf4b5a723b06b25babe201b0a97bdeebc716f5bba (patch)
tree10a759a0438df774a7b1eab6af0e3995f85ae4d3
parent32bd59d4f75f135b26a537f438e0d6b893f1cdfb (diff)
downloadrockbox-f4b5a723b06b25babe201b0a97bdeebc716f5bba.tar.gz
rockbox-f4b5a723b06b25babe201b0a97bdeebc716f5bba.zip
mpeg2dec in mpegplayer: Do a little code slashing and organizing. Much more to come I think.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13159 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/mpegplayer/SOURCES11
-rw-r--r--apps/plugins/mpegplayer/cpu_accel.c220
-rw-r--r--apps/plugins/mpegplayer/cpu_state.c129
-rw-r--r--apps/plugins/mpegplayer/decode.c23
-rw-r--r--apps/plugins/mpegplayer/header.c4
-rw-r--r--apps/plugins/mpegplayer/idct.c86
-rw-r--r--apps/plugins/mpegplayer/motion_comp.c133
-rw-r--r--apps/plugins/mpegplayer/motion_comp.h84
-rw-r--r--apps/plugins/mpegplayer/motion_comp_arm.c183
-rw-r--r--apps/plugins/mpegplayer/motion_comp_arm_c.c37
-rw-r--r--apps/plugins/mpegplayer/motion_comp_arm_s.S104
-rw-r--r--apps/plugins/mpegplayer/mpeg2.h14
-rw-r--r--apps/plugins/mpegplayer/mpeg2_internal.h46
-rw-r--r--apps/plugins/mpegplayer/slice.c67
14 files changed, 274 insertions, 867 deletions
diff --git a/apps/plugins/mpegplayer/SOURCES b/apps/plugins/mpegplayer/SOURCES
index fc23a2ab11..e9a01b73d0 100644
--- a/apps/plugins/mpegplayer/SOURCES
+++ b/apps/plugins/mpegplayer/SOURCES
@@ -1,14 +1,17 @@
1alloc.c 1alloc.c
2cpu_accel.c
3cpu_state.c
4decode.c 2decode.c
5header.c 3header.c
6idct.c 4idct.c
5
7motion_comp.c 6motion_comp.c
7
8#ifdef CPU_ARM 8#ifdef CPU_ARM
9motion_comp_arm.c 9motion_comp_arm_c.c
10motion_comp_arm_s.S 10motion_comp_arm_s.S
11#endif 11#else /* other CPU or SIM */
12motion_comp_c.c
13#endif /* CPU_* */
14
12slice.c 15slice.c
13video_out_rockbox.c 16video_out_rockbox.c
14mpeg_settings.c 17mpeg_settings.c
diff --git a/apps/plugins/mpegplayer/cpu_accel.c b/apps/plugins/mpegplayer/cpu_accel.c
deleted file mode 100644
index 2616e04cd0..0000000000
--- a/apps/plugins/mpegplayer/cpu_accel.c
+++ /dev/null
@@ -1,220 +0,0 @@
1/*
2 * cpu_accel.c
3 * Copyright (C) 2000-2003 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 "plugin.h"
25
26#include "mpeg2dec_config.h"
27
28#include "mpeg2.h"
29#include "attributes.h"
30#include "mpeg2_internal.h"
31
32#ifdef ACCEL_DETECT
33#ifdef ARCH_X86
34static inline uint32_t arch_accel (void)
35{
36 uint32_t eax, ebx, ecx, edx;
37 int AMD;
38 uint32_t caps;
39
40#if !defined(PIC) && !defined(__PIC__)
41#define cpuid(op,eax,ebx,ecx,edx) \
42 __asm__ ("cpuid" \
43 : "=a" (eax), \
44 "=b" (ebx), \
45 "=c" (ecx), \
46 "=d" (edx) \
47 : "a" (op) \
48 : "cc")
49#else /* PIC version : save ebx */
50#define cpuid(op,eax,ebx,ecx,edx) \
51 __asm__ ("push %%ebx\n\t" \
52 "cpuid\n\t" \
53 "movl %%ebx,%1\n\t" \
54 "pop %%ebx" \
55 : "=a" (eax), \
56 "=r" (ebx), \
57 "=c" (ecx), \
58 "=d" (edx) \
59 : "a" (op) \
60 : "cc")
61#endif
62
63 __asm__ ("pushf\n\t"
64 "pushf\n\t"
65 "pop %0\n\t"
66 "movl %0,%1\n\t"
67 "xorl $0x200000,%0\n\t"
68 "push %0\n\t"
69 "popf\n\t"
70 "pushf\n\t"
71 "pop %0\n\t"
72 "popf"
73 : "=r" (eax),
74 "=r" (ebx)
75 :
76 : "cc");
77
78 if (eax == ebx) /* no cpuid */
79 return 0;
80
81 cpuid (0x00000000, eax, ebx, ecx, edx);
82 if (!eax) /* vendor string only */
83 return 0;
84
85 AMD = (ebx == 0x68747541) && (ecx == 0x444d4163) && (edx == 0x69746e65);
86
87 cpuid (0x00000001, eax, ebx, ecx, edx);
88 if (! (edx & 0x00800000)) /* no MMX */
89 return 0;
90
91 caps = MPEG2_ACCEL_X86_MMX;
92 if (edx & 0x02000000) /* SSE - identical to AMD MMX extensions */
93 caps = MPEG2_ACCEL_X86_MMX | MPEG2_ACCEL_X86_MMXEXT;
94
95 cpuid (0x80000000, eax, ebx, ecx, edx);
96 if (eax < 0x80000001) /* no extended capabilities */
97 return caps;
98
99 cpuid (0x80000001, eax, ebx, ecx, edx);
100
101 if (edx & 0x80000000)
102 caps |= MPEG2_ACCEL_X86_3DNOW;
103
104 if (AMD && (edx & 0x00400000)) /* AMD MMX extensions */
105 caps |= MPEG2_ACCEL_X86_MMXEXT;
106
107 return caps;
108}
109#endif /* ARCH_X86 */
110
111#if defined(ARCH_PPC) || defined(ARCH_SPARC)
112#include <signal.h>
113#include <setjmp.h>
114
115static sigjmp_buf jmpbuf;
116static volatile sig_atomic_t canjump = 0;
117
118static RETSIGTYPE sigill_handler (int sig)
119{
120 if (!canjump) {
121 signal (sig, SIG_DFL);
122 raise (sig);
123 }
124
125 canjump = 0;
126 siglongjmp (jmpbuf, 1);
127}
128
129#ifdef ARCH_PPC
130static inline uint32_t arch_accel (void)
131{
132 static RETSIGTYPE (* oldsig) (int);
133
134 oldsig = signal (SIGILL, sigill_handler);
135 if (sigsetjmp (jmpbuf, 1)) {
136 signal (SIGILL, oldsig);
137 return 0;
138 }
139
140 canjump = 1;
141
142#ifdef HAVE_ALTIVEC_H /* gnu */
143#define VAND(a,b,c) "vand " #a "," #b "," #c "\n\t"
144#else /* apple */
145#define VAND(a,b,c) "vand v" #a ",v" #b ",v" #c "\n\t"
146#endif
147 asm volatile ("mtspr 256, %0\n\t"
148 VAND (0, 0, 0)
149 :
150 : "r" (-1));
151
152 canjump = 0;
153
154 signal (SIGILL, oldsig);
155 return MPEG2_ACCEL_PPC_ALTIVEC;
156}
157#endif /* ARCH_PPC */
158
159#ifdef ARCH_SPARC
160static inline uint32_t arch_accel (void)
161{
162 static RETSIGTYPE (* oldsig) (int);
163
164 oldsig = signal (SIGILL, sigill_handler);
165 if (sigsetjmp (jmpbuf, 1)) {
166 signal (SIGILL, oldsig);
167 return 0;
168 }
169
170 canjump = 1;
171
172 /* pdist %f0, %f0, %f0 */
173 __asm__ __volatile__(".word\t0x81b007c0");
174
175 canjump = 0;
176
177 if (sigsetjmp (jmpbuf, 1)) {
178 signal (SIGILL, oldsig);
179 return MPEG2_ACCEL_SPARC_VIS;
180 }
181
182 canjump = 1;
183
184 /* edge8n %g0, %g0, %g0 */
185 __asm__ __volatile__(".word\t0x81b00020");
186
187 canjump = 0;
188
189 signal (SIGILL, oldsig);
190 return MPEG2_ACCEL_SPARC_VIS | MPEG2_ACCEL_SPARC_VIS2;
191}
192#endif /* ARCH_SPARC */
193#endif /* ARCH_PPC || ARCH_SPARC */
194
195#ifdef ARCH_ALPHA
196static inline uint32_t arch_accel (void)
197{
198 uint64_t no_mvi;
199
200 asm volatile ("amask %1, %0"
201 : "=r" (no_mvi)
202 : "rI" (256)); /* AMASK_MVI */
203 return no_mvi ? MPEG2_ACCEL_ALPHA : (MPEG2_ACCEL_ALPHA |
204 MPEG2_ACCEL_ALPHA_MVI);
205}
206#endif /* ARCH_ALPHA */
207#endif /* ACCEL_DETECT */
208
209uint32_t mpeg2_detect_accel (void)
210{
211 uint32_t accel;
212
213 accel = 0;
214#ifdef ACCEL_DETECT
215#if defined (ARCH_X86) || defined (ARCH_PPC) || defined (ARCH_ALPHA) || defined (ARCH_SPARC)
216 accel = arch_accel ();
217#endif
218#endif
219 return accel;
220}
diff --git a/apps/plugins/mpegplayer/cpu_state.c b/apps/plugins/mpegplayer/cpu_state.c
deleted file mode 100644
index 4406853626..0000000000
--- a/apps/plugins/mpegplayer/cpu_state.c
+++ /dev/null
@@ -1,129 +0,0 @@
1/*
2 * cpu_state.c
3 * Copyright (C) 2000-2003 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 "plugin.h"
25
26#include "mpeg2dec_config.h"
27
28#include "mpeg2.h"
29#include "attributes.h"
30#include "mpeg2_internal.h"
31#ifdef ARCH_X86
32#include "mmx.h"
33#endif
34
35void (* mpeg2_cpu_state_save) (cpu_state_t * state) = NULL;
36void (* mpeg2_cpu_state_restore) (cpu_state_t * state) = NULL;
37
38#ifdef ARCH_X86
39static void state_restore_mmx (cpu_state_t * state)
40{
41 emms ();
42}
43#endif
44
45#ifdef ARCH_PPC
46#ifdef HAVE_ALTIVEC_H /* gnu */
47#define LI(a,b) "li " #a "," #b "\n\t"
48#define STVX0(a,b,c) "stvx " #a ",0," #c "\n\t"
49#define STVX(a,b,c) "stvx " #a "," #b "," #c "\n\t"
50#define LVX0(a,b,c) "lvx " #a ",0," #c "\n\t"
51#define LVX(a,b,c) "lvx " #a "," #b "," #c "\n\t"
52#else /* apple */
53#define LI(a,b) "li r" #a "," #b "\n\t"
54#define STVX0(a,b,c) "stvx v" #a ",0,r" #c "\n\t"
55#define STVX(a,b,c) "stvx v" #a ",r" #b ",r" #c "\n\t"
56#define LVX0(a,b,c) "lvx v" #a ",0,r" #c "\n\t"
57#define LVX(a,b,c) "lvx v" #a ",r" #b ",r" #c "\n\t"
58#endif
59
60static void state_save_altivec (cpu_state_t * state)
61{
62 asm (LI (9, 16)
63 STVX0 (20, 0, 3)
64 LI (11, 32)
65 STVX (21, 9, 3)
66 LI (9, 48)
67 STVX (22, 11, 3)
68 LI (11, 64)
69 STVX (23, 9, 3)
70 LI (9, 80)
71 STVX (24, 11, 3)
72 LI (11, 96)
73 STVX (25, 9, 3)
74 LI (9, 112)
75 STVX (26, 11, 3)
76 LI (11, 128)
77 STVX (27, 9, 3)
78 LI (9, 144)
79 STVX (28, 11, 3)
80 LI (11, 160)
81 STVX (29, 9, 3)
82 LI (9, 176)
83 STVX (30, 11, 3)
84 STVX (31, 9, 3));
85}
86
87static void state_restore_altivec (cpu_state_t * state)
88{
89 asm (LI (9, 16)
90 LVX0 (20, 0, 3)
91 LI (11, 32)
92 LVX (21, 9, 3)
93 LI (9, 48)
94 LVX (22, 11, 3)
95 LI (11, 64)
96 LVX (23, 9, 3)
97 LI (9, 80)
98 LVX (24, 11, 3)
99 LI (11, 96)
100 LVX (25, 9, 3)
101 LI (9, 112)
102 LVX (26, 11, 3)
103 LI (11, 128)
104 LVX (27, 9, 3)
105 LI (9, 144)
106 LVX (28, 11, 3)
107 LI (11, 160)
108 LVX (29, 9, 3)
109 LI (9, 176)
110 LVX (30, 11, 3)
111 LVX (31, 9, 3));
112}
113#endif
114
115void mpeg2_cpu_state_init (uint32_t accel)
116{
117 (void)accel;
118#ifdef ARCH_X86
119 if (accel & MPEG2_ACCEL_X86_MMX) {
120 mpeg2_cpu_state_restore = state_restore_mmx;
121 }
122#endif
123#ifdef ARCH_PPC
124 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) {
125 mpeg2_cpu_state_save = state_save_altivec;
126 mpeg2_cpu_state_restore = state_restore_altivec;
127 }
128#endif
129}
diff --git a/apps/plugins/mpegplayer/decode.c b/apps/plugins/mpegplayer/decode.c
index 613292699d..299abc9663 100644
--- a/apps/plugins/mpegplayer/decode.c
+++ b/apps/plugins/mpegplayer/decode.c
@@ -31,8 +31,6 @@ extern struct plugin_api* rb;
31#include "attributes.h" 31#include "attributes.h"
32#include "mpeg2_internal.h" 32#include "mpeg2_internal.h"
33 33
34static int mpeg2_accels = 0;
35
36#define BUFFER_SIZE (1194 * 1024) 34#define BUFFER_SIZE (1194 * 1024)
37 35
38const mpeg2_info_t * mpeg2_info (mpeg2dec_t * mpeg2dec) 36const mpeg2_info_t * mpeg2_info (mpeg2dec_t * mpeg2dec)
@@ -270,7 +268,7 @@ mpeg2_state_t mpeg2_parse_header (mpeg2dec_t * mpeg2dec)
270 break; 268 break;
271 case RECEIVED (0x01, STATE_PICTURE): 269 case RECEIVED (0x01, STATE_PICTURE):
272 case RECEIVED (0x01, STATE_PICTURE_2ND): 270 case RECEIVED (0x01, STATE_PICTURE_2ND):
273 mpeg2_header_picture_finalize (mpeg2dec, mpeg2_accels); 271 mpeg2_header_picture_finalize (mpeg2dec);
274 mpeg2dec->action = mpeg2_header_slice_start; 272 mpeg2dec->action = mpeg2_header_slice_start;
275 break; 273 break;
276 274
@@ -302,7 +300,7 @@ int mpeg2_convert (mpeg2dec_t * mpeg2dec, mpeg2_convert_t convert, void * arg)
302 int error; 300 int error;
303 301
304 error = convert (MPEG2_CONVERT_SET, NULL, &(mpeg2dec->sequence), 0, 302 error = convert (MPEG2_CONVERT_SET, NULL, &(mpeg2dec->sequence), 0,
305 mpeg2_accels, arg, &convert_init); 303 arg, &convert_init);
306 if (!error) { 304 if (!error) {
307 mpeg2dec->convert = convert; 305 mpeg2dec->convert = convert;
308 mpeg2dec->convert_arg = arg; 306 mpeg2dec->convert_arg = arg;
@@ -323,7 +321,7 @@ int mpeg2_stride (mpeg2dec_t * mpeg2dec, int stride)
323 321
324 stride = mpeg2dec->convert (MPEG2_CONVERT_STRIDE, NULL, 322 stride = mpeg2dec->convert (MPEG2_CONVERT_STRIDE, NULL,
325 &(mpeg2dec->sequence), stride, 323 &(mpeg2dec->sequence), stride,
326 mpeg2_accels, mpeg2dec->convert_arg, 324 mpeg2dec->convert_arg,
327 &convert_init); 325 &convert_init);
328 mpeg2dec->convert_id_size = convert_init.id_size; 326 mpeg2dec->convert_id_size = convert_init.id_size;
329 mpeg2dec->convert_stride = stride; 327 mpeg2dec->convert_stride = stride;
@@ -382,19 +380,6 @@ void mpeg2_tag_picture (mpeg2dec_t * mpeg2dec, uint32_t tag, uint32_t tag2)
382 mpeg2dec->bytes_since_tag = 0; 380 mpeg2dec->bytes_since_tag = 0;
383} 381}
384 382
385uint32_t mpeg2_accel (uint32_t accel)
386{
387 if (!mpeg2_accels) {
388 if (accel & MPEG2_ACCEL_DETECT)
389 accel |= mpeg2_detect_accel ();
390 mpeg2_accels = accel |= MPEG2_ACCEL_DETECT;
391 mpeg2_cpu_state_init (accel);
392 mpeg2_idct_init (accel);
393 mpeg2_mc_init (accel);
394 }
395 return mpeg2_accels & ~MPEG2_ACCEL_DETECT;
396}
397
398void mpeg2_reset (mpeg2dec_t * mpeg2dec, int full_reset) 383void mpeg2_reset (mpeg2dec_t * mpeg2dec, int full_reset)
399{ 384{
400 mpeg2dec->buf_start = mpeg2dec->buf_end = NULL; 385 mpeg2dec->buf_start = mpeg2dec->buf_end = NULL;
@@ -420,7 +405,7 @@ mpeg2dec_t * mpeg2_init (void)
420{ 405{
421 mpeg2dec_t * mpeg2dec; 406 mpeg2dec_t * mpeg2dec;
422 407
423 mpeg2_accel (MPEG2_ACCEL_DETECT); 408 mpeg2_idct_init ();
424 409
425 mpeg2dec = (mpeg2dec_t *) mpeg2_malloc (sizeof (mpeg2dec_t), 410 mpeg2dec = (mpeg2dec_t *) mpeg2_malloc (sizeof (mpeg2dec_t),
426 MPEG2_ALLOC_MPEG2DEC); 411 MPEG2_ALLOC_MPEG2DEC);
diff --git a/apps/plugins/mpegplayer/header.c b/apps/plugins/mpegplayer/header.c
index 6e8cfc213a..7f94705f52 100644
--- a/apps/plugins/mpegplayer/header.c
+++ b/apps/plugins/mpegplayer/header.c
@@ -603,7 +603,7 @@ static int picture_display_ext (mpeg2dec_t * mpeg2dec)
603 return 0; 603 return 0;
604} 604}
605 605
606void mpeg2_header_picture_finalize (mpeg2dec_t * mpeg2dec, uint32_t accels) 606void mpeg2_header_picture_finalize (mpeg2dec_t * mpeg2dec)
607{ 607{
608 mpeg2_decoder_t * decoder = &(mpeg2dec->decoder); 608 mpeg2_decoder_t * decoder = &(mpeg2dec->decoder);
609 int old_type_b = (decoder->coding_type == B_TYPE); 609 int old_type_b = (decoder->coding_type == B_TYPE);
@@ -661,7 +661,7 @@ void mpeg2_header_picture_finalize (mpeg2dec_t * mpeg2dec, uint32_t accels)
661 mpeg2dec->convert (MPEG2_CONVERT_START, 661 mpeg2dec->convert (MPEG2_CONVERT_START,
662 mpeg2dec->decoder.convert_id, 662 mpeg2dec->decoder.convert_id,
663 &(mpeg2dec->sequence), 663 &(mpeg2dec->sequence),
664 mpeg2dec->convert_stride, accels, 664 mpeg2dec->convert_stride,
665 mpeg2dec->convert_arg, &convert_init); 665 mpeg2dec->convert_arg, &convert_init);
666 mpeg2dec->convert_start = convert_init.start; 666 mpeg2dec->convert_start = convert_init.start;
667 mpeg2dec->decoder.convert = convert_init.copy; 667 mpeg2dec->decoder.convert = convert_init.copy;
diff --git a/apps/plugins/mpegplayer/idct.c b/apps/plugins/mpegplayer/idct.c
index 7ad78bfcd9..ee02e72a6f 100644
--- a/apps/plugins/mpegplayer/idct.c
+++ b/apps/plugins/mpegplayer/idct.c
@@ -77,18 +77,18 @@ uint8_t mpeg2_clip[3840 * 2 + 256] IBSS_ATTR;
77#endif 77#endif
78 78
79#if 0 79#if 0
80#define BUTTERFLY(t0,t1,W0,W1,d0,d1) \ 80#define BUTTERFLY(t0,t1,W0,W1,d0,d1) \
81do { \ 81 do { \
82 t0 = W0 * d0 + W1 * d1; \ 82 t0 = W0 * d0 + W1 * d1; \
83 t1 = W0 * d1 - W1 * d0; \ 83 t1 = W0 * d1 - W1 * d0; \
84} while (0) 84 } while (0)
85#else 85#else
86#define BUTTERFLY(t0,t1,W0,W1,d0,d1) \ 86#define BUTTERFLY(t0,t1,W0,W1,d0,d1) \
87do { \ 87 do { \
88 int tmp = W0 * (d0 + d1); \ 88 int tmp = W0 * (d0 + d1); \
89 t0 = tmp + (W1 - W0) * d1; \ 89 t0 = tmp + (W1 - W0) * d1; \
90 t1 = tmp - (W1 + W0) * d0; \ 90 t1 = tmp - (W1 + W0) * d0; \
91} while (0) 91 } while (0)
92#endif 92#endif
93 93
94static inline void idct_row (int16_t * const block) 94static inline void idct_row (int16_t * const block)
@@ -258,58 +258,26 @@ static void mpeg2_idct_add_c (const int last, int16_t * block,
258 } 258 }
259} 259}
260 260
261void mpeg2_idct_init (uint32_t accel) 261void mpeg2_idct_init (void)
262{ 262{
263 (void)accel; 263 extern uint8_t mpeg2_scan_norm[64];
264#ifdef ARCH_X86 264 extern uint8_t mpeg2_scan_alt[64];
265 if (accel & MPEG2_ACCEL_X86_MMXEXT) { 265 int i, j;
266 mpeg2_idct_copy = mpeg2_idct_copy_mmxext;
267 mpeg2_idct_add = mpeg2_idct_add_mmxext;
268 mpeg2_idct_mmx_init ();
269 } else if (accel & MPEG2_ACCEL_X86_MMX) {
270 mpeg2_idct_copy = mpeg2_idct_copy_mmx;
271 mpeg2_idct_add = mpeg2_idct_add_mmx;
272 mpeg2_idct_mmx_init ();
273 } else
274#endif
275#ifdef ARCH_PPC
276 if (accel & MPEG2_ACCEL_PPC_ALTIVEC) {
277 mpeg2_idct_copy = mpeg2_idct_copy_altivec;
278 mpeg2_idct_add = mpeg2_idct_add_altivec;
279 mpeg2_idct_altivec_init ();
280 } else
281#endif
282#ifdef ARCH_ALPHA
283 if (accel & MPEG2_ACCEL_ALPHA_MVI) {
284 mpeg2_idct_copy = mpeg2_idct_copy_mvi;
285 mpeg2_idct_add = mpeg2_idct_add_mvi;
286 mpeg2_idct_alpha_init ();
287 } else if (accel & MPEG2_ACCEL_ALPHA) {
288 int i;
289 266
290 mpeg2_idct_copy = mpeg2_idct_copy_alpha; 267 mpeg2_idct_copy = mpeg2_idct_copy_c;
291 mpeg2_idct_add = mpeg2_idct_add_alpha; 268 mpeg2_idct_add = mpeg2_idct_add_c;
292 mpeg2_idct_alpha_init ();
293 for (i = -3840; i < 3840 + 256; i++)
294 CLIP(i) = (i < 0) ? 0 : ((i > 255) ? 255 : i);
295 } else
296#endif
297 {
298 extern uint8_t mpeg2_scan_norm[64];
299 extern uint8_t mpeg2_scan_alt[64];
300 int i, j;
301 269
302 mpeg2_idct_copy = mpeg2_idct_copy_c;
303 mpeg2_idct_add = mpeg2_idct_add_c;
304#if !defined(CPU_COLDFIRE) && !defined(CPU_ARM) 270#if !defined(CPU_COLDFIRE) && !defined(CPU_ARM)
305 for (i = -3840; i < 3840 + 256; i++) 271 for (i = -3840; i < 3840 + 256; i++)
306 CLIP(i) = (i < 0) ? 0 : ((i > 255) ? 255 : i); 272 CLIP(i) = (i < 0) ? 0 : ((i > 255) ? 255 : i);
307#endif 273#endif
308 for (i = 0; i < 64; i++) { 274
309 j = mpeg2_scan_norm[i]; 275 for (i = 0; i < 64; i++)
310 mpeg2_scan_norm[i] = ((j & 0x36) >> 1) | ((j & 0x09) << 2); 276 {
311 j = mpeg2_scan_alt[i]; 277 j = mpeg2_scan_norm[i];
312 mpeg2_scan_alt[i] = ((j & 0x36) >> 1) | ((j & 0x09) << 2); 278 mpeg2_scan_norm[i] = ((j & 0x36) >> 1) | ((j & 0x09) << 2);
313 } 279
280 j = mpeg2_scan_alt[i];
281 mpeg2_scan_alt[i] = ((j & 0x36) >> 1) | ((j & 0x09) << 2);
314 } 282 }
315} 283}
diff --git a/apps/plugins/mpegplayer/motion_comp.c b/apps/plugins/mpegplayer/motion_comp.c
index b2f30c01ff..beb5c00228 100644
--- a/apps/plugins/mpegplayer/motion_comp.c
+++ b/apps/plugins/mpegplayer/motion_comp.c
@@ -29,108 +29,33 @@
29#include "attributes.h" 29#include "attributes.h"
30#include "mpeg2_internal.h" 30#include "mpeg2_internal.h"
31 31
32mpeg2_mc_t mpeg2_mc; 32/* These are defined in their respective target files - motion_comp_X.c */
33 33extern mpeg2_mc_fct MC_put_o_16;
34void mpeg2_mc_init (uint32_t accel) 34extern mpeg2_mc_fct MC_put_o_8;
35extern mpeg2_mc_fct MC_put_x_16;
36extern mpeg2_mc_fct MC_put_x_8;
37extern mpeg2_mc_fct MC_put_y_16;
38extern mpeg2_mc_fct MC_put_y_8;
39extern mpeg2_mc_fct MC_put_xy_16;
40extern mpeg2_mc_fct MC_put_xy_8;
41
42extern mpeg2_mc_fct MC_avg_o_16;
43extern mpeg2_mc_fct MC_avg_o_8;
44extern mpeg2_mc_fct MC_avg_x_16;
45extern mpeg2_mc_fct MC_avg_x_8;
46extern mpeg2_mc_fct MC_avg_y_16;
47extern mpeg2_mc_fct MC_avg_y_8;
48extern mpeg2_mc_fct MC_avg_xy_16;
49extern mpeg2_mc_fct MC_avg_xy_8;
50
51mpeg2_mc_t mpeg2_mc =
35{ 52{
36 (void)accel; 53 {
37#ifdef ARCH_X86 54 MC_put_o_16, MC_put_x_16, MC_put_y_16, MC_put_xy_16,
38 if (accel & MPEG2_ACCEL_X86_MMXEXT) 55 MC_put_o_8, MC_put_x_8, MC_put_y_8, MC_put_xy_8
39 mpeg2_mc = mpeg2_mc_mmxext; 56 },
40 else if (accel & MPEG2_ACCEL_X86_3DNOW) 57 {
41 mpeg2_mc = mpeg2_mc_3dnow; 58 MC_avg_o_16, MC_avg_x_16, MC_avg_y_16, MC_avg_xy_16,
42 else if (accel & MPEG2_ACCEL_X86_MMX) 59 MC_avg_o_8, MC_avg_x_8, MC_avg_y_8, MC_avg_xy_8
43 mpeg2_mc = mpeg2_mc_mmx; 60 }
44 else 61};
45#endif
46#ifdef ARCH_PPC
47 if (accel & MPEG2_ACCEL_PPC_ALTIVEC)
48 mpeg2_mc = mpeg2_mc_altivec;
49 else
50#endif
51#ifdef ARCH_ALPHA
52 if (accel & MPEG2_ACCEL_ALPHA)
53 mpeg2_mc = mpeg2_mc_alpha;
54 else
55#endif
56#ifdef ARCH_SPARC
57 if (accel & MPEG2_ACCEL_SPARC_VIS)
58 mpeg2_mc = mpeg2_mc_vis;
59 else
60#endif
61
62#ifdef CPU_ARM
63 mpeg2_mc = mpeg2_mc_arm;
64#else
65 mpeg2_mc = mpeg2_mc_c;
66#endif
67}
68
69#define avg2(a,b) ((a+b+1)>>1)
70#define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
71
72#define predict_o(i) (ref[i])
73#define predict_x(i) (avg2 (ref[i], ref[i+1]))
74#define predict_y(i) (avg2 (ref[i], (ref+stride)[i]))
75#define predict_xy(i) (avg4 (ref[i], ref[i+1], \
76 (ref+stride)[i], (ref+stride)[i+1]))
77
78#define put(predictor,i) dest[i] = predictor (i)
79#define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i])
80
81/* mc function template */
82
83#define MC_FUNC(op,xy) \
84static void MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \
85 const int stride, int height) \
86{ \
87 do { \
88 op (predict_##xy, 0); \
89 op (predict_##xy, 1); \
90 op (predict_##xy, 2); \
91 op (predict_##xy, 3); \
92 op (predict_##xy, 4); \
93 op (predict_##xy, 5); \
94 op (predict_##xy, 6); \
95 op (predict_##xy, 7); \
96 op (predict_##xy, 8); \
97 op (predict_##xy, 9); \
98 op (predict_##xy, 10); \
99 op (predict_##xy, 11); \
100 op (predict_##xy, 12); \
101 op (predict_##xy, 13); \
102 op (predict_##xy, 14); \
103 op (predict_##xy, 15); \
104 ref += stride; \
105 dest += stride; \
106 } while (--height); \
107} \
108static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, \
109 const int stride, int height) \
110{ \
111 do { \
112 op (predict_##xy, 0); \
113 op (predict_##xy, 1); \
114 op (predict_##xy, 2); \
115 op (predict_##xy, 3); \
116 op (predict_##xy, 4); \
117 op (predict_##xy, 5); \
118 op (predict_##xy, 6); \
119 op (predict_##xy, 7); \
120 ref += stride; \
121 dest += stride; \
122 } while (--height); \
123}
124
125/* definitions of the actual mc functions */
126
127MC_FUNC (put,o)
128MC_FUNC (avg,o)
129MC_FUNC (put,x)
130MC_FUNC (avg,x)
131MC_FUNC (put,y)
132MC_FUNC (avg,y)
133MC_FUNC (put,xy)
134MC_FUNC (avg,xy)
135
136MPEG2_MC_EXTERN (c)
diff --git a/apps/plugins/mpegplayer/motion_comp.h b/apps/plugins/mpegplayer/motion_comp.h
new file mode 100644
index 0000000000..2823cc6da1
--- /dev/null
+++ b/apps/plugins/mpegplayer/motion_comp.h
@@ -0,0 +1,84 @@
1/*
2 * motion_comp.h
3 * Copyright (C) 2000-2003 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
25#define avg2(a,b) ((a+b+1)>>1)
26#define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
27
28#define predict_o(i) (ref[i])
29#define predict_x(i) (avg2 (ref[i], ref[i+1]))
30#define predict_y(i) (avg2 (ref[i], (ref+stride)[i]))
31#define predict_xy(i) (avg4 (ref[i], ref[i+1], \
32 (ref+stride)[i], (ref+stride)[i+1]))
33
34#define put(predictor,i) dest[i] = predictor (i)
35#define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i])
36
37/* mc function template */
38#define MC_FUNC(op, xy) \
39 MC_FUNC_16(op, xy) \
40 MC_FUNC_8(op, xy)
41
42#define MC_FUNC_16(op, xy) \
43 void MC_##op##_##xy##_16 (uint8_t * dest, const uint8_t * ref, \
44 const int stride, int height) \
45 { \
46 do { \
47 op (predict_##xy, 0); \
48 op (predict_##xy, 1); \
49 op (predict_##xy, 2); \
50 op (predict_##xy, 3); \
51 op (predict_##xy, 4); \
52 op (predict_##xy, 5); \
53 op (predict_##xy, 6); \
54 op (predict_##xy, 7); \
55 op (predict_##xy, 8); \
56 op (predict_##xy, 9); \
57 op (predict_##xy, 10); \
58 op (predict_##xy, 11); \
59 op (predict_##xy, 12); \
60 op (predict_##xy, 13); \
61 op (predict_##xy, 14); \
62 op (predict_##xy, 15); \
63 ref += stride; \
64 dest += stride; \
65 } while (--height); \
66 }
67
68#define MC_FUNC_8(op, xy) \
69 void MC_##op##_##xy##_8 (uint8_t * dest, const uint8_t * ref, \
70 const int stride, int height) \
71 { \
72 do { \
73 op (predict_##xy, 0); \
74 op (predict_##xy, 1); \
75 op (predict_##xy, 2); \
76 op (predict_##xy, 3); \
77 op (predict_##xy, 4); \
78 op (predict_##xy, 5); \
79 op (predict_##xy, 6); \
80 op (predict_##xy, 7); \
81 ref += stride; \
82 dest += stride; \
83 } while (--height); \
84 }
diff --git a/apps/plugins/mpegplayer/motion_comp_arm.c b/apps/plugins/mpegplayer/motion_comp_arm.c
deleted file mode 100644
index ec9eddab72..0000000000
--- a/apps/plugins/mpegplayer/motion_comp_arm.c
+++ /dev/null
@@ -1,183 +0,0 @@
1/*
2 * motion_comp_arm.c
3 * Copyright (C) 2004 AGAWA Koji <i (AT) atty (DOT) jp>
4 *
5 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
6 * See http://libmpeg2.sourceforge.net/ for updates.
7 *
8 * mpeg2dec is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * mpeg2dec is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include "mpeg2dec_config.h"
24
25#include <inttypes.h>
26
27#include "mpeg2.h"
28#include "attributes.h"
29#include "mpeg2_internal.h"
30
31#define avg2(a,b) ((a+b+1)>>1)
32#define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
33
34#define predict_o(i) (ref[i])
35#define predict_x(i) (avg2 (ref[i], ref[i+1]))
36#define predict_y(i) (avg2 (ref[i], (ref+stride)[i]))
37#define predict_xy(i) (avg4 (ref[i], ref[i+1], \
38 (ref+stride)[i], (ref+stride)[i+1]))
39
40#define put(predictor,i) dest[i] = predictor (i)
41#define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i])
42
43/* mc function template */
44
45#define MC_FUNC(op,xy) \
46inline static void MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \
47 const int stride, int height) \
48{ \
49 do { \
50 op (predict_##xy, 0); \
51 op (predict_##xy, 1); \
52 op (predict_##xy, 2); \
53 op (predict_##xy, 3); \
54 op (predict_##xy, 4); \
55 op (predict_##xy, 5); \
56 op (predict_##xy, 6); \
57 op (predict_##xy, 7); \
58 op (predict_##xy, 8); \
59 op (predict_##xy, 9); \
60 op (predict_##xy, 10); \
61 op (predict_##xy, 11); \
62 op (predict_##xy, 12); \
63 op (predict_##xy, 13); \
64 op (predict_##xy, 14); \
65 op (predict_##xy, 15); \
66 ref += stride; \
67 dest += stride; \
68 } while (--height); \
69} \
70static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, \
71 const int stride, int height) \
72{ \
73 do { \
74 op (predict_##xy, 0); \
75 op (predict_##xy, 1); \
76 op (predict_##xy, 2); \
77 op (predict_##xy, 3); \
78 op (predict_##xy, 4); \
79 op (predict_##xy, 5); \
80 op (predict_##xy, 6); \
81 op (predict_##xy, 7); \
82 ref += stride; \
83 dest += stride; \
84 } while (--height); \
85} \
86/* definitions of the actual mc functions */
87
88/* MC_FUNC (put,o) */
89MC_FUNC (avg,o)
90/* MC_FUNC (put,x) */
91MC_FUNC (avg,x)
92MC_FUNC (put,y)
93MC_FUNC (avg,y)
94MC_FUNC (put,xy)
95MC_FUNC (avg,xy)
96
97
98extern void MC_put_o_16_arm (uint8_t * dest, const uint8_t * ref,
99 int stride, int height);
100
101extern void MC_put_x_16_arm (uint8_t * dest, const uint8_t * ref,
102 int stride, int height);
103
104
105static void MC_put_y_16_arm (uint8_t * dest, const uint8_t * ref,
106 int stride, int height)
107{
108 MC_put_y_16_c(dest, ref, stride, height);
109}
110
111static void MC_put_xy_16_arm (uint8_t * dest, const uint8_t * ref,
112 int stride, int height)
113{
114 MC_put_xy_16_c(dest, ref, stride, height);
115}
116
117extern void MC_put_o_8_arm (uint8_t * dest, const uint8_t * ref,
118 int stride, int height);
119
120extern void MC_put_x_8_arm (uint8_t * dest, const uint8_t * ref,
121 int stride, int height);
122
123static void MC_put_y_8_arm (uint8_t * dest, const uint8_t * ref,
124 int stride, int height)
125{
126 MC_put_y_8_c(dest, ref, stride, height);
127}
128
129static void MC_put_xy_8_arm (uint8_t * dest, const uint8_t * ref,
130 int stride, int height)
131{
132 MC_put_xy_8_c(dest, ref, stride, height);
133}
134
135static void MC_avg_o_16_arm (uint8_t * dest, const uint8_t * ref,
136 int stride, int height)
137{
138 MC_avg_o_16_c(dest, ref, stride, height);
139}
140
141static void MC_avg_x_16_arm (uint8_t * dest, const uint8_t * ref,
142 int stride, int height)
143{
144 MC_avg_x_16_c(dest, ref, stride, height);
145}
146
147static void MC_avg_y_16_arm (uint8_t * dest, const uint8_t * ref,
148 int stride, int height)
149{
150 MC_avg_y_16_c(dest, ref, stride, height);
151}
152
153static void MC_avg_xy_16_arm (uint8_t * dest, const uint8_t * ref,
154 int stride, int height)
155{
156 MC_avg_xy_16_c(dest, ref, stride, height);
157}
158
159static void MC_avg_o_8_arm (uint8_t * dest, const uint8_t * ref,
160 int stride, int height)
161{
162 MC_avg_o_8_c(dest, ref, stride, height);
163}
164
165static void MC_avg_x_8_arm (uint8_t * dest, const uint8_t * ref,
166 int stride, int height)
167{
168 MC_avg_x_8_c(dest, ref, stride, height);
169}
170
171static void MC_avg_y_8_arm (uint8_t * dest, const uint8_t * ref,
172 int stride, int height)
173{
174 MC_avg_y_8_c(dest, ref, stride, height);
175}
176
177static void MC_avg_xy_8_arm (uint8_t * dest, const uint8_t * ref,
178 int stride, int height)
179{
180 MC_avg_xy_8_c(dest, ref, stride, height);
181}
182
183MPEG2_MC_EXTERN (arm)
diff --git a/apps/plugins/mpegplayer/motion_comp_arm_c.c b/apps/plugins/mpegplayer/motion_comp_arm_c.c
new file mode 100644
index 0000000000..1d0f9d22fc
--- /dev/null
+++ b/apps/plugins/mpegplayer/motion_comp_arm_c.c
@@ -0,0 +1,37 @@
1/*
2 * motion_comp_arm.c
3 * Copyright (C) 2004 AGAWA Koji <i (AT) atty (DOT) jp>
4 *
5 * This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
6 * See http://libmpeg2.sourceforge.net/ for updates.
7 *
8 * mpeg2dec is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * mpeg2dec is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22#include <inttypes.h>
23#include "mpeg2.h"
24#include "attributes.h"
25#include "mpeg2_internal.h"
26#include "motion_comp.h"
27
28/* definitions of the actual mc functions */
29
30/* MC_FUNC (put, o) <= ASM */
31MC_FUNC (avg, o)
32/* MC_FUNC (put, x) <= ASM */
33MC_FUNC (avg, x)
34MC_FUNC (put, y)
35MC_FUNC (avg, y)
36MC_FUNC (put, xy)
37MC_FUNC (avg, xy)
diff --git a/apps/plugins/mpegplayer/motion_comp_arm_s.S b/apps/plugins/mpegplayer/motion_comp_arm_s.S
index 82be8e6a8e..e515f8b516 100644
--- a/apps/plugins/mpegplayer/motion_comp_arm_s.S
+++ b/apps/plugins/mpegplayer/motion_comp_arm_s.S
@@ -22,24 +22,24 @@
22 22
23@ ---------------------------------------------------------------- 23@ ----------------------------------------------------------------
24 .align 24 .align
25 .global MC_put_o_16_arm 25 .global MC_put_o_16
26MC_put_o_16_arm: 26MC_put_o_16:
27 @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height) 27 @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
28 @@ pld [r1] 28 @@ pld [r1]
29 stmfd sp!, {r4-r11, lr} @ R14 is also called LR 29 stmfd sp!, {r4-r11, lr} @ R14 is also called LR
30 and r4, r1, #3 30 and r4, r1, #3
31 adr r5, MC_put_o_16_arm_align_jt 31 adr r5, MC_put_o_16_align_jt
32 add r5, r5, r4, lsl #2 32 add r5, r5, r4, lsl #2
33 ldr pc, [r5] 33 ldr pc, [r5]
34 34
35MC_put_o_16_arm_align0: 35MC_put_o_16_align0:
36 ldmia r1, {r4-r7} 36 ldmia r1, {r4-r7}
37 add r1, r1, r2 37 add r1, r1, r2
38 @@ pld [r1] 38 @@ pld [r1]
39 stmia r0, {r4-r7} 39 stmia r0, {r4-r7}
40 subs r3, r3, #1 40 subs r3, r3, #1
41 add r0, r0, r2 41 add r0, r0, r2
42 bne MC_put_o_16_arm_align0 42 bne MC_put_o_16_align0
43 ldmfd sp!, {r4-r11, pc} @@ update PC with LR content. 43 ldmfd sp!, {r4-r11, pc} @@ update PC with LR content.
44 44
45.macro PROC shift 45.macro PROC shift
@@ -59,46 +59,46 @@ MC_put_o_16_arm_align0:
59 add r0, r0, r2 59 add r0, r0, r2
60.endm 60.endm
61 61
62MC_put_o_16_arm_align1: 62MC_put_o_16_align1:
63 and r1, r1, #0xFFFFFFFC 63 and r1, r1, #0xFFFFFFFC
641: PROC(8) 641: PROC(8)
65 bne 1b 65 bne 1b
66 ldmfd sp!, {r4-r11, pc} @@ update PC with LR content. 66 ldmfd sp!, {r4-r11, pc} @@ update PC with LR content.
67MC_put_o_16_arm_align2: 67MC_put_o_16_align2:
68 and r1, r1, #0xFFFFFFFC 68 and r1, r1, #0xFFFFFFFC
691: PROC(16) 691: PROC(16)
70 bne 1b 70 bne 1b
71 ldmfd sp!, {r4-r11, pc} @@ update PC with LR content. 71 ldmfd sp!, {r4-r11, pc} @@ update PC with LR content.
72MC_put_o_16_arm_align3: 72MC_put_o_16_align3:
73 and r1, r1, #0xFFFFFFFC 73 and r1, r1, #0xFFFFFFFC
741: PROC(24) 741: PROC(24)
75 bne 1b 75 bne 1b
76 ldmfd sp!, {r4-r11, pc} @@ update PC with LR content. 76 ldmfd sp!, {r4-r11, pc} @@ update PC with LR content.
77MC_put_o_16_arm_align_jt: 77MC_put_o_16_align_jt:
78 .word MC_put_o_16_arm_align0 78 .word MC_put_o_16_align0
79 .word MC_put_o_16_arm_align1 79 .word MC_put_o_16_align1
80 .word MC_put_o_16_arm_align2 80 .word MC_put_o_16_align2
81 .word MC_put_o_16_arm_align3 81 .word MC_put_o_16_align3
82 82
83@ ---------------------------------------------------------------- 83@ ----------------------------------------------------------------
84 .align 84 .align
85 .global MC_put_o_8_arm 85 .global MC_put_o_8
86MC_put_o_8_arm: 86MC_put_o_8:
87 @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height) 87 @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
88 @@ pld [r1] 88 @@ pld [r1]
89 stmfd sp!, {r4-r10, lr} @ R14 is also called LR 89 stmfd sp!, {r4-r10, lr} @ R14 is also called LR
90 and r4, r1, #3 90 and r4, r1, #3
91 adr r5, MC_put_o_8_arm_align_jt 91 adr r5, MC_put_o_8_align_jt
92 add r5, r5, r4, lsl #2 92 add r5, r5, r4, lsl #2
93 ldr pc, [r5] 93 ldr pc, [r5]
94MC_put_o_8_arm_align0: 94MC_put_o_8_align0:
95 ldmia r1, {r4-r5} 95 ldmia r1, {r4-r5}
96 add r1, r1, r2 96 add r1, r1, r2
97 @@ pld [r1] 97 @@ pld [r1]
98 stmia r0, {r4-r5} 98 stmia r0, {r4-r5}
99 add r0, r0, r2 99 add r0, r0, r2
100 subs r3, r3, #1 100 subs r3, r3, #1
101 bne MC_put_o_8_arm_align0 101 bne MC_put_o_8_align0
102 ldmfd sp!, {r4-r10, pc} @@ update PC with LR content. 102 ldmfd sp!, {r4-r10, pc} @@ update PC with LR content.
103 103
104.macro PROC8 shift 104.macro PROC8 shift
@@ -114,29 +114,29 @@ MC_put_o_8_arm_align0:
114 add r0, r0, r2 114 add r0, r0, r2
115.endm 115.endm
116 116
117MC_put_o_8_arm_align1: 117MC_put_o_8_align1:
118 and r1, r1, #0xFFFFFFFC 118 and r1, r1, #0xFFFFFFFC
1191: PROC8(8) 1191: PROC8(8)
120 bne 1b 120 bne 1b
121 ldmfd sp!, {r4-r10, pc} @@ update PC with LR content. 121 ldmfd sp!, {r4-r10, pc} @@ update PC with LR content.
122 122
123MC_put_o_8_arm_align2: 123MC_put_o_8_align2:
124 and r1, r1, #0xFFFFFFFC 124 and r1, r1, #0xFFFFFFFC
1251: PROC8(16) 1251: PROC8(16)
126 bne 1b 126 bne 1b
127 ldmfd sp!, {r4-r10, pc} @@ update PC with LR content. 127 ldmfd sp!, {r4-r10, pc} @@ update PC with LR content.
128 128
129MC_put_o_8_arm_align3: 129MC_put_o_8_align3:
130 and r1, r1, #0xFFFFFFFC 130 and r1, r1, #0xFFFFFFFC
1311: PROC8(24) 1311: PROC8(24)
132 bne 1b 132 bne 1b
133 ldmfd sp!, {r4-r10, pc} @@ update PC with LR content. 133 ldmfd sp!, {r4-r10, pc} @@ update PC with LR content.
134 134
135MC_put_o_8_arm_align_jt: 135MC_put_o_8_align_jt:
136 .word MC_put_o_8_arm_align0 136 .word MC_put_o_8_align0
137 .word MC_put_o_8_arm_align1 137 .word MC_put_o_8_align1
138 .word MC_put_o_8_arm_align2 138 .word MC_put_o_8_align2
139 .word MC_put_o_8_arm_align3 139 .word MC_put_o_8_align3
140 140
141@ ---------------------------------------------------------------- 141@ ----------------------------------------------------------------
142.macro AVG_PW rW1, rW2 142.macro AVG_PW rW1, rW2
@@ -151,13 +151,13 @@ MC_put_o_8_arm_align_jt:
151.endm 151.endm
152 152
153 .align 153 .align
154 .global MC_put_x_16_arm 154 .global MC_put_x_16
155MC_put_x_16_arm: 155MC_put_x_16:
156 @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height) 156 @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
157 @@ pld [r1] 157 @@ pld [r1]
158 stmfd sp!, {r4-r11,lr} @ R14 is also called LR 158 stmfd sp!, {r4-r11,lr} @ R14 is also called LR
159 and r4, r1, #3 159 and r4, r1, #3
160 adr r5, MC_put_x_16_arm_align_jt 160 adr r5, MC_put_x_16_align_jt
161 ldr r11, [r5] 161 ldr r11, [r5]
162 mvn r12, r11 162 mvn r12, r11
163 add r5, r5, r4, lsl #2 163 add r5, r5, r4, lsl #2
@@ -176,7 +176,7 @@ MC_put_x_16_arm:
176@ and \R4, \R4, #0xFF 176@ and \R4, \R4, #0xFF
177.endm 177.endm
178 178
179MC_put_x_16_arm_align0: 179MC_put_x_16_align0:
180 ldmia r1, {r4-r8} 180 ldmia r1, {r4-r8}
181 add r1, r1, r2 181 add r1, r1, r2
182 @@ pld [r1] 182 @@ pld [r1]
@@ -187,9 +187,9 @@ MC_put_x_16_arm_align0:
187 stmia r0, {r5-r8} 187 stmia r0, {r5-r8}
188 subs r3, r3, #1 188 subs r3, r3, #1
189 add r0, r0, r2 189 add r0, r0, r2
190 bne MC_put_x_16_arm_align0 190 bne MC_put_x_16_align0
191 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content. 191 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
192MC_put_x_16_arm_align1: 192MC_put_x_16_align1:
193 and r1, r1, #0xFFFFFFFC 193 and r1, r1, #0xFFFFFFFC
1941: ldmia r1, {r4-r8} 1941: ldmia r1, {r4-r8}
195 add r1, r1, r2 195 add r1, r1, r2
@@ -204,7 +204,7 @@ MC_put_x_16_arm_align1:
204 add r0, r0, r2 204 add r0, r0, r2
205 bne 1b 205 bne 1b
206 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content. 206 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
207MC_put_x_16_arm_align2: 207MC_put_x_16_align2:
208 and r1, r1, #0xFFFFFFFC 208 and r1, r1, #0xFFFFFFFC
2091: ldmia r1, {r4-r8} 2091: ldmia r1, {r4-r8}
210 add r1, r1, r2 210 add r1, r1, r2
@@ -219,7 +219,7 @@ MC_put_x_16_arm_align2:
219 add r0, r0, r2 219 add r0, r0, r2
220 bne 1b 220 bne 1b
221 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content. 221 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
222MC_put_x_16_arm_align3: 222MC_put_x_16_align3:
223 and r1, r1, #0xFFFFFFFC 223 and r1, r1, #0xFFFFFFFC
2241: ldmia r1, {r4-r8} 2241: ldmia r1, {r4-r8}
225 add r1, r1, r2 225 add r1, r1, r2
@@ -234,22 +234,22 @@ MC_put_x_16_arm_align3:
234 add r0, r0, r2 234 add r0, r0, r2
235 bne 1b 235 bne 1b
236 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content. 236 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
237MC_put_x_16_arm_align_jt: 237MC_put_x_16_align_jt:
238 .word 0x01010101 238 .word 0x01010101
239 .word MC_put_x_16_arm_align0 239 .word MC_put_x_16_align0
240 .word MC_put_x_16_arm_align1 240 .word MC_put_x_16_align1
241 .word MC_put_x_16_arm_align2 241 .word MC_put_x_16_align2
242 .word MC_put_x_16_arm_align3 242 .word MC_put_x_16_align3
243 243
244@ ---------------------------------------------------------------- 244@ ----------------------------------------------------------------
245 .align 245 .align
246 .global MC_put_x_8_arm 246 .global MC_put_x_8
247MC_put_x_8_arm: 247MC_put_x_8:
248 @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height) 248 @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
249 @@ pld [r1] 249 @@ pld [r1]
250 stmfd sp!, {r4-r11,lr} @ R14 is also called LR 250 stmfd sp!, {r4-r11,lr} @ R14 is also called LR
251 and r4, r1, #3 251 and r4, r1, #3
252 adr r5, MC_put_x_8_arm_align_jt 252 adr r5, MC_put_x_8_align_jt
253 ldr r11, [r5] 253 ldr r11, [r5]
254 mvn r12, r11 254 mvn r12, r11
255 add r5, r5, r4, lsl #2 255 add r5, r5, r4, lsl #2
@@ -264,7 +264,7 @@ MC_put_x_8_arm:
264@ and \R4, \R4, #0xFF 264@ and \R4, \R4, #0xFF
265.endm 265.endm
266 266
267MC_put_x_8_arm_align0: 267MC_put_x_8_align0:
268 ldmia r1, {r4-r6} 268 ldmia r1, {r4-r6}
269 add r1, r1, r2 269 add r1, r1, r2
270 @@ pld [r1] 270 @@ pld [r1]
@@ -273,9 +273,9 @@ MC_put_x_8_arm_align0:
273 stmia r0, {r5-r6} 273 stmia r0, {r5-r6}
274 subs r3, r3, #1 274 subs r3, r3, #1
275 add r0, r0, r2 275 add r0, r0, r2
276 bne MC_put_x_8_arm_align0 276 bne MC_put_x_8_align0
277 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content. 277 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
278MC_put_x_8_arm_align1: 278MC_put_x_8_align1:
279 and r1, r1, #0xFFFFFFFC 279 and r1, r1, #0xFFFFFFFC
2801: ldmia r1, {r4-r6} 2801: ldmia r1, {r4-r6}
281 add r1, r1, r2 281 add r1, r1, r2
@@ -288,7 +288,7 @@ MC_put_x_8_arm_align1:
288 add r0, r0, r2 288 add r0, r0, r2
289 bne 1b 289 bne 1b
290 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content. 290 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
291MC_put_x_8_arm_align2: 291MC_put_x_8_align2:
292 and r1, r1, #0xFFFFFFFC 292 and r1, r1, #0xFFFFFFFC
2931: ldmia r1, {r4-r6} 2931: ldmia r1, {r4-r6}
294 add r1, r1, r2 294 add r1, r1, r2
@@ -301,7 +301,7 @@ MC_put_x_8_arm_align2:
301 add r0, r0, r2 301 add r0, r0, r2
302 bne 1b 302 bne 1b
303 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content. 303 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
304MC_put_x_8_arm_align3: 304MC_put_x_8_align3:
305 and r1, r1, #0xFFFFFFFC 305 and r1, r1, #0xFFFFFFFC
3061: ldmia r1, {r4-r6} 3061: ldmia r1, {r4-r6}
307 add r1, r1, r2 307 add r1, r1, r2
@@ -314,9 +314,9 @@ MC_put_x_8_arm_align3:
314 add r0, r0, r2 314 add r0, r0, r2
315 bne 1b 315 bne 1b
316 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content. 316 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
317MC_put_x_8_arm_align_jt: 317MC_put_x_8_align_jt:
318 .word 0x01010101 318 .word 0x01010101
319 .word MC_put_x_8_arm_align0 319 .word MC_put_x_8_align0
320 .word MC_put_x_8_arm_align1 320 .word MC_put_x_8_align1
321 .word MC_put_x_8_arm_align2 321 .word MC_put_x_8_align2
322 .word MC_put_x_8_arm_align3 322 .word MC_put_x_8_align3
diff --git a/apps/plugins/mpegplayer/mpeg2.h b/apps/plugins/mpegplayer/mpeg2.h
index 6062f93010..01b3de49eb 100644
--- a/apps/plugins/mpegplayer/mpeg2.h
+++ b/apps/plugins/mpegplayer/mpeg2.h
@@ -144,24 +144,12 @@ typedef enum {
144} mpeg2_convert_stage_t; 144} mpeg2_convert_stage_t;
145typedef int mpeg2_convert_t (int stage, void * id, 145typedef int mpeg2_convert_t (int stage, void * id,
146 const mpeg2_sequence_t * sequence, int stride, 146 const mpeg2_sequence_t * sequence, int stride,
147 uint32_t accel, void * arg, 147 void * arg, mpeg2_convert_init_t * result);
148 mpeg2_convert_init_t * result);
149int mpeg2_convert (mpeg2dec_t * mpeg2dec, mpeg2_convert_t convert, void * arg); 148int mpeg2_convert (mpeg2dec_t * mpeg2dec, mpeg2_convert_t convert, void * arg);
150int mpeg2_stride (mpeg2dec_t * mpeg2dec, int stride); 149int mpeg2_stride (mpeg2dec_t * mpeg2dec, int stride);
151void mpeg2_set_buf (mpeg2dec_t * mpeg2dec, uint8_t * buf[3], void * id); 150void mpeg2_set_buf (mpeg2dec_t * mpeg2dec, uint8_t * buf[3], void * id);
152void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf); 151void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf);
153 152
154#define MPEG2_ACCEL_X86_MMX 1
155#define MPEG2_ACCEL_X86_3DNOW 2
156#define MPEG2_ACCEL_X86_MMXEXT 4
157#define MPEG2_ACCEL_PPC_ALTIVEC 1
158#define MPEG2_ACCEL_ALPHA 1
159#define MPEG2_ACCEL_ALPHA_MVI 2
160#define MPEG2_ACCEL_SPARC_VIS 1
161#define MPEG2_ACCEL_SPARC_VIS2 2
162#define MPEG2_ACCEL_DETECT 0x80000000
163
164uint32_t mpeg2_accel (uint32_t accel);
165mpeg2dec_t * mpeg2_init (void); 153mpeg2dec_t * mpeg2_init (void);
166const mpeg2_info_t * mpeg2_info (mpeg2dec_t * mpeg2dec); 154const mpeg2_info_t * mpeg2_info (mpeg2dec_t * mpeg2dec);
167void mpeg2_close (mpeg2dec_t * mpeg2dec); 155void mpeg2_close (mpeg2dec_t * mpeg2dec);
diff --git a/apps/plugins/mpegplayer/mpeg2_internal.h b/apps/plugins/mpegplayer/mpeg2_internal.h
index 443b6d6114..0c552b766f 100644
--- a/apps/plugins/mpegplayer/mpeg2_internal.h
+++ b/apps/plugins/mpegplayer/mpeg2_internal.h
@@ -244,58 +244,18 @@ int mpeg2_header_extension (mpeg2dec_t * mpeg2dec);
244int mpeg2_header_user_data (mpeg2dec_t * mpeg2dec); 244int mpeg2_header_user_data (mpeg2dec_t * mpeg2dec);
245void mpeg2_header_sequence_finalize (mpeg2dec_t * mpeg2dec); 245void mpeg2_header_sequence_finalize (mpeg2dec_t * mpeg2dec);
246void mpeg2_header_gop_finalize (mpeg2dec_t * mpeg2dec); 246void mpeg2_header_gop_finalize (mpeg2dec_t * mpeg2dec);
247void mpeg2_header_picture_finalize (mpeg2dec_t * mpeg2dec, uint32_t accels); 247void mpeg2_header_picture_finalize (mpeg2dec_t * mpeg2dec);
248mpeg2_state_t mpeg2_header_slice_start (mpeg2dec_t * mpeg2dec); 248mpeg2_state_t mpeg2_header_slice_start (mpeg2dec_t * mpeg2dec);
249mpeg2_state_t mpeg2_header_end (mpeg2dec_t * mpeg2dec); 249mpeg2_state_t mpeg2_header_end (mpeg2dec_t * mpeg2dec);
250void mpeg2_set_fbuf (mpeg2dec_t * mpeg2dec, int b_type); 250void mpeg2_set_fbuf (mpeg2dec_t * mpeg2dec, int b_type);
251 251
252/* idct.c */ 252/* idct.c */
253void mpeg2_idct_init (uint32_t accel); 253void mpeg2_idct_init (void);
254
255/* idct_mmx.c */
256void mpeg2_idct_copy_mmxext (int16_t * block, uint8_t * dest, int stride);
257void mpeg2_idct_add_mmxext (int last, int16_t * block,
258 uint8_t * dest, int stride);
259void mpeg2_idct_copy_mmx (int16_t * block, uint8_t * dest, int stride);
260void mpeg2_idct_add_mmx (int last, int16_t * block,
261 uint8_t * dest, int stride);
262void mpeg2_idct_mmx_init (void);
263
264/* idct_altivec.c */
265void mpeg2_idct_copy_altivec (int16_t * block, uint8_t * dest, int stride);
266void mpeg2_idct_add_altivec (int last, int16_t * block,
267 uint8_t * dest, int stride);
268void mpeg2_idct_altivec_init (void);
269
270/* idct_alpha.c */
271void mpeg2_idct_copy_mvi (int16_t * block, uint8_t * dest, int stride);
272void mpeg2_idct_add_mvi (int last, int16_t * block,
273 uint8_t * dest, int stride);
274void mpeg2_idct_copy_alpha (int16_t * block, uint8_t * dest, int stride);
275void mpeg2_idct_add_alpha (int last, int16_t * block,
276 uint8_t * dest, int stride);
277void mpeg2_idct_alpha_init (void);
278 254
279/* motion_comp.c */ 255/* motion_comp.c */
280void mpeg2_mc_init (uint32_t accel); 256void mpeg2_mc_init (void);
281 257
282typedef struct { 258typedef struct {
283 mpeg2_mc_fct * put [8]; 259 mpeg2_mc_fct * put [8];
284 mpeg2_mc_fct * avg [8]; 260 mpeg2_mc_fct * avg [8];
285} mpeg2_mc_t; 261} mpeg2_mc_t;
286
287#define MPEG2_MC_EXTERN(x) mpeg2_mc_t mpeg2_mc_##x = { \
288 {MC_put_o_16_##x, MC_put_x_16_##x, MC_put_y_16_##x, MC_put_xy_16_##x, \
289 MC_put_o_8_##x, MC_put_x_8_##x, MC_put_y_8_##x, MC_put_xy_8_##x}, \
290 {MC_avg_o_16_##x, MC_avg_x_16_##x, MC_avg_y_16_##x, MC_avg_xy_16_##x, \
291 MC_avg_o_8_##x, MC_avg_x_8_##x, MC_avg_y_8_##x, MC_avg_xy_8_##x} \
292};
293
294extern mpeg2_mc_t mpeg2_mc_c;
295extern mpeg2_mc_t mpeg2_mc_mmx;
296extern mpeg2_mc_t mpeg2_mc_mmxext;
297extern mpeg2_mc_t mpeg2_mc_3dnow;
298extern mpeg2_mc_t mpeg2_mc_altivec;
299extern mpeg2_mc_t mpeg2_mc_alpha;
300extern mpeg2_mc_t mpeg2_mc_vis;
301extern mpeg2_mc_t mpeg2_mc_arm;
diff --git a/apps/plugins/mpegplayer/slice.c b/apps/plugins/mpegplayer/slice.c
index 8ee341739d..7c1c07bf37 100644
--- a/apps/plugins/mpegplayer/slice.c
+++ b/apps/plugins/mpegplayer/slice.c
@@ -34,8 +34,6 @@ extern mpeg2_mc_t mpeg2_mc;
34extern void (* mpeg2_idct_copy) (int16_t * block, uint8_t * dest, int stride); 34extern void (* mpeg2_idct_copy) (int16_t * block, uint8_t * dest, int stride);
35extern void (* mpeg2_idct_add) (int last, int16_t * block, 35extern void (* mpeg2_idct_add) (int last, int16_t * block,
36 uint8_t * dest, int stride); 36 uint8_t * dest, int stride);
37extern void (* mpeg2_cpu_state_save) (cpu_state_t * state);
38extern void (* mpeg2_cpu_state_restore) (cpu_state_t * state);
39 37
40#include "vlc.h" 38#include "vlc.h"
41 39
@@ -1554,39 +1552,36 @@ static void motion_fi_conceal (mpeg2_decoder_t * const decoder)
1554#undef bits 1552#undef bits
1555#undef bit_ptr 1553#undef bit_ptr
1556 1554
1557#define MOTION_CALL(routine,direction) \ 1555#define MOTION_CALL(routine,direction) \
1558do { \ 1556do { \
1559 if ((direction) & MACROBLOCK_MOTION_FORWARD) \ 1557 if ((direction) & MACROBLOCK_MOTION_FORWARD) \
1560 routine (decoder, &(decoder->f_motion), mpeg2_mc.put); \ 1558 routine (decoder, &(decoder->f_motion), mpeg2_mc.put); \
1561 if ((direction) & MACROBLOCK_MOTION_BACKWARD) \ 1559 if ((direction) & MACROBLOCK_MOTION_BACKWARD) \
1562 routine (decoder, &(decoder->b_motion), \ 1560 routine (decoder, &(decoder->b_motion), \
1563 ((direction) & MACROBLOCK_MOTION_FORWARD ? \ 1561 ((direction) & MACROBLOCK_MOTION_FORWARD ? \
1564 mpeg2_mc.avg : mpeg2_mc.put)); \ 1562 mpeg2_mc.avg : mpeg2_mc.put)); \
1565} while (0) 1563} while (0)
1566 1564
1567#define NEXT_MACROBLOCK \ 1565#define NEXT_MACROBLOCK \
1568do { \ 1566do { \
1569 decoder->offset += 16; \ 1567 decoder->offset += 16; \
1570 if (decoder->offset == decoder->width) { \ 1568 if (decoder->offset == decoder->width) { \
1571 do { /* just so we can use the break statement */ \ 1569 do { /* just so we can use the break statement */ \
1572 if (decoder->convert) { \ 1570 if (decoder->convert) { \
1573 decoder->convert (decoder->convert_id, decoder->dest, \ 1571 decoder->convert (decoder->convert_id, decoder->dest, \
1574 decoder->v_offset); \ 1572 decoder->v_offset); \
1575 if (decoder->coding_type == B_TYPE) \ 1573 if (decoder->coding_type == B_TYPE) \
1576 break; \ 1574 break; \
1577 } \ 1575 } \
1578 decoder->dest[0] += decoder->slice_stride; \ 1576 decoder->dest[0] += decoder->slice_stride; \
1579 decoder->dest[1] += decoder->slice_uv_stride; \ 1577 decoder->dest[1] += decoder->slice_uv_stride; \
1580 decoder->dest[2] += decoder->slice_uv_stride; \ 1578 decoder->dest[2] += decoder->slice_uv_stride; \
1581 } while (0); \ 1579 } while (0); \
1582 decoder->v_offset += 16; \ 1580 decoder->v_offset += 16; \
1583 if (decoder->v_offset > decoder->limit_y) { \ 1581 if (decoder->v_offset > decoder->limit_y) \
1584 if (mpeg2_cpu_state_restore) \ 1582 return; \
1585 mpeg2_cpu_state_restore (&cpu_state); \ 1583 decoder->offset = 0; \
1586 return; \ 1584 } \
1587 } \
1588 decoder->offset = 0; \
1589 } \
1590} while (0) 1585} while (0)
1591 1586
1592void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3], 1587void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3],
@@ -1780,16 +1775,12 @@ void mpeg2_slice (mpeg2_decoder_t * const decoder, const int code,
1780#define bit_buf (decoder->bitstream_buf) 1775#define bit_buf (decoder->bitstream_buf)
1781#define bits (decoder->bitstream_bits) 1776#define bits (decoder->bitstream_bits)
1782#define bit_ptr (decoder->bitstream_ptr) 1777#define bit_ptr (decoder->bitstream_ptr)
1783 cpu_state_t cpu_state;
1784 1778
1785 bitstream_init (decoder, buffer); 1779 bitstream_init (decoder, buffer);
1786 1780
1787 if (slice_init (decoder, code)) 1781 if (slice_init (decoder, code))
1788 return; 1782 return;
1789 1783
1790 if (mpeg2_cpu_state_save)
1791 mpeg2_cpu_state_save (&cpu_state);
1792
1793 while (1) { 1784 while (1) {
1794 int macroblock_modes; 1785 int macroblock_modes;
1795 int mba_inc; 1786 int mba_inc;
@@ -2028,8 +2019,6 @@ void mpeg2_slice (mpeg2_decoder_t * const decoder, const int code,
2028 NEEDBITS (bit_buf, bits, bit_ptr); 2019 NEEDBITS (bit_buf, bits, bit_ptr);
2029 continue; 2020 continue;
2030 default: /* end of slice, or error */ 2021 default: /* end of slice, or error */
2031 if (mpeg2_cpu_state_restore)
2032 mpeg2_cpu_state_restore (&cpu_state);
2033 return; 2022 return;
2034 } 2023 }
2035 } 2024 }