[cvs] / xvidcore / src / motion / x86_asm / sad_xmm.asm Repository:
ViewVC logotype

Diff of /xvidcore/src/motion/x86_asm/sad_xmm.asm

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

revision 1.4, Tue Sep 10 19:28:01 2002 UTC revision 1.9, Sun Aug 22 11:46:10 2004 UTC
# Line 1  Line 1 
1  ;/*****************************************************************************  ;/****************************************************************************
2  ; *  ; *
3  ; *  XVID MPEG-4 VIDEO CODEC  ; *  XVID MPEG-4 VIDEO CODEC
4  ; *  xmm (extended 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  ; *  Copyright(C) 2002 Michael Militzer <michael@xvid.org>  ; *               2001 Michael Militzer <isibaar@xvid.org>
8  ; *  Copyright(C) 2002 Pascal Massimino <skal@planet-d.net>  ; *               2002 Pascal Massimino <skal@planet-d.net>
9  ; *  ; *
10  ; *  This program is an implementation of a part of one or more MPEG-4  ; *  This program is free software; you can redistribute it and/or modify it
11  ; *  Video tools as specified in ISO/IEC 14496-2 standard.  Those intending  ; *  under the terms of the GNU General Public License as published by
 ; *  to use this software module in hardware or software products are  
 ; *  advised that its use may infringe existing patents or copyrights, and  
 ; *  any such use would be at such party's own risk.  The original  
 ; *  developer of this software module and his/her company, and subsequent  
 ; *  editors and their companies, will have no liability for use of this  
 ; *  software or modifications or derivatives thereof.  
 ; *  
 ; *  This program is free software; you can redistribute it and/or modify  
 ; *  it under the terms of the GNU General Public License as published by  
12  ; *  the Free Software Foundation; either version 2 of the License, or  ; *  the Free Software Foundation; either version 2 of the License, or
13  ; *  (at your option) any later version.  ; *  (at your option) any later version.
14  ; *  ; *
# Line 30  Line 21 
21  ; *  along with this program; if not, write to the Free Software  ; *  along with this program; if not, write to the Free Software
22  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
23  ; *  ; *
24  ; *************************************************************************/  ; * $Id$
25    ; *
26    ; ***************************************************************************/
27    
28  bits 32  BITS 32
29    
30  %macro cglobal 1  %macro cglobal 1
31          %ifdef PREFIX          %ifdef PREFIX
32                    %ifdef MARK_FUNCS
33                            global _%1:function
34                            %define %1 _%1:function
35                    %else
36                  global _%1                  global _%1
37                  %define %1 _%1                  %define %1 _%1
38                    %endif
39            %else
40                    %ifdef MARK_FUNCS
41                            global %1:function
42          %else          %else
43                  global %1                  global %1
44          %endif          %endif
45            %endif
46    %endmacro
47    
48    ;=============================================================================
49    ; Read only data
50    ;=============================================================================
51    
52    %ifdef FORMAT_COFF
53    SECTION .rodata
54    %else
55    SECTION .rodata align=16
56    %endif
57    
58    ALIGN 16
59    mmx_one: times 4 dw 1
60    
61    ;=============================================================================
62    ; Helper macros
63    ;=============================================================================
64    
65    %macro SAD_16x16_SSE 0
66      movq mm0, [eax]
67      psadbw mm0, [edx]
68      movq mm1, [eax+8]
69      add eax, ecx
70      psadbw mm1, [edx+8]
71      paddusw mm5, mm0
72      add edx, ecx
73      paddusw mm6, mm1
74    %endmacro
75    
76    %macro SAD_8x8_SSE 0
77      movq mm0, [eax]
78      movq mm1, [eax+ecx]
79      psadbw mm0, [edx]
80      psadbw mm1, [edx+ecx]
81      add eax, ebx
82      add edx, ebx
83            paddusw mm5, mm0
84            paddusw mm6, mm1
85    %endmacro
86    
87    %macro SADBI_16x16_SSE 0
88      movq mm0, [eax]
89      movq mm1, [eax+8]
90      movq mm2, [edx]
91      movq mm3, [edx+8]
92      pavgb mm2, [ebx]
93      add edx, ecx
94      pavgb mm3, [ebx+8]
95      add ebx, ecx
96      psadbw mm0, mm2
97      add eax, ecx
98      psadbw mm1, mm3
99      paddusw mm5, mm0
100      paddusw mm6, mm1
101    %endmacro
102    
103    %macro SADBI_8x8_XMM 0
104      movq mm0, [eax]
105      movq mm1, [eax+ecx]
106      movq mm2, [edx]
107      movq mm3, [edx+ecx]
108      pavgb mm2, [ebx]
109      lea edx, [edx+2*ecx]
110      pavgb mm3, [ebx+ecx]
111      lea ebx, [ebx+2*ecx]
112      psadbw mm0, mm2
113      lea eax, [eax+2*ecx]
114      psadbw mm1, mm3
115      paddusw mm5, mm0
116      paddusw mm6, mm1
117  %endmacro  %endmacro
118    
119  section .data  %macro MEAN_16x16_SSE 0
120      movq mm0, [eax]
121      movq mm1, [eax+8]
122      psadbw mm0, mm7
123      psadbw mm1, mm7
124      add eax, ecx
125      paddw mm5, mm0
126      paddw mm6, mm1
127    %endmacro
128    
129    %macro ABS_16x16_SSE 0
130      movq mm0, [eax]
131      movq mm1, [eax+8]
132      psadbw mm0, mm4
133      psadbw mm1, mm4
134      lea eax, [eax+ecx]
135      paddw mm5, mm0
136      paddw mm6, mm1
137    %endmacro
138    
139  align 16  ;=============================================================================
140  mmx_one times 4 dw 1  ; Code
141    ;=============================================================================
142    
143  section .text  SECTION .text
144    
145  cglobal  sad16_xmm  cglobal  sad16_xmm
146  cglobal  sad8_xmm  cglobal  sad8_xmm
147  cglobal  sad16bi_xmm  cglobal  sad16bi_xmm
148  cglobal  sad8bi_xmm  cglobal  sad8bi_xmm
149  cglobal  dev16_xmm  cglobal  dev16_xmm
150    cglobal sad16v_xmm
151    
152  ;===========================================================================  ;-----------------------------------------------------------------------------
153  ;  ;
154  ; uint32_t sad16_xmm(const uint8_t * const cur,  ; uint32_t sad16_xmm(const uint8_t * const cur,
155  ;                                       const uint8_t * const ref,  ;                                       const uint8_t * const ref,
156  ;                                       const uint32_t stride,  ;                                       const uint32_t stride,
157  ;                                       const uint32_t best_sad);  ;                                       const uint32_t best_sad);
158  ;  ;
159  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %macro SAD_16x16_SSE 0  
     movq mm0, [eax]  
     psadbw mm0, [edx]  
     movq mm1, [eax+8]  
     add eax, ecx  
     psadbw mm1, [edx+8]  
     paddusw mm5,mm0  
     add edx, ecx  
     paddusw mm6,mm1  
 %endmacro  
