[svn] / branches / dev-api-4 / xvidcore / src / motion / x86_asm / sad_mmx.asm Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/src/motion/x86_asm/sad_mmx.asm

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

trunk/xvidcore/src/motion/x86_asm/sad_mmx.asm revision 851, Sat Feb 15 15:22:19 2003 UTC branches/dev-api-4/xvidcore/src/motion/x86_asm/sad_mmx.asm revision 1198, Mon Nov 3 15:51:50 2003 UTC
# Line 1  Line 1 
1  ;/**************************************************************************  ;/****************************************************************************
2  ; *  ; *
3  ; *     XVID MPEG-4 VIDEO CODEC  ; *     XVID MPEG-4 VIDEO CODEC
4  ; *     mmx 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  ; *               2002 Pascal Massimino <skal@planet-d.net>
8    ; *
9    ; *  This program is free software; you can redistribute it and/or modify it
10    ; *  under the terms of the GNU General Public License as published by
11  ; *     the Free Software Foundation; either version 2 of the License, or  ; *     the Free Software Foundation; either version 2 of the License, or
12  ; *     (at your option) any later version.  ; *     (at your option) any later version.
13  ; *  ; *
# Line 15  Line 18 
18  ; *  ; *
19  ; *     You should have received a copy of the GNU General Public License  ; *     You should have received a copy of the GNU General Public License
20  ; *     along with this program; if not, write to the Free Software  ; *     along with this program; if not, write to the Free Software
21  ; *     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 ; *  
 ; *************************************************************************/  
   
 ;/**************************************************************************  
 ; *  
 ; *     History:  
22  ; *  ; *
23  ; * 23.07.2002  sad[16,8]bi_xmm; <pross@xvid.org>  ; * $Id: sad_mmx.asm,v 1.11.2.2 2003-11-03 15:51:50 edgomez Exp $
 ; * 04.06.2002  cleanup -Skal-  
 ; *     12.11.2001      inital version; (c)2001 peter ross <pross@cs.rmit.edu.au>  
24  ; *  ; *
25  ; *************************************************************************/  ; ***************************************************************************/
26    
27  bits 32  BITS 32
28    
29  %macro cglobal 1  %macro cglobal 1
30          %ifdef PREFIX          %ifdef PREFIX
# Line 40  Line 35 
35          %endif          %endif
36  %endmacro  %endmacro
37    
38  section .data  ;=============================================================================
39    ; Read only data
40    ;=============================================================================
41    
42  align 16  %ifdef FORMAT_COFF
43  mmx_one times 4 dw 1  SECTION .rodata data
44    %else
45  section .text  SECTION .rodata data align=16
46    %endif
 cglobal  sad16_mmx  
 cglobal  sad16v_mmx  
 cglobal  sad8_mmx  
 cglobal  sad16bi_mmx  
 cglobal  sad8bi_mmx  
 cglobal  dev16_mmx  
47    
48  ;===========================================================================  ALIGN 16
49  ;  mmx_one:
50  ; uint32_t sad16_mmx(const uint8_t * const cur,          times 4 dw 1
51  ;                                        const uint8_t * const ref,  
52  ;                                        const uint32_t stride,  ;=============================================================================
53  ;                                        const uint32_t best_sad);  ; Helper macros
54  ;  ;=============================================================================
 ; (early termination ignore; slows this down)  
 ;  
 ;===========================================================================  
