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 ****************************************************************************/
22 .global mpeg2_idct_copy
23 .type mpeg2_idct_copy, %function
24 .global mpeg2_idct_add
25 .type mpeg2_idct_add, %function
28 /* Custom calling convention:
29 * r0 contains block pointer and is non-volatile
30 * all non-volatile c context saved and restored on its behalf
35 ldrsh r1, [r0, #0] /* d0 */
36 ldrsh r2, [r0, #2] /* d1 */
37 ldrsh r3, [r0, #4] /* d2 */
38 ldrsh r4, [r0, #6] /* d3 */
39 ldrsh r5, [r0, #8] /* d0 */
40 ldrsh r6, [r0, #10] /* d1 */
41 ldrsh r7, [r0, #12] /* d2 */
42 ldrsh r8, [r0, #14] /* d3 */
50 orr r1, r1, r1, lsr #16
59 mov r1, r1, asl #11 /* r1 = d0 = (block[0] << 11) + 2048 */
61 add r1, r1, r3, asl #11 /* r1 = t0 = d0 + (block[2] << 11) */
62 sub r3, r1, r3, asl #12 /* r3 = t1 = d0 - (block[2] << 11) */
64 add r9, r2, r4 /* r9 = tmp = (d1+d3)*(1108/4) */
65 add r10, r9, r9, asl #2
66 add r10, r10, r9, asl #4
67 add r9, r10, r9, asl #8
69 add r10, r2, r2, asl #4 /* r2 = t2 = tmp + (d1*(1568/32)*8) */
70 add r2, r10, r2, asl #5
71 add r2, r9, r2, asl #3
73 add r10, r4, r4, asl #2 /* r4 = t3 = tmp - (d3*(3784/8)*2) */
74 rsb r10, r10, r4, asl #6
75 add r4, r4, r10, asl #3
76 sub r4, r9, r4, asl #1
77 /* t2 & t3 are 1/4 final value here */
78 add r1, r1, r2, asl #2 /* r1 = a0 = t0 + t2 */
79 sub r2, r1, r2, asl #3 /* r2 = a3 = t0 - t2 */
80 add r3, r3, r4, asl #2 /* r3 = a1 = t1 + t3 */
81 sub r4, r3, r4, asl #3 /* r4 = a2 = t1 - t3 */
83 add r9, r8, r5 /* r9 = tmp = 565*(d3 + d0) */
84 add r10, r9, r9, asl #4
85 add r10, r10, r10, asl #5
86 add r9, r10, r9, asl #2
88 add r10, r5, r5, asl #4 /* r5 = t0 = tmp + (((2276/4)*d0)*4) */
89 add r10, r10, r10, asl #5
90 add r5, r10, r5, asl #3
91 add r5, r9, r5, asl #2
93 add r10, r8, r8, asl #2 /* r8 = t1 = tmp - (((3406/2)*d3)*2) */
94 add r10, r10, r10, asl #4
95 add r10, r10, r8, asl #7
96 rsb r8, r8, r10, asl #3
97 sub r8, r9, r8, asl #1
99 add r9, r6, r7 /* r9 = tmp = (2408/8)*(d1 + d2) */
100 add r10, r9, r9, asl #3
101 add r10, r10, r10, asl #5
102 add r9, r10, r9, asl #2
104 add r10, r7, r7, asl #3 /* r7 = t2 = (tmp*8) - 799*d2 */
105 add r10, r10, r7, asl #4
106 rsb r7, r7, r10, asl #5
107 rsb r7, r7, r9, asl #3
109 sub r10, r6, r6, asl #4 /* r6 = t3 = (tmp*8) - 4017*d1 */
110 sub r10, r10, r6, asl #6
111 add r10, r10, r6, asl #12
113 rsb r6, r6, r9, asl #3
114 /* t0 = r5, t1 = r8, t2 = r7, t3 = r6*/
115 add r9, r5, r7 /* r9 = b0 = t0 + t2 */
116 add r10, r8, r6 /* r10 = b3 = t1 + t3 */
117 sub r5, r5, r7 /* t0 -= t2 */
118 sub r8, r8, r6 /* t1 -= t3 */
119 add r6, r5, r8 /* r6 = t0 + t1 */
120 sub r7, r5, r8 /* r7 = t0 - t1 */
122 add r11, r6, r6, asr #2 /* r6 = b1 = r6*(181/128) */
123 add r11, r11, r11, asr #5
124 add r6, r11, r6, asr #3
125 add r11, r7, r7, asr #2 /* r7 = b2 = r7*(181/128) */
126 add r11, r11, r11, asr #5
127 add r7, r11, r7, asr #3
128 /* r1 = a0, r3 = a1, r4 = a2, r2 = a3 */
129 /* r9 = b0, r6 = b1*2, r7 = b2*2, r10 = b3 */
130 add r5, r1, r9 /* block[0] = (a0 + b0) >> 12 */
133 add r8, r3, r6, asr #1 /* block[1] = (a1 + b1) >> 12 */
136 add r5, r4, r7, asr #1 /* block[2] = (a2 + b2) >> 12 */
139 add r8, r2, r10 /* block[3] = (a3 + b3) >> 12 */
142 sub r5, r2, r10 /* block[4] = (a3 - b3) >> 12 */
145 sub r8, r4, r7, asr #1 /* block[5] = (a2 - b2) >> 12 */
148 sub r5, r3, r6, asr #1 /* block[6] = (a1 - b1) >> 12 */
151 sub r8, r1, r9 /* block[7] = (a0 - b0) >> 12 */
160 ldrsh r1, [r0, #0*8] /* d0 */
161 ldrsh r2, [r0, #2*8] /* d1 */
162 ldrsh r3, [r0, #4*8] /* d2 */
163 ldrsh r4, [r0, #6*8] /* d3 */
164 ldrsh r5, [r0, #8*8] /* d0 */
165 ldrsh r6, [r0, #10*8] /* d1 */
166 ldrsh r7, [r0, #12*8] /* d2 */
167 ldrsh r8, [r0, #14*8] /* d3 */
169 mov r1, r1, asl #11 /* r1 = d0 = (block[0] << 11) + 2048 */
171 add r1, r1, r3, asl #11 /* r1 = t0 = d0 + d2:(block[2] << 11) */
172 sub r3, r1, r3, asl #12 /* r3 = t1 = d0 - d2:(block[2] << 11) */
174 add r9, r2, r4 /* r9 = tmp = (d1+d3)*(1108/4) */
175 add r10, r9, r9, asl #2
176 add r10, r10, r9, asl #4
177 add r9, r10, r9, asl #8
179 add r11, r2, r2, asl #4 /* r2 = t2 = tmp + (d1*(1568/32)*8) */
180 add r2, r11, r2, asl #5
181 add r2, r9, r2, asl #3
183 add r10, r4, r4, asl #2 /* r4 = t3 = tmp - (d3*(3784/8)*2) */
184 rsb r10, r10, r4, asl #6
185 add r4, r4, r10, asl #3
186 sub r4, r9, r4, asl #1
187 /* t2 & t3 are 1/4 final value here */
188 add r1, r1, r2, asl #2 /* r1 = a0 = t0 + t2 */
189 sub r2, r1, r2, asl #3 /* r2 = a3 = t0 - t2 */
190 add r3, r3, r4, asl #2 /* r3 = a1 = t1 + t3 */
191 sub r4, r3, r4, asl #3 /* r4 = a2 = t1 - t3 */
193 add r9, r8, r5 /* r9 = tmp = 565*(d3 + d0) */
194 add r10, r9, r9, asl #4
195 add r10, r10, r10, asl #5
196 add r9, r10, r9, asl #2
198 add r10, r5, r5, asl #4 /* r5 = t0 = tmp + (((2276/4)*d0)*4) */
199 add r10, r10, r10, asl #5
200 add r5, r10, r5, asl #3
201 add r5, r9, r5, asl #2
203 add r10, r8, r8, asl #2 /* r8 = t1 = tmp - (((3406/2)*d3)*2) */
204 add r10, r10, r10, asl #4
205 add r10, r10, r8, asl #7
206 rsb r8, r8, r10, asl #3
207 sub r8, r9, r8, asl #1
209 add r9, r6, r7 /* r9 = tmp = (2408/8)*(d1 + d2) */
210 add r10, r9, r9, asl #3
211 add r10, r10, r10, asl #5
212 add r9, r10, r9, asl #2
214 add r10, r7, r7, asl #3 /* r7 = t2 = (tmp*8) - 799*d2 */
215 add r10, r10, r7, asl #4
216 rsb r7, r7, r10, asl #5
217 rsb r7, r7, r9, asl #3
219 sub r10, r6, r6, asl #4 /* r6 = t3 = (tmp*8) - 4017*d1 */
220 sub r10, r10, r6, asl #6
221 add r10, r10, r6, asl #12
223 rsb r6, r6, r9, asl #3
224 /* t0=r5, t1=r8, t2=r7, t3=r6*/
225 add r9, r5, r7 /* r9 = b0 = t0 + t2 */
226 add r10, r8, r6 /* r10 = b3 = t1 + t3 */
227 sub r5, r5, r7 /* t0 -= t2 */
228 sub r8, r8, r6 /* t1 -= t3 */
229 add r6, r5, r8 /* r6 = t0 + t1 */
230 sub r7, r5, r8 /* r7 = t0 - t1 */
232 add r11, r6, r6, asr #2 /* r6 = b1 = r5*(181/128) */
233 add r11, r11, r11, asr #5
234 add r6, r11, r6, asr #3
235 add r11, r7, r7, asr #2 /* r7 = b2 = r6*(181/128) */
236 add r11, r11, r11, asr #5
237 add r7, r11, r7, asr #3
238 /* r1 = a0, r3 = a1, r4 = a2, r2 = a3 */
239 /* r9 = b0, r6 = b1*2, r7 = b2*2, r10 = b3 */
240 add r5, r1, r9 /* block[0] = (a0 + b0) >> 17 */
243 add r8, r3, r6, asr #1 /* block[1] = (a1 + b1) >> 17 */
246 add r5, r4, r7, asr #1 /* block[2] = (a2 + b2) >> 17 */
249 add r8, r2, r10 /* block[3] = (a3 + b3) >> 17 */
252 sub r5, r2, r10 /* block[4] = (a3 - b3) >> 17 */
255 sub r8, r4, r7, asr #1 /* block[5] = (a2 - b2) >> 17 */
258 sub r5, r3, r6, asr #1 /* block[6] = (a1 - b1) >> 17 */
261 sub r8, r1, r9 /* block[7] = (a0 - b0) >> 17 */
271 stmfd sp!, { r1-r2, r4-r12, lr }
286 mvnhi r3, r3, asr #31
290 mvnhi r4, r4, asr #31
293 mvnhi r5, r5, asr #31
297 mvnhi r6, r6, asr #31
300 mvnhi r7, r7, asr #31
304 mvnhi r8, r8, asr #31
307 mvnhi r9, r9, asr #31
311 mvnhi r10, r10, asr #31
316 ldmfd sp!, { r4-r12, pc }
327 stmfd sp!, { r2-r12, lr }
344 mvnhi r7, r7, asr #31
350 mvnhi r8, r8, asr #31
356 mvnhi r9, r9, asr #31
362 mvnhi r10, r10, asr #31
368 mvnhi r7, r7, asr #31
373 mvnhi r8, r8, asr #31
378 mvnhi r9, r9, asr #31
382 mvnhi r10, r10, asr #31
388 ldmfd sp!, { r4-r12, pc }
390 stmfd sp!, { r4-r11 }
391 ldrsh r1, [r0, #0] /* r1 = block[0] */
393 strh r11, [r0, #0] /* block[0] = 0 */
394 strh r11, [r0, #126] /* block[63] = 0 */
395 add r1, r1, #64 /* r1 = DC << 7 */
396 add r0, r2, r3, asl #3
406 add r4, r4, r1, asr #7
408 mvnhi r4, r4, asr #31
410 add r5, r5, r1, asr #7
412 mvnhi r5, r5, asr #31
414 add r6, r6, r1, asr #7
416 mvnhi r6, r6, asr #31
418 add r7, r7, r1, asr #7
420 mvnhi r7, r7, asr #31
422 add r8, r8, r1, asr #7
424 mvnhi r8, r8, asr #31
426 add r9, r9, r1, asr #7
428 mvnhi r9, r9, asr #31
430 add r10, r10, r1, asr #7
432 mvnhi r10, r10, asr #31
434 add r11, r11, r1, asr #7
436 mvnhi r11, r11, asr #31
441 ldmfd sp!, { r4-r11 }