[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 1790, Tue Aug 19 09:06:48 2008 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.11 2008-08-19 09:06:48 Isibaar 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 %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  %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 104  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 SADBI_16x16_SSE 0  ALIGN 16
204      movq mm0, [eax]  sad8_xmm:
     movq mm1, [eax+8]  
205    
206      movq mm2, [edx]    mov eax, [esp+ 4] ; Src1
207      movq mm3, [edx+8]    mov edx, [esp+ 8] ; Src2
208      mov ecx, [esp+12] ; Stride
209      push ebx
210      lea ebx, [ecx+ecx]
211    
212      pavgb mm2, [ebx]    pxor mm5, mm5 ; accum1
213      add edx, ecx    pxor mm6, mm6 ; accum2
214    
215      pavgb mm3, [ebx+8]    SAD_8x8_SSE
216      add ebx, ecx    SAD_8x8_SSE
217      SAD_8x8_SSE
218    
219      psadbw mm0, mm2    movq mm0, [eax]
220      add eax, ecx    movq mm1, [eax+ecx]
221      psadbw mm0, [edx]
222      psadbw mm1, [edx+ecx]
223    
224      psadbw mm1, mm3    pop ebx
     paddusw mm5,mm0  
225    
226      paddusw mm5,mm0
227      paddusw mm6,mm1      paddusw mm6,mm1
 %endmacro  
228    
229  align 16    paddusw mm6,mm5
230      movd eax, mm6
231    
232      ret
233    .endfunc
234    
235    
236    ;-----------------------------------------------------------------------------
237    ;
238    ; uint32_t sad16bi_xmm(const uint8_t * const cur,
239    ;                                       const uint8_t * const ref1,
240    ;                                       const uint8_t * const ref2,
241    ;                                       const uint32_t stride);
242    ;
243    ;-----------------------------------------------------------------------------
244    
245    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 169  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  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 ;===========================================================================  
 ;  
 ; 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:  
288    
289      mov eax, [esp+ 4] ; Src1  ALIGN 16
290      mov edx, [esp+ 8] ; Src2  sad8bi_xmm:
     mov ecx, [esp+12] ; Stride  
291      push ebx      push ebx
292      lea ebx, [ecx+ecx]    mov eax, [esp+4+ 4] ; Src
293      mov edx, [esp+4+ 8] ; Ref1
294      mov ebx, [esp+4+12] ; Ref2
295      mov ecx, [esp+4+16] ; Stride
296    
297      pxor mm5, mm5 ; accum1      pxor mm5, mm5 ; accum1
298      pxor mm6, mm6 ; accum2      pxor mm6, mm6 ; accum2
299    .Loop
300      SAD_8x8_SSE    SADBI_8x8_XMM
301      SAD_8x8_SSE    SADBI_8x8_XMM
302      SAD_8x8_SSE    SADBI_8x8_XMM
303      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  
304    
305      paddusw mm6,mm5      paddusw mm6,mm5
306      movd eax, mm6      movd eax, mm6
307      pop ebx
308      ret      ret
309      movq mm0, [eax]  .endfunc
     movq mm1, [eax+8]  
     psadbw mm0, mm7  
     psadbw mm1, mm7  
     add eax, ecx  
     paddw mm5, mm0  
     paddw mm6, mm1  
 %endmacro  
310    
 %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  
311    
312  align 16  ;-----------------------------------------------------------------------------
313    ;
314    ; uint32_t dev16_xmm(const uint8_t * const cur,
315    ;                                       const uint32_t stride);
316    ;
317    ;-----------------------------------------------------------------------------
318    
319    ALIGN 16
320  dev16_xmm:  dev16_xmm:
321    
322      mov eax, [esp+ 4] ; Src      mov eax, [esp+ 4] ; Src
# Line 291  Line 358 
358    
359      mov eax, [esp+ 4] ; Src      mov eax, [esp+ 4] ; Src
360    
361    
362      pxor mm5, mm5 ; sums      pxor mm5, mm5 ; sums
363      pxor mm6, mm6      pxor mm6, mm6
364    
# Line 319  Line 387 
387    
388      movd eax, mm6      movd eax, mm6
389      ret      ret
390    .endfunc
391    
392    ;-----------------------------------------------------------------------------
393    ;int sad16v_xmm(const uint8_t * const cur,
394    ;               const uint8_t * const ref,
395    ;               const uint32_t stride,
396    ;               int* sad8);
397    ;-----------------------------------------------------------------------------
398    
399    ALIGN 16
400    sad16v_xmm:
401      push ebx
402      mov eax, [esp+4+ 4] ; Src1
403      mov edx, [esp+4+ 8] ; Src2
404      mov ecx, [esp+4+12] ; Stride
405      mov ebx, [esp+4+16] ; sad ptr
406    
407      pxor mm5, mm5 ; accum1
408      pxor mm6, mm6 ; accum2
409      pxor mm7, mm7 ; total
410    
411      SAD_16x16_SSE
412      SAD_16x16_SSE
413      SAD_16x16_SSE
414      SAD_16x16_SSE
415      SAD_16x16_SSE
416      SAD_16x16_SSE
417      SAD_16x16_SSE
418      SAD_16x16_SSE
419    
420      paddusw mm7, mm5
421      paddusw mm7, mm6
422      movd [ebx], mm5
423      movd [ebx+4], mm6
424    
425      pxor mm5, mm5 ; accum1
426      pxor mm6, mm6 ; accum2
427    
428      SAD_16x16_SSE
429      SAD_16x16_SSE
430      SAD_16x16_SSE
431      SAD_16x16_SSE
432      SAD_16x16_SSE
433      SAD_16x16_SSE
434      SAD_16x16_SSE
435      SAD_16x16_SSE
436    
437      paddusw mm7, mm5
438      paddusw mm7, mm6
439      movd [ebx+8], mm5
440      movd [ebx+12], mm6
441    
442      movd eax, mm7
443      pop ebx
444      ret
445    .endfunc
446    
447    
448    %ifidn __OUTPUT_FORMAT__,elf
449    section ".note.GNU-stack" noalloc noexec nowrite progbits
450    %endif
451    

Legend:
Removed from v.262  
changed lines
  Added in v.1790

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