[svn] / trunk / xvidcore / src / dct / x86_asm / fdct_sse2_skal.asm Repository:
ViewVC logotype

Annotation of /trunk/xvidcore/src/dct/x86_asm/fdct_sse2_skal.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1793 - (view) (download)

1 : edgomez 1382 ;/****************************************************************************
2 :     ; *
3 :     ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * - SSE2 forward discrete cosine transform -
5 :     ; *
6 :     ; * Copyright(C) 2003 Pascal Massimino <skal@planet-d.net>
7 :     ; *
8 :     ; * This program is free software; you can redistribute it and/or modify it
9 :     ; * 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 :     ; * This program 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 : Isibaar 1793 ; * $Id: fdct_sse2_skal.asm,v 1.9 2008-11-11 20:46:24 Isibaar Exp $
23 : edgomez 1382 ; *
24 :     ; ***************************************************************************/
25 :    
26 :     BITS 32
27 :    
28 :     %macro cglobal 1
29 : edgomez 1535 %ifdef PREFIX
30 :     %ifdef MARK_FUNCS
31 : edgomez 1540 global _%1:function %1.endfunc-%1
32 :     %define %1 _%1:function %1.endfunc-%1
33 : Isibaar 1793 %define ENDFUNC .endfunc
34 : edgomez 1535 %else
35 :     global _%1
36 :     %define %1 _%1
37 : Isibaar 1793 %define ENDFUNC
38 : edgomez 1535 %endif
39 :     %else
40 :     %ifdef MARK_FUNCS
41 : edgomez 1540 global %1:function %1.endfunc-%1
42 : Isibaar 1793 %define ENDFUNC .endfunc
43 : edgomez 1535 %else
44 :     global %1
45 : Isibaar 1793 %define ENDFUNC
46 : edgomez 1535 %endif
47 :     %endif
48 : edgomez 1382 %endmacro
49 :    
50 :     ;-----------------------------------------------------------------------------
51 :     ;
52 :     ; -=FDCT=-
53 :     ;
54 :     ; Vertical pass is an implementation of the scheme:
55 :     ; Loeffler C., Ligtenberg A., and Moschytz C.S.:
56 :     ; Practical Fast 1D DCT Algorithm with Eleven Multiplications,
57 :     ; Proc. ICASSP 1989, 988-991.
58 :     ;
59 :     ; Horizontal pass is a double 4x4 vector/matrix multiplication,
60 :     ; (see also Intel's Application Note 922:
61 :     ; http://developer.intel.com/vtune/cbts/strmsimd/922down.htm
62 :     ; Copyright (C) 1999 Intel Corporation)
63 :     ;
64 :     ; Notes:
65 :     ; * tan(3pi/16) is greater than 0.5, and would use the
66 :     ; sign bit when turned into 16b fixed-point precision. So,
67 :     ; we use the trick: x*tan3 = x*(tan3-1)+x
68 :     ;
69 :     ; * There's only one SSE-specific instruction (pshufw).
70 :     ;
71 :     ; * There's still 1 or 2 ticks to save in fLLM_PASS, but
72 :     ; I prefer having a readable code, instead of a tightly
73 :     ; scheduled one...
74 :     ;
75 :     ; * Quantization stage (as well as pre-transposition for the
76 :     ; idct way back) can be included in the fTab* constants
77 :     ; (with induced loss of precision, somehow)
78 :     ;
79 :     ; * Some more details at: http://skal.planet-d.net/coding/dct.html
80 :     ;
81 :     ;-----------------------------------------------------------------------------
82 :     ;
83 :     ; -=IDCT=-
84 :     ;
85 :     ; A little slower than fdct, because the final stages (butterflies and
86 :     ; descaling) require some unpairable shifting and packing, all on
87 :     ; the same CPU unit.
88 :     ;
89 :     ;-----------------------------------------------------------------------------
90 :    
91 :     ;=============================================================================
92 :     ; Read only data
93 :     ;=============================================================================
94 :    
95 :     %ifdef FORMAT_COFF
96 : edgomez 1519 SECTION .rodata
97 : edgomez 1382 %else
98 : edgomez 1519 SECTION .rodata align=16
99 : edgomez 1382 %endif
100 :    
101 :     ALIGN 16
102 :     tan1: times 8 dw 0x32ec ; tan( pi/16)
103 :     tan2: times 8 dw 0x6a0a ; tan(2pi/16) (=sqrt(2)-1)
104 :     tan3: times 8 dw 0xab0e ; tan(3pi/16)-1
105 :     sqrt2: times 8 dw 0x5a82 ; 0.5/sqrt(2)
106 :    
107 :     ;-----------------------------------------------------------------------------
108 :     ; Inverse DCT tables
109 :     ;-----------------------------------------------------------------------------
110 :    
111 : Isibaar 1627 ALIGN 16
112 : edgomez 1382 iTab1:
113 :     dw 0x4000, 0x539f, 0x4000, 0x22a3
114 :     dw 0x4000, 0xdd5d, 0x4000, 0xac61
115 :     dw 0x4000, 0x22a3, 0xc000, 0xac61
116 :     dw 0xc000, 0x539f, 0x4000, 0xdd5d
117 :     dw 0x58c5, 0x4b42, 0x4b42, 0xee58
118 :     dw 0x3249, 0xa73b, 0x11a8, 0xcdb7
119 :     dw 0x3249, 0x11a8, 0xa73b, 0xcdb7
120 :     dw 0x11a8, 0x4b42, 0x4b42, 0xa73b
121 :    
122 :     iTab2:
123 :     dw 0x58c5, 0x73fc, 0x58c5, 0x300b
124 :     dw 0x58c5, 0xcff5, 0x58c5, 0x8c04
125 :     dw 0x58c5, 0x300b, 0xa73b, 0x8c04
126 :     dw 0xa73b, 0x73fc, 0x58c5, 0xcff5
127 :     dw 0x7b21, 0x6862, 0x6862, 0xe782
128 :     dw 0x45bf, 0x84df, 0x187e, 0xba41
129 :     dw 0x45bf, 0x187e, 0x84df, 0xba41
130 :     dw 0x187e, 0x6862, 0x6862, 0x84df
131 :    
132 :     iTab3:
133 :     dw 0x539f, 0x6d41, 0x539f, 0x2d41
134 :     dw 0x539f, 0xd2bf, 0x539f, 0x92bf
135 :     dw 0x539f, 0x2d41, 0xac61, 0x92bf
136 :     dw 0xac61, 0x6d41, 0x539f, 0xd2bf
137 :     dw 0x73fc, 0x6254, 0x6254, 0xe8ee
138 :     dw 0x41b3, 0x8c04, 0x1712, 0xbe4d
139 :     dw 0x41b3, 0x1712, 0x8c04, 0xbe4d
140 :     dw 0x1712, 0x6254, 0x6254, 0x8c04
141 :    
142 :     iTab4:
143 :     dw 0x4b42, 0x6254, 0x4b42, 0x28ba
144 :     dw 0x4b42, 0xd746, 0x4b42, 0x9dac
145 :     dw 0x4b42, 0x28ba, 0xb4be, 0x9dac
146 :     dw 0xb4be, 0x6254, 0x4b42, 0xd746
147 :     dw 0x6862, 0x587e, 0x587e, 0xeb3d
148 :     dw 0x3b21, 0x979e, 0x14c3, 0xc4df
149 :     dw 0x3b21, 0x14c3, 0x979e, 0xc4df
150 :     dw 0x14c3, 0x587e, 0x587e, 0x979e
151 :    
152 : Isibaar 1627 ALIGN 16
153 : Skal 1618 Walken_Idct_Rounders:
154 :     dd 65536, 65536, 65536, 65536
155 :     dd 3597, 3597, 3597, 3597
156 :     dd 2260, 2260, 2260, 2260
157 :     dd 1203, 1203, 1203, 1203
158 :     dd 0, 0, 0, 0
159 :     dd 120, 120, 120, 120
160 :     dd 512, 512, 512, 512
161 :     dd 512, 512, 512, 512
162 : edgomez 1382
163 : Skal 1618 times 8 dw (65536>>11)
164 :     times 8 dw ( 3597>>11)
165 :     times 8 dw ( 2260>>11)
166 : edgomez 1382 ; other rounders are zero...
167 :    
168 :     ;-----------------------------------------------------------------------------
169 :     ; Forward DCT tables
170 :     ;-----------------------------------------------------------------------------
171 :    
172 :     ALIGN 16
173 :     fTab1:
174 :     dw 0x4000, 0x4000, 0x58c5, 0x4b42,
175 :     dw 0xdd5d, 0xac61, 0xa73b, 0xcdb7,
176 :     dw 0x4000, 0x4000, 0x3249, 0x11a8,
177 :     dw 0x539f, 0x22a3, 0x4b42, 0xee58,
178 :     dw 0x4000, 0xc000, 0x3249, 0xa73b,
179 :     dw 0x539f, 0xdd5d, 0x4b42, 0xa73b,
180 :     dw 0xc000, 0x4000, 0x11a8, 0x4b42,
181 :     dw 0x22a3, 0xac61, 0x11a8, 0xcdb7
182 :    
183 :     fTab2:
184 :     dw 0x58c5, 0x58c5, 0x7b21, 0x6862,
185 :     dw 0xcff5, 0x8c04, 0x84df, 0xba41,
186 :     dw 0x58c5, 0x58c5, 0x45bf, 0x187e,
187 :     dw 0x73fc, 0x300b, 0x6862, 0xe782,
188 :     dw 0x58c5, 0xa73b, 0x45bf, 0x84df,
189 :     dw 0x73fc, 0xcff5, 0x6862, 0x84df,
190 :     dw 0xa73b, 0x58c5, 0x187e, 0x6862,
191 :     dw 0x300b, 0x8c04, 0x187e, 0xba41
192 :    
193 :     fTab3:
194 :     dw 0x539f, 0x539f, 0x73fc, 0x6254,
195 :     dw 0xd2bf, 0x92bf, 0x8c04, 0xbe4d,
196 :     dw 0x539f, 0x539f, 0x41b3, 0x1712,
197 :     dw 0x6d41, 0x2d41, 0x6254, 0xe8ee,
198 :     dw 0x539f, 0xac61, 0x41b3, 0x8c04,
199 :     dw 0x6d41, 0xd2bf, 0x6254, 0x8c04,
200 :     dw 0xac61, 0x539f, 0x1712, 0x6254,
201 :     dw 0x2d41, 0x92bf, 0x1712, 0xbe4d
202 :    
203 :     fTab4:
204 :     dw 0x4b42, 0x4b42, 0x6862, 0x587e,
205 :     dw 0xd746, 0x9dac, 0x979e, 0xc4df,
206 :     dw 0x4b42, 0x4b42, 0x3b21, 0x14c3,
207 :     dw 0x6254, 0x28ba, 0x587e, 0xeb3d,
208 :     dw 0x4b42, 0xb4be, 0x3b21, 0x979e,
209 :     dw 0x6254, 0xd746, 0x587e, 0x979e,
210 :     dw 0xb4be, 0x4b42, 0x14c3, 0x587e,
211 :     dw 0x28ba, 0x9dac, 0x14c3, 0xc4df
212 :    
213 :    
214 :     ALIGN 16
215 :     Fdct_Rnd0: dw 6,8,8,8, 6,8,8,8
216 :     Fdct_Rnd1: dw 8,8,8,8, 8,8,8,8
217 :     Fdct_Rnd2: dw 10,8,8,8, 8,8,8,8
218 :     Rounder1: dw 1,1,1,1, 1,1,1,1
219 :    
220 :     ;=============================================================================
221 :     ; Code
222 :     ;=============================================================================
223 :    
224 :     SECTION .text
225 :    
226 :     cglobal idct_sse2_skal
227 :     cglobal fdct_sse2_skal
228 :    
229 :     ;-----------------------------------------------------------------------------
230 :     ; Helper macro iMTX_MULT
231 :     ;-----------------------------------------------------------------------------
232 :    
233 :     %macro iMTX_MULT 4 ; %1=src, %2 = Table to use, %3=rounder, %4=Shift
234 :    
235 :     movdqa xmm0, [ecx+%1*16] ; xmm0 = [01234567]
236 :    
237 : Skal 1618 pshuflw xmm0, xmm0, 11011000b ; [02134567] ; these two shufflings could be
238 :     pshufhw xmm0, xmm0, 11011000b ; [02134657] ; integrated in zig-zag orders
239 :    
240 : edgomez 1382 pshufd xmm4, xmm0, 00000000b ; [02020202]
241 :     pshufd xmm5, xmm0, 10101010b ; [46464646]
242 :     pshufd xmm6, xmm0, 01010101b ; [13131313]
243 :     pshufd xmm7, xmm0, 11111111b ; [57575757]
244 :    
245 :     pmaddwd xmm4, [%2+ 0] ; dot [M00,M01][M04,M05][M08,M09][M12,M13]
246 :     pmaddwd xmm5, [%2+16] ; dot [M02,M03][M06,M07][M10,M11][M14,M15]
247 :     pmaddwd xmm6, [%2+32] ; dot [M16,M17][M20,M21][M24,M25][M28,M29]
248 :     pmaddwd xmm7, [%2+48] ; dot [M18,M19][M22,M23][M26,M27][M30,M31]
249 :     paddd xmm4, [%3] ; Round
250 :    
251 :     paddd xmm6, xmm7 ; [b0|b1|b2|b3]
252 :     paddd xmm4, xmm5 ; [a0|a1|a2|a3]
253 :    
254 :     movdqa xmm7, xmm6
255 :     paddd xmm6, xmm4 ; mm6=a+b
256 :     psubd xmm4, xmm7 ; mm4=a-b
257 :     psrad xmm6, %4 ; => out [0123]
258 :     psrad xmm4, %4 ; => out [7654]
259 :    
260 :     packssdw xmm6, xmm4 ; [01237654]
261 : Skal 1618
262 : edgomez 1382 pshufhw xmm6, xmm6, 00011011b ; [01234567]
263 :    
264 :     movdqa [ecx+%1*16], xmm6
265 :    
266 :     %endmacro
267 :    
268 :     ;-----------------------------------------------------------------------------
269 :     ; Helper macro iLLM_PASS
270 :     ;-----------------------------------------------------------------------------
271 :    
272 :     %macro iLLM_PASS 1 ; %1: src/dst
273 :    
274 : Skal 1618 movdqa xmm0, [tan3] ; t3-1
275 :     movdqa xmm3, [%1+16*3] ; x3
276 : edgomez 1382 movdqa xmm1, xmm0 ; t3-1
277 : Skal 1618 movdqa xmm5, [%1+16*5] ; x5
278 : edgomez 1382
279 : Skal 1618 movdqa xmm4, [tan1] ; t1
280 :     movdqa xmm6, [%1+16*1] ; x1
281 :     movdqa xmm7, [%1+16*7] ; x7
282 : edgomez 1382 movdqa xmm2, xmm4 ; t1
283 :    
284 :     pmulhw xmm0, xmm3 ; x3*(t3-1)
285 :     pmulhw xmm1, xmm5 ; x5*(t3-1)
286 :     paddsw xmm0, xmm3 ; x3*t3
287 :     paddsw xmm1, xmm5 ; x5*t3
288 :     psubsw xmm0, xmm5 ; x3*t3-x5 = tm35
289 :     paddsw xmm1, xmm3 ; x3+x5*t3 = tp35
290 :    
291 :     pmulhw xmm4, xmm7 ; x7*t1
292 :     pmulhw xmm2, xmm6 ; x1*t1
293 :     paddsw xmm4, xmm6 ; x1+t1*x7 = tp17
294 :     psubsw xmm2, xmm7 ; x1*t1-x7 = tm17
295 :    
296 :    
297 :     movdqa xmm3, [sqrt2]
298 :     movdqa xmm7, xmm4
299 :     movdqa xmm6, xmm2
300 :     psubsw xmm4, xmm1 ; tp17-tp35 = t1
301 :     psubsw xmm2, xmm0 ; tm17-tm35 = b3
302 :     paddsw xmm1, xmm7 ; tp17+tp35 = b0
303 :     paddsw xmm0, xmm6 ; tm17+tm35 = t2
304 :    
305 :     ; xmm1 = b0, xmm2 = b3. preserved
306 :    
307 :     movdqa xmm6, xmm4
308 :     psubsw xmm4, xmm0 ; t1-t2
309 :     paddsw xmm0, xmm6 ; t1+t2
310 :    
311 :     pmulhw xmm4, xmm3 ; (t1-t2)/(2.sqrt2)
312 :     pmulhw xmm0, xmm3 ; (t1+t2)/(2.sqrt2)
313 :    
314 :     paddsw xmm0, xmm0 ; 2.(t1+t2) = b1
315 :     paddsw xmm4, xmm4 ; 2.(t1-t2) = b2
316 :    
317 : Skal 1618 movdqa xmm7, [tan2] ; t2
318 :     movdqa xmm3, [%1+2*16] ; x2
319 :     movdqa xmm6, [%1+6*16] ; x6
320 : edgomez 1382 movdqa xmm5, xmm7 ; t2
321 :    
322 :     pmulhw xmm7, xmm6 ; x6*t2
323 :     pmulhw xmm5, xmm3 ; x2*t2
324 :    
325 :     paddsw xmm7, xmm3 ; x2+x6*t2 = tp26
326 :     psubsw xmm5, xmm6 ; x2*t2-x6 = tm26
327 :    
328 :    
329 : Skal 1618 ; use:xmm3,xmm5,xmm6,xmm7 frozen: xmm0,xmm4,xmm1,xmm2
330 : edgomez 1382
331 :     movdqa xmm3, [%1+0*16] ; x0
332 :     movdqa xmm6, [%1+4*16] ; x4
333 :    
334 : Skal 1618 movdqa [%1 ], xmm2 ; we spill 1 reg to perform safe butterflies
335 :    
336 :     movdqa xmm2, xmm3
337 : edgomez 1382 psubsw xmm3, xmm6 ; x0-x4 = tm04
338 : Skal 1618 paddsw xmm6, xmm2 ; x0+x4 = tp04
339 : edgomez 1382
340 : Skal 1618 movdqa xmm2, xmm6
341 :     psubsw xmm6, xmm7
342 :     paddsw xmm7, xmm2
343 :     movdqa xmm2, xmm3
344 :     psubsw xmm3, xmm5
345 :     paddsw xmm5, xmm2
346 : edgomez 1382
347 : Skal 1618 movdqa xmm2, xmm5
348 :     psubsw xmm5, xmm0
349 :     paddsw xmm0, xmm2
350 :     movdqa xmm2, xmm3
351 :     psubsw xmm3, xmm4
352 :     paddsw xmm4, xmm2
353 : edgomez 1382
354 : Skal 1618 movdqa xmm2, [%1]
355 : edgomez 1382
356 : Skal 1618 psraw xmm5, 6 ; out6
357 :     psraw xmm3, 6 ; out5
358 :     psraw xmm0, 6 ; out1
359 :     psraw xmm4, 6 ; out2
360 :    
361 : edgomez 1382 movdqa [%1+6*16], xmm5
362 :     movdqa [%1+5*16], xmm3
363 :     movdqa [%1+1*16], xmm0
364 :     movdqa [%1+2*16], xmm4
365 :    
366 :     ; reminder: xmm1=b0, xmm2=b3, xmm7=a0, xmm6=a3
367 :    
368 :     movdqa xmm0, xmm7
369 :     movdqa xmm4, xmm6
370 :     psubsw xmm7, xmm1 ; a0-b0
371 :     psubsw xmm6, xmm2 ; a3-b3
372 :     paddsw xmm1, xmm0 ; a0+b0
373 :     paddsw xmm2, xmm4 ; a3+b3
374 :    
375 : Skal 1618 psraw xmm1, 6 ; out0
376 :     psraw xmm7, 6 ; out7
377 :     psraw xmm2, 6 ; out3
378 :     psraw xmm6, 6 ; out4
379 : edgomez 1382
380 : Skal 1618 ; store result
381 :    
382 : edgomez 1382 movdqa [%1+0*16], xmm1
383 :     movdqa [%1+3*16], xmm2
384 :     movdqa [%1+4*16], xmm6
385 :     movdqa [%1+7*16], xmm7
386 : Skal 1618
387 : edgomez 1382 %endmacro
388 :    
389 :     ;-----------------------------------------------------------------------------
390 :     ; Helper macro TEST_ROW (test a null row)
391 :     ;-----------------------------------------------------------------------------
392 :    
393 :     %macro TEST_ROW 2 ; %1:src, %2:label x8
394 :     mov eax, [%1 ]
395 :     mov edx, [%1+ 8]
396 :     or eax, [%1+ 4]
397 :     or edx, [%1+12]
398 :     or eax, edx
399 :     jz near %2
400 :     %endmacro
401 :    
402 :     ;-----------------------------------------------------------------------------
403 :     ; Function idct (this one skips null rows)
404 :     ;-----------------------------------------------------------------------------
405 : Skal 1618 ; IEEE1180 and Walken compatible version
406 : edgomez 1382
407 : Isibaar 1627 ALIGN 16
408 : Skal 1618 idct_sse2_skal:
409 : edgomez 1382
410 :     mov ecx, [esp+ 4] ; Src
411 :    
412 :     TEST_ROW ecx, .Row0_Round
413 : Skal 1618 iMTX_MULT 0, iTab1, Walken_Idct_Rounders + 16*0, 11
414 : edgomez 1382 jmp .Row1
415 : Isibaar 1793 .Row0_Round:
416 : Skal 1618 movdqa xmm0, [Walken_Idct_Rounders + 16*8 + 8*0]
417 :     movdqa [ecx ], xmm0
418 : edgomez 1382
419 : Isibaar 1793 .Row1:
420 : edgomez 1382 TEST_ROW ecx+16, .Row1_Round
421 : Skal 1618 iMTX_MULT 1, iTab2, Walken_Idct_Rounders + 16*1, 11
422 : edgomez 1382 jmp .Row2
423 : Isibaar 1793 .Row1_Round:
424 : Skal 1618 movdqa xmm0, [Walken_Idct_Rounders + 16*8 + 16*1]
425 :     movdqa [ecx+16 ], xmm0
426 : edgomez 1382
427 : Isibaar 1793 .Row2:
428 : edgomez 1382 TEST_ROW ecx+32, .Row2_Round
429 : Skal 1618 iMTX_MULT 2, iTab3, Walken_Idct_Rounders + 16*2, 11
430 : edgomez 1382 jmp .Row3
431 : Isibaar 1793 .Row2_Round:
432 : Skal 1618 movdqa xmm0, [Walken_Idct_Rounders + 16*8 + 16*2]
433 :     movdqa [ecx+32 ], xmm0
434 : edgomez 1382
435 : Isibaar 1793 .Row3:
436 : edgomez 1382 TEST_ROW ecx+48, .Row4
437 : Skal 1618 iMTX_MULT 3, iTab4, Walken_Idct_Rounders + 16*3, 11
438 : edgomez 1382
439 : Isibaar 1793 .Row4:
440 : edgomez 1382 TEST_ROW ecx+64, .Row5
441 : Skal 1618 iMTX_MULT 4, iTab1, Walken_Idct_Rounders + 16*4, 11
442 : edgomez 1382
443 : Isibaar 1793 .Row5:
444 : edgomez 1382 TEST_ROW ecx+80, .Row6
445 : Skal 1618 iMTX_MULT 5, iTab4, Walken_Idct_Rounders + 16*5, 11
446 : edgomez 1382
447 : Isibaar 1793 .Row6:
448 : edgomez 1382 TEST_ROW ecx+96, .Row7
449 : Skal 1618 iMTX_MULT 6, iTab3, Walken_Idct_Rounders + 16*6, 11
450 : edgomez 1382
451 : Isibaar 1793 .Row7:
452 : edgomez 1382 TEST_ROW ecx+112, .End
453 : Skal 1618 iMTX_MULT 7, iTab2, Walken_Idct_Rounders + 16*7, 11
454 : Isibaar 1793 .End:
455 : edgomez 1382
456 : Skal 1618 iLLM_PASS ecx
457 :    
458 : edgomez 1382 ret
459 : Isibaar 1793 ENDFUNC
460 : edgomez 1382
461 :     ;-----------------------------------------------------------------------------
462 :     ; Helper macro fLLM_PASS
463 :     ;-----------------------------------------------------------------------------
464 :    
465 :     %macro fLLM_PASS 2 ; %1: src/dst, %2:Shift
466 :    
467 :     movdqa xmm0, [%1+0*16] ; In0
468 :     movdqa xmm2, [%1+2*16] ; In2
469 :     movdqa xmm3, xmm0
470 :     movdqa xmm4, xmm2
471 :     movdqa xmm7, [%1+7*16] ; In7
472 :     movdqa xmm5, [%1+5*16] ; In5
473 :    
474 :     psubsw xmm0, xmm7 ; t7 = In0-In7
475 :     paddsw xmm7, xmm3 ; t0 = In0+In7
476 :     psubsw xmm2, xmm5 ; t5 = In2-In5
477 :     paddsw xmm5, xmm4 ; t2 = In2+In5
478 :    
479 :     movdqa xmm3, [%1+3*16] ; In3
480 :     movdqa xmm4, [%1+4*16] ; In4
481 :     movdqa xmm1, xmm3
482 :     psubsw xmm3, xmm4 ; t4 = In3-In4
483 :     paddsw xmm4, xmm1 ; t3 = In3+In4
484 :     movdqa xmm6, [%1+6*16] ; In6
485 :     movdqa xmm1, [%1+1*16] ; In1
486 :     psubsw xmm1, xmm6 ; t6 = In1-In6
487 :     paddsw xmm6, [%1+1*16] ; t1 = In1+In6
488 :    
489 :     psubsw xmm7, xmm4 ; tm03 = t0-t3
490 :     psubsw xmm6, xmm5 ; tm12 = t1-t2
491 :     paddsw xmm4, xmm4 ; 2.t3
492 :     paddsw xmm5, xmm5 ; 2.t2
493 :     paddsw xmm4, xmm7 ; tp03 = t0+t3
494 :     paddsw xmm5, xmm6 ; tp12 = t1+t2
495 :    
496 :     psllw xmm2, %2+1 ; shift t5 (shift +1 to..
497 :     psllw xmm1, %2+1 ; shift t6 ..compensate cos4/2)
498 :     psllw xmm4, %2 ; shift t3
499 :     psllw xmm5, %2 ; shift t2
500 :     psllw xmm7, %2 ; shift t0
501 :     psllw xmm6, %2 ; shift t1
502 :     psllw xmm3, %2 ; shift t4
503 :     psllw xmm0, %2 ; shift t7
504 :    
505 :     psubsw xmm4, xmm5 ; out4 = tp03-tp12
506 :     psubsw xmm1, xmm2 ; xmm1: t6-t5
507 :     paddsw xmm5, xmm5
508 :     paddsw xmm2, xmm2
509 :     paddsw xmm5, xmm4 ; out0 = tp03+tp12
510 :     movdqa [%1+4*16], xmm4 ; => out4
511 :     paddsw xmm2, xmm1 ; xmm2: t6+t5
512 :     movdqa [%1+0*16], xmm5 ; => out0
513 :    
514 :     movdqa xmm4, [tan2] ; xmm4 <= tan2
515 :     pmulhw xmm4, xmm7 ; tm03*tan2
516 :     movdqa xmm5, [tan2] ; xmm5 <= tan2
517 :     psubsw xmm4, xmm6 ; out6 = tm03*tan2 - tm12
518 :     pmulhw xmm5, xmm6 ; tm12*tan2
519 :     paddsw xmm5, xmm7 ; out2 = tm12*tan2 + tm03
520 :    
521 :     movdqa xmm6, [sqrt2]
522 :     movdqa xmm7, [Rounder1]
523 :    
524 :     pmulhw xmm2, xmm6 ; xmm2: tp65 = (t6 + t5)*cos4
525 :     por xmm5, xmm7 ; correct out2
526 :     por xmm4, xmm7 ; correct out6
527 :     pmulhw xmm1, xmm6 ; xmm1: tm65 = (t6 - t5)*cos4
528 :     por xmm2, xmm7 ; correct tp65
529 :    
530 :     movdqa [%1+2*16], xmm5 ; => out2
531 :     movdqa xmm5, xmm3 ; save t4
532 :     movdqa [%1+6*16], xmm4 ; => out6
533 :     movdqa xmm4, xmm0 ; save t7
534 :    
535 :     psubsw xmm3, xmm1 ; xmm3: tm465 = t4 - tm65
536 :     psubsw xmm0, xmm2 ; xmm0: tm765 = t7 - tp65
537 :     paddsw xmm2, xmm4 ; xmm2: tp765 = t7 + tp65
538 :     paddsw xmm1, xmm5 ; xmm1: tp465 = t4 + tm65
539 :    
540 :     movdqa xmm4, [tan3] ; tan3 - 1
541 :     movdqa xmm5, [tan1] ; tan1
542 :    
543 :     movdqa xmm7, xmm3 ; save tm465
544 :     pmulhw xmm3, xmm4 ; tm465*(tan3-1)
545 :     movdqa xmm6, xmm1 ; save tp465
546 :     pmulhw xmm1, xmm5 ; tp465*tan1
547 :    
548 :     paddsw xmm3, xmm7 ; tm465*tan3
549 :     pmulhw xmm4, xmm0 ; tm765*(tan3-1)
550 :     paddsw xmm4, xmm0 ; tm765*tan3
551 :     pmulhw xmm5, xmm2 ; tp765*tan1
552 :    
553 :     paddsw xmm1, xmm2 ; out1 = tp765 + tp465*tan1
554 :     psubsw xmm0, xmm3 ; out3 = tm765 - tm465*tan3
555 :     paddsw xmm7, xmm4 ; out5 = tm465 + tm765*tan3
556 :     psubsw xmm5, xmm6 ; out7 =-tp465 + tp765*tan1
557 :    
558 :     movdqa [%1+1*16], xmm1 ; => out1
559 :     movdqa [%1+3*16], xmm0 ; => out3
560 :     movdqa [%1+5*16], xmm7 ; => out5
561 :     movdqa [%1+7*16], xmm5 ; => out7
562 :    
563 :     %endmacro
564 :    
565 :     ;-----------------------------------------------------------------------------
566 :     ;Helper macro fMTX_MULT
567 :     ;-----------------------------------------------------------------------------
568 :    
569 :     %macro fMTX_MULT 3 ; %1=src, %2 = Coeffs, %3=rounders
570 :    
571 :     movdqa xmm0, [ecx+%1*16+0] ; xmm0 = [0123][4567]
572 :     pshufhw xmm1, xmm0, 00011011b ; xmm1 = [----][7654]
573 :     pshufd xmm0, xmm0, 01000100b
574 :     pshufd xmm1, xmm1, 11101110b
575 :    
576 :     movdqa xmm2, xmm0
577 :     paddsw xmm0, xmm1 ; xmm0 = [a0 a1 a2 a3]
578 :     psubsw xmm2, xmm1 ; xmm2 = [b0 b1 b2 b3]
579 :    
580 :     punpckldq xmm0, xmm2 ; xmm0 = [a0 a1 b0 b1][a2 a3 b2 b3]
581 :     pshufd xmm2, xmm0, 01001110b ; xmm2 = [a2 a3 b2 b3][a0 a1 b0 b1]
582 :    
583 :     ; [M00 M01 M16 M17] [M06 M07 M22 M23] x mm0 = [0 /1 /2'/3']
584 :     ; [M02 M03 M18 M19] [M04 M05 M20 M21] x mm2 = [0'/1'/2 /3 ]
585 :     ; [M08 M09 M24 M25] [M14 M15 M30 M31] x mm0 = [4 /5 /6'/7']
586 :     ; [M10 M11 M26 M27] [M12 M13 M28 M29] x mm2 = [4'/5'/6 /7 ]
587 :    
588 :     movdqa xmm1, [%2+16]
589 :     movdqa xmm3, [%2+32]
590 :     pmaddwd xmm1, xmm2
591 :     pmaddwd xmm3, xmm0
592 :     pmaddwd xmm2, [%2+48]
593 :     pmaddwd xmm0, [%2+ 0]
594 :    
595 :     paddd xmm0, xmm1 ; [ out0 | out1 ][ out2 | out3 ]
596 :     paddd xmm2, xmm3 ; [ out4 | out5 ][ out6 | out7 ]
597 :     psrad xmm0, 16
598 :     psrad xmm2, 16
599 :    
600 :     packssdw xmm0, xmm2 ; [ out0 .. out7 ]
601 :     paddsw xmm0, [%3] ; Round
602 :    
603 :     psraw xmm0, 4 ; => [-2048, 2047]
604 :    
605 :     movdqa [ecx+%1*16+0], xmm0
606 :     %endmacro
607 :    
608 :     ;-----------------------------------------------------------------------------
609 :     ; Function Forward DCT
610 :     ;-----------------------------------------------------------------------------
611 :    
612 :     ALIGN 16
613 :     fdct_sse2_skal:
614 :     mov ecx, [esp+4]
615 :     fLLM_PASS ecx+0, 3
616 :     fMTX_MULT 0, fTab1, Fdct_Rnd0
617 :     fMTX_MULT 1, fTab2, Fdct_Rnd2
618 :     fMTX_MULT 2, fTab3, Fdct_Rnd1
619 :     fMTX_MULT 3, fTab4, Fdct_Rnd1
620 :     fMTX_MULT 4, fTab1, Fdct_Rnd0
621 :     fMTX_MULT 5, fTab4, Fdct_Rnd1
622 :     fMTX_MULT 6, fTab3, Fdct_Rnd1
623 :     fMTX_MULT 7, fTab2, Fdct_Rnd1
624 :     ret
625 : Isibaar 1793 ENDFUNC
626 : edgomez 1540
627 : Isibaar 1790
628 :     %ifidn __OUTPUT_FORMAT__,elf
629 :     section ".note.GNU-stack" noalloc noexec nowrite progbits
630 :     %endif
631 :    

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