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

Diff of /branches/dev-api-4/xvidcore/src/motion/x86_asm/sad_mmx.asm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/xvidcore/src/motion/x86_asm/sad_mmx.asm revision 652, Sun Nov 17 00:35:33 2002 UTC branches/dev-api-4/xvidcore/src/motion/x86_asm/sad_mmx.asm revision 1192, Tue Oct 28 22:23:03 2003 UTC
# Line 1  Line 1 
1  ;/*****************************************************************************  ;/****************************************************************************
2  ; *  ; *
3  ; *  XVID MPEG-4 VIDEO CODEC  ; *  XVID MPEG-4 VIDEO CODEC
4  ; *  mmx sum of absolute difference  ; *  - K7 optimized SAD operators -
5  ; *  ; *
6  ; *  Copyright(C) 2002 Peter Ross <pross@xvid.org>  ; *  Copyright(C) 2001 Peter Ross <pross@xvid.org>
7    ; *               2002 Pascal Massimino <skal@planet-d.net>
8  ; *  ; *
9  ; *  This file is part of XviD, a free MPEG-4 video encoder/decoder  ; *  This program is free software; you can redistribute it and/or modify it
 ; *  
 ; *  XviD is free software; you can redistribute it and/or modify it  
10  ; *  under the terms of the GNU General Public License as published by  ; *  under the terms of the GNU General Public License as published by
11  ; *  the Free Software Foundation; either version 2 of the License, or  ; *  the Free Software Foundation; either version 2 of the License, or
12  ; *  (at your option) any later version.  ; *  (at your option) any later version.
# Line 21  Line 20 
20  ; *  along with this program; if not, write to the Free Software  ; *  along with this program; if not, write to the Free Software
21  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22  ; *  ; *
23  ; *  Under section 8 of the GNU General Public License, the copyright  ; * $Id: sad_mmx.asm,v 1.11.2.1 2003-10-28 22:23:03 edgomez Exp $
 ; *  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.  
 ; *  
 ; *  As a special exception, the copyright holders of XviD give you  
 ; *  permission to link XviD with independent modules that communicate with  
 ; *  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.  
 ; *  
 ; *  Note that people who make modified versions of XviD are not obligated  
 ; *  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.  
 ; *  
 ; * $Id: sad_mmx.asm,v 1.10 2002-11-17 00:32:06 edgomez Exp $  
24  ; *  ; *
25  ; ****************************************************************************/  ; ***************************************************************************/
26    
27  bits 32  BITS 32
28    
29  %macro cglobal 1  %macro cglobal 1
30          %ifdef PREFIX          %ifdef PREFIX
# Line 65  Line 35 
35          %endif          %endif
36  %endmacro  %endmacro
37    
38  section .data  ;=============================================================================
39    ; Read only data
40  align 16  ;=============================================================================
41  mmx_one times 4 dw 1  
42    SECTION .rodata
43  section .text  
44    ALIGN 16
45  cglobal  sad16_mmx  mmx_one:
46  cglobal  sad8_mmx          times 4 dw 1
47  cglobal  sad16bi_mmx  
48  cglobal  sad8bi_mmx  ;=============================================================================
49  cglobal  dev16_mmx  ; Helper macros
50    ;=============================================================================
 ;===========================================================================  
 ;  
 ; uint32_t sad16_mmx(const uint8_t * const cur,  
 ;                                        const uint8_t * const ref,  
 ;                                        const uint32_t stride,  
 ;                                        const uint32_t best_sad);  
 ;  
 ; (early termination ignore; slows this down)  
 ;  
 ;===========================================================================  
51    
52  %macro SAD_16x16_MMX 0  %macro SAD_16x16_MMX 0
53      movq mm0, [eax]      movq mm0, [eax]
# Line 122  Line 82 
82      paddusw mm6,mm2      paddusw mm6,mm2
83  %endmacro  %endmacro
84    
 align 16  
 sad16_mmx:  
   
     mov eax, [esp+ 4] ; Src1  
     mov edx, [esp+ 8] ; Src2  
     mov ecx, [esp+12] ; Stride  
   
     pxor mm6, mm6 ; accum  
     pxor mm7, mm7 ; zero  
   
     SAD_16x16_MMX  
     SAD_16x16_MMX  
     SAD_16x16_MMX  
     SAD_16x16_MMX  
     SAD_16x16_MMX  
     SAD_16x16_MMX  
     SAD_16x16_MMX  
     SAD_16x16_MMX  
   
     SAD_16x16_MMX  
     SAD_16x16_MMX  
     SAD_16x16_MMX  
     SAD_16x16_MMX  
     SAD_16x16_MMX  
     SAD_16x16_MMX  
     SAD_16x16_MMX  
     SAD_16x16_MMX  
   
     pmaddwd mm6, [mmx_one] ; collapse  
     movq mm7, mm6  
     psrlq mm7, 32  
     paddd mm6, mm7  
   
     movd eax, mm6  
   
     ret  
   
   
 ;===========================================================================  
 ;  
 ; uint32_t sad8_mmx(const uint8_t * const cur,  
 ;                                       const uint8_t * const ref,  
 ;                                       const uint32_t stride);  
 ;  
 ;===========================================================================  
   
