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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (view) (download)

1 : edgomez 1.2 ;/****************************************************************************
2 :     ; *
3 :     ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * - MMX and XMM forward discrete cosine transform -
5 :     ; *
6 :     ; * Copyright(C) 2002 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 1.9 ; * $Id: fdct_mmx_skal.asm,v 1.8 2008/08/19 09:06:48 Isibaar Exp $
23 : edgomez 1.2 ; *
24 :     ; ***************************************************************************/
25 :    
26 :     BITS 32
27 :    
28 :     %macro cglobal 1
29 :     %ifdef PREFIX
30 : edgomez 1.5 %ifdef MARK_FUNCS
31 : edgomez 1.6 global _%1:function %1.endfunc-%1
32 :     %define %1 _%1:function %1.endfunc-%1
33 : Isibaar 1.9 %define ENDFUNC .endfunc
34 : edgomez 1.5 %else
35 :     global _%1
36 :     %define %1 _%1
37 : Isibaar 1.9 %define ENDFUNC
38 : edgomez 1.5 %endif
39 : edgomez 1.2 %else
40 : edgomez 1.5 %ifdef MARK_FUNCS
41 : edgomez 1.6 global %1:function %1.endfunc-%1
42 : Isibaar 1.9 %define ENDFUNC .endfunc
43 : edgomez 1.5 %else
44 :     global %1
45 : Isibaar 1.9 %define ENDFUNC
46 : edgomez 1.5 %endif
47 : edgomez 1.2 %endif
48 :     %endmacro
49 :    
50 :     ;;; Define this if you want an unrolled version of the code
51 :     %define UNROLLED_LOOP
52 :    
53 :     ;=============================================================================
54 :     ;
55 :     ; Vertical pass is an implementation of the scheme:
56 :     ; Loeffler C., Ligtenberg A., and Moschytz C.S.:
57 :     ; Practical Fast 1D DCT Algorithm with Eleven Multiplications,
58 :     ; Proc. ICASSP 1989, 988-991.
59 :     ;
60 :     ; Horizontal pass is a double 4x4 vector/matrix multiplication,
61 :     ; (see also Intel's Application Note 922:
62 :     ; http://developer.intel.com/vtune/cbts/strmsimd/922down.htm
63 :     ; Copyright (C) 1999 Intel Corporation)
64 :     ;
65 :     ; Notes:
66 :     ; * tan(3pi/16) is greater than 0.5, and would use the
67 :     ; sign bit when turned into 16b fixed-point precision. So,
68 :     ; we use the trick: x*tan3 = x*(tan3-1)+x
69 :     ;
70 :     ; * There's only one SSE-specific instruction (pshufw).
71 :     ; Porting to SSE2 also seems straightforward.
72 :     ;
73 :     ; * There's still 1 or 2 ticks to save in fLLM_PASS, but
74 :     ; I prefer having a readable code, instead of a tightly
75 :     ; scheduled one...
76 :     ;
77 :     ; * Quantization stage (as well as pre-transposition for the
78 :     ; idct way back) can be included in the fTab* constants
79 :     ; (with induced loss of precision, somehow)
80 :     ;
81 :     ; * Some more details at: http://skal.planet-d.net/coding/dct.html
82 :     ;
83 :     ;=============================================================================
84 :     ;
85 :     ; idct-like IEEE errors:
86 :     ;
87 :     ; =========================
88 :     ; Peak error: 1.0000
89 :     ; Peak MSE: 0.0365
90 :     ; Overall MSE: 0.0201
91 :     ; Peak ME: 0.0265
92 :     ; Overall ME: 0.0006
93 :     ;
94 :     ; == Mean square errors ==
95 :     ; 0.000 0.001 0.001 0.002 0.000 0.002 0.001 0.000 [0.001]
96 :     ; 0.035 0.029 0.032 0.032 0.031 0.032 0.034 0.035 [0.032]
97 :     ; 0.026 0.028 0.027 0.027 0.025 0.028 0.028 0.025 [0.027]
98 :     ; 0.037 0.032 0.031 0.030 0.028 0.029 0.026 0.031 [0.030]
99 :     ; 0.000 0.001 0.001 0.002 0.000 0.002 0.001 0.001 [0.001]
100 :     ; 0.025 0.024 0.022 0.022 0.022 0.022 0.023 0.023 [0.023]
101 :     ; 0.026 0.028 0.025 0.028 0.030 0.025 0.026 0.027 [0.027]
102 :     ; 0.021 0.020 0.020 0.022 0.020 0.022 0.017 0.019 [0.020]
103 :     ;
104 :     ; == Abs Mean errors ==
105 :     ; 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 [0.000]
106 :     ; 0.020 0.001 0.003 0.003 0.000 0.004 0.002 0.003 [0.002]
107 :     ; 0.000 0.001 0.001 0.001 0.001 0.004 0.000 0.000 [0.000]
108 :     ; 0.027 0.001 0.000 0.002 0.002 0.002 0.001 0.000 [0.003]
109 :     ; 0.000 0.000 0.000 0.000 0.000 0.001 0.000 0.001 [-0.000]
110 :     ; 0.001 0.003 0.001 0.001 0.002 0.001 0.000 0.000 [-0.000]
111 :     ; 0.000 0.002 0.002 0.001 0.001 0.002 0.001 0.000 [-0.000]
112 :     ; 0.000 0.002 0.001 0.002 0.001 0.002 0.001 0.001 [-0.000]
113 :     ;
114 :     ;=============================================================================
115 :    
116 :     ;=============================================================================
117 :     ; Read only data
118 :     ;=============================================================================
119 :    
120 :     %ifdef FORMAT_COFF
121 : edgomez 1.3 SECTION .rodata
122 : edgomez 1.2 %else
123 : edgomez 1.3 SECTION .rodata align=16
124 : edgomez 1.2 %endif
125 :    
126 :     ALIGN 16
127 :     tan1:
128 :     dw 0x32ec,0x32ec,0x32ec,0x32ec ; tan( pi/16)
129 :     tan2:
130 :     dw 0x6a0a,0x6a0a,0x6a0a,0x6a0a ; tan(2pi/16) (=sqrt(2)-1)
131 :     tan3:
132 :     dw 0xab0e,0xab0e,0xab0e,0xab0e ; tan(3pi/16)-1
133 :     sqrt2:
134 :     dw 0x5a82,0x5a82,0x5a82,0x5a82 ; 0.5/sqrt(2)
135 :    
136 :     ALIGN 16
137 :     fdct_table:
138 :     ;fTab1:
139 :     dw 0x4000, 0x4000, 0x58c5, 0x4b42
140 :     dw 0x4000, 0x4000, 0x3249, 0x11a8
141 :     dw 0x539f, 0x22a3, 0x4b42, 0xee58
142 :     dw 0xdd5d, 0xac61, 0xa73b, 0xcdb7
143 :     dw 0x4000, 0xc000, 0x3249, 0xa73b
144 :     dw 0xc000, 0x4000, 0x11a8, 0x4b42
145 :     dw 0x22a3, 0xac61, 0x11a8, 0xcdb7
146 :     dw 0x539f, 0xdd5d, 0x4b42, 0xa73b
147 :    
148 :     ;fTab2:
149 :     dw 0x58c5, 0x58c5, 0x7b21, 0x6862
150 :     dw 0x58c5, 0x58c5, 0x45bf, 0x187e
151 :     dw 0x73fc, 0x300b, 0x6862, 0xe782
152 :     dw 0xcff5, 0x8c04, 0x84df, 0xba41
153 :     dw 0x58c5, 0xa73b, 0x45bf, 0x84df
154 :     dw 0xa73b, 0x58c5, 0x187e, 0x6862
155 :     dw 0x300b, 0x8c04, 0x187e, 0xba41
156 :     dw 0x73fc, 0xcff5, 0x6862, 0x84df
157 :    
158 :     ;fTab3:
159 :     dw 0x539f, 0x539f, 0x73fc, 0x6254
160 :     dw 0x539f, 0x539f, 0x41b3, 0x1712
161 :     dw 0x6d41, 0x2d41, 0x6254, 0xe8ee
162 :     dw 0xd2bf, 0x92bf, 0x8c04, 0xbe4d
163 :     dw 0x539f, 0xac61, 0x41b3, 0x8c04
164 :     dw 0xac61, 0x539f, 0x1712, 0x6254
165 :     dw 0x2d41, 0x92bf, 0x1712, 0xbe4d
166 :     dw 0x6d41, 0xd2bf, 0x6254, 0x8c04
167 :    
168 :     ;fTab4:
169 :     dw 0x4b42, 0x4b42, 0x6862, 0x587e
170 :     dw 0x4b42, 0x4b42, 0x3b21, 0x14c3
171 :     dw 0x6254, 0x28ba, 0x587e, 0xeb3d
172 :     dw 0xd746, 0x9dac, 0x979e, 0xc4df
173 :     dw 0x4b42, 0xb4be, 0x3b21, 0x979e
174 :     dw 0xb4be, 0x4b42, 0x14c3, 0x587e
175 :     dw 0x28ba, 0x9dac, 0x14c3, 0xc4df
176 :     dw 0x6254, 0xd746, 0x587e, 0x979e
177 :    
178 :     ;fTab1:
179 :     dw 0x4000, 0x4000, 0x58c5, 0x4b42
180 :     dw 0x4000, 0x4000, 0x3249, 0x11a8
181 :     dw 0x539f, 0x22a3, 0x4b42, 0xee58
182 :     dw 0xdd5d, 0xac61, 0xa73b, 0xcdb7
183 :     dw 0x4000, 0xc000, 0x3249, 0xa73b
184 :     dw 0xc000, 0x4000, 0x11a8, 0x4b42
185 :     dw 0x22a3, 0xac61, 0x11a8, 0xcdb7
186 :     dw 0x539f, 0xdd5d, 0x4b42, 0xa73b
187 :    
188 :     ;fTab4:
189 :     dw 0x4b42, 0x4b42, 0x6862, 0x587e
190 :     dw 0x4b42, 0x4b42, 0x3b21, 0x14c3
191 :     dw 0x6254, 0x28ba, 0x587e, 0xeb3d
192 :     dw 0xd746, 0x9dac, 0x979e, 0xc4df
193 :     dw 0x4b42, 0xb4be, 0x3b21, 0x979e
194 :     dw 0xb4be, 0x4b42, 0x14c3, 0x587e
195 :     dw 0x28ba, 0x9dac, 0x14c3, 0xc4df
196 :     dw 0x6254, 0xd746, 0x587e, 0x979e
197 :    
198 :     ;fTab3:
199 :     dw 0x539f, 0x539f, 0x73fc, 0x6254
200 :     dw 0x539f, 0x539f, 0x41b3, 0x1712
201 :     dw 0x6d41, 0x2d41, 0x6254, 0xe8ee
202 :     dw 0xd2bf, 0x92bf, 0x8c04, 0xbe4d
203 :     dw 0x539f, 0xac61, 0x41b3, 0x8c04
204 :     dw 0xac61, 0x539f, 0x1712, 0x6254
205 :     dw 0x2d41, 0x92bf, 0x1712, 0xbe4d
206 :     dw 0x6d41, 0xd2bf, 0x6254, 0x8c04
207 :    
208 :     ;fTab2:
209 :     dw 0x58c5, 0x58c5, 0x7b21, 0x6862
210 :     dw 0x58c5, 0x58c5, 0x45bf, 0x187e
211 :     dw 0x73fc, 0x300b, 0x6862, 0xe782
212 :     dw 0xcff5, 0x8c04, 0x84df, 0xba41
213 :     dw 0x58c5, 0xa73b, 0x45bf, 0x84df
214 :     dw 0xa73b, 0x58c5, 0x187e, 0x6862
215 :     dw 0x300b, 0x8c04, 0x187e, 0xba41
216 :     dw 0x73fc, 0xcff5, 0x6862, 0x84df
217 :    
218 :     ALIGN 16
219 :     fdct_rounding_1:
220 :     dw 6, 8, 8, 8
221 :     dw 10, 8, 8, 8
222 :     dw 8, 8, 8, 8
223 :     dw 8, 8, 8, 8
224 :     dw 6, 8, 8, 8
225 :     dw 8, 8, 8, 8
226 :     dw 8, 8, 8, 8
227 :     dw 8, 8, 8, 8
228 :    
229 :     ALIGN 16
230 :     fdct_rounding_2:
231 :     dw 6, 8, 8, 8
232 :     dw 8, 8, 8, 8
233 :     dw 8, 8, 8, 8
234 :     dw 8, 8, 8, 8
235 :     dw 6, 8, 8, 8
236 :     dw 8, 8, 8, 8
237 :     dw 8, 8, 8, 8
238 :     dw 8, 8, 8, 8
239 :    
240 :     ALIGN 16
241 :     MMX_One:
242 :     dw 1, 1, 1, 1
243 :    
244 :     ;=============================================================================
245 :     ; Helper Macros for real code
246 :     ;=============================================================================
247 :    
248 :     ;-----------------------------------------------------------------------------
249 :     ; FDCT LLM vertical pass (~39c)
250 :     ; %1=dst, %2=src, %3:Shift
251 :     ;-----------------------------------------------------------------------------
252 :    
253 :     %macro fLLM_PASS 3
254 :     movq mm0, [%2+0*16] ; In0
255 :     movq mm2, [%2+2*16] ; In2
256 :     movq mm3, mm0
257 :     movq mm4, mm2
258 :     movq mm7, [%2+7*16] ; In7
259 :     movq mm5, [%2+5*16] ; In5
260 :    
261 :     psubsw mm0, mm7 ; t7 = In0-In7
262 :     paddsw mm7, mm3 ; t0 = In0+In7
263 :     psubsw mm2, mm5 ; t5 = In2-In5
264 :     paddsw mm5, mm4 ; t2 = In2+In5
265 :    
266 :     movq mm3, [%2+3*16] ; In3
267 :     movq mm4, [%2+4*16] ; In4
268 :     movq mm1, mm3
269 :     psubsw mm3, mm4 ; t4 = In3-In4
270 :     paddsw mm4, mm1 ; t3 = In3+In4
271 :     movq mm6, [%2+6*16] ; In6
272 :     movq mm1, [%2+1*16] ; In1
273 :     psubsw mm1, mm6 ; t6 = In1-In6
274 :     paddsw mm6, [%2+1*16] ; t1 = In1+In6
275 :    
276 :     psubsw mm7, mm4 ; tm03 = t0-t3
277 :     psubsw mm6, mm5 ; tm12 = t1-t2
278 :     paddsw mm4, mm4 ; 2.t3
279 :     paddsw mm5, mm5 ; 2.t2
280 :     paddsw mm4, mm7 ; tp03 = t0+t3
281 :     paddsw mm5, mm6 ; tp12 = t1+t2
282 :    
283 :     psllw mm2, %3+1 ; shift t5 (shift +1 to..
284 :     psllw mm1, %3+1 ; shift t6 ..compensate cos4/2)
285 :     psllw mm4, %3 ; shift t3
286 :     psllw mm5, %3 ; shift t2
287 :     psllw mm7, %3 ; shift t0
288 :     psllw mm6, %3 ; shift t1
289 :     psllw mm3, %3 ; shift t4
290 :     psllw mm0, %3 ; shift t7
291 :    
292 :     psubsw mm4, mm5 ; out4 = tp03-tp12
293 :     psubsw mm1, mm2 ; mm1: t6-t5
294 :     paddsw mm5, mm5
295 :     paddsw mm2, mm2
296 :     paddsw mm5, mm4 ; out0 = tp03+tp12
297 :     movq [%1+4*16], mm4 ; => out4
298 :     paddsw mm2, mm1 ; mm2: t6+t5
299 :     movq [%1+0*16], mm5 ; => out0
300 :    
301 :     movq mm4, [tan2] ; mm4 <= tan2
302 :     pmulhw mm4, mm7 ; tm03*tan2
303 :     movq mm5, [tan2] ; mm5 <= tan2
304 :     psubsw mm4, mm6 ; out6 = tm03*tan2 - tm12
305 :     pmulhw mm5, mm6 ; tm12*tan2
306 :     paddsw mm5, mm7 ; out2 = tm12*tan2 + tm03
307 :    
308 :     movq mm6, [sqrt2]
309 :     movq mm7, [MMX_One]
310 :    
311 :     pmulhw mm2, mm6 ; mm2: tp65 = (t6 + t5)*cos4
312 :     por mm5, mm7 ; correct out2
313 :     por mm4, mm7 ; correct out6
314 :     pmulhw mm1, mm6 ; mm1: tm65 = (t6 - t5)*cos4
315 :     por mm2, mm7 ; correct tp65
316 :    
317 :     movq [%1+2*16], mm5 ; => out2
318 :     movq mm5, mm3 ; save t4
319 :     movq [%1+6*16], mm4 ; => out6
320 :     movq mm4, mm0 ; save t7
321 :    
322 :     psubsw mm3, mm1 ; mm3: tm465 = t4 - tm65
323 :     psubsw mm0, mm2 ; mm0: tm765 = t7 - tp65
324 :     paddsw mm2, mm4 ; mm2: tp765 = t7 + tp65
325 :     paddsw mm1, mm5 ; mm1: tp465 = t4 + tm65
326 :    
327 :     movq mm4, [tan3] ; tan3 - 1
328 :     movq mm5, [tan1] ; tan1
329 :    
330 :     movq mm7, mm3 ; save tm465
331 :     pmulhw mm3, mm4 ; tm465*(tan3-1)
332 :     movq mm6, mm1 ; save tp465
333 :     pmulhw mm1, mm5 ; tp465*tan1
334 :    
335 :     paddsw mm3, mm7 ; tm465*tan3
336 :     pmulhw mm4, mm0 ; tm765*(tan3-1)
337 :     paddsw mm4, mm0 ; tm765*tan3
338 :     pmulhw mm5, mm2 ; tp765*tan1
339 :    
340 :     paddsw mm1, mm2 ; out1 = tp765 + tp465*tan1
341 :     psubsw mm0, mm3 ; out3 = tm765 - tm465*tan3
342 :     paddsw mm7, mm4 ; out5 = tm465 + tm765*tan3
343 :     psubsw mm5, mm6 ; out7 =-tp465 + tp765*tan1
344 :    
345 :     movq [%1+1*16], mm1 ; => out1
346 :     movq [%1+3*16], mm0 ; => out3
347 :     movq [%1+5*16], mm7 ; => out5
348 :     movq [%1+7*16], mm5 ; => out7
349 :     %endmacro
350 :    
351 :     ;-----------------------------------------------------------------------------
352 :     ; fMTX_MULT_XMM (~20c)
353 :     ; %1=dst, %2=src, %3 = Coeffs, %4/%5=rounders
354 :     ;-----------------------------------------------------------------------------
355 :    
356 :     %macro fMTX_MULT_XMM 5
357 :     movq mm0, [%2 + 0] ; mm0 = [0123]
358 :     ; the 'pshufw' below is the only SSE instruction.
359 :     ; For MMX-only version, it should be emulated with
360 :     ; some 'punpck' soup...
361 :     pshufw mm1, [%2 + 8], 00011011b ; mm1 = [7654]
362 :     movq mm7, mm0
363 :    
364 :     paddsw mm0, mm1 ; mm0 = [a0 a1 a2 a3]
365 :     psubsw mm7, mm1 ; mm7 = [b0 b1 b2 b3]
366 :    
367 :     movq mm1, mm0
368 :     punpckldq mm0, mm7 ; mm0 = [a0 a1 b0 b1]
369 :     punpckhdq mm1, mm7 ; mm1 = [b2 b3 a2 a3]
370 :    
371 :     movq mm2, qword [%3 + 0] ; [ M00 M01 M16 M17]
372 :     movq mm3, qword [%3 + 8] ; [ M02 M03 M18 M19]
373 :     pmaddwd mm2, mm0 ; [a0.M00+a1.M01 | b0.M16+b1.M17]
374 :     movq mm4, qword [%3 + 16] ; [ M04 M05 M20 M21]
375 :     pmaddwd mm3, mm1 ; [a2.M02+a3.M03 | b2.M18+b3.M19]
376 :     movq mm5, qword [%3 + 24] ; [ M06 M07 M22 M23]
377 :     pmaddwd mm4, mm0 ; [a0.M04+a1.M05 | b0.M20+b1.M21]
378 :     movq mm6, qword [%3 + 32] ; [ M08 M09 M24 M25]
379 :     pmaddwd mm5, mm1 ; [a2.M06+a3.M07 | b2.M22+b3.M23]
380 :     movq mm7, qword [%3 + 40] ; [ M10 M11 M26 M27]
381 :     pmaddwd mm6, mm0 ; [a0.M08+a1.M09 | b0.M24+b1.M25]
382 :     paddd mm2, mm3 ; [ out0 | out1 ]
383 :     pmaddwd mm7, mm1 ; [a0.M10+a1.M11 | b0.M26+b1.M27]
384 :     psrad mm2, 16
385 : suxen_drol 1.7 pmaddwd mm0, [%3 + 48] ; [a0.M12+a1.M13 | b0.M28+b1.M29]
386 : edgomez 1.2 paddd mm4, mm5 ; [ out2 | out3 ]
387 : suxen_drol 1.7 pmaddwd mm1, [%3 + 56] ; [a0.M14+a1.M15 | b0.M30+b1.M31]
388 : edgomez 1.2 psrad mm4, 16
389 :    
390 :     paddd mm6, mm7 ; [ out4 | out5 ]
391 :     psrad mm6, 16
392 :     paddd mm0, mm1 ; [ out6 | out7 ]
393 :     psrad mm0, 16
394 :    
395 :     packssdw mm2, mm4 ; [ out0|out1|out2|out3 ]
396 :     paddsw mm2, [%4] ; Round
397 :     packssdw mm6, mm0 ; [ out4|out5|out6|out7 ]
398 :     paddsw mm6, [%5] ; Round
399 :    
400 :     psraw mm2, 4 ; => [-2048, 2047]
401 :     psraw mm6, 4
402 :    
403 :     movq [%1 + 0], mm2
404 :     movq [%1 + 8], mm6
405 :     %endmacro
406 :    
407 :     ;-----------------------------------------------------------------------------
408 :     ; fMTX_MULT_MMX (~22c)
409 :     ; %1=dst, %2=src, %3 = Coeffs, %4/%5=rounders
410 :     ;-----------------------------------------------------------------------------
411 :    
412 :     %macro fMTX_MULT_MMX 5
413 :     ; MMX-only version (no 'pshufw'. ~10% overall slower than SSE)
414 :     movd mm1, [%2 + 8 + 4] ; [67..]
415 :     movq mm0, [%2 + 0] ; mm0 = [0123]
416 :     movq mm7, mm0
417 :     punpcklwd mm1, [%2 + 8] ; [6475]
418 :     movq mm2, mm1
419 :     psrlq mm1, 32 ; [75..]
420 :     punpcklwd mm1,mm2 ; [7654]
421 :    
422 :     paddsw mm0, mm1 ; mm0 = [a0 a1 a2 a3]
423 :     psubsw mm7, mm1 ; mm7 = [b0 b1 b2 b3]
424 :    
425 :     movq mm1, mm0
426 :     punpckldq mm0, mm7 ; mm0 = [a0 a1 b0 b1]
427 :     punpckhdq mm1, mm7 ; mm1 = [b2 b3 a2 a3]
428 :    
429 :     movq mm2, qword [%3 + 0] ; [ M00 M01 M16 M17]
430 :     movq mm3, qword [%3 + 8] ; [ M02 M03 M18 M19]
431 :     pmaddwd mm2, mm0 ; [a0.M00+a1.M01 | b0.M16+b1.M17]
432 :     movq mm4, qword [%3 + 16] ; [ M04 M05 M20 M21]
433 :     pmaddwd mm3, mm1 ; [a2.M02+a3.M03 | b2.M18+b3.M19]
434 :     movq mm5, qword [%3 + 24] ; [ M06 M07 M22 M23]
435 :     pmaddwd mm4, mm0 ; [a0.M04+a1.M05 | b0.M20+b1.M21]
436 :     movq mm6, qword [%3 + 32] ; [ M08 M09 M24 M25]
437 :     pmaddwd mm5, mm1 ; [a2.M06+a3.M07 | b2.M22+b3.M23]
438 :     movq mm7, qword [%3 + 40] ; [ M10 M11 M26 M27]
439 :     pmaddwd mm6, mm0 ; [a0.M08+a1.M09 | b0.M24+b1.M25]
440 :     paddd mm2, mm3 ; [ out0 | out1 ]
441 :     pmaddwd mm7, mm1 ; [a0.M10+a1.M11 | b0.M26+b1.M27]
442 :     psrad mm2, 16
443 : suxen_drol 1.7 pmaddwd mm0, [%3 + 48] ; [a0.M12+a1.M13 | b0.M28+b1.M29]
444 : edgomez 1.2 paddd mm4, mm5 ; [ out2 | out3 ]
445 : suxen_drol 1.7 pmaddwd mm1, [%3 + 56] ; [a0.M14+a1.M15 | b0.M30+b1.M31]
446 : edgomez 1.2 psrad mm4, 16
447 :    
448 :     paddd mm6, mm7 ; [ out4 | out5 ]
449 :     psrad mm6, 16
450 :     paddd mm0, mm1 ; [ out6 | out7 ]
451 :     psrad mm0, 16
452 :    
453 :     packssdw mm2, mm4 ; [ out0|out1|out2|out3 ]
454 :     paddsw mm2, [%4] ; Round
455 :     packssdw mm6, mm0 ; [ out4|out5|out6|out7 ]
456 :     paddsw mm6, [%5] ; Round
457 :    
458 :     psraw mm2, 4 ; => [-2048, 2047]
459 :     psraw mm6, 4
460 :    
461 :     movq [%1 + 0], mm2
462 :     movq [%1 + 8], mm6
463 :     %endmacro
464 :    
465 :     ;-----------------------------------------------------------------------------
466 :     ; MAKE_FDCT_FUNC
467 :     ; %1 funcname, %2 macro for row dct
468 :     ;-----------------------------------------------------------------------------
469 :    
470 :     %macro MAKE_FDCT_FUNC 2
471 :     ALIGN 16
472 :     cglobal %1
473 :     %1:
474 :     %ifdef UNROLLED_LOOP
475 :     mov ecx, [esp + 4]
476 :     %else
477 :     push ebx
478 :     push edi
479 :     mov ecx, [esp + 8 + 4]
480 :     %endif
481 :    
482 :     fLLM_PASS ecx+0, ecx+0, 3
483 :     fLLM_PASS ecx+8, ecx+8, 3
484 :    
485 :     %ifdef UNROLLED_LOOP
486 :     %assign i 0
487 :     %rep 8
488 :     %2 ecx+i*16, ecx+i*16, fdct_table+i*64, fdct_rounding_1+i*8, fdct_rounding_2+i*8
489 :     %assign i i+1
490 :     %endrep
491 :     %else
492 :     mov eax, 8
493 :     mov edx, fdct_table
494 :     mov ebx, fdct_rounding_1
495 :     mov edi, fdct_rounding_2
496 :     .loop
497 :     %2 ecx, ecx, edx, ebx, edi
498 : edgomez 1.4 add ecx, 2*8
499 : edgomez 1.2 add edx, 2*32
500 :     add ebx, 2*4
501 :     add edi, 2*4
502 :     dec eax
503 :     jne .loop
504 :    
505 :     pop edi
506 :     pop ebx
507 :     %endif
508 :    
509 :     ret
510 : Isibaar 1.9 ENDFUNC
511 : edgomez 1.2 %endmacro
512 :    
513 :     ;=============================================================================
514 :     ; Code
515 :     ;=============================================================================
516 :    
517 :     SECTION .text
518 :    
519 :     ;-----------------------------------------------------------------------------
520 :     ; void fdct_mmx_skal(int16_t block[64]];
521 :     ;-----------------------------------------------------------------------------
522 :    
523 :     MAKE_FDCT_FUNC fdct_mmx_skal, fMTX_MULT_MMX
524 :    
525 :     ;-----------------------------------------------------------------------------
526 :     ; void fdct_xmm_skal(int16_t block[64]];
527 :     ;-----------------------------------------------------------------------------
528 :    
529 :     MAKE_FDCT_FUNC fdct_xmm_skal, fMTX_MULT_XMM
530 : Isibaar 1.8
531 :     %ifidn __OUTPUT_FORMAT__,elf
532 :     section ".note.GNU-stack" noalloc noexec nowrite progbits
533 :     %endif
534 :    

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