55    
56  %macro SAD_16x16_MMX 0  %macro SAD_16x16_MMX 0
57      movq mm0, [eax]      movq mm0, [eax]
# Line 98  Line 86 
86      paddusw mm6,mm2      paddusw mm6,mm2
87  %endmacro  %endmacro
88    
89  align 16  %macro SAD_8x8_MMX      0
90      movq mm0, [eax]
91      movq mm1, [edx]
92    
93      movq mm2, [eax+ecx]
94      movq mm3, [edx+ecx]
95    
96      lea eax,[eax+2*ecx]
97      lea edx,[edx+2*ecx]
98    
99      movq mm4, mm0
100      psubusb mm0, mm1
101      movq mm5, mm2
102      psubusb mm2, mm3
103    
104      psubusb mm1, mm4
105      por mm0, mm1
106      psubusb mm3, mm5
107      por mm2, mm3
108    
109      movq mm1,mm0
110      movq mm3,mm2
111    
112      punpcklbw mm0,mm7
113      punpckhbw mm1,mm7
114      punpcklbw mm2,mm7
115      punpckhbw mm3,mm7
116    
117      paddusw mm0,mm1
118      paddusw mm6,mm0
119      paddusw mm2,mm3
120      paddusw mm6,mm2
121    %endmacro
122    
123    %macro SADV_16x16_MMX 0
124      movq mm0, [eax]
125      movq mm1, [edx]
126    
127      movq mm2, [eax+8]
128      movq mm3, [edx+8]
129    
130      movq mm4, mm0
131      psubusb mm0, mm1
132    
133      psubusb mm1, mm4
134      por mm0, mm1
135      lea eax,[eax+ecx]
136    
137      movq mm4, mm2
138      psubusb mm2, mm3
139    
140      psubusb mm3, mm4
141      por mm2, mm3
142      lea edx,[edx+ecx]
143    
144      movq mm1,mm0
145      movq mm3,mm2
146    
147      punpcklbw mm0,mm7
148      punpckhbw mm1,mm7
149      punpcklbw mm2,mm7
150      punpckhbw mm3,mm7
151    
152      paddusw mm0,mm1
153      paddusw mm2,mm3
154    
155      paddusw mm5, mm0
156      paddusw mm6, mm2
157    %endmacro
158    
159    %macro SADBI_16x16_MMX 2    ; SADBI_16x16_MMX( int_ptr_offset, bool_increment_ptr );
160    
161      movq mm0, [edx+%1]
162      movq mm2, [ebx+%1]
163      movq mm1, mm0
164      movq mm3, mm2
165    
166    %if %2 != 0
167      add edx, ecx
168    %endif
169    
170      punpcklbw mm0, mm7
171      punpckhbw mm1, mm7
172      punpcklbw mm2, mm7
173      punpckhbw mm3, mm7
174    
175    %if %2 != 0
176      add ebx, ecx
177    %endif
178    
179      paddusw mm0, mm2              ; mm01 = ref1 + ref2
180      paddusw mm1, mm3
181      paddusw mm0, [mmx_one]        ; mm01 += 1
182      paddusw mm1, [mmx_one]
183      psrlw mm0, 1                  ; mm01 >>= 1
184      psrlw mm1, 1
185    
186      movq mm2, [eax+%1]
187      movq mm3, mm2
188      punpcklbw mm2, mm7            ; mm23 = src
189      punpckhbw mm3, mm7
190    
191    %if %2 != 0
192      add eax, ecx
193    %endif
194    
195      movq mm4, mm0
196      movq mm5, mm1
197      psubusw mm0, mm2
198      psubusw mm1, mm3
199      psubusw mm2, mm4
200      psubusw mm3, mm5
201      por mm0, mm2                  ; mm01 = ABS(mm01 - mm23)
202      por mm1, mm3
203    
204      paddusw mm6, mm0              ; mm6 += mm01
205      paddusw mm6, mm1
206    
207    %endmacro
208    
209    %macro MEAN_16x16_MMX 0
210      movq mm0, [eax]
211      movq mm2, [eax+8]
212      lea eax, [eax+ecx]
213      movq mm1, mm0
214      movq mm3, mm2
215      punpcklbw mm0, mm7
216      punpcklbw mm2, mm7
217      punpckhbw mm1, mm7
218      punpckhbw mm3, mm7
219      paddw mm5, mm0
220      paddw mm6, mm1
221      paddw mm5, mm2
222      paddw mm6, mm3
223    %endmacro
224    
225    %macro ABS_16x16_MMX 0
226      movq mm0, [eax]
227      movq mm2, [eax+8]
228      lea eax, [eax+ecx]
229      movq mm1, mm0
230      movq mm3, mm2
231      punpcklbw mm0, mm7
232      punpcklbw mm2, mm7
233      punpckhbw mm1, mm7
234      punpckhbw mm3, mm7
235      movq mm4, mm6
236      psubusw mm4, mm0
237    
238      psubusw mm0, mm6
239      por mm0, mm4
240      movq mm4, mm6
241      psubusw mm4, mm1
242      psubusw mm1, mm6
243      por mm1, mm4
244    
245      movq mm4, mm6
246      psubusw mm4, mm2
247      psubusw mm2, mm6
248      por mm2, mm4
249      movq mm4, mm6
250      psubusw mm4, mm3
251      psubusw mm3, mm6
252      por mm3, mm4
253    
254      paddw mm0, mm1
255      paddw mm2, mm3
256      paddw mm5, mm0
257      paddw mm5, mm2
258    %endmacro
259    
260    ;=============================================================================
261    ; Code
262    ;=============================================================================
263    
264    SECTION .text
265    
266    cglobal  sad16_mmx
267    cglobal  sad16v_mmx
268    cglobal  sad8_mmx
269    cglobal  sad16bi_mmx
270    cglobal  sad8bi_mmx
271    cglobal  dev16_mmx
272    
273    ;-----------------------------------------------------------------------------
274    ;
275    ; uint32_t sad16_mmx(const uint8_t * const cur,
276    ;                                        const uint8_t * const ref,
277    ;                                        const uint32_t stride,
278    ;                                        const uint32_t best_sad);
279    ;
280    ; (early termination ignore; slows this down)
281    ;
282    ;-----------------------------------------------------------------------------
283    
284    ALIGN 16
285  sad16_mmx:  sad16_mmx:
286    
287      mov eax, [esp+ 4] ; Src1      mov eax, [esp+ 4] ; Src1
# Line 135  Line 318 
318    
319      ret      ret
320    
321    ;-----------------------------------------------------------------------------
 ;===========================================================================  
