26 |
|
|
27 |
%macro cglobal 1 |
%macro cglobal 1 |
28 |
%ifdef PREFIX |
%ifdef PREFIX |
29 |
|
%ifdef MARK_FUNCS |
30 |
|
global _%1:function %1.endfunc-%1 |
31 |
|
%define %1 _%1:function %1.endfunc-%1 |
32 |
|
%define ENDFUNC .endfunc |
33 |
|
%else |
34 |
global _%1 |
global _%1 |
35 |
%define %1 _%1 |
%define %1 _%1 |
36 |
|
%define ENDFUNC |
37 |
|
%endif |
38 |
|
%else |
39 |
|
%ifdef MARK_FUNCS |
40 |
|
global %1:function %1.endfunc-%1 |
41 |
|
%define ENDFUNC .endfunc |
42 |
%else |
%else |
43 |
global %1 |
global %1 |
44 |
|
%define ENDFUNC |
45 |
|
%endif |
46 |
%endif |
%endif |
47 |
%endmacro |
%endmacro |
48 |
|
|
66 |
cglobal interpolate8x8_halfpel_v_xmm |
cglobal interpolate8x8_halfpel_v_xmm |
67 |
cglobal interpolate8x8_halfpel_hv_xmm |
cglobal interpolate8x8_halfpel_hv_xmm |
68 |
|
|
69 |
|
cglobal interpolate8x4_halfpel_h_xmm |
70 |
|
cglobal interpolate8x4_halfpel_v_xmm |
71 |
|
cglobal interpolate8x4_halfpel_hv_xmm |
72 |
|
|
73 |
cglobal interpolate8x8_halfpel_add_xmm |
cglobal interpolate8x8_halfpel_add_xmm |
74 |
cglobal interpolate8x8_halfpel_h_add_xmm |
cglobal interpolate8x8_halfpel_h_add_xmm |
75 |
cglobal interpolate8x8_halfpel_v_add_xmm |
cglobal interpolate8x8_halfpel_v_add_xmm |
134 |
COPY_H_SSE_RND0 |
COPY_H_SSE_RND0 |
135 |
ret |
ret |
136 |
|
|
137 |
.rounding1 |
.rounding1: |
138 |
; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1 |
; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1 |
139 |
movq mm7, [mmx_one] |
movq mm7, [mmx_one] |
140 |
COPY_H_SSE_RND1 |
COPY_H_SSE_RND1 |
145 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
146 |
COPY_H_SSE_RND1 |
COPY_H_SSE_RND1 |
147 |
ret |
ret |
148 |
|
ENDFUNC |
149 |
|
|
150 |
;=========================================================================== |
;=========================================================================== |
151 |
; |
; |
206 |
COPY_V_SSE_RND0 |
COPY_V_SSE_RND0 |
207 |
ret |
ret |
208 |
|
|
209 |
.rounding1 |
.rounding1: |
210 |
; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1 |
; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1 |
211 |
movq mm7, [mmx_one] |
movq mm7, [mmx_one] |
212 |
movq mm2, [eax] ; loop invariant |
movq mm2, [eax] ; loop invariant |
220 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
221 |
COPY_V_SSE_RND1 |
COPY_V_SSE_RND1 |
222 |
ret |
ret |
223 |
|
ENDFUNC |
224 |
|
|
225 |
;=========================================================================== |
;=========================================================================== |
226 |
; |
; |
350 |
COPY_HV_SSE_RND0 |
COPY_HV_SSE_RND0 |
351 |
ret |
ret |
352 |
|
|
353 |
.rounding1 |
.rounding1: |
354 |
COPY_HV_SSE_RND1 |
COPY_HV_SSE_RND1 |
355 |
add ecx, edx |
add ecx, edx |
356 |
COPY_HV_SSE_RND1 |
COPY_HV_SSE_RND1 |
359 |
add ecx, edx |
add ecx, edx |
360 |
COPY_HV_SSE_RND1 |
COPY_HV_SSE_RND1 |
361 |
ret |
ret |
362 |
|
ENDFUNC |
363 |
|
|
364 |
|
;=========================================================================== |
365 |
|
; |
366 |
|
; void interpolate8x4_halfpel_h_xmm(uint8_t * const dst, |
367 |
|
; const uint8_t * const src, |
368 |
|
; const uint32_t stride, |
369 |
|
; const uint32_t rounding); |
370 |
|
; |
371 |
|
;=========================================================================== |
372 |
|
|
373 |
|
ALIGN 16 |
374 |
|
interpolate8x4_halfpel_h_xmm: |
375 |
|
|
376 |
|
mov eax, [esp+16] ; rounding |
377 |
|
mov ecx, [esp+ 4] ; Dst |
378 |
|
test eax,eax |
379 |
|
mov eax, [esp+ 8] ; Src |
380 |
|
mov edx, [esp+12] ; stride |
381 |
|
|
382 |
|
jnz near .rounding1 |
383 |
|
|
384 |
|
COPY_H_SSE_RND0 |
385 |
|
lea ecx,[ecx+2*edx] |
386 |
|
COPY_H_SSE_RND0 |
387 |
|
ret |
388 |
|
|
389 |
|
.rounding1: |
390 |
|
; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1 |
391 |
|
movq mm7, [mmx_one] |
392 |
|
COPY_H_SSE_RND1 |
393 |
|
lea ecx, [ecx+2*edx] |
394 |
|
COPY_H_SSE_RND1 |
395 |
|
ret |
396 |
|
ENDFUNC |
397 |
|
|
398 |
|
;=========================================================================== |
399 |
|
; |
400 |
|
; void interpolate8x4_halfpel_v_xmm(uint8_t * const dst, |
401 |
|
; const uint8_t * const src, |
402 |
|
; const uint32_t stride, |
403 |
|
; const uint32_t rounding); |
404 |
|
; |
405 |
|
;=========================================================================== |
406 |
|
|
407 |
|
ALIGN 16 |
408 |
|
interpolate8x4_halfpel_v_xmm: |
409 |
|
|
410 |
|
mov eax, [esp+16]; rounding |
411 |
|
mov ecx, [esp+ 4] ; Dst |
412 |
|
test eax,eax |
413 |
|
mov eax, [esp+ 8] ; Src |
414 |
|
mov edx, [esp+12] ; stride |
415 |
|
|
416 |
|
; we process 2 line at a time |
417 |
|
jnz near .rounding1 |
418 |
|
|
419 |
|
COPY_V_SSE_RND0 |
420 |
|
lea ecx, [ecx+2*edx] |
421 |
|
COPY_V_SSE_RND0 |
422 |
|
ret |
423 |
|
|
424 |
|
.rounding1: |
425 |
|
; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1 |
426 |
|
movq mm7, [mmx_one] |
427 |
|
movq mm2, [eax] ; loop invariant |
428 |
|
add eax, edx |
429 |
|
|
430 |
|
COPY_V_SSE_RND1 |
431 |
|
lea ecx,[ecx+2*edx] |
432 |
|
COPY_V_SSE_RND1 |
433 |
|
ret |
434 |
|
ENDFUNC |
435 |
|
|
436 |
|
;=========================================================================== |
437 |
|
; |
438 |
|
; void interpolate8x4_halfpel_hv_xmm(uint8_t * const dst, |
439 |
|
; const uint8_t * const src, |
440 |
|
; const uint32_t stride, |
441 |
|
; const uint32_t rounding); |
442 |
|
; |
443 |
|
; |
444 |
|
;=========================================================================== |
445 |
|
|
446 |
|
; The trick is to correct the result of 'pavgb' with some combination of the |
447 |
|
; lsb's of the 4 input values i,j,k,l, and their intermediate 'pavgb' (s and t). |
448 |
|
; The boolean relations are: |
449 |
|
; (i+j+k+l+3)/4 = (s+t+1)/2 - (ij&kl)&st |
450 |
|
; (i+j+k+l+2)/4 = (s+t+1)/2 - (ij|kl)&st |
451 |
|
; (i+j+k+l+1)/4 = (s+t+1)/2 - (ij&kl)|st |
452 |
|
; (i+j+k+l+0)/4 = (s+t+1)/2 - (ij|kl)|st |
453 |
|
; with s=(i+j+1)/2, t=(k+l+1)/2, ij = i^j, kl = k^l, st = s^t. |
454 |
|
|
455 |
|
; Moreover, we process 2 lines at a times, for better overlapping (~15% faster). |
456 |
|
|
457 |
|
ALIGN 16 |
458 |
|
interpolate8x4_halfpel_hv_xmm: |
459 |
|
mov eax, [esp+16] ; rounding |
460 |
|
mov ecx, [esp+ 4] ; Dst |
461 |
|
test eax, eax |
462 |
|
mov eax, [esp+ 8] ; Src |
463 |
|
mov edx, [esp+12] ; stride |
464 |
|
|
465 |
|
movq mm7, [mmx_one] |
466 |
|
|
467 |
|
; loop invariants: mm2=(i+j+1)/2 and mm3= i^j |
468 |
|
movq mm2, [eax] |
469 |
|
movq mm3, [eax+1] |
470 |
|
movq mm6, mm2 |
471 |
|
pavgb mm2, mm3 |
472 |
|
pxor mm3, mm6 ; mm2/mm3 ready |
473 |
|
|
474 |
|
jnz near .rounding1 |
475 |
|
|
476 |
|
COPY_HV_SSE_RND0 |
477 |
|
add ecx, edx |
478 |
|
COPY_HV_SSE_RND0 |
479 |
|
ret |
480 |
|
|
481 |
|
.rounding1: |
482 |
|
COPY_HV_SSE_RND1 |
483 |
|
add ecx, edx |
484 |
|
COPY_HV_SSE_RND1 |
485 |
|
ret |
486 |
|
ENDFUNC |
487 |
|
|
488 |
;=========================================================================== |
;=========================================================================== |
489 |
; |
; |
551 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
552 |
ADD_FF 0, edx |
ADD_FF 0, edx |
553 |
EPILOG |
EPILOG |
554 |
|
ENDFUNC |
555 |
|
|
556 |
;=========================================================================== |
;=========================================================================== |
557 |
; |
; |
613 |
ADD_FH_RND0 0, edx |
ADD_FH_RND0 0, edx |
614 |
EPILOG |
EPILOG |
615 |
|
|
616 |
.Loop1 |
.Loop1: |
617 |
; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1 |
; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1 |
618 |
; movq mm7, [mmx_one] |
; movq mm7, [mmx_one] |
619 |
ADD_FH_RND1 0, edx |
ADD_FH_RND1 0, edx |
627 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
628 |
ADD_FH_RND1 0, edx |
ADD_FH_RND1 0, edx |
629 |
EPILOG |
EPILOG |
630 |
|
ENDFUNC |
631 |
|
|
632 |
|
|
633 |
;=========================================================================== |
;=========================================================================== |
688 |
ADD_8_HF_RND0 |
ADD_8_HF_RND0 |
689 |
EPILOG |
EPILOG |
690 |
|
|
691 |
.Loop1 |
.Loop1: |
692 |
movq mm0, [eax] ; loop invariant |
movq mm0, [eax] ; loop invariant |
693 |
movq mm7, [mmx_one] |
movq mm7, [mmx_one] |
694 |
|
|
703 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
704 |
ADD_8_HF_RND1 |
ADD_8_HF_RND1 |
705 |
EPILOG |
EPILOG |
706 |
|
ENDFUNC |
707 |
|
|
708 |
; The trick is to correct the result of 'pavgb' with some combination of the |
; The trick is to correct the result of 'pavgb' with some combination of the |
709 |
; lsb's of the 4 input values i,j,k,l, and their intermediate 'pavgb' (s and t). |
; lsb's of the 4 input values i,j,k,l, and their intermediate 'pavgb' (s and t). |
833 |
ADD_HH_RND0 |
ADD_HH_RND0 |
834 |
EPILOG |
EPILOG |
835 |
|
|
836 |
.Loop1 |
.Loop1: |
837 |
ADD_HH_RND1 |
ADD_HH_RND1 |
838 |
add ecx, edx |
add ecx, edx |
839 |
ADD_HH_RND1 |
ADD_HH_RND1 |
843 |
ADD_HH_RND1 |
ADD_HH_RND1 |
844 |
|
|
845 |
EPILOG |
EPILOG |
846 |
|
ENDFUNC |
847 |
|
|
848 |
|
|
849 |
|
%ifidn __OUTPUT_FORMAT__,elf |
850 |
|
section ".note.GNU-stack" noalloc noexec nowrite progbits |
851 |
|
%endif |
852 |
|
|