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> |
9 |
|
; * 2004 Jean-Marc Bastide <jmtest@voila.fr> |
10 |
; * |
; * |
11 |
; * This program is free software ; you can redistribute it and/or modify |
; * This program is free software ; you can redistribute it and/or modify |
12 |
; * 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 |
22 |
; * along with this program ; if not, write to the Free Software |
; * along with this program ; if not, write to the Free Software |
23 |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
24 |
; * |
; * |
25 |
; * $Id: mem_transfer_mmx.asm,v 1.10 2004-03-22 22:36:24 edgomez Exp $ |
; * $Id: mem_transfer_mmx.asm,v 1.11 2004-04-12 15:49:56 edgomez Exp $ |
26 |
; * |
; * |
27 |
; ***************************************************************************/ |
; ***************************************************************************/ |
28 |
|
|
152 |
%macro COPY_8_TO_16_SUB 2 |
%macro COPY_8_TO_16_SUB 2 |
153 |
movq mm0, [eax] ; cur |
movq mm0, [eax] ; cur |
154 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
|
movq mm1, mm0 |
|
|
movq mm3, mm2 |
|
155 |
|
|
|
punpcklbw mm0, mm7 |
|
|
punpcklbw mm2, mm7 |
|
156 |
movq mm4, [ebx] ; ref |
movq mm4, [ebx] ; ref |
|
punpckhbw mm1, mm7 |
|
|
punpckhbw mm3, mm7 |
|
157 |
movq mm5, [ebx+edx] ; ref |
movq mm5, [ebx+edx] ; ref |
158 |
|
|
|
movq mm6, mm4 |
|
159 |
%if %2 == 1 |
%if %2 == 1 |
160 |
movq [eax], mm4 |
movq [eax], mm4 |
161 |
movq [eax+edx], mm5 |
movq [eax+edx], mm5 |
162 |
%endif |
%endif |
163 |
punpcklbw mm4, mm7 |
|
|
punpckhbw mm6, mm7 |
|
|
psubsw mm0, mm4 |
|
|
psubsw mm1, mm6 |
|
|
movq mm6, mm5 |
|
|
punpcklbw mm5, mm7 |
|
|
punpckhbw mm6, mm7 |
|
|
psubsw mm2, mm5 |
|
164 |
lea eax, [eax+2*edx] |
lea eax, [eax+2*edx] |
165 |
psubsw mm3, mm6 |
|
166 |
|
psubsb mm0,mm4 |
167 |
|
psubsb mm2,mm5 |
168 |
lea ebx,[ebx+2*edx] |
lea ebx,[ebx+2*edx] |
169 |
|
|
170 |
|
movq mm1,mm0 |
171 |
|
movq mm3,mm2 |
172 |
|
punpcklbw mm0,mm7 |
173 |
|
punpckhbw mm1,mm7 |
174 |
|
punpcklbw mm2,mm7 |
175 |
|
punpckhbw mm3,mm7 |
176 |
|
|
177 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
178 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
179 |
movq [ecx+%1*32+16], mm2 |
movq [ecx+%1*32+16], mm2 |
231 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
232 |
|
|
233 |
; mm4 <- (ref1+ref2+1) / 2 |
; mm4 <- (ref1+ref2+1) / 2 |
234 |
|
;(a+b+1)/2 = (a|b)-((a^b)>>1) |
235 |
movq mm4, [ebx] ; ref1 |
movq mm4, [ebx] ; ref1 |
236 |
movq mm1, [esi] ; ref2 |
movq mm1, [esi] ; ref2 |
237 |
movq mm6, mm4 |
movq mm3, mm4 |
238 |
movq mm3, mm1 |
pxor mm3,mm1 |
239 |
punpcklbw mm4, mm7 |
por mm4,mm1 |
240 |
punpcklbw mm1, mm7 |
pandn mm3,mm6 |
241 |
punpckhbw mm6, mm7 |
psrlq mm3,1 |
242 |
punpckhbw mm3, mm7 |
psubb mm4,mm3 |
|
paddusw mm4, mm1 |
|
|
paddusw mm6, mm3 |
|
|
paddusw mm4, [mmx_one] |
|
|
paddusw mm6, [mmx_one] |
|
|
psrlw mm4, 1 |
|
|
psrlw mm6, 1 |
|
|
packuswb mm4, mm6 |
|
243 |
movq [eax], mm4 |
movq [eax], mm4 |
244 |
|
|
245 |
; mm5 <- (ref1+ref2+1) / 2 |
; mm5 <- (ref1+ref2+1) / 2 |
246 |
movq mm5, [ebx+edx] ; ref1 |
movq mm5, [ebx+edx] ; ref1 |
247 |
movq mm1, [esi+edx] ; ref2 |
movq mm1, [esi+edx] ; ref2 |
248 |
movq mm6, mm5 |
movq mm3, mm5 |
249 |
movq mm3, mm1 |
pxor mm3,mm1 |
250 |
punpcklbw mm5, mm7 |
por mm5,mm1 |
251 |
punpcklbw mm1, mm7 |
pandn mm3,mm6 |
252 |
punpckhbw mm6, mm7 |
psrlq mm3,1 |
253 |
punpckhbw mm3, mm7 |
psubb mm5,mm3 |
|
paddusw mm5, mm1 |
|
|
paddusw mm6, mm3 |
|
|
paddusw mm5, [mmx_one] |
|
|
paddusw mm6, [mmx_one] |
|
|
lea esi, [esi+2*edx] |
|
|
psrlw mm5, 1 |
|
|
psrlw mm6, 1 |
|
|
packuswb mm5, mm6 |
|
254 |
movq [eax+edx], mm5 |
movq [eax+edx], mm5 |
255 |
|
|
256 |
|
psubsb mm0,mm4 |
257 |
|
psubsb mm2,mm5 |
258 |
|
lea esi, [esi+2*edx] |
259 |
movq mm1, mm0 |
movq mm1, mm0 |
260 |
movq mm3, mm2 |
movq mm3, mm2 |
261 |
|
lea eax, [eax+2*edx] |
262 |
punpcklbw mm0, mm7 |
punpcklbw mm0, mm7 |
263 |
punpcklbw mm2, mm7 |
punpcklbw mm2, mm7 |
264 |
|
lea ebx, [ebx+2*edx] |
265 |
punpckhbw mm1, mm7 |
punpckhbw mm1, mm7 |
266 |
punpckhbw mm3, mm7 |
punpckhbw mm3, mm7 |
267 |
|
|
|
movq mm6, mm4 |
|
|
punpcklbw mm4, mm7 |
|
|
punpckhbw mm6, mm7 |
|
|
psubsw mm0, mm4 |
|
|
psubsw mm1, mm6 |
|
|
movq mm6, mm5 |
|
|
punpcklbw mm5, mm7 |
|
|
punpckhbw mm6, mm7 |
|
|
psubsw mm2, mm5 |
|
|
lea eax, [eax+2*edx] |
|
|
psubsw mm3, mm6 |
|
|
lea ebx, [ebx+2*edx] |
|
|
|
|
268 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
269 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
270 |
movq [ecx+%1*32+16], mm2 |
movq [ecx+%1*32+16], mm2 |
280 |
push esi |
push esi |
281 |
mov esi, [esp+8+16] ; Ref2 |
mov esi, [esp+8+16] ; Ref2 |
282 |
mov edx, [esp+8+20] ; Stride |
mov edx, [esp+8+20] ; Stride |
283 |
|
pxor mm6,mm6 |
284 |
|
pcmpeqb mm5,mm5 |
285 |
pxor mm7, mm7 |
pxor mm7, mm7 |
286 |
|
psubb mm6, mm5; mm6=1 |
287 |
|
|
288 |
COPY_8_TO_16_SUB2_MMX 0 |
COPY_8_TO_16_SUB2_MMX 0 |
289 |
COPY_8_TO_16_SUB2_MMX 1 |
COPY_8_TO_16_SUB2_MMX 1 |
307 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
308 |
movq mm0, [eax] ; cur |
movq mm0, [eax] ; cur |
309 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
|
movq mm1, mm0 |
|
|
movq mm3, mm2 |
|
310 |
|
|
|
punpcklbw mm0, mm7 |
|
|
punpcklbw mm2, mm7 |
|
311 |
movq mm4, [ebx] ; ref1 |
movq mm4, [ebx] ; ref1 |
312 |
pavgb mm4, [esi] ; ref2 |
pavgb mm4, [esi] ; ref2 |
313 |
movq [eax], mm4 |
|
|
punpckhbw mm1, mm7 |
|
|
punpckhbw mm3, mm7 |
|
314 |
movq mm5, [ebx+edx] ; ref |
movq mm5, [ebx+edx] ; ref |
315 |
pavgb mm5, [esi+edx] ; ref2 |
pavgb mm5, [esi+edx] ; ref2 |
316 |
|
|
317 |
|
movq [eax], mm4 |
318 |
movq [eax+edx], mm5 |
movq [eax+edx], mm5 |
319 |
|
|
320 |
movq mm6, mm4 |
psubsb mm0,mm4 |
321 |
punpcklbw mm4, mm7 |
psubsb mm2,mm5 |
|
punpckhbw mm6, mm7 |
|
|
psubsw mm0, mm4 |
|
|
psubsw mm1, mm6 |
|
322 |
lea esi, [esi+2*edx] |
lea esi, [esi+2*edx] |
323 |
movq mm6, mm5 |
movq mm1,mm0 |
324 |
punpcklbw mm5, mm7 |
movq mm3,mm2 |
|
punpckhbw mm6, mm7 |
|
|
psubsw mm2, mm5 |
|
325 |
lea eax, [eax+2*edx] |
lea eax, [eax+2*edx] |
326 |
psubsw mm3, mm6 |
punpcklbw mm0,mm7 |
327 |
|
punpcklbw mm2,mm7 |
328 |
lea ebx, [ebx+2*edx] |
lea ebx, [ebx+2*edx] |
329 |
|
punpckhbw mm1,mm7 |
330 |
|
punpckhbw mm3,mm7 |
331 |
|
|
332 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
333 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
364 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
365 |
|
|
366 |
%macro COPY_16_TO_8_ADD 1 |
%macro COPY_16_TO_8_ADD 1 |
367 |
movq mm0, [ecx] |
movq mm0, [eax+%1*32+ 0] ;src |
368 |
movq mm2, [ecx+edx] |
packuswb mm0,[eax+%1*32+8] |
369 |
movq mm1, mm0 |
movq mm1, [eax+%1*32+ 16] |
370 |
movq mm3, mm2 |
packuswb mm1,[eax+%1*32+24] |
371 |
punpcklbw mm0, mm7 |
|
372 |
punpcklbw mm2, mm7 |
paddusb mm0,[ecx] |
373 |
punpckhbw mm1, mm7 |
paddusb mm1,[ecx+edx] |
|
punpckhbw mm3, mm7 |
|
|
paddsw mm0, [eax+%1*32+ 0] |
|
|
paddsw mm1, [eax+%1*32+ 8] |
|
|
paddsw mm2, [eax+%1*32+16] |
|
|
paddsw mm3, [eax+%1*32+24] |
|
|
packuswb mm0, mm1 |
|
374 |
movq [ecx], mm0 |
movq [ecx], mm0 |
375 |
packuswb mm2, mm3 |
movq [ecx+edx],mm1 |
376 |
movq [ecx+edx], mm2 |
|
377 |
%endmacro |
%endmacro |
378 |
|
|
379 |
|
|
382 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
383 |
mov eax, [esp+ 8] ; Src |
mov eax, [esp+ 8] ; Src |
384 |
mov edx, [esp+12] ; Stride |
mov edx, [esp+12] ; Stride |
385 |
pxor mm7, mm7 |
; pxor mm7, mm7 |
386 |
|
|
387 |
COPY_16_TO_8_ADD 0 |
COPY_16_TO_8_ADD 0 |
388 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
402 |
; |
; |
403 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
404 |
|
|
|
%macro COPY_8_TO_8 0 |
|
|
movq mm0, [eax] |
|
|
movq mm1, [eax+edx] |
|
|
movq [ecx], mm0 |
|
|
lea eax, [eax+2*edx] |
|
|
movq [ecx+edx], mm1 |
|
|
%endmacro |
|
|
|
|
405 |
ALIGN 16 |
ALIGN 16 |
406 |
transfer8x8_copy_mmx: |
transfer8x8_copy_mmx: |
407 |
mov ecx, [esp+ 4] ; Dst |
|
408 |
mov eax, [esp+ 8] ; Src |
mov eax, [esp+ 8] ; Src |
409 |
|
mov ecx, [esp+ 4] ; Dst |
410 |
mov edx, [esp+12] ; Stride |
mov edx, [esp+12] ; Stride |
411 |
|
|
412 |
COPY_8_TO_8 |
movq mm0,[eax] |
413 |
lea ecx,[ecx+2*edx] |
lea eax,[eax+edx] |
414 |
COPY_8_TO_8 |
movq mm1,[eax] |
415 |
lea ecx,[ecx+2*edx] |
lea eax,[eax+edx] |
416 |
COPY_8_TO_8 |
movq mm2,[eax] |
417 |
lea ecx,[ecx+2*edx] |
lea eax,[eax+edx] |
418 |
COPY_8_TO_8 |
movq mm3,[eax] |
419 |
|
lea eax,[eax+edx] |
420 |
|
movq mm4,[eax] |
421 |
|
lea eax,[eax+edx] |
422 |
|
movq mm5,[eax] |
423 |
|
lea eax,[eax+edx] |
424 |
|
movq mm6,[eax] |
425 |
|
lea eax,[eax+edx] |
426 |
|
movq mm7,[eax] |
427 |
|
|
428 |
|
movq [ecx],mm0 |
429 |
|
lea ecx,[ecx+edx] |
430 |
|
movq [ecx],mm1 |
431 |
|
lea ecx,[ecx+edx] |
432 |
|
movq [ecx],mm2 |
433 |
|
lea ecx,[ecx+edx] |
434 |
|
movq [ecx],mm3 |
435 |
|
lea ecx,[ecx+edx] |
436 |
|
movq [ecx],mm4 |
437 |
|
lea ecx,[ecx+edx] |
438 |
|
movq [ecx],mm5 |
439 |
|
lea ecx,[ecx+edx] |
440 |
|
movq [ecx],mm6 |
441 |
|
lea ecx,[ecx+edx] |
442 |
|
movq [ecx],mm7 |
443 |
|
|
444 |
ret |
ret |