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 |
; * Copyright(C) 2002 Peter Ross <pross@xvid.org> |
; * Copyright(C) 2001 Peter Ross <pross@xvid.org> |
7 |
|
; * 2002 Pascal Massimino <skal@planet-d.net> |
8 |
; * |
; * |
9 |
; * This file is part of XviD, a free MPEG-4 video encoder/decoder |
; * This program is free software; you can redistribute it and/or modify it |
|
; * |
|
|
; * XviD is free software; you can redistribute it and/or modify it |
|
10 |
; * under the terms of the GNU General Public License as published by |
; * 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. |
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 |
; * |
; * |
23 |
; * Under section 8 of the GNU General Public License, the copyright |
; * $Id: sad_mmx.asm,v 1.15 2004-08-22 11:46:10 edgomez Exp $ |
|
; * holders of XVID explicitly forbid distribution in the following |
|
|
; * countries: |
|
|
; * |
|
|
; * - Japan |
|
|
; * - United States of America |
|
|
; * |
|
|
; * Linking XviD statically or dynamically with other modules is making a |
|
|
; * combined work based on XviD. Thus, the terms and conditions of the |
|
|
; * GNU General Public License cover the whole combination. |
|
|
; * |
|
|
; * As a special exception, the copyright holders of XviD give you |
|
|
; * permission to link XviD with independent modules that communicate with |
|
|
; * XviD solely through the VFW1.1 and DShow interfaces, regardless of the |
|
|
; * license terms of these independent modules, and to copy and distribute |
|
|
; * the resulting combined work under terms of your choice, provided that |
|
|
; * every copy of the combined work is accompanied by a complete copy of |
|
|
; * the source code of XviD (the version of XviD used to produce the |
|
|
; * combined work), being distributed under the terms of the GNU General |
|
|
; * Public License plus this exception. An independent module is a module |
|
|
; * which is not derived from or based on XviD. |
|
|
; * |
|
|
; * Note that people who make modified versions of XviD are not obligated |
|
|
; * to grant this special exception for their modified versions; it is |
|
|
; * their choice whether to do so. The GNU General Public License gives |
|
|
; * permission to release a modified version without this exception; this |
|
|
; * exception also makes it possible to release a modified version which |
|
|
; * carries forward this exception. |
|
|
; * |
|
|
; * $Id: sad_mmx.asm,v 1.10 2002-11-17 00:32:06 edgomez Exp $ |
|
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 |
33 |
|
%define %1 _%1:function |
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 |
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 |
|
|
|
|
|
section .text |
|
50 |
|
|
51 |
cglobal sad16_mmx |
%ifdef FORMAT_COFF |
52 |
cglobal sad8_mmx |
SECTION .rodata |
53 |
cglobal sad16bi_mmx |
%else |
54 |
cglobal sad8bi_mmx |
SECTION .rodata align=16 |
55 |
cglobal dev16_mmx |
%endif |
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 |
|
|
|
align 16 |
|
|
sad16_mmx: |
|
|
|
|
|
mov eax, [esp+ 4] ; Src1 |
|
|
mov edx, [esp+ 8] ; Src2 |
|
|
mov ecx, [esp+12] ; Stride |
|
|
|
|
|
pxor mm6, mm6 ; accum |
|
|
pxor mm7, mm7 ; zero |
|
|
|
|
|
SAD_16x16_MMX |
|
|
SAD_16x16_MMX |
|
|
SAD_16x16_MMX |
|
|
SAD_16x16_MMX |
|
|
SAD_16x16_MMX |
|
|
SAD_16x16_MMX |
|
|
SAD_16x16_MMX |
|
|
SAD_16x16_MMX |
|
|
|
|
|
SAD_16x16_MMX |
|
|
SAD_16x16_MMX |
|
|
SAD_16x16_MMX |
|
|
SAD_16x16_MMX |
|
|
SAD_16x16_MMX |
|
|
SAD_16x16_MMX |
|
|
SAD_16x16_MMX |
|
|
SAD_16x16_MMX |
|
|
|
|
|
pmaddwd mm6, [mmx_one] ; collapse |
|
|
movq mm7, mm6 |
|
|
psrlq mm7, 32 |
|
|
paddd mm6, mm7 |
|
|
|
|
|
movd eax, mm6 |
|
|
|
|
|
ret |
|
|
|
|
|
|
|
|
;=========================================================================== |
|
|
; |
|
|
; uint32_t sad8_mmx(const uint8_t * const cur, |
|
|
; const uint8_t * const ref, |
|
|
; const uint32_t stride); |
|
|
; |
|
|
;=========================================================================== |
|
|
|
|
98 |
%macro SAD_8x8_MMX 0 |
%macro SAD_8x8_MMX 0 |
99 |
movq mm0, [eax] |
movq mm0, [eax] |
100 |
movq mm1, [edx] |
movq mm1, [edx] |
129 |
paddusw mm6,mm2 |
paddusw mm6,mm2 |
130 |
%endmacro |
%endmacro |
131 |
|
|
132 |
align 16 |
%macro SADV_16x16_MMX 0 |
133 |
sad8_mmx: |
movq mm0, [eax] |
134 |
|
movq mm1, [edx] |
|
mov eax, [esp+ 4] ; Src1 |
|
|
mov edx, [esp+ 8] ; Src2 |
|
|
mov ecx, [esp+12] ; Stride |
|
135 |
|
|
136 |
pxor mm6, mm6 ; accum |
movq mm2, [eax+8] |
137 |
pxor mm7, mm7 ; zero |
movq mm3, [edx+8] |
138 |
|
|
139 |
SAD_8x8_MMX |
movq mm4, mm0 |
140 |
SAD_8x8_MMX |
psubusb mm0, mm1 |
|
SAD_8x8_MMX |
|
|
SAD_8x8_MMX |
|
141 |
|
|
142 |
pmaddwd mm6, [mmx_one] ; collapse |
psubusb mm1, mm4 |
143 |
movq mm7, mm6 |
por mm0, mm1 |
144 |
psrlq mm7, 32 |
lea eax,[eax+ecx] |
|
paddd mm6, mm7 |
|
145 |
|
|
146 |
movd eax, mm6 |
movq mm4, mm2 |
147 |
|
psubusb mm2, mm3 |
148 |
|
|
149 |
ret |
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 |
|
|
|
;=========================================================================== |
|
|
; |
|
|
; uint32_t sad16bi_mmx(const uint8_t * const cur, |
|
|
; const uint8_t * const ref1, |
|
|
; const uint8_t * const ref2, |
|
|
; const uint32_t stride); |
|
|
; |
|
|
;=========================================================================== |
|
168 |
%macro SADBI_16x16_MMX 2 ; SADBI_16x16_MMX( int_ptr_offset, bool_increment_ptr ); |
%macro SADBI_16x16_MMX 2 ; SADBI_16x16_MMX( int_ptr_offset, bool_increment_ptr ); |
169 |
|
|
170 |
movq mm0, [edx+%1] |
movq mm0, [edx+%1] |
215 |
|
|
216 |
%endmacro |
%endmacro |
217 |
|
|
218 |
align 16 |
%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: |
297 |
|
|
298 |
|
mov eax, [esp+ 4] ; Src1 |
299 |
|
mov edx, [esp+ 8] ; Src2 |
300 |
|
mov ecx, [esp+12] ; Stride |
301 |
|
|
302 |
|
pxor mm6, mm6 ; accum |
303 |
|
pxor mm7, mm7 ; zero |
304 |
|
|
305 |
|
SAD_16x16_MMX |
306 |
|
SAD_16x16_MMX |
307 |
|
SAD_16x16_MMX |
308 |
|
SAD_16x16_MMX |
309 |
|
SAD_16x16_MMX |
310 |
|
SAD_16x16_MMX |
311 |
|
SAD_16x16_MMX |
312 |
|
SAD_16x16_MMX |
313 |
|
|
314 |
|
SAD_16x16_MMX |
315 |
|
SAD_16x16_MMX |
316 |
|
SAD_16x16_MMX |
317 |
|
SAD_16x16_MMX |
318 |
|
SAD_16x16_MMX |
319 |
|
SAD_16x16_MMX |
320 |
|
SAD_16x16_MMX |
321 |
|
SAD_16x16_MMX |
322 |
|
|
323 |
|
pmaddwd mm6, [mmx_one] ; collapse |
324 |
|
movq mm7, mm6 |
325 |
|
psrlq mm7, 32 |
326 |
|
paddd mm6, mm7 |
327 |
|
|
328 |
|
movd eax, mm6 |
329 |
|
|
330 |
|
ret |
331 |
|
|
332 |
|
;----------------------------------------------------------------------------- |
333 |
|
; |
334 |
|
; uint32_t sad8_mmx(const uint8_t * const cur, |
335 |
|
; const uint8_t * const ref, |
336 |
|
; const uint32_t stride); |
337 |
|
; |
338 |
|
;----------------------------------------------------------------------------- |
339 |
|
|
340 |
|
ALIGN 16 |
341 |
|
sad8_mmx: |
342 |
|
|
343 |
|
mov eax, [esp+ 4] ; Src1 |
344 |
|
mov edx, [esp+ 8] ; Src2 |
345 |
|
mov ecx, [esp+12] ; Stride |
346 |
|
|
347 |
|
pxor mm6, mm6 ; accum |
348 |
|
pxor mm7, mm7 ; zero |
349 |
|
|
350 |
|
SAD_8x8_MMX |
351 |
|
SAD_8x8_MMX |
352 |
|
SAD_8x8_MMX |
353 |
|
SAD_8x8_MMX |
354 |
|
|
355 |
|
pmaddwd mm6, [mmx_one] ; collapse |
356 |
|
movq mm7, mm6 |
357 |
|
psrlq mm7, 32 |
358 |
|
paddd mm6, mm7 |
359 |
|
|
360 |
|
movd eax, mm6 |
361 |
|
|
362 |
|
ret |
363 |
|
|
364 |
|
;----------------------------------------------------------------------------- |
365 |
|
; |
366 |
|
; uint32_t sad16v_mmx(const uint8_t * const cur, |
367 |
|
; const uint8_t * const ref, |
368 |
|
; const uint32_t stride, |
369 |
|
; int32_t *sad); |
370 |
|
; |
371 |
|
;----------------------------------------------------------------------------- |
372 |
|
|
373 |
|
ALIGN 16 |
374 |
|
sad16v_mmx: |
375 |
|
|
376 |
|
push ebx |
377 |
|
push edi |
378 |
|
|
379 |
|
mov eax, [esp + 8 + 4] ; Src1 |
380 |
|
mov edx, [esp + 8 + 8] ; Src2 |
381 |
|
mov ecx, [esp + 8 + 12] ; Stride |
382 |
|
mov ebx, [esp + 8 + 16] ; sad ptr |
383 |
|
|
384 |
|
pxor mm5, mm5 ; accum |
385 |
|
pxor mm6, mm6 ; accum |
386 |
|
pxor mm7, mm7 ; zero |
387 |
|
|
388 |
|
SADV_16x16_MMX |
389 |
|
SADV_16x16_MMX |
390 |
|
SADV_16x16_MMX |
391 |
|
SADV_16x16_MMX |
392 |
|
SADV_16x16_MMX |
393 |
|
SADV_16x16_MMX |
394 |
|
SADV_16x16_MMX |
395 |
|
SADV_16x16_MMX |
396 |
|
|
397 |
|
pmaddwd mm5, [mmx_one] ; collapse |
398 |
|
pmaddwd mm6, [mmx_one] ; collapse |
399 |
|
|
400 |
|
movq mm2, mm5 |
401 |
|
movq mm3, mm6 |
402 |
|
|
403 |
|
psrlq mm2, 32 |
404 |
|
psrlq mm3, 32 |
405 |
|
|
406 |
|
paddd mm5, mm2 |
407 |
|
paddd mm6, mm3 |
408 |
|
|
409 |
|
movd [ebx], mm5 |
410 |
|
movd [ebx + 4], mm6 |
411 |
|
|
412 |
|
paddd mm5, mm6 |
413 |
|
|
414 |
|
movd edi, mm5 |
415 |
|
|
416 |
|
pxor mm5, mm5 |
417 |
|
pxor mm6, mm6 |
418 |
|
|
419 |
|
SADV_16x16_MMX |
420 |
|
SADV_16x16_MMX |
421 |
|
SADV_16x16_MMX |
422 |
|
SADV_16x16_MMX |
423 |
|
SADV_16x16_MMX |
424 |
|
SADV_16x16_MMX |
425 |
|
SADV_16x16_MMX |
426 |
|
SADV_16x16_MMX |
427 |
|
|
428 |
|
pmaddwd mm5, [mmx_one] ; collapse |
429 |
|
pmaddwd mm6, [mmx_one] ; collapse |
430 |
|
|
431 |
|
movq mm2, mm5 |
432 |
|
movq mm3, mm6 |
433 |
|
|
434 |
|
psrlq mm2, 32 |
435 |
|
psrlq mm3, 32 |
436 |
|
|
437 |
|
paddd mm5, mm2 |
438 |
|
paddd mm6, mm3 |
439 |
|
|
440 |
|
movd [ebx + 8], mm5 |
441 |
|
movd [ebx + 12], mm6 |
442 |
|
|
443 |
|
paddd mm5, mm6 |
444 |
|
|
445 |
|
movd eax, mm5 |
446 |
|
|
447 |
|
add eax, edi |
448 |
|
|
449 |
|
pop edi |
450 |
|
pop ebx |
451 |
|
|
452 |
|
ret |
453 |
|
|
454 |
|
;----------------------------------------------------------------------------- |
455 |
|
; |
456 |
|
; uint32_t sad16bi_mmx(const uint8_t * const cur, |
457 |
|
; const uint8_t * const ref1, |
458 |
|
; const uint8_t * const ref2, |
459 |
|
; const uint32_t stride); |
460 |
|
; |
461 |
|
;----------------------------------------------------------------------------- |
462 |
|
|
463 |
|
ALIGN 16 |
464 |
sad16bi_mmx: |
sad16bi_mmx: |
465 |
push ebx |
push ebx |
466 |
mov eax, [esp+4+ 4] ; Src |
mov eax, [esp+4+ 4] ; Src |
512 |
|
|
513 |
movd eax, mm6 |
movd eax, mm6 |
514 |
pop ebx |
pop ebx |
515 |
|
|
516 |
ret |
ret |
517 |
|
|
518 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
519 |
; |
; |
520 |
; uint32_t sad8bi_mmx(const uint8_t * const cur, |
; uint32_t sad8bi_mmx(const uint8_t * const cur, |
521 |
; const uint8_t * const ref1, |
; const uint8_t * const ref1, |
522 |
; const uint8_t * const ref2, |
; const uint8_t * const ref2, |
523 |
; const uint32_t stride); |
; const uint32_t stride); |
524 |
; |
; |
525 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
526 |
align 16 |
|
527 |
|
ALIGN 16 |
528 |
sad8bi_mmx: |
sad8bi_mmx: |
529 |
push ebx |
push ebx |
530 |
mov eax, [esp+4+ 4] ; Src |
mov eax, [esp+4+ 4] ; Src |
553 |
pop ebx |
pop ebx |
554 |
ret |
ret |
555 |
|
|
556 |
|
;----------------------------------------------------------------------------- |
|
|
|
|
|
|
|
;=========================================================================== |
|
557 |
; |
; |
558 |
; uint32_t dev16_mmx(const uint8_t * const cur, |
; uint32_t dev16_mmx(const uint8_t * const cur, |
559 |
; const uint32_t stride); |
; const uint32_t stride); |
560 |
; |
; |
561 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
|
|
|
%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 |
|
562 |
|
|
563 |
align 16 |
ALIGN 16 |
564 |
dev16_mmx: |
dev16_mmx: |
565 |
mov eax, [esp+ 4] ; Src |
mov eax, [esp+ 4] ; Src |
566 |
mov ecx, [esp+ 8] ; Stride |
mov ecx, [esp+ 8] ; Stride |
629 |
paddd mm6, mm5 |
paddd mm6, mm5 |
630 |
|
|
631 |
movd eax, mm6 |
movd eax, mm6 |
632 |
|
|
633 |
|
ret |
634 |
|
|
635 |
|
;----------------------------------------------------------------------------- |
636 |
|
; |
637 |
|
; uint32_t sse8_16bit_mmx(const int16_t *b1, |
638 |
|
; const int16_t *b2, |
639 |
|
; const uint32_t stride); |
640 |
|
; |
641 |
|
;----------------------------------------------------------------------------- |
642 |
|
|
643 |
|
%macro ROW_SSE_16bit_MMX 2 |
644 |
|
movq mm0, [%1] |
645 |
|
movq mm1, [%1+8] |
646 |
|
psubw mm0, [%2] |
647 |
|
psubw mm1, [%2+8] |
648 |
|
pmaddwd mm0, mm0 |
649 |
|
pmaddwd mm1, mm1 |
650 |
|
paddd mm2, mm0 |
651 |
|
paddd mm2, mm1 |
652 |
|
%endmacro |
653 |
|
|
654 |
|
sse8_16bit_mmx: |
655 |
|
push esi |
656 |
|
push edi |
657 |
|
|
658 |
|
;; Load the function params |
659 |
|
mov esi, [esp+8+4] |
660 |
|
mov edi, [esp+8+8] |
661 |
|
mov edx, [esp+8+12] |
662 |
|
|
663 |
|
;; Reset the sse accumulator |
664 |
|
pxor mm2, mm2 |
665 |
|
|
666 |
|
;; Let's go |
667 |
|
%rep 8 |
668 |
|
ROW_SSE_16bit_MMX esi, edi |
669 |
|
lea esi, [esi+edx] |
670 |
|
lea edi, [edi+edx] |
671 |
|
%endrep |
672 |
|
|
673 |
|
;; Finish adding each dword of the accumulator |
674 |
|
movq mm3, mm2 |
675 |
|
psrlq mm2, 32 |
676 |
|
paddd mm2, mm3 |
677 |
|
movd eax, mm2 |
678 |
|
|
679 |
|
;; All done |
680 |
|
pop edi |
681 |
|
pop esi |
682 |
ret |
ret |
683 |
|
|
684 |
|
;----------------------------------------------------------------------------- |
685 |
|
; |
686 |
|
; uint32_t sse8_8bit_mmx(const int8_t *b1, |
687 |
|
; const int8_t *b2, |
688 |
|
; const uint32_t stride); |
689 |
|
; |
690 |
|
;----------------------------------------------------------------------------- |
691 |
|
|
692 |
|
%macro ROW_SSE_8bit_MMX 2 |
693 |
|
movq mm0, [%1] ; load a row |
694 |
|
movq mm2, [%2] ; load a row |
695 |
|
|
696 |
|
movq mm1, mm0 ; copy row |
697 |
|
movq mm3, mm2 ; copy row |
698 |
|
|
699 |
|
punpcklbw mm0, mm7 ; turn the 4low elements into 16bit |
700 |
|
punpckhbw mm1, mm7 ; turn the 4high elements into 16bit |
701 |
|
|
702 |
|
punpcklbw mm2, mm7 ; turn the 4low elements into 16bit |
703 |
|
punpckhbw mm3, mm7 ; turn the 4high elements into 16bit |
704 |
|
|
705 |
|
psubw mm0, mm2 ; low part of src-dst |
706 |
|
psubw mm1, mm3 ; high part of src-dst |
707 |
|
|
708 |
|
pmaddwd mm0, mm0 ; compute the square sum |
709 |
|
pmaddwd mm1, mm1 ; compute the square sum |
710 |
|
|
711 |
|
paddd mm6, mm0 ; add to the accumulator |
712 |
|
paddd mm6, mm1 ; add to the accumulator |
713 |
|
%endmacro |
714 |
|
|
715 |
|
sse8_8bit_mmx: |
716 |
|
push esi |
717 |
|
push edi |
718 |
|
|
719 |
|
;; Load the function params |
720 |
|
mov esi, [esp+8+4] |
721 |
|
mov edi, [esp+8+8] |
722 |
|
mov edx, [esp+8+12] |
723 |
|
|
724 |
|
;; Reset the sse accumulator |
725 |
|
pxor mm6, mm6 |
726 |
|
|
727 |
|
;; Used to interleave 8bit data with 0x00 values |
728 |
|
pxor mm7, mm7 |
729 |
|
|
730 |
|
;; Let's go |
731 |
|
%rep 8 |
732 |
|
ROW_SSE_8bit_MMX esi, edi |
733 |
|
lea esi, [esi+edx] |
734 |
|
lea edi, [edi+edx] |
735 |
|
%endrep |
736 |
|
|
737 |
|
;; Finish adding each dword of the accumulator |
738 |
|
movq mm7, mm6 |
739 |
|
psrlq mm6, 32 |
740 |
|
paddd mm6, mm7 |
741 |
|
movd eax, mm6 |
742 |
|
|
743 |
|
;; All done |
744 |
|
pop edi |
745 |
|
pop esi |
746 |
|
ret |