1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 by Michael Sevakis
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
24 .global mpeg2_idct_copy
25 .type mpeg2_idct_copy, %function
26 .global mpeg2_idct_add
27 .type mpeg2_idct_add, %function
30 /* Custom calling convention:
31 * r0 contains block pointer and is non-volatile
32 * all non-volatile c context saved and restored on its behalf
37 ldrsh r1, [r0, #0] /* d0 */
38 ldrsh r2, [r0, #2] /* d1 */
39 ldrsh r3, [r0, #4] /* d2 */
40 ldrsh r4, [r0, #6] /* d3 */
41 ldrsh r5, [r0, #8] /* d0 */
42 ldrsh r6, [r0, #10] /* d1 */
43 ldrsh r7, [r0, #12] /* d2 */
44 ldrsh r8, [r0, #14] /* d3 */
52 orr r1, r1, r1, lsr #16
61 mov r1, r1, asl #11 /* r1 = d0 = (block[0] << 11) + 2048 */
63 add r1, r1, r3, asl #11 /* r1 = t0 = d0 + (block[2] << 11) */
64 sub r3, r1, r3, asl #12 /* r3 = t1 = d0 - (block[2] << 11) */
66 add r9, r2, r4 /* r9 = tmp = (d1+d3)*(1108/4) */
67 add r10, r9, r9, asl #2
68 add r10, r10, r9, asl #4
69 add r9, r10, r9, asl #8
71 add r10, r2, r2, asl #4 /* r2 = t2 = tmp + (d1*(1568/32)*8) */
72 add r2, r10, r2, asl #5
73 add r2, r9, r2, asl #3
75 add r10, r4, r4, asl #2 /* r4 = t3 = tmp - (d3*(3784/8)*2) */
76 rsb r10, r10, r4, asl #6
77 add r4, r4, r10, asl #3
78 sub r4, r9, r4, asl #1
79 /* t2 & t3 are 1/4 final value here */
80 add r1, r1, r2, asl #2 /* r1 = a0 = t0 + t2 */
81 sub r2, r1, r2, asl #3 /* r2 = a3 = t0 - t2 */
82 add r3, r3, r4, asl #2 /* r3 = a1 = t1 + t3 */
83 sub r4, r3, r4, asl #3 /* r4 = a2 = t1 - t3 */
85 add r9, r8, r5 /* r9 = tmp = 565*(d3 + d0) */
86 add r10, r9, r9, asl #4
87 add r10, r10, r10, asl #5
88 add r9, r10, r9, asl #2
90 add r10, r5, r5, asl #4 /* r5 = t0 = tmp + (((2276/4)*d0)*4) */
91 add r10, r10, r10, asl #5
92 add r5, r10, r5, asl #3
93 add r5, r9, r5, asl #2
95 add r10, r8, r8, asl #2 /* r8 = t1 = tmp - (((3406/2)*d3)*2) */
96 add r10, r10, r10, asl #4
97 add r10, r10, r8, asl #7
98 rsb r8, r8, r10, asl #3
99 sub r8, r9, r8, asl #1
101 add r9, r6, r7 /* r9 = tmp = (2408/8)*(d1 + d2) */
102 add r10, r9, r9, asl #3
103 add r10, r10, r10, asl #5
104 add r9, r10, r9, asl #2
106 add r10, r7, r7, asl #3 /* r7 = t2 = (tmp*8) - 799*d2 */
107 add r10, r10, r7, asl #4
108 rsb r7, r7, r10, asl #5
109 rsb r7, r7, r9, asl #3
111 sub r10, r6, r6, asl #4 /* r6 = t3 = (tmp*8) - 4017*d1 */
112 sub r10, r10, r6, asl #6
113 add r10, r10, r6, asl #12
115 rsb r6, r6, r9, asl #3
116 /* t0 = r5, t1 = r8, t2 = r7, t3 = r6*/
117 add r9, r5, r7 /* r9 = b0 = t0 + t2 */
118 add r10, r8, r6 /* r10 = b3 = t1 + t3 */
119 sub r5, r5, r7 /* t0 -= t2 */
120 sub r8, r8, r6 /* t1 -= t3 */
121 add r6, r5, r8 /* r6 = t0 + t1 */
122 sub r7, r5, r8 /* r7 = t0 - t1 */
124 add r11, r6, r6, asr #2 /* r6 = b1 = r6*(181/128) */
125 add r11, r11, r11, asr #5
126 add r6, r11, r6, asr #3
127 add r11, r7, r7, asr #2 /* r7 = b2 = r7*(181/128) */
128 add r11, r11, r11, asr #5
129 add r7, r11, r7, asr #3
130 /* r1 = a0, r3 = a1, r4 = a2, r2 = a3 */
131 /* r9 = b0, r6 = b1*2, r7 = b2*2, r10 = b3 */
132 add r5, r1, r9 /* block[0] = (a0 + b0) >> 12 */
135 add r8, r3, r6, asr #1 /* block[1] = (a1 + b1) >> 12 */
138 add r5, r4, r7, asr #1 /* block[2] = (a2 + b2) >> 12 */
141 add r8, r2, r10 /* block[3] = (a3 + b3) >> 12 */
144 sub r5, r2, r10 /* block[4] = (a3 - b3) >> 12 */
147 sub r8, r4, r7, asr #1 /* block[5] = (a2 - b2) >> 12 */
150 sub r5, r3, r6, asr #1 /* block[6] = (a1 - b1) >> 12 */
153 sub r8, r1, r9 /* block[7] = (a0 - b0) >> 12 */
162 ldrsh r1, [r0, #0*8] /* d0 */
163 ldrsh r2, [r0, #2*8] /* d1 */
164 ldrsh r3, [r0, #4*8] /* d2 */
165 ldrsh r4, [r0, #6*8] /* d3 */
166 ldrsh r5, [r0, #8*8] /* d0 */
167 ldrsh r6, [r0, #10*8] /* d1 */
168 ldrsh r7, [r0, #12*8] /* d2 */
169 ldrsh r8, [r0, #14*8] /* d3 */
171 mov r1, r1, asl #11 /* r1 = d0 = (block[0] << 11) + 2048 */
173 add r1, r1, r3, asl #11 /* r1 = t0 = d0 + d2:(block[2] << 11) */
174 sub r3, r1, r3, asl #12 /* r3 = t1 = d0 - d2:(block[2] << 11) */
176 add r9, r2, r4 /* r9 = tmp = (d1+d3)*(1108/4) */
177 add r10, r9, r9, asl #2
178 add r10, r10, r9, asl #4
179 add r9, r10, r9, asl #8
181 add r11, r2, r2, asl #4 /* r2 = t2 = tmp + (d1*(1568/32)*8) */
182 add r2, r11, r2, asl #5
183 add r2, r9, r2, asl #3
185 add r10, r4, r4, asl #2 /* r4 = t3 = tmp - (d3*(3784/8)*2) */
186 rsb r10, r10, r4, asl #6
187 add r4, r4, r10, asl #3
188 sub r4, r9, r4, asl #1
189 /* t2 & t3 are 1/4 final value here */
190 add r1, r1, r2, asl #2 /* r1 = a0 = t0 + t2 */
191 sub r2, r1, r2, asl #3 /* r2 = a3 = t0 - t2 */
192 add r3, r3, r4, asl #2 /* r3 = a1 = t1 + t3 */
193 sub r4, r3, r4, asl #3 /* r4 = a2 = t1 - t3 */
195 add r9, r8, r5 /* r9 = tmp = 565*(d3 + d0) */
196 add r10, r9, r9, asl #4
197 add r10, r10, r10, asl #5
198 add r9, r10, r9, asl #2
200 add r10, r5, r5, asl #4 /* r5 = t0 = tmp + (((2276/4)*d0)*4) */
201 add r10, r10, r10, asl #5
202 add r5, r10, r5, asl #3
203 add r5, r9, r5, asl #2
205 add r10, r8, r8, asl #2 /* r8 = t1 = tmp - (((3406/2)*d3)*2) */
206 add r10, r10, r10, asl #4
207 add r10, r10, r8, asl #7
208 rsb r8, r8, r10, asl #3
209 sub r8, r9, r8, asl #1
211 add r9, r6, r7 /* r9 = tmp = (2408/8)*(d1 + d2) */
212 add r10, r9, r9, asl #3
213 add r10, r10, r10, asl #5
214 add r9, r10, r9, asl #2
216 add r10, r7, r7, asl #3 /* r7 = t2 = (tmp*8) - 799*d2 */
217 add r10, r10, r7, asl #4
218 rsb r7, r7, r10, asl #5
219 rsb r7, r7, r9, asl #3
221 sub r10, r6, r6, asl #4 /* r6 = t3 = (tmp*8) - 4017*d1 */
222 sub r10, r10, r6, asl #6
223 add r10, r10, r6, asl #12
225 rsb r6, r6, r9, asl #3
226 /* t0=r5, t1=r8, t2=r7, t3=r6*/
227 add r9, r5, r7 /* r9 = b0 = t0 + t2 */
228 add r10, r8, r6 /* r10 = b3 = t1 + t3 */
229 sub r5, r5, r7 /* t0 -= t2 */
230 sub r8, r8, r6 /* t1 -= t3 */
231 add r6, r5, r8 /* r6 = t0 + t1 */
232 sub r7, r5, r8 /* r7 = t0 - t1 */
234 add r11, r6, r6, asr #2 /* r6 = b1 = r5*(181/128) */
235 add r11, r11, r11, asr #5
236 add r6, r11, r6, asr #3
237 add r11, r7, r7, asr #2 /* r7 = b2 = r6*(181/128) */
238 add r11, r11, r11, asr #5
239 add r7, r11, r7, asr #3
240 /* r1 = a0, r3 = a1, r4 = a2, r2 = a3 */
241 /* r9 = b0, r6 = b1*2, r7 = b2*2, r10 = b3 */
242 add r5, r1, r9 /* block[0] = (a0 + b0) >> 17 */
245 add r8, r3, r6, asr #1 /* block[1] = (a1 + b1) >> 17 */
248 add r5, r4, r7, asr #1 /* block[2] = (a2 + b2) >> 17 */
251 add r8, r2, r10 /* block[3] = (a3 + b3) >> 17 */
254 sub r5, r2, r10 /* block[4] = (a3 - b3) >> 17 */
257 sub r8, r4, r7, asr #1 /* block[5] = (a2 - b2) >> 17 */
260 sub r5, r3, r6, asr #1 /* block[6] = (a1 - b1) >> 17 */
263 sub r8, r1, r9 /* block[7] = (a0 - b0) >> 17 */
273 stmfd sp!, { r1-r2, r4-r11, lr }
288 mvnhi r3, r3, asr #31
292 mvnhi r4, r4, asr #31
295 mvnhi r5, r5, asr #31
299 mvnhi r6, r6, asr #31
302 mvnhi r7, r7, asr #31
306 mvnhi r8, r8, asr #31
309 mvnhi r9, r9, asr #31
313 mvnhi r10, r10, asr #31
329 stmfd sp!, { r2-r11, lr }
346 mvnhi r7, r7, asr #31
352 mvnhi r8, r8, asr #31
358 mvnhi r9, r9, asr #31
364 mvnhi r10, r10, asr #31
370 mvnhi r7, r7, asr #31
375 mvnhi r8, r8, asr #31
380 mvnhi r9, r9, asr #31
384 mvnhi r10, r10, asr #31
392 stmfd sp!, { r4-r5, lr }
393 ldrsh r1, [r0, #0] /* r1 = block[0] */
395 strh r4, [r0, #0] /* block[0] = 0 */
396 strh r4, [r0, #126] /* block[63] = 0 */
397 add r1, r1, #64 /* r1 = DC << 7 */
398 add r0, r2, r3, asl #3
404 add r4, r4, r1, asr #7
406 mvnhi r4, r4, asr #31
408 add r5, r5, r1, asr #7
410 mvnhi r5, r5, asr #31
412 add r12, r12, r1, asr #7
414 mvnhi r12, r12, asr #31
416 add lr, lr, r1, asr #7
418 mvnhi lr, lr, asr #31
424 add r4, r4, r1, asr #7
426 mvnhi r4, r4, asr #31
428 add r5, r5, r1, asr #7
430 mvnhi r5, r5, asr #31
432 add r12, r12, r1, asr #7
434 mvnhi r12, r12, asr #31
436 add lr, lr, r1, asr #7
438 mvnhi lr, lr, asr #31