[cvs] / xvidcore / src / dct / x86_asm / simple_idct_mmx.asm Repository:
ViewVC logotype

Annotation of /xvidcore/src/dct/x86_asm/simple_idct_mmx.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (view) (download)

1 : edgomez 1.2 ;/*
2 :     ; * Simple IDCT MMX
3 :     ; *
4 :     ; * Copyright (c) 2001, 2002 Michael Niedermayer <michaelni@gmx.at>
5 :     ; *
6 :     ; * This library is free software; you can redistribute it and/or
7 :     ; * modify it under the terms of the GNU Lesser General Public
8 :     ; * License as published by the Free Software Foundation; either
9 :     ; * version 2 of the License, or (at your option) any later version.
10 :     ; *
11 :     ; * This library is distributed in the hope that it will be useful,
12 :     ; * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 :     ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 :     ; * Lesser General Public License for more details.
15 :     ; *
16 :     ; * You should have received a copy of the GNU Lesser General Public
17 :     ; * License along with this library; if not, write to the Free Software
18 :     ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 :     ; *
20 :     ; * Ported to nasm by Peter Ross <pross@xvid.org>
21 :     ; */
22 :    
23 : edgomez 1.4 BITS 32
24 : edgomez 1.2
25 : edgomez 1.4 ;=============================================================================
26 :     ; Macros and other preprocessor constants
27 :     ;=============================================================================
28 : edgomez 1.2
29 : edgomez 1.4 %macro cglobal 1
30 :     %ifdef PREFIX
31 : edgomez 1.6 %ifdef MARK_FUNCS
32 : edgomez 1.7 global _%1:function %1.endfunc-%1
33 :     %define %1 _%1:function %1.endfunc-%1
34 : Isibaar 1.9 %define ENDFUNC .endfunc
35 : edgomez 1.6 %else
36 :     global _%1
37 :     %define %1 _%1
38 : Isibaar 1.9 %define ENDFUNC
39 : edgomez 1.6 %endif
40 : edgomez 1.4 %else
41 : edgomez 1.6 %ifdef MARK_FUNCS
42 : edgomez 1.7 global %1:function %1.endfunc-%1
43 : Isibaar 1.9 %define ENDFUNC .endfunc
44 : edgomez 1.6 %else
45 :     global %1
46 : Isibaar 1.9 %define ENDFUNC
47 : edgomez 1.6 %endif
48 : edgomez 1.4 %endif
49 :     %endmacro
50 : edgomez 1.2
51 :     %define ROW_SHIFT 11
52 :     %define COL_SHIFT 20
53 :     %define C0 23170 ;cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 = 23170.475006
54 :     %define C1 22725 ;cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 = 22725.260826
55 :     %define C2 21407 ;cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 = 21406.727617
56 :     %define C3 19266 ;cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 = 19265.545870
57 :     %define C4 16383 ;cos(i*M_PI/16)*sqrt(2)*(1<<14) - 0.5 = 16384.000000
58 :     %define C5 12873 ;cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 = 12872.826198
59 :     %define C6 8867 ;cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 = 8866.956905
60 :     %define C7 4520 ;cos(i*M_PI/16)*sqrt(2)*(1<<14) + 0.5 = 4520.335430
61 :    
62 : edgomez 1.4 ;===========================================================================
63 :     ; Data (Read Only)
64 :     ;===========================================================================
65 :    
66 :     %ifdef FORMAT_COFF
67 : edgomez 1.5 SECTION .rodata
68 : edgomez 1.4 %else
69 : edgomez 1.5 SECTION .rodata align=16
70 : edgomez 1.4 %endif
71 :    
72 :     ;-----------------------------------------------------------------------------
73 :     ; Trigonometric Tables
74 :     ;-----------------------------------------------------------------------------
75 :    
76 :     ALIGN 16
77 :     wm1010:
78 :     dw 0, 0xffff, 0, 0xffff
79 :    
80 :     ALIGN 16
81 :     d40000:
82 :     dd 0x40000, 0
83 :    
84 :     ALIGN 16
85 :     coeffs:
86 :     dw 1<<(ROW_SHIFT-1), 0, 1<<(ROW_SHIFT-1), 0, ; 0
87 :     dw 1<<(ROW_SHIFT-1), 1, 1<<(ROW_SHIFT-1), 0, ; 8
88 :    
89 :     dw C4, C4, C4, C4 ; 16
90 :     dw C4, -C4, C4, -C4 ; 24
91 :    
92 :     dw C2, C6, C2, C6 ; 32
93 :     dw C6, -C2, C6, -C2 ; 40
94 :    
95 :     dw C1, C3, C1, C3 ; 48
96 :     dw C5, C7, C5, C7 ; 56
97 :    
98 :     dw C3, -C7, C3, -C7 ; 64
99 :     dw -C1, -C5, -C1, -C5 ; 72
100 :    
101 :     dw C5, -C1, C5, -C1 ; 80
102 :     dw C7, C3, C7, C3 ; 88
103 :    
104 :     dw C7, -C5, C7, -C5 ; 96
105 :     dw C3, -C1, C3, -C1 ; 104
106 : edgomez 1.2
107 :    
108 :     ;===========================================================================
109 : edgomez 1.4 ; Helper macros
110 : edgomez 1.2 ;===========================================================================
111 : edgomez 1.4
112 :     ;---------------------------------------------------------------------------
113 :     ; DC_COND_IDCT
114 :     ;---------------------------------------------------------------------------
115 : edgomez 1.2
116 :     %macro DC_COND_IDCT 8
117 :     %define src0 %1
118 :     %define src4 %2
119 :     %define src1 %3
120 :     %define src5 %4
121 :     %define dst %5
122 :     %define rounder_op %6
123 :     %define rounder_arg %7
124 :     %define shift %8
125 : edgomez 1.4 movq mm0,[src0] ; R4 R0 r4 r0
126 :     movq mm1,[src4] ; R6 R2 r6 r2
127 :     movq mm2,[src1] ; R3 R1 r3 r1
128 :     movq mm3,[src5] ; R7 R5 r7 r5
129 :     movq mm4,[wm1010]
130 :     pand mm4,mm0
131 :     por mm4,mm1
132 :     por mm4,mm2
133 :     por mm4,mm3
134 :     packssdw mm4,mm4
135 :     movd eax,mm4
136 :     or eax,eax
137 :     jz near .skip1
138 :     movq mm4,[coeffs+16] ; C4 C4 C4 C4
139 :     pmaddwd mm4,mm0 ; C4R4+C4R0 C4r4+C4r0
140 :     movq mm5,[coeffs+24] ; -C4 C4 -C4 C4
141 :     pmaddwd mm0,mm5 ; -C4R4+C4R0 -C4r4+C4r0
142 :     movq mm5,[coeffs+32] ; C6 C2 C6 C2
143 :     pmaddwd mm5,mm1 ; C6R6+C2R2 C6r6+C2r2
144 :     movq mm6,[coeffs+40] ; -C2 C6 -C2 C6
145 :     pmaddwd mm1,mm6 ; -C2R6+C6R2 -C2r6+C6r2
146 :     movq mm7,[coeffs+48] ; C3 C1 C3 C1
147 :     pmaddwd mm7,mm2 ; C3R3+C1R1 C3r3+C1r1
148 :     rounder_op mm4, rounder_arg
149 :     movq mm6,mm4 ; C4R4+C4R0 C4r4+C4r0
150 :     paddd mm4,mm5 ; A0 a0
151 :     psubd mm6,mm5 ; A3 a3
152 :     movq mm5,[coeffs+56] ; C7 C5 C7 C5
153 :     pmaddwd mm5,mm3 ; C7R7+C5R5 C7r7+C5r5
154 :     rounder_op mm0, rounder_arg
155 :     paddd mm1,mm0 ; A1 a1
156 :     paddd mm0,mm0
157 :     psubd mm0,mm1 ; A2 a2
158 :     pmaddwd mm2,[coeffs+64] ; -C7R3+C3R1 -C7r3+C3r1
159 :     paddd mm7,mm5 ; B0 b0
160 :     movq mm5,[coeffs+72] ; -C5 -C1 -C5 -C1
161 :     pmaddwd mm5,mm3 ; -C5R7-C1R5 -C5r7-C1r5
162 :     paddd mm7,mm4 ; A0+B0 a0+b0
163 :     paddd mm4,mm4 ; 2A0 2a0
164 :     psubd mm4,mm7 ; A0-B0 a0-b0
165 :     paddd mm5,mm2 ; B1 b1
166 :     psrad mm7,shift
167 :     psrad mm4,shift
168 :     movq mm2,mm1 ; A1 a1
169 :     paddd mm1,mm5 ; A1+B1 a1+b1
170 :     psubd mm2,mm5 ; A1-B1 a1-b1
171 :     psrad mm1,shift
172 :     psrad mm2,shift
173 :     packssdw mm7,mm1 ; A1+B1 a1+b1 A0+B0 a0+b0
174 :     packssdw mm2,mm4 ; A0-B0 a0-b0 A1-B1 a1-b1
175 :     movq [dst],mm7
176 :     movq mm1,[src1] ; R3 R1 r3 r1
177 :     movq mm4,[coeffs+80] ;-C1 C5 -C1 C5
178 :     movq [dst + 24],mm2
179 :     pmaddwd mm4,mm1 ; -C1R3+C5R1 -C1r3+C5r1
180 :     movq mm7,[coeffs+88] ; C3 C7 C3 C7
181 :     pmaddwd mm1,[coeffs+96] ; -C5R3+C7R1 -C5r3+C7r1
182 :     pmaddwd mm7,mm3 ; C3R7+C7R5 C3r7+C7r5
183 :     movq mm2,mm0 ; A2 a2
184 :     pmaddwd mm3,[coeffs+104] ; -C1R7+C3R5 -C1r7+C3r5
185 :     paddd mm4,mm7 ; B2 b2
186 :     paddd mm2,mm4 ; A2+B2 a2+b2
187 :     psubd mm0,mm4 ; a2-B2 a2-b2
188 :     psrad mm2,shift
189 :     psrad mm0,shift
190 :     movq mm4,mm6 ; A3 a3
191 :     paddd mm3,mm1 ; B3 b3
192 :     paddd mm6,mm3 ; A3+B3 a3+b3
193 :     psubd mm4,mm3 ; a3-B3 a3-b3
194 :     psrad mm6,shift
195 :     packssdw mm2,mm6 ; A3+B3 a3+b3 A2+B2 a2+b2
196 :     movq [ dst + 8],mm2
197 :     psrad mm4,shift
198 :     packssdw mm4,mm0 ; A2-B2 a2-b2 A3-B3 a3-b3
199 :     movq [ dst + 16],mm4
200 :     jmp short .skip2
201 : Isibaar 1.9 .skip1:
202 : edgomez 1.4 pslld mm0,16
203 :     paddd mm0,[d40000]
204 :     psrad mm0,13
205 :     packssdw mm0,mm0
206 :     movq [ dst ],mm0
207 :     movq [ dst + 8],mm0
208 :     movq [ dst + 16],mm0
209 :     movq [ dst + 24],mm0
210 : Isibaar 1.9 .skip2:
211 : edgomez 1.4 %undef src0
212 :     %undef src4
213 :     %undef src1
214 :     %undef src5
215 :     %undef dst
216 :     %undef rounder_op
217 :     %undef rounder_arg
218 :     %undef shift
219 : edgomez 1.2 %endmacro
220 :    
221 : edgomez 1.4 ;---------------------------------------------------------------------------
222 :     ; Z_COND_IDCT
223 :     ;---------------------------------------------------------------------------
224 : edgomez 1.2
225 :     %macro Z_COND_IDCT 9
226 : edgomez 1.4 %define src0 %1
227 :     %define src4 %2
228 :     %define src1 %3
229 :     %define src5 %4
230 :     %define dst %5
231 :     %define rounder_op %6
232 :     %define rounder_arg %7
233 :     %define shift %8
234 :     %define bt %9
235 :     movq mm0,[src0] ; R4 R0 r4 r0
236 :     movq mm1,[src4] ; R6 R2 r6 r2
237 :     movq mm2,[src1] ; R3 R1 r3 r1
238 :     movq mm3,[src5] ; R7 R5 r7 r5
239 :     movq mm4,mm0
240 :     por mm4,mm1
241 :     por mm4,mm2
242 :     por mm4,mm3
243 :     packssdw mm4,mm4
244 :     movd eax,mm4
245 :     or eax,eax
246 :     jz near bt
247 :     movq mm4,[coeffs+16] ; C4 C4 C4 C4
248 :     pmaddwd mm4,mm0 ; C4R4+C4R0 C4r4+C4r0
249 :     movq mm5,[coeffs+24] ; -C4 C4 -C4 C4
250 :     pmaddwd mm0,mm5 ; -C4R4+C4R0 -C4r4+C4r0
251 :     movq mm5,[coeffs+32] ; C6 C2 C6 C2
252 :     pmaddwd mm5,mm1 ; C6R6+C2R2 C6r6+C2r2
253 :     movq mm6,[coeffs+40] ; -C2 C6 -C2 C6
254 :     pmaddwd mm1,mm6 ; -C2R6+C6R2 -C2r6+C6r2
255 :     movq mm7,[coeffs+48] ; C3 C1 C3 C1
256 :     pmaddwd mm7,mm2 ; C3R3+C1R1 C3r3+C1r1
257 :     rounder_op mm4, rounder_arg
258 :     movq mm6,mm4 ; C4R4+C4R0 C4r4+C4r0
259 :     paddd mm4,mm5 ; A0 a0
260 :     psubd mm6,mm5 ; A3 a3
261 :     movq mm5,[coeffs+56] ; C7 C5 C7 C5
262 :     pmaddwd mm5,mm3 ; C7R7+C5R5 C7r7+C5r5
263 :     rounder_op mm0, rounder_arg
264 :     paddd mm1,mm0 ; A1 a1
265 :     paddd mm0,mm0
266 :     psubd mm0,mm1 ; A2 a2
267 :     pmaddwd mm2,[coeffs+64] ; -C7R3+C3R1 -C7r3+C3r1
268 :     paddd mm7,mm5 ; B0 b0
269 :     movq mm5,[coeffs+72] ; -C5 -C1 -C5 -C1
270 :     pmaddwd mm5,mm3 ; -C5R7-C1R5 -C5r7-C1r5
271 :     paddd mm7,mm4 ; A0+B0 a0+b0
272 :     paddd mm4,mm4 ; 2A0 2a0
273 :     psubd mm4,mm7 ; A0-B0 a0-b0
274 :     paddd mm5,mm2 ; B1 b1
275 :     psrad mm7,shift
276 :     psrad mm4,shift
277 :     movq mm2,mm1 ; A1 a1
278 :     paddd mm1,mm5 ; A1+B1 a1+b1
279 :     psubd mm2,mm5 ; A1-B1 a1-b1
280 :     psrad mm1,shift
281 :     psrad mm2,shift
282 :     packssdw mm7,mm1 ; A1+B1 a1+b1 A0+B0 a0+b0
283 :     packssdw mm2,mm4 ; A0-B0 a0-b0 A1-B1 a1-b1
284 :     movq [ dst ],mm7
285 :     movq mm1,[src1] ; R3 R1 r3 r1
286 :     movq mm4,[coeffs+80] ; -C1 C5 -C1 C5
287 :     movq [ dst + 24 ],mm2
288 :     pmaddwd mm4,mm1 ; -C1R3+C5R1 -C1r3+C5r1
289 :     movq mm7,[coeffs+88] ; C3 C7 C3 C7
290 :     pmaddwd mm1,[coeffs+96] ; -C5R3+C7R1 -C5r3+C7r1
291 :     pmaddwd mm7,mm3 ; C3R7+C7R5 C3r7+C7r5
292 :     movq mm2,mm0 ; A2 a2
293 :     pmaddwd mm3,[coeffs+104] ; -C1R7+C3R5 -C1r7+C3r5
294 :     paddd mm4,mm7 ; B2 b2
295 :     paddd mm2,mm4 ; A2+B2 a2+b2
296 :     psubd mm0,mm4 ; a2-B2 a2-b2
297 :     psrad mm2,shift
298 :     psrad mm0,shift
299 :     movq mm4,mm6 ; A3 a3
300 :     paddd mm3,mm1 ; B3 b3
301 :     paddd mm6,mm3 ; A3+B3 a3+b3
302 :     psubd mm4,mm3 ; a3-B3 a3-b3
303 :     psrad mm6,shift
304 :     packssdw mm2,mm6 ; A3+B3 a3+b3 A2+B2 a2+b2
305 :     movq [ dst + 8],mm2
306 :     psrad mm4,shift
307 :     packssdw mm4,mm0 ; A2-B2 a2-b2 A3-B3 a3-b3
308 :     movq [dst + 16],mm4
309 : edgomez 1.2 %undef src0
310 :     %undef src4
311 :     %undef src1
312 :     %undef src5
313 :     %undef dst
314 :     %undef rounder_op
315 :     %undef rounder_arg
316 :     %undef shift
317 :     %undef bt
318 :     %endmacro
319 :    
320 : edgomez 1.4 ;---------------------------------------------------------------------------
321 :     ; IDCT0
322 :     ;---------------------------------------------------------------------------
323 : edgomez 1.2
324 :     %macro IDCT0 8
325 :     %define src0 %1
326 : edgomez 1.4 %define src4 %2
327 :     %define src1 %3
328 :     %define src5 %4
329 :     %define dst %5
330 :     %define rounder_op %6
331 :     %define rounder_arg %7
332 :     %define shift %8
333 :     movq mm0,[src0] ; R4 R0 r4 r0
334 :     movq mm1,[src4] ; R6 R2 r6 r2
335 :     movq mm2,[src1] ; R3 R1 r3 r1
336 :     movq mm3,[src5] ; R7 R5 r7 r5
337 :     movq mm4,[coeffs+16] ; C4 C4 C4 C4
338 :     pmaddwd mm4,mm0 ; C4R4+C4R0 C4r4+C4r0
339 :     movq mm5,[coeffs+24] ; -C4 C4 -C4 C4
340 :     pmaddwd mm0,mm5 ; -C4R4+C4R0 -C4r4+C4r0
341 :     movq mm5,[coeffs+32] ; C6 C2 C6 C2
342 :     pmaddwd mm5,mm1 ; C6R6+C2R2 C6r6+C2r2
343 :     movq mm6,[coeffs+40] ; -C2 C6 -C2 C6
344 :     pmaddwd mm1,mm6 ; -C2R6+C6R2 -C2r6+C6r2
345 :     ; rounder_op mm4, rounder_arg
346 :     movq mm6,mm4 ; C4R4+C4R0 C4r4+C4r0
347 :     movq mm7,[coeffs+48] ; C3 C1 C3 C1
348 :     ; rounder_op mm0, rounder_arg
349 :     pmaddwd mm7,mm2 ; C3R3+C1R1 C3r3+C1r1
350 :     paddd mm4,mm5 ; A0 a0
351 :     psubd mm6,mm5 ; A3 a3
352 :     movq mm5,mm0 ; -C4R4+C4R0 -C4r4+C4r0
353 :     paddd mm0,mm1 ; A1 a1
354 :     psubd mm5,mm1 ; A2 a2
355 :     movq mm1,[coeffs+56] ; C7 C5 C7 C5
356 :     pmaddwd mm1,mm3 ; C7R7+C5R5 C7r7+C5r5
357 :     pmaddwd mm2,[coeffs+64] ; -C7R3+C3R1 -C7r3+C3r1
358 :     paddd mm7,mm1 ; B0 b0
359 :     movq mm1,[coeffs+72] ; -C5 -C1 -C5 -C1
360 :     pmaddwd mm1,mm3 ; -C5R7-C1R5 -C5r7-C1r5
361 :     paddd mm7,mm4 ; A0+B0 a0+b0
362 :     paddd mm4,mm4 ; 2A0 2a0
363 :     psubd mm4,mm7 ; A0-B0 a0-b0
364 :     paddd mm1,mm2 ; B1 b1
365 :     psrad mm7,shift
366 :     psrad mm4,shift
367 :     movq mm2,mm0 ; A1 a1
368 :     paddd mm0,mm1 ; A1+B1 a1+b1
369 :     psubd mm2,mm1 ; A1-B1 a1-b1
370 :     psrad mm0,shift
371 :     psrad mm2,shift
372 :     packssdw mm7,mm7 ; A0+B0 a0+b0
373 :     movd [ dst ],mm7
374 :     packssdw mm0,mm0 ; A1+B1 a1+b1
375 :     movd [ dst + 16],mm0
376 :     packssdw mm2,mm2 ; A1-B1 a1-b1
377 :     movd [ dst + 96 ],mm2
378 :     packssdw mm4,mm4 ; A0-B0 a0-b0
379 :     movd [ dst + 112],mm4
380 :     movq mm0,[src1] ; R3 R1 r3 r1
381 :     movq mm4,[coeffs+80] ; -C1 C5 -C1 C5
382 :     pmaddwd mm4,mm0 ; -C1R3+C5R1 -C1r3+C5r1
383 :     movq mm7,[coeffs+88] ; C3 C7 C3 C7
384 :     pmaddwd mm0,[coeffs+96] ; -C5R3+C7R1 -C5r3+C7r1
385 :     pmaddwd mm7,mm3 ; C3R7+C7R5 C3r7+C7r5
386 :     movq mm2,mm5 ; A2 a2
387 :     pmaddwd mm3,[coeffs+104] ; -C1R7+C3R5 -C1r7+C3r5
388 :     paddd mm4,mm7 ; B2 b2
389 :     paddd mm2,mm4 ; A2+B2 a2+b2
390 :     psubd mm5,mm4 ; a2-B2 a2-b2
391 :     psrad mm2,shift
392 :     psrad mm5,shift
393 :     movq mm4,mm6 ; A3 a3
394 :     paddd mm3,mm0 ; B3 b3
395 :     paddd mm6,mm3 ; A3+B3 a3+b3
396 :     psubd mm4,mm3 ; a3-B3 a3-b3
397 :     psrad mm6,shift
398 :     psrad mm4,shift
399 :     packssdw mm2,mm2 ; A2+B2 a2+b2
400 :     packssdw mm6,mm6 ; A3+B3 a3+b3
401 :     movd [ dst + 32 ],mm2
402 :     packssdw mm4,mm4 ; A3-B3 a3-b3
403 :     packssdw mm5,mm5 ; A2-B2 a2-b2
404 :     movd [ dst + 48 ],mm6
405 :     movd [ dst + 64 ],mm4
406 :     movd [ dst + 80 ],mm5
407 : edgomez 1.2 %undef src0
408 :     %undef src4
409 :     %undef src1
410 :     %undef src5
411 :     %undef dst
412 :     %undef rounder_op
413 :     %undef rounder_arg
414 :     %undef shift
415 :     %endmacro
416 :    
417 : edgomez 1.4 ;---------------------------------------------------------------------------
418 :     ; IDCT4
419 :     ;---------------------------------------------------------------------------
420 : edgomez 1.2
421 :     %macro IDCT4 8
422 :     %define src0 %1
423 :     %define src4 %2
424 :     %define src1 %3
425 :     %define src5 %4
426 :     %define dst %5
427 :     %define rounder_op %6
428 :     %define rounder_arg %7
429 :     %define shift %8
430 : edgomez 1.4 movq mm0,[src0] ; R4 R0 r4 r0
431 :     movq mm1,[src4] ; R6 R2 r6 r2
432 :     movq mm3,[src5] ; R7 R5 r7 r5
433 :     movq mm4,[coeffs+16] ; C4 C4 C4 C4
434 :     pmaddwd mm4,mm0 ; C4R4+C4R0 C4r4+C4r0
435 :     movq mm5,[coeffs+24] ; -C4 C4 -C4 C4
436 :     pmaddwd mm0,mm5 ; -C4R4+C4R0 -C4r4+C4r0
437 :     movq mm5,[coeffs+32] ; C6 C2 C6 C2
438 :     pmaddwd mm5,mm1 ; C6R6+C2R2 C6r6+C2r2
439 :     movq mm6,[coeffs+40] ; -C2 C6 -C2 C6
440 :     pmaddwd mm1,mm6 ; -C2R6+C6R2 -C2r6+C6r2
441 :     ; rounder_op mm4, rounder_arg
442 :     movq mm6,mm4 ; C4R4+C4R0 C4r4+C4r0
443 :     ; rounder_op mm0, rounder_arg
444 :     paddd mm4,mm5 ; A0 a0
445 :     psubd mm6,mm5 ; A3 a3
446 :     movq mm5,mm0 ; -C4R4+C4R0 -C4r4+C4r0
447 :     paddd mm0,mm1 ; A1 a1
448 :     psubd mm5,mm1 ; A2 a2
449 :     movq mm1,[coeffs+56] ; C7 C5 C7 C5
450 :     pmaddwd mm1,mm3 ; C7R7+C5R5 C7r7+C5r5
451 :     movq mm7,[coeffs+72] ; -C5 -C1 -C5 -C1
452 :     pmaddwd mm7,mm3 ; -C5R7-C1R5 -C5r7-C1r5
453 :     paddd mm1,mm4 ; A0+B0 a0+b0
454 :     paddd mm4,mm4 ; 2A0 2a0
455 :     psubd mm4,mm1 ; A0-B0 a0-b0
456 :     psrad mm1,shift
457 :     psrad mm4,shift
458 :     movq mm2,mm0 ; A1 a1
459 :     paddd mm0,mm7 ; A1+B1 a1+b1
460 :     psubd mm2,mm7 ; A1-B1 a1-b1
461 :     psrad mm0,shift
462 :     psrad mm2,shift
463 :     packssdw mm1,mm1 ; A0+B0 a0+b0
464 :     movd [ dst ],mm1
465 :     packssdw mm0,mm0 ; A1+B1 a1+b1
466 :     movd [ dst + 16 ],mm0
467 :     packssdw mm2,mm2 ; A1-B1 a1-b1
468 :     movd [ dst + 96 ],mm2
469 :     packssdw mm4,mm4 ; A0-B0 a0-b0
470 :     movd [ dst + 112 ],mm4
471 :     movq mm1,[coeffs+88] ; C3 C7 C3 C7
472 :     pmaddwd mm1,mm3 ; C3R7+C7R5 C3r7+C7r5
473 :     movq mm2,mm5 ; A2 a2
474 :     pmaddwd mm3,[coeffs+104] ; -C1R7+C3R5 -C1r7+C3r5
475 :     paddd mm2,mm1 ; A2+B2 a2+b2
476 :     psubd mm5,mm1 ; a2-B2 a2-b2
477 :     psrad mm2,shift
478 :     psrad mm5,shift
479 :     movq mm1,mm6 ; A3 a3
480 :     paddd mm6,mm3 ; A3+B3 a3+b3
481 :     psubd mm1,mm3 ; a3-B3 a3-b3
482 :     psrad mm6,shift
483 :     psrad mm1,shift
484 :     packssdw mm2,mm2 ; A2+B2 a2+b2
485 :     packssdw mm6,mm6 ; A3+B3 a3+b3
486 :     movd [dst + 32],mm2
487 :     packssdw mm1,mm1 ; A3-B3 a3-b3
488 :     packssdw mm5,mm5 ; A2-B2 a2-b2
489 :     movd [dst + 48],mm6
490 :     movd [dst + 64],mm1
491 :     movd [dst + 80],mm5
492 : edgomez 1.2 %undef src0
493 :     %undef src4
494 :     %undef src1
495 :     %undef src5
496 :     %undef dst
497 :     %undef rounder_op
498 :     %undef rounder_arg
499 :     %undef shift
500 :     %endmacro
501 :    
502 : edgomez 1.4 ;---------------------------------------------------------------------------
503 :     ; IDCT6
504 :     ;---------------------------------------------------------------------------
505 : edgomez 1.2
506 :     %macro IDCT6 8
507 :     %define src0 %1
508 :     %define src4 %2
509 :     %define src1 %3
510 :     %define src5 %4
511 :     %define dst %5
512 :     %define rounder_op %6
513 :     %define rounder_arg %7
514 :     %define shift %8
515 : edgomez 1.4 movq mm0,[src0] ; R4 R0 r4 r0
516 :     movq mm3,[src5] ; R7 R5 r7 r5
517 :     movq mm4,[coeffs+16] ; C4 C4 C4 C4
518 :     pmaddwd mm4,mm0 ; C4R4+C4R0 C4r4+C4r0
519 :     movq mm5,[coeffs+24] ; -C4 C4 -C4 C4
520 :     pmaddwd mm0,mm5 ; -C4R4+C4R0 -C4r4+C4r0
521 :     ; rounder_op mm4, rounder_arg
522 :     movq mm6,mm4 ; C4R4+C4R0 C4r4+C4r0
523 :     ; rounder_op mm0, rounder_arg
524 :     movq mm5,mm0 ; -C4R4+C4R0 -C4r4+C4r0
525 :     movq mm1,[coeffs+56] ; C7 C5 C7 C5
526 :     pmaddwd mm1,mm3 ; C7R7+C5R5 C7r7+C5r5
527 :     movq mm7,[coeffs+72] ; -C5 -C1 -C5 -C1
528 :     pmaddwd mm7,mm3 ; -C5R7-C1R5 -C5r7-C1r5
529 :     paddd mm1,mm4 ; A0+B0 a0+b0
530 :     paddd mm4,mm4 ; 2A0 2a0
531 :     psubd mm4,mm1 ; A0-B0 a0-b0
532 :     psrad mm1,shift
533 :     psrad mm4,shift
534 :     movq mm2,mm0 ; A1 a1
535 :     paddd mm0,mm7 ; A1+B1 a1+b1
536 :     psubd mm2,mm7 ; A1-B1 a1-b1
537 :     psrad mm0,shift
538 :     psrad mm2,shift
539 :     packssdw mm1,mm1 ; A0+B0 a0+b0
540 :     movd [ dst ],mm1
541 :     packssdw mm0,mm0 ; A1+B1 a1+b1
542 :     movd [ dst + 16 ],mm0
543 :     packssdw mm2,mm2 ; A1-B1 a1-b1
544 :     movd [ dst + 96 ],mm2
545 :     packssdw mm4,mm4 ; A0-B0 a0-b0
546 :     movd [ dst + 112 ],mm4
547 :     movq mm1,[coeffs+88] ; C3 C7 C3 C7
548 :     pmaddwd mm1,mm3 ; C3R7+C7R5 C3r7+C7r5
549 :     movq mm2,mm5 ; A2 a2
550 :     pmaddwd mm3,[coeffs+104] ; -C1R7+C3R5 -C1r7+C3r5
551 :     paddd mm2,mm1 ; A2+B2 a2+b2
552 :     psubd mm5,mm1 ; a2-B2 a2-b2
553 :     psrad mm2,shift
554 :     psrad mm5,shift
555 :     movq mm1,mm6 ; A3 a3
556 :     paddd mm6,mm3 ; A3+B3 a3+b3
557 :     psubd mm1,mm3 ; a3-B3 a3-b3
558 :     psrad mm6,shift
559 :     psrad mm1,shift
560 :     packssdw mm2,mm2 ; A2+B2 a2+b2
561 :     packssdw mm6,mm6 ; A3+B3 a3+b3
562 :     movd [dst + 32],mm2
563 :     packssdw mm1,mm1 ; A3-B3 a3-b3
564 :     packssdw mm5,mm5 ; A2-B2 a2-b2
565 :     movd [dst + 48],mm6
566 :     movd [dst + 64],mm1
567 :     movd [dst + 80],mm5
568 :     %undef src0
569 :     %undef src4
570 :     %undef src1
571 :     %undef src5
572 :     %undef dst
573 :     %undef rounder_op
574 :     %undef rounder_arg
575 : edgomez 1.2 %undef shift
576 :     %endmacro
577 :    
578 : edgomez 1.4 ;---------------------------------------------------------------------------
579 :     ; IDCT2
580 :     ;---------------------------------------------------------------------------
581 : edgomez 1.2
582 :     %macro IDCT2 8
583 :     %define src0 %1
584 :     %define src4 %2
585 :     %define src1 %3
586 :     %define src5 %4
587 :     %define dst %5
588 :     %define rounder_op %6
589 :     %define rounder_arg %7
590 : edgomez 1.4 %define shift %8
591 :     movq mm0,[src0] ; R4 R0 r4 r0
592 :     movq mm2,[src1] ; R3 R1 r3 r1
593 :     movq mm3,[src5] ; R7 R5 r7 r5
594 :     movq mm4,[coeffs+16] ; C4 C4 C4 C4
595 :     pmaddwd mm4,mm0 ; C4R4+C4R0 C4r4+C4r0
596 :     movq mm5,[coeffs+24] ; -C4 C4 -C4 C4
597 :     pmaddwd mm0,mm5 ; -C4R4+C4R0 -C4r4+C4r0
598 :     ; rounder_op mm4, rounder_arg
599 :     movq mm6,mm4 ; C4R4+C4R0 C4r4+C4r0
600 :     movq mm7,[coeffs+48] ; C3 C1 C3 C1
601 :     ; rounder_op mm0, rounder_arg
602 :     pmaddwd mm7,mm2 ; C3R3+C1R1 C3r3+C1r1
603 :     movq mm5,mm0 ; -C4R4+C4R0 -C4r4+C4r0
604 :     movq mm1,[coeffs+56] ; C7 C5 C7 C5
605 :     pmaddwd mm1,mm3 ; C7R7+C5R5 C7r7+C5r5
606 :     pmaddwd mm2,[coeffs+64] ; -C7R3+C3R1 -C7r3+C3r1
607 :     paddd mm7,mm1 ; B0 b0
608 :     movq mm1,[coeffs+72] ; -C5 -C1 -C5 -C1
609 :     pmaddwd mm1,mm3 ; -C5R7-C1R5 -C5r7-C1r5
610 :     paddd mm7,mm4 ; A0+B0 a0+b0
611 :     paddd mm4,mm4 ; 2A0 2a0
612 :     psubd mm4,mm7 ; A0-B0 a0-b0
613 :     paddd mm1,mm2 ; B1 b1
614 :     psrad mm7,shift
615 :     psrad mm4,shift
616 :     movq mm2,mm0 ; A1 a1
617 :     paddd mm0,mm1 ; A1+B1 a1+b1
618 :     psubd mm2,mm1 ; A1-B1 a1-b1
619 :     psrad mm0,shift
620 :     psrad mm2,shift
621 :     packssdw mm7,mm7 ; A0+B0 a0+b0
622 :     movd [dst],mm7
623 :     packssdw mm0,mm0 ; A1+B1 a1+b1
624 :     movd [dst + 16],mm0
625 :     packssdw mm2,mm2 ; A1-B1 a1-b1
626 :     movd [dst + 96],mm2
627 :     packssdw mm4,mm4 ; A0-B0 a0-b0
628 :     movd [dst + 112],mm4
629 :     movq mm0,[src1] ; R3 R1 r3 r1
630 :     movq mm4,[coeffs+80] ; -C1 C5 -C1 C5
631 :     pmaddwd mm4,mm0 ; -C1R3+C5R1 -C1r3+C5r1
632 :     movq mm7,[coeffs+88] ; C3 C7 C3 C7
633 :     pmaddwd mm0,[coeffs+96] ; -C5R3+C7R1 -C5r3+C7r1
634 :     pmaddwd mm7,mm3 ; C3R7+C7R5 C3r7+C7r5
635 :     movq mm2,mm5 ; A2 a2
636 :     pmaddwd mm3,[coeffs+104] ; -C1R7+C3R5 -C1r7+C3r5
637 :     paddd mm4,mm7 ; B2 b2
638 :     paddd mm2,mm4 ; A2+B2 a2+b2
639 :     psubd mm5,mm4 ; a2-B2 a2-b2
640 :     psrad mm2,shift
641 :     psrad mm5,shift
642 :     movq mm4,mm6 ; A3 a3
643 :     paddd mm3,mm0 ; B3 b3
644 :     paddd mm6,mm3 ; A3+B3 a3+b3
645 :     psubd mm4,mm3 ; a3-B3 a3-b3
646 :     psrad mm6,shift
647 :     psrad mm4,shift
648 :     packssdw mm2,mm2 ; A2+B2 a2+b2
649 :     packssdw mm6,mm6 ; A3+B3 a3+b3
650 :     movd [dst + 32],mm2
651 :     packssdw mm4,mm4 ; A3-B3 a3-b3
652 :     packssdw mm5,mm5 ; A2-B2 a2-b2
653 :     movd [dst + 48],mm6
654 :     movd [dst + 64],mm4
655 :     movd [dst + 80],mm5
656 :     %undef src0
657 :     %undef src4
658 :     %undef src1
659 :     %undef src5
660 :     %undef dst
661 :     %undef rounder_op
662 :     %undef rounder_arg
663 :     %undef shift
664 :     %endmacro
665 :    
666 :     ;---------------------------------------------------------------------------
667 :     ; IDCT3
668 :     ;---------------------------------------------------------------------------
669 :    
670 :     %macro IDCT3 8
671 :     %define src0 %1
672 :     %define src4 %2
673 :     %define src1 %3
674 :     %define src5 %4
675 :     %define dst %5
676 :     %define rounder_op %6
677 :     %define rounder_arg %7
678 :     %define shift %8
679 :     movq mm0,[src0] ; R4 R0 r4 r0
680 :     movq mm2,[src1] ; R3 R1 r3 r1
681 :     movq mm4,[coeffs+16] ; C4 C4 C4 C4
682 :     pmaddwd mm4,mm0 ; C4R4+C4R0 C4r4+C4r0
683 :     movq mm5,[coeffs+24] ; -C4 C4 -C4 C4
684 :     pmaddwd mm0,mm5 ; -C4R4+C4R0 -C4r4+C4r0
685 :     ; rounder_op mm4, rounder_arg
686 :     movq mm6,mm4 ; C4R4+C4R0 C4r4+C4r0
687 :     movq mm7,[coeffs+48] ; C3 C1 C3 C1
688 :     ; rounder_op mm0, rounder_arg
689 :     pmaddwd mm7,mm2 ; C3R3+C1R1 C3r3+C1r1
690 :     movq mm5,mm0 ; -C4R4+C4R0 -C4r4+C4r0
691 :     movq mm3,[coeffs+64]
692 :     pmaddwd mm3,mm2 ; -C7R3+C3R1 -C7r3+C3r1
693 :     paddd mm7,mm4 ; A0+B0 a0+b0
694 :     paddd mm4,mm4 ; 2A0 2a0
695 :     psubd mm4,mm7 ; A0-B0 a0-b0
696 :     psrad mm7,shift
697 :     psrad mm4,shift
698 :     movq mm1,mm0 ; A1 a1
699 :     paddd mm0,mm3 ; A1+B1 a1+b1
700 :     psubd mm1,mm3 ; A1-B1 a1-b1
701 :     psrad mm0,shift
702 :     psrad mm1,shift
703 :     packssdw mm7,mm7 ; A0+B0 a0+b0
704 :     movd [dst],mm7
705 :     packssdw mm0,mm0 ; A1+B1 a1+b1
706 :     movd [dst + 16],mm0
707 :     packssdw mm1,mm1 ; A1-B1 a1-b1
708 :     movd [dst + 96],mm1
709 :     packssdw mm4,mm4 ; A0-B0 a0-b0
710 :     movd [dst + 112],mm4
711 :     movq mm4,[coeffs+80] ; -C1 C5 -C1 C5
712 :     pmaddwd mm4,mm2 ; -C1R3+C5R1 -C1r3+C5r1
713 :     pmaddwd mm2,[coeffs+96] ; -C5R3+C7R1 -C5r3+C7r1
714 :     movq mm1,mm5 ; A2 a2
715 :     paddd mm1,mm4 ; A2+B2 a2+b2
716 :     psubd mm5,mm4 ; a2-B2 a2-b2
717 :     psrad mm1,shift
718 :     psrad mm5,shift
719 :     movq mm4,mm6 ; A3 a3
720 :     paddd mm6,mm2 ; A3+B3 a3+b3
721 :     psubd mm4,mm2 ; a3-B3 a3-b3
722 :     psrad mm6,shift
723 :     psrad mm4,shift
724 :     packssdw mm1,mm1 ; A2+B2 a2+b2
725 :     packssdw mm6,mm6 ; A3+B3 a3+b3
726 :     movd [dst + 32],mm1
727 :     packssdw mm4,mm4 ; A3-B3 a3-b3
728 :     packssdw mm5,mm5 ; A2-B2 a2-b2
729 :     movd [dst + 48],mm6
730 :     movd [dst + 64],mm4
731 :     movd [dst + 80],mm5
732 :     %undef src0
733 : edgomez 1.2 %undef src4
734 :     %undef src1
735 :     %undef src5
736 :     %undef dst
737 :     %undef rounder_op
738 :     %undef rounder_arg
739 :     %undef shift
740 :     %endmacro
741 :    
742 : edgomez 1.4 ;---------------------------------------------------------------------------
743 :     ; IDCT5
744 :     ;---------------------------------------------------------------------------
745 : edgomez 1.2
746 : edgomez 1.4 %macro IDCT5 8
747 : edgomez 1.2 %define src0 %1
748 :     %define src4 %2
749 :     %define src1 %3
750 :     %define src5 %4
751 :     %define dst %5
752 :     %define rounder_op %6
753 :     %define rounder_arg %7
754 :     %define shift %8
755 : edgomez 1.4 movq mm0,[src0] ; R4 R0 r4 r0
756 :     movq mm1,[src4] ; R6 R2 r6 r2
757 :     movq mm4,[coeffs+16] ; C4 C4 C4 C4
758 :     pmaddwd mm4,mm0 ; C4R4+C4R0 C4r4+C4r0
759 :     movq mm5,[coeffs+24] ; -C4 C4 -C4 C4
760 :     pmaddwd mm0,mm5 ; -C4R4+C4R0 -C4r4+C4r0
761 :     movq mm5,[coeffs+32] ; C6 C2 C6 C2
762 :     pmaddwd mm5,mm1 ; C6R6+C2R2 C6r6+C2r2
763 :     movq mm6,[coeffs+40] ; -C2 C6 -C2 C6
764 :     pmaddwd mm1,mm6 ; -C2R6+C6R2 -C2r6+C6r2
765 :     ; rounder_op mm4, rounder_arg
766 :     movq mm6,mm4 ; C4R4+C4R0 C4r4+C4r0
767 :     paddd mm4,mm5 ; A0 a0
768 :     ; rounder_op mm0, rounder_arg
769 :     psubd mm6,mm5 ; A3 a3
770 :     movq mm5,mm0 ; -C4R4+C4R0 -C4r4+C4r0
771 :     paddd mm0,mm1 ; A1 a1
772 :     psubd mm5,mm1 ; A2 a2
773 :     movq mm2,[src0 + 8] ; R4 R0 r4 r0
774 :     movq mm3,[src4 + 8] ; R6 R2 r6 r2
775 :     movq mm1,[coeffs+16] ; C4 C4 C4 C4
776 :     pmaddwd mm1,mm2 ; C4R4+C4R0 C4r4+C4r0
777 :     movq mm7,[coeffs+24] ; -C4 C4 -C4 C4
778 :     pmaddwd mm2,mm7 ; -C4R4+C4R0 -C4r4+C4r0
779 :     movq mm7,[coeffs+32] ; C6 C2 C6 C2
780 :     pmaddwd mm7,mm3 ; C6R6+C2R2 C6r6+C2r2
781 :     pmaddwd mm3,[coeffs+40] ; -C2R6+C6R2 -C2r6+C6r2
782 :     ; rounder_op mm1, rounder_arg
783 :     paddd mm7,mm1 ; A0 a0
784 :     paddd mm1,mm1 ; 2C0 2c0
785 :     ; rounder_op mm2, rounder_arg
786 :     psubd mm1,mm7 ; A3 a3
787 :     paddd mm3,mm2 ; A1 a1
788 :     paddd mm2,mm2 ; 2C1 2c1
789 :     psubd mm2,mm3 ; A2 a2
790 :     psrad mm4,shift
791 :     psrad mm7,shift
792 :     psrad mm3,shift
793 :     packssdw mm4,mm7 ; A0 a0
794 :     movq [dst],mm4
795 :     psrad mm0,shift
796 :     packssdw mm0,mm3 ; A1 a1
797 :     movq [dst + 16],mm0
798 :     movq [dst + 96],mm0
799 :     movq [dst + 112],mm4
800 :     psrad mm5,shift
801 :     psrad mm6,shift
802 :     psrad mm2,shift
803 :     packssdw mm5,mm2 ; A2-B2 a2-b2
804 :     movq [dst + 32],mm5
805 :     psrad mm1,shift
806 :     packssdw mm6,mm1 ; A3+B3 a3+b3
807 :     movq [dst + 48],mm6
808 :     movq [dst + 64],mm6
809 :     movq [dst + 80],mm5
810 :     %undef src0
811 :     %undef src4
812 :     %undef src1
813 :     %undef src5
814 :     %undef dst
815 :     %undef rounder_op
816 : edgomez 1.2 %undef rounder_arg
817 :     %undef shift
818 :     %endmacro
819 :    
820 : edgomez 1.4 ;---------------------------------------------------------------------------
821 :     ; IDCT1
822 :     ;---------------------------------------------------------------------------
823 : edgomez 1.2
824 : edgomez 1.4 %macro IDCT1 8
825 : edgomez 1.2 %define src0 %1
826 :     %define src4 %2
827 :     %define src1 %3
828 :     %define src5 %4
829 : edgomez 1.4 %define dst %5
830 :     %define rounder_op %6
831 :     %define rounder_arg %7
832 :     %define shift %8
833 :     movq mm0,[src0] ; R4 R0 r4 r0
834 :     movq mm1,[src4] ; R6 R2 r6 r2
835 :     movq mm2,[src1] ; R3 R1 r3 r1
836 :     movq mm4,[coeffs+16] ; C4 C4 C4 C4
837 :     pmaddwd mm4,mm0 ; C4R4+C4R0 C4r4+C4r0
838 :     movq mm5,[coeffs+24] ; -C4 C4 -C4 C4
839 :     pmaddwd mm0,mm5 ; -C4R4+C4R0 -C4r4+C4r0
840 :     movq mm5,[coeffs+32] ; C6 C2 C6 C2
841 :     pmaddwd mm5,mm1 ; C6R6+C2R2 C6r6+C2r2
842 :     movq mm6,[coeffs+40] ; -C2 C6 -C2 C6
843 :     pmaddwd mm1,mm6 ; -C2R6+C6R2 -C2r6+C6r2
844 :     ; rounder_op mm4, rounder_arg
845 :     movq mm6,mm4 ; C4R4+C4R0 C4r4+C4r0
846 :     movq mm7,[coeffs+48] ; C3 C1 C3 C1
847 :     ; rounder_op mm0, rounder_arg
848 :     pmaddwd mm7,mm2 ; C3R3+C1R1 C3r3+C1r1
849 :     paddd mm4,mm5 ; A0 a0
850 :     psubd mm6,mm5 ; A3 a3
851 :     movq mm5,mm0 ; -C4R4+C4R0 -C4r4+C4r0
852 :     paddd mm0,mm1 ; A1 a1
853 :     psubd mm5,mm1 ; A2 a2
854 :     movq mm1,[coeffs+64]
855 :     pmaddwd mm1,mm2 ; -C7R3+C3R1 -C7r3+C3r1
856 :     paddd mm7,mm4 ; A0+B0 a0+b0
857 :     paddd mm4,mm4 ; 2A0 2a0
858 :     psubd mm4,mm7 ; A0-B0 a0-b0
859 :     psrad mm7,shift
860 :     psrad mm4,shift
861 :     movq mm3,mm0 ; A1 a1
862 :     paddd mm0,mm1 ; A1+B1 a1+b1
863 :     psubd mm3,mm1 ; A1-B1 a1-b1
864 :     psrad mm0,shift
865 :     psrad mm3,shift
866 :     packssdw mm7,mm7 ; A0+B0 a0+b0
867 :     movd [dst],mm7
868 :     packssdw mm0,mm0 ; A1+B1 a1+b1
869 :     movd [dst + 16],mm0
870 :     packssdw mm3,mm3 ; A1-B1 a1-b1
871 :     movd [dst + 96],mm3
872 :     packssdw mm4,mm4 ; A0-B0 a0-b0
873 :     movd [dst + 112],mm4
874 :     movq mm4,[coeffs+80] ; -C1 C5 -C1 C5
875 :     pmaddwd mm4,mm2 ; -C1R3+C5R1 -C1r3+C5r1
876 :     pmaddwd mm2,[coeffs+96] ; -C5R3+C7R1 -C5r3+C7r1
877 :     movq mm3,mm5 ; A2 a2
878 :     paddd mm3,mm4 ; A2+B2 a2+b2
879 :     psubd mm5,mm4 ; a2-B2 a2-b2
880 :     psrad mm3,shift
881 :     psrad mm5,shift
882 :     movq mm4,mm6 ; A3 a3
883 :     paddd mm6,mm2 ; A3+B3 a3+b3
884 :     psubd mm4,mm2 ; a3-B3 a3-b3
885 :     psrad mm6,shift
886 :     packssdw mm3,mm3 ; A2+B2 a2+b2
887 :     movd [dst + 32],mm3
888 :     psrad mm4,shift
889 :     packssdw mm6,mm6 ; A3+B3 a3+b3
890 :     movd [dst + 48],mm6
891 :     packssdw mm4,mm4 ; A3-B3 a3-b3
892 :     packssdw mm5,mm5 ; A2-B2 a2-b2
893 :     movd [dst + 64],mm4
894 :     movd [dst + 80],mm5
895 :     %undef src0
896 :     %undef src4
897 :     %undef src1
898 :     %undef src5
899 :     %undef dst
900 :     %undef rounder_op
901 :     %undef rounder_arg
902 :     %undef shift
903 : edgomez 1.2 %endmacro
904 :    
905 : edgomez 1.4 ;---------------------------------------------------------------------------
906 :     ; IDCT7
907 :     ;---------------------------------------------------------------------------
908 : edgomez 1.2
909 : edgomez 1.4 %macro IDCT7 8
910 : edgomez 1.2 %define src0 %1
911 :     %define src4 %2
912 :     %define src1 %3
913 :     %define src5 %4
914 :     %define dst %5
915 :     %define rounder_op %6
916 :     %define rounder_arg %7
917 :     %define shift %8
918 : edgomez 1.4 movq mm0,[src0] ; R4 R0 r4 r0
919 :     movq mm4,[coeffs+16] ; C4 C4 C4 C4
920 :     pmaddwd mm4,mm0 ; C4R4+C4R0 C4r4+C4r0
921 :     movq mm5,[coeffs+24] ; -C4 C4 -C4 C4
922 :     pmaddwd mm0,mm5 ; -C4R4+C4R0 -C4r4+C4r0
923 :     ; rounder_op mm4, rounder_arg
924 :     ; rounder_op mm0, rounder_arg
925 :     psrad mm4,shift
926 :     psrad mm0,shift
927 :     movq mm2,[src0 + 8] ; R4 R0 r4 r0
928 :     movq mm1,[coeffs+16] ; C4 C4 C4 C4
929 :     pmaddwd mm1,mm2 ; C4R4+C4R0 C4r4+C4r0
930 :     movq mm7,[coeffs+24] ; -C4 C4 -C4 C4
931 :     pmaddwd mm2,mm7 ; -C4R4+C4R0 -C4r4+C4r0
932 :     movq mm7,[coeffs+32] ; C6 C2 C6 C2
933 :     ; rounder_op mm1, rounder_arg
934 :     ; rounder_op mm2, rounder_arg
935 :     psrad mm1,shift
936 :     packssdw mm4,mm1 ; A0 a0
937 :     movq [dst],mm4
938 :     psrad mm2,shift
939 :     packssdw mm0,mm2 ; A1 a1
940 :     movq [dst + 16],mm0
941 :     movq [dst + 96],mm0
942 :     movq [dst + 112],mm4
943 :     movq [dst + 32],mm0
944 :     movq [dst + 48],mm4
945 :     movq [dst + 64],mm4
946 :     movq [dst + 80],mm0
947 : edgomez 1.2 %undef src0
948 :     %undef src4
949 :     %undef src1
950 :     %undef src5
951 :     %undef dst
952 :     %undef rounder_op
953 :     %undef rounder_arg
954 :     %undef shift
955 :     %endmacro
956 :    
957 : edgomez 1.4 ;---------------------------------------------------------------------------
958 :     ; Permutation helpers
959 :     ;---------------------------------------------------------------------------
960 :    
961 :     %macro XLODA 2
962 :     mov bx, [srcP+2*%2] ; get src contents
963 :     mov ax, [srcP+2*%1] ; get dest contents
964 :     mov [srcP+2*%1], bx ; store new dest val
965 :     %endmacro
966 : edgomez 1.2
967 : edgomez 1.4 %macro XCHGA 2
968 :     mov ax, [srcP+2*%1] ; get dest contents
969 :     mov [srcP+2*%1], bx ; store new dest val
970 :     %endmacro
971 : edgomez 1.2
972 : edgomez 1.4 %macro XCHGB 2
973 :     mov bx, [srcP+2*%1] ; get dest contents
974 :     mov [srcP+2*%1], ax ; store new dest val
975 :     %endmacro
976 :    
977 :     %macro XSTRA 2
978 :     mov [srcP+2*%1], bx ; store dest val
979 :     %endmacro
980 : edgomez 1.2
981 : edgomez 1.4 %macro XSTRB 2
982 :     mov [srcP+2*%1], ax ; store dest val
983 : edgomez 1.2 %endmacro
984 :    
985 : edgomez 1.4 ;---------------------------------------------------------------------------
986 :     ; Permutation macro
987 :     ;---------------------------------------------------------------------------
988 :    
989 :     %macro PERMUTEP 1
990 :     %define srcP %1
991 :     push ebx
992 :    
993 :     ; XCHGA 0x00, 0x00 ; nothing to do
994 :    
995 :     XLODA 0x08, 0x01
996 :     XCHGB 0x10, 0x08
997 :     XCHGA 0x20, 0x10
998 :     XCHGB 0x02, 0x20
999 :     XCHGA 0x04, 0x02
1000 :     XSTRB 0x01, 0x04
1001 :    
1002 :     XLODA 0x09, 0x03
1003 :     XCHGB 0x18, 0x09
1004 :     XCHGA 0x12, 0x18
1005 :     XCHGB 0x24, 0x12
1006 :     XSTRA 0x03, 0x24
1007 :    
1008 :     XLODA 0x0C, 0x05
1009 :     XCHGB 0x11, 0x0C
1010 :     XCHGA 0x28, 0x11
1011 :     XCHGB 0x30, 0x28
1012 :     XCHGA 0x22, 0x30
1013 :     XCHGB 0x06, 0x22
1014 :     XSTRA 0x05, 0x06
1015 :    
1016 :     XLODA 0x0D, 0x07
1017 :     XCHGB 0x1C, 0x0D
1018 :     XCHGA 0x13, 0x1C
1019 :     XCHGB 0x29, 0x13
1020 :     XCHGA 0x38, 0x29
1021 :     XCHGB 0x32, 0x38
1022 :     XCHGA 0x26, 0x32
1023 :     XSTRB 0x07, 0x26
1024 :    
1025 :     XLODA 0x14, 0x0A
1026 :     XCHGB 0x21, 0x14
1027 :     XSTRA 0x0A, 0x21
1028 :    
1029 :     XLODA 0x19, 0x0B
1030 :     XCHGB 0x1A, 0x19
1031 :     XCHGA 0x16, 0x1A
1032 :     XCHGB 0x25, 0x16
1033 :     XCHGA 0x0E, 0x25
1034 :     XCHGB 0x15, 0x0E
1035 :     XCHGA 0x2C, 0x15
1036 :     XCHGB 0x31, 0x2C
1037 :     XCHGA 0x2A, 0x31
1038 :     XCHGB 0x34, 0x2A
1039 :     XCHGA 0x23, 0x34
1040 :     XSTRB 0x0B, 0x23
1041 :    
1042 :     XLODA 0x1D, 0x0F
1043 :     XCHGB 0x1E, 0x1D
1044 :     XCHGA 0x17, 0x1E
1045 :     XCHGB 0x2D, 0x17
1046 :     XCHGA 0x3C, 0x2D
1047 :     XCHGB 0x33, 0x3C
1048 :     XCHGA 0x2B, 0x33
1049 :     XCHGB 0x39, 0x2B
1050 :     XCHGA 0x3A, 0x39
1051 :     XCHGB 0x36, 0x3A
1052 :     XCHGA 0x27, 0x36
1053 :     XSTRB 0x0F, 0x27
1054 :    
1055 :     ; XCHGA 0x1B, 0x1B
1056 :    
1057 :     ; XCHGA 0x1F, 0x1F
1058 :    
1059 :     XLODA 0x35, 0x2E
1060 :     XSTRB 0x2E, 0x35
1061 :    
1062 :     XLODA 0x3D, 0x2F
1063 :     XCHGB 0x3E, 0x3D
1064 :     XCHGA 0x37, 0x3E
1065 :     XSTRB 0x2F, 0x37
1066 : edgomez 1.2
1067 : edgomez 1.4 ; XCHGA 0x3B, 0x3B
1068 : edgomez 1.2
1069 : edgomez 1.4 ; XCHGA 0x3F, 0x3F
1070 :     pop ebx
1071 :     %undef srcP
1072 : edgomez 1.2 %endmacro
1073 :    
1074 : edgomez 1.4 ;=============================================================================
1075 :     ; Code
1076 :     ;=============================================================================
1077 :    
1078 :     SECTION .text
1079 :    
1080 :     cglobal simple_idct_mmx_P
1081 :     cglobal simple_idct_mmx
1082 : edgomez 1.2
1083 : edgomez 1.4 ;-----------------------------------------------------------------------------
1084 :     ; void simple_idct_mmx_P(int16_t * const block)
1085 : Isibaar 1.3 ; expects input data to be permutated
1086 : edgomez 1.4 ;-----------------------------------------------------------------------------
1087 :    
1088 :     ALIGN 16
1089 :     simple_idct_mmx_P:
1090 :     sub esp, 128
1091 :     mov edx, [esp+128+4]
1092 :    
1093 :     ; src0, src4, src1, src5, dst, rndop, rndarg, shift, bt
1094 :     DC_COND_IDCT edx+0, edx+8, edx+16, edx+24, esp, paddd, [coeffs+8], 11
1095 :     Z_COND_IDCT edx+32, edx+40, edx+48, edx+56, esp+32, paddd, [coeffs], 11, .four
1096 :     Z_COND_IDCT edx+64, edx+72, edx+80, edx+88, esp+64, paddd, [coeffs], 11, .two
1097 :     Z_COND_IDCT edx+96, edx+104,edx+112,edx+120,esp+96, paddd, [coeffs], 11, .one
1098 :     IDCT0 esp, esp+64, esp+32, esp+96, edx, nop, 0, 20
1099 :     IDCT0 esp+8, esp+72, esp+40, esp+104,edx+4, nop, 0, 20
1100 :     IDCT0 esp+16, esp+80, esp+48, esp+112,edx+8, nop, 0, 20
1101 :     IDCT0 esp+24, esp+88, esp+56, esp+120,edx+12, nop, 0, 20
1102 :     jmp .ret
1103 : edgomez 1.2
1104 : edgomez 1.4 ALIGN 16
1105 : Isibaar 1.9 .four:
1106 : edgomez 1.4 Z_COND_IDCT edx+64, edx+72, edx+80, edx+88, esp+64, paddd, [coeffs], 11, .six
1107 :     Z_COND_IDCT edx+96, edx+104,edx+112,edx+120,esp+96, paddd, [coeffs], 11, .five
1108 :     IDCT4 esp, esp+64, esp+32, esp+96, edx, nop, 0, 20
1109 :     IDCT4 esp+8, esp+72, esp+40, esp+104,edx+4, nop, 0, 20
1110 :     IDCT4 esp+16, esp+80, esp+48, esp+112,edx+8, nop, 0, 20
1111 :     IDCT4 esp+24, esp+88, esp+56, esp+120,edx+12, nop, 0, 20
1112 :     jmp .ret
1113 : edgomez 1.2
1114 : edgomez 1.4 ALIGN 16
1115 : Isibaar 1.9 .six:
1116 : edgomez 1.4 Z_COND_IDCT edx+96, edx+104,edx+112,edx+120,esp+96, paddd, [coeffs], 11, .seven
1117 :     IDCT6 esp, esp+64, esp+32, esp+96, edx, nop, 0, 20
1118 :     IDCT6 esp+8, esp+72, esp+40, esp+104,edx+4, nop, 0, 20
1119 :     IDCT6 esp+16, esp+80, esp+48, esp+112,edx+8, nop, 0, 20
1120 :     IDCT6 esp+24, esp+88, esp+56, esp+120,edx+12, nop, 0, 20
1121 :     jmp .ret
1122 : edgomez 1.2
1123 : edgomez 1.4 ALIGN 16
1124 : Isibaar 1.9 .two:
1125 : edgomez 1.4 Z_COND_IDCT edx+96, edx+104,edx+112,edx+120,esp+96, paddd, [coeffs], 11, .three
1126 :     IDCT2 esp, esp+64, esp+32, esp+96, edx, nop, 0, 20
1127 :     IDCT2 esp+8, esp+72, esp+40, esp+104,edx+4, nop, 0, 20
1128 :     IDCT2 esp+16, esp+80, esp+48, esp+112,edx+8, nop, 0, 20
1129 :     IDCT2 esp+24, esp+88, esp+56, esp+120,edx+12, nop, 0, 20
1130 :     jmp .ret
1131 : edgomez 1.2
1132 : edgomez 1.4 ALIGN 16
1133 : Isibaar 1.9 .three:
1134 : edgomez 1.4 IDCT3 esp, esp+64, esp+32, esp+96, edx, nop, 0, 20
1135 :     IDCT3 esp+8, esp+72, esp+40, esp+104,edx+4, nop, 0, 20
1136 :     IDCT3 esp+16, esp+80, esp+48, esp+112,edx+8, nop, 0, 20
1137 :     IDCT3 esp+24, esp+88, esp+56, esp+120,edx+12, nop, 0, 20
1138 :     jmp .ret
1139 : edgomez 1.2
1140 : edgomez 1.4 ALIGN 16
1141 : Isibaar 1.9 .five:
1142 : edgomez 1.4 IDCT5 esp, esp+64, esp+32, esp+96, edx, nop, 0, 20
1143 :     ; IDCT5 esp+8, esp+72, esp+40, esp+104,edx+4, nop, 0, 20
1144 :     IDCT5 esp+16, esp+80, esp+48, esp+112,edx+8, nop, 0, 20
1145 :     ; IDCT5 esp+24, esp+88, esp+56, esp+120,edx+12, nop, 0, 20
1146 :     jmp .ret
1147 : edgomez 1.2
1148 : edgomez 1.4 ALIGN 16
1149 : Isibaar 1.9 .one:
1150 : edgomez 1.4 IDCT1 esp, esp+64, esp+32, esp+96, edx, nop, 0, 20
1151 :     IDCT1 esp+8, esp+72, esp+40, esp+104,edx+4, nop, 0, 20
1152 :     IDCT1 esp+16, esp+80, esp+48, esp+112,edx+8, nop, 0, 20
1153 :     IDCT1 esp+24, esp+88, esp+56, esp+120,edx+12, nop, 0, 20
1154 :     jmp .ret
1155 : edgomez 1.2
1156 : edgomez 1.4 ALIGN 16
1157 : Isibaar 1.9 .seven:
1158 : edgomez 1.4 IDCT7 esp, esp+64, esp+32, esp+96, edx, nop, 0, 20
1159 :     ; IDCT7 esp+8, esp+72, esp+40, esp+104,edx+4, nop, 0, 20
1160 :     IDCT7 esp+16, esp+80, esp+48, esp+112,edx+8, nop, 0, 20
1161 :     ; IDCT7 esp+24, esp+88, esp+56, esp+120,edx+12, nop, 0, 20
1162 : edgomez 1.2
1163 : Isibaar 1.9 .ret:
1164 : edgomez 1.4 add esp, 128
1165 : Isibaar 1.3
1166 : edgomez 1.4 ret
1167 : Isibaar 1.9 ENDFUNC
1168 : Isibaar 1.3
1169 : edgomez 1.4
1170 :     ;-----------------------------------------------------------------------------
1171 :     ; void simple_idct_mmx(int16_t * const block)
1172 : Isibaar 1.3 ;
1173 : edgomez 1.4 ; simple_idct_mmx is the same function as simple_idct_mmx_P above except that
1174 :     ; on entry it will do a fast in-line and in-place permutation on the iDCT parm
1175 :     ; list. This means that same parm list will also not have to be copied on the
1176 :     ; way out. - trbarry 6/2003
1177 :     ;-----------------------------------------------------------------------------
1178 :    
1179 :     ALIGN 16
1180 :     simple_idct_mmx:
1181 :     sub esp, 128
1182 :     mov edx, [esp+128+4]
1183 :     PERMUTEP edx ; permute parm list in place
1184 :    
1185 :     ; src0, src4, src1, src5, dst, rndop, rndarg, shift, bt
1186 :     DC_COND_IDCT edx+0, edx+8, edx+16, edx+24, esp, paddd, [coeffs+8], 11
1187 :     Z_COND_IDCT edx+32, edx+40, edx+48, edx+56, esp+32, paddd, [coeffs], 11, .fourP
1188 :     Z_COND_IDCT edx+64, edx+72, edx+80, edx+88, esp+64, paddd, [coeffs], 11, .twoP
1189 :     Z_COND_IDCT edx+96, edx+104,edx+112,edx+120,esp+96, paddd, [coeffs], 11, .oneP
1190 :     IDCT0 esp, esp+64, esp+32, esp+96, edx, nop, 0, 20
1191 :     IDCT0 esp+8, esp+72, esp+40, esp+104,edx+4, nop, 0, 20
1192 :     IDCT0 esp+16, esp+80, esp+48, esp+112,edx+8, nop, 0, 20
1193 :     IDCT0 esp+24, esp+88, esp+56, esp+120,edx+12, nop, 0, 20
1194 :     jmp .retP
1195 : Isibaar 1.3
1196 : edgomez 1.4 ALIGN 16
1197 : Isibaar 1.9 .fourP:
1198 : edgomez 1.4 Z_COND_IDCT edx+64, edx+72, edx+80, edx+88, esp+64, paddd, [coeffs], 11, .sixP
1199 :     Z_COND_IDCT edx+96, edx+104,edx+112,edx+120,esp+96, paddd, [coeffs], 11, .fiveP
1200 :     IDCT4 esp, esp+64, esp+32, esp+96, edx, nop, 0, 20
1201 :     IDCT4 esp+8, esp+72, esp+40, esp+104,edx+4, nop, 0, 20
1202 :     IDCT4 esp+16, esp+80, esp+48, esp+112,edx+8, nop, 0, 20
1203 :     IDCT4 esp+24, esp+88, esp+56, esp+120,edx+12, nop, 0, 20
1204 :     jmp .retP
1205 : Isibaar 1.3
1206 : edgomez 1.4 ALIGN 16
1207 : Isibaar 1.9 .sixP:
1208 : edgomez 1.4 Z_COND_IDCT edx+96, edx+104,edx+112,edx+120,esp+96, paddd, [coeffs], 11, .sevenP
1209 :     IDCT6 esp, esp+64, esp+32, esp+96, edx, nop, 0, 20
1210 :     IDCT6 esp+8, esp+72, esp+40, esp+104,edx+4, nop, 0, 20
1211 :     IDCT6 esp+16, esp+80, esp+48, esp+112,edx+8, nop, 0, 20
1212 :     IDCT6 esp+24, esp+88, esp+56, esp+120,edx+12, nop, 0, 20
1213 :     jmp .retP
1214 : Isibaar 1.3
1215 : edgomez 1.4 ALIGN 16
1216 : Isibaar 1.9 .twoP:
1217 : edgomez 1.4 Z_COND_IDCT edx+96, edx+104,edx+112,edx+120,esp+96, paddd, [coeffs], 11, .threeP
1218 :     IDCT2 esp, esp+64, esp+32, esp+96, edx, nop, 0, 20
1219 :     IDCT2 esp+8, esp+72, esp+40, esp+104,edx+4, nop, 0, 20
1220 :     IDCT2 esp+16, esp+80, esp+48, esp+112,edx+8, nop, 0, 20
1221 :     IDCT2 esp+24, esp+88, esp+56, esp+120,edx+12, nop, 0, 20
1222 :     jmp .retP
1223 : Isibaar 1.3
1224 : edgomez 1.4 ALIGN 16
1225 : Isibaar 1.9 .threeP:
1226 : edgomez 1.4 IDCT3 esp, esp+64, esp+32, esp+96, edx, nop, 0, 20
1227 :     IDCT3 esp+8, esp+72, esp+40, esp+104,edx+4, nop, 0, 20
1228 :     IDCT3 esp+16, esp+80, esp+48, esp+112,edx+8, nop, 0, 20
1229 :     IDCT3 esp+24, esp+88, esp+56, esp+120,edx+12, nop, 0, 20
1230 :     jmp .retP
1231 : Isibaar 1.3
1232 : edgomez 1.4 ALIGN 16
1233 : Isibaar 1.9 .fiveP:
1234 : edgomez 1.4 IDCT5 esp, esp+64, esp+32, esp+96, edx, nop, 0, 20
1235 :     ; IDCT5 esp+8, esp+72, esp+40, esp+104,edx+4, nop, 0, 20
1236 :     IDCT5 esp+16, esp+80, esp+48, esp+112,edx+8, nop, 0, 20
1237 :     ; IDCT5 esp+24, esp+88, esp+56, esp+120,edx+12, nop, 0, 20
1238 :     jmp .retP
1239 : Isibaar 1.3
1240 : edgomez 1.4 ALIGN 16
1241 : Isibaar 1.9 .oneP:
1242 : edgomez 1.4 IDCT1 esp, esp+64, esp+32, esp+96, edx, nop, 0, 20
1243 :     IDCT1 esp+8, esp+72, esp+40, esp+104,edx+4, nop, 0, 20
1244 :     IDCT1 esp+16, esp+80, esp+48, esp+112,edx+8, nop, 0, 20
1245 :     IDCT1 esp+24, esp+88, esp+56, esp+120,edx+12, nop, 0, 20
1246 :     jmp .retP
1247 : Isibaar 1.3
1248 : edgomez 1.4 ALIGN 16
1249 : Isibaar 1.9 .sevenP:
1250 : edgomez 1.4 IDCT7 esp, esp+64, esp+32, esp+96, edx, nop, 0, 20
1251 :     ; IDCT7 esp+8, esp+72, esp+40, esp+104,edx+4, nop, 0, 20
1252 :     IDCT7 esp+16, esp+80, esp+48, esp+112,edx+8, nop, 0, 20
1253 :     ; IDCT7 esp+24, esp+88, esp+56, esp+120,edx+12, nop, 0, 20
1254 : Isibaar 1.3
1255 : Isibaar 1.9 .retP:
1256 : edgomez 1.4 add esp, 128
1257 : edgomez 1.2
1258 : edgomez 1.4 ret
1259 : Isibaar 1.9 ENDFUNC
1260 : edgomez 1.7
1261 : Isibaar 1.8
1262 :     %ifidn __OUTPUT_FORMAT__,elf
1263 :     section ".note.GNU-stack" noalloc noexec nowrite progbits
1264 :     %endif
1265 :    

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4