322  ;  ;
323  ; uint32_t sad8_mmx(const uint8_t * const cur,  ; uint32_t sad8_mmx(const uint8_t * const cur,
324  ;                                       const uint8_t * const ref,  ;                                       const uint8_t * const ref,
325  ;                                       const uint32_t stride);  ;                                       const uint32_t stride);
326  ;  ;
327  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %macro SAD_8x8_MMX  0  
     movq mm0, [eax]  
     movq mm1, [edx]  
   
     movq mm2, [eax+ecx]  
     movq mm3, [edx+ecx]  
   
     lea eax,[eax+2*ecx]  
     lea edx,[edx+2*ecx]  
   
     movq mm4, mm0  
     psubusb mm0, mm1  
     movq mm5, mm2  
     psubusb mm2, mm3  
   
     psubusb mm1, mm4  
     por mm0, mm1  
     psubusb mm3, mm5  
     por mm2, mm3  
   
     movq mm1,mm0  
     movq mm3,mm2  
   
     punpcklbw mm0,mm7  
     punpckhbw mm1,mm7  
     punpcklbw mm2,mm7  
     punpckhbw mm3,mm7  
   
     paddusw mm0,mm1  
     paddusw mm6,mm0  
     paddusw mm2,mm3  
     paddusw mm6,mm2  
 %endmacro  
328    
329  align 16  ALIGN 16
330  sad8_mmx:  sad8_mmx:
331    
332      mov eax, [esp+ 4] ; Src1      mov eax, [esp+ 4] ; Src1
# Line 202  Line 350 
350    
351      ret      ret
352    
353    ;-----------------------------------------------------------------------------
 ;===========================================================================  
