1 |
;/***************************************************************************** |
;/**************************************************************************** |
2 |
; * |
; * |
3 |
; * XVID MPEG-4 VIDEO CODEC |
; * XVID MPEG-4 VIDEO CODEC |
4 |
; * 3dnow (*but without xmm*) sum of absolute difference |
; * - 3DNow sad operators w/o XMM instructions - |
5 |
; * |
; * |
6 |
; * Copyright(C) 2002 Peter Ross <pross@xvid.org> |
; * Copyright(C) 2002 Peter ross <pross@xvid.org> |
7 |
; * |
; * |
8 |
; * This file is part of XviD, a free MPEG-4 video encoder/decoder |
; * This program is free software; you can redistribute it and/or modify it |
|
; * |
|
|
; * XviD is free software; you can redistribute it and/or modify it |
|
9 |
; * under the terms of the GNU General Public License as published by |
; * under the terms of the GNU General Public License as published by |
10 |
; * the Free Software Foundation; either version 2 of the License, or |
; * the Free Software Foundation; either version 2 of the License, or |
11 |
; * (at your option) any later version. |
; * (at your option) any later version. |
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
; * |
; * |
22 |
; * Under section 8 of the GNU General Public License, the copyright |
; * $Id: sad_3dn.asm,v 1.13 2008-12-04 14:41:50 Isibaar Exp $ |
23 |
; * holders of XVID explicitly forbid distribution in the following |
; * |
24 |
; * countries: |
; ***************************************************************************/ |
|
; * |
|
|
; * - Japan |
|
|
; * - United States of America |
|
|
; * |
|
|
; * Linking XviD statically or dynamically with other modules is making a |
|
|
; * combined work based on XviD. Thus, the terms and conditions of the |
|
|
; * GNU General Public License cover the whole combination. |
|
|
; * |
|
|
; * As a special exception, the copyright holders of XviD give you |
|
|
; * permission to link XviD with independent modules that communicate with |
|
|
; * XviD solely through the VFW1.1 and DShow interfaces, regardless of the |
|
|
; * license terms of these independent modules, and to copy and distribute |
|
|
; * the resulting combined work under terms of your choice, provided that |
|
|
; * every copy of the combined work is accompanied by a complete copy of |
|
|
; * the source code of XviD (the version of XviD used to produce the |
|
|
; * combined work), being distributed under the terms of the GNU General |
|
|
; * Public License plus this exception. An independent module is a module |
|
|
; * which is not derived from or based on XviD. |
|
|
; * |
|
|
; * Note that people who make modified versions of XviD are not obligated |
|
|
; * to grant this special exception for their modified versions; it is |
|
|
; * their choice whether to do so. The GNU General Public License gives |
|
|
; * permission to release a modified version without this exception; this |
|
|
; * exception also makes it possible to release a modified version which |
|
|
; * carries forward this exception. |
|
|
; * |
|
|
; * $Id: sad_3dn.asm,v 1.4 2002-11-17 00:32:06 edgomez Exp $ |
|
|
; * |
|
|
; ****************************************************************************/ |
|
|
|
|
|
bits 32 |
|
|
|
|
|
%macro cglobal 1 |
|
|
%ifdef PREFIX |
|
|
global _%1 |
|
|
%define %1 _%1 |
|
|
%else |
|
|
global %1 |
|
|
%endif |
|
|
%endmacro |
|
25 |
|
|
26 |
section .data |
%include "nasm.inc" |
27 |
|
|
28 |
align 16 |
;============================================================================= |
29 |
mmx_one times 4 dw 1 |
; Read only data |
30 |
|
;============================================================================= |
31 |
|
|
32 |
section .text |
DATA |
33 |
|
|
34 |
cglobal sad16bi_3dn |
ALIGN SECTION_ALIGN |
35 |
cglobal sad8bi_3dn |
mmx_one: |
36 |
|
times 4 dw 1 |
|
;=========================================================================== |
|
|
; |
|
|
; uint32_t sad16bi_3dn(const uint8_t * const cur, |
|
|
; const uint8_t * const ref1, |
|
|
; const uint8_t * const ref2, |
|
|
; const uint32_t stride); |
|
|
; |
|
|
;=========================================================================== |
|
37 |
|
|
38 |
|
;============================================================================= |
39 |
|
; Helper macros |
40 |
|
;============================================================================= |
41 |
%macro SADBI_16x16_3DN 0 |
%macro SADBI_16x16_3DN 0 |
42 |
movq mm0, [eax] ; src |
movq mm0, [_EAX] ; src |
43 |
movq mm2, [eax+8] |
movq mm2, [_EAX+8] |
44 |
|
|
45 |
movq mm1, [edx] ; ref1 |
movq mm1, [TMP1] ; ref1 |
46 |
movq mm3, [edx+8] |
movq mm3, [TMP1+8] |
47 |
pavgusb mm1, [ebx] ; ref2 |
pavgusb mm1, [_EBX] ; ref2 |
48 |
lea edx,[edx+ecx] |
lea TMP1, [TMP1+TMP0] |
49 |
pavgusb mm3, [ebx+8] |
pavgusb mm3, [_EBX+8] |
50 |
lea ebx,[ebx+ecx] |
lea _EBX, [_EBX+TMP0] |
51 |
|
|
52 |
movq mm4, mm0 |
movq mm4, mm0 |
53 |
lea eax,[eax+ecx] |
lea _EAX, [_EAX+TMP0] |
54 |
psubusb mm0, mm1 |
psubusb mm0, mm1 |
55 |
movq mm5, mm2 |
movq mm5, mm2 |
56 |
psubusb mm2, mm3 |
psubusb mm2, mm3 |
74 |
paddusw mm6,mm2 |
paddusw mm6,mm2 |
75 |
%endmacro |
%endmacro |
76 |
|
|
77 |
align 16 |
%macro SADBI_8x8_3DN 0 |
78 |
|
movq mm0, [_EAX] ; src |
79 |
|
movq mm2, [_EAX+TMP0] |
80 |
|
|
81 |
|
movq mm1, [TMP1] ; ref1 |
82 |
|
movq mm3, [TMP1+TMP0] |
83 |
|
pavgusb mm1, [_EBX] ; ref2 |
84 |
|
lea TMP1, [TMP1+2*TMP0] |
85 |
|
pavgusb mm3, [_EBX+TMP0] |
86 |
|
lea _EBX, [_EBX+2*TMP0] |
87 |
|
|
88 |
|
movq mm4, mm0 |
89 |
|
lea _EAX, [_EAX+2*TMP0] |
90 |
|
psubusb mm0, mm1 |
91 |
|
movq mm5, mm2 |
92 |
|
psubusb mm2, mm3 |
93 |
|
|
94 |
|
psubusb mm1, mm4 |
95 |
|
por mm0, mm1 |
96 |
|
psubusb mm3, mm5 |
97 |
|
por mm2, mm3 |
98 |
|
|
99 |
|
movq mm1, mm0 |
100 |
|
movq mm3, mm2 |
101 |
|
|
102 |
|
punpcklbw mm0,mm7 |
103 |
|
punpckhbw mm1,mm7 |
104 |
|
punpcklbw mm2,mm7 |
105 |
|
punpckhbw mm3,mm7 |
106 |
|
|
107 |
|
paddusw mm0,mm1 |
108 |
|
paddusw mm2,mm3 |
109 |
|
paddusw mm6,mm0 |
110 |
|
paddusw mm6,mm2 |
111 |
|
%endmacro |
112 |
|
|
113 |
|
;============================================================================= |
114 |
|
; Code |
115 |
|
;============================================================================= |
116 |
|
|
117 |
|
TEXT |
118 |
|
|
119 |
|
cglobal sad16bi_3dn |
120 |
|
cglobal sad8bi_3dn |
121 |
|
|
122 |
|
;----------------------------------------------------------------------------- |
123 |
|
; |
124 |
|
; uint32_t sad16bi_3dn(const uint8_t * const cur, |
125 |
|
; const uint8_t * const ref1, |
126 |
|
; const uint8_t * const ref2, |
127 |
|
; const uint32_t stride); |
128 |
|
; |
129 |
|
;----------------------------------------------------------------------------- |
130 |
|
|
131 |
|
ALIGN SECTION_ALIGN |
132 |
sad16bi_3dn: |
sad16bi_3dn: |
133 |
push ebx |
mov _EAX, prm1 ; Src |
134 |
mov eax, [esp+4+ 4] ; Src |
mov TMP1, prm2 ; Ref1 |
135 |
mov edx, [esp+4+ 8] ; Ref1 |
mov TMP0, prm4 ; Stride |
136 |
mov ebx, [esp+4+12] ; Ref2 |
|
137 |
mov ecx, [esp+4+16] ; Stride |
push _EBX |
138 |
|
%ifdef ARCH_IS_X86_64 |
139 |
|
mov _EBX, prm3 |
140 |
|
%else |
141 |
|
mov _EBX, [_ESP+4+12] ; Ref2 |
142 |
|
%endif |
143 |
|
|
144 |
pxor mm6, mm6 ; accum2 |
pxor mm6, mm6 ; accum2 |
145 |
pxor mm7, mm7 |
pxor mm7, mm7 |
146 |
.Loop |
.Loop: |
147 |
SADBI_16x16_3DN |
SADBI_16x16_3DN |
148 |
SADBI_16x16_3DN |
SADBI_16x16_3DN |
149 |
SADBI_16x16_3DN |
SADBI_16x16_3DN |
169 |
|
|
170 |
movd eax, mm6 |
movd eax, mm6 |
171 |
|
|
172 |
pop ebx |
pop _EBX |
173 |
|
|
174 |
ret |
ret |
175 |
|
ENDFUNC |
176 |
|
|
177 |
|
;----------------------------------------------------------------------------- |
|
|
|
|
;=========================================================================== |
|
178 |
; |
; |
179 |
; uint32_t sad8bi_3dn(const uint8_t * const cur, |
; uint32_t sad8bi_3dn(const uint8_t * const cur, |
180 |
; const uint8_t * const ref1, |
; const uint8_t * const ref1, |
181 |
; const uint8_t * const ref2, |
; const uint8_t * const ref2, |
182 |
; const uint32_t stride); |
; const uint32_t stride); |
183 |
; |
; |
184 |
;=========================================================================== |
;----------------------------------------------------------------------------- |
185 |
|
|
186 |
%macro SADBI_8x8_3DN 0 |
ALIGN SECTION_ALIGN |
|
movq mm0, [eax] ; src |
|
|
movq mm2, [eax+ecx] |
|
|
|
|
|
movq mm1, [edx] ; ref1 |
|
|
movq mm3, [edx+ecx] |
|
|
pavgusb mm1, [ebx] ; ref2 |
|
|
lea edx,[edx+2*ecx] |
|
|
pavgusb mm3, [ebx+ecx] |
|
|
lea ebx,[ebx+2*ecx] |
|
|
|
|
|
movq mm4, mm0 |
|
|
lea eax,[eax+2*ecx] |
|
|
psubusb mm0, mm1 |
|
|
movq mm5, mm2 |
|
|
psubusb mm2, mm3 |
|
|
|
|
|
psubusb mm1, mm4 |
|
|
por mm0, mm1 |
|
|
psubusb mm3, mm5 |
|
|
por mm2, mm3 |
|
|
|
|
|
movq mm1,mm0 |
|
|
movq mm3,mm2 |
|
|
|
|
|
punpcklbw mm0,mm7 |
|
|
punpckhbw mm1,mm7 |
|
|
punpcklbw mm2,mm7 |
|
|
punpckhbw mm3,mm7 |
|
|
|
|
|
paddusw mm0,mm1 |
|
|
paddusw mm2,mm3 |
|
|
paddusw mm6,mm0 |
|
|
paddusw mm6,mm2 |
|
|
%endmacro |
|
|
|
|
|
align 16 |
|
187 |
sad8bi_3dn: |
sad8bi_3dn: |
188 |
push ebx |
mov _EAX, prm1 ; Src |
189 |
mov eax, [esp+4+ 4] ; Src |
mov TMP1, prm2 ; Ref1 |
190 |
mov edx, [esp+4+ 8] ; Ref1 |
mov TMP0, prm4 ; Stride |
191 |
mov ebx, [esp+4+12] ; Ref2 |
|
192 |
mov ecx, [esp+4+16] ; Stride |
push _EBX |
193 |
|
%ifdef ARCH_IS_X86_64 |
194 |
|
mov _EBX, prm3 |
195 |
|
%else |
196 |
|
mov _EBX, [_ESP+4+12] ; Ref2 |
197 |
|
%endif |
198 |
|
|
199 |
pxor mm6, mm6 ; accum2 |
pxor mm6, mm6 ; accum2 |
200 |
pxor mm7, mm7 |
pxor mm7, mm7 |
201 |
.Loop |
.Loop: |
202 |
SADBI_8x8_3DN |
SADBI_8x8_3DN |
203 |
SADBI_8x8_3DN |
SADBI_8x8_3DN |
204 |
SADBI_8x8_3DN |
SADBI_8x8_3DN |
211 |
|
|
212 |
movd eax, mm6 |
movd eax, mm6 |
213 |
|
|
214 |
pop ebx |
pop _EBX |
215 |
|
|
216 |
ret |
ret |
217 |
|
ENDFUNC |
218 |
|
|
219 |
|
|
220 |
|
%ifidn __OUTPUT_FORMAT__,elf |
221 |
|
section ".note.GNU-stack" noalloc noexec nowrite progbits |
222 |
|
%endif |
223 |
|
|