6 |
; * Copyright (C) 2001 Peter Ross <pross@xvid.org> |
; * Copyright (C) 2001 Peter Ross <pross@xvid.org> |
7 |
; * 2001 Michael Militzer <isibaar@xvid.org> |
; * 2001 Michael Militzer <isibaar@xvid.org> |
8 |
; * 2002 Pascal Massimino <skal@planet-d.net> |
; * 2002 Pascal Massimino <skal@planet-d.net> |
|
; * 2004 Jean-Marc Bastide <jmtest@voila.fr> |
|
9 |
; * |
; * |
10 |
; * This program is free software ; you can redistribute it and/or modify |
; * This program is free software ; you can redistribute it and/or modify |
11 |
; * it under the terms of the GNU General Public License as published by |
; * it under the terms of the GNU General Public License as published by |
21 |
; * along with this program ; if not, write to the Free Software |
; * along with this program ; if not, write to the Free Software |
22 |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 |
; * |
; * |
24 |
; * $Id: mem_transfer_mmx.asm,v 1.11 2004-04-12 15:49:56 edgomez Exp $ |
; * $Id: mem_transfer_mmx.asm,v 1.16 2004-12-19 13:16:50 syskin Exp $ |
25 |
; * |
; * |
26 |
; ***************************************************************************/ |
; ***************************************************************************/ |
27 |
|
|
29 |
|
|
30 |
%macro cglobal 1 |
%macro cglobal 1 |
31 |
%ifdef PREFIX |
%ifdef PREFIX |
32 |
|
%ifdef MARK_FUNCS |
33 |
|
global _%1:function %1.endfunc-%1 |
34 |
|
%define %1 _%1:function %1.endfunc-%1 |
35 |
|
%else |
36 |
global _%1 |
global _%1 |
37 |
%define %1 _%1 |
%define %1 _%1 |
38 |
|
%endif |
39 |
|
%else |
40 |
|
%ifdef MARK_FUNCS |
41 |
|
global %1:function %1.endfunc-%1 |
42 |
%else |
%else |
43 |
global %1 |
global %1 |
44 |
%endif |
%endif |
45 |
|
%endif |
46 |
%endmacro |
%endmacro |
47 |
|
|
48 |
;============================================================================= |
;============================================================================= |
50 |
;============================================================================= |
;============================================================================= |
51 |
|
|
52 |
%ifdef FORMAT_COFF |
%ifdef FORMAT_COFF |
53 |
SECTION .rodata data |
SECTION .rodata |
54 |
%else |
%else |
55 |
SECTION .rodata data align=16 |
SECTION .rodata align=16 |
56 |
%endif |
%endif |
57 |
|
|
58 |
ALIGN 16 |
ALIGN 16 |
71 |
cglobal transfer_8to16subro_mmx |
cglobal transfer_8to16subro_mmx |
72 |
cglobal transfer_8to16sub2_mmx |
cglobal transfer_8to16sub2_mmx |
73 |
cglobal transfer_8to16sub2_xmm |
cglobal transfer_8to16sub2_xmm |
74 |
|
cglobal transfer_8to16sub2ro_xmm |
75 |
cglobal transfer_16to8add_mmx |
cglobal transfer_16to8add_mmx |
76 |
cglobal transfer8x8_copy_mmx |
cglobal transfer8x8_copy_mmx |
77 |
|
|
112 |
COPY_8_TO_16 2 |
COPY_8_TO_16 2 |
113 |
COPY_8_TO_16 3 |
COPY_8_TO_16 3 |
114 |
ret |
ret |
115 |
|
.endfunc |
116 |
|
|
117 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
118 |
; |
; |
148 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
149 |
COPY_16_TO_8 3 |
COPY_16_TO_8 3 |
150 |
ret |
ret |
151 |
|
.endfunc |
152 |
|
|
153 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
154 |
; |
; |
163 |
%macro COPY_8_TO_16_SUB 2 |
%macro COPY_8_TO_16_SUB 2 |
164 |
movq mm0, [eax] ; cur |
movq mm0, [eax] ; cur |
165 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
166 |
|
movq mm1, mm0 |
167 |
|
movq mm3, mm2 |
168 |
|
|
169 |
|
punpcklbw mm0, mm7 |
170 |
|
punpcklbw mm2, mm7 |
171 |
movq mm4, [ebx] ; ref |
movq mm4, [ebx] ; ref |
172 |
|
punpckhbw mm1, mm7 |
173 |
|
punpckhbw mm3, mm7 |
174 |
movq mm5, [ebx+edx] ; ref |
movq mm5, [ebx+edx] ; ref |
175 |
|
|
176 |
|
movq mm6, mm4 |
177 |
%if %2 == 1 |
%if %2 == 1 |
178 |
movq [eax], mm4 |
movq [eax], mm4 |
179 |
movq [eax+edx], mm5 |
movq [eax+edx], mm5 |
180 |
%endif |
%endif |
181 |
|
punpcklbw mm4, mm7 |
182 |
|
punpckhbw mm6, mm7 |
183 |
|
psubsw mm0, mm4 |
184 |
|
psubsw mm1, mm6 |
185 |
|
movq mm6, mm5 |
186 |
|
punpcklbw mm5, mm7 |
187 |
|
punpckhbw mm6, mm7 |
188 |
|
psubsw mm2, mm5 |
189 |
lea eax, [eax+2*edx] |
lea eax, [eax+2*edx] |
190 |
|
psubsw mm3, mm6 |
|
psubsb mm0,mm4 |
|
|
psubsb mm2,mm5 |
|
191 |
lea ebx,[ebx+2*edx] |
lea ebx,[ebx+2*edx] |
192 |
|
|
|
movq mm1,mm0 |
|
|
movq mm3,mm2 |
|
|
punpcklbw mm0,mm7 |
|
|
punpckhbw mm1,mm7 |
|
|
punpcklbw mm2,mm7 |
|
|
punpckhbw mm3,mm7 |
|
|
|
|
193 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
194 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
195 |
movq [ecx+%1*32+16], mm2 |
movq [ecx+%1*32+16], mm2 |
212 |
|
|
213 |
pop ebx |
pop ebx |
214 |
ret |
ret |
215 |
|
.endfunc |
216 |
|
|
217 |
|
|
218 |
ALIGN 16 |
ALIGN 16 |
231 |
|
|
232 |
pop ebx |
pop ebx |
233 |
ret |
ret |
234 |
|
.endfunc |
235 |
|
|
236 |
|
|
237 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
249 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
250 |
|
|
251 |
; mm4 <- (ref1+ref2+1) / 2 |
; mm4 <- (ref1+ref2+1) / 2 |
|
;(a+b+1)/2 = (a|b)-((a^b)>>1) |
|
252 |
movq mm4, [ebx] ; ref1 |
movq mm4, [ebx] ; ref1 |
253 |
movq mm1, [esi] ; ref2 |
movq mm1, [esi] ; ref2 |
254 |
movq mm3, mm4 |
movq mm6, mm4 |
255 |
pxor mm3,mm1 |
movq mm3, mm1 |
256 |
por mm4,mm1 |
punpcklbw mm4, mm7 |
257 |
pandn mm3,mm6 |
punpcklbw mm1, mm7 |
258 |
psrlq mm3,1 |
punpckhbw mm6, mm7 |
259 |
psubb mm4,mm3 |
punpckhbw mm3, mm7 |
260 |
|
paddusw mm4, mm1 |
261 |
|
paddusw mm6, mm3 |
262 |
|
paddusw mm4, [mmx_one] |
263 |
|
paddusw mm6, [mmx_one] |
264 |
|
psrlw mm4, 1 |
265 |
|
psrlw mm6, 1 |
266 |
|
packuswb mm4, mm6 |
267 |
movq [eax],mm4 |
movq [eax],mm4 |
268 |
|
|
269 |
; mm5 <- (ref1+ref2+1) / 2 |
; mm5 <- (ref1+ref2+1) / 2 |
270 |
movq mm5, [ebx+edx] ; ref1 |
movq mm5, [ebx+edx] ; ref1 |
271 |
movq mm1, [esi+edx] ; ref2 |
movq mm1, [esi+edx] ; ref2 |
272 |
movq mm3, mm5 |
movq mm6, mm5 |
273 |
pxor mm3,mm1 |
movq mm3, mm1 |
274 |
por mm5,mm1 |
punpcklbw mm5, mm7 |
275 |
pandn mm3,mm6 |
punpcklbw mm1, mm7 |
276 |
psrlq mm3,1 |
punpckhbw mm6, mm7 |
277 |
psubb mm5,mm3 |
punpckhbw mm3, mm7 |
278 |
|
paddusw mm5, mm1 |
279 |
|
paddusw mm6, mm3 |
280 |
|
paddusw mm5, [mmx_one] |
281 |
|
paddusw mm6, [mmx_one] |
282 |
|
lea esi, [esi+2*edx] |
283 |
|
psrlw mm5, 1 |
284 |
|
psrlw mm6, 1 |
285 |
|
packuswb mm5, mm6 |
286 |
movq [eax+edx],mm5 |
movq [eax+edx],mm5 |
287 |
|
|
|
psubsb mm0,mm4 |
|
|
psubsb mm2,mm5 |
|
|
lea esi, [esi+2*edx] |
|
288 |
movq mm1,mm0 |
movq mm1,mm0 |
289 |
movq mm3,mm2 |
movq mm3,mm2 |
|
lea eax, [eax+2*edx] |
|
290 |
punpcklbw mm0,mm7 |
punpcklbw mm0,mm7 |
291 |
punpcklbw mm2,mm7 |
punpcklbw mm2,mm7 |
|
lea ebx, [ebx+2*edx] |
|
292 |
punpckhbw mm1,mm7 |
punpckhbw mm1,mm7 |
293 |
punpckhbw mm3,mm7 |
punpckhbw mm3,mm7 |
294 |
|
|
295 |
|
movq mm6, mm4 |
296 |
|
punpcklbw mm4, mm7 |
297 |
|
punpckhbw mm6, mm7 |
298 |
|
psubsw mm0, mm4 |
299 |
|
psubsw mm1, mm6 |
300 |
|
movq mm6, mm5 |
301 |
|
punpcklbw mm5, mm7 |
302 |
|
punpckhbw mm6, mm7 |
303 |
|
psubsw mm2, mm5 |
304 |
|
lea eax, [eax+2*edx] |
305 |
|
psubsw mm3, mm6 |
306 |
|
lea ebx, [ebx+2*edx] |
307 |
|
|
308 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
309 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
310 |
movq [ecx+%1*32+16], mm2 |
movq [ecx+%1*32+16], mm2 |
320 |
push esi |
push esi |
321 |
mov esi, [esp+8+16] ; Ref2 |
mov esi, [esp+8+16] ; Ref2 |
322 |
mov edx, [esp+8+20] ; Stride |
mov edx, [esp+8+20] ; Stride |
|
pxor mm6,mm6 |
|
|
pcmpeqb mm5,mm5 |
|
323 |
pxor mm7, mm7 |
pxor mm7, mm7 |
|
psubb mm6, mm5; mm6=1 |
|
324 |
|
|
325 |
COPY_8_TO_16_SUB2_MMX 0 |
COPY_8_TO_16_SUB2_MMX 0 |
326 |
COPY_8_TO_16_SUB2_MMX 1 |
COPY_8_TO_16_SUB2_MMX 1 |
330 |
pop esi |
pop esi |
331 |
pop ebx |
pop ebx |
332 |
ret |
ret |
333 |
|
.endfunc |
334 |
|
|
335 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
336 |
; |
; |
345 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
346 |
movq mm0, [eax] ; cur |
movq mm0, [eax] ; cur |
347 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
348 |
|
movq mm1, mm0 |
349 |
|
movq mm3, mm2 |
350 |
|
|
351 |
|
punpcklbw mm0, mm7 |
352 |
|
punpcklbw mm2, mm7 |
353 |
movq mm4, [ebx] ; ref1 |
movq mm4, [ebx] ; ref1 |
354 |
pavgb mm4, [esi] ; ref2 |
pavgb mm4, [esi] ; ref2 |
355 |
|
movq [eax], mm4 |
356 |
|
punpckhbw mm1, mm7 |
357 |
|
punpckhbw mm3, mm7 |
358 |
movq mm5, [ebx+edx] ; ref |
movq mm5, [ebx+edx] ; ref |
359 |
pavgb mm5, [esi+edx] ; ref2 |
pavgb mm5, [esi+edx] ; ref2 |
|
|
|
|
movq [eax], mm4 |
|
360 |
movq [eax+edx], mm5 |
movq [eax+edx], mm5 |
361 |
|
|
362 |
psubsb mm0,mm4 |
movq mm6, mm4 |
363 |
psubsb mm2,mm5 |
punpcklbw mm4, mm7 |
364 |
|
punpckhbw mm6, mm7 |
365 |
|
psubsw mm0, mm4 |
366 |
|
psubsw mm1, mm6 |
367 |
lea esi, [esi+2*edx] |
lea esi, [esi+2*edx] |
368 |
movq mm1,mm0 |
movq mm6, mm5 |
369 |
movq mm3,mm2 |
punpcklbw mm5, mm7 |
370 |
|
punpckhbw mm6, mm7 |
371 |
|
psubsw mm2, mm5 |
372 |
lea eax, [eax+2*edx] |
lea eax, [eax+2*edx] |
373 |
punpcklbw mm0,mm7 |
psubsw mm3, mm6 |
|
punpcklbw mm2,mm7 |
|
374 |
lea ebx, [ebx+2*edx] |
lea ebx, [ebx+2*edx] |
|
punpckhbw mm1,mm7 |
|
|
punpckhbw mm3,mm7 |
|
375 |
|
|
376 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
377 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
398 |
pop esi |
pop esi |
399 |
pop ebx |
pop ebx |
400 |
ret |
ret |
401 |
|
.endfunc |
402 |
|
|
403 |
|
|
404 |
|
;----------------------------------------------------------------------------- |
405 |
|
; |
406 |
|
; void transfer_8to16sub2ro_xmm(int16_t * const dct, |
407 |
|
; const uint8_t * const cur, |
408 |
|
; const uint8_t * ref1, |
409 |
|
; const uint8_t * ref2, |
410 |
|
; const uint32_t stride) |
411 |
|
; |
412 |
|
;----------------------------------------------------------------------------- |
413 |
|
|
414 |
|
%macro COPY_8_TO_16_SUB2RO_SSE 1 |
415 |
|
movq mm0, [eax] ; cur |
416 |
|
movq mm2, [eax+edx] |
417 |
|
movq mm1, mm0 |
418 |
|
movq mm3, mm2 |
419 |
|
|
420 |
|
punpcklbw mm0, mm7 |
421 |
|
punpcklbw mm2, mm7 |
422 |
|
movq mm4, [ebx] ; ref1 |
423 |
|
pavgb mm4, [esi] ; ref2 |
424 |
|
punpckhbw mm1, mm7 |
425 |
|
punpckhbw mm3, mm7 |
426 |
|
movq mm5, [ebx+edx] ; ref |
427 |
|
pavgb mm5, [esi+edx] ; ref2 |
428 |
|
|
429 |
|
movq mm6, mm4 |
430 |
|
punpcklbw mm4, mm7 |
431 |
|
punpckhbw mm6, mm7 |
432 |
|
psubsw mm0, mm4 |
433 |
|
psubsw mm1, mm6 |
434 |
|
lea esi, [esi+2*edx] |
435 |
|
movq mm6, mm5 |
436 |
|
punpcklbw mm5, mm7 |
437 |
|
punpckhbw mm6, mm7 |
438 |
|
psubsw mm2, mm5 |
439 |
|
lea eax, [eax+2*edx] |
440 |
|
psubsw mm3, mm6 |
441 |
|
lea ebx, [ebx+2*edx] |
442 |
|
|
443 |
|
movq [ecx+%1*32+ 0], mm0 ; dst |
444 |
|
movq [ecx+%1*32+ 8], mm1 |
445 |
|
movq [ecx+%1*32+16], mm2 |
446 |
|
movq [ecx+%1*32+24], mm3 |
447 |
|
%endmacro |
448 |
|
|
449 |
|
ALIGN 16 |
450 |
|
transfer_8to16sub2ro_xmm: |
451 |
|
pxor mm7, mm7 |
452 |
|
mov ecx, [esp + 4] ; Dst |
453 |
|
mov eax, [esp + 8] ; Cur |
454 |
|
push ebx |
455 |
|
mov ebx, [esp+4+12] ; Ref1 |
456 |
|
push esi |
457 |
|
mov esi, [esp+8+16] ; Ref2 |
458 |
|
mov edx, [esp+8+20] ; Stride |
459 |
|
|
460 |
|
COPY_8_TO_16_SUB2RO_SSE 0 |
461 |
|
COPY_8_TO_16_SUB2RO_SSE 1 |
462 |
|
COPY_8_TO_16_SUB2RO_SSE 2 |
463 |
|
COPY_8_TO_16_SUB2RO_SSE 3 |
464 |
|
|
465 |
|
pop esi |
466 |
|
pop ebx |
467 |
|
ret |
468 |
|
.endfunc |
469 |
|
|
470 |
|
|
471 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
472 |
; |
; |
477 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
478 |
|
|
479 |
%macro COPY_16_TO_8_ADD 1 |
%macro COPY_16_TO_8_ADD 1 |
480 |
movq mm0, [eax+%1*32+ 0] ;src |
movq mm0, [ecx] |
481 |
packuswb mm0,[eax+%1*32+8] |
movq mm2, [ecx+edx] |
482 |
movq mm1, [eax+%1*32+ 16] |
movq mm1, mm0 |
483 |
packuswb mm1,[eax+%1*32+24] |
movq mm3, mm2 |
484 |
|
punpcklbw mm0, mm7 |
485 |
paddusb mm0,[ecx] |
punpcklbw mm2, mm7 |
486 |
paddusb mm1,[ecx+edx] |
punpckhbw mm1, mm7 |
487 |
|
punpckhbw mm3, mm7 |
488 |
|
paddsw mm0, [eax+%1*32+ 0] |
489 |
|
paddsw mm1, [eax+%1*32+ 8] |
490 |
|
paddsw mm2, [eax+%1*32+16] |
491 |
|
paddsw mm3, [eax+%1*32+24] |
492 |
|
packuswb mm0, mm1 |
493 |
movq [ecx],mm0 |
movq [ecx],mm0 |
494 |
movq [ecx+edx],mm1 |
packuswb mm2, mm3 |
495 |
|
movq [ecx+edx], mm2 |
496 |
%endmacro |
%endmacro |
497 |
|
|
498 |
|
|
501 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
502 |
mov eax, [esp+ 8] ; Src |
mov eax, [esp+ 8] ; Src |
503 |
mov edx, [esp+12] ; Stride |
mov edx, [esp+12] ; Stride |
504 |
; pxor mm7, mm7 |
pxor mm7, mm7 |
505 |
|
|
506 |
COPY_16_TO_8_ADD 0 |
COPY_16_TO_8_ADD 0 |
507 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
511 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
512 |
COPY_16_TO_8_ADD 3 |
COPY_16_TO_8_ADD 3 |
513 |
ret |
ret |
514 |
|
.endfunc |
515 |
|
|
516 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
517 |
; |
; |
522 |
; |
; |
523 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
524 |
|
|
525 |
|
%macro COPY_8_TO_8 0 |
526 |
|
movq mm0, [eax] |
527 |
|
movq mm1, [eax+edx] |
528 |
|
movq [ecx], mm0 |
529 |
|
lea eax, [eax+2*edx] |
530 |
|
movq [ecx+edx], mm1 |
531 |
|
%endmacro |
532 |
|
|
533 |
ALIGN 16 |
ALIGN 16 |
534 |
transfer8x8_copy_mmx: |
transfer8x8_copy_mmx: |
|
|
|
|
mov eax, [esp+ 8] ; Src |
|
535 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
536 |
|
mov eax, [esp+ 8] ; Src |
537 |
mov edx, [esp+12] ; Stride |
mov edx, [esp+12] ; Stride |
538 |
|
|
539 |
movq mm0,[eax] |
COPY_8_TO_8 |
540 |
lea eax,[eax+edx] |
lea ecx,[ecx+2*edx] |
541 |
movq mm1,[eax] |
COPY_8_TO_8 |
542 |
lea eax,[eax+edx] |
lea ecx,[ecx+2*edx] |
543 |
movq mm2,[eax] |
COPY_8_TO_8 |
544 |
lea eax,[eax+edx] |
lea ecx,[ecx+2*edx] |
545 |
movq mm3,[eax] |
COPY_8_TO_8 |
|
lea eax,[eax+edx] |
|
|
movq mm4,[eax] |
|
|
lea eax,[eax+edx] |
|
|
movq mm5,[eax] |
|
|
lea eax,[eax+edx] |
|
|
movq mm6,[eax] |
|
|
lea eax,[eax+edx] |
|
|
movq mm7,[eax] |
|
|
|
|
|
movq [ecx],mm0 |
|
|
lea ecx,[ecx+edx] |
|
|
movq [ecx],mm1 |
|
|
lea ecx,[ecx+edx] |
|
|
movq [ecx],mm2 |
|
|
lea ecx,[ecx+edx] |
|
|
movq [ecx],mm3 |
|
|
lea ecx,[ecx+edx] |
|
|
movq [ecx],mm4 |
|
|
lea ecx,[ecx+edx] |
|
|
movq [ecx],mm5 |
|
|
lea ecx,[ecx+edx] |
|
|
movq [ecx],mm6 |
|
|
lea ecx,[ecx+edx] |
|
|
movq [ecx],mm7 |
|
|
|
|
546 |
ret |
ret |
547 |
|
.endfunc |
548 |
|
|