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 |
|
%else |
37 |
global _%1 |
global _%1 |
38 |
%define %1 _%1 |
%define %1 _%1 |
39 |
|
%endif |
40 |
|
%else |
41 |
|
%ifdef MARK_FUNCS |
42 |
|
global %1:function %1.endfunc-%1 |
43 |
%else |
%else |
44 |
global %1 |
global %1 |
45 |
%endif |
%endif |
46 |
|
%endif |
47 |
%endmacro |
%endmacro |
48 |
|
|
49 |
|
;============================================================================= |
50 |
|
; Read only data |
51 |
|
;============================================================================= |
52 |
|
|
53 |
|
%ifdef FORMAT_COFF |
54 |
|
SECTION .rodata |
55 |
|
%else |
56 |
|
SECTION .rodata align=16 |
57 |
|
%endif |
58 |
|
|
59 |
|
ALIGN 8 |
60 |
|
mm_zero: |
61 |
|
dd 0,0 |
62 |
|
;============================================================================= |
63 |
|
; Macros |
64 |
|
;============================================================================= |
65 |
|
|
66 |
%macro nop4 0 |
%macro nop4 0 |
67 |
DB 08Dh,074h,026h,0 |
db 08Dh, 074h, 026h, 0 |
68 |
%endmacro |
%endmacro |
69 |
|
|
70 |
section .text |
;============================================================================= |
71 |
|
; Code |
72 |
|
;============================================================================= |
73 |
|
|
74 |
|
SECTION .text |
75 |
|
|
76 |
cglobal transfer_8to16copy_3dne |
cglobal transfer_8to16copy_3dne |
77 |
cglobal transfer_16to8copy_3dne |
cglobal transfer_16to8copy_3dne |
81 |
cglobal transfer_16to8add_3dne |
cglobal transfer_16to8add_3dne |
82 |
cglobal transfer8x8_copy_3dne |
cglobal transfer8x8_copy_3dne |
83 |
|
|
84 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
85 |
; |
; |
86 |
; void transfer_8to16copy_3dne(int16_t * const dst, |
; void transfer_8to16copy_3dne(int16_t * const dst, |
87 |
; const uint8_t * const src, |
; const uint8_t * const src, |
88 |
; uint32_t stride); |
; uint32_t stride); |
89 |
; |
; |
90 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
91 |
|
|
92 |
align 16 |
ALIGN 16 |
93 |
transfer_8to16copy_3dne: |
transfer_8to16copy_3dne: |
94 |
|
|
95 |
mov eax, [esp+ 8] ; Src |
mov eax, [esp+ 8] ; Src |
148 |
movq [byte ecx+1*64+48], mm6 |
movq [byte ecx+1*64+48], mm6 |
149 |
movq [ecx+1*64+40], mm7 |
movq [ecx+1*64+40], mm7 |
150 |
ret |
ret |
151 |
|
.endfunc |
152 |
|
|
153 |
|
|
154 |
|
;----------------------------------------------------------------------------- |
|
;=========================================================================== |
|
155 |
; |
; |
156 |
; void transfer_16to8copy_3dne(uint8_t * const dst, |
; void transfer_16to8copy_3dne(uint8_t * const dst, |
157 |
; const int16_t * const src, |
; const int16_t * const src, |
158 |
; uint32_t stride); |
; uint32_t stride); |
159 |
; |
; |
160 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
161 |
|
|
162 |
align 16 |
ALIGN 16 |
163 |
transfer_16to8copy_3dne: |
transfer_16to8copy_3dne: |
164 |
|
|
165 |
mov eax, [esp+ 8] ; Src |
mov eax, [esp+ 8] ; Src |
194 |
movq [eax+4*edx], mm7 |
movq [eax+4*edx], mm7 |
195 |
movq [ecx+2*edx], mm6 |
movq [ecx+2*edx], mm6 |
196 |
ret |
ret |
197 |
|
.endfunc |
198 |
|
|
199 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
200 |
; |
; |
201 |
; void transfer_8to16sub_3dne(int16_t * const dct, |
; void transfer_8to16sub_3dne(int16_t * const dct, |
202 |
; uint8_t * const cur, |
; uint8_t * const cur, |
203 |
; const uint8_t * const ref, |
; const uint8_t * const ref, |
204 |
; const uint32_t stride); |
; const uint32_t stride); |
205 |
; |
; |
206 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
|
;/************************************************************************** |
|
|
; * |
|
|
; * 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> |
|
|
; * |
|
|
; *************************************************************************/ |
|
207 |
|
|
208 |
; when second argument == 1, reference (ebx) block is to current (eax) |
; when second argument == 1, reference (ebx) block is to current (eax) |
209 |
%macro COPY_8_TO_16_SUB 2 |
%macro COPY_8_TO_16_SUB 2 |
217 |
punpckhbw mm1, mm7 |
punpckhbw mm1, mm7 |
218 |
punpckhbw mm6, mm7 |
punpckhbw mm6, mm7 |
219 |
punpcklbw mm4, mm7 |
punpcklbw mm4, mm7 |
220 |
align 8 |
ALIGN 8 |
221 |
movq mm2, [byte eax+edx] |
movq mm2, [byte eax+edx] |
222 |
punpcklbw mm0, mm7 |
punpcklbw mm0, mm7 |
223 |
movq mm3, [byte eax+edx] |
movq mm3, [byte eax+edx] |
248 |
movq [edi+%1*32+24], mm3 |
movq [edi+%1*32+24], mm3 |
249 |
%endmacro |
%endmacro |
250 |
|
|
251 |
align 16 |
ALIGN 16 |
252 |
transfer_8to16sub_3dne: |
transfer_8to16sub_3dne: |
253 |
mov eax, [esp + 8] ; Cur |
mov eax, [esp + 8] ; Cur |
254 |
mov ecx, [esp +12] ; Ref |
mov ecx, [esp +12] ; Ref |
257 |
mov edi, [esp+4+ 4] ; Dst |
mov edi, [esp+4+ 4] ; Dst |
258 |
pxor mm7, mm7 |
pxor mm7, mm7 |
259 |
nop |
nop |
260 |
align 4 |
ALIGN 4 |
261 |
COPY_8_TO_16_SUB 0, 1 |
COPY_8_TO_16_SUB 0, 1 |
262 |
COPY_8_TO_16_SUB 1, 1 |
COPY_8_TO_16_SUB 1, 1 |
263 |
COPY_8_TO_16_SUB 2, 1 |
COPY_8_TO_16_SUB 2, 1 |
264 |
COPY_8_TO_16_SUB 3, 1 |
COPY_8_TO_16_SUB 3, 1 |
265 |
mov edi,ecx |
mov edi,ecx |
266 |
ret |
ret |
267 |
|
.endfunc |
268 |
|
|
269 |
align 16 |
ALIGN 16 |
270 |
transfer_8to16subro_3dne: |
transfer_8to16subro_3dne: |
271 |
mov eax, [esp + 8] ; Cur |
mov eax, [esp + 8] ; Cur |
272 |
mov ecx, [esp +12] ; Ref |
mov ecx, [esp +12] ; Ref |
275 |
mov edi, [esp+4+ 4] ; Dst |
mov edi, [esp+4+ 4] ; Dst |
276 |
pxor mm7, mm7 |
pxor mm7, mm7 |
277 |
nop |
nop |
278 |
align 4 |
ALIGN 4 |
279 |
COPY_8_TO_16_SUB 0, 0 |
COPY_8_TO_16_SUB 0, 0 |
280 |
COPY_8_TO_16_SUB 1, 0 |
COPY_8_TO_16_SUB 1, 0 |
281 |
COPY_8_TO_16_SUB 2, 0 |
COPY_8_TO_16_SUB 2, 0 |
282 |
COPY_8_TO_16_SUB 3, 0 |
COPY_8_TO_16_SUB 3, 0 |
283 |
mov edi,ecx |
mov edi,ecx |
284 |
ret |
ret |
285 |
|
.endfunc |
286 |
|
|
287 |
|
|
288 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
289 |
; |
; |
290 |
; void transfer_8to16sub2_3dne(int16_t * const dct, |
; void transfer_8to16sub2_3dne(int16_t * const dct, |
291 |
; uint8_t * const cur, |
; uint8_t * const cur, |
293 |
; const uint8_t * ref2, |
; const uint8_t * ref2, |
294 |
; const uint32_t stride) |
; const uint32_t stride) |
295 |
; |
; |
296 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
297 |
|
|
298 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
%macro COPY_8_TO_16_SUB2_SSE 1 |
299 |
db 0Fh, 6Fh, 44h, 20h, 00 ;movq mm0, [byte eax] ; cur |
db 0Fh, 6Fh, 44h, 20h, 00 ;movq mm0, [byte eax] ; cur |
307 |
|
|
308 |
movq mm4, [byte ebx] ; ref1 |
movq mm4, [byte ebx] ; ref1 |
309 |
pavgb mm4, [byte esi] ; ref2 |
pavgb mm4, [byte esi] ; ref2 |
310 |
|
movq [eax], mm4 |
311 |
movq mm5, [ebx+edx] ; ref |
movq mm5, [ebx+edx] ; ref |
312 |
pavgb mm5, [esi+edx] ; ref2 |
pavgb mm5, [esi+edx] ; ref2 |
313 |
|
movq [eax+edx], mm5 |
314 |
movq mm6, mm4 |
movq mm6, mm4 |
315 |
punpcklbw mm4, mm7 |
punpcklbw mm4, mm7 |
316 |
punpckhbw mm6, mm7 |
punpckhbw mm6, mm7 |
336 |
movq [ecx+%1*32+24], mm3 |
movq [ecx+%1*32+24], mm3 |
337 |
%endmacro |
%endmacro |
338 |
|
|
339 |
align 16 |
ALIGN 16 |
340 |
transfer_8to16sub2_3dne: |
transfer_8to16sub2_3dne: |
341 |
mov edx, [esp +20] ; Stride |
mov edx, [esp +20] ; Stride |
342 |
mov ecx, [esp + 4] ; Dst |
mov ecx, [esp + 4] ; Dst |
354 |
COPY_8_TO_16_SUB2_SSE 3 |
COPY_8_TO_16_SUB2_SSE 3 |
355 |
|
|
356 |
ret |
ret |
357 |
|
.endfunc |
358 |
|
|
359 |
|
|
360 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
361 |
; |
; |
362 |
; void transfer_16to8add_3dne(uint8_t * const dst, |
; void transfer_16to8add_3dne(uint8_t * const dst, |
363 |
; const int16_t * const src, |
; const int16_t * const src, |
364 |
; uint32_t stride); |
; uint32_t stride); |
365 |
; |
; |
366 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
367 |
|
|
368 |
%macro COPY_16_TO_8_ADD 1 |
%macro COPY_16_TO_8_ADD 1 |
369 |
db 0Fh, 6Fh, 44h, 21h, 00 ;movq mm0, [byte ecx] |
db 0Fh, 6Fh, 44h, 21h, 00 ;movq mm0, [byte ecx] |
386 |
%endmacro |
%endmacro |
387 |
|
|
388 |
|
|
389 |
align 16 |
ALIGN 16 |
390 |
transfer_16to8add_3dne: |
transfer_16to8add_3dne: |
391 |
mov ecx, [esp+ 4] ; Dst |
mov ecx, [esp+ 4] ; Dst |
392 |
mov edx, [esp+12] ; Stride |
mov edx, [esp+12] ; Stride |
402 |
lea ecx,[byte ecx+2*edx] |
lea ecx,[byte ecx+2*edx] |
403 |
COPY_16_TO_8_ADD 3 |
COPY_16_TO_8_ADD 3 |
404 |
ret |
ret |
405 |
|
.endfunc |
406 |
|
|
407 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
408 |
; |
; |
409 |
; void transfer8x8_copy_3dne(uint8_t * const dst, |
; void transfer8x8_copy_3dne(uint8_t * const dst, |
410 |
; const uint8_t * const src, |
; const uint8_t * const src, |
411 |
; const uint32_t stride); |
; const uint32_t stride); |
412 |
; |
; |
413 |
; |
; |
414 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
415 |
|
|
416 |
%macro COPY_8_TO_8 0 |
%macro COPY_8_TO_8 0 |
417 |
movq mm0, [byte eax] |
movq mm0, [byte eax] |
421 |
movq [ecx+edx], mm1 |
movq [ecx+edx], mm1 |
422 |
%endmacro |
%endmacro |
423 |
|
|
424 |
align 16 |
ALIGN 16 |
425 |
transfer8x8_copy_3dne: |
transfer8x8_copy_3dne: |
426 |
mov eax, [esp+ 8] ; Src |
mov eax, [esp+ 8] ; Src |
427 |
mov edx, [esp+12] ; Stride |
mov edx, [esp+12] ; Stride |
435 |
lea ecx,[byte ecx+2*edx] |
lea ecx,[byte ecx+2*edx] |
436 |
COPY_8_TO_8 |
COPY_8_TO_8 |
437 |
ret |
ret |
438 |
|
.endfunc |
439 |
|
|