1 |
;/***************************************************************************** |
;/************************************************************************** |
2 |
; * |
; * |
3 |
; * XVID MPEG-4 VIDEO CODEC |
; * XVID MPEG-4 VIDEO CODEC |
4 |
; * mmx sum of absolute difference |
; * mmx sum of absolute difference |
5 |
; * |
; * |
6 |
; * Copyright(C) 2002 Peter Ross <pross@xvid.org> |
; * 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 |
|
; * This file is part of XviD, a free MPEG-4 video encoder/decoder |
|
|
; * |
|
|
; * XviD is free software; you can redistribute it and/or modify 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 |
; * the Free Software Foundation; either version 2 of the License, or |
9 |
; * (at your option) any later version. |
; * (at your option) any later version. |
10 |
; * |
; * |
15 |
; * |
; * |
16 |
; * You should have received a copy of the GNU General Public License |
; * You should have received a copy of the GNU General Public License |
17 |
; * along with this program; if not, write to the Free Software |
; * along with this program; if not, write to the Free Software |
18 |
; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
; * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
; * |
|
|
; * Under section 8 of the GNU General Public License, the copyright |
|
|
; * holders of XVID explicitly forbid distribution in the following |
|
|
; * countries: |
|
|
; * |
|
|
; * - Japan |
|
|
; * - United States of America |
|
|
; * |
|
|
; * Linking XviD statically or dynamically with other modules is making a |
|
|
; * combined work based on XviD. Thus, the terms and conditions of the |
|
|
; * GNU General Public License cover the whole combination. |
|
19 |
; * |
; * |
20 |
; * As a special exception, the copyright holders of XviD give you |
; *************************************************************************/ |
21 |
; * permission to link XviD with independent modules that communicate with |
|
22 |
; * XviD solely through the VFW1.1 and DShow interfaces, regardless of the |
;/************************************************************************** |
|
; * license terms of these independent modules, and to copy and distribute |
|
|
; * the resulting combined work under terms of your choice, provided that |
|
|
; * every copy of the combined work is accompanied by a complete copy of |
|
|
; * the source code of XviD (the version of XviD used to produce the |
|
|
; * combined work), being distributed under the terms of the GNU General |
|
|
; * Public License plus this exception. An independent module is a module |
|
|
; * which is not derived from or based on XviD. |
|
23 |
; * |
; * |
24 |
; * Note that people who make modified versions of XviD are not obligated |
; * History: |
|
; * to grant this special exception for their modified versions; it is |
|
|
; * their choice whether to do so. The GNU General Public License gives |
|
|
; * permission to release a modified version without this exception; this |
|
|
; * exception also makes it possible to release a modified version which |
|
|
; * carries forward this exception. |
|
25 |
; * |
; * |
26 |
; * $Id: sad_mmx.asm,v 1.10 2002-11-17 00:32:06 edgomez Exp $ |
; * 23.07.2002 sad[16,8]bi_xmm; <pross@xvid.org> |
27 |
|
; * 04.06.2002 cleanup -Skal- |
28 |
|
; * 12.11.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
29 |
; * |
; * |
30 |
; ****************************************************************************/ |
; *************************************************************************/ |
31 |
|
|
32 |
bits 32 |
bits 32 |
33 |
|
|
48 |
section .text |
section .text |
49 |
|
|
50 |
cglobal sad16_mmx |
cglobal sad16_mmx |
51 |
|
cglobal sad16v_mmx |
52 |
cglobal sad8_mmx |
cglobal sad8_mmx |
53 |
cglobal sad16bi_mmx |
cglobal sad16bi_mmx |
54 |
cglobal sad8bi_mmx |
cglobal sad8bi_mmx |
203 |
ret |
ret |
204 |
|
|
205 |
|
|
206 |
|
;=========================================================================== |
207 |
|
; |
208 |
|
; uint32_t sad16v_mmx(const uint8_t * const cur, |
209 |
|
; const uint8_t * const ref, |
210 |
|
; const uint32_t stride, |
211 |
|
; int32_t *sad); |
212 |
|
; |
213 |
|
;=========================================================================== |
214 |
|
|
215 |
|
%macro SADV_16x16_MMX 0 |
216 |
|
movq mm0, [eax] |
217 |
|
movq mm1, [edx] |
218 |
|
|
219 |
|
movq mm2, [eax+8] |
220 |
|
movq mm3, [edx+8] |
221 |
|
|
222 |
|
movq mm4, mm0 |
223 |
|
psubusb mm0, mm1 |
224 |
|
|
225 |
|
psubusb mm1, mm4 |
226 |
|
por mm0, mm1 |
227 |
|
lea eax,[eax+ecx] |
228 |
|
|
229 |
|
movq mm4, mm2 |
230 |
|
psubusb mm2, mm3 |
231 |
|
|
232 |
|
psubusb mm3, mm4 |
233 |
|
por mm2, mm3 |
234 |
|
lea edx,[edx+ecx] |
235 |
|
|
236 |
|
movq mm1,mm0 |
237 |
|
movq mm3,mm2 |
238 |
|
|
239 |
|
punpcklbw mm0,mm7 |
240 |
|
punpckhbw mm1,mm7 |
241 |
|
punpcklbw mm2,mm7 |
242 |
|
punpckhbw mm3,mm7 |
243 |
|
|
244 |
|
paddusw mm0,mm1 |
245 |
|
paddusw mm2,mm3 |
246 |
|
|
247 |
|
paddusw mm5, mm0 |
248 |
|
paddusw mm6, mm2 |
249 |
|
%endmacro |
250 |
|
|
251 |
|
align 16 |
252 |
|
sad16v_mmx: |
253 |
|
|
254 |
|
push ebx |
255 |
|
push edi |
256 |
|
|
257 |
|
mov eax, [esp + 8 + 4] ; Src1 |
258 |
|
mov edx, [esp + 8 + 8] ; Src2 |
259 |
|
mov ecx, [esp + 8 + 12] ; Stride |
260 |
|
mov ebx, [esp + 8 + 16] ; sad ptr |
261 |
|
|
262 |
|
pxor mm5, mm5 ; accum |
263 |
|
pxor mm6, mm6 ; accum |
264 |
|
pxor mm7, mm7 ; zero |
265 |
|
|
266 |
|
SADV_16x16_MMX |
267 |
|
SADV_16x16_MMX |
268 |
|
SADV_16x16_MMX |
269 |
|
SADV_16x16_MMX |
270 |
|
SADV_16x16_MMX |
271 |
|
SADV_16x16_MMX |
272 |
|
SADV_16x16_MMX |
273 |
|
SADV_16x16_MMX |
274 |
|
|
275 |
|
pmaddwd mm5, [mmx_one] ; collapse |
276 |
|
pmaddwd mm6, [mmx_one] ; collapse |
277 |
|
|
278 |
|
movq mm2, mm5 |
279 |
|
movq mm3, mm6 |
280 |
|
|
281 |
|
psrlq mm2, 32 |
282 |
|
psrlq mm3, 32 |
283 |
|
|
284 |
|
paddd mm5, mm2 |
285 |
|
paddd mm6, mm3 |
286 |
|
|
287 |
|
movd [ebx], mm5 |
288 |
|
movd [ebx + 4], mm6 |
289 |
|
|
290 |
|
paddd mm5, mm6 |
291 |
|
|
292 |
|
movd edi, mm5 |
293 |
|
|
294 |
|
pxor mm5, mm5 |
295 |
|
pxor mm6, mm6 |
296 |
|
|
297 |
|
SADV_16x16_MMX |
298 |
|
SADV_16x16_MMX |
299 |
|
SADV_16x16_MMX |
300 |
|
SADV_16x16_MMX |
301 |
|
SADV_16x16_MMX |
302 |
|
SADV_16x16_MMX |
303 |
|
SADV_16x16_MMX |
304 |
|
SADV_16x16_MMX |
305 |
|
|
306 |
|
pmaddwd mm5, [mmx_one] ; collapse |
307 |
|
pmaddwd mm6, [mmx_one] ; collapse |
308 |
|
|
309 |
|
movq mm2, mm5 |
310 |
|
movq mm3, mm6 |
311 |
|
|
312 |
|
psrlq mm2, 32 |
313 |
|
psrlq mm3, 32 |
314 |
|
|
315 |
|
paddd mm5, mm2 |
316 |
|
paddd mm6, mm3 |
317 |
|
|
318 |
|
movd [ebx + 8], mm5 |
319 |
|
movd [ebx + 12], mm6 |
320 |
|
|
321 |
|
paddd mm5, mm6 |
322 |
|
|
323 |
|
movd eax, mm5 |
324 |
|
|
325 |
|
add eax, edi |
326 |
|
|
327 |
|
pop edi |
328 |
|
pop ebx |
329 |
|
ret |
330 |
|
|
331 |
|
|
332 |
|
|
610 |
|
|
611 |
movd eax, mm6 |
movd eax, mm6 |
612 |
ret |
ret |
|
|
|