1 |
;/************************************************************************** |
;/**************************************************************************** |
2 |
; * |
; * |
3 |
; * XVID MPEG-4 VIDEO CODEC |
; * XVID MPEG-4 VIDEO CODEC |
4 |
; * mmx 8bit<->16bit transfers |
; * - 8<->16 bit transfer functions - |
5 |
; * |
; * |
6 |
; * This program is an implementation of a part of one or more MPEG-4 |
; * Copyright (C) 2001 Peter Ross <pross@xvid.org> |
7 |
; * Video tools as specified in ISO/IEC 14496-2 standard. Those intending |
; * 2001 Michael Militzer <isibaar@xvid.org> |
8 |
; * to use this software module in hardware or software products are |
; * 2002 Pascal Massimino <skal@planet-d.net> |
|
; * advised that its use may infringe existing patents or copyrights, and |
|
|
; * any such use would be at such party's own risk. The original |
|
|
; * developer of this software module and his/her company, and subsequent |
|
|
; * editors and their companies, will have no liability for use of this |
|
|
; * software or modifications or derivatives thereof. |
|
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 |
19 |
; * |
; * |
20 |
; * You should have received a copy of the GNU General Public License |
; * You should have received a copy of the GNU General Public License |
21 |
; * along with this program; if not, write to the Free Software |
; * along with this program; if not, write to the Free Software |
22 |
; * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
23 |
; * |
; * |
24 |
; *************************************************************************/ |
; * $Id$ |
|
|
|
|
;/************************************************************************** |
|
|
; * |
|
|
; * History: |
|
|
; * |
|
|
; * 04.06.2002 speed enhancement (unroll+overlap). -Skal- |
|
|
; * + added transfer_8to16sub2_mmx/xmm |
|
|
; * 07.01.2002 merge functions from compensate_mmx; rename functions |
|
|
; * 07.11.2001 initial version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
|
25 |
; * |
; * |
26 |
; *************************************************************************/ |
; ***************************************************************************/ |
27 |
|
|
28 |
|
BITS 32 |
|
bits 32 |
|
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 |
|
;============================================================================= |
49 |
|
; Read only data |
50 |
|
;============================================================================= |
51 |
|
|
52 |
|
%ifdef FORMAT_COFF |
53 |
|
SECTION .rodata |
54 |
|
%else |
55 |
|
SECTION .rodata align=16 |
56 |
|
%endif |
57 |
|
|
58 |
section .text |
ALIGN 16 |
59 |
|
mmx_one: |
60 |
|
dw 1, 1, 1, 1 |
61 |
|
|
62 |
|
;============================================================================= |
63 |
|
; Code |
64 |
|
;============================================================================= |
65 |
|
|
66 |
|
SECTION .text |
67 |
|
|
68 |
cglobal transfer_8to16copy_mmx |
cglobal transfer_8to16copy_mmx |
69 |
cglobal transfer_16to8copy_mmx |
cglobal transfer_16to8copy_mmx |
74 |
cglobal transfer_16to8add_mmx |
cglobal transfer_16to8add_mmx |
75 |
cglobal transfer8x8_copy_mmx |
cglobal transfer8x8_copy_mmx |
76 |
|
|
77 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
78 |
; |
; |
79 |
; void transfer_8to16copy_mmx(int16_t * const dst, |
; void transfer_8to16copy_mmx(int16_t * const dst, |
80 |
; const uint8_t * const src, |
; const uint8_t * const src, |
81 |
; uint32_t stride); |
; uint32_t stride); |
82 |
; |
; |
83 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
84 |
|
|
85 |
%macro COPY_8_TO_16 1 |
%macro COPY_8_TO_16 1 |
86 |
movq mm0, [eax] |
movq mm0, [eax] |
98 |
movq [ecx+%1*32+24], mm3 |
movq [ecx+%1*32+24], mm3 |
99 |
%endmacro |
%endmacro |
100 |
|
|
101 |
align 16 |
ALIGN 16 |
102 |
transfer_8to16copy_mmx: |
transfer_8to16copy_mmx: |
103 |
|
|
104 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
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 |
; |
; |
118 |
; void transfer_16to8copy_mmx(uint8_t * const dst, |
; void transfer_16to8copy_mmx(uint8_t * const dst, |
119 |
; const int16_t * const src, |
; const int16_t * const src, |
120 |
; uint32_t stride); |
; uint32_t stride); |
121 |
; |
; |
122 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
123 |
|
|
124 |
%macro COPY_16_TO_8 1 |
%macro COPY_16_TO_8 1 |
125 |
movq mm0, [eax+%1*32] |
movq mm0, [eax+%1*32] |
132 |
movq [ecx+edx], mm2 |
movq [ecx+edx], mm2 |
133 |
%endmacro |
%endmacro |
134 |
|
|
135 |
align 16 |
ALIGN 16 |
136 |
transfer_16to8copy_mmx: |
transfer_16to8copy_mmx: |
137 |
|
|
138 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
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 |
; |
; |
154 |
; void transfer_8to16sub_mmx(int16_t * const dct, |
; void transfer_8to16sub_mmx(int16_t * const dct, |
155 |
; uint8_t * const cur, |
; uint8_t * const cur, |
156 |
; const uint8_t * const ref, |
; const uint8_t * const ref, |
157 |
; const uint32_t stride); |
; const uint32_t stride); |
158 |
; |
; |
159 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
;/************************************************************************** |
|
|
; * |
|
|
; * History: |
|
|
; * |
|
|
; * 27.12.2001 renamed from 'compensate' to 'transfer_8to16sub' |
|
|
; * 02.12.2001 loop unrolled, code runs 10% faster now (Isibaar) |
|
|
; * 30.11.2001 16 pixels are processed per iteration (Isibaar) |
|
|
; * 30.11.2001 .text missing |
|
|
; * 06.11.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
|
|
; * |
|
|
; *************************************************************************/ |
|
160 |
|
|
161 |
; when second argument == 1, reference (ebx) block is to current (eax) |
; when second argument == 1, reference (ebx) block is to current (eax) |
162 |
%macro COPY_8_TO_16_SUB 2 |
%macro COPY_8_TO_16_SUB 2 |
195 |
movq [ecx+%1*32+24], mm3 |
movq [ecx+%1*32+24], mm3 |
196 |
%endmacro |
%endmacro |
197 |
|
|
198 |
align 16 |
ALIGN 16 |
199 |
transfer_8to16sub_mmx: |
transfer_8to16sub_mmx: |
200 |
mov ecx, [esp + 4] ; Dst |
mov ecx, [esp + 4] ; Dst |
201 |
mov eax, [esp + 8] ; Cur |
mov eax, [esp + 8] ; Cur |
211 |
|
|
212 |
pop ebx |
pop ebx |
213 |
ret |
ret |
214 |
|
.endfunc |
215 |
|
|
216 |
|
|
217 |
align 16 |
ALIGN 16 |
218 |
transfer_8to16subro_mmx: |
transfer_8to16subro_mmx: |
219 |
mov ecx, [esp + 4] ; Dst |
mov ecx, [esp + 4] ; Dst |
220 |
mov eax, [esp + 8] ; Cur |
mov eax, [esp + 8] ; Cur |
230 |
|
|
231 |
pop ebx |
pop ebx |
232 |
ret |
ret |
233 |
|
.endfunc |
234 |
|
|
235 |
|
|
236 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
237 |
; |
; |
238 |
; void transfer_8to16sub2_mmx(int16_t * const dct, |
; void transfer_8to16sub2_mmx(int16_t * const dct, |
239 |
; uint8_t * const cur, |
; uint8_t * const cur, |
241 |
; const uint8_t * ref2, |
; const uint8_t * ref2, |
242 |
; const uint32_t stride) |
; const uint32_t stride) |
243 |
; |
; |
244 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
245 |
|
|
246 |
%macro COPY_8_TO_16_SUB2_MMX 1 |
%macro COPY_8_TO_16_SUB2_MMX 1 |
247 |
movq mm0, [eax] ; cur |
movq mm0, [eax] ; cur |
258 |
punpckhbw mm3, mm7 |
punpckhbw mm3, mm7 |
259 |
paddusw mm4, mm1 |
paddusw mm4, mm1 |
260 |
paddusw mm6, mm3 |
paddusw mm6, mm3 |
261 |
|
paddusw mm4, [mmx_one] |
262 |
|
paddusw mm6, [mmx_one] |
263 |
psrlw mm4,1 |
psrlw mm4,1 |
264 |
psrlw mm6,1 |
psrlw mm6,1 |
265 |
packuswb mm4, mm6 |
packuswb mm4, mm6 |
266 |
|
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 |
276 |
punpckhbw mm3, mm7 |
punpckhbw mm3, mm7 |
277 |
paddusw mm5, mm1 |
paddusw mm5, mm1 |
278 |
paddusw mm6, mm3 |
paddusw mm6, mm3 |
279 |
|
paddusw mm5, [mmx_one] |
280 |
|
paddusw mm6, [mmx_one] |
281 |
lea esi,[esi+2*edx] |
lea esi,[esi+2*edx] |
282 |
psrlw mm5,1 |
psrlw mm5,1 |
283 |
psrlw mm6,1 |
psrlw mm6,1 |
284 |
packuswb mm5, mm6 |
packuswb mm5, mm6 |
285 |
|
movq [eax+edx], mm5 |
286 |
|
|
287 |
movq mm1, mm0 |
movq mm1, mm0 |
288 |
movq mm3, mm2 |
movq mm3, mm2 |
310 |
movq [ecx+%1*32+24], mm3 |
movq [ecx+%1*32+24], mm3 |
311 |
%endmacro |
%endmacro |
312 |
|
|
313 |
align 16 |
ALIGN 16 |
314 |
transfer_8to16sub2_mmx: |
transfer_8to16sub2_mmx: |
315 |
mov ecx, [esp + 4] ; Dst |
mov ecx, [esp + 4] ; Dst |
316 |
mov eax, [esp + 8] ; Cur |
mov eax, [esp + 8] ; Cur |
329 |
pop esi |
pop esi |
330 |
pop ebx |
pop ebx |
331 |
ret |
ret |
332 |
|
.endfunc |
333 |
|
|
334 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
335 |
; |
; |
336 |
; void transfer_8to16sub2_xmm(int16_t * const dct, |
; void transfer_8to16sub2_xmm(int16_t * const dct, |
337 |
; uint8_t * const cur, |
; uint8_t * const cur, |
339 |
; const uint8_t * ref2, |
; const uint8_t * ref2, |
340 |
; const uint32_t stride) |
; const uint32_t stride) |
341 |
; |
; |
342 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
343 |
|
|
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 |
351 |
punpcklbw mm2, mm7 |
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 |
punpckhbw mm1, mm7 |
356 |
punpckhbw mm3, mm7 |
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 |
359 |
|
movq [eax+edx], mm5 |
360 |
|
|
361 |
movq mm6, mm4 |
movq mm6, mm4 |
362 |
punpcklbw mm4, mm7 |
punpcklbw mm4, mm7 |
378 |
movq [ecx+%1*32+24], mm3 |
movq [ecx+%1*32+24], mm3 |
379 |
%endmacro |
%endmacro |
380 |
|
|
381 |
align 16 |
ALIGN 16 |
382 |
transfer_8to16sub2_xmm: |
transfer_8to16sub2_xmm: |
383 |
mov ecx, [esp + 4] ; Dst |
mov ecx, [esp + 4] ; Dst |
384 |
mov eax, [esp + 8] ; Cur |
mov eax, [esp + 8] ; Cur |
397 |
pop esi |
pop esi |
398 |
pop ebx |
pop ebx |
399 |
ret |
ret |
400 |
|
.endfunc |
401 |
|
|
402 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
403 |
; |
; |
404 |
; void transfer_16to8add_mmx(uint8_t * const dst, |
; void transfer_16to8add_mmx(uint8_t * const dst, |
405 |
; const int16_t * const src, |
; const int16_t * const src, |
406 |
; uint32_t stride); |
; uint32_t stride); |
407 |
; |
; |
408 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
409 |
|
|
410 |
%macro COPY_16_TO_8_ADD 1 |
%macro COPY_16_TO_8_ADD 1 |
411 |
movq mm0, [ecx] |
movq mm0, [ecx] |
427 |
%endmacro |
%endmacro |
428 |
|
|
429 |
|
|
430 |
align 16 |
ALIGN 16 |
431 |
transfer_16to8add_mmx: |
transfer_16to8add_mmx: |
432 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
433 |
mov eax, [esp+ 8] ; Src |
mov eax, [esp+ 8] ; Src |
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 |
; |
; |
449 |
; void transfer8x8_copy_mmx(uint8_t * const dst, |
; void transfer8x8_copy_mmx(uint8_t * const dst, |
450 |
; const uint8_t * const src, |
; const uint8_t * const src, |
451 |
; const uint32_t stride); |
; const uint32_t stride); |
452 |
; |
; |
453 |
; |
; |
454 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
455 |
|
|
456 |
%macro COPY_8_TO_8 0 |
%macro COPY_8_TO_8 0 |
457 |
movq mm0, [eax] |
movq mm0, [eax] |
461 |
movq [ecx+edx], mm1 |
movq [ecx+edx], mm1 |
462 |
%endmacro |
%endmacro |
463 |
|
|
464 |
align 16 |
ALIGN 16 |
465 |
transfer8x8_copy_mmx: |
transfer8x8_copy_mmx: |
466 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
467 |
mov eax, [esp+ 8] ; Src |
mov eax, [esp+ 8] ; Src |
475 |
lea ecx,[ecx+2*edx] |
lea ecx,[ecx+2*edx] |
476 |
COPY_8_TO_8 |
COPY_8_TO_8 |
477 |
ret |
ret |
478 |
|
.endfunc |
479 |
|
|