[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.6, Sat Feb 15 15:22:19 2003 UTC revision 1.10, Sun Aug 29 10:02:38 2004 UTC
# Line 1  Line 1 
1  ;/**************************************************************************  ;/****************************************************************************
2  ; *  ; *
3  ; *     XVID MPEG-4 VIDEO CODEC  ; *     XVID MPEG-4 VIDEO CODEC
4  ; *     xmm sum of absolute difference  ; *  - K7 optimized SAD operators -
5  ; *  ; *
6  ; *     This program is an implementation of a part of one or more MPEG-4  ; *  Copyright(C) 2001 Peter Ross <pross@xvid.org>
7  ; *     Video tools as specified in ISO/IEC 14496-2 standard.  Those intending  ; *               2001 Michael Militzer <isibaar@xvid.org>
8  ; *     to use this software module in hardware or software products are  ; *               2002 Pascal Massimino <skal@planet-d.net>
 ; *     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.  
9  ; *  ; *
10  ; *     This program is free software; you can redistribute it and/or modify  ; *  This program is free software; you can redistribute it and/or modify it
11  ; *     it under the terms of the GNU General Public License as published by  ; *  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 24  Line 19 
19  ; *  ; *
20  ; *     You should have received a copy of the GNU General Public License  ; *     You should have received a copy of the GNU General Public License
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., 675 Mass Ave, Cambridge, MA 02139, USA.  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
23  ; *  ; *
24  ; *************************************************************************/  ; * $Id$
   
 ;/**************************************************************************  
 ; *  
 ; *     History:  
 ; *  
 ; * 23.07.2002  sad8bi_xmm; <pross@xvid.org>  
 ; * 04.06.2002  rewrote some funcs (XMM mainly)     -Skal-  
 ; * 17.11.2001  bugfix and small improvement for dev16_xmm,  
 ; *             removed terminate early in sad16_xmm (Isibaar)  
 ; *     12.11.2001      inital version; (c)2001 peter ross <pross@cs.rmit.edu.au>  
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 %1.endfunc-%1
34                            %define %1 _%1:function %1.endfunc-%1
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 %1.endfunc-%1
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
118    
119    %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  %endmacro
128    
129  section .data  %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  ;===========================================================================  ;-----------------------------------------------------------------------------
160    
161  %macro SAD_16x16_SSE 0  ALIGN 16
     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  
   
 align 16  
162  sad16_xmm:  sad16_xmm:
163    
164      mov eax, [esp+ 4] ; Src1      mov eax, [esp+ 4] ; Src1
# Line 115  Line 189 
189      paddusw mm6,mm5      paddusw mm6,mm5
190      movd eax, mm6      movd eax, mm6
191      ret      ret
192    .endfunc
193    
194    
195  ;===========================================================================  ;-----------------------------------------------------------------------------
196  ;  ;
197  ; uint32_t sad8_xmm(const uint8_t * const cur,  ; uint32_t sad8_xmm(const uint8_t * const cur,
198  ;                                       const uint8_t * const ref,  ;                                       const uint8_t * const ref,
199  ;                                       const uint32_t stride);  ;                                       const uint32_t stride);
200  ;  ;
201  ;===========================================================================  ;-----------------------------------------------------------------------------
202    
203  %macro SAD_8x8_SSE 0  ALIGN 16
     movq mm0, [eax]  
     movq mm1, [eax+ecx]  
   
     psadbw mm0, [edx]  
     psadbw mm1, [edx+ecx]  
     add eax, ebx  
     add edx, ebx  
   
     paddusw mm5,mm0  
     paddusw mm6,mm1  
 %endmacro  
   
 align 16  
204  sad8_xmm:  sad8_xmm:
205    
206      mov eax, [esp+ 4] ; Src1      mov eax, [esp+ 4] ; Src1
# Line 168  Line 230 
230      movd eax, mm6      movd eax, mm6
231    
232      ret      ret
233    .endfunc
234    
235    
236  ;===========================================================================  ;-----------------------------------------------------------------------------
237  ;  ;
238  ; uint32_t sad16bi_xmm(const uint8_t * const cur,  ; uint32_t sad16bi_xmm(const uint8_t * const cur,
239  ;                                       const uint8_t * const ref1,  ;                                       const uint8_t * const ref1,
240  ;                                       const uint8_t * const ref2,  ;                                       const uint8_t * const ref2,
241  ;                                       const uint32_t stride);  ;                                       const uint32_t stride);
242  ;  ;
243  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %macro SADBI_16x16_SSE 0  
     movq mm0, [eax]  
     movq mm1, [eax+8]  
244    
245      movq mm2, [edx]  ALIGN 16
     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  
   
 align 16  
246  sad16bi_xmm:  sad16bi_xmm:
247      push ebx      push ebx
248      mov eax, [esp+4+ 4] ; Src      mov eax, [esp+4+ 4] ; Src
# Line 234  Line 275 
275      movd eax, mm6      movd eax, mm6
276      pop ebx      pop ebx
277      ret      ret
278    .endfunc
279    
280  ;===========================================================================  ;-----------------------------------------------------------------------------
281  ;  ;
282  ; uint32_t sad8bi_xmm(const uint8_t * const cur,  ; uint32_t sad8bi_xmm(const uint8_t * const cur,
283  ; const uint8_t * const ref1,  ; const uint8_t * const ref1,
284  ; const uint8_t * const ref2,  ; const uint8_t * const ref2,
285  ; const uint32_t stride);  ; const uint32_t stride);
286  ;  ;
287  ;===========================================================================  ;-----------------------------------------------------------------------------
288    
289  %macro SADBI_8x8_XMM 0  ALIGN 16
    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  
   
    paddusw mm6,mm1  
 %endmacro  
   
 align 16  
290  sad8bi_xmm:  sad8bi_xmm:
291     push ebx     push ebx
292     mov eax, [esp+4+ 4] ; Src     mov eax, [esp+4+ 4] ; Src
# Line 286  Line 306 
306     movd eax, mm6     movd eax, mm6
307     pop ebx     pop ebx
308     ret     ret
309    .endfunc
310    
311    
312  ;===========================================================================  ;-----------------------------------------------------------------------------
313  ;  ;
314  ; uint32_t dev16_xmm(const uint8_t * const cur,  ; uint32_t dev16_xmm(const uint8_t * const cur,
315  ;                                       const uint32_t stride);  ;                                       const uint32_t stride);
316  ;  ;
317  ;===========================================================================  ;-----------------------------------------------------------------------------
318    
319  %macro MEAN_16x16_SSE 0  ALIGN 16
     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  
   
 align 16  
320  dev16_xmm:  dev16_xmm:
321    
322      mov eax, [esp+ 4] ; Src      mov eax, [esp+ 4] ; Src
# Line 386  Line 387 
387    
388      movd eax, mm6      movd eax, mm6
389      ret      ret
390    .endfunc
391    
392  cglobal sad16v_xmm  ;-----------------------------------------------------------------------------
   
 ;===========================================================================  
393  ;int sad16v_xmm(const uint8_t * const cur,  ;int sad16v_xmm(const uint8_t * const cur,
394  ;               const uint8_t * const ref,  ;               const uint8_t * const ref,
395  ;               const uint32_t stride,  ;               const uint32_t stride,
396  ;               int* sad8);  ;               int* sad8);
397  ;===========================================================================  ;-----------------------------------------------------------------------------
398  align 16  
399    ALIGN 16
400  sad16v_xmm:  sad16v_xmm:
401      push ebx      push ebx
402      mov eax, [esp+4+ 4] ; Src1      mov eax, [esp+4+ 4] ; Src1
# Line 406  Line 407 
407      pxor mm5, mm5 ; accum1      pxor mm5, mm5 ; accum1
408      pxor mm6, mm6 ; accum2      pxor mm6, mm6 ; accum2
409      pxor mm7, mm7 ; total      pxor mm7, mm7 ; total
410    
411      SAD_16x16_SSE      SAD_16x16_SSE
412      SAD_16x16_SSE      SAD_16x16_SSE
413      SAD_16x16_SSE      SAD_16x16_SSE
# Line 414  Line 416 
416      SAD_16x16_SSE      SAD_16x16_SSE
417      SAD_16x16_SSE      SAD_16x16_SSE
418      SAD_16x16_SSE      SAD_16x16_SSE
419    
420      paddusw mm7, mm5      paddusw mm7, mm5
421      paddusw mm7, mm6      paddusw mm7, mm6
422      movd [ebx], mm5      movd [ebx], mm5
# Line 421  Line 424 
424    
425      pxor mm5, mm5 ; accum1      pxor mm5, mm5 ; accum1
426      pxor mm6, mm6 ; accum2      pxor mm6, mm6 ; accum2
427    
428      SAD_16x16_SSE      SAD_16x16_SSE
429      SAD_16x16_SSE      SAD_16x16_SSE
430      SAD_16x16_SSE      SAD_16x16_SSE
# Line 429  Line 433 
433      SAD_16x16_SSE      SAD_16x16_SSE
434      SAD_16x16_SSE      SAD_16x16_SSE
435      SAD_16x16_SSE      SAD_16x16_SSE
436    
437      paddusw mm7, mm5      paddusw mm7, mm5
438      paddusw mm7, mm6      paddusw mm7, mm6
439      movd [ebx+8], mm5      movd [ebx+8], mm5
# Line 437  Line 442 
442      movd eax, mm7      movd eax, mm7
443      pop ebx      pop ebx
444      ret      ret
445  ;--------  .endfunc
   
446    

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.10

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