[svn] / branches / dev-api-4 / xvidcore / src / motion / x86_asm / sad_xmm.asm Repository:
ViewVC logotype

Annotation of /branches/dev-api-4/xvidcore/src/motion/x86_asm/sad_xmm.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 886 - (view) (download)

1 : edgomez 851 ;/**************************************************************************
2 : Isibaar 262 ; *
3 : edgomez 851 ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * xmm sum of absolute difference
5 : Isibaar 262 ; *
6 : edgomez 851 ; * This program is an implementation of a part of one or more MPEG-4
7 :     ; * Video tools as specified in ISO/IEC 14496-2 standard. Those intending
8 :     ; * to use this software module in hardware or software products are
9 :     ; * advised that its use may infringe existing patents or copyrights, and
10 :     ; * any such use would be at such party's own risk. The original
11 :     ; * developer of this software module and his/her company, and subsequent
12 :     ; * editors and their companies, will have no liability for use of this
13 :     ; * software or modifications or derivatives thereof.
14 : Isibaar 262 ; *
15 : edgomez 851 ; * This program is free software; you can redistribute it and/or modify
16 :     ; * it under the terms of the GNU General Public License as published by
17 :     ; * the Free Software Foundation; either version 2 of the License, or
18 :     ; * (at your option) any later version.
19 : Isibaar 262 ; *
20 : edgomez 851 ; * This program is distributed in the hope that it will be useful,
21 :     ; * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 :     ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 :     ; * GNU General Public License for more details.
24 : Isibaar 262 ; *
25 : edgomez 851 ; * You should have received a copy of the GNU General Public License
26 :     ; * along with this program; if not, write to the Free Software
27 :     ; * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 : Isibaar 262 ; *
29 : edgomez 851 ; *************************************************************************/
30 :    
31 :     ;/**************************************************************************
32 : Isibaar 262 ; *
33 : edgomez 851 ; * History:
34 : edgomez 652 ; *
35 : edgomez 851 ; * 23.07.2002 sad8bi_xmm; <pross@xvid.org>
36 :     ; * 04.06.2002 rewrote some funcs (XMM mainly) -Skal-
37 :     ; * 17.11.2001 bugfix and small improvement for dev16_xmm,
38 :     ; * removed terminate early in sad16_xmm (Isibaar)
39 :     ; * 12.11.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au>
40 : edgomez 652 ; *
41 : Isibaar 262 ; *************************************************************************/
42 :    
43 :     bits 32
44 : suxen_drol 329
45 : Isibaar 262 %macro cglobal 1
46 :     %ifdef PREFIX
47 :     global _%1
48 :     %define %1 _%1
49 :     %else
50 :     global %1
51 :     %endif
52 :     %endmacro
53 :    
54 :     section .data
55 :    
56 :     align 16
57 :     mmx_one times 4 dw 1
58 :    
59 :     section .text
60 :    
61 :     cglobal sad16_xmm
62 :     cglobal sad8_xmm
63 :     cglobal sad16bi_xmm
64 :     cglobal sad8bi_xmm
65 :     cglobal dev16_xmm
66 :    
67 :     ;===========================================================================
68 :     ;
69 :     ; uint32_t sad16_xmm(const uint8_t * const cur,
70 :     ; const uint8_t * const ref,
71 : suxen_drol 329 ; const uint32_t stride,
72 : Isibaar 262 ; const uint32_t best_sad);
73 : suxen_drol 329 ;
74 : Isibaar 262 ;===========================================================================
75 :    
76 :     %macro SAD_16x16_SSE 0
77 :     movq mm0, [eax]
78 :     psadbw mm0, [edx]
79 :     movq mm1, [eax+8]
80 :     add eax, ecx
81 :     psadbw mm1, [edx+8]
82 :     paddusw mm5,mm0
83 :     add edx, ecx
84 :     paddusw mm6,mm1
85 :     %endmacro
86 :    
87 :     align 16
88 :     sad16_xmm:
89 :    
90 :     mov eax, [esp+ 4] ; Src1
91 :     mov edx, [esp+ 8] ; Src2
92 :     mov ecx, [esp+12] ; Stride
93 :    
94 :     pxor mm5, mm5 ; accum1
95 :     pxor mm6, mm6 ; accum2
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 :     SAD_16x16_SSE
107 :     SAD_16x16_SSE
108 :     SAD_16x16_SSE
109 :     SAD_16x16_SSE
110 :     SAD_16x16_SSE
111 :     SAD_16x16_SSE
112 :     SAD_16x16_SSE
113 :     SAD_16x16_SSE
114 :    
115 :     paddusw mm6,mm5
116 :     movd eax, mm6
117 :     ret
118 :    
119 :    
120 :     ;===========================================================================
121 :     ;
122 :     ; uint32_t sad8_xmm(const uint8_t * const cur,
123 :     ; const uint8_t * const ref,
124 :     ; const uint32_t stride);
125 :     ;
126 :     ;===========================================================================
127 :    
128 : suxen_drol 329 %macro SAD_8x8_SSE 0
129 :     movq mm0, [eax]
130 :     movq mm1, [eax+ecx]
131 :    
132 :     psadbw mm0, [edx]
133 :     psadbw mm1, [edx+ecx]
134 :     add eax, ebx
135 :     add edx, ebx
136 :    
137 :     paddusw mm5,mm0
138 :     paddusw mm6,mm1
139 :     %endmacro
140 :    
141 :     align 16
142 :     sad8_xmm:
143 :    
144 :     mov eax, [esp+ 4] ; Src1
145 :     mov edx, [esp+ 8] ; Src2
146 :     mov ecx, [esp+12] ; Stride
147 :     push ebx
148 :     lea ebx, [ecx+ecx]
149 :    
150 :     pxor mm5, mm5 ; accum1
151 :     pxor mm6, mm6 ; accum2
152 :    
153 :     SAD_8x8_SSE
154 :     SAD_8x8_SSE
155 :     SAD_8x8_SSE
156 :    
157 :     movq mm0, [eax]
158 :     movq mm1, [eax+ecx]
159 :     psadbw mm0, [edx]
160 :     psadbw mm1, [edx+ecx]
161 :    
162 :     pop ebx
163 :    
164 :     paddusw mm5,mm0
165 :     paddusw mm6,mm1
166 :    
167 :     paddusw mm6,mm5
168 :     movd eax, mm6
169 :    
170 :     ret
171 :    
172 :    
173 :     ;===========================================================================
174 :     ;
175 :     ; uint32_t sad16bi_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 : Isibaar 262 %macro SADBI_16x16_SSE 0
183 :     movq mm0, [eax]
184 :     movq mm1, [eax+8]
185 :    
186 :     movq mm2, [edx]
187 :     movq mm3, [edx+8]
188 :    
189 :     pavgb mm2, [ebx]
190 :     add edx, ecx
191 :    
192 :     pavgb mm3, [ebx+8]
193 :     add ebx, ecx
194 :    
195 :     psadbw mm0, mm2
196 :     add eax, ecx
197 :    
198 :     psadbw mm1, mm3
199 :     paddusw mm5,mm0
200 :    
201 :     paddusw mm6,mm1
202 :     %endmacro
203 :    
204 :     align 16
205 :     sad16bi_xmm:
206 :     push ebx
207 :     mov eax, [esp+4+ 4] ; Src
208 :     mov edx, [esp+4+ 8] ; Ref1
209 :     mov ebx, [esp+4+12] ; Ref2
210 :     mov ecx, [esp+4+16] ; Stride
211 :    
212 :     pxor mm5, mm5 ; accum1
213 :     pxor mm6, mm6 ; accum2
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 :     SADBI_16x16_SSE
225 :     SADBI_16x16_SSE
226 :     SADBI_16x16_SSE
227 :     SADBI_16x16_SSE
228 :     SADBI_16x16_SSE
229 :     SADBI_16x16_SSE
230 :     SADBI_16x16_SSE
231 :     SADBI_16x16_SSE
232 :    
233 :     paddusw mm6,mm5
234 :     movd eax, mm6
235 :     pop ebx
236 :     ret
237 :    
238 :     ;===========================================================================
239 :     ;
240 :     ; uint32_t sad8bi_xmm(const uint8_t * const cur,
241 :     ; const uint8_t * const ref1,
242 :     ; const uint8_t * const ref2,
243 :     ; const uint32_t stride);
244 :     ;
245 :     ;===========================================================================
246 :    
247 : suxen_drol 329 %macro SADBI_8x8_XMM 0
248 :     movq mm0, [eax]
249 :     movq mm1, [eax+ecx]
250 : Isibaar 262
251 : suxen_drol 329 movq mm2, [edx]
252 :     movq mm3, [edx+ecx]
253 : Isibaar 262
254 : suxen_drol 329 pavgb mm2, [ebx]
255 :     lea edx, [edx+2*ecx]
256 : Isibaar 262
257 : suxen_drol 329 pavgb mm3, [ebx+ecx]
258 :     lea ebx, [ebx+2*ecx]
259 : Isibaar 262
260 : suxen_drol 329 psadbw mm0, mm2
261 :     lea eax, [eax+2*ecx]
262 : Isibaar 262
263 : suxen_drol 329 psadbw mm1, mm3
264 :     paddusw mm5,mm0
265 : Isibaar 262
266 : suxen_drol 329 paddusw mm6,mm1
267 :     %endmacro
268 : Isibaar 262
269 : suxen_drol 329 align 16
270 :     sad8bi_xmm:
271 :     push ebx
272 :     mov eax, [esp+4+ 4] ; Src
273 :     mov edx, [esp+4+ 8] ; Ref1
274 :     mov ebx, [esp+4+12] ; Ref2
275 :     mov ecx, [esp+4+16] ; Stride
276 : Isibaar 262
277 : suxen_drol 329 pxor mm5, mm5 ; accum1
278 :     pxor mm6, mm6 ; accum2
279 :     .Loop
280 :     SADBI_8x8_XMM
281 :     SADBI_8x8_XMM
282 :     SADBI_8x8_XMM
283 :     SADBI_8x8_XMM
284 : Isibaar 262
285 : suxen_drol 329 paddusw mm6,mm5
286 :     movd eax, mm6
287 :     pop ebx
288 :     ret
289 : Isibaar 262
290 : suxen_drol 329
291 :     ;===========================================================================
292 :     ;
293 :     ; uint32_t dev16_xmm(const uint8_t * const cur,
294 :     ; const uint32_t stride);
295 :     ;
296 :     ;===========================================================================
297 :    
298 :     %macro MEAN_16x16_SSE 0
299 : Isibaar 262 movq mm0, [eax]
300 :     movq mm1, [eax+8]
301 :     psadbw mm0, mm7
302 :     psadbw mm1, mm7
303 :     add eax, ecx
304 :     paddw mm5, mm0
305 :     paddw mm6, mm1
306 :     %endmacro
307 :    
308 :     %macro ABS_16x16_SSE 0
309 :     movq mm0, [eax]
310 :     movq mm1, [eax+8]
311 :     psadbw mm0, mm4
312 :     psadbw mm1, mm4
313 :     lea eax,[eax+ecx]
314 :     paddw mm5, mm0
315 :     paddw mm6, mm1
316 :     %endmacro
317 :    
318 :     align 16
319 :     dev16_xmm:
320 :    
321 :     mov eax, [esp+ 4] ; Src
322 :     mov ecx, [esp+ 8] ; Stride
323 :    
324 :     pxor mm7, mm7 ; zero
325 :     pxor mm5, mm5 ; mean accums
326 :     pxor mm6, mm6
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 :     MEAN_16x16_SSE
338 :     MEAN_16x16_SSE
339 :     MEAN_16x16_SSE
340 :     MEAN_16x16_SSE
341 :     MEAN_16x16_SSE
342 :     MEAN_16x16_SSE
343 :     MEAN_16x16_SSE
344 :     MEAN_16x16_SSE
345 :    
346 :     paddusw mm6, mm5
347 :    
348 :     movq mm4, mm6
349 :     psllq mm4, 32
350 :     paddd mm4, mm6
351 :     psrld mm4, 8 ; /= (16*16)
352 :    
353 :     packssdw mm4, mm4
354 :     packuswb mm4, mm4
355 :    
356 :     ; mm4 contains the mean
357 :    
358 :     mov eax, [esp+ 4] ; Src
359 :    
360 : edgomez 851
361 : Isibaar 262 pxor mm5, mm5 ; sums
362 :     pxor mm6, mm6
363 :    
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 :     ABS_16x16_SSE
372 :    
373 :     ABS_16x16_SSE
374 :     ABS_16x16_SSE
375 :     ABS_16x16_SSE
376 :     ABS_16x16_SSE
377 :     ABS_16x16_SSE
378 :     ABS_16x16_SSE
379 :     ABS_16x16_SSE
380 :     ABS_16x16_SSE
381 :    
382 :     paddusw mm6, mm5
383 :     movq mm7, mm6
384 :     psllq mm7, 32
385 :     paddd mm6, mm7
386 :    
387 :     movd eax, mm6
388 : chl 430 ret
389 : edgomez 851
390 :     cglobal sad16v_xmm
391 :    
392 :     ;===========================================================================
393 :     ;int sad16v_xmm(const uint8_t * const cur,
394 :     ; const uint8_t * const ref,
395 :     ; const uint32_t stride,
396 :     ; int* sad8);
397 :     ;===========================================================================
398 :     align 16
399 :     sad16v_xmm:
400 :     push ebx
401 :     mov eax, [esp+4+ 4] ; Src1
402 :     mov edx, [esp+4+ 8] ; Src2
403 :     mov ecx, [esp+4+12] ; Stride
404 :     mov ebx, [esp+4+16] ; sad ptr
405 :    
406 :     pxor mm5, mm5 ; accum1
407 :     pxor mm6, mm6 ; accum2
408 :     pxor mm7, mm7 ; total
409 :     SAD_16x16_SSE
410 :     SAD_16x16_SSE
411 :     SAD_16x16_SSE
412 :     SAD_16x16_SSE
413 :     SAD_16x16_SSE
414 :     SAD_16x16_SSE
415 :     SAD_16x16_SSE
416 :     SAD_16x16_SSE
417 :     paddusw mm7, mm5
418 :     paddusw mm7, mm6
419 :     movd [ebx], mm5
420 :     movd [ebx+4], mm6
421 :    
422 :     pxor mm5, mm5 ; accum1
423 :     pxor mm6, mm6 ; accum2
424 :     SAD_16x16_SSE
425 :     SAD_16x16_SSE
426 :     SAD_16x16_SSE
427 :     SAD_16x16_SSE
428 :     SAD_16x16_SSE
429 :     SAD_16x16_SSE
430 :     SAD_16x16_SSE
431 :     SAD_16x16_SSE
432 :     paddusw mm7, mm5
433 :     paddusw mm7, mm6
434 :     movd [ebx+8], mm5
435 :     movd [ebx+12], mm6
436 :    
437 :     movd eax, mm7
438 :     pop ebx
439 :     ret
440 :     ;--------
441 :    
442 :    

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