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) 2002 Jaan Kalda |
|
; * Video tools as specified in ISO/IEC 14496-2 standard. Those intending |
|
|
; * to use this software module in hardware or software products are |
|
|
; * 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. |
|
7 |
; * |
; * |
8 |
; * This program is free software; you can redistribute it and/or modify |
; * This program is free software; you can redistribute it and/or modify |
9 |
; * 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 |
17 |
; * |
; * |
18 |
; * You should have received a copy of the GNU General Public License |
; * You should have received a copy of the GNU General Public License |
19 |
; * along with this program; if not, write to the Free Software |
; * along with this program; if not, write to the Free Software |
20 |
; * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
; * |
; * |
22 |
; *************************************************************************/ |
; * $Id$ |
23 |
|
; * |
24 |
; these 3dne functions are compatible with iSSE, but are optimized specifically for |
; ***************************************************************************/ |
|
; K7 pipelines |
|
|
; |
|
|
;------------------------------------------------------------------------------ |
|
|
; 09.12.2002 Athlon optimizations contributed by Jaan Kalda |
|
|
;------------------------------------------------------------------------------ |
|
|
|
|
|
|
|
|
bits 32 |
|
|
%ifdef FORMAT_COFF |
|
|
section .data data |
|
|
%else |
|
|
section .data data align=16 |
|
|
%endif |
|
|
|
|
25 |
|
|
26 |
align 8 |
; these 3dne functions are compatible with iSSE, but are optimized specifically |
27 |
mm_zero: |
; for K7 pipelines |
|
dd 0,0 |
|
28 |
|
|
29 |
|
BITS 32 |
30 |
|
|
31 |
%macro cglobal 1 |
%macro cglobal 1 |
32 |
%ifdef PREFIX |
%ifdef PREFIX |
33 |
|
%ifdef MARK_FUNCS |
34 |
|
global _%1:function %1.endfunc-%1 |
35 |
|
%define %1 _%1:function %1.endfunc-%1 |
36 |
|
%define ENDFUNC .endfunc |
37 |
|
%else |
38 |
global _%1 |
global _%1 |
39 |
%define %1 _%1 |
%define %1 _%1 |
40 |
|
%define ENDFUNC |
41 |
|
%endif |
42 |
|
%else |
43 |
|
%ifdef MARK_FUNCS |
44 |
|
global %1:function %1.endfunc-%1 |
45 |
|
%define ENDFUNC .endfunc |
46 |
%else |
%else |
47 |
global %1 |
global %1 |
48 |
|
%define ENDFUNC |
49 |
|
%endif |
50 |
%endif |
%endif |
51 |
%endmacro |
%endmacro |
52 |
|
|
53 |
|
;============================================================================= |
54 |
|
; Read only data |
55 |
|
;============================================================================= |
56 |
|
|
57 |
|
%ifdef FORMAT_COFF |
58 |
|
SECTION .rodata |
59 |
|
%else |
60 |
|
SECTION .rodata align=16 |
61 |
|
%endif |
62 |
|
|
63 |
|
ALIGN 8 |
64 |
|
mm_zero: |
65 |
|
dd 0,0 |
66 |
|
;============================================================================= |
67 |
|
; Macros |
68 |
|
;============================================================================= |
69 |
|
|
70 |
%macro nop4 0 |
%macro nop4 0 |
71 |
DB 08Dh,074h,026h,0 |
db 08Dh, 074h, 026h, 0 |
72 |
%endmacro |
%endmacro |
73 |
|
|
74 |
section .text |
;============================================================================= |
75 |
|
; Code |
76 |
|
;============================================================================= |
77 |
|
|
78 |
|
SECTION .text |
79 |
|
|
80 |
cglobal transfer_8to16copy_3dne |
cglobal transfer_8to16copy_3dne |
81 |
cglobal transfer_16to8copy_3dne |
cglobal transfer_16to8copy_3dne |
84 |
cglobal transfer_8to16sub2_3dne |
cglobal transfer_8to16sub2_3dne |
85 |
cglobal transfer_16to8add_3dne |
cglobal transfer_16to8add_3dne |
86 |
cglobal transfer8x8_copy_3dne |
cglobal transfer8x8_copy_3dne |
87 |
|
cglobal transfer8x4_copy_3dne |
88 |
|
|
89 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
90 |
; |
; |
91 |
; void transfer_8to16copy_3dne(int16_t * const dst, |
; void transfer_8to16copy_3dne(int16_t * const dst, |
92 |
; const uint8_t * const src, |
; const uint8_t * const src, |
93 |
; uint32_t stride); |
; uint32_t stride); |
94 |
; |
; |
95 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
96 |
|
|
97 |
align 16 |
ALIGN 16 |
98 |
transfer_8to16copy_3dne: |
transfer_8to16copy_3dne: |
99 |
|
|
100 |
mov eax, [esp+ 8] ; Src |
mov eax, [esp+ 8] ; Src |
153 |
movq [byte ecx+1*64+48], mm6 |
movq [byte ecx+1*64+48], mm6 |
154 |
movq [ecx+1*64+40], mm7 |
movq [ecx+1*64+40], mm7 |
155 |
ret |
ret |
156 |
|
ENDFUNC |
157 |
|
|
158 |
|
|
159 |
|
;----------------------------------------------------------------------------- |
|
;=========================================================================== |
|
160 |
; |
; |
161 |
; void transfer_16to8copy_3dne(uint8_t * const dst, |
; void transfer_16to8copy_3dne(uint8_t * const dst, |
162 |
; const int16_t * const src, |
; const int16_t * const src, |
163 |
; uint32_t stride); |
; uint32_t stride); |
164 |
; |
; |
165 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
166 |
|
|
167 |
align 16 |
ALIGN 16 |
168 |
transfer_16to8copy_3dne: |
transfer_16to8copy_3dne: |
169 |
|
|
170 |
mov eax, [esp+ 8] ; Src |
mov eax, [esp+ 8] ; Src |
199 |
movq [eax+4*edx], mm7 |
movq [eax+4*edx], mm7 |
200 |
movq [ecx+2*edx], mm6 |
movq [ecx+2*edx], mm6 |
201 |
ret |
ret |
202 |
|
ENDFUNC |
203 |
|
|
204 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
205 |
; |
; |
206 |
; void transfer_8to16sub_3dne(int16_t * const dct, |
; void transfer_8to16sub_3dne(int16_t * const dct, |
207 |
; uint8_t * const cur, |
; uint8_t * const cur, |
208 |
; const uint8_t * const ref, |
; const uint8_t * const ref, |
209 |
; const uint32_t stride); |
; const uint32_t stride); |
210 |
; |
; |
211 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
;/************************************************************************** |
|
|
; * |
|
|
; * 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> |
|
|
; * |
|
|
; *************************************************************************/ |
|
212 |
|
|
213 |
; when second argument == 1, reference (ebx) block is to current (eax) |
; when second argument == 1, reference (ebx) block is to current (eax) |
214 |
%macro COPY_8_TO_16_SUB 2 |
%macro COPY_8_TO_16_SUB 2 |
222 |
punpckhbw mm1, mm7 |
punpckhbw mm1, mm7 |
223 |
punpckhbw mm6, mm7 |
punpckhbw mm6, mm7 |
224 |
punpcklbw mm4, mm7 |
punpcklbw mm4, mm7 |
225 |
align 8 |
ALIGN 8 |
226 |
movq mm2, [byte eax+edx] |
movq mm2, [byte eax+edx] |
227 |
punpcklbw mm0, mm7 |
punpcklbw mm0, mm7 |
228 |
movq mm3, [byte eax+edx] |
movq mm3, [byte eax+edx] |
253 |
movq [edi+%1*32+24], mm3 |
movq [edi+%1*32+24], mm3 |
254 |
%endmacro |
%endmacro |
255 |
|
|
256 |
align 16 |
ALIGN 16 |
257 |
transfer_8to16sub_3dne: |
transfer_8to16sub_3dne: |
258 |
mov eax, [esp + 8] ; Cur |
mov eax, [esp + 8] ; Cur |
259 |
mov ecx, [esp +12] ; Ref |
mov ecx, [esp +12] ; Ref |
260 |
push edi |
push edi |
261 |
mov edx, [dword esp+4+16] ; Stride |
mov edx, [esp+4+16] ; Stride |
262 |
mov edi, [esp+4+ 4] ; Dst |
mov edi, [esp+4+ 4] ; Dst |
263 |
pxor mm7, mm7 |
pxor mm7, mm7 |
264 |
nop |
nop |
265 |
align 4 |
ALIGN 4 |
266 |
COPY_8_TO_16_SUB 0, 1 |
COPY_8_TO_16_SUB 0, 1 |
267 |
COPY_8_TO_16_SUB 1, 1 |
COPY_8_TO_16_SUB 1, 1 |
268 |
COPY_8_TO_16_SUB 2, 1 |
COPY_8_TO_16_SUB 2, 1 |
269 |
COPY_8_TO_16_SUB 3, 1 |
COPY_8_TO_16_SUB 3, 1 |
270 |
mov edi,ecx |
mov edi,ecx |
271 |
ret |
ret |
272 |
|
ENDFUNC |
273 |
|
|
274 |
align 16 |
ALIGN 16 |
275 |
transfer_8to16subro_3dne: |
transfer_8to16subro_3dne: |
276 |
mov eax, [esp + 8] ; Cur |
mov eax, [esp + 8] ; Cur |
277 |
mov ecx, [esp +12] ; Ref |
mov ecx, [esp +12] ; Ref |
278 |
push edi |
push edi |
279 |
mov edx, [dword esp+4+16] ; Stride |
mov edx, [esp+4+16] ; Stride |
280 |
mov edi, [esp+4+ 4] ; Dst |
mov edi, [esp+4+ 4] ; Dst |
281 |
pxor mm7, mm7 |
pxor mm7, mm7 |
282 |
nop |
nop |
283 |
align 4 |
ALIGN 4 |
284 |
COPY_8_TO_16_SUB 0, 0 |
COPY_8_TO_16_SUB 0, 0 |
285 |
COPY_8_TO_16_SUB 1, 0 |
COPY_8_TO_16_SUB 1, 0 |
286 |
COPY_8_TO_16_SUB 2, 0 |
COPY_8_TO_16_SUB 2, 0 |
287 |
COPY_8_TO_16_SUB 3, 0 |
COPY_8_TO_16_SUB 3, 0 |
288 |
mov edi,ecx |
mov edi,ecx |
289 |
ret |
ret |
290 |
|
ENDFUNC |
291 |
|
|
292 |
|
|
293 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
294 |
; |
; |
295 |
; void transfer_8to16sub2_3dne(int16_t * const dct, |
; void transfer_8to16sub2_3dne(int16_t * const dct, |
296 |
; uint8_t * const cur, |
; uint8_t * const cur, |
298 |
; const uint8_t * ref2, |
; const uint8_t * ref2, |
299 |
; const uint32_t stride) |
; const uint32_t stride) |
300 |
; |
; |
301 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
302 |
|
|
303 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
304 |
db 0Fh, 6Fh, 44h, 20h, 00 ;movq mm0, [byte eax] ; cur |
db 0Fh, 6Fh, 44h, 20h, 00 ;movq mm0, [byte eax] ; cur |
312 |
|
|
313 |
movq mm4, [byte ebx] ; ref1 |
movq mm4, [byte ebx] ; ref1 |
314 |
pavgb mm4, [byte esi] ; ref2 |
pavgb mm4, [byte esi] ; ref2 |
315 |
|
movq [eax], mm4 |
316 |
movq mm5, [ebx+edx] ; ref |
movq mm5, [ebx+edx] ; ref |
317 |
pavgb mm5, [esi+edx] ; ref2 |
pavgb mm5, [esi+edx] ; ref2 |
318 |
|
movq [eax+edx], mm5 |
319 |
movq mm6, mm4 |
movq mm6, mm4 |
320 |
punpcklbw mm4, mm7 |
punpcklbw mm4, mm7 |
321 |
punpckhbw mm6, mm7 |
punpckhbw mm6, mm7 |
341 |
movq [ecx+%1*32+24], mm3 |
movq [ecx+%1*32+24], mm3 |
342 |
%endmacro |
%endmacro |
343 |
|
|
344 |
align 16 |
ALIGN 16 |
345 |
transfer_8to16sub2_3dne: |
transfer_8to16sub2_3dne: |
346 |
mov edx, [esp +20] ; Stride |
mov edx, [esp +20] ; Stride |
347 |
mov ecx, [esp + 4] ; Dst |
mov ecx, [esp + 4] ; Dst |
359 |
COPY_8_TO_16_SUB2_SSE 3 |
COPY_8_TO_16_SUB2_SSE 3 |
360 |
|
|
361 |
ret |
ret |
362 |
|
ENDFUNC |
363 |
|
|
364 |
|
|
365 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
366 |
; |
; |
367 |
; void transfer_16to8add_3dne(uint8_t * const dst, |
; void transfer_16to8add_3dne(uint8_t * const dst, |
368 |
; const int16_t * const src, |
; const int16_t * const src, |
369 |
; uint32_t stride); |
; uint32_t stride); |
370 |
; |
; |
371 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
372 |
|
|
373 |
%macro COPY_16_TO_8_ADD 1 |
%macro COPY_16_TO_8_ADD 1 |
374 |
db 0Fh, 6Fh, 44h, 21h, 00 ;movq mm0, [byte ecx] |
db 0Fh, 6Fh, 44h, 21h, 00 ;movq mm0, [byte ecx] |
391 |
%endmacro |
%endmacro |
392 |
|
|
393 |
|
|
394 |
align 16 |
ALIGN 16 |
395 |
transfer_16to8add_3dne: |
transfer_16to8add_3dne: |
396 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
397 |
mov edx, [esp+12] ; Stride |
mov edx, [esp+12] ; Stride |
407 |
lea ecx,[byte ecx+2*edx] |
lea ecx,[byte ecx+2*edx] |
408 |
COPY_16_TO_8_ADD 3 |
COPY_16_TO_8_ADD 3 |
409 |
ret |
ret |
410 |
|
ENDFUNC |
411 |
|
|
412 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
413 |
; |
; |
414 |
; void transfer8x8_copy_3dne(uint8_t * const dst, |
; void transfer8x8_copy_3dne(uint8_t * const dst, |
415 |
; const uint8_t * const src, |
; const uint8_t * const src, |
416 |
; const uint32_t stride); |
; const uint32_t stride); |
417 |
; |
; |
418 |
; |
; |
419 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
420 |
|
|
421 |
%macro COPY_8_TO_8 0 |
%macro COPY_8_TO_8 0 |
422 |
movq mm0, [byte eax] |
movq mm0, [byte eax] |
426 |
movq [ecx+edx], mm1 |
movq [ecx+edx], mm1 |
427 |
%endmacro |
%endmacro |
428 |
|
|
429 |
align 16 |
ALIGN 16 |
430 |
transfer8x8_copy_3dne: |
transfer8x8_copy_3dne: |
431 |
mov eax, [esp+ 8] ; Src |
mov eax, [esp+ 8] ; Src |
432 |
mov edx, [esp+12] ; Stride |
mov edx, [esp+12] ; Stride |
440 |
lea ecx,[byte ecx+2*edx] |
lea ecx,[byte ecx+2*edx] |
441 |
COPY_8_TO_8 |
COPY_8_TO_8 |
442 |
ret |
ret |
443 |
|
ENDFUNC |
444 |
|
|
445 |
|
;----------------------------------------------------------------------------- |
446 |
|
; |
447 |
|
; void transfer8x4_copy_3dne(uint8_t * const dst, |
448 |
|
; const uint8_t * const src, |
449 |
|
; const uint32_t stride); |
450 |
|
; |
451 |
|
; |
452 |
|
;----------------------------------------------------------------------------- |
453 |
|
|
454 |
|
ALIGN 16 |
455 |
|
transfer8x4_copy_3dne: |
456 |
|
mov eax, [esp+ 8] ; Src |
457 |
|
mov edx, [esp+12] ; Stride |
458 |
|
mov ecx, [esp+ 4] ; Dst |
459 |
|
|
460 |
|
COPY_8_TO_8 |
461 |
|
lea ecx,[byte ecx+2*edx] |
462 |
|
COPY_8_TO_8 |
463 |
|
ret |
464 |
|
ENDFUNC |
465 |
|
|
466 |
|
|
467 |
|
%ifidn __OUTPUT_FORMAT__,elf |
468 |
|
section ".note.GNU-stack" noalloc noexec nowrite progbits |
469 |
|
%endif |
470 |
|
|