28 |
%macro cglobal 1 |
%macro cglobal 1 |
29 |
%ifdef PREFIX |
%ifdef PREFIX |
30 |
%ifdef MARK_FUNCS |
%ifdef MARK_FUNCS |
31 |
global _%1:function |
global _%1:function %1.endfunc-%1 |
32 |
%define %1 _%1:function |
%define %1 _%1:function %1.endfunc-%1 |
33 |
|
%define ENDFUNC .endfunc |
34 |
%else |
%else |
35 |
global _%1 |
global _%1 |
36 |
%define %1 _%1 |
%define %1 _%1 |
37 |
|
%define ENDFUNC |
38 |
%endif |
%endif |
39 |
%else |
%else |
40 |
%ifdef MARK_FUNCS |
%ifdef MARK_FUNCS |
41 |
global %1:function |
global %1:function %1.endfunc-%1 |
42 |
|
%define ENDFUNC .endfunc |
43 |
%else |
%else |
44 |
global %1 |
global %1 |
45 |
|
%define ENDFUNC |
46 |
%endif |
%endif |
47 |
%endif |
%endif |
48 |
%endmacro |
%endmacro |
71 |
cglobal interpolate8x8_halfpel_v_3dn |
cglobal interpolate8x8_halfpel_v_3dn |
72 |
cglobal interpolate8x8_halfpel_hv_3dn |
cglobal interpolate8x8_halfpel_hv_3dn |
73 |
|
|
74 |
|
cglobal interpolate8x4_halfpel_h_3dn |
75 |
|
cglobal interpolate8x4_halfpel_v_3dn |
76 |
|
cglobal interpolate8x4_halfpel_hv_3dn |
77 |
|
|
78 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
79 |
; |
; |
80 |
; void interpolate8x8_halfpel_h_3dn(uint8_t * const dst, |
; void interpolate8x8_halfpel_h_3dn(uint8_t * const dst, |
134 |
COPY_H_3DN_RND0 |
COPY_H_3DN_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_3DN_RND1 |
COPY_H_3DN_RND1 |
145 |
lea ecx, [ecx+2*edx] |
lea ecx, [ecx+2*edx] |
146 |
COPY_H_3DN_RND1 |
COPY_H_3DN_RND1 |
147 |
ret |
ret |
148 |
|
ENDFUNC |
149 |
|
|
150 |
|
|
151 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
208 |
COPY_V_3DN_RND0 |
COPY_V_3DN_RND0 |
209 |
ret |
ret |
210 |
|
|
211 |
.rounding1 |
.rounding1: |
212 |
; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1 |
; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1 |
213 |
movq mm7, [mmx_one] |
movq mm7, [mmx_one] |
214 |
movq mm2, [eax] ; loop invariant |
movq mm2, [eax] ; loop invariant |
222 |
lea ecx, [ecx+2*edx] |
lea ecx, [ecx+2*edx] |
223 |
COPY_V_3DN_RND1 |
COPY_V_3DN_RND1 |
224 |
ret |
ret |
225 |
|
ENDFUNC |
226 |
|
|
227 |
|
|
228 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
326 |
%endmacro |
%endmacro |
327 |
|
|
328 |
ALIGN 16 |
ALIGN 16 |
329 |
interpolate8x8_halfpel_hv_3dn |
interpolate8x8_halfpel_hv_3dn: |
330 |
mov eax, [esp+16] ; rounding |
mov eax, [esp+16] ; rounding |
331 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
332 |
test eax, eax |
test eax, eax |
353 |
COPY_HV_3DN_RND0 |
COPY_HV_3DN_RND0 |
354 |
ret |
ret |
355 |
|
|
356 |
.rounding1 |
.rounding1: |
357 |
|
COPY_HV_3DN_RND1 |
358 |
|
add ecx, edx |
359 |
|
COPY_HV_3DN_RND1 |
360 |
|
add ecx, edx |
361 |
COPY_HV_3DN_RND1 |
COPY_HV_3DN_RND1 |
362 |
add ecx, edx |
add ecx, edx |
363 |
COPY_HV_3DN_RND1 |
COPY_HV_3DN_RND1 |
364 |
|
ret |
365 |
|
ENDFUNC |
366 |
|
|
367 |
|
;----------------------------------------------------------------------------- |
368 |
|
; |
369 |
|
; void interpolate8x4_halfpel_h_3dn(uint8_t * const dst, |
370 |
|
; const uint8_t * const src, |
371 |
|
; const uint32_t stride, |
372 |
|
; const uint32_t rounding); |
373 |
|
; |
374 |
|
;----------------------------------------------------------------------------- |
375 |
|
|
376 |
|
ALIGN 16 |
377 |
|
interpolate8x4_halfpel_h_3dn: |
378 |
|
|
379 |
|
mov eax, [esp+16] ; rounding |
380 |
|
mov ecx, [esp+ 4] ; Dst |
381 |
|
test eax, eax |
382 |
|
mov eax, [esp+ 8] ; Src |
383 |
|
mov edx, [esp+12] ; stride |
384 |
|
|
385 |
|
jnz near .rounding1 |
386 |
|
|
387 |
|
COPY_H_3DN_RND0 |
388 |
|
lea ecx, [ecx+2*edx] |
389 |
|
COPY_H_3DN_RND0 |
390 |
|
ret |
391 |
|
|
392 |
|
.rounding1: |
393 |
|
; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1 |
394 |
|
movq mm7, [mmx_one] |
395 |
|
COPY_H_3DN_RND1 |
396 |
|
lea ecx, [ecx+2*edx] |
397 |
|
COPY_H_3DN_RND1 |
398 |
|
ret |
399 |
|
ENDFUNC |
400 |
|
|
401 |
|
|
402 |
|
;----------------------------------------------------------------------------- |
403 |
|
; |
404 |
|
; void interpolate8x4_halfpel_v_3dn(uint8_t * const dst, |
405 |
|
; const uint8_t * const src, |
406 |
|
; const uint32_t stride, |
407 |
|
; const uint32_t rounding); |
408 |
|
; |
409 |
|
;----------------------------------------------------------------------------- |
410 |
|
|
411 |
|
ALIGN 16 |
412 |
|
interpolate8x4_halfpel_v_3dn: |
413 |
|
|
414 |
|
mov eax, [esp+16] ; rounding |
415 |
|
mov ecx, [esp+ 4] ; Dst |
416 |
|
test eax,eax |
417 |
|
mov eax, [esp+ 8] ; Src |
418 |
|
mov edx, [esp+12] ; stride |
419 |
|
|
420 |
|
; we process 2 line at a time |
421 |
|
|
422 |
|
jnz near .rounding1 |
423 |
|
|
424 |
|
COPY_V_3DN_RND0 |
425 |
|
lea ecx, [ecx+2*edx] |
426 |
|
COPY_V_3DN_RND0 |
427 |
|
ret |
428 |
|
|
429 |
|
.rounding1: |
430 |
|
; we use: (i+j)/2 = ( i+j+1 )/2 - (i^j)&1 |
431 |
|
movq mm7, [mmx_one] |
432 |
|
movq mm2, [eax] ; loop invariant |
433 |
|
add eax, edx |
434 |
|
|
435 |
|
COPY_V_3DN_RND1 |
436 |
|
lea ecx, [ecx+2*edx] |
437 |
|
COPY_V_3DN_RND1 |
438 |
|
ret |
439 |
|
ENDFUNC |
440 |
|
|
441 |
|
|
442 |
|
;----------------------------------------------------------------------------- |
443 |
|
; |
444 |
|
; void interpolate8x4_halfpel_hv_3dn(uint8_t * const dst, |
445 |
|
; const uint8_t * const src, |
446 |
|
; const uint32_t stride, |
447 |
|
; const uint32_t rounding); |
448 |
|
; |
449 |
|
; |
450 |
|
;----------------------------------------------------------------------------- |
451 |
|
|
452 |
|
; The trick is to correct the result of 'pavgusb' with some combination of the |
453 |
|
; lsb's of the 4 input values i,j,k,l, and their intermediate 'pavgusb' (s and t). |
454 |
|
; The boolean relations are: |
455 |
|
; (i+j+k+l+3)/4 = (s+t+1)/2 - (ij&kl)&st |
456 |
|
; (i+j+k+l+2)/4 = (s+t+1)/2 - (ij|kl)&st |
457 |
|
; (i+j+k+l+1)/4 = (s+t+1)/2 - (ij&kl)|st |
458 |
|
; (i+j+k+l+0)/4 = (s+t+1)/2 - (ij|kl)|st |
459 |
|
; with s=(i+j+1)/2, t=(k+l+1)/2, ij = i^j, kl = k^l, st = s^t. |
460 |
|
|
461 |
|
ALIGN 16 |
462 |
|
interpolate8x4_halfpel_hv_3dn: |
463 |
|
mov eax, [esp+16] ; rounding |
464 |
|
mov ecx, [esp+ 4] ; Dst |
465 |
|
test eax, eax |
466 |
|
mov eax, [esp+ 8] ; Src |
467 |
|
mov edx, [esp+12] ; stride |
468 |
|
|
469 |
|
movq mm7, [mmx_one] |
470 |
|
|
471 |
|
; loop invariants: mm2=(i+j+1)/2 and mm3= i^j |
472 |
|
movq mm2, [eax] |
473 |
|
movq mm3, [eax+1] |
474 |
|
movq mm6, mm2 |
475 |
|
pavgusb mm2, mm3 |
476 |
|
pxor mm3, mm6 ; mm2/mm3 ready |
477 |
|
|
478 |
|
jnz near .rounding1 |
479 |
|
|
480 |
|
COPY_HV_3DN_RND0 |
481 |
add ecx, edx |
add ecx, edx |
482 |
|
COPY_HV_3DN_RND0 |
483 |
|
ret |
484 |
|
|
485 |
|
.rounding1: |
486 |
COPY_HV_3DN_RND1 |
COPY_HV_3DN_RND1 |
487 |
add ecx, edx |
add ecx, edx |
488 |
COPY_HV_3DN_RND1 |
COPY_HV_3DN_RND1 |
489 |
ret |
ret |
490 |
|
ENDFUNC |
491 |
|
|
492 |
|
|
493 |
|
%ifidn __OUTPUT_FORMAT__,elf |
494 |
|
section ".note.GNU-stack" noalloc noexec nowrite progbits |
495 |
|
%endif |
496 |
|
|