354  ;  ;
355  ; uint32_t sad16v_mmx(const uint8_t * const cur,  ; uint32_t sad16v_mmx(const uint8_t * const cur,
356  ;                                     const uint8_t * const ref,  ;                                     const uint8_t * const ref,
357  ;                                         const uint32_t stride,  ;                                         const uint32_t stride,
358  ;                                         int32_t *sad);  ;                                         int32_t *sad);
359  ;  ;
360  ;===========================================================================  ;-----------------------------------------------------------------------------
361    
362  %macro SADV_16x16_MMX 0  ALIGN 16
     movq mm0, [eax]  
     movq mm1, [edx]  
   
     movq mm2, [eax+8]  
     movq mm3, [edx+8]  
   
     movq mm4, mm0  
     psubusb mm0, mm1  
   
     psubusb mm1, mm4  
     por mm0, mm1  
     lea eax,[eax+ecx]  
   
     movq mm4, mm2  
     psubusb mm2, mm3  
   
     psubusb mm3, mm4  
     por mm2, mm3  
     lea edx,[edx+ecx]  
   
     movq mm1,mm0  
     movq mm3,mm2  
   
     punpcklbw mm0,mm7  
     punpckhbw mm1,mm7  
     punpcklbw mm2,mm7  
     punpckhbw mm3,mm7  
   
     paddusw mm0,mm1  
     paddusw mm2,mm3  
   
         paddusw mm5, mm0  
         paddusw mm6, mm2  
 %endmacro  
   
 align 16  
363  sad16v_mmx:  sad16v_mmx:
364    
365          push ebx          push ebx
# Line 326  Line 437 
437    
438          pop edi          pop edi
439      pop ebx      pop ebx
         ret  
   
440    
441      ret
442    
443  ;===========================================================================  ;-----------------------------------------------------------------------------
444  ;  ;
445  ; uint32_t sad16bi_mmx(const uint8_t * const cur,  ; uint32_t sad16bi_mmx(const uint8_t * const cur,
446  ; const uint8_t * const ref1,  ; const uint8_t * const ref1,
447  ; const uint8_t * const ref2,  ; const uint8_t * const ref2,
448  ; const uint32_t stride);  ; const uint32_t stride);
449  ;  ;
450  ;===========================================================================  ;-----------------------------------------------------------------------------
 %macro SADBI_16x16_MMX 2    ; SADBI_16x16_MMX( int_ptr_offset, bool_increment_ptr );  
   
    movq mm0, [edx+%1]  
    movq mm2, [ebx+%1]  
    movq mm1, mm0  
    movq mm3, mm2  
   
 %if %2 != 0  
    add edx, ecx  
 %endif  
   
    punpcklbw mm0, mm7  
    punpckhbw mm1, mm7  
 punpcklbw mm2, mm7  
 punpckhbw mm3, mm7  
451    
452  %if %2 != 0  ALIGN 16
    add ebx, ecx  
 %endif  
   
 paddusw mm0, mm2    ; mm01 = ref1 + ref2  
 paddusw mm1, mm3  
 paddusw mm0, [mmx_one] ; mm01 += 1  
 paddusw mm1, [mmx_one]  
 psrlw mm0, 1     ; mm01 >>= 1  
 psrlw mm1, 1  
   
    movq mm2, [eax+%1]  
    movq mm3, mm2  
    punpcklbw mm2, mm7          ; mm23 = src  
    punpckhbw mm3, mm7  
   
 %if %2 != 0  
    add eax, ecx  
 %endif  
   
    movq mm4, mm0  
    movq mm5, mm1  
    psubusw mm0, mm2  
    psubusw mm1, mm3  
    psubusw mm2, mm4  
    psubusw mm3, mm5  
    por mm0, mm2                ; mm01 = ABS(mm01 - mm23)  
    por mm1, mm3  
   
    paddusw mm6,mm0             ; mm6 += mm01  
    paddusw mm6,mm1  
   
 %endmacro  
   
 align 16  
