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

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

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

revision 329, Tue Jul 23 12:59:57 2002 UTC revision 1382, Mon Mar 22 22:36:25 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 free software; you can redistribute it and/or modify  ; *  Copyright(C) 2001 Peter Ross <pross@xvid.org>
7  ; *     it under the terms of the GNU General Public License as published by  ; *               2001 Michael Militzer <isibaar@xvid.org>
8    ; *               2002 Pascal Massimino <skal@planet-d.net>
9    ; *
10    ; *  This program is free software; you can redistribute it and/or modify it
11    ; *  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 15  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
 ; *  
 ; *************************************************************************/  
   
 ;/**************************************************************************  
 ; *  
 ; *     History:  
23  ; *  ; *
24  ; * 23.07.2002  sad8bi_xmm; <pross@xvid.org>  ; * $Id: sad_xmm.asm,v 1.7 2004-03-22 22:36:24 edgomez Exp $
 ; * 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
# Line 42  Line 36 
36          %endif          %endif
37  %endmacro  %endmacro
38    
39  section .data  ;=============================================================================
40    ; Read only data
41    ;=============================================================================
42    
43    %ifdef FORMAT_COFF
44    SECTION .rodata data
45    %else
46    SECTION .rodata data align=16
47    %endif
48    
49    ALIGN 16
50    mmx_one: times 4 dw 1
51    
52    ;=============================================================================
53    ; Helper macros
54    ;=============================================================================
55    
56    %macro SAD_16x16_SSE 0
57      movq mm0, [eax]
58      psadbw mm0, [edx]
59      movq mm1, [eax+8]
60      add eax, ecx
61      psadbw mm1, [edx+8]
62      paddusw mm5, mm0
63      add edx, ecx
64      paddusw mm6, mm1
65    %endmacro
66    
67  align 16  %macro SAD_8x8_SSE 0
68  mmx_one times 4 dw 1    movq mm0, [eax]
69      movq mm1, [eax+ecx]
70      psadbw mm0, [edx]
71      psadbw mm1, [edx+ecx]
72      add eax, ebx
73      add edx, ebx
74            paddusw mm5, mm0
75            paddusw mm6, mm1
76    %endmacro
77    
78  section .text  %macro SADBI_16x16_SSE 0
79      movq mm0, [eax]
80      movq mm1, [eax+8]
81      movq mm2, [edx]
82      movq mm3, [edx+8]
83      pavgb mm2, [ebx]
84      add edx, ecx
85      pavgb mm3, [ebx+8]
86      add ebx, ecx
87      psadbw mm0, mm2
88      add eax, ecx
89      psadbw mm1, mm3
90      paddusw mm5, mm0
91      paddusw mm6, mm1
92    %endmacro
93    
94    %macro SADBI_8x8_XMM 0
95      movq mm0, [eax]
96      movq mm1, [eax+ecx]
97      movq mm2, [edx]
98      movq mm3, [edx+ecx]
99      pavgb mm2, [ebx]
100      lea edx, [edx+2*ecx]
101      pavgb mm3, [ebx+ecx]
102      lea ebx, [ebx+2*ecx]
103      psadbw mm0, mm2
104      lea eax, [eax+2*ecx]
105      psadbw mm1, mm3
106      paddusw mm5, mm0
107      paddusw mm6, mm1
108    %endmacro
109    
110    %macro MEAN_16x16_SSE 0
111      movq mm0, [eax]
112      movq mm1, [eax+8]
113      psadbw mm0, mm7
114      psadbw mm1, mm7
115      add eax, ecx
116      paddw mm5, mm0
117      paddw mm6, mm1
118    %endmacro
119    
120    %macro ABS_16x16_SSE 0
121      movq mm0, [eax]
122      movq mm1, [eax+8]
123      psadbw mm0, mm4
124      psadbw mm1, mm4
125      lea eax, [eax+ecx]
126      paddw mm5, mm0
127      paddw mm6, mm1
128    %endmacro
129    
130    ;=============================================================================
131    ; Code
132    ;=============================================================================
133    
134    SECTION .text
135    
136  cglobal  sad16_xmm  cglobal  sad16_xmm
137  cglobal  sad8_xmm  cglobal  sad8_xmm
138  cglobal  sad16bi_xmm  cglobal  sad16bi_xmm
139  cglobal  sad8bi_xmm  cglobal  sad8bi_xmm
140  cglobal  dev16_xmm  cglobal  dev16_xmm
141    cglobal sad16v_xmm
142    
143  ;===========================================================================  ;-----------------------------------------------------------------------------
144  ;  ;
145  ; uint32_t sad16_xmm(const uint8_t * const cur,  ; uint32_t sad16_xmm(const uint8_t * const cur,
146  ;                                       const uint8_t * const ref,  ;                                       const uint8_t * const ref,
147  ;                                       const uint32_t stride,  ;                                       const uint32_t stride,
148  ;                                       const uint32_t best_sad);  ;                                       const uint32_t best_sad);
149  ;  ;
150  ;===========================================================================  ;-----------------------------------------------------------------------------
151    
152  %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  
153  sad16_xmm:  sad16_xmm:
154    
155      mov eax, [esp+ 4] ; Src1      mov eax, [esp+ 4] ; Src1
# Line 108  Line 182 
182      ret      ret
183    
184    
185  ;===========================================================================  ;-----------------------------------------------------------------------------
186  ;  ;
187  ; uint32_t sad8_xmm(const uint8_t * const cur,  ; uint32_t sad8_xmm(const uint8_t * const cur,
188  ;                                       const uint8_t * const ref,  ;                                       const uint8_t * const ref,
189  ;                                       const uint32_t stride);  ;                                       const uint32_t stride);
190  ;  ;
191  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %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  
192    
193      paddusw mm5,mm0  ALIGN 16
     paddusw mm6,mm1  
 %endmacro  
   
 align 16  
194  sad8_xmm:  sad8_xmm:
195    
196      mov eax, [esp+ 4] ; Src1      mov eax, [esp+ 4] ; Src1
# Line 161  Line 222 
222      ret      ret
223    
224    
225  ;===========================================================================  ;-----------------------------------------------------------------------------
226  ;  ;
227  ; uint32_t sad16bi_xmm(const uint8_t * const cur,  ; uint32_t sad16bi_xmm(const uint8_t * const cur,
228  ;                                       const uint8_t * const ref1,  ;                                       const uint8_t * const ref1,
229  ;                                       const uint8_t * const ref2,  ;                                       const uint8_t * const ref2,
230  ;                                       const uint32_t stride);  ;                                       const uint32_t stride);
231  ;  ;
232  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %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  
233    
234  align 16  ALIGN 16
235  sad16bi_xmm:  sad16bi_xmm:
236      push ebx      push ebx
237      mov eax, [esp+4+ 4] ; Src      mov eax, [esp+4+ 4] ; Src
# Line 226  Line 265 
265      pop ebx      pop ebx
266      ret      ret
267    
268  ;===========================================================================  ;-----------------------------------------------------------------------------
269  ;  ;
270  ; uint32_t sad8bi_xmm(const uint8_t * const cur,  ; uint32_t sad8bi_xmm(const uint8_t * const cur,
271  ; const uint8_t * const ref1,  ; const uint8_t * const ref1,
272  ; const uint8_t * const ref2,  ; const uint8_t * const ref2,
273  ; const uint32_t stride);  ; const uint32_t stride);
274  ;  ;
275  ;===========================================================================  ;-----------------------------------------------------------------------------
276    
277  %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  
278  sad8bi_xmm:  sad8bi_xmm:
279     push ebx     push ebx
280     mov eax, [esp+4+ 4] ; Src     mov eax, [esp+4+ 4] ; Src
# Line 279  Line 296 
296     ret     ret
297    
298    
299  ;===========================================================================  ;-----------------------------------------------------------------------------
300  ;  ;
301  ; uint32_t dev16_xmm(const uint8_t * const cur,  ; uint32_t dev16_xmm(const uint8_t * const cur,
302  ;                                       const uint32_t stride);  ;                                       const uint32_t stride);
303  ;  ;
304  ;===========================================================================  ;-----------------------------------------------------------------------------
305    
306  %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  
307  dev16_xmm:  dev16_xmm:
308    
309      mov eax, [esp+ 4] ; Src      mov eax, [esp+ 4] ; Src
# Line 348  Line 345 
345    
346      mov eax, [esp+ 4] ; Src      mov eax, [esp+ 4] ; Src
347    
348    
349      pxor mm5, mm5 ; sums      pxor mm5, mm5 ; sums
350      pxor mm6, mm6      pxor mm6, mm6
351    
# Line 376  Line 374 
374    
375      movd eax, mm6      movd eax, mm6
376      ret      ret
377    
378    ;-----------------------------------------------------------------------------
379    ;int sad16v_xmm(const uint8_t * const cur,
380    ;               const uint8_t * const ref,
381    ;               const uint32_t stride,
382    ;               int* sad8);
383    ;-----------------------------------------------------------------------------
384    
385    ALIGN 16
386    sad16v_xmm:
387      push ebx
388      mov eax, [esp+4+ 4] ; Src1
389      mov edx, [esp+4+ 8] ; Src2
390      mov ecx, [esp+4+12] ; Stride
391      mov ebx, [esp+4+16] ; sad ptr
392    
393      pxor mm5, mm5 ; accum1
394      pxor mm6, mm6 ; accum2
395      pxor mm7, mm7 ; total
396    
397      SAD_16x16_SSE
398      SAD_16x16_SSE
399      SAD_16x16_SSE
400      SAD_16x16_SSE
401      SAD_16x16_SSE
402      SAD_16x16_SSE
403      SAD_16x16_SSE
404      SAD_16x16_SSE
405    
406      paddusw mm7, mm5
407      paddusw mm7, mm6
408      movd [ebx], mm5
409      movd [ebx+4], mm6
410    
411      pxor mm5, mm5 ; accum1
412      pxor mm6, mm6 ; accum2
413    
414      SAD_16x16_SSE
415      SAD_16x16_SSE
416      SAD_16x16_SSE
417      SAD_16x16_SSE
418      SAD_16x16_SSE
419      SAD_16x16_SSE
420      SAD_16x16_SSE
421      SAD_16x16_SSE
422    
423      paddusw mm7, mm5
424      paddusw mm7, mm6
425      movd [ebx+8], mm5
426      movd [ebx+12], mm6
427    
428      movd eax, mm7
429      pop ebx
430      ret

Legend:
Removed from v.329  
changed lines
  Added in v.1382

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