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

Annotation of /branches/release-1_2-branch/xvidcore/src/motion/x86_asm/sad_sse2.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1793 - (view) (download)
Original Path: trunk/xvidcore/src/motion/x86_asm/sad_sse2.asm

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 : Isibaar 1793 ; * $Id: sad_sse2.asm,v 1.15 2008-11-11 20:46:24 Isibaar 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 : Isibaar 1793 %define ENDFUNC .endfunc
35 : edgomez 1535 %else
36 :     global _%1
37 :     %define %1 _%1
38 : Isibaar 1793 %define ENDFUNC
39 : edgomez 1535 %endif
40 : Isibaar 262 %else
41 : edgomez 1535 %ifdef MARK_FUNCS
42 : edgomez 1540 global %1:function %1.endfunc-%1
43 : Isibaar 1793 %define ENDFUNC .endfunc
44 : edgomez 1535 %else
45 :     global %1
46 : Isibaar 1793 %define ENDFUNC
47 : edgomez 1535 %endif
48 : Isibaar 262 %endif
49 :     %endmacro
50 :    
51 : edgomez 1382 ;=============================================================================
52 :     ; Read only data
53 :     ;=============================================================================
54 : Isibaar 262
55 : edgomez 1382 %ifdef FORMAT_COFF
56 : edgomez 1519 SECTION .rodata
57 : edgomez 1382 %else
58 : edgomez 1519 SECTION .rodata align=16
59 : edgomez 1382 %endif
60 : Isibaar 262
61 : edgomez 1382 ALIGN 64
62 : Isibaar 262 zero times 4 dd 0
63 :    
64 : edgomez 1382 ;=============================================================================
65 :     ; Code
66 :     ;=============================================================================
67 : Isibaar 262
68 : edgomez 1382 SECTION .text
69 :    
70 : Isibaar 262 cglobal sad16_sse2
71 :     cglobal dev16_sse2
72 :    
73 : Isibaar 1764 cglobal sad16_sse3
74 :     cglobal dev16_sse3
75 :    
76 : edgomez 1382 ;-----------------------------------------------------------------------------
77 :     ; uint32_t sad16_sse2 (const uint8_t * const cur, <- assumed aligned!
78 :     ; const uint8_t * const ref,
79 :     ; const uint32_t stride,
80 :     ; const uint32_t /*ignored*/);
81 :     ;-----------------------------------------------------------------------------
82 : Isibaar 262
83 :    
84 : Isibaar 1764 %macro SAD_16x16_SSE2 1
85 :     %1 xmm0, [edx]
86 :     %1 xmm1, [edx+ecx]
87 : edgomez 1382 lea edx,[edx+2*ecx]
88 :     movdqa xmm2, [eax]
89 :     movdqa xmm3, [eax+ecx]
90 :     lea eax,[eax+2*ecx]
91 :     psadbw xmm0, xmm2
92 :     paddusw xmm6,xmm0
93 :     psadbw xmm1, xmm3
94 :     paddusw xmm6,xmm1
95 : Isibaar 262 %endmacro
96 :    
97 : Isibaar 1764 %macro SAD16_SSE2_SSE3 1
98 : edgomez 1382 mov eax, [esp+ 4] ; cur (assumed aligned)
99 :     mov edx, [esp+ 8] ; ref
100 :     mov ecx, [esp+12] ; stride
101 : Isibaar 262
102 : edgomez 1382 pxor xmm6, xmm6 ; accum
103 : Isibaar 262
104 : Isibaar 1764 SAD_16x16_SSE2 %1
105 :     SAD_16x16_SSE2 %1
106 :     SAD_16x16_SSE2 %1
107 :     SAD_16x16_SSE2 %1
108 :     SAD_16x16_SSE2 %1
109 :     SAD_16x16_SSE2 %1
110 :     SAD_16x16_SSE2 %1
111 :     SAD_16x16_SSE2 %1
112 : Isibaar 262
113 : edgomez 1382 pshufd xmm5, xmm6, 00000010b
114 :     paddusw xmm6, xmm5
115 :     pextrw eax, xmm6, 0
116 :     ret
117 : Isibaar 1764 %endmacro
118 :    
119 :     ALIGN 16
120 :     sad16_sse2:
121 :     SAD16_SSE2_SSE3 movdqu
122 : Isibaar 1793 ENDFUNC
123 : Isibaar 262
124 :    
125 : Isibaar 1764 ALIGN 16
126 :     sad16_sse3:
127 :     SAD16_SSE2_SSE3 lddqu
128 : Isibaar 1793 ENDFUNC
129 : Isibaar 1764
130 :    
131 : edgomez 1382 ;-----------------------------------------------------------------------------
132 :     ; uint32_t dev16_sse2(const uint8_t * const cur, const uint32_t stride);
133 :     ;-----------------------------------------------------------------------------
134 : Isibaar 262
135 : Isibaar 1764 %macro MEAN_16x16_SSE2 1 ; eax: src, ecx:stride, mm7: zero or mean => mm6: result
136 :     %1 xmm0, [eax]
137 :     %1 xmm1, [eax+ecx]
138 : edgomez 1382 lea eax, [eax+2*ecx] ; + 2*stride
139 :     psadbw xmm0, xmm7
140 :     paddusw xmm6, xmm0
141 :     psadbw xmm1, xmm7
142 :     paddusw xmm6, xmm1
143 : Isibaar 262 %endmacro
144 :    
145 :    
146 : Isibaar 1764 %macro MEAN16_SSE2_SSE3 1
147 : edgomez 1382 mov eax, [esp+ 4] ; src
148 :     mov ecx, [esp+ 8] ; stride
149 : Isibaar 262
150 : edgomez 1382 pxor xmm6, xmm6 ; accum
151 :     pxor xmm7, xmm7 ; zero
152 : Isibaar 262
153 : Isibaar 1764 MEAN_16x16_SSE2 %1
154 :     MEAN_16x16_SSE2 %1
155 :     MEAN_16x16_SSE2 %1
156 :     MEAN_16x16_SSE2 %1
157 : Isibaar 262
158 : Isibaar 1764 MEAN_16x16_SSE2 %1
159 :     MEAN_16x16_SSE2 %1
160 :     MEAN_16x16_SSE2 %1
161 :     MEAN_16x16_SSE2 %1
162 : Isibaar 262
163 : edgomez 1382 mov eax, [esp+ 4] ; src again
164 : Isibaar 262
165 : edgomez 1382 pshufd xmm7, xmm6, 10b
166 :     paddusw xmm7, xmm6
167 :     pxor xmm6, xmm6 ; zero accum
168 :     psrlw xmm7, 8 ; => Mean
169 :     pshuflw xmm7, xmm7, 0 ; replicate Mean
170 :     packuswb xmm7, xmm7
171 :     pshufd xmm7, xmm7, 00000000b
172 : Isibaar 262
173 : Isibaar 1764 MEAN_16x16_SSE2 %1
174 :     MEAN_16x16_SSE2 %1
175 :     MEAN_16x16_SSE2 %1
176 :     MEAN_16x16_SSE2 %1
177 : Isibaar 262
178 : Isibaar 1764 MEAN_16x16_SSE2 %1
179 :     MEAN_16x16_SSE2 %1
180 :     MEAN_16x16_SSE2 %1
181 :     MEAN_16x16_SSE2 %1
182 : Isibaar 262
183 : edgomez 1382 pshufd xmm7, xmm6, 10b
184 :     paddusw xmm7, xmm6
185 :     pextrw eax, xmm7, 0
186 :     ret
187 : Isibaar 1764 %endmacro
188 :    
189 :     ALIGN 16
190 :     dev16_sse2:
191 :     MEAN16_SSE2_SSE3 movdqu
192 : Isibaar 1793 ENDFUNC
193 : edgomez 1540
194 : Isibaar 1764 ALIGN 16
195 :     dev16_sse3:
196 :     MEAN16_SSE2_SSE3 lddqu
197 : Isibaar 1793 ENDFUNC
198 : Isibaar 1790
199 :    
200 :     %ifidn __OUTPUT_FORMAT__,elf
201 :     section ".note.GNU-stack" noalloc noexec nowrite progbits
202 :     %endif
203 :    

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