[svn] / branches / release-1_2-branch / xvidcore / src / motion / x86_asm / sad_xmm.asm Repository:
ViewVC logotype

Diff of /branches/release-1_2-branch/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 1535, 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 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.9 2004-08-22 11:46:10 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                    %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  %endmacro
47    
48  section .data  ;=============================================================================
49    ; Read only data
50  align 16  ;=============================================================================
 mmx_one times 4 dw 1  
51    
52  section .text  %ifdef FORMAT_COFF
53    SECTION .rodata
54    %else
55    SECTION .rodata align=16
56    %endif
57    
58  cglobal  sad16_xmm  ALIGN 16
59  cglobal  sad8_xmm  mmx_one: times 4 dw 1
 cglobal  sad16bi_xmm  
 cglobal  sad8bi_xmm  
 cglobal  dev16_xmm  
60    
61  ;===========================================================================  ;=============================================================================
62  ;  ; Helper macros
63  ; uint32_t sad16_xmm(const uint8_t * const cur,  ;=============================================================================
 ;                                       const uint8_t * const ref,  
 ;                                       const uint32_t best_sad);  
 cglobal  sad8_xmm  
 ;===========================================================================  
64    
65  %macro SAD_16x16_SSE 0  %macro SAD_16x16_SSE 0
66      movq mm0, [eax]      movq mm0, [eax]
# Line 73  Line 73 
73      paddusw mm6,mm1      paddusw mm6,mm1
74  %endmacro  %endmacro
75    
76  align 16  %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
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    ;=============================================================================
140    ; Code
141    ;=============================================================================
142    
143    SECTION .text
144    
145    cglobal sad16_xmm
146    cglobal sad8_xmm
147    cglobal sad16bi_xmm
148    cglobal sad8bi_xmm
149    cglobal dev16_xmm
150    cglobal sad16v_xmm
151    
152    ;-----------------------------------------------------------------------------
153    ;
154    ; uint32_t sad16_xmm(const uint8_t * const cur,
155    ;                                       const uint8_t * const ref,
156    ;                                       const uint32_t stride,
157    ;                                       const uint32_t best_sad);
158    ;
159    ;-----------------------------------------------------------------------------
160    
161    ALIGN 16
162  sad16_xmm:  sad16_xmm:
163    
164      mov eax, [esp+ 4] ; Src1      mov eax, [esp+ 4] ; Src1
# Line 106  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  ;===========================================================================  ;-----------------------------------------------------------------------------
201    
202  %macro SADBI_16x16_SSE 0  ALIGN 16
203      movq mm0, [eax]  sad8_xmm:
     movq mm1, [eax+8]  
204    
205      movq mm2, [edx]    mov eax, [esp+ 4] ; Src1
206      movq mm3, [edx+8]    mov edx, [esp+ 8] ; Src2
207      mov ecx, [esp+12] ; Stride
208      push ebx
209      lea ebx, [ecx+ecx]
210    
211      pavgb mm2, [ebx]    pxor mm5, mm5 ; accum1
212      add edx, ecx    pxor mm6, mm6 ; accum2
213    
214      pavgb mm3, [ebx+8]    SAD_8x8_SSE
215      add ebx, ecx    SAD_8x8_SSE
216      SAD_8x8_SSE
217    
218      psadbw mm0, mm2    movq mm0, [eax]
219      add eax, ecx    movq mm1, [eax+ecx]
220      psadbw mm0, [edx]
221      psadbw mm1, [edx+ecx]
222    
223      psadbw mm1, mm3    pop ebx
     paddusw mm5,mm0  
224    
225      paddusw mm5,mm0
226      paddusw mm6,mm1      paddusw mm6,mm1
 %endmacro  
227    
228  align 16    paddusw mm6,mm5
229      movd eax, mm6
230    
231      ret
232    
233    
234    ;-----------------------------------------------------------------------------
235    ;
236    ; uint32_t sad16bi_xmm(const uint8_t * const cur,
237    ;                                       const uint8_t * const ref1,
238    ;                                       const uint8_t * const ref2,
239    ;                                       const uint32_t stride);
240    ;
241    ;-----------------------------------------------------------------------------
242    
243    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 170  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  ;===========================================================================  ;-----------------------------------------------------------------------------
285    
286  ;===========================================================================  ALIGN 16
287  ;  sad8bi_xmm:
 ; 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:  
   
     mov eax, [esp+ 4] ; Src1  
     mov edx, [esp+ 8] ; Src2  
     mov ecx, [esp+12] ; Stride  
288      push ebx      push ebx
289      lea ebx, [ecx+ecx]    mov eax, [esp+4+ 4] ; Src
290      mov edx, [esp+4+ 8] ; Ref1
291      mov ebx, [esp+4+12] ; Ref2
292      mov ecx, [esp+4+16] ; Stride
293    
294      pxor mm5, mm5 ; accum1      pxor mm5, mm5 ; accum1
295      pxor mm6, mm6 ; accum2      pxor mm6, mm6 ; accum2
296    .Loop
297      SAD_8x8_SSE    SADBI_8x8_XMM
298      SAD_8x8_SSE    SADBI_8x8_XMM
299      SAD_8x8_SSE    SADBI_8x8_XMM
300      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  
301    
302      paddusw mm6,mm5      paddusw mm6,mm5
303      movd eax, mm6      movd eax, mm6
304      pop ebx
305      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  
306    
 %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  
307    
308  align 16  ;-----------------------------------------------------------------------------
309    ;
310    ; uint32_t dev16_xmm(const uint8_t * const cur,
311    ;                                       const uint32_t stride);
312    ;
313    ;-----------------------------------------------------------------------------
314    
315    ALIGN 16
316  dev16_xmm:  dev16_xmm:
317    
318      mov eax, [esp+ 4] ; Src      mov eax, [esp+ 4] ; Src
# Line 291  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 319  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.262  
changed lines
  Added in v.1535

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