160    
161  align 16  ALIGN 16
162  sad16_xmm:  sad16_xmm:
163    
164      mov eax, [esp+ 4] ; Src1      mov eax, [esp+ 4] ; Src1
# Line 109  Line 191 
191      ret      ret
192    
193    
194  ;===========================================================================  ;-----------------------------------------------------------------------------
195  ;  ;
196  ; uint32_t sad8_xmm(const uint8_t * const cur,  ; uint32_t sad8_xmm(const uint8_t * const cur,
197  ;                                       const uint8_t * const ref,  ;                                       const uint8_t * const ref,
198  ;                                       const uint32_t stride);  ;                                       const uint32_t stride);
199  ;  ;
200  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %macro SAD_8x8_SSE 0  
     movq mm0, [eax]  
     movq mm1, [eax+ecx]  
   
     psadbw mm0, [edx]  
     psadbw mm1, [edx+ecx]  
     add eax, ebx  
     add edx, ebx  
201    
202      paddusw mm5,mm0  ALIGN 16
     paddusw mm6,mm1  
 %endmacro  
   
 align 16  
203  sad8_xmm:  sad8_xmm:
204    
205      mov eax, [esp+ 4] ; Src1      mov eax, [esp+ 4] ; Src1
# Line 162  Line 231 
231      ret      ret
232    
233    
234  ;===========================================================================  ;-----------------------------------------------------------------------------
235  ;  ;
236  ; uint32_t sad16bi_xmm(const uint8_t * const cur,  ; uint32_t sad16bi_xmm(const uint8_t * const cur,
237  ;                                       const uint8_t * const ref1,  ;                                       const uint8_t * const ref1,
238  ;                                       const uint8_t * const ref2,  ;                                       const uint8_t * const ref2,
239  ;                                       const uint32_t stride);  ;                                       const uint32_t stride);
240  ;  ;
241  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %macro SADBI_16x16_SSE 0  
     movq mm0, [eax]  
     movq mm1, [eax+8]  
   
     movq mm2, [edx]  
     movq mm3, [edx+8]  
   
     pavgb mm2, [ebx]  
     add edx, ecx  
   
     pavgb mm3, [ebx+8]  
     add ebx, ecx  
   
     psadbw mm0, mm2  
     add eax, ecx  
   
     psadbw mm1, mm3  
     paddusw mm5,mm0  
   
     paddusw mm6,mm1  
 %endmacro  
