6 |
; * Copyright (C) 2001 Peter Ross <pross@xvid.org> |
; * Copyright (C) 2001 Peter Ross <pross@xvid.org> |
7 |
; * 2001 Michael Militzer <isibaar@xvid.org> |
; * 2001 Michael Militzer <isibaar@xvid.org> |
8 |
; * 2002 Pascal Massimino <skal@planet-d.net> |
; * 2002 Pascal Massimino <skal@planet-d.net> |
|
; * 2004 Jean-Marc Bastide <jmtest@voila.fr> |
|
9 |
; * |
; * |
10 |
; * This program is free software ; you can redistribute it and/or modify |
; * This program is free software ; you can redistribute it and/or modify |
11 |
; * 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 |
29 |
|
|
30 |
%macro cglobal 1 |
%macro cglobal 1 |
31 |
%ifdef PREFIX |
%ifdef PREFIX |
32 |
|
%ifdef MARK_FUNCS |
33 |
|
global _%1:function |
34 |
|
%define %1 _%1:function |
35 |
|
%else |
36 |
global _%1 |
global _%1 |
37 |
%define %1 _%1 |
%define %1 _%1 |
38 |
|
%endif |
39 |
|
%else |
40 |
|
%ifdef MARK_FUNCS |
41 |
|
global %1:function |
42 |
%else |
%else |
43 |
global %1 |
global %1 |
44 |
%endif |
%endif |
45 |
|
%endif |
46 |
%endmacro |
%endmacro |
47 |
|
|
48 |
;============================================================================= |
;============================================================================= |
50 |
;============================================================================= |
;============================================================================= |
51 |
|
|
52 |
%ifdef FORMAT_COFF |
%ifdef FORMAT_COFF |
53 |
SECTION .rodata data |
SECTION .rodata |
54 |
%else |
%else |
55 |
SECTION .rodata data align=16 |
SECTION .rodata align=16 |
56 |
%endif |
%endif |
57 |
|
|
58 |
ALIGN 16 |
ALIGN 16 |
160 |
%macro COPY_8_TO_16_SUB 2 |
%macro COPY_8_TO_16_SUB 2 |
161 |
movq mm0, [eax] ; cur |
movq mm0, [eax] ; cur |
162 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
163 |
|
movq mm1, mm0 |
164 |
|
movq mm3, mm2 |
165 |
|
|
166 |
|
punpcklbw mm0, mm7 |
167 |
|
punpcklbw mm2, mm7 |
168 |
movq mm4, [ebx] ; ref |
movq mm4, [ebx] ; ref |
169 |
|
punpckhbw mm1, mm7 |
170 |
|
punpckhbw mm3, mm7 |
171 |
movq mm5, [ebx+edx] ; ref |
movq mm5, [ebx+edx] ; ref |
172 |
|
|
173 |
|
movq mm6, mm4 |
174 |
%if %2 == 1 |
%if %2 == 1 |
175 |
movq [eax], mm4 |
movq [eax], mm4 |
176 |
movq [eax+edx], mm5 |
movq [eax+edx], mm5 |
177 |
%endif |
%endif |
178 |
|
punpcklbw mm4, mm7 |
179 |
|
punpckhbw mm6, mm7 |
180 |
|
psubsw mm0, mm4 |
181 |
|
psubsw mm1, mm6 |
182 |
|
movq mm6, mm5 |
183 |
|
punpcklbw mm5, mm7 |
184 |
|
punpckhbw mm6, mm7 |
185 |
|
psubsw mm2, mm5 |
186 |
lea eax, [eax+2*edx] |
lea eax, [eax+2*edx] |
187 |
|
psubsw mm3, mm6 |
|
psubsb mm0,mm4 |
|
|
psubsb mm2,mm5 |
|
188 |
lea ebx,[ebx+2*edx] |
lea ebx,[ebx+2*edx] |
189 |
|
|
|
movq mm1,mm0 |
|
|
movq mm3,mm2 |
|
|
punpcklbw mm0,mm7 |
|
|
punpckhbw mm1,mm7 |
|
|
punpcklbw mm2,mm7 |
|
|
punpckhbw mm3,mm7 |
|
|
|
|
190 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
191 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
192 |
movq [ecx+%1*32+16], mm2 |
movq [ecx+%1*32+16], mm2 |
244 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
245 |
|
|
246 |
; mm4 <- (ref1+ref2+1) / 2 |
; mm4 <- (ref1+ref2+1) / 2 |
|
;(a+b+1)/2 = (a|b)-((a^b)>>1) |
|
247 |
movq mm4, [ebx] ; ref1 |
movq mm4, [ebx] ; ref1 |
248 |
movq mm1, [esi] ; ref2 |
movq mm1, [esi] ; ref2 |
249 |
movq mm3, mm4 |
movq mm6, mm4 |
250 |
pxor mm3,mm1 |
movq mm3, mm1 |
251 |
por mm4,mm1 |
punpcklbw mm4, mm7 |
252 |
pandn mm3,mm6 |
punpcklbw mm1, mm7 |
253 |
psrlq mm3,1 |
punpckhbw mm6, mm7 |
254 |
psubb mm4,mm3 |
punpckhbw mm3, mm7 |
255 |
|
paddusw mm4, mm1 |
256 |
|
paddusw mm6, mm3 |
257 |
|
paddusw mm4, [mmx_one] |
258 |
|
paddusw mm6, [mmx_one] |
259 |
|
psrlw mm4, 1 |
260 |
|
psrlw mm6, 1 |
261 |
|
packuswb mm4, mm6 |
262 |
movq [eax],mm4 |
movq [eax],mm4 |
263 |
|
|
264 |
; mm5 <- (ref1+ref2+1) / 2 |
; mm5 <- (ref1+ref2+1) / 2 |
265 |
movq mm5, [ebx+edx] ; ref1 |
movq mm5, [ebx+edx] ; ref1 |
266 |
movq mm1, [esi+edx] ; ref2 |
movq mm1, [esi+edx] ; ref2 |
267 |
movq mm3, mm5 |
movq mm6, mm5 |
268 |
pxor mm3,mm1 |
movq mm3, mm1 |
269 |
por mm5,mm1 |
punpcklbw mm5, mm7 |
270 |
pandn mm3,mm6 |
punpcklbw mm1, mm7 |
271 |
psrlq mm3,1 |
punpckhbw mm6, mm7 |
272 |
psubb mm5,mm3 |
punpckhbw mm3, mm7 |
273 |
|
paddusw mm5, mm1 |
274 |
|
paddusw mm6, mm3 |
275 |
|
paddusw mm5, [mmx_one] |
276 |
|
paddusw mm6, [mmx_one] |
277 |
|
lea esi, [esi+2*edx] |
278 |
|
psrlw mm5, 1 |
279 |
|
psrlw mm6, 1 |
280 |
|
packuswb mm5, mm6 |
281 |
movq [eax+edx],mm5 |
movq [eax+edx],mm5 |
282 |
|
|
|
psubsb mm0,mm4 |
|
|
psubsb mm2,mm5 |
|
|
lea esi, [esi+2*edx] |
|
283 |
movq mm1,mm0 |
movq mm1,mm0 |
284 |
movq mm3,mm2 |
movq mm3,mm2 |
|
lea eax, [eax+2*edx] |
|
285 |
punpcklbw mm0,mm7 |
punpcklbw mm0,mm7 |
286 |
punpcklbw mm2,mm7 |
punpcklbw mm2,mm7 |
|
lea ebx, [ebx+2*edx] |
|
287 |
punpckhbw mm1,mm7 |
punpckhbw mm1,mm7 |
288 |
punpckhbw mm3,mm7 |
punpckhbw mm3,mm7 |
289 |
|
|
290 |
|
movq mm6, mm4 |
291 |
|
punpcklbw mm4, mm7 |
292 |
|
punpckhbw mm6, mm7 |
293 |
|
psubsw mm0, mm4 |
294 |
|
psubsw mm1, mm6 |
295 |
|
movq mm6, mm5 |
296 |
|
punpcklbw mm5, mm7 |
297 |
|
punpckhbw mm6, mm7 |
298 |
|
psubsw mm2, mm5 |
299 |
|
lea eax, [eax+2*edx] |
300 |
|
psubsw mm3, mm6 |
301 |
|
lea ebx, [ebx+2*edx] |
302 |
|
|
303 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
304 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
305 |
movq [ecx+%1*32+16], mm2 |
movq [ecx+%1*32+16], mm2 |
315 |
push esi |
push esi |
316 |
mov esi, [esp+8+16] ; Ref2 |
mov esi, [esp+8+16] ; Ref2 |
317 |
mov edx, [esp+8+20] ; Stride |
mov edx, [esp+8+20] ; Stride |
|
pxor mm6,mm6 |
|
|
pcmpeqb mm5,mm5 |
|
318 |
pxor mm7, mm7 |
pxor mm7, mm7 |
|
psubb mm6, mm5; mm6=1 |
|
319 |
|
|
320 |
COPY_8_TO_16_SUB2_MMX 0 |
COPY_8_TO_16_SUB2_MMX 0 |
321 |
COPY_8_TO_16_SUB2_MMX 1 |
COPY_8_TO_16_SUB2_MMX 1 |
339 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
340 |
movq mm0, [eax] ; cur |
movq mm0, [eax] ; cur |
341 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
342 |
|
movq mm1, mm0 |
343 |
|
movq mm3, mm2 |
344 |
|
|
345 |
|
punpcklbw mm0, mm7 |
346 |
|
punpcklbw mm2, mm7 |
347 |
movq mm4, [ebx] ; ref1 |
movq mm4, [ebx] ; ref1 |
348 |
pavgb mm4, [esi] ; ref2 |
pavgb mm4, [esi] ; ref2 |
349 |
|
movq [eax], mm4 |
350 |
|
punpckhbw mm1, mm7 |
351 |
|
punpckhbw mm3, mm7 |
352 |
movq mm5, [ebx+edx] ; ref |
movq mm5, [ebx+edx] ; ref |
353 |
pavgb mm5, [esi+edx] ; ref2 |
pavgb mm5, [esi+edx] ; ref2 |
|
|
|
|
movq [eax], mm4 |
|
354 |
movq [eax+edx], mm5 |
movq [eax+edx], mm5 |
355 |
|
|
356 |
psubsb mm0,mm4 |
movq mm6, mm4 |
357 |
psubsb mm2,mm5 |
punpcklbw mm4, mm7 |
358 |
|
punpckhbw mm6, mm7 |
359 |
|
psubsw mm0, mm4 |
360 |
|
psubsw mm1, mm6 |
361 |
lea esi, [esi+2*edx] |
lea esi, [esi+2*edx] |
362 |
movq mm1,mm0 |
movq mm6, mm5 |
363 |
movq mm3,mm2 |
punpcklbw mm5, mm7 |
364 |
|
punpckhbw mm6, mm7 |
365 |
|
psubsw mm2, mm5 |
366 |
lea eax, [eax+2*edx] |
lea eax, [eax+2*edx] |
367 |
punpcklbw mm0,mm7 |
psubsw mm3, mm6 |
|
punpcklbw mm2,mm7 |
|
368 |
lea ebx, [ebx+2*edx] |
lea ebx, [ebx+2*edx] |
|
punpckhbw mm1,mm7 |
|
|
punpckhbw mm3,mm7 |
|
369 |
|
|
370 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
371 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
402 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
403 |
|
|
404 |
%macro COPY_16_TO_8_ADD 1 |
%macro COPY_16_TO_8_ADD 1 |
405 |
movq mm0, [eax+%1*32+ 0] ;src |
movq mm0, [ecx] |
406 |
packuswb mm0,[eax+%1*32+8] |
movq mm2, [ecx+edx] |
407 |
movq mm1, [eax+%1*32+ 16] |
movq mm1, mm0 |
408 |
packuswb mm1,[eax+%1*32+24] |
movq mm3, mm2 |
409 |
|
punpcklbw mm0, mm7 |
410 |
paddusb mm0,[ecx] |
punpcklbw mm2, mm7 |
411 |
paddusb mm1,[ecx+edx] |
punpckhbw mm1, mm7 |
412 |
|
punpckhbw mm3, mm7 |
413 |
|
paddsw mm0, [eax+%1*32+ 0] |
414 |
|
paddsw mm1, [eax+%1*32+ 8] |
415 |
|
paddsw mm2, [eax+%1*32+16] |
416 |
|
paddsw mm3, [eax+%1*32+24] |
417 |
|
packuswb mm0, mm1 |
418 |
movq [ecx],mm0 |
movq [ecx],mm0 |
419 |
movq [ecx+edx],mm1 |
packuswb mm2, mm3 |
420 |
|
movq [ecx+edx], mm2 |
421 |
%endmacro |
%endmacro |
422 |
|
|
423 |
|
|
426 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
427 |
mov eax, [esp+ 8] ; Src |
mov eax, [esp+ 8] ; Src |
428 |
mov edx, [esp+12] ; Stride |
mov edx, [esp+12] ; Stride |
429 |
; pxor mm7, mm7 |
pxor mm7, mm7 |
430 |
|
|
431 |
COPY_16_TO_8_ADD 0 |
COPY_16_TO_8_ADD 0 |
432 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
446 |
; |
; |
447 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
448 |
|
|
449 |
|
%macro COPY_8_TO_8 0 |
450 |
|
movq mm0, [eax] |
451 |
|
movq mm1, [eax+edx] |
452 |
|
movq [ecx], mm0 |
453 |
|
lea eax, [eax+2*edx] |
454 |
|
movq [ecx+edx], mm1 |
455 |
|
%endmacro |
456 |
|
|
457 |
ALIGN 16 |
ALIGN 16 |
458 |
transfer8x8_copy_mmx: |
transfer8x8_copy_mmx: |
|
|
|
|
mov eax, [esp+ 8] ; Src |
|
459 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
460 |
|
mov eax, [esp+ 8] ; Src |
461 |
mov edx, [esp+12] ; Stride |
mov edx, [esp+12] ; Stride |
462 |
|
|
463 |
movq mm0,[eax] |
COPY_8_TO_8 |
464 |
lea eax,[eax+edx] |
lea ecx,[ecx+2*edx] |
465 |
movq mm1,[eax] |
COPY_8_TO_8 |
466 |
lea eax,[eax+edx] |
lea ecx,[ecx+2*edx] |
467 |
movq mm2,[eax] |
COPY_8_TO_8 |
468 |
lea eax,[eax+edx] |
lea ecx,[ecx+2*edx] |
469 |
movq mm3,[eax] |
COPY_8_TO_8 |
|
lea eax,[eax+edx] |
|
|
movq mm4,[eax] |
|
|
lea eax,[eax+edx] |
|
|
movq mm5,[eax] |
|
|
lea eax,[eax+edx] |
|
|
movq mm6,[eax] |
|
|
lea eax,[eax+edx] |
|
|
movq mm7,[eax] |
|
|
|
|
|
movq [ecx],mm0 |
|
|
lea ecx,[ecx+edx] |
|
|
movq [ecx],mm1 |
|
|
lea ecx,[ecx+edx] |
|
|
movq [ecx],mm2 |
|
|
lea ecx,[ecx+edx] |
|
|
movq [ecx],mm3 |
|
|
lea ecx,[ecx+edx] |
|
|
movq [ecx],mm4 |
|
|
lea ecx,[ecx+edx] |
|
|
movq [ecx],mm5 |
|
|
lea ecx,[ecx+edx] |
|
|
movq [ecx],mm6 |
|
|
lea ecx,[ecx+edx] |
|
|
movq [ecx],mm7 |
|
|
|
|
470 |
ret |
ret |