[svn] / trunk / xvidcore / src / motion / x86_asm / sad_xmm.asm Repository:
ViewVC logotype

Annotation of /trunk/xvidcore/src/motion/x86_asm/sad_xmm.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 262 - (view) (download)

1 : Isibaar 262 ;/**************************************************************************
2 :     ; *
3 :     ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * xmm sum of absolute difference
5 :     ; *
6 :     ; * This program is free software; you can redistribute it and/or modify
7 :     ; * it under the terms of the GNU General Public License as published by
8 :     ; * the Free Software Foundation; either version 2 of the License, or
9 :     ; * (at your option) any later version.
10 :     ; *
11 :     ; * This program is distributed in the hope that it will be useful,
12 :     ; * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 :     ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 :     ; * GNU General Public License for more details.
15 :     ; *
16 :     ; * You should have received a copy of the GNU General Public License
17 :     ; * along with this program; if not, write to the Free Software
18 :     ; * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 :     ; *
20 :     ; *************************************************************************/
21 :    
22 :     ;/**************************************************************************
23 :     ; *
24 :     ; * History:
25 :     ; *
26 :     ; * 23.07.2002 sad8bi_xmm; <pross@xvid.org>
27 :     ; * 04.06.2002 rewrote some funcs (XMM mainly) -Skal-
28 :     ; * 17.11.2001 bugfix and small improvement for dev16_xmm,
29 :     ; * removed terminate early in sad16_xmm (Isibaar)
30 :     ; * 12.11.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au>
31 :     ; *
32 :     ; *************************************************************************/
33 :    
34 :     bits 32
35 :     %macro cglobal 1
36 :     %ifdef PREFIX
37 :     global _%1
38 :     %define %1 _%1
39 :     %else
40 :     global %1
41 :     %endif
42 :     %endmacro
43 :    
44 :     section .data
45 :    
46 :     align 16
47 :     mmx_one times 4 dw 1
48 :    
49 :     section .text
50 :    
51 :     cglobal sad16_xmm
52 :     cglobal sad8_xmm
53 :     cglobal sad16bi_xmm
54 :     cglobal sad8bi_xmm
55 :     cglobal dev16_xmm
56 :    
57 :     ;===========================================================================
58 :     ;
59 :     ; uint32_t sad16_xmm(const uint8_t * const cur,
60 :     ; const uint8_t * const ref,
61 :     ; const uint32_t best_sad);
62 :     cglobal sad8_xmm
63 :     ;===========================================================================
64 :    
65 :     %macro SAD_16x16_SSE 0
66 :     movq mm0, [eax]
67 :     psadbw mm0, [edx]
68 :     movq mm1, [eax+8]
69 :     add eax, ecx
70 :     psadbw mm1, [edx+8]
71 :     paddusw mm5,mm0
72 :     add edx, ecx
73 :     paddusw mm6,mm1
74 :     %endmacro
75 :    
76 :     align 16
77 :     sad16_xmm:
78 :    
79 :     mov eax, [esp+ 4] ; Src1
80 :     mov edx, [esp+ 8] ; Src2
81 :     mov ecx, [esp+12] ; Stride
82 :    
83 :     pxor mm5, mm5 ; accum1
84 :     pxor mm6, mm6 ; accum2
85 :    
86 :     SAD_16x16_SSE
87 :     SAD_16x16_SSE
88 :     SAD_16x16_SSE
89 :     SAD_16x16_SSE
90 :     SAD_16x16_SSE
91 :     SAD_16x16_SSE
92 :     SAD_16x16_SSE
93 :     SAD_16x16_SSE
94 :    
95 :     SAD_16x16_SSE
96 :     SAD_16x16_SSE
97 :     SAD_16x16_SSE
98 :     SAD_16x16_SSE
99 :     SAD_16x16_SSE
100 :     SAD_16x16_SSE
101 :     SAD_16x16_SSE
102 :     SAD_16x16_SSE
103 :    
104 :     paddusw mm6,mm5
105 :     movd eax, mm6
106 :     ret
107 :    
108 :    
109 :     ;===========================================================================
110 :     ;
111 :     ; uint32_t sad8_xmm(const uint8_t * const cur,
112 :     ; const uint8_t * const ref,
113 :     ; const uint32_t stride);
114 :     ;
115 :     ;===========================================================================
116 :    
117 :     %macro SADBI_16x16_SSE 0
118 :     movq mm0, [eax]
119 :     movq mm1, [eax+8]
120 :    
121 :     movq mm2, [edx]
122 :     movq mm3, [edx+8]
123 :    
124 :     pavgb mm2, [ebx]
125 :     add edx, ecx
126 :    
127 :     pavgb mm3, [ebx+8]
128 :     add ebx, ecx
129 :    
130 :     psadbw mm0, mm2
131 :     add eax, ecx
132 :    
133 :     psadbw mm1, mm3
134 :     paddusw mm5,mm0
135 :    
136 :     paddusw mm6,mm1
137 :     %endmacro
138 :    
139 :     align 16
140 :     sad16bi_xmm:
141 :     push ebx
142 :     mov eax, [esp+4+ 4] ; Src
143 :     mov edx, [esp+4+ 8] ; Ref1
144 :     mov ebx, [esp+4+12] ; Ref2
145 :     mov ecx, [esp+4+16] ; Stride
146 :    
147 :     pxor mm5, mm5 ; accum1
148 :     pxor mm6, mm6 ; accum2
149 :    
150 :     SADBI_16x16_SSE
151 :     SADBI_16x16_SSE
152 :     SADBI_16x16_SSE
153 :     SADBI_16x16_SSE
154 :     SADBI_16x16_SSE
155 :     SADBI_16x16_SSE
156 :     SADBI_16x16_SSE
157 :     SADBI_16x16_SSE
158 :    
159 :     SADBI_16x16_SSE
160 :     SADBI_16x16_SSE
161 :     SADBI_16x16_SSE
162 :     SADBI_16x16_SSE
163 :     SADBI_16x16_SSE
164 :     SADBI_16x16_SSE
165 :     SADBI_16x16_SSE
166 :     SADBI_16x16_SSE
167 :    
168 :     paddusw mm6,mm5
169 :     movd eax, mm6
170 :     pop ebx
171 :     ret
172 :    
173 :     ;===========================================================================
174 :     ;
175 :     ; uint32_t sad8bi_xmm(const uint8_t * const cur,
176 :     ; const uint8_t * const ref1,
177 :     ; const uint8_t * const ref2,
178 :     ; const uint32_t stride);
179 :     ;
180 :     ;===========================================================================
181 :    
182 :     ;===========================================================================
183 :     ;
184 :     ; uint32_t sad8_xmm(const uint8_t * const cur,
185 :     ; const uint8_t * const ref,
186 :     ; const uint32_t stride);
187 :     ;
188 :     ;===========================================================================
189 :    
190 :     %macro SAD_8x8_SSE 0
191 :     movq mm0, [eax]
192 :     movq mm1, [eax+ecx]
193 :     %macro MEAN_16x16_SSE 0
194 :     psadbw mm0, [edx]
195 :     psadbw mm1, [edx+ecx]
196 :     add eax, ebx
197 :     add edx, ebx
198 :    
199 :     paddusw mm5,mm0
200 :     paddusw mm6,mm1
201 :     %endmacro
202 :    
203 :     align 16
204 :     sad8_xmm:
205 :    
206 :     mov eax, [esp+ 4] ; Src1
207 :     mov edx, [esp+ 8] ; Src2
208 :     mov ecx, [esp+12] ; Stride
209 :     push ebx
210 :     lea ebx, [ecx+ecx]
211 :    
212 :     pxor mm5, mm5 ; accum1
213 :     pxor mm6, mm6 ; accum2
214 :    
215 :     SAD_8x8_SSE
216 :     SAD_8x8_SSE
217 :     SAD_8x8_SSE
218 :    
219 :     movq mm0, [eax]
220 :     movq mm1, [eax+ecx]
221 :     psadbw mm0, [edx]
222 :     psadbw mm1, [edx+ecx]
223 :    
224 :     pop ebx
225 :    
226 :     paddusw mm5,mm0
227 :     paddusw mm6,mm1
228 :    
229 :     paddusw mm6,mm5
230 :     movd eax, mm6
231 :    
232 :     ret
233 :     movq mm0, [eax]
234 :     movq mm1, [eax+8]
235 :     psadbw mm0, mm7
236 :     psadbw mm1, mm7
237 :     add eax, ecx
238 :     paddw mm5, mm0
239 :     paddw mm6, mm1
240 :     %endmacro
241 :    
242 :     %macro ABS_16x16_SSE 0
243 :     movq mm0, [eax]
244 :     movq mm1, [eax+8]
245 :     psadbw mm0, mm4
246 :     psadbw mm1, mm4
247 :     lea eax,[eax+ecx]
248 :     paddw mm5, mm0
249 :     paddw mm6, mm1
250 :     %endmacro
251 :    
252 :     align 16
253 :     dev16_xmm:
254 :    
255 :     mov eax, [esp+ 4] ; Src
256 :     mov ecx, [esp+ 8] ; Stride
257 :    
258 :     pxor mm7, mm7 ; zero
259 :     pxor mm5, mm5 ; mean accums
260 :     pxor mm6, mm6
261 :    
262 :     MEAN_16x16_SSE
263 :     MEAN_16x16_SSE
264 :     MEAN_16x16_SSE
265 :     MEAN_16x16_SSE
266 :     MEAN_16x16_SSE
267 :     MEAN_16x16_SSE
268 :     MEAN_16x16_SSE
269 :     MEAN_16x16_SSE
270 :    
271 :     MEAN_16x16_SSE
272 :     MEAN_16x16_SSE
273 :     MEAN_16x16_SSE
274 :     MEAN_16x16_SSE
275 :     MEAN_16x16_SSE
276 :     MEAN_16x16_SSE
277 :     MEAN_16x16_SSE
278 :     MEAN_16x16_SSE
279 :    
280 :     paddusw mm6, mm5
281 :    
282 :     movq mm4, mm6
283 :     psllq mm4, 32
284 :     paddd mm4, mm6
285 :     psrld mm4, 8 ; /= (16*16)
286 :    
287 :     packssdw mm4, mm4
288 :     packuswb mm4, mm4
289 :    
290 :     ; mm4 contains the mean
291 :    
292 :     mov eax, [esp+ 4] ; Src
293 :    
294 :     pxor mm5, mm5 ; sums
295 :     pxor mm6, mm6
296 :    
297 :     ABS_16x16_SSE
298 :     ABS_16x16_SSE
299 :     ABS_16x16_SSE
300 :     ABS_16x16_SSE
301 :     ABS_16x16_SSE
302 :     ABS_16x16_SSE
303 :     ABS_16x16_SSE
304 :     ABS_16x16_SSE
305 :    
306 :     ABS_16x16_SSE
307 :     ABS_16x16_SSE
308 :     ABS_16x16_SSE
309 :     ABS_16x16_SSE
310 :     ABS_16x16_SSE
311 :     ABS_16x16_SSE
312 :     ABS_16x16_SSE
313 :     ABS_16x16_SSE
314 :    
315 :     paddusw mm6, mm5
316 :     movq mm7, mm6
317 :     psllq mm7, 32
318 :     paddd mm6, mm7
319 :    
320 :     movd eax, mm6
321 :     ret

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4