242    
243  align 16  ALIGN 16
244  sad16bi_xmm:  sad16bi_xmm:
245      push ebx      push ebx
246      mov eax, [esp+4+ 4] ; Src      mov eax, [esp+4+ 4] ; Src
# Line 227  Line 274 
274      pop ebx      pop ebx
275      ret      ret
276    
277  ;===========================================================================  ;-----------------------------------------------------------------------------
278  ;  ;
279  ; uint32_t sad8bi_xmm(const uint8_t * const cur,  ; uint32_t sad8bi_xmm(const uint8_t * const cur,
280  ; const uint8_t * const ref1,  ; const uint8_t * const ref1,
281  ; const uint8_t * const ref2,  ; const uint8_t * const ref2,
282  ; const uint32_t stride);  ; const uint32_t stride);
283  ;  ;
284  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %macro SADBI_8x8_XMM 0  
    movq mm0, [eax]  
    movq mm1, [eax+ecx]  
   
    movq mm2, [edx]  
    movq mm3, [edx+ecx]  
   
    pavgb mm2, [ebx]  
    lea edx, [edx+2*ecx]  
   
    pavgb mm3, [ebx+ecx]  
    lea ebx, [ebx+2*ecx]  
   
    psadbw mm0, mm2  
    lea eax, [eax+2*ecx]  
   
    psadbw mm1, mm3  
    paddusw mm5,mm0  
285    
286     paddusw mm6,mm1  ALIGN 16
 %endmacro  
   
 align 16  
287  sad8bi_xmm:  sad8bi_xmm:
288     push ebx     push ebx
289     mov eax, [esp+4+ 4] ; Src     mov eax, [esp+4+ 4] ; Src
# Line 280  Line 305 
305     ret     ret
306    
307    
308  ;===========================================================================  ;-----------------------------------------------------------------------------
309  ;  ;
310  ; uint32_t dev16_xmm(const uint8_t * const cur,  ; uint32_t dev16_xmm(const uint8_t * const cur,
311  ;                                       const uint32_t stride);  ;                                       const uint32_t stride);
312  ;  ;
313  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %macro MEAN_16x16_SSE 0  
     movq mm0, [eax]  
     movq mm1, [eax+8]  
     psadbw mm0, mm7  
     psadbw mm1, mm7  
     add eax, ecx  
     paddw mm5, mm0  
     paddw mm6, mm1  
 %endmacro  
   
 %macro ABS_16x16_SSE 0  
     movq mm0, [eax]  
     movq mm1, [eax+8]  
     psadbw mm0, mm4  
     psadbw mm1, mm4  
     lea eax,[eax+ecx]  
     paddw mm5, mm0  
     paddw mm6, mm1  
 %endmacro  
314    
315  align 16  ALIGN 16
316  dev16_xmm:  dev16_xmm:
317    
318      mov eax, [esp+ 4] ; Src      mov eax, [esp+ 4] ; Src
# Line 349  Line 354 
354    
355      mov eax, [esp+ 4] ; Src      mov eax, [esp+ 4] ; Src
356    
357    
358      pxor mm5, mm5 ; sums      pxor mm5, mm5 ; sums
359      pxor mm6, mm6      pxor mm6, mm6
360    
# Line 377  Line 383 
383    
384      movd eax, mm6      movd eax, mm6
385      ret      ret
386    
387    ;-----------------------------------------------------------------------------
388    ;int sad16v_xmm(const uint8_t * const cur,
389    ;               const uint8_t * const ref,
390    ;               const uint32_t stride,
391    ;               int* sad8);
392    ;-----------------------------------------------------------------------------
393    
394    ALIGN 16
395    sad16v_xmm:
396      push ebx
397      mov eax, [esp+4+ 4] ; Src1
398      mov edx, [esp+4+ 8] ; Src2
399      mov ecx, [esp+4+12] ; Stride
400      mov ebx, [esp+4+16] ; sad ptr
401    
402      pxor mm5, mm5 ; accum1
403      pxor mm6, mm6 ; accum2
404      pxor mm7, mm7 ; total
405    
406      SAD_16x16_SSE
407      SAD_16x16_SSE
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    
415      paddusw mm7, mm5
416      paddusw mm7, mm6
417      movd [ebx], mm5
418      movd [ebx+4], mm6
419    
420      pxor mm5, mm5 ; accum1
421      pxor mm6, mm6 ; accum2
422    
423      SAD_16x16_SSE
424      SAD_16x16_SSE
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    
432      paddusw mm7, mm5
433      paddusw mm7, mm6
434      movd [ebx+8], mm5
435      movd [ebx+12], mm6
436    
437      movd eax, mm7
438      pop ebx
439      ret

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.9

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