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 %1.endfunc-%1 |
34 |
|
%define %1 _%1:function %1.endfunc-%1 |
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 %1.endfunc-%1 |
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 |
111 |
COPY_8_TO_16 2 |
COPY_8_TO_16 2 |
112 |
COPY_8_TO_16 3 |
COPY_8_TO_16 3 |
113 |
ret |
ret |
114 |
|
.endfunc |
115 |
|
|
116 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
117 |
; |
; |
147 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
148 |
COPY_16_TO_8 3 |
COPY_16_TO_8 3 |
149 |
ret |
ret |
150 |
|
.endfunc |
151 |
|
|
152 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
153 |
; |
; |
162 |
%macro COPY_8_TO_16_SUB 2 |
%macro COPY_8_TO_16_SUB 2 |
163 |
movq mm0, [eax] ; cur |
movq mm0, [eax] ; cur |
164 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
165 |
|
movq mm1, mm0 |
166 |
|
movq mm3, mm2 |
167 |
|
|
168 |
|
punpcklbw mm0, mm7 |
169 |
|
punpcklbw mm2, mm7 |
170 |
movq mm4, [ebx] ; ref |
movq mm4, [ebx] ; ref |
171 |
|
punpckhbw mm1, mm7 |
172 |
|
punpckhbw mm3, mm7 |
173 |
movq mm5, [ebx+edx] ; ref |
movq mm5, [ebx+edx] ; ref |
174 |
|
|
175 |
|
movq mm6, mm4 |
176 |
%if %2 == 1 |
%if %2 == 1 |
177 |
movq [eax], mm4 |
movq [eax], mm4 |
178 |
movq [eax+edx], mm5 |
movq [eax+edx], mm5 |
179 |
%endif |
%endif |
180 |
|
punpcklbw mm4, mm7 |
181 |
|
punpckhbw mm6, mm7 |
182 |
|
psubsw mm0, mm4 |
183 |
|
psubsw mm1, mm6 |
184 |
|
movq mm6, mm5 |
185 |
|
punpcklbw mm5, mm7 |
186 |
|
punpckhbw mm6, mm7 |
187 |
|
psubsw mm2, mm5 |
188 |
lea eax, [eax+2*edx] |
lea eax, [eax+2*edx] |
189 |
|
psubsw mm3, mm6 |
|
psubsb mm0,mm4 |
|
|
psubsb mm2,mm5 |
|
190 |
lea ebx,[ebx+2*edx] |
lea ebx,[ebx+2*edx] |
191 |
|
|
|
movq mm1,mm0 |
|
|
movq mm3,mm2 |
|
|
punpcklbw mm0,mm7 |
|
|
punpckhbw mm1,mm7 |
|
|
punpcklbw mm2,mm7 |
|
|
punpckhbw mm3,mm7 |
|
|
|
|
192 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
193 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
194 |
movq [ecx+%1*32+16], mm2 |
movq [ecx+%1*32+16], mm2 |
211 |
|
|
212 |
pop ebx |
pop ebx |
213 |
ret |
ret |
214 |
|
.endfunc |
215 |
|
|
216 |
|
|
217 |
ALIGN 16 |
ALIGN 16 |
230 |
|
|
231 |
pop ebx |
pop ebx |
232 |
ret |
ret |
233 |
|
.endfunc |
234 |
|
|
235 |
|
|
236 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
248 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
249 |
|
|
250 |
; mm4 <- (ref1+ref2+1) / 2 |
; mm4 <- (ref1+ref2+1) / 2 |
|
;(a+b+1)/2 = (a|b)-((a^b)>>1) |
|
251 |
movq mm4, [ebx] ; ref1 |
movq mm4, [ebx] ; ref1 |
252 |
movq mm1, [esi] ; ref2 |
movq mm1, [esi] ; ref2 |
253 |
movq mm3, mm4 |
movq mm6, mm4 |
254 |
pxor mm3,mm1 |
movq mm3, mm1 |
255 |
por mm4,mm1 |
punpcklbw mm4, mm7 |
256 |
pandn mm3,mm6 |
punpcklbw mm1, mm7 |
257 |
psrlq mm3,1 |
punpckhbw mm6, mm7 |
258 |
psubb mm4,mm3 |
punpckhbw mm3, mm7 |
259 |
|
paddusw mm4, mm1 |
260 |
|
paddusw mm6, mm3 |
261 |
|
paddusw mm4, [mmx_one] |
262 |
|
paddusw mm6, [mmx_one] |
263 |
|
psrlw mm4, 1 |
264 |
|
psrlw mm6, 1 |
265 |
|
packuswb mm4, mm6 |
266 |
movq [eax],mm4 |
movq [eax],mm4 |
267 |
|
|
268 |
; mm5 <- (ref1+ref2+1) / 2 |
; mm5 <- (ref1+ref2+1) / 2 |
269 |
movq mm5, [ebx+edx] ; ref1 |
movq mm5, [ebx+edx] ; ref1 |
270 |
movq mm1, [esi+edx] ; ref2 |
movq mm1, [esi+edx] ; ref2 |
271 |
movq mm3, mm5 |
movq mm6, mm5 |
272 |
pxor mm3,mm1 |
movq mm3, mm1 |
273 |
por mm5,mm1 |
punpcklbw mm5, mm7 |
274 |
pandn mm3,mm6 |
punpcklbw mm1, mm7 |
275 |
psrlq mm3,1 |
punpckhbw mm6, mm7 |
276 |
psubb mm5,mm3 |
punpckhbw mm3, mm7 |
277 |
|
paddusw mm5, mm1 |
278 |
|
paddusw mm6, mm3 |
279 |
|
paddusw mm5, [mmx_one] |
280 |
|
paddusw mm6, [mmx_one] |
281 |
|
lea esi, [esi+2*edx] |
282 |
|
psrlw mm5, 1 |
283 |
|
psrlw mm6, 1 |
284 |
|
packuswb mm5, mm6 |
285 |
movq [eax+edx],mm5 |
movq [eax+edx],mm5 |
286 |
|
|
|
psubsb mm0,mm4 |
|
|
psubsb mm2,mm5 |
|
|
lea esi, [esi+2*edx] |
|
287 |
movq mm1,mm0 |
movq mm1,mm0 |
288 |
movq mm3,mm2 |
movq mm3,mm2 |
|
lea eax, [eax+2*edx] |
|
289 |
punpcklbw mm0,mm7 |
punpcklbw mm0,mm7 |
290 |
punpcklbw mm2,mm7 |
punpcklbw mm2,mm7 |
|
lea ebx, [ebx+2*edx] |
|
291 |
punpckhbw mm1,mm7 |
punpckhbw mm1,mm7 |
292 |
punpckhbw mm3,mm7 |
punpckhbw mm3,mm7 |
293 |
|
|
294 |
|
movq mm6, mm4 |
295 |
|
punpcklbw mm4, mm7 |
296 |
|
punpckhbw mm6, mm7 |
297 |
|
psubsw mm0, mm4 |
298 |
|
psubsw mm1, mm6 |
299 |
|
movq mm6, mm5 |
300 |
|
punpcklbw mm5, mm7 |
301 |
|
punpckhbw mm6, mm7 |
302 |
|
psubsw mm2, mm5 |
303 |
|
lea eax, [eax+2*edx] |
304 |
|
psubsw mm3, mm6 |
305 |
|
lea ebx, [ebx+2*edx] |
306 |
|
|
307 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
308 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
309 |
movq [ecx+%1*32+16], mm2 |
movq [ecx+%1*32+16], mm2 |
319 |
push esi |
push esi |
320 |
mov esi, [esp+8+16] ; Ref2 |
mov esi, [esp+8+16] ; Ref2 |
321 |
mov edx, [esp+8+20] ; Stride |
mov edx, [esp+8+20] ; Stride |
|
pxor mm6,mm6 |
|
|
pcmpeqb mm5,mm5 |
|
322 |
pxor mm7, mm7 |
pxor mm7, mm7 |
|
psubb mm6, mm5; mm6=1 |
|
323 |
|
|
324 |
COPY_8_TO_16_SUB2_MMX 0 |
COPY_8_TO_16_SUB2_MMX 0 |
325 |
COPY_8_TO_16_SUB2_MMX 1 |
COPY_8_TO_16_SUB2_MMX 1 |
329 |
pop esi |
pop esi |
330 |
pop ebx |
pop ebx |
331 |
ret |
ret |
332 |
|
.endfunc |
333 |
|
|
334 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
335 |
; |
; |
344 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
345 |
movq mm0, [eax] ; cur |
movq mm0, [eax] ; cur |
346 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
347 |
|
movq mm1, mm0 |
348 |
|
movq mm3, mm2 |
349 |
|
|
350 |
|
punpcklbw mm0, mm7 |
351 |
|
punpcklbw mm2, mm7 |
352 |
movq mm4, [ebx] ; ref1 |
movq mm4, [ebx] ; ref1 |
353 |
pavgb mm4, [esi] ; ref2 |
pavgb mm4, [esi] ; ref2 |
354 |
|
movq [eax], mm4 |
355 |
|
punpckhbw mm1, mm7 |
356 |
|
punpckhbw mm3, mm7 |
357 |
movq mm5, [ebx+edx] ; ref |
movq mm5, [ebx+edx] ; ref |
358 |
pavgb mm5, [esi+edx] ; ref2 |
pavgb mm5, [esi+edx] ; ref2 |
|
|
|
|
movq [eax], mm4 |
|
359 |
movq [eax+edx], mm5 |
movq [eax+edx], mm5 |
360 |
|
|
361 |
psubsb mm0,mm4 |
movq mm6, mm4 |
362 |
psubsb mm2,mm5 |
punpcklbw mm4, mm7 |
363 |
|
punpckhbw mm6, mm7 |
364 |
|
psubsw mm0, mm4 |
365 |
|
psubsw mm1, mm6 |
366 |
lea esi, [esi+2*edx] |
lea esi, [esi+2*edx] |
367 |
movq mm1,mm0 |
movq mm6, mm5 |
368 |
movq mm3,mm2 |
punpcklbw mm5, mm7 |
369 |
|
punpckhbw mm6, mm7 |
370 |
|
psubsw mm2, mm5 |
371 |
lea eax, [eax+2*edx] |
lea eax, [eax+2*edx] |
372 |
punpcklbw mm0,mm7 |
psubsw mm3, mm6 |
|
punpcklbw mm2,mm7 |
|
373 |
lea ebx, [ebx+2*edx] |
lea ebx, [ebx+2*edx] |
|
punpckhbw mm1,mm7 |
|
|
punpckhbw mm3,mm7 |
|
374 |
|
|
375 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
376 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
397 |
pop esi |
pop esi |
398 |
pop ebx |
pop ebx |
399 |
ret |
ret |
400 |
|
.endfunc |
401 |
|
|
402 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
403 |
; |
; |
408 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
409 |
|
|
410 |
%macro COPY_16_TO_8_ADD 1 |
%macro COPY_16_TO_8_ADD 1 |
411 |
movq mm0, [eax+%1*32+ 0] ;src |
movq mm0, [ecx] |
412 |
packuswb mm0,[eax+%1*32+8] |
movq mm2, [ecx+edx] |
413 |
movq mm1, [eax+%1*32+ 16] |
movq mm1, mm0 |
414 |
packuswb mm1,[eax+%1*32+24] |
movq mm3, mm2 |
415 |
|
punpcklbw mm0, mm7 |
416 |
paddusb mm0,[ecx] |
punpcklbw mm2, mm7 |
417 |
paddusb mm1,[ecx+edx] |
punpckhbw mm1, mm7 |
418 |
|
punpckhbw mm3, mm7 |
419 |
|
paddsw mm0, [eax+%1*32+ 0] |
420 |
|
paddsw mm1, [eax+%1*32+ 8] |
421 |
|
paddsw mm2, [eax+%1*32+16] |
422 |
|
paddsw mm3, [eax+%1*32+24] |
423 |
|
packuswb mm0, mm1 |
424 |
movq [ecx],mm0 |
movq [ecx],mm0 |
425 |
movq [ecx+edx],mm1 |
packuswb mm2, mm3 |
426 |
|
movq [ecx+edx], mm2 |
427 |
%endmacro |
%endmacro |
428 |
|
|
429 |
|
|
432 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
433 |
mov eax, [esp+ 8] ; Src |
mov eax, [esp+ 8] ; Src |
434 |
mov edx, [esp+12] ; Stride |
mov edx, [esp+12] ; Stride |
435 |
; pxor mm7, mm7 |
pxor mm7, mm7 |
436 |
|
|
437 |
COPY_16_TO_8_ADD 0 |
COPY_16_TO_8_ADD 0 |
438 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
442 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
443 |
COPY_16_TO_8_ADD 3 |
COPY_16_TO_8_ADD 3 |
444 |
ret |
ret |
445 |
|
.endfunc |
446 |
|
|
447 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
448 |
; |
; |
453 |
; |
; |
454 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
455 |
|
|
456 |
|
%macro COPY_8_TO_8 0 |
457 |
|
movq mm0, [eax] |
458 |
|
movq mm1, [eax+edx] |
459 |
|
movq [ecx], mm0 |
460 |
|
lea eax, [eax+2*edx] |
461 |
|
movq [ecx+edx], mm1 |
462 |
|
%endmacro |
463 |
|
|
464 |
ALIGN 16 |
ALIGN 16 |
465 |
transfer8x8_copy_mmx: |
transfer8x8_copy_mmx: |
|
|
|
|
mov eax, [esp+ 8] ; Src |
|
466 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
467 |
|
mov eax, [esp+ 8] ; Src |
468 |
mov edx, [esp+12] ; Stride |
mov edx, [esp+12] ; Stride |
469 |
|
|
470 |
movq mm0,[eax] |
COPY_8_TO_8 |
471 |
lea eax,[eax+edx] |
lea ecx,[ecx+2*edx] |
472 |
movq mm1,[eax] |
COPY_8_TO_8 |
473 |
lea eax,[eax+edx] |
lea ecx,[ecx+2*edx] |
474 |
movq mm2,[eax] |
COPY_8_TO_8 |
475 |
lea eax,[eax+edx] |
lea ecx,[ecx+2*edx] |
476 |
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 |
|
|
|
|
477 |
ret |
ret |
478 |
|
.endfunc |
479 |
|
|