[svn] / trunk / xvidcore / src / motion / x86_asm / sad_sse2.asm Repository:
ViewVC logotype

Annotation of /trunk/xvidcore/src/motion/x86_asm/sad_sse2.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1540 - (view) (download)

1 : edgomez 1382 ;/****************************************************************************
2 : Isibaar 262 ; *
3 : edgomez 1382 ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * - SSE2 optimized SAD operators -
5 : Isibaar 262 ; *
6 : edgomez 1382 ; * Copyright(C) 2003 Pascal Massimino <skal@planet-d.net>
7 : Isibaar 262 ; *
8 :     ; *
9 : edgomez 1382 ; * 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
12 :     ; * (at your option) any later version.
13 : Isibaar 262 ; *
14 : edgomez 1382 ; * This program is distributed in the hope that it will be useful,
15 :     ; * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 :     ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 :     ; * GNU General Public License for more details.
18 : Isibaar 262 ; *
19 : edgomez 1382 ; * You should have received a copy of the GNU General Public License
20 :     ; * along with this program; if not, write to the Free Software
21 :     ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 : Isibaar 262 ; *
23 : edgomez 1540 ; * $Id: sad_sse2.asm,v 1.12 2004-08-29 10:02:38 edgomez Exp $
24 : edgomez 652 ; *
25 : edgomez 1382 ; ***************************************************************************/
26 : Isibaar 262
27 : edgomez 1382 BITS 32
28 : Isibaar 262
29 : edgomez 1382 %macro cglobal 1
30 : Isibaar 262 %ifdef PREFIX
31 : edgomez 1535 %ifdef MARK_FUNCS
32 : edgomez 1540 global _%1:function %1.endfunc-%1
33 :     %define %1 _%1:function %1.endfunc-%1
34 : edgomez 1535 %else
35 :     global _%1
36 :     %define %1 _%1
37 :     %endif
38 : Isibaar 262 %else
39 : edgomez 1535 %ifdef MARK_FUNCS
40 : edgomez 1540 global %1:function %1.endfunc-%1
41 : edgomez 1535 %else
42 :     global %1
43 :     %endif
44 : Isibaar 262 %endif
45 :     %endmacro
46 :    
47 : edgomez 1382 ;=============================================================================
48 :     ; Read only data
49 :     ;=============================================================================
50 : Isibaar 262
51 : edgomez 1382 %ifdef FORMAT_COFF
52 : edgomez 1519 SECTION .rodata
53 : edgomez 1382 %else
54 : edgomez 1519 SECTION .rodata align=16
55 : edgomez 1382 %endif
56 : Isibaar 262
57 : edgomez 1382 ALIGN 64
58 : Isibaar 262 zero times 4 dd 0
59 :    
60 : edgomez 1382 ;=============================================================================
61 :     ; Code
62 :     ;=============================================================================
63 : Isibaar 262
64 : edgomez 1382 SECTION .text
65 :    
66 : Isibaar 262 cglobal sad16_sse2
67 :     cglobal dev16_sse2
68 :    
69 : edgomez 1382 ;-----------------------------------------------------------------------------
70 :     ; uint32_t sad16_sse2 (const uint8_t * const cur, <- assumed aligned!
71 :     ; const uint8_t * const ref,
72 :     ; const uint32_t stride,
73 :     ; const uint32_t /*ignored*/);
74 :     ;-----------------------------------------------------------------------------
75 : Isibaar 262
76 :    
77 : edgomez 1382 %macro SAD_16x16_SSE2 0
78 :     movdqu xmm0, [edx]
79 :     movdqu xmm1, [edx+ecx]
80 :     lea edx,[edx+2*ecx]
81 :     movdqa xmm2, [eax]
82 :     movdqa xmm3, [eax+ecx]
83 :     lea eax,[eax+2*ecx]
84 :     psadbw xmm0, xmm2
85 :     paddusw xmm6,xmm0
86 :     psadbw xmm1, xmm3
87 :     paddusw xmm6,xmm1
88 : Isibaar 262 %endmacro
89 :    
90 : edgomez 1382 ALIGN 16
91 :     sad16_sse2:
92 :     mov eax, [esp+ 4] ; cur (assumed aligned)
93 :     mov edx, [esp+ 8] ; ref
94 :     mov ecx, [esp+12] ; stride
95 : Isibaar 262
96 : edgomez 1382 pxor xmm6, xmm6 ; accum
97 : Isibaar 262
98 : edgomez 1382 SAD_16x16_SSE2
99 :     SAD_16x16_SSE2
100 :     SAD_16x16_SSE2
101 :     SAD_16x16_SSE2
102 :     SAD_16x16_SSE2
103 :     SAD_16x16_SSE2
104 :     SAD_16x16_SSE2
105 :     SAD_16x16_SSE2
106 : Isibaar 262
107 : edgomez 1382 pshufd xmm5, xmm6, 00000010b
108 :     paddusw xmm6, xmm5
109 :     pextrw eax, xmm6, 0
110 :     ret
111 : edgomez 1540 .endfunc
112 : Isibaar 262
113 :    
114 : edgomez 1382 ;-----------------------------------------------------------------------------
115 :     ; uint32_t dev16_sse2(const uint8_t * const cur, const uint32_t stride);
116 :     ;-----------------------------------------------------------------------------
117 : Isibaar 262
118 : edgomez 1382 %macro MEAN_16x16_SSE2 0 ; eax: src, ecx:stride, mm7: zero or mean => mm6: result
119 :     movdqu xmm0, [eax]
120 :     movdqu xmm1, [eax+ecx]
121 :     lea eax, [eax+2*ecx] ; + 2*stride
122 :     psadbw xmm0, xmm7
123 :     paddusw xmm6, xmm0
124 :     psadbw xmm1, xmm7
125 :     paddusw xmm6, xmm1
126 : Isibaar 262 %endmacro
127 :    
128 :    
129 : edgomez 1382 ALIGN 16
130 :     dev16_sse2:
131 :     mov eax, [esp+ 4] ; src
132 :     mov ecx, [esp+ 8] ; stride
133 : Isibaar 262
134 : edgomez 1382 pxor xmm6, xmm6 ; accum
135 :     pxor xmm7, xmm7 ; zero
136 : Isibaar 262
137 : edgomez 1382 MEAN_16x16_SSE2
138 :     MEAN_16x16_SSE2
139 :     MEAN_16x16_SSE2
140 :     MEAN_16x16_SSE2
141 : Isibaar 262
142 : edgomez 1382 MEAN_16x16_SSE2
143 :     MEAN_16x16_SSE2
144 :     MEAN_16x16_SSE2
145 :     MEAN_16x16_SSE2
146 : Isibaar 262
147 : edgomez 1382 mov eax, [esp+ 4] ; src again
148 : Isibaar 262
149 : edgomez 1382 pshufd xmm7, xmm6, 10b
150 :     paddusw xmm7, xmm6
151 :     pxor xmm6, xmm6 ; zero accum
152 :     psrlw xmm7, 8 ; => Mean
153 :     pshuflw xmm7, xmm7, 0 ; replicate Mean
154 :     packuswb xmm7, xmm7
155 :     pshufd xmm7, xmm7, 00000000b
156 : Isibaar 262
157 : edgomez 1382 MEAN_16x16_SSE2
158 :     MEAN_16x16_SSE2
159 :     MEAN_16x16_SSE2
160 :     MEAN_16x16_SSE2
161 : Isibaar 262
162 : edgomez 1382 MEAN_16x16_SSE2
163 :     MEAN_16x16_SSE2
164 :     MEAN_16x16_SSE2
165 :     MEAN_16x16_SSE2
166 : Isibaar 262
167 : edgomez 1382 pshufd xmm7, xmm6, 10b
168 :     paddusw xmm7, xmm6
169 :     pextrw eax, xmm7, 0
170 :     ret
171 : edgomez 1540 .endfunc
172 :    

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