[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 262, Sun Jul 7 09:45:40 2002 UTC revision 1519, Sat Jul 24 11:46:08 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.8 2004-07-24 11:46:08 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
29    
 bits 32  
30  %macro cglobal 1  %macro cglobal 1
31          %ifdef PREFIX          %ifdef PREFIX
32                  global _%1                  global _%1
# Line 41  Line 36 
36          %endif          %endif
37  %endmacro  %endmacro
38    
39  section .data  ;=============================================================================
40    ; Read only data
41    ;=============================================================================
42    
43  align 16  %ifdef FORMAT_COFF
44  mmx_one times 4 dw 1  SECTION .rodata
45    %else
46    SECTION .rodata align=16
47    %endif
48    
49  section .text  ALIGN 16
50    mmx_one: times 4 dw 1
51    
52  cglobal  sad16_xmm  ;=============================================================================
53  cglobal  sad8_xmm  ; Helper macros
54  cglobal  sad16bi_xmm  ;=============================================================================
 cglobal  sad8bi_xmm  
 cglobal  dev16_xmm  
   
 ;===========================================================================  
 ;  
 ; uint32_t sad16_xmm(const uint8_t * const cur,  
 ;                                       const uint8_t * const ref,  
 ;                                       const uint32_t best_sad);  
 cglobal  sad8_xmm  
 ;===========================================================================  
55    
56  %macro SAD_16x16_SSE 0  %macro SAD_16x16_SSE 0
57      movq mm0, [eax]      movq mm0, [eax]
# Line 73  Line 64 
64      paddusw mm6,mm1      paddusw mm6,mm1
65  %endmacro  %endmacro
66    
67  align 16  %macro SAD_8x8_SSE 0
68      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    %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
137    cglobal sad8_xmm
138    cglobal sad16bi_xmm
139    cglobal sad8bi_xmm
140    cglobal dev16_xmm
141    cglobal sad16v_xmm
142    
143    ;-----------------------------------------------------------------------------
144    ;
145    ; uint32_t sad16_xmm(const uint8_t * const cur,
146    ;                                       const uint8_t * const ref,
147    ;                                       const uint32_t stride,
148    ;                                       const uint32_t best_sad);
149    ;
150    ;-----------------------------------------------------------------------------
151    
152    ALIGN 16
153  sad16_xmm:  sad16_xmm:
154    
155      mov eax, [esp+ 4] ; Src1      mov eax, [esp+ 4] ; Src1
# Line 106  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  ;===========================================================================  ;-----------------------------------------------------------------------------
192    
193  %macro SADBI_16x16_SSE 0  ALIGN 16
194      movq mm0, [eax]  sad8_xmm:
     movq mm1, [eax+8]  
195    
196      movq mm2, [edx]    mov eax, [esp+ 4] ; Src1
197      movq mm3, [edx+8]    mov edx, [esp+ 8] ; Src2
198      mov ecx, [esp+12] ; Stride
199      push ebx
200      lea ebx, [ecx+ecx]
201    
202      pavgb mm2, [ebx]    pxor mm5, mm5 ; accum1
203      add edx, ecx    pxor mm6, mm6 ; accum2
204    
205      pavgb mm3, [ebx+8]    SAD_8x8_SSE
206      add ebx, ecx    SAD_8x8_SSE
207      SAD_8x8_SSE
208    
209      psadbw mm0, mm2    movq mm0, [eax]
210      add eax, ecx    movq mm1, [eax+ecx]
211      psadbw mm0, [edx]
212      psadbw mm1, [edx+ecx]
213    
214      psadbw mm1, mm3    pop ebx
     paddusw mm5,mm0  
215    
216      paddusw mm5,mm0
217      paddusw mm6,mm1      paddusw mm6,mm1
 %endmacro  
218    
219  align 16    paddusw mm6,mm5
220      movd eax, mm6
221    
222      ret
223    
224    
225    ;-----------------------------------------------------------------------------
226    ;
227    ; uint32_t sad16bi_xmm(const uint8_t * const cur,
228    ;                                       const uint8_t * const ref1,
229    ;                                       const uint8_t * const ref2,
230    ;                                       const uint32_t stride);
231    ;
232    ;-----------------------------------------------------------------------------
233    
234    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 170  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  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 ;===========================================================================  
 ;  
 ; uint32_t sad8_xmm(const uint8_t * const cur,  
 ;                                       const uint8_t * const ref,  
 ;                                       const uint32_t stride);  
 ;  
 ;===========================================================================  
   
 %macro SAD_8x8_SSE 0  
     movq mm0, [eax]  
     movq mm1, [eax+ecx]  
 %macro MEAN_16x16_SSE 0  
     psadbw mm0, [edx]  
     psadbw mm1, [edx+ecx]  
     add eax, ebx  
     add edx, ebx  
   
     paddusw mm5,mm0  
     paddusw mm6,mm1  
 %endmacro  
   
 align 16  
 sad8_xmm:  
276    
277      mov eax, [esp+ 4] ; Src1  ALIGN 16
278      mov edx, [esp+ 8] ; Src2  sad8bi_xmm:
     mov ecx, [esp+12] ; Stride  
279      push ebx      push ebx
280      lea ebx, [ecx+ecx]    mov eax, [esp+4+ 4] ; Src
281      mov edx, [esp+4+ 8] ; Ref1
282      mov ebx, [esp+4+12] ; Ref2
283      mov ecx, [esp+4+16] ; Stride
284    
285      pxor mm5, mm5 ; accum1      pxor mm5, mm5 ; accum1
286      pxor mm6, mm6 ; accum2      pxor mm6, mm6 ; accum2
287    .Loop
288      SAD_8x8_SSE    SADBI_8x8_XMM
289      SAD_8x8_SSE    SADBI_8x8_XMM
290      SAD_8x8_SSE    SADBI_8x8_XMM
291      SADBI_8x8_XMM
     movq mm0, [eax]  
     movq mm1, [eax+ecx]  
     psadbw mm0, [edx]  
     psadbw mm1, [edx+ecx]  
   
     pop ebx  
   
     paddusw mm5,mm0  
     paddusw mm6,mm1  
292    
293      paddusw mm6,mm5      paddusw mm6,mm5
294      movd eax, mm6      movd eax, mm6
295      pop ebx
296      ret      ret
     movq mm0, [eax]  
     movq mm1, [eax+8]  
     psadbw mm0, mm7  
     psadbw mm1, mm7  
     add eax, ecx  
     paddw mm5, mm0  
     paddw mm6, mm1  
 %endmacro  
297    
 %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  
298    
299  align 16  ;-----------------------------------------------------------------------------
300    ;
301    ; uint32_t dev16_xmm(const uint8_t * const cur,
302    ;                                       const uint32_t stride);
303    ;
304    ;-----------------------------------------------------------------------------
305    
306    ALIGN 16
307  dev16_xmm:  dev16_xmm:
308    
309      mov eax, [esp+ 4] ; Src      mov eax, [esp+ 4] ; Src
# Line 291  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 319  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.262  
changed lines
  Added in v.1519

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