1 |
;/************************************************************************** |
;/**************************************************************************** |
2 |
; * |
; * |
3 |
; * XVID MPEG-4 VIDEO CODEC |
; * XVID MPEG-4 VIDEO CODEC |
4 |
; * mmx sum of absolute difference |
; * - K7 optimized SAD operators - |
5 |
; * |
; * |
6 |
; * This program is free software; you can redistribute it and/or modify |
; * Copyright(C) 2001 Peter Ross <pross@xvid.org> |
7 |
; * it under the terms of the GNU General Public License as published by |
; * 2002 Pascal Massimino <skal@planet-d.net> |
8 |
|
; * |
9 |
|
; * This program is free software; you can redistribute it and/or modify it |
10 |
|
; * under the terms of the GNU General Public License as published by |
11 |
; * the Free Software Foundation; either version 2 of the License, or |
; * the Free Software Foundation; either version 2 of the License, or |
12 |
; * (at your option) any later version. |
; * (at your option) any later version. |
13 |
; * |
; * |
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 |
; * 23.07.2002 sad[16,8]bi_xmm; <pross@xvid.org> |
; * $Id: sad_mmx.asm,v 1.16 2004-08-29 10:02:38 edgomez Exp $ |
|
; * 04.06.2002 cleanup -Skal- |
|
|
; * 12.11.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
|
24 |
; * |
; * |
25 |
; *************************************************************************/ |
; ***************************************************************************/ |
26 |
|
|
27 |
bits 32 |
BITS 32 |
28 |
|
|
29 |
%macro cglobal 1 |
%macro cglobal 1 |
30 |
%ifdef PREFIX |
%ifdef PREFIX |
31 |
|
%ifdef MARK_FUNCS |
32 |
|
global _%1:function %1.endfunc-%1 |
33 |
|
%define %1 _%1:function %1.endfunc-%1 |
34 |
|
%else |
35 |
global _%1 |
global _%1 |
36 |
%define %1 _%1 |
%define %1 _%1 |
37 |
|
%endif |
38 |
|
%else |
39 |
|
%ifdef MARK_FUNCS |
40 |
|
global %1:function %1.endfunc-%1 |
41 |
%else |
%else |
42 |
global %1 |
global %1 |
43 |
%endif |
%endif |
44 |
|
%endif |
45 |
%endmacro |
%endmacro |
46 |
|
|
47 |
section .data |
;============================================================================= |
48 |
|
; Read only data |
49 |
align 16 |
;============================================================================= |
|
mmx_one times 4 dw 1 |
|
50 |
|
|
51 |
section .text |
%ifdef FORMAT_COFF |
52 |
|
SECTION .rodata |
53 |
cglobal sad16_mmx |
%else |
54 |
cglobal sad16v_mmx |
SECTION .rodata align=16 |
55 |
cglobal sad8_mmx |
%endif |
|
cglobal sad16bi_mmx |
|
|
cglobal sad8bi_mmx |
|
|
cglobal dev16_mmx |
|
56 |
|
|
57 |
;=========================================================================== |
ALIGN 16 |
58 |
; |
mmx_one: |
59 |
; uint32_t sad16_mmx(const uint8_t * const cur, |
times 4 dw 1 |
60 |
; const uint8_t * const ref, |
|
61 |
; const uint32_t stride, |
;============================================================================= |
62 |
; const uint32_t best_sad); |
; Helper macros |
63 |
; |
;============================================================================= |
|
; (early termination ignore; slows this down) |
|
|
; |
|
|
;=========================================================================== |
|
64 |
|
|
65 |
%macro SAD_16x16_MMX 0 |
%macro SAD_16x16_MMX 0 |
66 |
movq mm0, [eax] |
movq mm0, [eax] |
95 |
paddusw mm6,mm2 |
paddusw mm6,mm2 |
96 |
%endmacro |
%endmacro |
97 |
|
|
98 |
align 16 |
%macro SAD_8x8_MMX 0 |
99 |
|
movq mm0, [eax] |
100 |
|
movq mm1, [edx] |
101 |
|
|
102 |
|
movq mm2, [eax+ecx] |
103 |
|
movq mm3, [edx+ecx] |
104 |
|
|
105 |
|
lea eax,[eax+2*ecx] |
106 |
|
lea edx,[edx+2*ecx] |
107 |
|
|
108 |
|
movq mm4, mm0 |
109 |
|
psubusb mm0, mm1 |
110 |
|
movq mm5, mm2 |
111 |
|
psubusb mm2, mm3 |
112 |
|
|
113 |
|
psubusb mm1, mm4 |
114 |
|
por mm0, mm1 |
115 |
|
psubusb mm3, mm5 |
116 |
|
por mm2, mm3 |
117 |
|
|
118 |
|
movq mm1,mm0 |
119 |
|
movq mm3,mm2 |
120 |
|
|
121 |
|
punpcklbw mm0,mm7 |
122 |
|
punpckhbw mm1,mm7 |
123 |
|
punpcklbw mm2,mm7 |
124 |
|
punpckhbw mm3,mm7 |
125 |
|
|
126 |
|
paddusw mm0,mm1 |
127 |
|
paddusw mm6,mm0 |
128 |
|
paddusw mm2,mm3 |
129 |
|
paddusw mm6,mm2 |
130 |
|
%endmacro |
131 |
|
|
132 |
|
%macro SADV_16x16_MMX 0 |
133 |
|
movq mm0, [eax] |
134 |
|
movq mm1, [edx] |
135 |
|
|
136 |
|
movq mm2, [eax+8] |
137 |
|
movq mm3, [edx+8] |
138 |
|
|
139 |
|
movq mm4, mm0 |
140 |
|
psubusb mm0, mm1 |
141 |
|
|
142 |
|
psubusb mm1, mm4 |
143 |
|
por mm0, mm1 |
144 |
|
lea eax,[eax+ecx] |
145 |
|
|
146 |
|
movq mm4, mm2 |
147 |
|
psubusb mm2, mm3 |
148 |
|
|
149 |
|
psubusb mm3, mm4 |
150 |
|
por mm2, mm3 |
151 |
|
lea edx,[edx+ecx] |
152 |
|
|
153 |
|
movq mm1,mm0 |
154 |
|
movq mm3,mm2 |
155 |
|
|
156 |
|
punpcklbw mm0,mm7 |
157 |
|
punpckhbw mm1,mm7 |
158 |
|
punpcklbw mm2,mm7 |
159 |
|
punpckhbw mm3,mm7 |
160 |
|
|
161 |
|
paddusw mm0,mm1 |
162 |
|
paddusw mm2,mm3 |
163 |
|
|
164 |
|
paddusw mm5, mm0 |
165 |
|
paddusw mm6, mm2 |
166 |
|
%endmacro |
167 |
|
|
168 |
|
%macro SADBI_16x16_MMX 2 ; SADBI_16x16_MMX( int_ptr_offset, bool_increment_ptr ); |
169 |
|
|
170 |
|
movq mm0, [edx+%1] |
171 |
|
movq mm2, [ebx+%1] |
172 |
|
movq mm1, mm0 |
173 |
|
movq mm3, mm2 |
174 |
|
|
175 |
|
%if %2 != 0 |
176 |
|
add edx, ecx |
177 |
|
%endif |
178 |
|
|
179 |
|
punpcklbw mm0, mm7 |
180 |
|
punpckhbw mm1, mm7 |
181 |
|
punpcklbw mm2, mm7 |
182 |
|
punpckhbw mm3, mm7 |
183 |
|
|
184 |
|
%if %2 != 0 |
185 |
|
add ebx, ecx |
186 |
|
%endif |
187 |
|
|
188 |
|
paddusw mm0, mm2 ; mm01 = ref1 + ref2 |
189 |
|
paddusw mm1, mm3 |
190 |
|
paddusw mm0, [mmx_one] ; mm01 += 1 |
191 |
|
paddusw mm1, [mmx_one] |
192 |
|
psrlw mm0, 1 ; mm01 >>= 1 |
193 |
|
psrlw mm1, 1 |
194 |
|
|
195 |
|
movq mm2, [eax+%1] |
196 |
|
movq mm3, mm2 |
197 |
|
punpcklbw mm2, mm7 ; mm23 = src |
198 |
|
punpckhbw mm3, mm7 |
199 |
|
|
200 |
|
%if %2 != 0 |
201 |
|
add eax, ecx |
202 |
|
%endif |
203 |
|
|
204 |
|
movq mm4, mm0 |
205 |
|
movq mm5, mm1 |
206 |
|
psubusw mm0, mm2 |
207 |
|
psubusw mm1, mm3 |
208 |
|
psubusw mm2, mm4 |
209 |
|
psubusw mm3, mm5 |
210 |
|
por mm0, mm2 ; mm01 = ABS(mm01 - mm23) |
211 |
|
por mm1, mm3 |
212 |
|
|
213 |
|
paddusw mm6, mm0 ; mm6 += mm01 |
214 |
|
paddusw mm6, mm1 |
215 |
|
|
216 |
|
%endmacro |
217 |
|
|
218 |
|
%macro MEAN_16x16_MMX 0 |
219 |
|
movq mm0, [eax] |
220 |
|
movq mm2, [eax+8] |
221 |
|
lea eax, [eax+ecx] |
222 |
|
movq mm1, mm0 |
223 |
|
movq mm3, mm2 |
224 |
|
punpcklbw mm0, mm7 |
225 |
|
punpcklbw mm2, mm7 |
226 |
|
punpckhbw mm1, mm7 |
227 |
|
punpckhbw mm3, mm7 |
228 |
|
paddw mm5, mm0 |
229 |
|
paddw mm6, mm1 |
230 |
|
paddw mm5, mm2 |
231 |
|
paddw mm6, mm3 |
232 |
|
%endmacro |
233 |
|
|
234 |
|
%macro ABS_16x16_MMX 0 |
235 |
|
movq mm0, [eax] |
236 |
|
movq mm2, [eax+8] |
237 |
|
lea eax, [eax+ecx] |
238 |
|
movq mm1, mm0 |
239 |
|
movq mm3, mm2 |
240 |
|
punpcklbw mm0, mm7 |
241 |
|
punpcklbw mm2, mm7 |
242 |
|
punpckhbw mm1, mm7 |
243 |
|
punpckhbw mm3, mm7 |
244 |
|
movq mm4, mm6 |
245 |
|
psubusw mm4, mm0 |
246 |
|
|
247 |
|
psubusw mm0, mm6 |
248 |
|
por mm0, mm4 |
249 |
|
movq mm4, mm6 |
250 |
|
psubusw mm4, mm1 |
251 |
|
psubusw mm1, mm6 |
252 |
|
por mm1, mm4 |
253 |
|
|
254 |
|
movq mm4, mm6 |
255 |
|
psubusw mm4, mm2 |
256 |
|
psubusw mm2, mm6 |
257 |
|
por mm2, mm4 |
258 |
|
movq mm4, mm6 |
259 |
|
psubusw mm4, mm3 |
260 |
|
psubusw mm3, mm6 |
261 |
|
por mm3, mm4 |
262 |
|
|
263 |
|
paddw mm0, mm1 |
264 |
|
paddw mm2, mm3 |
265 |
|
paddw mm5, mm0 |
266 |
|
paddw mm5, mm2 |
267 |
|
%endmacro |
268 |
|
|
269 |
|
;============================================================================= |
270 |
|
; Code |
271 |
|
;============================================================================= |
272 |
|
|
273 |
|
SECTION .text |
274 |
|
|
275 |
|
cglobal sad16_mmx |
276 |
|
cglobal sad16v_mmx |
277 |
|
cglobal sad8_mmx |
278 |
|
cglobal sad16bi_mmx |
279 |
|
cglobal sad8bi_mmx |
280 |
|
cglobal dev16_mmx |
281 |
|
cglobal sse8_16bit_mmx |
282 |
|
cglobal sse8_8bit_mmx |
283 |
|
|
284 |
|
;----------------------------------------------------------------------------- |
285 |
|
; |
286 |
|
; uint32_t sad16_mmx(const uint8_t * const cur, |
287 |
|
; const uint8_t * const ref, |
288 |
|
; const uint32_t stride, |
289 |
|
; const uint32_t best_sad); |
290 |
|
; |
291 |
|
; (early termination ignore; slows this down) |
292 |
|
; |
293 |
|
;----------------------------------------------------------------------------- |
294 |
|
|
295 |
|
ALIGN 16 |
296 |
sad16_mmx: |
sad16_mmx: |
297 |
|
|
298 |
mov eax, [esp+ 4] ; Src1 |
mov eax, [esp+ 4] ; Src1 |
328 |
movd eax, mm6 |
movd eax, mm6 |
329 |
|
|
330 |
ret |
ret |
331 |
|
.endfunc |
332 |
|
|
333 |
|
;----------------------------------------------------------------------------- |
|
;=========================================================================== |
|
334 |
; |
; |
335 |
; uint32_t sad8_mmx(const uint8_t * const cur, |
; uint32_t sad8_mmx(const uint8_t * const cur, |
336 |
; const uint8_t * const ref, |
; const uint8_t * const ref, |
337 |
; const uint32_t stride); |
; const uint32_t stride); |
338 |
; |
; |
339 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
|
|
|
%macro SAD_8x8_MMX 0 |
|
|
movq mm0, [eax] |
|
|
movq mm1, [edx] |
|
340 |
|
|
341 |
movq mm2, [eax+ecx] |
ALIGN 16 |
|
movq mm3, [edx+ecx] |
|
|
|
|
|
lea eax,[eax+2*ecx] |
|
|
lea edx,[edx+2*ecx] |
|
|
|
|
|
movq mm4, mm0 |
|
|
psubusb mm0, mm1 |
|
|
movq mm5, mm2 |
|
|
psubusb mm2, mm3 |
|
|
|
|
|
psubusb mm1, mm4 |
|
|
por mm0, mm1 |
|
|
psubusb mm3, mm5 |
|
|
por mm2, mm3 |
|
|
|
|
|
movq mm1,mm0 |
|
|
movq mm3,mm2 |
|
|
|
|
|
punpcklbw mm0,mm7 |
|
|
punpckhbw mm1,mm7 |
|
|
punpcklbw mm2,mm7 |
|
|
punpckhbw mm3,mm7 |
|
|
|
|
|
paddusw mm0,mm1 |
|
|
paddusw mm6,mm0 |
|
|
paddusw mm2,mm3 |
|
|
paddusw mm6,mm2 |
|
|
%endmacro |
|
|
|
|
|
align 16 |
|
342 |
sad8_mmx: |
sad8_mmx: |
343 |
|
|
344 |
mov eax, [esp+ 4] ; Src1 |
mov eax, [esp+ 4] ; Src1 |
361 |
movd eax, mm6 |
movd eax, mm6 |
362 |
|
|
363 |
ret |
ret |
364 |
|
.endfunc |
365 |
|
|
366 |
|
;----------------------------------------------------------------------------- |
|
;=========================================================================== |
|
367 |
; |
; |
368 |
; uint32_t sad16v_mmx(const uint8_t * const cur, |
; uint32_t sad16v_mmx(const uint8_t * const cur, |
369 |
; const uint8_t * const ref, |
; const uint8_t * const ref, |
370 |
; const uint32_t stride, |
; const uint32_t stride, |
371 |
; int32_t *sad); |
; int32_t *sad); |
372 |
; |
; |
373 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
|
|
|
%macro SADV_16x16_MMX 0 |
|
|
movq mm0, [eax] |
|
|
movq mm1, [edx] |
|
|
|
|
|
movq mm2, [eax+8] |
|
|
movq mm3, [edx+8] |
|
|
|
|
|
movq mm4, mm0 |
|
|
psubusb mm0, mm1 |
|
|
|
|
|
psubusb mm1, mm4 |
|
|
por mm0, mm1 |
|
|
lea eax,[eax+ecx] |
|
|
|
|
|
movq mm4, mm2 |
|
|
psubusb mm2, mm3 |
|
|
|
|
|
psubusb mm3, mm4 |
|
|
por mm2, mm3 |
|
|
lea edx,[edx+ecx] |
|
|
|
|
|
movq mm1,mm0 |
|
|
movq mm3,mm2 |
|
374 |
|
|
375 |
punpcklbw mm0,mm7 |
ALIGN 16 |
|
punpckhbw mm1,mm7 |
|
|
punpcklbw mm2,mm7 |
|
|
punpckhbw mm3,mm7 |
|
|
|
|
|
paddusw mm0,mm1 |
|
|
paddusw mm2,mm3 |
|
|
|
|
|
paddusw mm5, mm0 |
|
|
paddusw mm6, mm2 |
|
|
%endmacro |
|
|
|
|
|
align 16 |
|
376 |
sad16v_mmx: |
sad16v_mmx: |
377 |
|
|
378 |
push ebx |
push ebx |
450 |
|
|
451 |
pop edi |
pop edi |
452 |
pop ebx |
pop ebx |
|
ret |
|
|
|
|
453 |
|
|
454 |
|
ret |
455 |
|
.endfunc |
456 |
|
|
457 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
458 |
; |
; |
459 |
; uint32_t sad16bi_mmx(const uint8_t * const cur, |
; uint32_t sad16bi_mmx(const uint8_t * const cur, |
460 |
; const uint8_t * const ref1, |
; const uint8_t * const ref1, |
461 |
; const uint8_t * const ref2, |
; const uint8_t * const ref2, |
462 |
; const uint32_t stride); |
; const uint32_t stride); |
463 |
; |
; |
464 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
%macro SADBI_16x16_MMX 2 ; SADBI_16x16_MMX( int_ptr_offset, bool_increment_ptr ); |
|
|
|
|
|
movq mm0, [edx+%1] |
|
|
movq mm2, [ebx+%1] |
|
|
movq mm1, mm0 |
|
|
movq mm3, mm2 |
|
|
|
|
|
%if %2 != 0 |
|
|
add edx, ecx |
|
|
%endif |
|
|
|
|
|
punpcklbw mm0, mm7 |
|
|
punpckhbw mm1, mm7 |
|
|
punpcklbw mm2, mm7 |
|
|
punpckhbw mm3, mm7 |
|
|
|
|
|
%if %2 != 0 |
|
|
add ebx, ecx |
|
|
%endif |
|
|
|
|
|
paddusw mm0, mm2 ; mm01 = ref1 + ref2 |
|
|
paddusw mm1, mm3 |
|
|
paddusw mm0, [mmx_one] ; mm01 += 1 |
|
|
paddusw mm1, [mmx_one] |
|
|
psrlw mm0, 1 ; mm01 >>= 1 |
|
|
psrlw mm1, 1 |
|
|
|
|
|
movq mm2, [eax+%1] |
|
|
movq mm3, mm2 |
|
|
punpcklbw mm2, mm7 ; mm23 = src |
|
|
punpckhbw mm3, mm7 |
|
|
|
|
|
%if %2 != 0 |
|
|
add eax, ecx |
|
|
%endif |
|
|
|
|
|
movq mm4, mm0 |
|
|
movq mm5, mm1 |
|
|
psubusw mm0, mm2 |
|
|
psubusw mm1, mm3 |
|
|
psubusw mm2, mm4 |
|
|
psubusw mm3, mm5 |
|
|
por mm0, mm2 ; mm01 = ABS(mm01 - mm23) |
|
|
por mm1, mm3 |
|
|
|
|
|
paddusw mm6,mm0 ; mm6 += mm01 |
|
|
paddusw mm6,mm1 |
|
465 |
|
|
466 |
%endmacro |
ALIGN 16 |
|
|
|
|
align 16 |
|
467 |
sad16bi_mmx: |
sad16bi_mmx: |
468 |
push ebx |
push ebx |
469 |
mov eax, [esp+4+ 4] ; Src |
mov eax, [esp+4+ 4] ; Src |
515 |
|
|
516 |
movd eax, mm6 |
movd eax, mm6 |
517 |
pop ebx |
pop ebx |
518 |
|
|
519 |
ret |
ret |
520 |
|
.endfunc |
521 |
|
|
522 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
523 |
; |
; |
524 |
; uint32_t sad8bi_mmx(const uint8_t * const cur, |
; uint32_t sad8bi_mmx(const uint8_t * const cur, |
525 |
; const uint8_t * const ref1, |
; const uint8_t * const ref1, |
526 |
; const uint8_t * const ref2, |
; const uint8_t * const ref2, |
527 |
; const uint32_t stride); |
; const uint32_t stride); |
528 |
; |
; |
529 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
530 |
align 16 |
|
531 |
|
ALIGN 16 |
532 |
sad8bi_mmx: |
sad8bi_mmx: |
533 |
push ebx |
push ebx |
534 |
mov eax, [esp+4+ 4] ; Src |
mov eax, [esp+4+ 4] ; Src |
556 |
movd eax, mm6 |
movd eax, mm6 |
557 |
pop ebx |
pop ebx |
558 |
ret |
ret |
559 |
|
.endfunc |
560 |
|
|
561 |
|
;----------------------------------------------------------------------------- |
|
|
|
|
|
|
|
;=========================================================================== |
|
562 |
; |
; |
563 |
; uint32_t dev16_mmx(const uint8_t * const cur, |
; uint32_t dev16_mmx(const uint8_t * const cur, |
564 |
; const uint32_t stride); |
; const uint32_t stride); |
565 |
; |
; |
566 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
|
|
|
%macro MEAN_16x16_MMX 0 |
|
|
movq mm0, [eax] |
|
|
movq mm2, [eax+8] |
|
|
lea eax,[eax+ecx] |
|
|
movq mm1, mm0 |
|
|
movq mm3, mm2 |
|
|
punpcklbw mm0,mm7 |
|
|
punpcklbw mm2,mm7 |
|
|
punpckhbw mm1,mm7 |
|
|
punpckhbw mm3,mm7 |
|
|
paddw mm5, mm0 |
|
|
paddw mm6, mm1 |
|
|
paddw mm5, mm2 |
|
|
paddw mm6, mm3 |
|
|
%endmacro |
|
|
|
|
|
%macro ABS_16x16_MMX 0 |
|
|
movq mm0, [eax] |
|
|
movq mm2, [eax+8] |
|
|
lea eax,[eax+ecx] |
|
|
movq mm1, mm0 |
|
|
movq mm3, mm2 |
|
|
punpcklbw mm0, mm7 |
|
|
punpcklbw mm2, mm7 |
|
|
punpckhbw mm1, mm7 |
|
|
punpckhbw mm3, mm7 |
|
|
movq mm4, mm6 |
|
|
psubusw mm4, mm0 |
|
|
|
|
|
psubusw mm0, mm6 |
|
|
por mm0, mm4 |
|
|
movq mm4, mm6 |
|
|
psubusw mm4, mm1 |
|
|
psubusw mm1, mm6 |
|
|
por mm1, mm4 |
|
|
|
|
|
movq mm4, mm6 |
|
|
psubusw mm4, mm2 |
|
|
psubusw mm2, mm6 |
|
|
por mm2, mm4 |
|
|
movq mm4, mm6 |
|
|
psubusw mm4, mm3 |
|
|
psubusw mm3, mm6 |
|
|
por mm3, mm4 |
|
|
|
|
|
paddw mm0, mm1 |
|
|
paddw mm2, mm3 |
|
|
paddw mm5, mm0 |
|
|
paddw mm5, mm2 |
|
|
%endmacro |
|
567 |
|
|
568 |
align 16 |
ALIGN 16 |
569 |
dev16_mmx: |
dev16_mmx: |
570 |
mov eax, [esp+ 4] ; Src |
mov eax, [esp+ 4] ; Src |
571 |
mov ecx, [esp+ 8] ; Stride |
mov ecx, [esp+ 8] ; Stride |
634 |
paddd mm6, mm5 |
paddd mm6, mm5 |
635 |
|
|
636 |
movd eax, mm6 |
movd eax, mm6 |
637 |
|
|
638 |
|
ret |
639 |
|
.endfunc |
640 |
|
|
641 |
|
;----------------------------------------------------------------------------- |
642 |
|
; |
643 |
|
; uint32_t sse8_16bit_mmx(const int16_t *b1, |
644 |
|
; const int16_t *b2, |
645 |
|
; const uint32_t stride); |
646 |
|
; |
647 |
|
;----------------------------------------------------------------------------- |
648 |
|
|
649 |
|
%macro ROW_SSE_16bit_MMX 2 |
650 |
|
movq mm0, [%1] |
651 |
|
movq mm1, [%1+8] |
652 |
|
psubw mm0, [%2] |
653 |
|
psubw mm1, [%2+8] |
654 |
|
pmaddwd mm0, mm0 |
655 |
|
pmaddwd mm1, mm1 |
656 |
|
paddd mm2, mm0 |
657 |
|
paddd mm2, mm1 |
658 |
|
%endmacro |
659 |
|
|
660 |
|
sse8_16bit_mmx: |
661 |
|
push esi |
662 |
|
push edi |
663 |
|
|
664 |
|
;; Load the function params |
665 |
|
mov esi, [esp+8+4] |
666 |
|
mov edi, [esp+8+8] |
667 |
|
mov edx, [esp+8+12] |
668 |
|
|
669 |
|
;; Reset the sse accumulator |
670 |
|
pxor mm2, mm2 |
671 |
|
|
672 |
|
;; Let's go |
673 |
|
%rep 8 |
674 |
|
ROW_SSE_16bit_MMX esi, edi |
675 |
|
lea esi, [esi+edx] |
676 |
|
lea edi, [edi+edx] |
677 |
|
%endrep |
678 |
|
|
679 |
|
;; Finish adding each dword of the accumulator |
680 |
|
movq mm3, mm2 |
681 |
|
psrlq mm2, 32 |
682 |
|
paddd mm2, mm3 |
683 |
|
movd eax, mm2 |
684 |
|
|
685 |
|
;; All done |
686 |
|
pop edi |
687 |
|
pop esi |
688 |
ret |
ret |
689 |
|
.endfunc |
690 |
|
|
691 |
|
;----------------------------------------------------------------------------- |
692 |
|
; |
693 |
|
; uint32_t sse8_8bit_mmx(const int8_t *b1, |
694 |
|
; const int8_t *b2, |
695 |
|
; const uint32_t stride); |
696 |
|
; |
697 |
|
;----------------------------------------------------------------------------- |
698 |
|
|
699 |
|
%macro ROW_SSE_8bit_MMX 2 |
700 |
|
movq mm0, [%1] ; load a row |
701 |
|
movq mm2, [%2] ; load a row |
702 |
|
|
703 |
|
movq mm1, mm0 ; copy row |
704 |
|
movq mm3, mm2 ; copy row |
705 |
|
|
706 |
|
punpcklbw mm0, mm7 ; turn the 4low elements into 16bit |
707 |
|
punpckhbw mm1, mm7 ; turn the 4high elements into 16bit |
708 |
|
|
709 |
|
punpcklbw mm2, mm7 ; turn the 4low elements into 16bit |
710 |
|
punpckhbw mm3, mm7 ; turn the 4high elements into 16bit |
711 |
|
|
712 |
|
psubw mm0, mm2 ; low part of src-dst |
713 |
|
psubw mm1, mm3 ; high part of src-dst |
714 |
|
|
715 |
|
pmaddwd mm0, mm0 ; compute the square sum |
716 |
|
pmaddwd mm1, mm1 ; compute the square sum |
717 |
|
|
718 |
|
paddd mm6, mm0 ; add to the accumulator |
719 |
|
paddd mm6, mm1 ; add to the accumulator |
720 |
|
%endmacro |
721 |
|
|
722 |
|
sse8_8bit_mmx: |
723 |
|
push esi |
724 |
|
push edi |
725 |
|
|
726 |
|
;; Load the function params |
727 |
|
mov esi, [esp+8+4] |
728 |
|
mov edi, [esp+8+8] |
729 |
|
mov edx, [esp+8+12] |
730 |
|
|
731 |
|
;; Reset the sse accumulator |
732 |
|
pxor mm6, mm6 |
733 |
|
|
734 |
|
;; Used to interleave 8bit data with 0x00 values |
735 |
|
pxor mm7, mm7 |
736 |
|
|
737 |
|
;; Let's go |
738 |
|
%rep 8 |
739 |
|
ROW_SSE_8bit_MMX esi, edi |
740 |
|
lea esi, [esi+edx] |
741 |
|
lea edi, [edi+edx] |
742 |
|
%endrep |
743 |
|
|
744 |
|
;; Finish adding each dword of the accumulator |
745 |
|
movq mm7, mm6 |
746 |
|
psrlq mm6, 32 |
747 |
|
paddd mm6, mm7 |
748 |
|
movd eax, mm6 |
749 |
|
|
750 |
|
;; All done |
751 |
|
pop edi |
752 |
|
pop esi |
753 |
|
ret |
754 |
|
.endfunc |
755 |
|
|