[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 652, Sun Nov 17 00:35:33 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 (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 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  
11  ; *  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.
# Line 23  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  ; *  Under section 8 of the GNU General Public License, the copyright  ; * $Id: sad_xmm.asm,v 1.8 2004-07-24 11:46:08 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.  
25  ; *  ; *
26  ; *  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_xmm.asm,v 1.5 2002-11-17 00:32:06 edgomez Exp $  
 ; *  
 ; *************************************************************************/  
27    
28  bits 32  BITS 32
29    
30  %macro cglobal 1  %macro cglobal 1
31          %ifdef PREFIX          %ifdef PREFIX
# Line 67  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
45    %else
46    SECTION .rodata 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    %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  align 16  ;=============================================================================
131  mmx_one times 4 dw 1  ; Code
132    ;=============================================================================
133    
134  section .text  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  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %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  
151    
152  align 16  ALIGN 16
153  sad16_xmm:  sad16_xmm:
154    
155      mov eax, [esp+ 4] ; Src1      mov eax, [esp+ 4] ; Src1
# Line 133  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 186  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 251  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  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %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  
276    
277     paddusw mm6,mm1  ALIGN 16
 %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 304  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  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %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  
305    
306  align 16  ALIGN 16
307  dev16_xmm:  dev16_xmm:
308    
309      mov eax, [esp+ 4] ; Src      mov eax, [esp+ 4] ; Src
# Line 373  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 401  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.652  
changed lines
  Added in v.1519

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