85  %macro SAD_8x8_MMX  0  %macro SAD_8x8_MMX  0
86      movq mm0, [eax]      movq mm0, [eax]
87      movq mm1, [edx]      movq mm1, [edx]
# Line 202  Line 116 
116      paddusw mm6,mm2      paddusw mm6,mm2
117  %endmacro  %endmacro
118    
119  align 16  %macro SADV_16x16_MMX 0
120  sad8_mmx:    movq mm0, [eax]
121      movq mm1, [edx]
     mov eax, [esp+ 4] ; Src1  
     mov edx, [esp+ 8] ; Src2  
     mov ecx, [esp+12] ; Stride  
122    
123      pxor mm6, mm6 ; accum    movq mm2, [eax+8]
124      pxor mm7, mm7 ; zero    movq mm3, [edx+8]
125    
126      SAD_8x8_MMX    movq mm4, mm0
127      SAD_8x8_MMX    psubusb mm0, mm1
     SAD_8x8_MMX  
     SAD_8x8_MMX  
128    
129      pmaddwd mm6, [mmx_one] ; collapse    psubusb mm1, mm4
130      movq mm7, mm6    por mm0, mm1
131      psrlq mm7, 32    lea eax,[eax+ecx]
     paddd mm6, mm7  
132    
133      movd eax, mm6    movq mm4, mm2
134      psubusb mm2, mm3
135    
136      ret    psubusb mm3, mm4
137      por mm2, mm3
138      lea edx,[edx+ecx]
139    
140      movq mm1,mm0
141      movq mm3,mm2
142    
143      punpcklbw mm0,mm7
144      punpckhbw mm1,mm7
145      punpcklbw mm2,mm7
146      punpckhbw mm3,mm7
147    
148      paddusw mm0,mm1
149      paddusw mm2,mm3
150    
151      paddusw mm5, mm0
152      paddusw mm6, mm2
153    %endmacro
154    
 ;===========================================================================  
 ;  
 ; uint32_t sad16bi_mmx(const uint8_t * const cur,  
 ; const uint8_t * const ref1,  
 ; const uint8_t * const ref2,  
 ; const uint32_t stride);  
 ;  
 ;===========================================================================  