453  sad16bi_mmx:  sad16bi_mmx:
454     push ebx     push ebx
455     mov eax, [esp+4+ 4] ; Src     mov eax, [esp+4+ 4] ; Src
# Line 440  Line 501 
501    
502     movd eax, mm6     movd eax, mm6
503     pop ebx     pop ebx
504    
505     ret     ret
506    
507  ;===========================================================================  ;-----------------------------------------------------------------------------
508  ;  ;
509  ; uint32_t sad8bi_mmx(const uint8_t * const cur,  ; uint32_t sad8bi_mmx(const uint8_t * const cur,
510  ; const uint8_t * const ref1,  ; const uint8_t * const ref1,
511  ; const uint8_t * const ref2,  ; const uint8_t * const ref2,
512  ; const uint32_t stride);  ; const uint32_t stride);
513  ;  ;
514  ;===========================================================================  ;-----------------------------------------------------------------------------
515  align 16  
516    ALIGN 16
517  sad8bi_mmx:  sad8bi_mmx:
518     push ebx     push ebx
519     mov eax, [esp+4+ 4] ; Src     mov eax, [esp+4+ 4] ; Src
# Line 479  Line 542 
542     pop ebx     pop ebx
543     ret     ret
544    
545    ;-----------------------------------------------------------------------------
   
   
 ;===========================================================================  
546  ;  ;
547  ; uint32_t dev16_mmx(const uint8_t * const cur,  ; uint32_t dev16_mmx(const uint8_t * const cur,
548  ;                                       const uint32_t stride);  ;                                       const uint32_t stride);
549  ;  ;
550  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %macro MEAN_16x16_MMX 0  
     movq mm0, [eax]  
     movq mm2, [eax+8]  
     lea eax,[eax+ecx]  
     movq mm1, mm0  
     movq mm3, mm2  
     punpcklbw mm0,mm7  
     punpcklbw mm2,mm7  
     punpckhbw mm1,mm7  
     punpckhbw mm3,mm7  
     paddw mm5, mm0  
     paddw mm6, mm1  
     paddw mm5, mm2  
     paddw mm6, mm3  
 %endmacro  
551    
552  %macro ABS_16x16_MMX 0  ALIGN 16
     movq mm0, [eax]  
     movq mm2, [eax+8]  
     lea eax,[eax+ecx]  
     movq mm1, mm0  
     movq mm3, mm2  
     punpcklbw mm0, mm7  
     punpcklbw mm2, mm7  
     punpckhbw mm1, mm7  
     punpckhbw mm3, mm7  
     movq mm4, mm6  
         psubusw mm4, mm0  
   
         psubusw mm0, mm6  
         por mm0, mm4  
         movq mm4, mm6  
         psubusw mm4, mm1  
         psubusw mm1, mm6  
         por mm1, mm4  
   
     movq mm4, mm6  
         psubusw mm4, mm2  
         psubusw mm2, mm6  
         por mm2, mm4  
         movq mm4, mm6  
         psubusw mm4, mm3  
         psubusw mm3, mm6  
         por mm3, mm4  
   
         paddw mm0, mm1  
         paddw mm2, mm3  
         paddw mm5, mm0  
         paddw mm5, mm2  
 %endmacro  
   
 align 16  
553  dev16_mmx:  dev16_mmx:
554      mov eax, [esp+ 4] ; Src      mov eax, [esp+ 4] ; Src
555      mov ecx, [esp+ 8] ; Stride      mov ecx, [esp+ 8] ; Stride
# Line 609  Line 618 
618      paddd mm6, mm5      paddd mm6, mm5
619    
620      movd eax, mm6      movd eax, mm6
621    
622      ret      ret

Legend:
Removed from v.851  
changed lines
  Added in v.1198

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