[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 430 - (view) (download)

1 : chl 430 ;/*****************************************************************************
2 : Isibaar 262 ; *
3 : chl 430 ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * xmm (extended mmx) sum of absolute difference
5 : Isibaar 262 ; *
6 : chl 430 ; * Copyright(C) 2002 Peter Ross <pross@xvid.org>
7 :     ; * Copyright(C) 2002 Michael Militzer <michael@xvid.org>
8 :     ; * Copyright(C) 2002 -Skal-
9 : Isibaar 262 ; *
10 : chl 430 ; * This program is an implementation of a part of one or more MPEG-4
11 :     ; * Video tools as specified in ISO/IEC 14496-2 standard. Those intending
12 :     ; * to use this software module in hardware or software products are
13 :     ; * advised that its use may infringe existing patents or copyrights, and
14 :     ; * any such use would be at such party's own risk. The original
15 :     ; * developer of this software module and his/her company, and subsequent
16 :     ; * editors and their companies, will have no liability for use of this
17 :     ; * software or modifications or derivatives thereof.
18 : Isibaar 262 ; *
19 : chl 430 ; * This program is free software; you can redistribute it and/or modify
20 :     ; * it under the terms of the GNU General Public License as published by
21 :     ; * the Free Software Foundation; either version 2 of the License, or
22 :     ; * (at your option) any later version.
23 : Isibaar 262 ; *
24 : chl 430 ; * This program is distributed in the hope that it will be useful,
25 :     ; * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 :     ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 :     ; * GNU General Public License for more details.
28 : Isibaar 262 ; *
29 : chl 430 ; * You should have received a copy of the GNU General Public License
30 :     ; * along with this program; if not, write to the Free Software
31 :     ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 : Isibaar 262 ; *
33 :     ; *************************************************************************/
34 :    
35 :     bits 32
36 : suxen_drol 329
37 : Isibaar 262 %macro cglobal 1
38 :     %ifdef PREFIX
39 :     global _%1
40 :     %define %1 _%1
41 :     %else
42 :     global %1
43 :     %endif
44 :     %endmacro
45 :    
46 :     section .data
47 :    
48 :     align 16
49 :     mmx_one times 4 dw 1
50 :    
51 :     section .text
52 :    
53 :     cglobal sad16_xmm
54 :     cglobal sad8_xmm
55 :     cglobal sad16bi_xmm
56 :     cglobal sad8bi_xmm
57 :     cglobal dev16_xmm
58 :    
59 :     ;===========================================================================
60 :     ;
61 :     ; uint32_t sad16_xmm(const uint8_t * const cur,
62 :     ; const uint8_t * const ref,
63 : suxen_drol 329 ; const uint32_t stride,
64 : Isibaar 262 ; const uint32_t best_sad);
65 : suxen_drol 329 ;
66 : Isibaar 262 ;===========================================================================
67 :    
68 :     %macro SAD_16x16_SSE 0
69 :     movq mm0, [eax]
70 :     psadbw mm0, [edx]
71 :     movq mm1, [eax+8]
72 :     add eax, ecx
73 :     psadbw mm1, [edx+8]
74 :     paddusw mm5,mm0
75 :     add edx, ecx
76 :     paddusw mm6,mm1
77 :     %endmacro
78 :    
79 :     align 16
80 :     sad16_xmm:
81 :    
82 :     mov eax, [esp+ 4] ; Src1
83 :     mov edx, [esp+ 8] ; Src2
84 :     mov ecx, [esp+12] ; Stride
85 :    
86 :     pxor mm5, mm5 ; accum1
87 :     pxor mm6, mm6 ; accum2
88 :    
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 :     SAD_16x16_SSE
97 :    
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 :     SAD_16x16_SSE
106 :    
107 :     paddusw mm6,mm5
108 :     movd eax, mm6
109 :     ret
110 :    
111 :    
112 :     ;===========================================================================
113 :     ;
114 :     ; uint32_t sad8_xmm(const uint8_t * const cur,
115 :     ; const uint8_t * const ref,
116 :     ; const uint32_t stride);
117 :     ;
118 :     ;===========================================================================
119 :    
120 : suxen_drol 329 %macro SAD_8x8_SSE 0
121 :     movq mm0, [eax]
122 :     movq mm1, [eax+ecx]
123 :    
124 :     psadbw mm0, [edx]
125 :     psadbw mm1, [edx+ecx]
126 :     add eax, ebx
127 :     add edx, ebx
128 :    
129 :     paddusw mm5,mm0
130 :     paddusw mm6,mm1
131 :     %endmacro
132 :    
133 :     align 16
134 :     sad8_xmm:
135 :    
136 :     mov eax, [esp+ 4] ; Src1
137 :     mov edx, [esp+ 8] ; Src2
138 :     mov ecx, [esp+12] ; Stride
139 :     push ebx
140 :     lea ebx, [ecx+ecx]
141 :    
142 :     pxor mm5, mm5 ; accum1
143 :     pxor mm6, mm6 ; accum2
144 :    
145 :     SAD_8x8_SSE
146 :     SAD_8x8_SSE
147 :     SAD_8x8_SSE
148 :    
149 :     movq mm0, [eax]
150 :     movq mm1, [eax+ecx]
151 :     psadbw mm0, [edx]
152 :     psadbw mm1, [edx+ecx]
153 :    
154 :     pop ebx
155 :    
156 :     paddusw mm5,mm0
157 :     paddusw mm6,mm1
158 :    
159 :     paddusw mm6,mm5
160 :     movd eax, mm6
161 :    
162 :     ret
163 :    
164 :    
165 :     ;===========================================================================
166 :     ;
167 :     ; uint32_t sad16bi_xmm(const uint8_t * const cur,
168 :     ; const uint8_t * const ref1,
169 :     ; const uint8_t * const ref2,
170 :     ; const uint32_t stride);
171 :     ;
172 :     ;===========================================================================
173 :    
174 : Isibaar 262 %macro SADBI_16x16_SSE 0
175 :     movq mm0, [eax]
176 :     movq mm1, [eax+8]
177 :    
178 :     movq mm2, [edx]
179 :     movq mm3, [edx+8]
180 :    
181 :     pavgb mm2, [ebx]
182 :     add edx, ecx
183 :    
184 :     pavgb mm3, [ebx+8]
185 :     add ebx, ecx
186 :    
187 :     psadbw mm0, mm2
188 :     add eax, ecx
189 :    
190 :     psadbw mm1, mm3
191 :     paddusw mm5,mm0
192 :    
193 :     paddusw mm6,mm1
194 :     %endmacro
195 :    
196 :     align 16
197 :     sad16bi_xmm:
198 :     push ebx
199 :     mov eax, [esp+4+ 4] ; Src
200 :     mov edx, [esp+4+ 8] ; Ref1
201 :     mov ebx, [esp+4+12] ; Ref2
202 :     mov ecx, [esp+4+16] ; Stride
203 :    
204 :     pxor mm5, mm5 ; accum1
205 :     pxor mm6, mm6 ; accum2
206 :    
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 :     SADBI_16x16_SSE
215 :    
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 :     SADBI_16x16_SSE
224 :    
225 :     paddusw mm6,mm5
226 :     movd eax, mm6
227 :     pop ebx
228 :     ret
229 :    
230 :     ;===========================================================================
231 :     ;
232 :     ; uint32_t sad8bi_xmm(const uint8_t * const cur,
233 :     ; const uint8_t * const ref1,
234 :     ; const uint8_t * const ref2,
235 :     ; const uint32_t stride);
236 :     ;
237 :     ;===========================================================================
238 :    
239 : suxen_drol 329 %macro SADBI_8x8_XMM 0
240 :     movq mm0, [eax]
241 :     movq mm1, [eax+ecx]
242 : Isibaar 262
243 : suxen_drol 329 movq mm2, [edx]
244 :     movq mm3, [edx+ecx]
245 : Isibaar 262
246 : suxen_drol 329 pavgb mm2, [ebx]
247 :     lea edx, [edx+2*ecx]
248 : Isibaar 262
249 : suxen_drol 329 pavgb mm3, [ebx+ecx]
250 :     lea ebx, [ebx+2*ecx]
251 : Isibaar 262
252 : suxen_drol 329 psadbw mm0, mm2
253 :     lea eax, [eax+2*ecx]
254 : Isibaar 262
255 : suxen_drol 329 psadbw mm1, mm3
256 :     paddusw mm5,mm0
257 : Isibaar 262
258 : suxen_drol 329 paddusw mm6,mm1
259 :     %endmacro
260 : Isibaar 262
261 : suxen_drol 329 align 16
262 :     sad8bi_xmm:
263 :     push ebx
264 :     mov eax, [esp+4+ 4] ; Src
265 :     mov edx, [esp+4+ 8] ; Ref1
266 :     mov ebx, [esp+4+12] ; Ref2
267 :     mov ecx, [esp+4+16] ; Stride
268 : Isibaar 262
269 : suxen_drol 329 pxor mm5, mm5 ; accum1
270 :     pxor mm6, mm6 ; accum2
271 :     .Loop
272 :     SADBI_8x8_XMM
273 :     SADBI_8x8_XMM
274 :     SADBI_8x8_XMM
275 :     SADBI_8x8_XMM
276 : Isibaar 262
277 : suxen_drol 329 paddusw mm6,mm5
278 :     movd eax, mm6
279 :     pop ebx
280 :     ret
281 : Isibaar 262
282 : suxen_drol 329
283 :     ;===========================================================================
284 :     ;
285 :     ; uint32_t dev16_xmm(const uint8_t * const cur,
286 :     ; const uint32_t stride);
287 :     ;
288 :     ;===========================================================================
289 :    
290 :     %macro MEAN_16x16_SSE 0
291 : Isibaar 262 movq mm0, [eax]
292 :     movq mm1, [eax+8]
293 :     psadbw mm0, mm7
294 :     psadbw mm1, mm7
295 :     add eax, ecx
296 :     paddw mm5, mm0
297 :     paddw mm6, mm1
298 :     %endmacro
299 :    
300 :     %macro ABS_16x16_SSE 0
301 :     movq mm0, [eax]
302 :     movq mm1, [eax+8]
303 :     psadbw mm0, mm4
304 :     psadbw mm1, mm4
305 :     lea eax,[eax+ecx]
306 :     paddw mm5, mm0
307 :     paddw mm6, mm1
308 :     %endmacro
309 :    
310 :     align 16
311 :     dev16_xmm:
312 :    
313 :     mov eax, [esp+ 4] ; Src
314 :     mov ecx, [esp+ 8] ; Stride
315 :    
316 :     pxor mm7, mm7 ; zero
317 :     pxor mm5, mm5 ; mean accums
318 :     pxor mm6, mm6
319 :    
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 :     MEAN_16x16_SSE
328 :    
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 :     MEAN_16x16_SSE
337 :    
338 :     paddusw mm6, mm5
339 :    
340 :     movq mm4, mm6
341 :     psllq mm4, 32
342 :     paddd mm4, mm6
343 :     psrld mm4, 8 ; /= (16*16)
344 :    
345 :     packssdw mm4, mm4
346 :     packuswb mm4, mm4
347 :    
348 :     ; mm4 contains the mean
349 :    
350 :     mov eax, [esp+ 4] ; Src
351 :    
352 :     pxor mm5, mm5 ; sums
353 :     pxor mm6, mm6
354 :    
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 :     ABS_16x16_SSE
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 :     paddusw mm6, mm5
374 :     movq mm7, mm6
375 :     psllq mm7, 32
376 :     paddd mm6, mm7
377 :    
378 :     movd eax, mm6
379 : chl 430 ret

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