155  %macro SADBI_16x16_MMX 2    ; SADBI_16x16_MMX( int_ptr_offset, bool_increment_ptr );  %macro SADBI_16x16_MMX 2    ; SADBI_16x16_MMX( int_ptr_offset, bool_increment_ptr );
156    
157     movq mm0, [edx+%1]     movq mm0, [edx+%1]
# Line 288  Line 202 
202    
203  %endmacro  %endmacro
204    
205  align 16  %macro MEAN_16x16_MMX 0
206      movq mm0, [eax]
207      movq mm2, [eax+8]
208      lea eax, [eax+ecx]
209      movq mm1, mm0
210      movq mm3, mm2
211      punpcklbw mm0, mm7
212      punpcklbw mm2, mm7
213      punpckhbw mm1, mm7
214      punpckhbw mm3, mm7
215      paddw mm5, mm0
216      paddw mm6, mm1
217      paddw mm5, mm2
218      paddw mm6, mm3
219    %endmacro
220    
221    %macro ABS_16x16_MMX 0
222      movq mm0, [eax]
223      movq mm2, [eax+8]
224      lea eax, [eax+ecx]
225      movq mm1, mm0
226      movq mm3, mm2
227      punpcklbw mm0, mm7
228      punpcklbw mm2, mm7
229      punpckhbw mm1, mm7
230      punpckhbw mm3, mm7
231      movq mm4, mm6
232      psubusw mm4, mm0
233    
234      psubusw mm0, mm6
235      por mm0, mm4
236      movq mm4, mm6
237      psubusw mm4, mm1
238      psubusw mm1, mm6
239      por mm1, mm4
240    
241      movq mm4, mm6
242      psubusw mm4, mm2
243      psubusw mm2, mm6
244      por mm2, mm4
245      movq mm4, mm6
246      psubusw mm4, mm3
247      psubusw mm3, mm6
248      por mm3, mm4
249    
250      paddw mm0, mm1
251      paddw mm2, mm3
252      paddw mm5, mm0
253      paddw mm5, mm2
254    %endmacro
255    
256    ;=============================================================================
257    ; Code
258    ;=============================================================================
259    
260    SECTION .text
261    
262    cglobal  sad16_mmx
263    cglobal  sad16v_mmx
264    cglobal  sad8_mmx
265    cglobal  sad16bi_mmx
266    cglobal  sad8bi_mmx
267    cglobal  dev16_mmx
268    
269    ;-----------------------------------------------------------------------------
270    ;
271    ; uint32_t sad16_mmx(const uint8_t * const cur,
272    ;                                        const uint8_t * const ref,
273    ;                                        const uint32_t stride,
274    ;                                        const uint32_t best_sad);
275    ;
276    ; (early termination ignore; slows this down)
277    ;
278    ;-----------------------------------------------------------------------------
279    
280    ALIGN 16
281    sad16_mmx:
282    
283      mov eax, [esp+ 4] ; Src1
284      mov edx, [esp+ 8] ; Src2
285      mov ecx, [esp+12] ; Stride
286    
287      pxor mm6, mm6 ; accum
288      pxor mm7, mm7 ; zero
289    
290      SAD_16x16_MMX
291      SAD_16x16_MMX
292      SAD_16x16_MMX
293      SAD_16x16_MMX
294      SAD_16x16_MMX
295      SAD_16x16_MMX
296      SAD_16x16_MMX
297      SAD_16x16_MMX
298    
299      SAD_16x16_MMX
300      SAD_16x16_MMX
301      SAD_16x16_MMX
302      SAD_16x16_MMX
303      SAD_16x16_MMX
304      SAD_16x16_MMX
305      SAD_16x16_MMX
306      SAD_16x16_MMX
307    
308      pmaddwd mm6, [mmx_one] ; collapse
309      movq mm7, mm6
310      psrlq mm7, 32
311      paddd mm6, mm7
312    
313      movd eax, mm6
314    
315      ret
316    
317    ;-----------------------------------------------------------------------------
318    ;
319    ; uint32_t sad8_mmx(const uint8_t * const cur,
320    ;                                       const uint8_t * const ref,
321    ;                                       const uint32_t stride);
322    ;
323    ;-----------------------------------------------------------------------------
324    
325    ALIGN 16
326    sad8_mmx:
327    
328      mov eax, [esp+ 4] ; Src1
329      mov edx, [esp+ 8] ; Src2
330      mov ecx, [esp+12] ; Stride
331    
332      pxor mm6, mm6 ; accum
333      pxor mm7, mm7 ; zero
334    
335      SAD_8x8_MMX
336      SAD_8x8_MMX
337      SAD_8x8_MMX
338      SAD_8x8_MMX
339    
340      pmaddwd mm6, [mmx_one] ; collapse
341      movq mm7, mm6
342      psrlq mm7, 32
343      paddd mm6, mm7
344    
345      movd eax, mm6
346    
347      ret
348    
349    ;-----------------------------------------------------------------------------
350    ;
351    ; uint32_t sad16v_mmx(const uint8_t * const cur,
352    ;                                     const uint8_t * const ref,
353    ;                                         const uint32_t stride,
354    ;                                         int32_t *sad);
355    ;
356    ;-----------------------------------------------------------------------------
357    
358    ALIGN 16
359    sad16v_mmx:
360    
361      push ebx
362      push edi
363    
364      mov eax, [esp + 8 + 4] ; Src1
365      mov edx, [esp + 8 + 8] ; Src2
366      mov ecx, [esp + 8 + 12] ; Stride
367      mov ebx, [esp + 8 + 16] ; sad ptr
368    
369      pxor mm5, mm5 ; accum
370      pxor mm6, mm6 ; accum
371      pxor mm7, mm7 ; zero
372    
373      SADV_16x16_MMX
374      SADV_16x16_MMX
375      SADV_16x16_MMX
376      SADV_16x16_MMX
377      SADV_16x16_MMX
378      SADV_16x16_MMX
379      SADV_16x16_MMX
380      SADV_16x16_MMX
381    
382      pmaddwd mm5, [mmx_one] ; collapse
383      pmaddwd mm6, [mmx_one] ; collapse
384    
385      movq mm2, mm5
386      movq mm3, mm6
387    
388      psrlq mm2, 32
389      psrlq mm3, 32
390    
391      paddd mm5, mm2
392      paddd mm6, mm3
393    
394      movd [ebx], mm5
395      movd [ebx + 4], mm6
396    
397      paddd mm5, mm6
398    
399      movd edi, mm5
400    
401      pxor mm5, mm5
402      pxor mm6, mm6
403    
404      SADV_16x16_MMX
405      SADV_16x16_MMX
406      SADV_16x16_MMX
407      SADV_16x16_MMX
408      SADV_16x16_MMX
409      SADV_16x16_MMX
410      SADV_16x16_MMX
411      SADV_16x16_MMX
412    
413      pmaddwd mm5, [mmx_one] ; collapse
414      pmaddwd mm6, [mmx_one] ; collapse
415    
416      movq mm2, mm5
417      movq mm3, mm6
418    
419      psrlq mm2, 32
420      psrlq mm3, 32
421    
422      paddd mm5, mm2
423      paddd mm6, mm3
424    
425      movd [ebx + 8], mm5
426      movd [ebx + 12], mm6
427    
428      paddd mm5, mm6
429    
430      movd eax, mm5
431    
432      add eax, edi
433    
434      pop edi
435      pop ebx
436    
437      ret
438    
439    ;-----------------------------------------------------------------------------
440    ;
441    ; uint32_t sad16bi_mmx(const uint8_t * const cur,
442    ; const uint8_t * const ref1,
443    ; const uint8_t * const ref2,
444    ; const uint32_t stride);
445    ;
446    ;-----------------------------------------------------------------------------
447    
448    ALIGN 16
449  sad16bi_mmx:  sad16bi_mmx:
450     push ebx     push ebx
451     mov eax, [esp+4+ 4] ; Src     mov eax, [esp+4+ 4] ; Src
# Line 340  Line 497 
497    
498     movd eax, mm6     movd eax, mm6
499     pop ebx     pop ebx
500    
501     ret     ret
502    
503  ;===========================================================================  ;-----------------------------------------------------------------------------
504  ;  ;
505  ; uint32_t sad8bi_mmx(const uint8_t * const cur,  ; uint32_t sad8bi_mmx(const uint8_t * const cur,
506  ; const uint8_t * const ref1,  ; const uint8_t * const ref1,
507  ; const uint8_t * const ref2,  ; const uint8_t * const ref2,
508  ; const uint32_t stride);  ; const uint32_t stride);
509  ;  ;
510  ;===========================================================================  ;-----------------------------------------------------------------------------
511  align 16  
512    ALIGN 16
513  sad8bi_mmx:  sad8bi_mmx:
514     push ebx     push ebx
515     mov eax, [esp+4+ 4] ; Src     mov eax, [esp+4+ 4] ; Src
# Line 379  Line 538 
538     pop ebx     pop ebx
539     ret     ret
540    
541    ;-----------------------------------------------------------------------------
   
   
 ;===========================================================================  
