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 |
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 |
|
%define ENDFUNC .endfunc |
36 |
|
%else |
37 |
global _%1 |
global _%1 |
38 |
%define %1 _%1 |
%define %1 _%1 |
39 |
|
%define ENDFUNC |
40 |
|
%endif |
41 |
|
%else |
42 |
|
%ifdef MARK_FUNCS |
43 |
|
global %1:function %1.endfunc-%1 |
44 |
|
%define ENDFUNC .endfunc |
45 |
%else |
%else |
46 |
global %1 |
global %1 |
47 |
|
%define ENDFUNC |
48 |
|
%endif |
49 |
%endif |
%endif |
50 |
%endmacro |
%endmacro |
51 |
|
|
54 |
;============================================================================= |
;============================================================================= |
55 |
|
|
56 |
%ifdef FORMAT_COFF |
%ifdef FORMAT_COFF |
57 |
SECTION .rodata data |
SECTION .rodata |
58 |
%else |
%else |
59 |
SECTION .rodata data align=16 |
SECTION .rodata align=16 |
60 |
%endif |
%endif |
61 |
|
|
62 |
ALIGN 16 |
ALIGN 16 |
75 |
cglobal transfer_8to16subro_mmx |
cglobal transfer_8to16subro_mmx |
76 |
cglobal transfer_8to16sub2_mmx |
cglobal transfer_8to16sub2_mmx |
77 |
cglobal transfer_8to16sub2_xmm |
cglobal transfer_8to16sub2_xmm |
78 |
|
cglobal transfer_8to16sub2ro_xmm |
79 |
cglobal transfer_16to8add_mmx |
cglobal transfer_16to8add_mmx |
80 |
cglobal transfer8x8_copy_mmx |
cglobal transfer8x8_copy_mmx |
81 |
|
cglobal transfer8x4_copy_mmx |
82 |
|
|
83 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
84 |
; |
; |
117 |
COPY_8_TO_16 2 |
COPY_8_TO_16 2 |
118 |
COPY_8_TO_16 3 |
COPY_8_TO_16 3 |
119 |
ret |
ret |
120 |
|
ENDFUNC |
121 |
|
|
122 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
123 |
; |
; |
153 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
154 |
COPY_16_TO_8 3 |
COPY_16_TO_8 3 |
155 |
ret |
ret |
156 |
|
ENDFUNC |
157 |
|
|
158 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
159 |
; |
; |
168 |
%macro COPY_8_TO_16_SUB 2 |
%macro COPY_8_TO_16_SUB 2 |
169 |
movq mm0, [eax] ; cur |
movq mm0, [eax] ; cur |
170 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
171 |
|
movq mm1, mm0 |
172 |
|
movq mm3, mm2 |
173 |
|
|
174 |
|
punpcklbw mm0, mm7 |
175 |
|
punpcklbw mm2, mm7 |
176 |
movq mm4, [ebx] ; ref |
movq mm4, [ebx] ; ref |
177 |
|
punpckhbw mm1, mm7 |
178 |
|
punpckhbw mm3, mm7 |
179 |
movq mm5, [ebx+edx] ; ref |
movq mm5, [ebx+edx] ; ref |
180 |
|
|
181 |
|
movq mm6, mm4 |
182 |
%if %2 == 1 |
%if %2 == 1 |
183 |
movq [eax], mm4 |
movq [eax], mm4 |
184 |
movq [eax+edx], mm5 |
movq [eax+edx], mm5 |
185 |
%endif |
%endif |
186 |
|
punpcklbw mm4, mm7 |
187 |
|
punpckhbw mm6, mm7 |
188 |
|
psubsw mm0, mm4 |
189 |
|
psubsw mm1, mm6 |
190 |
|
movq mm6, mm5 |
191 |
|
punpcklbw mm5, mm7 |
192 |
|
punpckhbw mm6, mm7 |
193 |
|
psubsw mm2, mm5 |
194 |
lea eax, [eax+2*edx] |
lea eax, [eax+2*edx] |
195 |
|
psubsw mm3, mm6 |
|
psubsb mm0,mm4 |
|
|
psubsb mm2,mm5 |
|
196 |
lea ebx,[ebx+2*edx] |
lea ebx,[ebx+2*edx] |
197 |
|
|
|
movq mm1,mm0 |
|
|
movq mm3,mm2 |
|
|
punpcklbw mm0,mm7 |
|
|
punpckhbw mm1,mm7 |
|
|
punpcklbw mm2,mm7 |
|
|
punpckhbw mm3,mm7 |
|
|
|
|
198 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
199 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
200 |
movq [ecx+%1*32+16], mm2 |
movq [ecx+%1*32+16], mm2 |
217 |
|
|
218 |
pop ebx |
pop ebx |
219 |
ret |
ret |
220 |
|
ENDFUNC |
221 |
|
|
222 |
|
|
223 |
ALIGN 16 |
ALIGN 16 |
236 |
|
|
237 |
pop ebx |
pop ebx |
238 |
ret |
ret |
239 |
|
ENDFUNC |
240 |
|
|
241 |
|
|
242 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
254 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
255 |
|
|
256 |
; mm4 <- (ref1+ref2+1) / 2 |
; mm4 <- (ref1+ref2+1) / 2 |
|
;(a+b+1)/2 = (a|b)-((a^b)>>1) |
|
257 |
movq mm4, [ebx] ; ref1 |
movq mm4, [ebx] ; ref1 |
258 |
movq mm1, [esi] ; ref2 |
movq mm1, [esi] ; ref2 |
259 |
movq mm3, mm4 |
movq mm6, mm4 |
260 |
pxor mm3,mm1 |
movq mm3, mm1 |
261 |
por mm4,mm1 |
punpcklbw mm4, mm7 |
262 |
pandn mm3,mm6 |
punpcklbw mm1, mm7 |
263 |
psrlq mm3,1 |
punpckhbw mm6, mm7 |
264 |
psubb mm4,mm3 |
punpckhbw mm3, mm7 |
265 |
|
paddusw mm4, mm1 |
266 |
|
paddusw mm6, mm3 |
267 |
|
paddusw mm4, [mmx_one] |
268 |
|
paddusw mm6, [mmx_one] |
269 |
|
psrlw mm4, 1 |
270 |
|
psrlw mm6, 1 |
271 |
|
packuswb mm4, mm6 |
272 |
movq [eax],mm4 |
movq [eax],mm4 |
273 |
|
|
274 |
; mm5 <- (ref1+ref2+1) / 2 |
; mm5 <- (ref1+ref2+1) / 2 |
275 |
movq mm5, [ebx+edx] ; ref1 |
movq mm5, [ebx+edx] ; ref1 |
276 |
movq mm1, [esi+edx] ; ref2 |
movq mm1, [esi+edx] ; ref2 |
277 |
movq mm3, mm5 |
movq mm6, mm5 |
278 |
pxor mm3,mm1 |
movq mm3, mm1 |
279 |
por mm5,mm1 |
punpcklbw mm5, mm7 |
280 |
pandn mm3,mm6 |
punpcklbw mm1, mm7 |
281 |
psrlq mm3,1 |
punpckhbw mm6, mm7 |
282 |
psubb mm5,mm3 |
punpckhbw mm3, mm7 |
283 |
|
paddusw mm5, mm1 |
284 |
|
paddusw mm6, mm3 |
285 |
|
paddusw mm5, [mmx_one] |
286 |
|
paddusw mm6, [mmx_one] |
287 |
|
lea esi, [esi+2*edx] |
288 |
|
psrlw mm5, 1 |
289 |
|
psrlw mm6, 1 |
290 |
|
packuswb mm5, mm6 |
291 |
movq [eax+edx],mm5 |
movq [eax+edx],mm5 |
292 |
|
|
|
psubsb mm0,mm4 |
|
|
psubsb mm2,mm5 |
|
|
lea esi, [esi+2*edx] |
|
293 |
movq mm1,mm0 |
movq mm1,mm0 |
294 |
movq mm3,mm2 |
movq mm3,mm2 |
|
lea eax, [eax+2*edx] |
|
295 |
punpcklbw mm0,mm7 |
punpcklbw mm0,mm7 |
296 |
punpcklbw mm2,mm7 |
punpcklbw mm2,mm7 |
|
lea ebx, [ebx+2*edx] |
|
297 |
punpckhbw mm1,mm7 |
punpckhbw mm1,mm7 |
298 |
punpckhbw mm3,mm7 |
punpckhbw mm3,mm7 |
299 |
|
|
300 |
|
movq mm6, mm4 |
301 |
|
punpcklbw mm4, mm7 |
302 |
|
punpckhbw mm6, mm7 |
303 |
|
psubsw mm0, mm4 |
304 |
|
psubsw mm1, mm6 |
305 |
|
movq mm6, mm5 |
306 |
|
punpcklbw mm5, mm7 |
307 |
|
punpckhbw mm6, mm7 |
308 |
|
psubsw mm2, mm5 |
309 |
|
lea eax, [eax+2*edx] |
310 |
|
psubsw mm3, mm6 |
311 |
|
lea ebx, [ebx+2*edx] |
312 |
|
|
313 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
314 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
315 |
movq [ecx+%1*32+16], mm2 |
movq [ecx+%1*32+16], mm2 |
325 |
push esi |
push esi |
326 |
mov esi, [esp+8+16] ; Ref2 |
mov esi, [esp+8+16] ; Ref2 |
327 |
mov edx, [esp+8+20] ; Stride |
mov edx, [esp+8+20] ; Stride |
|
pxor mm6,mm6 |
|
|
pcmpeqb mm5,mm5 |
|
328 |
pxor mm7, mm7 |
pxor mm7, mm7 |
|
psubb mm6, mm5; mm6=1 |
|
329 |
|
|
330 |
COPY_8_TO_16_SUB2_MMX 0 |
COPY_8_TO_16_SUB2_MMX 0 |
331 |
COPY_8_TO_16_SUB2_MMX 1 |
COPY_8_TO_16_SUB2_MMX 1 |
335 |
pop esi |
pop esi |
336 |
pop ebx |
pop ebx |
337 |
ret |
ret |
338 |
|
ENDFUNC |
339 |
|
|
340 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
341 |
; |
; |
350 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
351 |
movq mm0, [eax] ; cur |
movq mm0, [eax] ; cur |
352 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
353 |
|
movq mm1, mm0 |
354 |
|
movq mm3, mm2 |
355 |
|
|
356 |
|
punpcklbw mm0, mm7 |
357 |
|
punpcklbw mm2, mm7 |
358 |
movq mm4, [ebx] ; ref1 |
movq mm4, [ebx] ; ref1 |
359 |
pavgb mm4, [esi] ; ref2 |
pavgb mm4, [esi] ; ref2 |
360 |
|
movq [eax], mm4 |
361 |
|
punpckhbw mm1, mm7 |
362 |
|
punpckhbw mm3, mm7 |
363 |
movq mm5, [ebx+edx] ; ref |
movq mm5, [ebx+edx] ; ref |
364 |
pavgb mm5, [esi+edx] ; ref2 |
pavgb mm5, [esi+edx] ; ref2 |
|
|
|
|
movq [eax], mm4 |
|
365 |
movq [eax+edx], mm5 |
movq [eax+edx], mm5 |
366 |
|
|
367 |
psubsb mm0,mm4 |
movq mm6, mm4 |
368 |
psubsb mm2,mm5 |
punpcklbw mm4, mm7 |
369 |
|
punpckhbw mm6, mm7 |
370 |
|
psubsw mm0, mm4 |
371 |
|
psubsw mm1, mm6 |
372 |
lea esi, [esi+2*edx] |
lea esi, [esi+2*edx] |
373 |
movq mm1,mm0 |
movq mm6, mm5 |
374 |
movq mm3,mm2 |
punpcklbw mm5, mm7 |
375 |
|
punpckhbw mm6, mm7 |
376 |
|
psubsw mm2, mm5 |
377 |
lea eax, [eax+2*edx] |
lea eax, [eax+2*edx] |
378 |
punpcklbw mm0,mm7 |
psubsw mm3, mm6 |
|
punpcklbw mm2,mm7 |
|
379 |
lea ebx, [ebx+2*edx] |
lea ebx, [ebx+2*edx] |
|
punpckhbw mm1,mm7 |
|
|
punpckhbw mm3,mm7 |
|
380 |
|
|
381 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
382 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
403 |
pop esi |
pop esi |
404 |
pop ebx |
pop ebx |
405 |
ret |
ret |
406 |
|
ENDFUNC |
407 |
|
|
408 |
|
|
409 |
|
;----------------------------------------------------------------------------- |
410 |
|
; |
411 |
|
; void transfer_8to16sub2ro_xmm(int16_t * const dct, |
412 |
|
; const uint8_t * const cur, |
413 |
|
; const uint8_t * ref1, |
414 |
|
; const uint8_t * ref2, |
415 |
|
; const uint32_t stride) |
416 |
|
; |
417 |
|
;----------------------------------------------------------------------------- |
418 |
|
|
419 |
|
%macro COPY_8_TO_16_SUB2RO_SSE 1 |
420 |
|
movq mm0, [eax] ; cur |
421 |
|
movq mm2, [eax+edx] |
422 |
|
movq mm1, mm0 |
423 |
|
movq mm3, mm2 |
424 |
|
|
425 |
|
punpcklbw mm0, mm7 |
426 |
|
punpcklbw mm2, mm7 |
427 |
|
movq mm4, [ebx] ; ref1 |
428 |
|
pavgb mm4, [esi] ; ref2 |
429 |
|
punpckhbw mm1, mm7 |
430 |
|
punpckhbw mm3, mm7 |
431 |
|
movq mm5, [ebx+edx] ; ref |
432 |
|
pavgb mm5, [esi+edx] ; ref2 |
433 |
|
|
434 |
|
movq mm6, mm4 |
435 |
|
punpcklbw mm4, mm7 |
436 |
|
punpckhbw mm6, mm7 |
437 |
|
psubsw mm0, mm4 |
438 |
|
psubsw mm1, mm6 |
439 |
|
lea esi, [esi+2*edx] |
440 |
|
movq mm6, mm5 |
441 |
|
punpcklbw mm5, mm7 |
442 |
|
punpckhbw mm6, mm7 |
443 |
|
psubsw mm2, mm5 |
444 |
|
lea eax, [eax+2*edx] |
445 |
|
psubsw mm3, mm6 |
446 |
|
lea ebx, [ebx+2*edx] |
447 |
|
|
448 |
|
movq [ecx+%1*32+ 0], mm0 ; dst |
449 |
|
movq [ecx+%1*32+ 8], mm1 |
450 |
|
movq [ecx+%1*32+16], mm2 |
451 |
|
movq [ecx+%1*32+24], mm3 |
452 |
|
%endmacro |
453 |
|
|
454 |
|
ALIGN 16 |
455 |
|
transfer_8to16sub2ro_xmm: |
456 |
|
pxor mm7, mm7 |
457 |
|
mov ecx, [esp + 4] ; Dst |
458 |
|
mov eax, [esp + 8] ; Cur |
459 |
|
push ebx |
460 |
|
mov ebx, [esp+4+12] ; Ref1 |
461 |
|
push esi |
462 |
|
mov esi, [esp+8+16] ; Ref2 |
463 |
|
mov edx, [esp+8+20] ; Stride |
464 |
|
|
465 |
|
COPY_8_TO_16_SUB2RO_SSE 0 |
466 |
|
COPY_8_TO_16_SUB2RO_SSE 1 |
467 |
|
COPY_8_TO_16_SUB2RO_SSE 2 |
468 |
|
COPY_8_TO_16_SUB2RO_SSE 3 |
469 |
|
|
470 |
|
pop esi |
471 |
|
pop ebx |
472 |
|
ret |
473 |
|
ENDFUNC |
474 |
|
|
475 |
|
|
476 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
477 |
; |
; |
482 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
483 |
|
|
484 |
%macro COPY_16_TO_8_ADD 1 |
%macro COPY_16_TO_8_ADD 1 |
485 |
movq mm0, [eax+%1*32+ 0] ;src |
movq mm0, [ecx] |
486 |
packuswb mm0,[eax+%1*32+8] |
movq mm2, [ecx+edx] |
487 |
movq mm1, [eax+%1*32+ 16] |
movq mm1, mm0 |
488 |
packuswb mm1,[eax+%1*32+24] |
movq mm3, mm2 |
489 |
|
punpcklbw mm0, mm7 |
490 |
paddusb mm0,[ecx] |
punpcklbw mm2, mm7 |
491 |
paddusb mm1,[ecx+edx] |
punpckhbw mm1, mm7 |
492 |
|
punpckhbw mm3, mm7 |
493 |
|
paddsw mm0, [eax+%1*32+ 0] |
494 |
|
paddsw mm1, [eax+%1*32+ 8] |
495 |
|
paddsw mm2, [eax+%1*32+16] |
496 |
|
paddsw mm3, [eax+%1*32+24] |
497 |
|
packuswb mm0, mm1 |
498 |
movq [ecx],mm0 |
movq [ecx],mm0 |
499 |
movq [ecx+edx],mm1 |
packuswb mm2, mm3 |
500 |
|
movq [ecx+edx], mm2 |
501 |
%endmacro |
%endmacro |
502 |
|
|
503 |
|
|
506 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
507 |
mov eax, [esp+ 8] ; Src |
mov eax, [esp+ 8] ; Src |
508 |
mov edx, [esp+12] ; Stride |
mov edx, [esp+12] ; Stride |
509 |
; pxor mm7, mm7 |
pxor mm7, mm7 |
510 |
|
|
511 |
COPY_16_TO_8_ADD 0 |
COPY_16_TO_8_ADD 0 |
512 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
516 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
517 |
COPY_16_TO_8_ADD 3 |
COPY_16_TO_8_ADD 3 |
518 |
ret |
ret |
519 |
|
ENDFUNC |
520 |
|
|
521 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
522 |
; |
; |
527 |
; |
; |
528 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
529 |
|
|
530 |
|
%macro COPY_8_TO_8 0 |
531 |
|
movq mm0, [eax] |
532 |
|
movq mm1, [eax+edx] |
533 |
|
movq [ecx], mm0 |
534 |
|
lea eax, [eax+2*edx] |
535 |
|
movq [ecx+edx], mm1 |
536 |
|
%endmacro |
537 |
|
|
538 |
ALIGN 16 |
ALIGN 16 |
539 |
transfer8x8_copy_mmx: |
transfer8x8_copy_mmx: |
|
|
|
|
mov eax, [esp+ 8] ; Src |
|
540 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
541 |
|
mov eax, [esp+ 8] ; Src |
542 |
mov edx, [esp+12] ; Stride |
mov edx, [esp+12] ; Stride |
543 |
|
|
544 |
movq mm0,[eax] |
COPY_8_TO_8 |
545 |
lea eax,[eax+edx] |
lea ecx,[ecx+2*edx] |
546 |
movq mm1,[eax] |
COPY_8_TO_8 |
547 |
lea eax,[eax+edx] |
lea ecx,[ecx+2*edx] |
548 |
movq mm2,[eax] |
COPY_8_TO_8 |
549 |
lea eax,[eax+edx] |
lea ecx,[ecx+2*edx] |
550 |
movq mm3,[eax] |
COPY_8_TO_8 |
551 |
lea eax,[eax+edx] |
ret |
552 |
movq mm4,[eax] |
ENDFUNC |
|
lea eax,[eax+edx] |
|
|
movq mm5,[eax] |
|
|
lea eax,[eax+edx] |
|
|
movq mm6,[eax] |
|
|
lea eax,[eax+edx] |
|
|
movq mm7,[eax] |
|
553 |
|
|
554 |
movq [ecx],mm0 |
;----------------------------------------------------------------------------- |
555 |
lea ecx,[ecx+edx] |
; |
556 |
movq [ecx],mm1 |
; void transfer8x4_copy_mmx(uint8_t * const dst, |
557 |
lea ecx,[ecx+edx] |
; const uint8_t * const src, |
558 |
movq [ecx],mm2 |
; const uint32_t stride); |
559 |
lea ecx,[ecx+edx] |
; |
560 |
movq [ecx],mm3 |
; |
561 |
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 |
|
562 |
|
|
563 |
|
ALIGN 16 |
564 |
|
transfer8x4_copy_mmx: |
565 |
|
mov ecx, [esp+ 4] ; Dst |
566 |
|
mov eax, [esp+ 8] ; Src |
567 |
|
mov edx, [esp+12] ; Stride |
568 |
|
|
569 |
|
COPY_8_TO_8 |
570 |
|
lea ecx,[ecx+2*edx] |
571 |
|
COPY_8_TO_8 |
572 |
ret |
ret |
573 |
|
ENDFUNC |
574 |
|
|
575 |
|
|
576 |
|
%ifidn __OUTPUT_FORMAT__,elf |
577 |
|
section ".note.GNU-stack" noalloc noexec nowrite progbits |
578 |
|
%endif |
579 |
|
|