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

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