Parent Directory | Revision Log
Revision 652 - (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 : | chl | 458 | ; * Copyright(C) 2002 Pascal Massimino <skal@planet-d.net> |
9 : | Isibaar | 262 | ; * |
10 : | edgomez | 652 | ; * This file is part of XviD, a free MPEG-4 video encoder/decoder |
11 : | Isibaar | 262 | ; * |
12 : | edgomez | 652 | ; * XviD is free software; you can redistribute it and/or modify it |
13 : | ; * under the terms of the GNU General Public License as published by | ||
14 : | chl | 430 | ; * the Free Software Foundation; either version 2 of the License, or |
15 : | ; * (at your option) any later version. | ||
16 : | Isibaar | 262 | ; * |
17 : | chl | 430 | ; * This program is distributed in the hope that it will be useful, |
18 : | ; * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 : | ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 : | ; * GNU General Public License for more details. | ||
21 : | Isibaar | 262 | ; * |
22 : | chl | 430 | ; * You should have received a copy of the GNU General Public License |
23 : | ; * along with this program; if not, write to the Free Software | ||
24 : | ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
25 : | Isibaar | 262 | ; * |
26 : | edgomez | 652 | ; * Under section 8 of the GNU General Public License, the copyright |
27 : | ; * holders of XVID explicitly forbid distribution in the following | ||
28 : | ; * countries: | ||
29 : | ; * | ||
30 : | ; * - Japan | ||
31 : | ; * - United States of America | ||
32 : | ; * | ||
33 : | ; * Linking XviD statically or dynamically with other modules is making a | ||
34 : | ; * combined work based on XviD. Thus, the terms and conditions of the | ||
35 : | ; * GNU General Public License cover the whole combination. | ||
36 : | ; * | ||
37 : | ; * As a special exception, the copyright holders of XviD give you | ||
38 : | ; * permission to link XviD with independent modules that communicate with | ||
39 : | ; * XviD solely through the VFW1.1 and DShow interfaces, regardless of the | ||
40 : | ; * license terms of these independent modules, and to copy and distribute | ||
41 : | ; * the resulting combined work under terms of your choice, provided that | ||
42 : | ; * every copy of the combined work is accompanied by a complete copy of | ||
43 : | ; * the source code of XviD (the version of XviD used to produce the | ||
44 : | ; * combined work), being distributed under the terms of the GNU General | ||
45 : | ; * Public License plus this exception. An independent module is a module | ||
46 : | ; * which is not derived from or based on XviD. | ||
47 : | ; * | ||
48 : | ; * Note that people who make modified versions of XviD are not obligated | ||
49 : | ; * to grant this special exception for their modified versions; it is | ||
50 : | ; * their choice whether to do so. The GNU General Public License gives | ||
51 : | ; * permission to release a modified version without this exception; this | ||
52 : | ; * exception also makes it possible to release a modified version which | ||
53 : | ; * carries forward this exception. | ||
54 : | ; * | ||
55 : | ; * $Id: sad_xmm.asm,v 1.5 2002-11-17 00:32:06 edgomez Exp $ | ||
56 : | ; * | ||
57 : | Isibaar | 262 | ; *************************************************************************/ |
58 : | |||
59 : | bits 32 | ||
60 : | suxen_drol | 329 | |
61 : | Isibaar | 262 | %macro cglobal 1 |
62 : | %ifdef PREFIX | ||
63 : | global _%1 | ||
64 : | %define %1 _%1 | ||
65 : | %else | ||
66 : | global %1 | ||
67 : | %endif | ||
68 : | %endmacro | ||
69 : | |||
70 : | section .data | ||
71 : | |||
72 : | align 16 | ||
73 : | mmx_one times 4 dw 1 | ||
74 : | |||
75 : | section .text | ||
76 : | |||
77 : | cglobal sad16_xmm | ||
78 : | cglobal sad8_xmm | ||
79 : | cglobal sad16bi_xmm | ||
80 : | cglobal sad8bi_xmm | ||
81 : | cglobal dev16_xmm | ||
82 : | |||
83 : | ;=========================================================================== | ||
84 : | ; | ||
85 : | ; uint32_t sad16_xmm(const uint8_t * const cur, | ||
86 : | ; const uint8_t * const ref, | ||
87 : | suxen_drol | 329 | ; const uint32_t stride, |
88 : | Isibaar | 262 | ; const uint32_t best_sad); |
89 : | suxen_drol | 329 | ; |
90 : | Isibaar | 262 | ;=========================================================================== |
91 : | |||
92 : | %macro SAD_16x16_SSE 0 | ||
93 : | movq mm0, [eax] | ||
94 : | psadbw mm0, [edx] | ||
95 : | movq mm1, [eax+8] | ||
96 : | add eax, ecx | ||
97 : | psadbw mm1, [edx+8] | ||
98 : | paddusw mm5,mm0 | ||
99 : | add edx, ecx | ||
100 : | paddusw mm6,mm1 | ||
101 : | %endmacro | ||
102 : | |||
103 : | align 16 | ||
104 : | sad16_xmm: | ||
105 : | |||
106 : | mov eax, [esp+ 4] ; Src1 | ||
107 : | mov edx, [esp+ 8] ; Src2 | ||
108 : | mov ecx, [esp+12] ; Stride | ||
109 : | |||
110 : | pxor mm5, mm5 ; accum1 | ||
111 : | pxor mm6, mm6 ; accum2 | ||
112 : | |||
113 : | SAD_16x16_SSE | ||
114 : | SAD_16x16_SSE | ||
115 : | SAD_16x16_SSE | ||
116 : | SAD_16x16_SSE | ||
117 : | SAD_16x16_SSE | ||
118 : | SAD_16x16_SSE | ||
119 : | SAD_16x16_SSE | ||
120 : | SAD_16x16_SSE | ||
121 : | |||
122 : | SAD_16x16_SSE | ||
123 : | SAD_16x16_SSE | ||
124 : | SAD_16x16_SSE | ||
125 : | SAD_16x16_SSE | ||
126 : | SAD_16x16_SSE | ||
127 : | SAD_16x16_SSE | ||
128 : | SAD_16x16_SSE | ||
129 : | SAD_16x16_SSE | ||
130 : | |||
131 : | paddusw mm6,mm5 | ||
132 : | movd eax, mm6 | ||
133 : | ret | ||
134 : | |||
135 : | |||
136 : | ;=========================================================================== | ||
137 : | ; | ||
138 : | ; uint32_t sad8_xmm(const uint8_t * const cur, | ||
139 : | ; const uint8_t * const ref, | ||
140 : | ; const uint32_t stride); | ||
141 : | ; | ||
142 : | ;=========================================================================== | ||
143 : | |||
144 : | suxen_drol | 329 | %macro SAD_8x8_SSE 0 |
145 : | movq mm0, [eax] | ||
146 : | movq mm1, [eax+ecx] | ||
147 : | |||
148 : | psadbw mm0, [edx] | ||
149 : | psadbw mm1, [edx+ecx] | ||
150 : | add eax, ebx | ||
151 : | add edx, ebx | ||
152 : | |||
153 : | paddusw mm5,mm0 | ||
154 : | paddusw mm6,mm1 | ||
155 : | %endmacro | ||
156 : | |||
157 : | align 16 | ||
158 : | sad8_xmm: | ||
159 : | |||
160 : | mov eax, [esp+ 4] ; Src1 | ||
161 : | mov edx, [esp+ 8] ; Src2 | ||
162 : | mov ecx, [esp+12] ; Stride | ||
163 : | push ebx | ||
164 : | lea ebx, [ecx+ecx] | ||
165 : | |||
166 : | pxor mm5, mm5 ; accum1 | ||
167 : | pxor mm6, mm6 ; accum2 | ||
168 : | |||
169 : | SAD_8x8_SSE | ||
170 : | SAD_8x8_SSE | ||
171 : | SAD_8x8_SSE | ||
172 : | |||
173 : | movq mm0, [eax] | ||
174 : | movq mm1, [eax+ecx] | ||
175 : | psadbw mm0, [edx] | ||
176 : | psadbw mm1, [edx+ecx] | ||
177 : | |||
178 : | pop ebx | ||
179 : | |||
180 : | paddusw mm5,mm0 | ||
181 : | paddusw mm6,mm1 | ||
182 : | |||
183 : | paddusw mm6,mm5 | ||
184 : | movd eax, mm6 | ||
185 : | |||
186 : | ret | ||
187 : | |||
188 : | |||
189 : | ;=========================================================================== | ||
190 : | ; | ||
191 : | ; uint32_t sad16bi_xmm(const uint8_t * const cur, | ||
192 : | ; const uint8_t * const ref1, | ||
193 : | ; const uint8_t * const ref2, | ||
194 : | ; const uint32_t stride); | ||
195 : | ; | ||
196 : | ;=========================================================================== | ||
197 : | |||
198 : | Isibaar | 262 | %macro SADBI_16x16_SSE 0 |
199 : | movq mm0, [eax] | ||
200 : | movq mm1, [eax+8] | ||
201 : | |||
202 : | movq mm2, [edx] | ||
203 : | movq mm3, [edx+8] | ||
204 : | |||
205 : | pavgb mm2, [ebx] | ||
206 : | add edx, ecx | ||
207 : | |||
208 : | pavgb mm3, [ebx+8] | ||
209 : | add ebx, ecx | ||
210 : | |||
211 : | psadbw mm0, mm2 | ||
212 : | add eax, ecx | ||
213 : | |||
214 : | psadbw mm1, mm3 | ||
215 : | paddusw mm5,mm0 | ||
216 : | |||
217 : | paddusw mm6,mm1 | ||
218 : | %endmacro | ||
219 : | |||
220 : | align 16 | ||
221 : | sad16bi_xmm: | ||
222 : | push ebx | ||
223 : | mov eax, [esp+4+ 4] ; Src | ||
224 : | mov edx, [esp+4+ 8] ; Ref1 | ||
225 : | mov ebx, [esp+4+12] ; Ref2 | ||
226 : | mov ecx, [esp+4+16] ; Stride | ||
227 : | |||
228 : | pxor mm5, mm5 ; accum1 | ||
229 : | pxor mm6, mm6 ; accum2 | ||
230 : | |||
231 : | SADBI_16x16_SSE | ||
232 : | SADBI_16x16_SSE | ||
233 : | SADBI_16x16_SSE | ||
234 : | SADBI_16x16_SSE | ||
235 : | SADBI_16x16_SSE | ||
236 : | SADBI_16x16_SSE | ||
237 : | SADBI_16x16_SSE | ||
238 : | SADBI_16x16_SSE | ||
239 : | |||
240 : | SADBI_16x16_SSE | ||
241 : | SADBI_16x16_SSE | ||
242 : | SADBI_16x16_SSE | ||
243 : | SADBI_16x16_SSE | ||
244 : | SADBI_16x16_SSE | ||
245 : | SADBI_16x16_SSE | ||
246 : | SADBI_16x16_SSE | ||
247 : | SADBI_16x16_SSE | ||
248 : | |||
249 : | paddusw mm6,mm5 | ||
250 : | movd eax, mm6 | ||
251 : | pop ebx | ||
252 : | ret | ||
253 : | |||
254 : | ;=========================================================================== | ||
255 : | ; | ||
256 : | ; uint32_t sad8bi_xmm(const uint8_t * const cur, | ||
257 : | ; const uint8_t * const ref1, | ||
258 : | ; const uint8_t * const ref2, | ||
259 : | ; const uint32_t stride); | ||
260 : | ; | ||
261 : | ;=========================================================================== | ||
262 : | |||
263 : | suxen_drol | 329 | %macro SADBI_8x8_XMM 0 |
264 : | movq mm0, [eax] | ||
265 : | movq mm1, [eax+ecx] | ||
266 : | Isibaar | 262 | |
267 : | suxen_drol | 329 | movq mm2, [edx] |
268 : | movq mm3, [edx+ecx] | ||
269 : | Isibaar | 262 | |
270 : | suxen_drol | 329 | pavgb mm2, [ebx] |
271 : | lea edx, [edx+2*ecx] | ||
272 : | Isibaar | 262 | |
273 : | suxen_drol | 329 | pavgb mm3, [ebx+ecx] |
274 : | lea ebx, [ebx+2*ecx] | ||
275 : | Isibaar | 262 | |
276 : | suxen_drol | 329 | psadbw mm0, mm2 |
277 : | lea eax, [eax+2*ecx] | ||
278 : | Isibaar | 262 | |
279 : | suxen_drol | 329 | psadbw mm1, mm3 |
280 : | paddusw mm5,mm0 | ||
281 : | Isibaar | 262 | |
282 : | suxen_drol | 329 | paddusw mm6,mm1 |
283 : | %endmacro | ||
284 : | Isibaar | 262 | |
285 : | suxen_drol | 329 | align 16 |
286 : | sad8bi_xmm: | ||
287 : | push ebx | ||
288 : | mov eax, [esp+4+ 4] ; Src | ||
289 : | mov edx, [esp+4+ 8] ; Ref1 | ||
290 : | mov ebx, [esp+4+12] ; Ref2 | ||
291 : | mov ecx, [esp+4+16] ; Stride | ||
292 : | Isibaar | 262 | |
293 : | suxen_drol | 329 | pxor mm5, mm5 ; accum1 |
294 : | pxor mm6, mm6 ; accum2 | ||
295 : | .Loop | ||
296 : | SADBI_8x8_XMM | ||
297 : | SADBI_8x8_XMM | ||
298 : | SADBI_8x8_XMM | ||
299 : | SADBI_8x8_XMM | ||
300 : | Isibaar | 262 | |
301 : | suxen_drol | 329 | paddusw mm6,mm5 |
302 : | movd eax, mm6 | ||
303 : | pop ebx | ||
304 : | ret | ||
305 : | Isibaar | 262 | |
306 : | suxen_drol | 329 | |
307 : | ;=========================================================================== | ||
308 : | ; | ||
309 : | ; uint32_t dev16_xmm(const uint8_t * const cur, | ||
310 : | ; const uint32_t stride); | ||
311 : | ; | ||
312 : | ;=========================================================================== | ||
313 : | |||
314 : | %macro MEAN_16x16_SSE 0 | ||
315 : | Isibaar | 262 | movq mm0, [eax] |
316 : | movq mm1, [eax+8] | ||
317 : | psadbw mm0, mm7 | ||
318 : | psadbw mm1, mm7 | ||
319 : | add eax, ecx | ||
320 : | paddw mm5, mm0 | ||
321 : | paddw mm6, mm1 | ||
322 : | %endmacro | ||
323 : | |||
324 : | %macro ABS_16x16_SSE 0 | ||
325 : | movq mm0, [eax] | ||
326 : | movq mm1, [eax+8] | ||
327 : | psadbw mm0, mm4 | ||
328 : | psadbw mm1, mm4 | ||
329 : | lea eax,[eax+ecx] | ||
330 : | paddw mm5, mm0 | ||
331 : | paddw mm6, mm1 | ||
332 : | %endmacro | ||
333 : | |||
334 : | align 16 | ||
335 : | dev16_xmm: | ||
336 : | |||
337 : | mov eax, [esp+ 4] ; Src | ||
338 : | mov ecx, [esp+ 8] ; Stride | ||
339 : | |||
340 : | pxor mm7, mm7 ; zero | ||
341 : | pxor mm5, mm5 ; mean accums | ||
342 : | pxor mm6, mm6 | ||
343 : | |||
344 : | MEAN_16x16_SSE | ||
345 : | MEAN_16x16_SSE | ||
346 : | MEAN_16x16_SSE | ||
347 : | MEAN_16x16_SSE | ||
348 : | MEAN_16x16_SSE | ||
349 : | MEAN_16x16_SSE | ||
350 : | MEAN_16x16_SSE | ||
351 : | MEAN_16x16_SSE | ||
352 : | |||
353 : | MEAN_16x16_SSE | ||
354 : | MEAN_16x16_SSE | ||
355 : | MEAN_16x16_SSE | ||
356 : | MEAN_16x16_SSE | ||
357 : | MEAN_16x16_SSE | ||
358 : | MEAN_16x16_SSE | ||
359 : | MEAN_16x16_SSE | ||
360 : | MEAN_16x16_SSE | ||
361 : | |||
362 : | paddusw mm6, mm5 | ||
363 : | |||
364 : | movq mm4, mm6 | ||
365 : | psllq mm4, 32 | ||
366 : | paddd mm4, mm6 | ||
367 : | psrld mm4, 8 ; /= (16*16) | ||
368 : | |||
369 : | packssdw mm4, mm4 | ||
370 : | packuswb mm4, mm4 | ||
371 : | |||
372 : | ; mm4 contains the mean | ||
373 : | |||
374 : | mov eax, [esp+ 4] ; Src | ||
375 : | |||
376 : | pxor mm5, mm5 ; sums | ||
377 : | pxor mm6, mm6 | ||
378 : | |||
379 : | ABS_16x16_SSE | ||
380 : | ABS_16x16_SSE | ||
381 : | ABS_16x16_SSE | ||
382 : | ABS_16x16_SSE | ||
383 : | ABS_16x16_SSE | ||
384 : | ABS_16x16_SSE | ||
385 : | ABS_16x16_SSE | ||
386 : | ABS_16x16_SSE | ||
387 : | |||
388 : | ABS_16x16_SSE | ||
389 : | ABS_16x16_SSE | ||
390 : | ABS_16x16_SSE | ||
391 : | ABS_16x16_SSE | ||
392 : | ABS_16x16_SSE | ||
393 : | ABS_16x16_SSE | ||
394 : | ABS_16x16_SSE | ||
395 : | ABS_16x16_SSE | ||
396 : | |||
397 : | paddusw mm6, mm5 | ||
398 : | movq mm7, mm6 | ||
399 : | psllq mm7, 32 | ||
400 : | paddd mm6, mm7 | ||
401 : | |||
402 : | movd eax, mm6 | ||
403 : | chl | 430 | ret |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |