[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 329 - (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 : suxen_drol 329
36 : Isibaar 262 %macro cglobal 1
37 :     %ifdef PREFIX
38 :     global _%1
39 :     %define %1 _%1
40 :     %else
41 :     global %1
42 :     %endif
43 :     %endmacro
44 :    
45 :     section .data
46 :    
47 :     align 16
48 :     mmx_one times 4 dw 1
49 :    
50 :     section .text
51 :    
52 :     cglobal sad16_xmm
53 :     cglobal sad8_xmm
54 :     cglobal sad16bi_xmm
55 :     cglobal sad8bi_xmm
56 :     cglobal dev16_xmm
57 :    
58 :     ;===========================================================================
59 :     ;
60 :     ; uint32_t sad16_xmm(const uint8_t * const cur,
61 :     ; const uint8_t * const ref,
62 : suxen_drol 329 ; const uint32_t stride,
63 : Isibaar 262 ; const uint32_t best_sad);
64 : suxen_drol 329 ;
65 : Isibaar 262 ;===========================================================================
66 :    
67 :     %macro SAD_16x16_SSE 0
68 :     movq mm0, [eax]
69 :     psadbw mm0, [edx]
70 :     movq mm1, [eax+8]
71 :     add eax, ecx
72 :     psadbw mm1, [edx+8]
73 :     paddusw mm5,mm0
74 :     add edx, ecx
75 :     paddusw mm6,mm1
76 :     %endmacro
77 :    
78 :     align 16
79 :     sad16_xmm:
80 :    
81 :     mov eax, [esp+ 4] ; Src1
82 :     mov edx, [esp+ 8] ; Src2
83 :     mov ecx, [esp+12] ; Stride
84 :    
85 :     pxor mm5, mm5 ; accum1
86 :     pxor mm6, mm6 ; accum2
87 :    
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 :     SAD_16x16_SSE
95 :     SAD_16x16_SSE
96 :    
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 :     SAD_16x16_SSE
104 :     SAD_16x16_SSE
105 :    
106 :     paddusw mm6,mm5
107 :     movd eax, mm6
108 :     ret
109 :    
110 :    
111 :     ;===========================================================================
112 :     ;
113 :     ; uint32_t sad8_xmm(const uint8_t * const cur,
114 :     ; const uint8_t * const ref,
115 :     ; const uint32_t stride);
116 :     ;
117 :     ;===========================================================================
118 :    
119 : suxen_drol 329 %macro SAD_8x8_SSE 0
120 :     movq mm0, [eax]
121 :     movq mm1, [eax+ecx]
122 :    
123 :     psadbw mm0, [edx]
124 :     psadbw mm1, [edx+ecx]
125 :     add eax, ebx
126 :     add edx, ebx
127 :    
128 :     paddusw mm5,mm0
129 :     paddusw mm6,mm1
130 :     %endmacro
131 :    
132 :     align 16
133 :     sad8_xmm:
134 :    
135 :     mov eax, [esp+ 4] ; Src1
136 :     mov edx, [esp+ 8] ; Src2
137 :     mov ecx, [esp+12] ; Stride
138 :     push ebx
139 :     lea ebx, [ecx+ecx]
140 :    
141 :     pxor mm5, mm5 ; accum1
142 :     pxor mm6, mm6 ; accum2
143 :    
144 :     SAD_8x8_SSE
145 :     SAD_8x8_SSE
146 :     SAD_8x8_SSE
147 :    
148 :     movq mm0, [eax]
149 :     movq mm1, [eax+ecx]
150 :     psadbw mm0, [edx]
151 :     psadbw mm1, [edx+ecx]
152 :    
153 :     pop ebx
154 :    
155 :     paddusw mm5,mm0
156 :     paddusw mm6,mm1
157 :    
158 :     paddusw mm6,mm5
159 :     movd eax, mm6
160 :    
161 :     ret
162 :    
163 :    
164 :     ;===========================================================================
165 :     ;
166 :     ; uint32_t sad16bi_xmm(const uint8_t * const cur,
167 :     ; const uint8_t * const ref1,
168 :     ; const uint8_t * const ref2,
169 :     ; const uint32_t stride);
170 :     ;
171 :     ;===========================================================================
172 :    
173 : Isibaar 262 %macro SADBI_16x16_SSE 0
174 :     movq mm0, [eax]
175 :     movq mm1, [eax+8]
176 :    
177 :     movq mm2, [edx]
178 :     movq mm3, [edx+8]
179 :    
180 :     pavgb mm2, [ebx]
181 :     add edx, ecx
182 :    
183 :     pavgb mm3, [ebx+8]
184 :     add ebx, ecx
185 :    
186 :     psadbw mm0, mm2
187 :     add eax, ecx
188 :    
189 :     psadbw mm1, mm3
190 :     paddusw mm5,mm0
191 :    
192 :     paddusw mm6,mm1
193 :     %endmacro
194 :    
195 :     align 16
196 :     sad16bi_xmm:
197 :     push ebx
198 :     mov eax, [esp+4+ 4] ; Src
199 :     mov edx, [esp+4+ 8] ; Ref1
200 :     mov ebx, [esp+4+12] ; Ref2
201 :     mov ecx, [esp+4+16] ; Stride
202 :    
203 :     pxor mm5, mm5 ; accum1
204 :     pxor mm6, mm6 ; accum2
205 :    
206 :     SADBI_16x16_SSE
207 :     SADBI_16x16_SSE
208 :     SADBI_16x16_SSE
209 :     SADBI_16x16_SSE
210 :     SADBI_16x16_SSE
211 :     SADBI_16x16_SSE
212 :     SADBI_16x16_SSE
213 :     SADBI_16x16_SSE
214 :    
215 :     SADBI_16x16_SSE
216 :     SADBI_16x16_SSE
217 :     SADBI_16x16_SSE
218 :     SADBI_16x16_SSE
219 :     SADBI_16x16_SSE
220 :     SADBI_16x16_SSE
221 :     SADBI_16x16_SSE
222 :     SADBI_16x16_SSE
223 :    
224 :     paddusw mm6,mm5
225 :     movd eax, mm6
226 :     pop ebx
227 :     ret
228 :    
229 :     ;===========================================================================
230 :     ;
231 :     ; uint32_t sad8bi_xmm(const uint8_t * const cur,
232 :     ; const uint8_t * const ref1,
233 :     ; const uint8_t * const ref2,
234 :     ; const uint32_t stride);
235 :     ;
236 :     ;===========================================================================
237 :    
238 : suxen_drol 329 %macro SADBI_8x8_XMM 0
239 :     movq mm0, [eax]
240 :     movq mm1, [eax+ecx]
241 : Isibaar 262
242 : suxen_drol 329 movq mm2, [edx]
243 :     movq mm3, [edx+ecx]
244 : Isibaar 262
245 : suxen_drol 329 pavgb mm2, [ebx]
246 :     lea edx, [edx+2*ecx]
247 : Isibaar 262
248 : suxen_drol 329 pavgb mm3, [ebx+ecx]
249 :     lea ebx, [ebx+2*ecx]
250 : Isibaar 262
251 : suxen_drol 329 psadbw mm0, mm2
252 :     lea eax, [eax+2*ecx]
253 : Isibaar 262
254 : suxen_drol 329 psadbw mm1, mm3
255 :     paddusw mm5,mm0
256 : Isibaar 262
257 : suxen_drol 329 paddusw mm6,mm1
258 :     %endmacro
259 : Isibaar 262
260 : suxen_drol 329 align 16
261 :     sad8bi_xmm:
262 :     push ebx
263 :     mov eax, [esp+4+ 4] ; Src
264 :     mov edx, [esp+4+ 8] ; Ref1
265 :     mov ebx, [esp+4+12] ; Ref2
266 :     mov ecx, [esp+4+16] ; Stride
267 : Isibaar 262
268 : suxen_drol 329 pxor mm5, mm5 ; accum1
269 :     pxor mm6, mm6 ; accum2
270 :     .Loop
271 :     SADBI_8x8_XMM
272 :     SADBI_8x8_XMM
273 :     SADBI_8x8_XMM
274 :     SADBI_8x8_XMM
275 : Isibaar 262
276 : suxen_drol 329 paddusw mm6,mm5
277 :     movd eax, mm6
278 :     pop ebx
279 :     ret
280 : Isibaar 262
281 : suxen_drol 329
282 :     ;===========================================================================
283 :     ;
284 :     ; uint32_t dev16_xmm(const uint8_t * const cur,
285 :     ; const uint32_t stride);
286 :     ;
287 :     ;===========================================================================
288 :    
289 :     %macro MEAN_16x16_SSE 0
290 : Isibaar 262 movq mm0, [eax]
291 :     movq mm1, [eax+8]
292 :     psadbw mm0, mm7
293 :     psadbw mm1, mm7
294 :     add eax, ecx
295 :     paddw mm5, mm0
296 :     paddw mm6, mm1
297 :     %endmacro
298 :    
299 :     %macro ABS_16x16_SSE 0
300 :     movq mm0, [eax]
301 :     movq mm1, [eax+8]
302 :     psadbw mm0, mm4
303 :     psadbw mm1, mm4
304 :     lea eax,[eax+ecx]
305 :     paddw mm5, mm0
306 :     paddw mm6, mm1
307 :     %endmacro
308 :    
309 :     align 16
310 :     dev16_xmm:
311 :    
312 :     mov eax, [esp+ 4] ; Src
313 :     mov ecx, [esp+ 8] ; Stride
314 :    
315 :     pxor mm7, mm7 ; zero
316 :     pxor mm5, mm5 ; mean accums
317 :     pxor mm6, mm6
318 :    
319 :     MEAN_16x16_SSE
320 :     MEAN_16x16_SSE
321 :     MEAN_16x16_SSE
322 :     MEAN_16x16_SSE
323 :     MEAN_16x16_SSE
324 :     MEAN_16x16_SSE
325 :     MEAN_16x16_SSE
326 :     MEAN_16x16_SSE
327 :    
328 :     MEAN_16x16_SSE
329 :     MEAN_16x16_SSE
330 :     MEAN_16x16_SSE
331 :     MEAN_16x16_SSE
332 :     MEAN_16x16_SSE
333 :     MEAN_16x16_SSE
334 :     MEAN_16x16_SSE
335 :     MEAN_16x16_SSE
336 :    
337 :     paddusw mm6, mm5
338 :    
339 :     movq mm4, mm6
340 :     psllq mm4, 32
341 :     paddd mm4, mm6
342 :     psrld mm4, 8 ; /= (16*16)
343 :    
344 :     packssdw mm4, mm4
345 :     packuswb mm4, mm4
346 :    
347 :     ; mm4 contains the mean
348 :    
349 :     mov eax, [esp+ 4] ; Src
350 :    
351 :     pxor mm5, mm5 ; sums
352 :     pxor mm6, mm6
353 :    
354 :     ABS_16x16_SSE
355 :     ABS_16x16_SSE
356 :     ABS_16x16_SSE
357 :     ABS_16x16_SSE
358 :     ABS_16x16_SSE
359 :     ABS_16x16_SSE
360 :     ABS_16x16_SSE
361 :     ABS_16x16_SSE
362 :    
363 :     ABS_16x16_SSE
364 :     ABS_16x16_SSE
365 :     ABS_16x16_SSE
366 :     ABS_16x16_SSE
367 :     ABS_16x16_SSE
368 :     ABS_16x16_SSE
369 :     ABS_16x16_SSE
370 :     ABS_16x16_SSE
371 :    
372 :     paddusw mm6, mm5
373 :     movq mm7, mm6
374 :     psllq mm7, 32
375 :     paddd mm6, mm7
376 :    
377 :     movd eax, mm6
378 :     ret

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