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 |
41 |
;============================================================================= |
;============================================================================= |
42 |
|
|
43 |
%ifdef FORMAT_COFF |
%ifdef FORMAT_COFF |
44 |
SECTION .rodata data |
SECTION .rodata |
45 |
%else |
%else |
46 |
SECTION .rodata data align=16 |
SECTION .rodata align=16 |
47 |
%endif |
%endif |
48 |
|
|
49 |
ALIGN 16 |
ALIGN 16 |
151 |
%macro COPY_8_TO_16_SUB 2 |
%macro COPY_8_TO_16_SUB 2 |
152 |
movq mm0, [eax] ; cur |
movq mm0, [eax] ; cur |
153 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
154 |
|
movq mm1, mm0 |
155 |
|
movq mm3, mm2 |
156 |
|
|
157 |
|
punpcklbw mm0, mm7 |
158 |
|
punpcklbw mm2, mm7 |
159 |
movq mm4, [ebx] ; ref |
movq mm4, [ebx] ; ref |
160 |
|
punpckhbw mm1, mm7 |
161 |
|
punpckhbw mm3, mm7 |
162 |
movq mm5, [ebx+edx] ; ref |
movq mm5, [ebx+edx] ; ref |
163 |
|
|
164 |
|
movq mm6, mm4 |
165 |
%if %2 == 1 |
%if %2 == 1 |
166 |
movq [eax], mm4 |
movq [eax], mm4 |
167 |
movq [eax+edx], mm5 |
movq [eax+edx], mm5 |
168 |
%endif |
%endif |
169 |
|
punpcklbw mm4, mm7 |
170 |
|
punpckhbw mm6, mm7 |
171 |
|
psubsw mm0, mm4 |
172 |
|
psubsw mm1, mm6 |
173 |
|
movq mm6, mm5 |
174 |
|
punpcklbw mm5, mm7 |
175 |
|
punpckhbw mm6, mm7 |
176 |
|
psubsw mm2, mm5 |
177 |
lea eax, [eax+2*edx] |
lea eax, [eax+2*edx] |
178 |
|
psubsw mm3, mm6 |
|
psubsb mm0,mm4 |
|
|
psubsb mm2,mm5 |
|
179 |
lea ebx,[ebx+2*edx] |
lea ebx,[ebx+2*edx] |
180 |
|
|
|
movq mm1,mm0 |
|
|
movq mm3,mm2 |
|
|
punpcklbw mm0,mm7 |
|
|
punpckhbw mm1,mm7 |
|
|
punpcklbw mm2,mm7 |
|
|
punpckhbw mm3,mm7 |
|
|
|
|
181 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
182 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
183 |
movq [ecx+%1*32+16], mm2 |
movq [ecx+%1*32+16], mm2 |
235 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
236 |
|
|
237 |
; mm4 <- (ref1+ref2+1) / 2 |
; mm4 <- (ref1+ref2+1) / 2 |
|
;(a+b+1)/2 = (a|b)-((a^b)>>1) |
|
238 |
movq mm4, [ebx] ; ref1 |
movq mm4, [ebx] ; ref1 |
239 |
movq mm1, [esi] ; ref2 |
movq mm1, [esi] ; ref2 |
240 |
movq mm3, mm4 |
movq mm6, mm4 |
241 |
pxor mm3,mm1 |
movq mm3, mm1 |
242 |
por mm4,mm1 |
punpcklbw mm4, mm7 |
243 |
pandn mm3,mm6 |
punpcklbw mm1, mm7 |
244 |
psrlq mm3,1 |
punpckhbw mm6, mm7 |
245 |
psubb mm4,mm3 |
punpckhbw mm3, mm7 |
246 |
|
paddusw mm4, mm1 |
247 |
|
paddusw mm6, mm3 |
248 |
|
paddusw mm4, [mmx_one] |
249 |
|
paddusw mm6, [mmx_one] |
250 |
|
psrlw mm4, 1 |
251 |
|
psrlw mm6, 1 |
252 |
|
packuswb mm4, mm6 |
253 |
movq [eax],mm4 |
movq [eax],mm4 |
254 |
|
|
255 |
; mm5 <- (ref1+ref2+1) / 2 |
; mm5 <- (ref1+ref2+1) / 2 |
256 |
movq mm5, [ebx+edx] ; ref1 |
movq mm5, [ebx+edx] ; ref1 |
257 |
movq mm1, [esi+edx] ; ref2 |
movq mm1, [esi+edx] ; ref2 |
258 |
movq mm3, mm5 |
movq mm6, mm5 |
259 |
pxor mm3,mm1 |
movq mm3, mm1 |
260 |
por mm5,mm1 |
punpcklbw mm5, mm7 |
261 |
pandn mm3,mm6 |
punpcklbw mm1, mm7 |
262 |
psrlq mm3,1 |
punpckhbw mm6, mm7 |
263 |
psubb mm5,mm3 |
punpckhbw mm3, mm7 |
264 |
|
paddusw mm5, mm1 |
265 |
|
paddusw mm6, mm3 |
266 |
|
paddusw mm5, [mmx_one] |
267 |
|
paddusw mm6, [mmx_one] |
268 |
|
lea esi, [esi+2*edx] |
269 |
|
psrlw mm5, 1 |
270 |
|
psrlw mm6, 1 |
271 |
|
packuswb mm5, mm6 |
272 |
movq [eax+edx],mm5 |
movq [eax+edx],mm5 |
273 |
|
|
|
psubsb mm0,mm4 |
|
|
psubsb mm2,mm5 |
|
|
lea esi, [esi+2*edx] |
|
274 |
movq mm1,mm0 |
movq mm1,mm0 |
275 |
movq mm3,mm2 |
movq mm3,mm2 |
|
lea eax, [eax+2*edx] |
|
276 |
punpcklbw mm0,mm7 |
punpcklbw mm0,mm7 |
277 |
punpcklbw mm2,mm7 |
punpcklbw mm2,mm7 |
|
lea ebx, [ebx+2*edx] |
|
278 |
punpckhbw mm1,mm7 |
punpckhbw mm1,mm7 |
279 |
punpckhbw mm3,mm7 |
punpckhbw mm3,mm7 |
280 |
|
|
281 |
|
movq mm6, mm4 |
282 |
|
punpcklbw mm4, mm7 |
283 |
|
punpckhbw mm6, mm7 |
284 |
|
psubsw mm0, mm4 |
285 |
|
psubsw mm1, mm6 |
286 |
|
movq mm6, mm5 |
287 |
|
punpcklbw mm5, mm7 |
288 |
|
punpckhbw mm6, mm7 |
289 |
|
psubsw mm2, mm5 |
290 |
|
lea eax, [eax+2*edx] |
291 |
|
psubsw mm3, mm6 |
292 |
|
lea ebx, [ebx+2*edx] |
293 |
|
|
294 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
295 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
296 |
movq [ecx+%1*32+16], mm2 |
movq [ecx+%1*32+16], mm2 |
306 |
push esi |
push esi |
307 |
mov esi, [esp+8+16] ; Ref2 |
mov esi, [esp+8+16] ; Ref2 |
308 |
mov edx, [esp+8+20] ; Stride |
mov edx, [esp+8+20] ; Stride |
|
pxor mm6,mm6 |
|
|
pcmpeqb mm5,mm5 |
|
309 |
pxor mm7, mm7 |
pxor mm7, mm7 |
|
psubb mm6, mm5; mm6=1 |
|
310 |
|
|
311 |
COPY_8_TO_16_SUB2_MMX 0 |
COPY_8_TO_16_SUB2_MMX 0 |
312 |
COPY_8_TO_16_SUB2_MMX 1 |
COPY_8_TO_16_SUB2_MMX 1 |
330 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
331 |
movq mm0, [eax] ; cur |
movq mm0, [eax] ; cur |
332 |
movq mm2, [eax+edx] |
movq mm2, [eax+edx] |
333 |
|
movq mm1, mm0 |
334 |
|
movq mm3, mm2 |
335 |
|
|
336 |
|
punpcklbw mm0, mm7 |
337 |
|
punpcklbw mm2, mm7 |
338 |
movq mm4, [ebx] ; ref1 |
movq mm4, [ebx] ; ref1 |
339 |
pavgb mm4, [esi] ; ref2 |
pavgb mm4, [esi] ; ref2 |
340 |
|
movq [eax], mm4 |
341 |
|
punpckhbw mm1, mm7 |
342 |
|
punpckhbw mm3, mm7 |
343 |
movq mm5, [ebx+edx] ; ref |
movq mm5, [ebx+edx] ; ref |
344 |
pavgb mm5, [esi+edx] ; ref2 |
pavgb mm5, [esi+edx] ; ref2 |
|
|
|
|
movq [eax], mm4 |
|
345 |
movq [eax+edx], mm5 |
movq [eax+edx], mm5 |
346 |
|
|
347 |
psubsb mm0,mm4 |
movq mm6, mm4 |
348 |
psubsb mm2,mm5 |
punpcklbw mm4, mm7 |
349 |
|
punpckhbw mm6, mm7 |
350 |
|
psubsw mm0, mm4 |
351 |
|
psubsw mm1, mm6 |
352 |
lea esi, [esi+2*edx] |
lea esi, [esi+2*edx] |
353 |
movq mm1,mm0 |
movq mm6, mm5 |
354 |
movq mm3,mm2 |
punpcklbw mm5, mm7 |
355 |
|
punpckhbw mm6, mm7 |
356 |
|
psubsw mm2, mm5 |
357 |
lea eax, [eax+2*edx] |
lea eax, [eax+2*edx] |
358 |
punpcklbw mm0,mm7 |
psubsw mm3, mm6 |
|
punpcklbw mm2,mm7 |
|
359 |
lea ebx, [ebx+2*edx] |
lea ebx, [ebx+2*edx] |
|
punpckhbw mm1,mm7 |
|
|
punpckhbw mm3,mm7 |
|
360 |
|
|
361 |
movq [ecx+%1*32+ 0], mm0 ; dst |
movq [ecx+%1*32+ 0], mm0 ; dst |
362 |
movq [ecx+%1*32+ 8], mm1 |
movq [ecx+%1*32+ 8], mm1 |
393 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
394 |
|
|
395 |
%macro COPY_16_TO_8_ADD 1 |
%macro COPY_16_TO_8_ADD 1 |
396 |
movq mm0, [eax+%1*32+ 0] ;src |
movq mm0, [ecx] |
397 |
packuswb mm0,[eax+%1*32+8] |
movq mm2, [ecx+edx] |
398 |
movq mm1, [eax+%1*32+ 16] |
movq mm1, mm0 |
399 |
packuswb mm1,[eax+%1*32+24] |
movq mm3, mm2 |
400 |
|
punpcklbw mm0, mm7 |
401 |
paddusb mm0,[ecx] |
punpcklbw mm2, mm7 |
402 |
paddusb mm1,[ecx+edx] |
punpckhbw mm1, mm7 |
403 |
|
punpckhbw mm3, mm7 |
404 |
|
paddsw mm0, [eax+%1*32+ 0] |
405 |
|
paddsw mm1, [eax+%1*32+ 8] |
406 |
|
paddsw mm2, [eax+%1*32+16] |
407 |
|
paddsw mm3, [eax+%1*32+24] |
408 |
|
packuswb mm0, mm1 |
409 |
movq [ecx],mm0 |
movq [ecx],mm0 |
410 |
movq [ecx+edx],mm1 |
packuswb mm2, mm3 |
411 |
|
movq [ecx+edx], mm2 |
412 |
%endmacro |
%endmacro |
413 |
|
|
414 |
|
|
417 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
418 |
mov eax, [esp+ 8] ; Src |
mov eax, [esp+ 8] ; Src |
419 |
mov edx, [esp+12] ; Stride |
mov edx, [esp+12] ; Stride |
420 |
; pxor mm7, mm7 |
pxor mm7, mm7 |
421 |
|
|
422 |
COPY_16_TO_8_ADD 0 |
COPY_16_TO_8_ADD 0 |
423 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
437 |
; |
; |
438 |
;----------------------------------------------------------------------------- |
;----------------------------------------------------------------------------- |
439 |
|
|
440 |
|
%macro COPY_8_TO_8 0 |
441 |
|
movq mm0, [eax] |
442 |
|
movq mm1, [eax+edx] |
443 |
|
movq [ecx], mm0 |
444 |
|
lea eax, [eax+2*edx] |
445 |
|
movq [ecx+edx], mm1 |
446 |
|
%endmacro |
447 |
|
|
448 |
ALIGN 16 |
ALIGN 16 |
449 |
transfer8x8_copy_mmx: |
transfer8x8_copy_mmx: |
|
|
|
|
mov eax, [esp+ 8] ; Src |
|
450 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
451 |
|
mov eax, [esp+ 8] ; Src |
452 |
mov edx, [esp+12] ; Stride |
mov edx, [esp+12] ; Stride |
453 |
|
|
454 |
movq mm0,[eax] |
COPY_8_TO_8 |
455 |
lea eax,[eax+edx] |
lea ecx,[ecx+2*edx] |
456 |
movq mm1,[eax] |
COPY_8_TO_8 |
457 |
lea eax,[eax+edx] |
lea ecx,[ecx+2*edx] |
458 |
movq mm2,[eax] |
COPY_8_TO_8 |
459 |
lea eax,[eax+edx] |
lea ecx,[ecx+2*edx] |
460 |
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 |
|
|
|
|
461 |
ret |
ret |