542  ;  ;
543  ; uint32_t dev16_mmx(const uint8_t * const cur,  ; uint32_t dev16_mmx(const uint8_t * const cur,
544  ;                                       const uint32_t stride);  ;                                       const uint32_t stride);
545  ;  ;
546  ;===========================================================================  ;-----------------------------------------------------------------------------
547    
548  %macro MEAN_16x16_MMX 0  ALIGN 16
     movq mm0, [eax]  
     movq mm2, [eax+8]  
     lea eax,[eax+ecx]  
     movq mm1, mm0  
     movq mm3, mm2  
     punpcklbw mm0,mm7  
     punpcklbw mm2,mm7  
     punpckhbw mm1,mm7  
     punpckhbw mm3,mm7  
     paddw mm5, mm0  
     paddw mm6, mm1  
     paddw mm5, mm2  
     paddw mm6, mm3  
 %endmacro  
   
 %macro ABS_16x16_MMX 0  
     movq mm0, [eax]  
     movq mm2, [eax+8]  
     lea eax,[eax+ecx]  
     movq mm1, mm0  
     movq mm3, mm2  
     punpcklbw mm0, mm7  
     punpcklbw mm2, mm7  
     punpckhbw mm1, mm7  
     punpckhbw mm3, mm7  
     movq mm4, mm6  
         psubusw mm4, mm0  
   
         psubusw mm0, mm6  
         por mm0, mm4  
         movq mm4, mm6  
         psubusw mm4, mm1  
         psubusw mm1, mm6  
         por mm1, mm4  
   
     movq mm4, mm6  
         psubusw mm4, mm2  
         psubusw mm2, mm6  
         por mm2, mm4  
         movq mm4, mm6  
         psubusw mm4, mm3  
         psubusw mm3, mm6  
         por mm3, mm4  
   
         paddw mm0, mm1  
         paddw mm2, mm3  
         paddw mm5, mm0  
         paddw mm5, mm2  
 %endmacro  
   
 align 16  
549  dev16_mmx:  dev16_mmx:
550      mov eax, [esp+ 4] ; Src      mov eax, [esp+ 4] ; Src
551      mov ecx, [esp+ 8] ; Stride      mov ecx, [esp+ 8] ; Stride
# Line 509  Line 614 
614      paddd mm6, mm5      paddd mm6, mm5
615    
616      movd eax, mm6      movd eax, mm6
     ret  
617    
618      ret

Legend:
Removed from v.652  
changed lines
  Added in v.1192

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