Parent Directory | Revision Log
Revision 1790 - (view) (download)
1 : | edgomez | 1586 | ;/**************************************************************************** |
2 : | ; * | ||
3 : | ; * XVID MPEG-4 VIDEO CODEC | ||
4 : | ; * - K7 optimized SAD operators - | ||
5 : | ; * | ||
6 : | ; * Copyright(C) 2001 Peter Ross <pross@xvid.org> | ||
7 : | ; * 2001 Michael Militzer <isibaar@xvid.org> | ||
8 : | ; * 2002 Pascal Massimino <skal@planet-d.net> | ||
9 : | ; * 2004 Andre Werthmann <wertmann@aei.mpg.de> | ||
10 : | ; * | ||
11 : | ; * This program is free software; you can redistribute it and/or modify it | ||
12 : | ; * under the terms of the GNU General Public License as published by | ||
13 : | ; * the Free Software Foundation; either version 2 of the License, or | ||
14 : | ; * (at your option) any later version. | ||
15 : | ; * | ||
16 : | ; * This program is distributed in the hope that it will be useful, | ||
17 : | ; * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 : | ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 : | ; * GNU General Public License for more details. | ||
20 : | ; * | ||
21 : | ; * You should have received a copy of the GNU General Public License | ||
22 : | ; * along with this program; if not, write to the Free Software | ||
23 : | ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
24 : | ; * | ||
25 : | Isibaar | 1790 | ; * $Id: sad_xmm.asm,v 1.2 2008-08-19 09:06:48 Isibaar Exp $ |
26 : | edgomez | 1586 | ; * |
27 : | ; ***************************************************************************/ | ||
28 : | |||
29 : | BITS 64 | ||
30 : | |||
31 : | %macro cglobal 1 | ||
32 : | %ifdef PREFIX | ||
33 : | %ifdef MARK_FUNCS | ||
34 : | global _%1:function %1.endfunc-%1 | ||
35 : | %define %1 _%1:function %1.endfunc-%1 | ||
36 : | %else | ||
37 : | global _%1 | ||
38 : | %define %1 _%1 | ||
39 : | %endif | ||
40 : | %else | ||
41 : | %ifdef MARK_FUNCS | ||
42 : | global %1:function %1.endfunc-%1 | ||
43 : | %else | ||
44 : | global %1 | ||
45 : | %endif | ||
46 : | %endif | ||
47 : | %endmacro | ||
48 : | |||
49 : | ;============================================================================= | ||
50 : | ; Read only data | ||
51 : | ;============================================================================= | ||
52 : | |||
53 : | %ifdef FORMAT_COFF | ||
54 : | SECTION .rodata | ||
55 : | %else | ||
56 : | SECTION .rodata align=16 | ||
57 : | %endif | ||
58 : | |||
59 : | ALIGN 16 | ||
60 : | mmx_one: times 4 dw 1 | ||
61 : | |||
62 : | ;============================================================================= | ||
63 : | ; Helper macros | ||
64 : | ;============================================================================= | ||
65 : | |||
66 : | %macro SAD_16x16_SSE 0 | ||
67 : | movq mm0, [rax] | ||
68 : | psadbw mm0, [rdx] | ||
69 : | movq mm1, [rax+8] | ||
70 : | add rax, rcx | ||
71 : | psadbw mm1, [rdx+8] | ||
72 : | paddusw mm5, mm0 | ||
73 : | add rdx, rcx | ||
74 : | paddusw mm6, mm1 | ||
75 : | %endmacro | ||
76 : | |||
77 : | %macro SAD_8x8_SSE 0 | ||
78 : | movq mm0, [rax] | ||
79 : | movq mm1, [rax+rcx] | ||
80 : | psadbw mm0, [rdx] | ||
81 : | psadbw mm1, [rdx+rcx] | ||
82 : | add rax, rbx | ||
83 : | add rdx, rbx | ||
84 : | paddusw mm5, mm0 | ||
85 : | paddusw mm6, mm1 | ||
86 : | %endmacro | ||
87 : | |||
88 : | %macro SADBI_16x16_SSE 0 | ||
89 : | movq mm0, [rax] | ||
90 : | movq mm1, [rax+8] | ||
91 : | movq mm2, [rdx] | ||
92 : | movq mm3, [rdx+8] | ||
93 : | pavgb mm2, [rbx] | ||
94 : | add rdx, rcx | ||
95 : | pavgb mm3, [rbx+8] | ||
96 : | add rbx, rcx | ||
97 : | psadbw mm0, mm2 | ||
98 : | add rax, rcx | ||
99 : | psadbw mm1, mm3 | ||
100 : | paddusw mm5, mm0 | ||
101 : | paddusw mm6, mm1 | ||
102 : | %endmacro | ||
103 : | |||
104 : | %macro SADBI_8x8_XMM 0 | ||
105 : | movq mm0, [rax] | ||
106 : | movq mm1, [rax+rcx] | ||
107 : | movq mm2, [rdx] | ||
108 : | movq mm3, [rdx+rcx] | ||
109 : | pavgb mm2, [rbx] | ||
110 : | lea rdx, [rdx+2*rcx] | ||
111 : | pavgb mm3, [rbx+rcx] | ||
112 : | lea rbx, [rbx+2*rcx] | ||
113 : | psadbw mm0, mm2 | ||
114 : | lea rax, [rax+2*rcx] | ||
115 : | psadbw mm1, mm3 | ||
116 : | paddusw mm5, mm0 | ||
117 : | paddusw mm6, mm1 | ||
118 : | %endmacro | ||
119 : | |||
120 : | %macro MEAN_16x16_SSE 0 | ||
121 : | movq mm0, [rax] | ||
122 : | movq mm1, [rax+8] | ||
123 : | psadbw mm0, mm7 | ||
124 : | psadbw mm1, mm7 | ||
125 : | add rax, rcx | ||
126 : | paddw mm5, mm0 | ||
127 : | paddw mm6, mm1 | ||
128 : | %endmacro | ||
129 : | |||
130 : | %macro ABS_16x16_SSE 0 | ||
131 : | movq mm0, [rax] | ||
132 : | movq mm1, [rax+8] | ||
133 : | psadbw mm0, mm4 | ||
134 : | psadbw mm1, mm4 | ||
135 : | lea rax, [rax+rcx] | ||
136 : | paddw mm5, mm0 | ||
137 : | paddw mm6, mm1 | ||
138 : | %endmacro | ||
139 : | |||
140 : | ;============================================================================= | ||
141 : | ; Code | ||
142 : | ;============================================================================= | ||
143 : | |||
144 : | SECTION .text align=16 | ||
145 : | |||
146 : | cglobal sad16_x86_64 | ||
147 : | cglobal sad8_x86_64 | ||
148 : | cglobal sad16bi_x86_64 | ||
149 : | cglobal sad8bi_x86_64 | ||
150 : | cglobal dev16_x86_64 | ||
151 : | cglobal sad16v_x86_64 | ||
152 : | |||
153 : | ;----------------------------------------------------------------------------- | ||
154 : | ; | ||
155 : | ; uint32_t sad16_x86_64(const uint8_t * const cur, | ||
156 : | ; const uint8_t * const ref, | ||
157 : | ; const uint32_t stride, | ||
158 : | ; const uint32_t best_sad); | ||
159 : | ; | ||
160 : | ;----------------------------------------------------------------------------- | ||
161 : | |||
162 : | ALIGN 16 | ||
163 : | sad16_x86_64: | ||
164 : | mov rcx, rdx ; stride | ||
165 : | mov rdx, rsi ; src2 (64bit pointer) | ||
166 : | mov rax, rdi ; src1 (64bit pointer) | ||
167 : | |||
168 : | pxor mm5, mm5 ; accum1 | ||
169 : | pxor mm6, mm6 ; accum2 | ||
170 : | |||
171 : | SAD_16x16_SSE | ||
172 : | SAD_16x16_SSE | ||
173 : | SAD_16x16_SSE | ||
174 : | SAD_16x16_SSE | ||
175 : | SAD_16x16_SSE | ||
176 : | SAD_16x16_SSE | ||
177 : | SAD_16x16_SSE | ||
178 : | SAD_16x16_SSE | ||
179 : | |||
180 : | SAD_16x16_SSE | ||
181 : | SAD_16x16_SSE | ||
182 : | SAD_16x16_SSE | ||
183 : | SAD_16x16_SSE | ||
184 : | SAD_16x16_SSE | ||
185 : | SAD_16x16_SSE | ||
186 : | SAD_16x16_SSE | ||
187 : | SAD_16x16_SSE | ||
188 : | |||
189 : | paddusw mm6,mm5 | ||
190 : | movd eax, mm6 | ||
191 : | ret | ||
192 : | .endfunc | ||
193 : | |||
194 : | ;----------------------------------------------------------------------------- | ||
195 : | ; | ||
196 : | ; uint32_t sad8_x86_64(const uint8_t * const cur, | ||
197 : | ; const uint8_t * const ref, | ||
198 : | ; const uint32_t stride); | ||
199 : | ; | ||
200 : | ;----------------------------------------------------------------------------- | ||
201 : | |||
202 : | ALIGN 16 | ||
203 : | sad8_x86_64: | ||
204 : | mov rcx, rdx ; stride | ||
205 : | mov rdx, rsi ; src2 | ||
206 : | mov rax, rdi ; src1 | ||
207 : | |||
208 : | push rbx | ||
209 : | |||
210 : | lea rbx, [rcx+rcx] | ||
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, [rax] | ||
220 : | movq mm1, [rax+rcx] | ||
221 : | psadbw mm0, [rdx] | ||
222 : | psadbw mm1, [rdx+rcx] | ||
223 : | |||
224 : | pop rbx | ||
225 : | |||
226 : | paddusw mm5,mm0 | ||
227 : | paddusw mm6,mm1 | ||
228 : | |||
229 : | paddusw mm6,mm5 | ||
230 : | movd eax, mm6 | ||
231 : | |||
232 : | ret | ||
233 : | .endfunc | ||
234 : | |||
235 : | ;----------------------------------------------------------------------------- | ||
236 : | ; | ||
237 : | ; uint32_t sad16bi_x86_64(const uint8_t * const cur, | ||
238 : | ; const uint8_t * const ref1, | ||
239 : | ; const uint8_t * const ref2, | ||
240 : | ; const uint32_t stride); | ||
241 : | ; | ||
242 : | ;----------------------------------------------------------------------------- | ||
243 : | |||
244 : | ALIGN 16 | ||
245 : | sad16bi_x86_64: | ||
246 : | push rbx | ||
247 : | ; rcx is stride (4. arg) | ||
248 : | mov rbx, rdx ; ref2 | ||
249 : | mov rdx, rsi ; ref1 | ||
250 : | mov rax, rdi ; src | ||
251 : | |||
252 : | pxor mm5, mm5 ; accum1 | ||
253 : | pxor mm6, mm6 ; accum2 | ||
254 : | |||
255 : | SADBI_16x16_SSE | ||
256 : | SADBI_16x16_SSE | ||
257 : | SADBI_16x16_SSE | ||
258 : | SADBI_16x16_SSE | ||
259 : | SADBI_16x16_SSE | ||
260 : | SADBI_16x16_SSE | ||
261 : | SADBI_16x16_SSE | ||
262 : | SADBI_16x16_SSE | ||
263 : | |||
264 : | SADBI_16x16_SSE | ||
265 : | SADBI_16x16_SSE | ||
266 : | SADBI_16x16_SSE | ||
267 : | SADBI_16x16_SSE | ||
268 : | SADBI_16x16_SSE | ||
269 : | SADBI_16x16_SSE | ||
270 : | SADBI_16x16_SSE | ||
271 : | SADBI_16x16_SSE | ||
272 : | |||
273 : | paddusw mm6,mm5 | ||
274 : | movd eax, mm6 | ||
275 : | pop rbx | ||
276 : | ret | ||
277 : | .endfunc | ||
278 : | |||
279 : | ;----------------------------------------------------------------------------- | ||
280 : | ; | ||
281 : | ; uint32_t sad8bi_x86_64(const uint8_t * const cur, | ||
282 : | ; const uint8_t * const ref1, | ||
283 : | ; const uint8_t * const ref2, | ||
284 : | ; const uint32_t stride); | ||
285 : | ; | ||
286 : | ;----------------------------------------------------------------------------- | ||
287 : | |||
288 : | ALIGN 16 | ||
289 : | sad8bi_x86_64: | ||
290 : | push rbx | ||
291 : | ; rcx is stride | ||
292 : | mov rbx, rdx ; ref2 | ||
293 : | mov rdx, rsi ; ref1 | ||
294 : | mov rax, rdi ; src | ||
295 : | |||
296 : | pxor mm5, mm5 ; accum1 | ||
297 : | pxor mm6, mm6 ; accum2 | ||
298 : | .Loop | ||
299 : | SADBI_8x8_XMM | ||
300 : | SADBI_8x8_XMM | ||
301 : | SADBI_8x8_XMM | ||
302 : | SADBI_8x8_XMM | ||
303 : | |||
304 : | paddusw mm6,mm5 | ||
305 : | movd eax, mm6 | ||
306 : | pop rbx | ||
307 : | ret | ||
308 : | .endfunc | ||
309 : | |||
310 : | ;----------------------------------------------------------------------------- | ||
311 : | ; | ||
312 : | ; uint32_t dev16_x86_64(const uint8_t * const cur, | ||
313 : | ; const uint32_t stride); | ||
314 : | ; | ||
315 : | ;----------------------------------------------------------------------------- | ||
316 : | |||
317 : | ALIGN 16 | ||
318 : | dev16_x86_64: | ||
319 : | mov rcx, rsi ; stride | ||
320 : | mov rax, rdi ; src | ||
321 : | |||
322 : | pxor mm7, mm7 ; zero | ||
323 : | pxor mm5, mm5 ; mean accums | ||
324 : | pxor mm6, mm6 | ||
325 : | |||
326 : | MEAN_16x16_SSE | ||
327 : | MEAN_16x16_SSE | ||
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 : | |||
335 : | MEAN_16x16_SSE | ||
336 : | MEAN_16x16_SSE | ||
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 : | |||
344 : | paddusw mm6, mm5 | ||
345 : | |||
346 : | movq mm4, mm6 | ||
347 : | psllq mm4, 32 | ||
348 : | paddd mm4, mm6 | ||
349 : | psrld mm4, 8 ; /= (16*16) | ||
350 : | |||
351 : | packssdw mm4, mm4 | ||
352 : | packuswb mm4, mm4 | ||
353 : | |||
354 : | ; mm4 contains the mean | ||
355 : | |||
356 : | mov rax, rdi ; src | ||
357 : | |||
358 : | pxor mm5, mm5 ; sums | ||
359 : | pxor mm6, mm6 | ||
360 : | |||
361 : | ABS_16x16_SSE | ||
362 : | ABS_16x16_SSE | ||
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 : | |||
370 : | ABS_16x16_SSE | ||
371 : | ABS_16x16_SSE | ||
372 : | ABS_16x16_SSE | ||
373 : | ABS_16x16_SSE | ||
374 : | ABS_16x16_SSE | ||
375 : | ABS_16x16_SSE | ||
376 : | ABS_16x16_SSE | ||
377 : | ABS_16x16_SSE | ||
378 : | |||
379 : | paddusw mm6, mm5 | ||
380 : | movq mm7, mm6 | ||
381 : | psllq mm7, 32 | ||
382 : | paddd mm6, mm7 | ||
383 : | |||
384 : | movd eax, mm6 | ||
385 : | ret | ||
386 : | .endfunc | ||
387 : | |||
388 : | ;----------------------------------------------------------------------------- | ||
389 : | ;int sad16v_x86_64(const uint8_t * const cur, | ||
390 : | ; const uint8_t * const ref, | ||
391 : | ; const uint32_t stride, | ||
392 : | ; int* sad8); | ||
393 : | ;----------------------------------------------------------------------------- | ||
394 : | |||
395 : | ALIGN 16 | ||
396 : | sad16v_x86_64: | ||
397 : | push rbx | ||
398 : | |||
399 : | mov rbx, rcx ; sad ptr (64bit) | ||
400 : | mov rcx, rdx ; stride | ||
401 : | mov rdx, rsi ; src2 | ||
402 : | mov rax, rdi ; src1 | ||
403 : | |||
404 : | pxor mm5, mm5 ; accum1 | ||
405 : | pxor mm6, mm6 ; accum2 | ||
406 : | pxor mm7, mm7 ; total | ||
407 : | |||
408 : | SAD_16x16_SSE | ||
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 : | |||
417 : | paddusw mm7, mm5 | ||
418 : | paddusw mm7, mm6 | ||
419 : | movd [rbx], mm5 | ||
420 : | movd [rbx+4], mm6 | ||
421 : | |||
422 : | pxor mm5, mm5 ; accum1 | ||
423 : | pxor mm6, mm6 ; accum2 | ||
424 : | |||
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 : | SAD_16x16_SSE | ||
433 : | |||
434 : | paddusw mm7, mm5 | ||
435 : | paddusw mm7, mm6 | ||
436 : | movd [rbx+8], mm5 | ||
437 : | movd [rbx+12], mm6 | ||
438 : | |||
439 : | movd eax, mm7 | ||
440 : | pop rbx | ||
441 : | ret | ||
442 : | Isibaar | 1790 | .endfunc |
443 : | |||
444 : | %ifidn __OUTPUT_FORMAT__,elf | ||
445 : | section ".note.GNU-stack" noalloc noexec nowrite progbits | ||
446 : | %endif | ||
447 : |
No admin address has been configured | ViewVC Help |
Powered by ViewVC 1.0.4 |