1 |
;/************************************************************************** |
;/***************************************************************************** |
2 |
; * |
; * |
3 |
; * XVID MPEG-4 VIDEO CODEC |
; * XVID MPEG-4 VIDEO CODEC |
4 |
; * mmx 8x8 block-based halfpel interpolation |
; * - mmx 8x8 block-based halfpel interpolation - |
5 |
|
; * |
6 |
|
; * Copyright(C) 2001 Peter Ross <pross@xvid.org> |
7 |
|
; * 2002 Michael Militzer <isibaar@xvid.org> |
8 |
; * |
; * |
9 |
; * This program is free software; you can redistribute it and/or modify |
; * This program is free software; you can redistribute it and/or modify |
10 |
; * 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 |
18 |
; * |
; * |
19 |
; * You should have received a copy of the GNU General Public License |
; * You should have received a copy of the GNU General Public License |
20 |
; * along with this program; if not, write to the Free Software |
; * along with this program; if not, write to the Free Software |
21 |
; * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
; * |
|
|
; *************************************************************************/ |
|
|
|
|
|
;/************************************************************************** |
|
|
; * |
|
|
; * History: |
|
22 |
; * |
; * |
23 |
; * 05.10.2002 added some qpel mmx code - Isibaar |
; ****************************************************************************/ |
|
; * 06.07.2002 mmx cleanup - Isibaar |
|
|
; * 22.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
|
|
; * |
|
|
; *************************************************************************/ |
|
|
|
|
24 |
|
|
25 |
bits 32 |
BITS 32 |
26 |
|
|
27 |
%macro cglobal 1 |
%macro cglobal 1 |
28 |
%ifdef PREFIX |
%ifdef PREFIX |
29 |
|
%ifdef MARK_FUNCS |
30 |
|
global _%1:function |
31 |
|
%define %1 _%1:function |
32 |
|
%else |
33 |
global _%1 |
global _%1 |
34 |
%define %1 _%1 |
%define %1 _%1 |
35 |
|
%endif |
36 |
|
%else |
37 |
|
%ifdef MARK_FUNCS |
38 |
|
global %1:function |
39 |
%else |
%else |
40 |
global %1 |
global %1 |
41 |
%endif |
%endif |
42 |
|
%endif |
43 |
%endmacro |
%endmacro |
44 |
|
|
45 |
section .data |
;============================================================================= |
46 |
|
; Read only data |
47 |
|
;============================================================================= |
48 |
|
|
49 |
align 16 |
%ifdef FORMAT_COFF |
50 |
|
SECTION .rodata |
51 |
|
%else |
52 |
|
SECTION .rodata align=16 |
53 |
|
%endif |
54 |
|
|
55 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
56 |
; (16 - r) rounding table |
; (16 - r) rounding table |
57 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
58 |
|
|
59 |
rounding_lowpass_mmx |
ALIGN 16 |
60 |
|
rounding_lowpass_mmx: |
61 |
times 4 dw 16 |
times 4 dw 16 |
62 |
times 4 dw 15 |
times 4 dw 15 |
63 |
|
|
64 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
65 |
; (1 - r) rounding table |
; (1 - r) rounding table |
66 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
67 |
|
|
68 |
rounding1_mmx |
rounding1_mmx: |
69 |
times 4 dw 1 |
times 4 dw 1 |
70 |
times 4 dw 0 |
times 4 dw 0 |
71 |
|
|
72 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
73 |
; (2 - r) rounding table |
; (2 - r) rounding table |
74 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
75 |
|
|
76 |
rounding2_mmx |
rounding2_mmx: |
77 |
times 4 dw 2 |
times 4 dw 2 |
78 |
times 4 dw 1 |
times 4 dw 1 |
79 |
|
|
80 |
mmx_one |
mmx_one: |
81 |
times 8 db 1 |
times 8 db 1 |
82 |
|
|
83 |
mmx_two |
mmx_two: |
84 |
times 8 db 2 |
times 8 db 2 |
85 |
|
|
86 |
mmx_three |
mmx_three: |
87 |
times 8 db 3 |
times 8 db 3 |
88 |
|
|
89 |
mmx_five |
mmx_five: |
90 |
times 4 dw 5 |
times 4 dw 5 |
91 |
|
|
92 |
mmx_mask |
mmx_mask: |
93 |
times 8 db 254 |
times 8 db 254 |
94 |
|
|
95 |
mmx_mask2 |
mmx_mask2: |
96 |
times 8 db 252 |
times 8 db 252 |
97 |
|
|
98 |
section .text |
;============================================================================= |
99 |
|
; Code |
100 |
|
;============================================================================= |
101 |
|
|
102 |
|
SECTION .text |
103 |
|
|
104 |
|
cglobal interpolate8x8_halfpel_h_mmx |
105 |
|
cglobal interpolate8x8_halfpel_v_mmx |
106 |
|
cglobal interpolate8x8_halfpel_hv_mmx |
107 |
|
|
108 |
|
cglobal interpolate8x8_avg4_mmx |
109 |
|
cglobal interpolate8x8_avg2_mmx |
110 |
|
|
111 |
|
cglobal interpolate8x8_6tap_lowpass_h_mmx |
112 |
|
cglobal interpolate8x8_6tap_lowpass_v_mmx |
113 |
|
|
114 |
|
cglobal interpolate8x8_halfpel_add_mmx |
115 |
|
cglobal interpolate8x8_halfpel_h_add_mmx |
116 |
|
cglobal interpolate8x8_halfpel_v_add_mmx |
117 |
|
cglobal interpolate8x8_halfpel_hv_add_mmx |
118 |
|
|
119 |
%macro CALC_AVG 6 |
%macro CALC_AVG 6 |
120 |
punpcklbw %3, %6 |
punpcklbw %3, %6 |
127 |
|
|
128 |
psrlw %1, 1 ; mm01 >>= 1 |
psrlw %1, 1 ; mm01 >>= 1 |
129 |
psrlw %2, 1 |
psrlw %2, 1 |
|
|
|
130 |
%endmacro |
%endmacro |
131 |
|
|
132 |
|
|
133 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
134 |
; |
; |
135 |
; void interpolate8x8_halfpel_h_mmx(uint8_t * const dst, |
; void interpolate8x8_halfpel_h_mmx(uint8_t * const dst, |
136 |
; const uint8_t * const src, |
; const uint8_t * const src, |
137 |
; const uint32_t stride, |
; const uint32_t stride, |
138 |
; const uint32_t rounding); |
; const uint32_t rounding); |
139 |
; |
; |
140 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
141 |
|
|
142 |
%macro COPY_H_MMX 0 |
%macro COPY_H_MMX 0 |
143 |
movq mm0, [esi] |
movq mm0, [esi] |
157 |
add edi, edx ; dst += stride |
add edi, edx ; dst += stride |
158 |
%endmacro |
%endmacro |
159 |
|
|
160 |
align 16 |
ALIGN 16 |
161 |
cglobal interpolate8x8_halfpel_h_mmx |
interpolate8x8_halfpel_h_mmx: |
|
interpolate8x8_halfpel_h_mmx |
|
162 |
|
|
163 |
push esi |
push esi |
164 |
push edi |
push edi |
|
|
|
165 |
mov eax, [esp + 8 + 16] ; rounding |
mov eax, [esp + 8 + 16] ; rounding |
166 |
|
|
|
interpolate8x8_halfpel_h_mmx.start |
|
167 |
movq mm7, [rounding1_mmx + eax * 8] |
movq mm7, [rounding1_mmx + eax * 8] |
168 |
|
|
169 |
mov edi, [esp + 8 + 4] ; dst |
mov edi, [esp + 8 + 4] ; dst |
187 |
ret |
ret |
188 |
|
|
189 |
|
|
190 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
191 |
; |
; |
192 |
; void interpolate8x8_halfpel_v_mmx(uint8_t * const dst, |
; void interpolate8x8_halfpel_v_mmx(uint8_t * const dst, |
193 |
; const uint8_t * const src, |
; const uint8_t * const src, |
194 |
; const uint32_t stride, |
; const uint32_t stride, |
195 |
; const uint32_t rounding); |
; const uint32_t rounding); |
196 |
; |
; |
197 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
198 |
|
|
199 |
%macro COPY_V_MMX 0 |
%macro COPY_V_MMX 0 |
200 |
movq mm0, [esi] |
movq mm0, [esi] |
214 |
add edi, edx ; dst += stride |
add edi, edx ; dst += stride |
215 |
%endmacro |
%endmacro |
216 |
|
|
217 |
align 16 |
ALIGN 16 |
218 |
cglobal interpolate8x8_halfpel_v_mmx |
interpolate8x8_halfpel_v_mmx: |
|
interpolate8x8_halfpel_v_mmx |
|
219 |
|
|
220 |
push esi |
push esi |
221 |
push edi |
push edi |
222 |
|
|
223 |
mov eax, [esp + 8 + 16] ; rounding |
mov eax, [esp + 8 + 16] ; rounding |
224 |
|
|
|
interpolate8x8_halfpel_v_mmx.start |
|
225 |
movq mm7, [rounding1_mmx + eax * 8] |
movq mm7, [rounding1_mmx + eax * 8] |
226 |
|
|
227 |
mov edi, [esp + 8 + 4] ; dst |
mov edi, [esp + 8 + 4] ; dst |
246 |
ret |
ret |
247 |
|
|
248 |
|
|
249 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
250 |
; |
; |
251 |
; void interpolate8x8_halfpel_hv_mmx(uint8_t * const dst, |
; void interpolate8x8_halfpel_hv_mmx(uint8_t * const dst, |
252 |
; const uint8_t * const src, |
; const uint8_t * const src, |
254 |
; const uint32_t rounding); |
; const uint32_t rounding); |
255 |
; |
; |
256 |
; |
; |
257 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
258 |
|
|
259 |
%macro COPY_HV_MMX 0 |
%macro COPY_HV_MMX 0 |
260 |
; current row |
; current row |
|
|
|
261 |
movq mm0, [esi] |
movq mm0, [esi] |
262 |
movq mm2, [esi + 1] |
movq mm2, [esi + 1] |
263 |
|
|
273 |
paddusw mm1, mm3 |
paddusw mm1, mm3 |
274 |
|
|
275 |
; next row |
; next row |
|
|
|
276 |
movq mm4, [esi + edx] |
movq mm4, [esi + edx] |
277 |
movq mm2, [esi + edx + 1] |
movq mm2, [esi + edx + 1] |
278 |
|
|
288 |
paddusw mm5, mm3 |
paddusw mm5, mm3 |
289 |
|
|
290 |
; add current + next row |
; add current + next row |
|
|
|
291 |
paddusw mm0, mm4 ; mm01 += mm45 |
paddusw mm0, mm4 ; mm01 += mm45 |
292 |
paddusw mm1, mm5 |
paddusw mm1, mm5 |
293 |
paddusw mm0, mm7 ; mm01 += rounding2 |
paddusw mm0, mm7 ; mm01 += rounding2 |
303 |
add edi, edx ; dst += stride |
add edi, edx ; dst += stride |
304 |
%endmacro |
%endmacro |
305 |
|
|
306 |
align 16 |
ALIGN 16 |
307 |
cglobal interpolate8x8_halfpel_hv_mmx |
interpolate8x8_halfpel_hv_mmx: |
|
interpolate8x8_halfpel_hv_mmx |
|
308 |
|
|
309 |
push esi |
push esi |
310 |
push edi |
push edi |
311 |
|
|
312 |
mov eax, [esp + 8 + 16] ; rounding |
mov eax, [esp + 8 + 16] ; rounding |
|
interpolate8x8_halfpel_hv_mmx.start |
|
313 |
|
|
314 |
movq mm7, [rounding2_mmx + eax * 8] |
movq mm7, [rounding2_mmx + eax * 8] |
315 |
|
|
336 |
|
|
337 |
ret |
ret |
338 |
|
|
339 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
340 |
; |
; |
341 |
; void interpolate8x8_avg2_mmx(uint8_t const *dst, |
; void interpolate8x8_avg2_mmx(uint8_t const *dst, |
342 |
; const uint8_t * const src1, |
; const uint8_t * const src1, |
345 |
; const uint32_t rounding, |
; const uint32_t rounding, |
346 |
; const uint32_t height); |
; const uint32_t height); |
347 |
; |
; |
348 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
349 |
|
|
350 |
%macro AVG2_MMX_RND0 0 |
%macro AVG2_MMX_RND0 0 |
351 |
movq mm0, [eax] ; src1 -> mm0 |
movq mm0, [eax] ; src1 -> mm0 |
441 |
movq [ecx+edx], mm4 |
movq [ecx+edx], mm4 |
442 |
%endmacro |
%endmacro |
443 |
|
|
444 |
align 16 |
ALIGN 16 |
445 |
cglobal interpolate8x8_avg2_mmx |
interpolate8x8_avg2_mmx: |
|
interpolate8x8_avg2_mmx |
|
446 |
|
|
447 |
push ebx |
push ebx |
448 |
|
|
511 |
ret |
ret |
512 |
|
|
513 |
|
|
514 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
515 |
; |
; |
516 |
; void interpolate8x8_avg4_mmx(uint8_t const *dst, |
; void interpolate8x8_avg4_mmx(uint8_t const *dst, |
517 |
; const uint8_t * const src1, |
; const uint8_t * const src1, |
521 |
; const uint32_t stride, |
; const uint32_t stride, |
522 |
; const uint32_t rounding); |
; const uint32_t rounding); |
523 |
; |
; |
524 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
525 |
|
|
526 |
%macro AVG4_MMX_RND0 0 |
%macro AVG4_MMX_RND0 0 |
527 |
movq mm0, [eax] ; src1 -> mm0 |
movq mm0, [eax] ; src1 -> mm0 |
633 |
movq [ecx], mm0 ; (src1 + src2 + src3 + src4 + 2) / 4 -> dst |
movq [ecx], mm0 ; (src1 + src2 + src3 + src4 + 2) / 4 -> dst |
634 |
%endmacro |
%endmacro |
635 |
|
|
636 |
align 16 |
ALIGN 16 |
637 |
cglobal interpolate8x8_avg4_mmx |
interpolate8x8_avg4_mmx: |
|
interpolate8x8_avg4_mmx |
|
638 |
|
|
639 |
push ebx |
push ebx |
640 |
push edi |
push edi |
699 |
ret |
ret |
700 |
|
|
701 |
|
|
702 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
703 |
; |
; |
704 |
; void interpolate8x8_6tap_lowpass_h_mmx(uint8_t const *dst, |
; void interpolate8x8_6tap_lowpass_h_mmx(uint8_t const *dst, |
705 |
; const uint8_t * const src, |
; const uint8_t * const src, |
706 |
; const uint32_t stride, |
; const uint32_t stride, |
707 |
; const uint32_t rounding); |
; const uint32_t rounding); |
708 |
; |
; |
709 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
710 |
|
|
711 |
%macro LOWPASS_6TAP_H_MMX 0 |
%macro LOWPASS_6TAP_H_MMX 0 |
712 |
movq mm0, [eax] |
movq mm0, [eax] |
777 |
movq [ecx], mm0 |
movq [ecx], mm0 |
778 |
%endmacro |
%endmacro |
779 |
|
|
780 |
align 16 |
ALIGN 16 |
781 |
cglobal interpolate8x8_6tap_lowpass_h_mmx |
interpolate8x8_6tap_lowpass_h_mmx: |
|
interpolate8x8_6tap_lowpass_h_mmx |
|
782 |
|
|
783 |
mov eax, [esp + 16] ; rounding |
mov eax, [esp + 16] ; rounding |
784 |
|
|
808 |
|
|
809 |
ret |
ret |
810 |
|
|
811 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
812 |
; |
; |
813 |
; void interpolate8x8_6tap_lowpass_v_mmx(uint8_t const *dst, |
; void interpolate8x8_6tap_lowpass_v_mmx(uint8_t const *dst, |
814 |
; const uint8_t * const src, |
; const uint8_t * const src, |
815 |
; const uint32_t stride, |
; const uint32_t stride, |
816 |
; const uint32_t rounding); |
; const uint32_t rounding); |
817 |
; |
; |
818 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
819 |
|
|
820 |
%macro LOWPASS_6TAP_V_MMX 0 |
%macro LOWPASS_6TAP_V_MMX 0 |
821 |
movq mm0, [eax] |
movq mm0, [eax] |
887 |
movq [ecx], mm0 |
movq [ecx], mm0 |
888 |
%endmacro |
%endmacro |
889 |
|
|
890 |
align 16 |
ALIGN 16 |
891 |
cglobal interpolate8x8_6tap_lowpass_v_mmx |
interpolate8x8_6tap_lowpass_v_mmx: |
|
interpolate8x8_6tap_lowpass_v_mmx |
|
892 |
|
|
893 |
push ebx |
push ebx |
894 |
|
|
924 |
|
|
925 |
pop ebx |
pop ebx |
926 |
ret |
ret |
927 |
|
|
928 |
|
;=========================================================================== |
929 |
|
; |
930 |
|
; The next functions combine both source halfpel interpolation step and the |
931 |
|
; averaging (with rouding) step to avoid wasting memory bandwidth computing |
932 |
|
; intermediate halfpel images and then averaging them. |
933 |
|
; |
934 |
|
;=========================================================================== |
935 |
|
|
936 |
|
%macro PROLOG0 0 |
937 |
|
mov ecx, [esp+ 4] ; Dst |
938 |
|
mov eax, [esp+ 8] ; Src |
939 |
|
mov edx, [esp+12] ; BpS |
940 |
|
%endmacro |
941 |
|
|
942 |
|
%macro PROLOG 2 ; %1: Rounder, %2 load Dst-Rounder |
943 |
|
pxor mm6, mm6 |
944 |
|
movq mm7, [%1] ; TODO: dangerous! (eax isn't checked) |
945 |
|
%if %2 |
946 |
|
movq mm5, [rounding1_mmx] |
947 |
|
%endif |
948 |
|
|
949 |
|
PROLOG0 |
950 |
|
%endmacro |
951 |
|
|
952 |
|
; performs: mm0 == (mm0+mm2) mm1 == (mm1+mm3) |
953 |
|
%macro MIX 0 |
954 |
|
punpcklbw mm0, mm6 |
955 |
|
punpcklbw mm2, mm6 |
956 |
|
punpckhbw mm1, mm6 |
957 |
|
punpckhbw mm3, mm6 |
958 |
|
paddusw mm0, mm2 |
959 |
|
paddusw mm1, mm3 |
960 |
|
%endmacro |
961 |
|
|
962 |
|
%macro MIX_DST 0 |
963 |
|
movq mm3, mm2 |
964 |
|
paddusw mm0, mm7 ; rounder |
965 |
|
paddusw mm1, mm7 ; rounder |
966 |
|
punpcklbw mm2, mm6 |
967 |
|
punpckhbw mm3, mm6 |
968 |
|
psrlw mm0, 1 |
969 |
|
psrlw mm1, 1 |
970 |
|
|
971 |
|
paddusw mm0, mm2 ; mix Src(mm0/mm1) with Dst(mm2/mm3) |
972 |
|
paddusw mm1, mm3 |
973 |
|
paddusw mm0, mm5 |
974 |
|
paddusw mm1, mm5 |
975 |
|
psrlw mm0, 1 |
976 |
|
psrlw mm1, 1 |
977 |
|
|
978 |
|
packuswb mm0, mm1 |
979 |
|
%endmacro |
980 |
|
|
981 |
|
%macro MIX2 0 |
982 |
|
punpcklbw mm0, mm6 |
983 |
|
punpcklbw mm2, mm6 |
984 |
|
paddusw mm0, mm2 |
985 |
|
paddusw mm0, mm7 |
986 |
|
punpckhbw mm1, mm6 |
987 |
|
punpckhbw mm3, mm6 |
988 |
|
paddusw mm1, mm7 |
989 |
|
paddusw mm1, mm3 |
990 |
|
psrlw mm0, 1 |
991 |
|
psrlw mm1, 1 |
992 |
|
|
993 |
|
packuswb mm0, mm1 |
994 |
|
%endmacro |
995 |
|
|
996 |
|
;=========================================================================== |
997 |
|
; |
998 |
|
; void interpolate8x8_halfpel_add_mmx(uint8_t * const dst, |
999 |
|
; const uint8_t * const src, |
1000 |
|
; const uint32_t stride, |
1001 |
|
; const uint32_t rounding); |
1002 |
|
; |
1003 |
|
; |
1004 |
|
;=========================================================================== |
1005 |
|
|
1006 |
|
%macro ADD_FF_MMX 1 |
1007 |
|
movq mm0, [eax] |
1008 |
|
movq mm2, [ecx] |
1009 |
|
movq mm1, mm0 |
1010 |
|
movq mm3, mm2 |
1011 |
|
%if (%1!=0) |
1012 |
|
lea eax,[eax+%1*edx] |
1013 |
|
%endif |
1014 |
|
MIX |
1015 |
|
paddusw mm0, mm5 ; rounder |
1016 |
|
paddusw mm1, mm5 ; rounder |
1017 |
|
psrlw mm0, 1 |
1018 |
|
psrlw mm1, 1 |
1019 |
|
|
1020 |
|
packuswb mm0, mm1 |
1021 |
|
movq [ecx], mm0 |
1022 |
|
%if (%1!=0) |
1023 |
|
lea ecx,[ecx+%1*edx] |
1024 |
|
%endif |
1025 |
|
%endmacro |
1026 |
|
|
1027 |
|
ALIGN 16 |
1028 |
|
interpolate8x8_halfpel_add_mmx: |
1029 |
|
PROLOG rounding1_mmx, 1 |
1030 |
|
ADD_FF_MMX 1 |
1031 |
|
ADD_FF_MMX 1 |
1032 |
|
ADD_FF_MMX 1 |
1033 |
|
ADD_FF_MMX 1 |
1034 |
|
ADD_FF_MMX 1 |
1035 |
|
ADD_FF_MMX 1 |
1036 |
|
ADD_FF_MMX 1 |
1037 |
|
ADD_FF_MMX 0 |
1038 |
|
ret |
1039 |
|
|
1040 |
|
;=========================================================================== |
1041 |
|
; |
1042 |
|
; void interpolate8x8_halfpel_h_add_mmx(uint8_t * const dst, |
1043 |
|
; const uint8_t * const src, |
1044 |
|
; const uint32_t stride, |
1045 |
|
; const uint32_t rounding); |
1046 |
|
; |
1047 |
|
; |
1048 |
|
;=========================================================================== |
1049 |
|
|
1050 |
|
%macro ADD_FH_MMX 0 |
1051 |
|
movq mm0, [eax] |
1052 |
|
movq mm2, [eax+1] |
1053 |
|
movq mm1, mm0 |
1054 |
|
movq mm3, mm2 |
1055 |
|
|
1056 |
|
lea eax,[eax+edx] |
1057 |
|
|
1058 |
|
MIX |
1059 |
|
movq mm2, [ecx] ; prepare mix with Dst[0] |
1060 |
|
MIX_DST |
1061 |
|
movq [ecx], mm0 |
1062 |
|
%endmacro |
1063 |
|
|
1064 |
|
ALIGN 16 |
1065 |
|
interpolate8x8_halfpel_h_add_mmx: |
1066 |
|
PROLOG rounding1_mmx, 1 |
1067 |
|
|
1068 |
|
ADD_FH_MMX |
1069 |
|
lea ecx,[ecx+edx] |
1070 |
|
ADD_FH_MMX |
1071 |
|
lea ecx,[ecx+edx] |
1072 |
|
ADD_FH_MMX |
1073 |
|
lea ecx,[ecx+edx] |
1074 |
|
ADD_FH_MMX |
1075 |
|
lea ecx,[ecx+edx] |
1076 |
|
ADD_FH_MMX |
1077 |
|
lea ecx,[ecx+edx] |
1078 |
|
ADD_FH_MMX |
1079 |
|
lea ecx,[ecx+edx] |
1080 |
|
ADD_FH_MMX |
1081 |
|
lea ecx,[ecx+edx] |
1082 |
|
ADD_FH_MMX |
1083 |
|
ret |
1084 |
|
|
1085 |
|
;=========================================================================== |
1086 |
|
; |
1087 |
|
; void interpolate8x8_halfpel_v_add_mmx(uint8_t * const dst, |
1088 |
|
; const uint8_t * const src, |
1089 |
|
; const uint32_t stride, |
1090 |
|
; const uint32_t rounding); |
1091 |
|
; |
1092 |
|
; |
1093 |
|
;=========================================================================== |
1094 |
|
|
1095 |
|
%macro ADD_HF_MMX 0 |
1096 |
|
movq mm0, [eax] |
1097 |
|
movq mm2, [eax+edx] |
1098 |
|
movq mm1, mm0 |
1099 |
|
movq mm3, mm2 |
1100 |
|
|
1101 |
|
lea eax,[eax+edx] |
1102 |
|
|
1103 |
|
MIX |
1104 |
|
movq mm2, [ecx] ; prepare mix with Dst[0] |
1105 |
|
MIX_DST |
1106 |
|
movq [ecx], mm0 |
1107 |
|
|
1108 |
|
%endmacro |
1109 |
|
|
1110 |
|
ALIGN 16 |
1111 |
|
interpolate8x8_halfpel_v_add_mmx: |
1112 |
|
PROLOG rounding1_mmx, 1 |
1113 |
|
|
1114 |
|
ADD_HF_MMX |
1115 |
|
lea ecx,[ecx+edx] |
1116 |
|
ADD_HF_MMX |
1117 |
|
lea ecx,[ecx+edx] |
1118 |
|
ADD_HF_MMX |
1119 |
|
lea ecx,[ecx+edx] |
1120 |
|
ADD_HF_MMX |
1121 |
|
lea ecx,[ecx+edx] |
1122 |
|
ADD_HF_MMX |
1123 |
|
lea ecx,[ecx+edx] |
1124 |
|
ADD_HF_MMX |
1125 |
|
lea ecx,[ecx+edx] |
1126 |
|
ADD_HF_MMX |
1127 |
|
lea ecx,[ecx+edx] |
1128 |
|
ADD_HF_MMX |
1129 |
|
ret |
1130 |
|
|
1131 |
|
; The trick is to correct the result of 'pavgb' with some combination of the |
1132 |
|
; lsb's of the 4 input values i,j,k,l, and their intermediate 'pavgb' (s and t). |
1133 |
|
; The boolean relations are: |
1134 |
|
; (i+j+k+l+3)/4 = (s+t+1)/2 - (ij&kl)&st |
1135 |
|
; (i+j+k+l+2)/4 = (s+t+1)/2 - (ij|kl)&st |
1136 |
|
; (i+j+k+l+1)/4 = (s+t+1)/2 - (ij&kl)|st |
1137 |
|
; (i+j+k+l+0)/4 = (s+t+1)/2 - (ij|kl)|st |
1138 |
|
; with s=(i+j+1)/2, t=(k+l+1)/2, ij = i^j, kl = k^l, st = s^t. |
1139 |
|
|
1140 |
|
; Moreover, we process 2 lines at a times, for better overlapping (~15% faster). |
1141 |
|
|
1142 |
|
;=========================================================================== |
1143 |
|
; |
1144 |
|
; void interpolate8x8_halfpel_hv_add_mmx(uint8_t * const dst, |
1145 |
|
; const uint8_t * const src, |
1146 |
|
; const uint32_t stride, |
1147 |
|
; const uint32_t rounding); |
1148 |
|
; |
1149 |
|
; |
1150 |
|
;=========================================================================== |
1151 |
|
|
1152 |
|
%macro ADD_HH_MMX 0 |
1153 |
|
lea eax,[eax+edx] |
1154 |
|
|
1155 |
|
; transfert prev line to mm0/mm1 |
1156 |
|
movq mm0, mm2 |
1157 |
|
movq mm1, mm3 |
1158 |
|
|
1159 |
|
; load new line in mm2/mm3 |
1160 |
|
movq mm2, [eax] |
1161 |
|
movq mm4, [eax+1] |
1162 |
|
movq mm3, mm2 |
1163 |
|
movq mm5, mm4 |
1164 |
|
|
1165 |
|
punpcklbw mm2, mm6 |
1166 |
|
punpcklbw mm4, mm6 |
1167 |
|
paddusw mm2, mm4 |
1168 |
|
punpckhbw mm3, mm6 |
1169 |
|
punpckhbw mm5, mm6 |
1170 |
|
paddusw mm3, mm5 |
1171 |
|
|
1172 |
|
; mix current line (mm2/mm3) with previous (mm0,mm1); |
1173 |
|
; we'll preserve mm2/mm3 for next line... |
1174 |
|
|
1175 |
|
paddusw mm0, mm2 |
1176 |
|
paddusw mm1, mm3 |
1177 |
|
|
1178 |
|
movq mm4, [ecx] ; prepare mix with Dst[0] |
1179 |
|
movq mm5, mm4 |
1180 |
|
|
1181 |
|
paddusw mm0, mm7 ; finish mixing current line |
1182 |
|
paddusw mm1, mm7 |
1183 |
|
|
1184 |
|
punpcklbw mm4, mm6 |
1185 |
|
punpckhbw mm5, mm6 |
1186 |
|
|
1187 |
|
psrlw mm0, 2 |
1188 |
|
psrlw mm1, 2 |
1189 |
|
|
1190 |
|
paddusw mm0, mm4 ; mix Src(mm0/mm1) with Dst(mm2/mm3) |
1191 |
|
paddusw mm1, mm5 |
1192 |
|
|
1193 |
|
paddusw mm0, [rounding1_mmx] |
1194 |
|
paddusw mm1, [rounding1_mmx] |
1195 |
|
|
1196 |
|
psrlw mm0, 1 |
1197 |
|
psrlw mm1, 1 |
1198 |
|
|
1199 |
|
packuswb mm0, mm1 |
1200 |
|
|
1201 |
|
movq [ecx], mm0 |
1202 |
|
%endmacro |
1203 |
|
|
1204 |
|
ALIGN 16 |
1205 |
|
interpolate8x8_halfpel_hv_add_mmx: |
1206 |
|
PROLOG rounding2_mmx, 0 ; mm5 is busy. Don't load dst-rounder |
1207 |
|
|
1208 |
|
; preprocess first line |
1209 |
|
movq mm0, [eax] |
1210 |
|
movq mm2, [eax+1] |
1211 |
|
movq mm1, mm0 |
1212 |
|
movq mm3, mm2 |
1213 |
|
|
1214 |
|
punpcklbw mm0, mm6 |
1215 |
|
punpcklbw mm2, mm6 |
1216 |
|
punpckhbw mm1, mm6 |
1217 |
|
punpckhbw mm3, mm6 |
1218 |
|
paddusw mm2, mm0 |
1219 |
|
paddusw mm3, mm1 |
1220 |
|
|
1221 |
|
; Input: mm2/mm3 contains the value (Src[0]+Src[1]) of previous line |
1222 |
|
|
1223 |
|
ADD_HH_MMX |
1224 |
|
lea ecx,[ecx+edx] |
1225 |
|
ADD_HH_MMX |
1226 |
|
lea ecx,[ecx+edx] |
1227 |
|
ADD_HH_MMX |
1228 |
|
lea ecx,[ecx+edx] |
1229 |
|
ADD_HH_MMX |
1230 |
|
lea ecx,[ecx+edx] |
1231 |
|
ADD_HH_MMX |
1232 |
|
lea ecx,[ecx+edx] |
1233 |
|
ADD_HH_MMX |
1234 |
|
lea ecx,[ecx+edx] |
1235 |
|
ADD_HH_MMX |
1236 |
|
lea ecx,[ecx+edx] |
1237 |
|
ADD_HH_MMX |
1238 |
|
|
1239 |
|
ret |
1240 |
|
|