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.19 2008-11-11 20:46:24 Isibaar 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. |
|
24 |
; * |
; * |
25 |
; * 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 $ |
|
|
; * |
|
|
; ****************************************************************************/ |
|
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 |
|
%define ENDFUNC .endfunc |
35 |
|
%else |
36 |
global _%1 |
global _%1 |
37 |
%define %1 _%1 |
%define %1 _%1 |
38 |
|
%define ENDFUNC |
39 |
|
%endif |
40 |
|
%else |
41 |
|
%ifdef MARK_FUNCS |
42 |
|
global %1:function %1.endfunc-%1 |
43 |
|
%define ENDFUNC .endfunc |
44 |
%else |
%else |
45 |
global %1 |
global %1 |
46 |
|
%define ENDFUNC |
47 |
|
%endif |
48 |
%endif |
%endif |
49 |
%endmacro |
%endmacro |
50 |
|
|
51 |
section .data |
;============================================================================= |
52 |
|
; Read only data |
53 |
|
;============================================================================= |
54 |
|
|
55 |
align 16 |
%ifdef FORMAT_COFF |
56 |
mmx_one times 4 dw 1 |
SECTION .rodata |
57 |
|
%else |
58 |
section .text |
SECTION .rodata align=16 |
59 |
|
%endif |
|
cglobal sad16_mmx |
|
|
cglobal sad8_mmx |
|
|
cglobal sad16bi_mmx |
|
|
cglobal sad8bi_mmx |
|
|
cglobal dev16_mmx |
|
60 |
|
|
61 |
;=========================================================================== |
ALIGN 16 |
62 |
; |
mmx_one: |
63 |
; uint32_t sad16_mmx(const uint8_t * const cur, |
times 4 dw 1 |
64 |
; const uint8_t * const ref, |
|
65 |
; const uint32_t stride, |
;============================================================================= |
66 |
; const uint32_t best_sad); |
; Helper macros |
67 |
; |
;============================================================================= |
|
; (early termination ignore; slows this down) |
|
|
; |
|
|
;=========================================================================== |
|
68 |
|
|
69 |
%macro SAD_16x16_MMX 0 |
%macro SAD_16x16_MMX 0 |
70 |
movq mm0, [eax] |
movq mm0, [eax] |
78 |
lea eax,[eax+ecx] |
lea eax,[eax+ecx] |
79 |
movq mm5, mm2 |
movq mm5, mm2 |
80 |
psubusb mm2, mm3 |
psubusb mm2, mm3 |
|
lea edx,[edx+ecx] |
|
81 |
|
|
82 |
psubusb mm1, mm4 |
psubusb mm1, mm4 |
|
por mm0, mm1 |
|
83 |
psubusb mm3, mm5 |
psubusb mm3, mm5 |
84 |
|
por mm0, mm1 |
85 |
por mm2, mm3 |
por mm2, mm3 |
86 |
|
|
87 |
movq mm1,mm0 |
movq mm1,mm0 |
|
movq mm3,mm2 |
|
|
|
|
88 |
punpcklbw mm0,mm7 |
punpcklbw mm0,mm7 |
89 |
|
movq mm3, mm2 |
90 |
punpckhbw mm1,mm7 |
punpckhbw mm1,mm7 |
91 |
|
lea edx, [edx+ecx] |
92 |
punpcklbw mm2,mm7 |
punpcklbw mm2,mm7 |
|
punpckhbw mm3,mm7 |
|
|
|
|
93 |
paddusw mm0,mm1 |
paddusw mm0,mm1 |
94 |
|
punpckhbw mm3,mm7 |
95 |
paddusw mm6,mm0 |
paddusw mm6,mm0 |
96 |
paddusw mm2,mm3 |
paddusw mm2,mm3 |
97 |
paddusw mm6,mm2 |
paddusw mm6,mm2 |
|
%endmacro |
|
|
|
|
|
align 16 |
|
|
sad16_mmx: |
|
98 |
|
|
99 |
mov eax, [esp+ 4] ; Src1 |
%endmacro |
|
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); |
|
|
; |
|
|
;=========================================================================== |
|
100 |
|
|
101 |
%macro SAD_8x8_MMX 0 |
%macro SAD_8x8_MMX 0 |
102 |
movq mm0, [eax] |
movq mm0, [eax] |
114 |
psubusb mm2, mm3 |
psubusb mm2, mm3 |
115 |
|
|
116 |
psubusb mm1, mm4 |
psubusb mm1, mm4 |
|
por mm0, mm1 |
|
117 |
psubusb mm3, mm5 |
psubusb mm3, mm5 |
118 |
|
por mm0, mm1 |
119 |
por mm2, mm3 |
por mm2, mm3 |
120 |
|
|
121 |
movq mm1,mm0 |
movq mm1,mm0 |
|
movq mm3,mm2 |
|
|
|
|
122 |
punpcklbw mm0,mm7 |
punpcklbw mm0,mm7 |
123 |
|
movq mm3,mm2 |
124 |
punpckhbw mm1,mm7 |
punpckhbw mm1,mm7 |
125 |
punpcklbw mm2,mm7 |
punpcklbw mm2,mm7 |
|
punpckhbw mm3,mm7 |
|
|
|
|
126 |
paddusw mm0,mm1 |
paddusw mm0,mm1 |
127 |
|
punpckhbw mm3,mm7 |
128 |
paddusw mm6,mm0 |
paddusw mm6,mm0 |
129 |
paddusw mm2,mm3 |
paddusw mm2,mm3 |
130 |
paddusw mm6,mm2 |
paddusw mm6,mm2 |
131 |
%endmacro |
%endmacro |
132 |
|
|
|
align 16 |
|
|
sad8_mmx: |
|
133 |
|
|
134 |
mov eax, [esp+ 4] ; Src1 |
%macro SADV_16x16_MMX 0 |
135 |
mov edx, [esp+ 8] ; Src2 |
movq mm0, [eax] |
136 |
mov ecx, [esp+12] ; Stride |
movq mm1, [edx] |
|
|
|
|
pxor mm6, mm6 ; accum |
|
|
pxor mm7, mm7 ; zero |
|
|
|
|
|
SAD_8x8_MMX |
|
|
SAD_8x8_MMX |
|
|
SAD_8x8_MMX |
|
|
SAD_8x8_MMX |
|
|
|
|
|
pmaddwd mm6, [mmx_one] ; collapse |
|
|
movq mm7, mm6 |
|
|
psrlq mm7, 32 |
|
|
paddd mm6, mm7 |
|
|
|
|
|
movd eax, mm6 |
|
137 |
|
|
138 |
ret |
movq mm2, [eax+8] |
139 |
|
movq mm4, mm0 |
140 |
|
movq mm3, [edx+8] |
141 |
|
psubusb mm0, mm1 |
142 |
|
|
143 |
|
psubusb mm1, mm4 |
144 |
|
lea eax,[eax+ecx] |
145 |
|
por mm0, mm1 |
146 |
|
|
147 |
|
movq mm4, mm2 |
148 |
|
psubusb mm2, mm3 |
149 |
|
|
150 |
|
psubusb mm3, mm4 |
151 |
|
por mm2, mm3 |
152 |
|
|
153 |
|
movq mm1,mm0 |
154 |
|
punpcklbw mm0,mm7 |
155 |
|
movq mm3,mm2 |
156 |
|
punpckhbw mm1,mm7 |
157 |
|
punpcklbw mm2,mm7 |
158 |
|
paddusw mm0,mm1 |
159 |
|
punpckhbw mm3,mm7 |
160 |
|
paddusw mm5, mm0 |
161 |
|
paddusw mm2,mm3 |
162 |
|
lea edx,[edx+ecx] |
163 |
|
paddusw mm6, mm2 |
164 |
|
%endmacro |
165 |
|
|
|
;=========================================================================== |
|
|
; |
|
|
; uint32_t sad16bi_mmx(const uint8_t * const cur, |
|
|
; const uint8_t * const ref1, |
|
|
; const uint8_t * const ref2, |
|
|
; const uint32_t stride); |
|
|
; |
|
|
;=========================================================================== |
|
166 |
%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 ); |
167 |
|
|
168 |
movq mm0, [edx+%1] |
movq mm0, [edx+%1] |
213 |
|
|
214 |
%endmacro |
%endmacro |
215 |
|
|
216 |
align 16 |
%macro MEAN_16x16_MMX 0 |
217 |
|
movq mm0, [eax] |
218 |
|
movq mm2, [eax+8] |
219 |
|
lea eax, [eax+ecx] |
220 |
|
movq mm1, mm0 |
221 |
|
punpcklbw mm0, mm7 |
222 |
|
movq mm3, mm2 |
223 |
|
punpckhbw mm1, mm7 |
224 |
|
paddw mm5, mm0 |
225 |
|
punpcklbw mm2, mm7 |
226 |
|
paddw mm6, mm1 |
227 |
|
punpckhbw mm3, mm7 |
228 |
|
paddw mm5, mm2 |
229 |
|
paddw mm6, mm3 |
230 |
|
%endmacro |
231 |
|
|
232 |
|
%macro ABS_16x16_MMX 0 |
233 |
|
movq mm0, [eax] |
234 |
|
movq mm2, [eax+8] |
235 |
|
lea eax, [eax+ecx] |
236 |
|
movq mm1, mm0 |
237 |
|
movq mm3, mm2 |
238 |
|
punpcklbw mm0, mm7 |
239 |
|
punpcklbw mm2, mm7 |
240 |
|
punpckhbw mm1, mm7 |
241 |
|
punpckhbw mm3, mm7 |
242 |
|
movq mm4, mm6 |
243 |
|
psubusw mm4, mm0 |
244 |
|
|
245 |
|
psubusw mm0, mm6 |
246 |
|
por mm0, mm4 |
247 |
|
movq mm4, mm6 |
248 |
|
psubusw mm4, mm1 |
249 |
|
psubusw mm1, mm6 |
250 |
|
por mm1, mm4 |
251 |
|
|
252 |
|
movq mm4, mm6 |
253 |
|
psubusw mm4, mm2 |
254 |
|
psubusw mm2, mm6 |
255 |
|
por mm2, mm4 |
256 |
|
movq mm4, mm6 |
257 |
|
psubusw mm4, mm3 |
258 |
|
psubusw mm3, mm6 |
259 |
|
por mm3, mm4 |
260 |
|
|
261 |
|
paddw mm0, mm1 |
262 |
|
paddw mm2, mm3 |
263 |
|
paddw mm5, mm0 |
264 |
|
paddw mm5, mm2 |
265 |
|
%endmacro |
266 |
|
|
267 |
|
;============================================================================= |
268 |
|
; Code |
269 |
|
;============================================================================= |
270 |
|
|
271 |
|
SECTION .text |
272 |
|
|
273 |
|
cglobal sad16_mmx |
274 |
|
cglobal sad16v_mmx |
275 |
|
cglobal sad8_mmx |
276 |
|
cglobal sad16bi_mmx |
277 |
|
cglobal sad8bi_mmx |
278 |
|
cglobal dev16_mmx |
279 |
|
cglobal sse8_16bit_mmx |
280 |
|
cglobal sse8_8bit_mmx |
281 |
|
|
282 |
|
;----------------------------------------------------------------------------- |
283 |
|
; |
284 |
|
; uint32_t sad16_mmx(const uint8_t * const cur, |
285 |
|
; const uint8_t * const ref, |
286 |
|
; const uint32_t stride, |
287 |
|
; const uint32_t best_sad); |
288 |
|
; |
289 |
|
; (early termination ignore; slows this down) |
290 |
|
; |
291 |
|
;----------------------------------------------------------------------------- |
292 |
|
|
293 |
|
ALIGN 16 |
294 |
|
sad16_mmx: |
295 |
|
|
296 |
|
mov eax, [esp+ 4] ; Src1 |
297 |
|
mov edx, [esp+ 8] ; Src2 |
298 |
|
mov ecx, [esp+12] ; Stride |
299 |
|
|
300 |
|
pxor mm6, mm6 ; accum |
301 |
|
pxor mm7, mm7 ; zero |
302 |
|
|
303 |
|
SAD_16x16_MMX |
304 |
|
SAD_16x16_MMX |
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 |
|
|
312 |
|
SAD_16x16_MMX |
313 |
|
SAD_16x16_MMX |
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 |
|
|
321 |
|
pmaddwd mm6, [mmx_one] ; collapse |
322 |
|
movq mm7, mm6 |
323 |
|
psrlq mm7, 32 |
324 |
|
paddd mm6, mm7 |
325 |
|
|
326 |
|
movd eax, mm6 |
327 |
|
|
328 |
|
ret |
329 |
|
ENDFUNC |
330 |
|
|
331 |
|
;----------------------------------------------------------------------------- |
332 |
|
; |
333 |
|
; uint32_t sad8_mmx(const uint8_t * const cur, |
334 |
|
; const uint8_t * const ref, |
335 |
|
; const uint32_t stride); |
336 |
|
; |
337 |
|
;----------------------------------------------------------------------------- |
338 |
|
|
339 |
|
ALIGN 16 |
340 |
|
sad8_mmx: |
341 |
|
|
342 |
|
mov eax, [esp+ 4] ; Src1 |
343 |
|
mov edx, [esp+ 8] ; Src2 |
344 |
|
mov ecx, [esp+12] ; Stride |
345 |
|
|
346 |
|
pxor mm6, mm6 ; accum |
347 |
|
pxor mm7, mm7 ; zero |
348 |
|
|
349 |
|
SAD_8x8_MMX |
350 |
|
SAD_8x8_MMX |
351 |
|
SAD_8x8_MMX |
352 |
|
SAD_8x8_MMX |
353 |
|
|
354 |
|
pmaddwd mm6, [mmx_one] ; collapse |
355 |
|
movq mm7, mm6 |
356 |
|
psrlq mm7, 32 |
357 |
|
paddd mm6, mm7 |
358 |
|
|
359 |
|
movd eax, mm6 |
360 |
|
|
361 |
|
ret |
362 |
|
ENDFUNC |
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 |
|
ENDFUNC |
454 |
|
|
455 |
|
;----------------------------------------------------------------------------- |
456 |
|
; |
457 |
|
; uint32_t sad16bi_mmx(const uint8_t * const cur, |
458 |
|
; const uint8_t * const ref1, |
459 |
|
; const uint8_t * const ref2, |
460 |
|
; const uint32_t stride); |
461 |
|
; |
462 |
|
;----------------------------------------------------------------------------- |
463 |
|
|
464 |
|
ALIGN 16 |
465 |
sad16bi_mmx: |
sad16bi_mmx: |
466 |
push ebx |
push ebx |
467 |
mov eax, [esp+4+ 4] ; Src |
mov eax, [esp+4+ 4] ; Src |
471 |
|
|
472 |
pxor mm6, mm6 ; accum2 |
pxor mm6, mm6 ; accum2 |
473 |
pxor mm7, mm7 |
pxor mm7, mm7 |
474 |
.Loop |
.Loop: |
475 |
SADBI_16x16_MMX 0, 0 |
SADBI_16x16_MMX 0, 0 |
476 |
SADBI_16x16_MMX 8, 1 |
SADBI_16x16_MMX 8, 1 |
477 |
SADBI_16x16_MMX 0, 0 |
SADBI_16x16_MMX 0, 0 |
513 |
|
|
514 |
movd eax, mm6 |
movd eax, mm6 |
515 |
pop ebx |
pop ebx |
516 |
|
|
517 |
ret |
ret |
518 |
|
ENDFUNC |
519 |
|
|
520 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
521 |
; |
; |
522 |
; uint32_t sad8bi_mmx(const uint8_t * const cur, |
; uint32_t sad8bi_mmx(const uint8_t * const cur, |
523 |
; const uint8_t * const ref1, |
; const uint8_t * const ref1, |
524 |
; const uint8_t * const ref2, |
; const uint8_t * const ref2, |
525 |
; const uint32_t stride); |
; const uint32_t stride); |
526 |
; |
; |
527 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
528 |
align 16 |
|
529 |
|
ALIGN 16 |
530 |
sad8bi_mmx: |
sad8bi_mmx: |
531 |
push ebx |
push ebx |
532 |
mov eax, [esp+4+ 4] ; Src |
mov eax, [esp+4+ 4] ; Src |
536 |
|
|
537 |
pxor mm6, mm6 ; accum2 |
pxor mm6, mm6 ; accum2 |
538 |
pxor mm7, mm7 |
pxor mm7, mm7 |
539 |
.Loop |
.Loop: |
540 |
SADBI_16x16_MMX 0, 1 |
SADBI_16x16_MMX 0, 1 |
541 |
SADBI_16x16_MMX 0, 1 |
SADBI_16x16_MMX 0, 1 |
542 |
SADBI_16x16_MMX 0, 1 |
SADBI_16x16_MMX 0, 1 |
554 |
movd eax, mm6 |
movd eax, mm6 |
555 |
pop ebx |
pop ebx |
556 |
ret |
ret |
557 |
|
ENDFUNC |
558 |
|
|
559 |
|
;----------------------------------------------------------------------------- |
|
|
|
|
|
|
|
;=========================================================================== |
|
560 |
; |
; |
561 |
; uint32_t dev16_mmx(const uint8_t * const cur, |
; uint32_t dev16_mmx(const uint8_t * const cur, |
562 |
; const uint32_t stride); |
; const uint32_t stride); |
563 |
; |
; |
564 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
|
|
|
%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 |
|
565 |
|
|
566 |
align 16 |
ALIGN 16 |
567 |
dev16_mmx: |
dev16_mmx: |
568 |
mov eax, [esp+ 4] ; Src |
mov eax, [esp+ 4] ; Src |
569 |
mov ecx, [esp+ 8] ; Stride |
mov ecx, [esp+ 8] ; Stride |
632 |
paddd mm6, mm5 |
paddd mm6, mm5 |
633 |
|
|
634 |
movd eax, mm6 |
movd eax, mm6 |
635 |
|
|
636 |
ret |
ret |
637 |
|
ENDFUNC |
638 |
|
|
639 |
|
;----------------------------------------------------------------------------- |
640 |
|
; |
641 |
|
; uint32_t sse8_16bit_mmx(const int16_t *b1, |
642 |
|
; const int16_t *b2, |
643 |
|
; const uint32_t stride); |
644 |
|
; |
645 |
|
;----------------------------------------------------------------------------- |
646 |
|
|
647 |
|
%macro ROW_SSE_16bit_MMX 2 |
648 |
|
movq mm0, [%1] |
649 |
|
movq mm1, [%1+8] |
650 |
|
psubw mm0, [%2] |
651 |
|
psubw mm1, [%2+8] |
652 |
|
pmaddwd mm0, mm0 |
653 |
|
pmaddwd mm1, mm1 |
654 |
|
paddd mm2, mm0 |
655 |
|
paddd mm2, mm1 |
656 |
|
%endmacro |
657 |
|
|
658 |
|
sse8_16bit_mmx: |
659 |
|
push esi |
660 |
|
push edi |
661 |
|
|
662 |
|
;; Load the function params |
663 |
|
mov esi, [esp+8+4] |
664 |
|
mov edi, [esp+8+8] |
665 |
|
mov edx, [esp+8+12] |
666 |
|
|
667 |
|
;; Reset the sse accumulator |
668 |
|
pxor mm2, mm2 |
669 |
|
|
670 |
|
;; Let's go |
671 |
|
%rep 8 |
672 |
|
ROW_SSE_16bit_MMX esi, edi |
673 |
|
lea esi, [esi+edx] |
674 |
|
lea edi, [edi+edx] |
675 |
|
%endrep |
676 |
|
|
677 |
|
;; Finish adding each dword of the accumulator |
678 |
|
movq mm3, mm2 |
679 |
|
psrlq mm2, 32 |
680 |
|
paddd mm2, mm3 |
681 |
|
movd eax, mm2 |
682 |
|
|
683 |
|
;; All done |
684 |
|
pop edi |
685 |
|
pop esi |
686 |
|
ret |
687 |
|
ENDFUNC |
688 |
|
|
689 |
|
;----------------------------------------------------------------------------- |
690 |
|
; |
691 |
|
; uint32_t sse8_8bit_mmx(const int8_t *b1, |
692 |
|
; const int8_t *b2, |
693 |
|
; const uint32_t stride); |
694 |
|
; |
695 |
|
;----------------------------------------------------------------------------- |
696 |
|
|
697 |
|
%macro ROW_SSE_8bit_MMX 2 |
698 |
|
movq mm0, [%1] ; load a row |
699 |
|
movq mm2, [%2] ; load a row |
700 |
|
|
701 |
|
movq mm1, mm0 ; copy row |
702 |
|
movq mm3, mm2 ; copy row |
703 |
|
|
704 |
|
punpcklbw mm0, mm7 ; turn the 4low elements into 16bit |
705 |
|
punpckhbw mm1, mm7 ; turn the 4high elements into 16bit |
706 |
|
|
707 |
|
punpcklbw mm2, mm7 ; turn the 4low elements into 16bit |
708 |
|
punpckhbw mm3, mm7 ; turn the 4high elements into 16bit |
709 |
|
|
710 |
|
psubw mm0, mm2 ; low part of src-dst |
711 |
|
psubw mm1, mm3 ; high part of src-dst |
712 |
|
|
713 |
|
pmaddwd mm0, mm0 ; compute the square sum |
714 |
|
pmaddwd mm1, mm1 ; compute the square sum |
715 |
|
|
716 |
|
paddd mm6, mm0 ; add to the accumulator |
717 |
|
paddd mm6, mm1 ; add to the accumulator |
718 |
|
%endmacro |
719 |
|
|
720 |
|
sse8_8bit_mmx: |
721 |
|
push esi |
722 |
|
push edi |
723 |
|
|
724 |
|
;; Load the function params |
725 |
|
mov esi, [esp+8+4] |
726 |
|
mov edi, [esp+8+8] |
727 |
|
mov edx, [esp+8+12] |
728 |
|
|
729 |
|
;; Reset the sse accumulator |
730 |
|
pxor mm6, mm6 |
731 |
|
|
732 |
|
;; Used to interleave 8bit data with 0x00 values |
733 |
|
pxor mm7, mm7 |
734 |
|
|
735 |
|
;; Let's go |
736 |
|
%rep 8 |
737 |
|
ROW_SSE_8bit_MMX esi, edi |
738 |
|
lea esi, [esi+edx] |
739 |
|
lea edi, [edi+edx] |
740 |
|
%endrep |
741 |
|
|
742 |
|
;; Finish adding each dword of the accumulator |
743 |
|
movq mm7, mm6 |
744 |
|
psrlq mm6, 32 |
745 |
|
paddd mm6, mm7 |
746 |
|
movd eax, mm6 |
747 |
|
|
748 |
|
;; All done |
749 |
|
pop edi |
750 |
|
pop esi |
751 |
|
ret |
752 |
|
ENDFUNC |
753 |
|
|
754 |
|
|
755 |
|
%ifidn __OUTPUT_FORMAT__,elf |
756 |
|
section ".note.GNU-stack" noalloc noexec nowrite progbits |
757 |
|
%endif |
758 |
|
|