summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoen Hirschberg <marcoen@gmail.com>2007-04-05 09:56:28 +0000
committerMarcoen Hirschberg <marcoen@gmail.com>2007-04-05 09:56:28 +0000
commit80d882105e11acd44dfb7cc69a766136dbeee906 (patch)
treec0e0e9d5927486d59bb05c7c69d99a3eb812cf1e
parent78585318b5170f642cabe012e72c955ca6d9ccc8 (diff)
downloadrockbox-80d882105e11acd44dfb7cc69a766136dbeee906.tar.gz
rockbox-80d882105e11acd44dfb7cc69a766136dbeee906.zip
optimized motion compensation for ARM from the mplayer-w100 project. Elefants Dream plays back 2.3fps faster on the Gigabeat
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13032 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/mpegplayer/SOURCES4
-rw-r--r--apps/plugins/mpegplayer/motion_comp.c5
-rw-r--r--apps/plugins/mpegplayer/motion_comp_arm.c183
-rw-r--r--apps/plugins/mpegplayer/motion_comp_arm_s.S322
-rw-r--r--apps/plugins/mpegplayer/mpeg2_internal.h1
5 files changed, 515 insertions, 0 deletions
diff --git a/apps/plugins/mpegplayer/SOURCES b/apps/plugins/mpegplayer/SOURCES
index 4646599440..fc23a2ab11 100644
--- a/apps/plugins/mpegplayer/SOURCES
+++ b/apps/plugins/mpegplayer/SOURCES
@@ -5,6 +5,10 @@ decode.c
5header.c 5header.c
6idct.c 6idct.c
7motion_comp.c 7motion_comp.c
8#ifdef CPU_ARM
9motion_comp_arm.c
10motion_comp_arm_s.S
11#endif
8slice.c 12slice.c
9video_out_rockbox.c 13video_out_rockbox.c
10mpeg_settings.c 14mpeg_settings.c
diff --git a/apps/plugins/mpegplayer/motion_comp.c b/apps/plugins/mpegplayer/motion_comp.c
index fbf2ee1eb4..b2f30c01ff 100644
--- a/apps/plugins/mpegplayer/motion_comp.c
+++ b/apps/plugins/mpegplayer/motion_comp.c
@@ -58,7 +58,12 @@ void mpeg2_mc_init (uint32_t accel)
58 mpeg2_mc = mpeg2_mc_vis; 58 mpeg2_mc = mpeg2_mc_vis;
59 else 59 else
60#endif 60#endif
61
62#ifdef CPU_ARM
63 mpeg2_mc = mpeg2_mc_arm;
64#else
61 mpeg2_mc = mpeg2_mc_c; 65 mpeg2_mc = mpeg2_mc_c;
66#endif
62} 67}
63 68
64#define avg2(a,b) ((a+b+1)>>1) 69#define avg2(a,b) ((a+b+1)>>1)
diff --git a/apps/plugins/mpegplayer/motion_comp_arm.c b/apps/plugins/mpegplayer/motion_comp_arm.c
new file mode 100644
index 0000000000..ec9eddab72
--- /dev/null
+++ b/apps/plugins/mpegplayer/motion_comp_arm.c
@@ -0,0 +1,183 @@
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_s.S b/apps/plugins/mpegplayer/motion_comp_arm_s.S
new file mode 100644
index 0000000000..82be8e6a8e
--- /dev/null
+++ b/apps/plugins/mpegplayer/motion_comp_arm_s.S
@@ -0,0 +1,322 @@
1@ motion_comp_arm_s.S
2@ Copyright (C) 2004 AGAWA Koji <i (AT) atty (DOT) jp>
3@
4@ This file is part of mpeg2dec, a free MPEG-2 video stream decoder.
5@ See http://libmpeg2.sourceforge.net/ for updates.
6@
7@ mpeg2dec is free software; you can redistribute it and/or modify
8@ it under the terms of the GNU General Public License as published by
9@ the Free Software Foundation; either version 2 of the License, or
10@ (at your option) any later version.
11@
12@ mpeg2dec is distributed in the hope that it will be useful,
13@ but WITHOUT ANY WARRANTY; without even the implied warranty of
14@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15@ GNU General Public License for more details.
16@
17@ You should have received a copy of the GNU General Public License
18@ along with this program; if not, write to the Free Software
19@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21 .text
22
23@ ----------------------------------------------------------------
24 .align
25 .global MC_put_o_16_arm
26MC_put_o_16_arm:
27 @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
28 @@ pld [r1]
29 stmfd sp!, {r4-r11, lr} @ R14 is also called LR
30 and r4, r1, #3
31 adr r5, MC_put_o_16_arm_align_jt
32 add r5, r5, r4, lsl #2
33 ldr pc, [r5]
34
35MC_put_o_16_arm_align0:
36 ldmia r1, {r4-r7}
37 add r1, r1, r2
38 @@ pld [r1]
39 stmia r0, {r4-r7}
40 subs r3, r3, #1
41 add r0, r0, r2
42 bne MC_put_o_16_arm_align0
43 ldmfd sp!, {r4-r11, pc} @@ update PC with LR content.
44
45.macro PROC shift
46 ldmia r1, {r4-r8}
47 add r1, r1, r2
48 mov r9, r4, lsr #(\shift)
49 @@ pld [r1]
50 mov r10, r5, lsr #(\shift)
51 orr r9, r9, r5, lsl #(32-\shift)
52 mov r11, r6, lsr #(\shift)
53 orr r10, r10, r6, lsl #(32-\shift)
54 mov r12, r7, lsr #(\shift)
55 orr r11, r11, r7, lsl #(32-\shift)
56 orr r12, r12, r8, lsl #(32-\shift)
57 stmia r0, {r9-r12}
58 subs r3, r3, #1
59 add r0, r0, r2
60.endm
61
62MC_put_o_16_arm_align1:
63 and r1, r1, #0xFFFFFFFC
641: PROC(8)
65 bne 1b
66 ldmfd sp!, {r4-r11, pc} @@ update PC with LR content.
67MC_put_o_16_arm_align2:
68 and r1, r1, #0xFFFFFFFC
691: PROC(16)
70 bne 1b
71 ldmfd sp!, {r4-r11, pc} @@ update PC with LR content.
72MC_put_o_16_arm_align3:
73 and r1, r1, #0xFFFFFFFC
741: PROC(24)
75 bne 1b
76 ldmfd sp!, {r4-r11, pc} @@ update PC with LR content.
77MC_put_o_16_arm_align_jt:
78 .word MC_put_o_16_arm_align0
79 .word MC_put_o_16_arm_align1
80 .word MC_put_o_16_arm_align2
81 .word MC_put_o_16_arm_align3
82
83@ ----------------------------------------------------------------
84 .align
85 .global MC_put_o_8_arm
86MC_put_o_8_arm:
87 @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
88 @@ pld [r1]
89 stmfd sp!, {r4-r10, lr} @ R14 is also called LR
90 and r4, r1, #3
91 adr r5, MC_put_o_8_arm_align_jt
92 add r5, r5, r4, lsl #2
93 ldr pc, [r5]
94MC_put_o_8_arm_align0:
95 ldmia r1, {r4-r5}
96 add r1, r1, r2
97 @@ pld [r1]
98 stmia r0, {r4-r5}
99 add r0, r0, r2
100 subs r3, r3, #1
101 bne MC_put_o_8_arm_align0
102 ldmfd sp!, {r4-r10, pc} @@ update PC with LR content.
103
104.macro PROC8 shift
105 ldmia r1, {r4-r6}
106 add r1, r1, r2
107 mov r9, r4, lsr #(\shift)
108 @@ pld [r1]
109 mov r10, r5, lsr #(\shift)
110 orr r9, r9, r5, lsl #(32-\shift)
111 orr r10, r10, r6, lsl #(32-\shift)
112 stmia r0, {r9-r10}
113 subs r3, r3, #1
114 add r0, r0, r2
115.endm
116
117MC_put_o_8_arm_align1:
118 and r1, r1, #0xFFFFFFFC
1191: PROC8(8)
120 bne 1b
121 ldmfd sp!, {r4-r10, pc} @@ update PC with LR content.
122
123MC_put_o_8_arm_align2:
124 and r1, r1, #0xFFFFFFFC
1251: PROC8(16)
126 bne 1b
127 ldmfd sp!, {r4-r10, pc} @@ update PC with LR content.
128
129MC_put_o_8_arm_align3:
130 and r1, r1, #0xFFFFFFFC
1311: PROC8(24)
132 bne 1b
133 ldmfd sp!, {r4-r10, pc} @@ update PC with LR content.
134
135MC_put_o_8_arm_align_jt:
136 .word MC_put_o_8_arm_align0
137 .word MC_put_o_8_arm_align1
138 .word MC_put_o_8_arm_align2
139 .word MC_put_o_8_arm_align3
140
141@ ----------------------------------------------------------------
142.macro AVG_PW rW1, rW2
143 mov \rW2, \rW2, lsl #24
144 orr \rW2, \rW2, \rW1, lsr #8
145 eor r9, \rW1, \rW2
146 and \rW2, \rW1, \rW2
147 and r10, r9, r12
148 add \rW2, \rW2, r10, lsr #1
149 and r10, r9, r11
150 add \rW2, \rW2, r10
151.endm
152
153 .align
154 .global MC_put_x_16_arm
155MC_put_x_16_arm:
156 @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
157 @@ pld [r1]
158 stmfd sp!, {r4-r11,lr} @ R14 is also called LR
159 and r4, r1, #3
160 adr r5, MC_put_x_16_arm_align_jt
161 ldr r11, [r5]
162 mvn r12, r11
163 add r5, r5, r4, lsl #2
164 ldr pc, [r5, #4]
165
166.macro ADJ_ALIGN_QW shift, R0, R1, R2, R3, R4
167 mov \R0, \R0, lsr #(\shift)
168 orr \R0, \R0, \R1, lsl #(32 - \shift)
169 mov \R1, \R1, lsr #(\shift)
170 orr \R1, \R1, \R2, lsl #(32 - \shift)
171 mov \R2, \R2, lsr #(\shift)
172 orr \R2, \R2, \R3, lsl #(32 - \shift)
173 mov \R3, \R3, lsr #(\shift)
174 orr \R3, \R3, \R4, lsl #(32 - \shift)
175 mov \R4, \R4, lsr #(\shift)
176@ and \R4, \R4, #0xFF
177.endm
178
179MC_put_x_16_arm_align0:
180 ldmia r1, {r4-r8}
181 add r1, r1, r2
182 @@ pld [r1]
183 AVG_PW r7, r8
184 AVG_PW r6, r7
185 AVG_PW r5, r6
186 AVG_PW r4, r5
187 stmia r0, {r5-r8}
188 subs r3, r3, #1
189 add r0, r0, r2
190 bne MC_put_x_16_arm_align0
191 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
192MC_put_x_16_arm_align1:
193 and r1, r1, #0xFFFFFFFC
1941: ldmia r1, {r4-r8}
195 add r1, r1, r2
196 @@ pld [r1]
197 ADJ_ALIGN_QW 8, r4, r5, r6, r7, r8
198 AVG_PW r7, r8
199 AVG_PW r6, r7
200 AVG_PW r5, r6
201 AVG_PW r4, r5
202 stmia r0, {r5-r8}
203 subs r3, r3, #1
204 add r0, r0, r2
205 bne 1b
206 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
207MC_put_x_16_arm_align2:
208 and r1, r1, #0xFFFFFFFC
2091: ldmia r1, {r4-r8}
210 add r1, r1, r2
211 @@ pld [r1]
212 ADJ_ALIGN_QW 16, r4, r5, r6, r7, r8
213 AVG_PW r7, r8
214 AVG_PW r6, r7
215 AVG_PW r5, r6
216 AVG_PW r4, r5
217 stmia r0, {r5-r8}
218 subs r3, r3, #1
219 add r0, r0, r2
220 bne 1b
221 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
222MC_put_x_16_arm_align3:
223 and r1, r1, #0xFFFFFFFC
2241: ldmia r1, {r4-r8}
225 add r1, r1, r2
226 @@ pld [r1]
227 ADJ_ALIGN_QW 24, r4, r5, r6, r7, r8
228 AVG_PW r7, r8
229 AVG_PW r6, r7
230 AVG_PW r5, r6
231 AVG_PW r4, r5
232 stmia r0, {r5-r8}
233 subs r3, r3, #1
234 add r0, r0, r2
235 bne 1b
236 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
237MC_put_x_16_arm_align_jt:
238 .word 0x01010101
239 .word MC_put_x_16_arm_align0
240 .word MC_put_x_16_arm_align1
241 .word MC_put_x_16_arm_align2
242 .word MC_put_x_16_arm_align3
243
244@ ----------------------------------------------------------------
245 .align
246 .global MC_put_x_8_arm
247MC_put_x_8_arm:
248 @@ void func(uint8_t * dest, const uint8_t * ref, int stride, int height)
249 @@ pld [r1]
250 stmfd sp!, {r4-r11,lr} @ R14 is also called LR
251 and r4, r1, #3
252 adr r5, MC_put_x_8_arm_align_jt
253 ldr r11, [r5]
254 mvn r12, r11
255 add r5, r5, r4, lsl #2
256 ldr pc, [r5, #4]
257
258.macro ADJ_ALIGN_DW shift, R0, R1, R2
259 mov \R0, \R0, lsr #(\shift)
260 orr \R0, \R0, \R1, lsl #(32 - \shift)
261 mov \R1, \R1, lsr #(\shift)
262 orr \R1, \R1, \R2, lsl #(32 - \shift)
263 mov \R2, \R2, lsr #(\shift)
264@ and \R4, \R4, #0xFF
265.endm
266
267MC_put_x_8_arm_align0:
268 ldmia r1, {r4-r6}
269 add r1, r1, r2
270 @@ pld [r1]
271 AVG_PW r5, r6
272 AVG_PW r4, r5
273 stmia r0, {r5-r6}
274 subs r3, r3, #1
275 add r0, r0, r2
276 bne MC_put_x_8_arm_align0
277 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
278MC_put_x_8_arm_align1:
279 and r1, r1, #0xFFFFFFFC
2801: ldmia r1, {r4-r6}
281 add r1, r1, r2
282 @@ pld [r1]
283 ADJ_ALIGN_DW 8, r4, r5, r6
284 AVG_PW r5, r6
285 AVG_PW r4, r5
286 stmia r0, {r5-r6}
287 subs r3, r3, #1
288 add r0, r0, r2
289 bne 1b
290 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
291MC_put_x_8_arm_align2:
292 and r1, r1, #0xFFFFFFFC
2931: ldmia r1, {r4-r6}
294 add r1, r1, r2
295 @@ pld [r1]
296 ADJ_ALIGN_DW 16, r4, r5, r6
297 AVG_PW r5, r6
298 AVG_PW r4, r5
299 stmia r0, {r5-r6}
300 subs r3, r3, #1
301 add r0, r0, r2
302 bne 1b
303 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
304MC_put_x_8_arm_align3:
305 and r1, r1, #0xFFFFFFFC
3061: ldmia r1, {r4-r6}
307 add r1, r1, r2
308 @@ pld [r1]
309 ADJ_ALIGN_DW 24, r4, r5, r6
310 AVG_PW r5, r6
311 AVG_PW r4, r5
312 stmia r0, {r5-r6}
313 subs r3, r3, #1
314 add r0, r0, r2
315 bne 1b
316 ldmfd sp!, {r4-r11,pc} @@ update PC with LR content.
317MC_put_x_8_arm_align_jt:
318 .word 0x01010101
319 .word MC_put_x_8_arm_align0
320 .word MC_put_x_8_arm_align1
321 .word MC_put_x_8_arm_align2
322 .word MC_put_x_8_arm_align3
diff --git a/apps/plugins/mpegplayer/mpeg2_internal.h b/apps/plugins/mpegplayer/mpeg2_internal.h
index 850456b1f8..443b6d6114 100644
--- a/apps/plugins/mpegplayer/mpeg2_internal.h
+++ b/apps/plugins/mpegplayer/mpeg2_internal.h
@@ -298,3 +298,4 @@ extern mpeg2_mc_t mpeg2_mc_3dnow;
298extern mpeg2_mc_t mpeg2_mc_altivec; 298extern mpeg2_mc_t mpeg2_mc_altivec;
299extern mpeg2_mc_t mpeg2_mc_alpha; 299extern mpeg2_mc_t mpeg2_mc_alpha;
300extern mpeg2_mc_t mpeg2_mc_vis; 300extern mpeg2_mc_t mpeg2_mc_vis;
301extern mpeg2_mc_t mpeg2_mc_arm;