[svn] / trunk / xvidcore / src / utils / x86_asm / mem_transfer_3dne.asm Repository:
ViewVC logotype

Annotation of /trunk/xvidcore/src/utils/x86_asm/mem_transfer_3dne.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1632 - (view) (download)

1 : edgomez 1382 ;/****************************************************************************
2 : edgomez 851 ; *
3 : edgomez 1382 ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * - 8<->16 bit transfer functions -
5 : edgomez 851 ; *
6 : edgomez 1382 ; * Copyright (C) 2002 Jaan Kalda
7 : edgomez 851 ; *
8 : edgomez 1382 ; * This program is free software ; you can redistribute it and/or modify
9 :     ; * it 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 : edgomez 851 ; *
13 : edgomez 1382 ; * 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 : edgomez 851 ; *
18 : edgomez 1382 ; * 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 : edgomez 851 ; *
22 : suxen_drol 1632 ; * $Id: mem_transfer_3dne.asm,v 1.7 2005-09-13 12:12:15 suxen_drol Exp $
23 : edgomez 1382 ; *
24 :     ; ***************************************************************************/
25 : edgomez 851
26 : edgomez 1382 ; these 3dne functions are compatible with iSSE, but are optimized specifically
27 :     ; for K7 pipelines
28 : edgomez 851
29 : edgomez 1382 BITS 32
30 : edgomez 851
31 : edgomez 1382 %macro cglobal 1
32 : edgomez 851 %ifdef PREFIX
33 : edgomez 1535 %ifdef MARK_FUNCS
34 : edgomez 1540 global _%1:function %1.endfunc-%1
35 :     %define %1 _%1:function %1.endfunc-%1
36 : edgomez 1535 %else
37 :     global _%1
38 :     %define %1 _%1
39 :     %endif
40 : edgomez 851 %else
41 : edgomez 1535 %ifdef MARK_FUNCS
42 : edgomez 1540 global %1:function %1.endfunc-%1
43 : edgomez 1535 %else
44 :     global %1
45 :     %endif
46 : edgomez 851 %endif
47 :     %endmacro
48 : edgomez 1382
49 :     ;=============================================================================
50 :     ; Read only data
51 :     ;=============================================================================
52 :    
53 :     %ifdef FORMAT_COFF
54 : edgomez 1519 SECTION .rodata
55 : edgomez 1382 %else
56 : edgomez 1519 SECTION .rodata align=16
57 : edgomez 1382 %endif
58 :    
59 :     ALIGN 8
60 :     mm_zero:
61 :     dd 0,0
62 :     ;=============================================================================
63 :     ; Macros
64 :     ;=============================================================================
65 :    
66 : edgomez 851 %macro nop4 0
67 : edgomez 1382 db 08Dh, 074h, 026h, 0
68 : edgomez 851 %endmacro
69 :    
70 : edgomez 1382 ;=============================================================================
71 :     ; Code
72 :     ;=============================================================================
73 : edgomez 851
74 : edgomez 1382 SECTION .text
75 :    
76 : edgomez 851 cglobal transfer_8to16copy_3dne
77 :     cglobal transfer_16to8copy_3dne
78 :     cglobal transfer_8to16sub_3dne
79 :     cglobal transfer_8to16subro_3dne
80 :     cglobal transfer_8to16sub2_3dne
81 :     cglobal transfer_16to8add_3dne
82 :     cglobal transfer8x8_copy_3dne
83 : suxen_drol 1632 cglobal transfer8x4_copy_3dne
84 : edgomez 851
85 : edgomez 1382 ;-----------------------------------------------------------------------------
86 : edgomez 851 ;
87 :     ; void transfer_8to16copy_3dne(int16_t * const dst,
88 :     ; const uint8_t * const src,
89 :     ; uint32_t stride);
90 :     ;
91 : edgomez 1382 ;-----------------------------------------------------------------------------
92 : edgomez 851
93 : edgomez 1382 ALIGN 16
94 : edgomez 851 transfer_8to16copy_3dne:
95 :    
96 :     mov eax, [esp+ 8] ; Src
97 :     mov edx, [esp+12] ; Stride
98 :     mov ecx, [esp+ 4] ; Dst
99 :     punpcklbw mm0, [byte eax]
100 :     punpcklbw mm1, [eax+4]
101 : edgomez 1382 movq mm2, [eax+edx]
102 :     movq mm3, [eax+edx]
103 :     pxor mm7, mm7
104 :     lea eax, [eax+2*edx]
105 :     punpcklbw mm2, mm7
106 :     punpckhbw mm3, mm7
107 :     psrlw mm0, 8
108 :     psrlw mm1, 8
109 : edgomez 851 punpcklbw mm4, [eax]
110 :     punpcklbw mm5, [eax+edx+4]
111 :     movq [byte ecx+0*64], mm0
112 :     movq [ecx+0*64+8], mm1
113 :     punpcklbw mm6, [eax+edx]
114 :     punpcklbw mm7, [eax+4]
115 : edgomez 1382 lea eax, [byte eax+2*edx]
116 :     psrlw mm4, 8
117 :     psrlw mm5, 8
118 : edgomez 851 punpcklbw mm0, [eax]
119 :     punpcklbw mm1, [eax+edx+4]
120 :     movq [ecx+0*64+16], mm2
121 :     movq [ecx+0*64+24], mm3
122 : edgomez 1382 psrlw mm6, 8
123 :     psrlw mm7, 8
124 : edgomez 851 punpcklbw mm2, [eax+edx]
125 :     punpcklbw mm3, [eax+4]
126 : edgomez 1382 lea eax, [byte eax+2*edx]
127 : edgomez 851 movq [byte ecx+0*64+32], mm4
128 :     movq [ecx+0*64+56], mm5
129 : edgomez 1382 psrlw mm0, 8
130 :     psrlw mm1, 8
131 : edgomez 851 punpcklbw mm4, [eax]
132 :     punpcklbw mm5, [eax+edx+4]
133 :     movq [byte ecx+0*64+48], mm6
134 :     movq [ecx+0*64+40], mm7
135 : edgomez 1382 psrlw mm2, 8
136 :     psrlw mm3, 8
137 : edgomez 851 punpcklbw mm6, [eax+edx]
138 :     punpcklbw mm7, [eax+4]
139 :     movq [byte ecx+1*64], mm0
140 :     movq [ecx+1*64+24], mm1
141 : edgomez 1382 psrlw mm4, 8
142 :     psrlw mm5, 8
143 : edgomez 851 movq [ecx+1*64+16], mm2
144 :     movq [ecx+1*64+8], mm3
145 : edgomez 1382 psrlw mm6, 8
146 :     psrlw mm7, 8
147 : edgomez 851 movq [byte ecx+1*64+32], mm4
148 : edgomez 1382 movq [ecx+1*64+56], mm5
149 : edgomez 851 movq [byte ecx+1*64+48], mm6
150 :     movq [ecx+1*64+40], mm7
151 : edgomez 1382 ret
152 : edgomez 1540 .endfunc
153 : edgomez 851
154 : edgomez 1382
155 :     ;-----------------------------------------------------------------------------
156 : edgomez 851 ;
157 :     ; void transfer_16to8copy_3dne(uint8_t * const dst,
158 :     ; const int16_t * const src,
159 :     ; uint32_t stride);
160 :     ;
161 : edgomez 1382 ;-----------------------------------------------------------------------------
162 : edgomez 851
163 : edgomez 1382 ALIGN 16
164 : edgomez 851 transfer_16to8copy_3dne:
165 :    
166 :     mov eax, [esp+ 8] ; Src
167 :     mov ecx, [esp+ 4] ; Dst
168 :     mov edx, [esp+12] ; Stride
169 :    
170 :     movq mm0, [byte eax+0*32]
171 : edgomez 1382 packuswb mm0, [eax+0*32+8]
172 : edgomez 851 movq mm1, [eax+0*32+16]
173 : edgomez 1382 packuswb mm1, [eax+0*32+24]
174 : edgomez 851 movq mm5, [eax+2*32+16]
175 :     movq mm2, [eax+1*32]
176 : edgomez 1382 packuswb mm2, [eax+1*32+8]
177 : edgomez 851 movq mm3, [eax+1*32+16]
178 :     packuswb mm3, [eax+1*32+24]
179 : edgomez 1382 movq mm6, [eax+3*32]
180 : edgomez 851 movq mm4, [eax+2*32]
181 : edgomez 1382 packuswb mm4, [eax+2*32+8]
182 : edgomez 851 packuswb mm5, [eax+2*32+24]
183 :     movq mm7, [eax+3*32+16]
184 :     packuswb mm7, [eax+3*32+24]
185 : edgomez 1382 packuswb mm6, [eax+3*32+8]
186 : edgomez 851 movq [ecx], mm0
187 : edgomez 1382 lea eax, [3*edx]
188 :     add eax, ecx
189 : edgomez 851 movq [ecx+edx], mm1
190 :     movq [ecx+2*edx], mm2
191 :     movq [byte eax], mm3
192 :     movq [ecx+4*edx], mm4
193 : edgomez 1382 lea ecx, [byte ecx+4*edx]
194 : edgomez 851 movq [eax+2*edx], mm5
195 :     movq [eax+4*edx], mm7
196 :     movq [ecx+2*edx], mm6
197 :     ret
198 : edgomez 1540 .endfunc
199 : edgomez 851
200 : edgomez 1382 ;-----------------------------------------------------------------------------
201 : edgomez 851 ;
202 :     ; void transfer_8to16sub_3dne(int16_t * const dct,
203 :     ; uint8_t * const cur,
204 :     ; const uint8_t * const ref,
205 :     ; const uint32_t stride);
206 :     ;
207 : edgomez 1382 ;-----------------------------------------------------------------------------
208 : edgomez 851
209 :     ; when second argument == 1, reference (ebx) block is to current (eax)
210 :     %macro COPY_8_TO_16_SUB 2
211 :     movq mm1, [eax] ; cur
212 :     movq mm0, mm1
213 :     movq mm4, [ecx] ; ref
214 :     movq mm6, mm4
215 :     %if %2 == 1
216 :     movq [eax], mm4
217 :     %endif
218 :     punpckhbw mm1, mm7
219 :     punpckhbw mm6, mm7
220 :     punpcklbw mm4, mm7
221 : edgomez 1382 ALIGN 8
222 : edgomez 851 movq mm2, [byte eax+edx]
223 :     punpcklbw mm0, mm7
224 :     movq mm3, [byte eax+edx]
225 :     punpcklbw mm2, mm7
226 :     movq mm5, [byte ecx+edx] ; ref
227 :     punpckhbw mm3, mm7
228 :     %if %2 == 1
229 :     movq [byte eax+edx], mm5
230 :     %endif
231 :     psubsw mm1, mm6
232 :    
233 :     movq mm6, mm5
234 :     psubsw mm0, mm4
235 : edgomez 1382 %if (%1 < 3)
236 : edgomez 851 lea eax,[eax+2*edx]
237 :     lea ecx,[ecx+2*edx]
238 :     %else
239 :     mov ecx,[esp]
240 :     add esp,byte 4
241 :     %endif
242 :     movq [edi+%1*32+ 8], mm1
243 :     movq [byte edi+%1*32+ 0], mm0 ; dst
244 :     punpcklbw mm5, mm7
245 :     punpckhbw mm6, mm7
246 :     psubsw mm2, mm5
247 :     psubsw mm3, mm6
248 :     movq [edi+%1*32+16], mm2
249 :     movq [edi+%1*32+24], mm3
250 :     %endmacro
251 :    
252 : edgomez 1382 ALIGN 16
253 : edgomez 851 transfer_8to16sub_3dne:
254 :     mov eax, [esp + 8] ; Cur
255 :     mov ecx, [esp +12] ; Ref
256 :     push edi
257 :     mov edx, [dword esp+4+16] ; Stride
258 :     mov edi, [esp+4+ 4] ; Dst
259 :     pxor mm7, mm7
260 :     nop
261 : edgomez 1382 ALIGN 4
262 : edgomez 851 COPY_8_TO_16_SUB 0, 1
263 :     COPY_8_TO_16_SUB 1, 1
264 :     COPY_8_TO_16_SUB 2, 1
265 :     COPY_8_TO_16_SUB 3, 1
266 : edgomez 1382 mov edi, ecx
267 : edgomez 851 ret
268 : edgomez 1540 .endfunc
269 : edgomez 851
270 : edgomez 1382 ALIGN 16
271 : edgomez 851 transfer_8to16subro_3dne:
272 :     mov eax, [esp + 8] ; Cur
273 :     mov ecx, [esp +12] ; Ref
274 :     push edi
275 :     mov edx, [dword esp+4+16] ; Stride
276 :     mov edi, [esp+4+ 4] ; Dst
277 :     pxor mm7, mm7
278 :     nop
279 : edgomez 1382 ALIGN 4
280 : edgomez 851 COPY_8_TO_16_SUB 0, 0
281 :     COPY_8_TO_16_SUB 1, 0
282 :     COPY_8_TO_16_SUB 2, 0
283 :     COPY_8_TO_16_SUB 3, 0
284 : edgomez 1382 mov edi, ecx
285 : edgomez 851 ret
286 : edgomez 1540 .endfunc
287 : edgomez 851
288 :    
289 : edgomez 1382 ;-----------------------------------------------------------------------------
290 : edgomez 851 ;
291 :     ; void transfer_8to16sub2_3dne(int16_t * const dct,
292 :     ; uint8_t * const cur,
293 :     ; const uint8_t * ref1,
294 :     ; const uint8_t * ref2,
295 :     ; const uint32_t stride)
296 :     ;
297 : edgomez 1382 ;-----------------------------------------------------------------------------
298 : edgomez 851
299 :     %macro COPY_8_TO_16_SUB2_SSE 1
300 : edgomez 1382 db 0Fh, 6Fh, 44h, 20h, 00 ;movq mm0, [byte eax] ; cur
301 : edgomez 851 punpcklbw mm0, mm7
302 :     movq mm2, [byte eax+edx]
303 :     punpcklbw mm2, mm7
304 :     db 0Fh, 6Fh, 4ch, 20h, 00 ;movq mm1, [byte eax]
305 :     punpckhbw mm1, mm7
306 :     movq mm3, [byte eax+edx]
307 :     punpckhbw mm3, mm7
308 : edgomez 1382
309 : edgomez 851 movq mm4, [byte ebx] ; ref1
310 :     pavgb mm4, [byte esi] ; ref2
311 : edgomez 1382 movq [eax], mm4
312 : edgomez 851 movq mm5, [ebx+edx] ; ref
313 :     pavgb mm5, [esi+edx] ; ref2
314 : edgomez 1382 movq [eax+edx], mm5
315 : edgomez 851 movq mm6, mm4
316 :     punpcklbw mm4, mm7
317 :     punpckhbw mm6, mm7
318 :     %if (%1 < 3)
319 :     lea esi,[esi+2*edx]
320 :     lea ebx,[byte ebx+2*edx]
321 :     lea eax,[eax+2*edx]
322 :     %else
323 :     mov esi,[esp]
324 :     mov ebx,[esp+4]
325 :     add esp,byte 8
326 : edgomez 1382 %endif
327 : edgomez 851 psubsw mm0, mm4
328 :     psubsw mm1, mm6
329 :     movq mm6, mm5
330 :     punpcklbw mm5, mm7
331 :     punpckhbw mm6, mm7
332 :     psubsw mm2, mm5
333 :     psubsw mm3, mm6
334 :     movq [byte ecx+%1*32+ 0], mm0 ; dst
335 :     movq [ecx+%1*32+ 8], mm1
336 :     movq [ecx+%1*32+16], mm2
337 :     movq [ecx+%1*32+24], mm3
338 :     %endmacro
339 :    
340 : edgomez 1382 ALIGN 16
341 : edgomez 851 transfer_8to16sub2_3dne:
342 :     mov edx, [esp +20] ; Stride
343 :     mov ecx, [esp + 4] ; Dst
344 :     mov eax, [esp + 8] ; Cur
345 :     push ebx
346 :     lea ebp,[byte ebp]
347 :     mov ebx, [esp+4+12] ; Ref1
348 :     push esi
349 :     pxor mm7, mm7
350 :     mov esi, [esp+8+16] ; Ref2
351 : edgomez 1382 nop4
352 : edgomez 851 COPY_8_TO_16_SUB2_SSE 0
353 :     COPY_8_TO_16_SUB2_SSE 1
354 :     COPY_8_TO_16_SUB2_SSE 2
355 :     COPY_8_TO_16_SUB2_SSE 3
356 :    
357 :     ret
358 : edgomez 1540 .endfunc
359 : edgomez 851
360 :    
361 : edgomez 1382 ;-----------------------------------------------------------------------------
362 : edgomez 851 ;
363 :     ; void transfer_16to8add_3dne(uint8_t * const dst,
364 :     ; const int16_t * const src,
365 :     ; uint32_t stride);
366 :     ;
367 : edgomez 1382 ;-----------------------------------------------------------------------------
368 : edgomez 851
369 :     %macro COPY_16_TO_8_ADD 1
370 :     db 0Fh, 6Fh, 44h, 21h, 00 ;movq mm0, [byte ecx]
371 :     punpcklbw mm0, mm7
372 :     movq mm2, [byte ecx+edx]
373 :     punpcklbw mm2, mm7
374 :     db 0Fh, 6Fh, 4ch, 21h, 00 ;movq mm1, [byte ecx]
375 :     punpckhbw mm1, mm7
376 :     movq mm3, [byte ecx+edx]
377 :     punpckhbw mm3, mm7
378 :     paddsw mm0, [byte eax+%1*32+ 0]
379 :     paddsw mm1, [eax+%1*32+ 8]
380 :     paddsw mm2, [eax+%1*32+16]
381 :     paddsw mm3, [eax+%1*32+24]
382 :     packuswb mm0, mm1
383 :     packuswb mm2, mm3
384 : edgomez 1382 mov esp,esp
385 : edgomez 851 movq [byte ecx], mm0
386 :     movq [ecx+edx], mm2
387 :     %endmacro
388 :    
389 :    
390 : edgomez 1382 ALIGN 16
391 : edgomez 851 transfer_16to8add_3dne:
392 :     mov ecx, [esp+ 4] ; Dst
393 :     mov edx, [esp+12] ; Stride
394 :     mov eax, [esp+ 8] ; Src
395 :     pxor mm7, mm7
396 :     nop
397 :    
398 :     COPY_16_TO_8_ADD 0
399 :     lea ecx,[byte ecx+2*edx]
400 :     COPY_16_TO_8_ADD 1
401 :     lea ecx,[byte ecx+2*edx]
402 :     COPY_16_TO_8_ADD 2
403 :     lea ecx,[byte ecx+2*edx]
404 :     COPY_16_TO_8_ADD 3
405 :     ret
406 : edgomez 1540 .endfunc
407 : edgomez 851
408 : edgomez 1382 ;-----------------------------------------------------------------------------
409 : edgomez 851 ;
410 :     ; void transfer8x8_copy_3dne(uint8_t * const dst,
411 :     ; const uint8_t * const src,
412 :     ; const uint32_t stride);
413 :     ;
414 :     ;
415 : edgomez 1382 ;-----------------------------------------------------------------------------
416 : edgomez 851
417 :     %macro COPY_8_TO_8 0
418 :     movq mm0, [byte eax]
419 :     movq mm1, [eax+edx]
420 :     movq [byte ecx], mm0
421 :     lea eax,[byte eax+2*edx]
422 :     movq [ecx+edx], mm1
423 :     %endmacro
424 :    
425 : edgomez 1382 ALIGN 16
426 : edgomez 851 transfer8x8_copy_3dne:
427 :     mov eax, [esp+ 8] ; Src
428 :     mov edx, [esp+12] ; Stride
429 :     mov ecx, [esp+ 4] ; Dst
430 :    
431 :     COPY_8_TO_8
432 :     lea ecx,[byte ecx+2*edx]
433 :     COPY_8_TO_8
434 :     lea ecx,[byte ecx+2*edx]
435 :     COPY_8_TO_8
436 :     lea ecx,[byte ecx+2*edx]
437 :     COPY_8_TO_8
438 :     ret
439 : edgomez 1540 .endfunc
440 :    
441 : suxen_drol 1632 ;-----------------------------------------------------------------------------
442 :     ;
443 :     ; void transfer8x4_copy_3dne(uint8_t * const dst,
444 :     ; const uint8_t * const src,
445 :     ; const uint32_t stride);
446 :     ;
447 :     ;
448 :     ;-----------------------------------------------------------------------------
449 :    
450 :     ALIGN 16
451 :     transfer8x4_copy_3dne:
452 :     mov eax, [esp+ 8] ; Src
453 :     mov edx, [esp+12] ; Stride
454 :     mov ecx, [esp+ 4] ; Dst
455 :    
456 :     COPY_8_TO_8
457 :     lea ecx,[byte ecx+2*edx]
458 :     COPY_8_TO_8
459 :     ret
460 :     .endfunc
461 :    

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