[cvs] / xvidcore / src / motion / x86_asm / sad_3dn.asm Repository:
ViewVC logotype

Annotation of /xvidcore/src/motion/x86_asm/sad_3dn.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (view) (download)

1 : edgomez 1.6 ;/****************************************************************************
2 : suxen_drol 1.1 ; *
3 : edgomez 1.6 ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * - 3DNow sad operators w/o XMM instructions -
5 : suxen_drol 1.1 ; *
6 : edgomez 1.6 ; * Copyright(C) 2002 Peter ross <pross@xvid.org>
7 : suxen_drol 1.1 ; *
8 : edgomez 1.6 ; * This program is free software; you can redistribute it and/or modify it
9 :     ; * under the terms of the GNU General Public License as published by
10 :     ; * the Free Software Foundation; either version 2 of the License, or
11 :     ; * (at your option) any later version.
12 : chl 1.2 ; *
13 : edgomez 1.6 ; * This program is distributed in the hope that it will be useful,
14 :     ; * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 :     ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 :     ; * GNU General Public License for more details.
17 : edgomez 1.4 ; *
18 : edgomez 1.6 ; * You should have received a copy of the GNU General Public License
19 :     ; * along with this program; if not, write to the Free Software
20 :     ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 : edgomez 1.5 ; *
22 : Isibaar 1.11 ; * $Id: sad_3dn.asm,v 1.10 2008/08/19 09:06:48 Isibaar Exp $
23 : edgomez 1.5 ; *
24 : edgomez 1.6 ; ***************************************************************************/
25 : suxen_drol 1.1
26 : edgomez 1.6 BITS 32
27 : suxen_drol 1.1
28 : edgomez 1.6 %macro cglobal 1
29 : suxen_drol 1.1 %ifdef PREFIX
30 : edgomez 1.8 %ifdef MARK_FUNCS
31 : edgomez 1.9 global _%1:function %1.endfunc-%1
32 :     %define %1 _%1:function %1.endfunc-%1
33 : Isibaar 1.11 %define ENDFUNC .endfunc
34 : edgomez 1.8 %else
35 :     global _%1
36 :     %define %1 _%1
37 : Isibaar 1.11 %define ENDFUNC
38 : edgomez 1.8 %endif
39 : suxen_drol 1.1 %else
40 : edgomez 1.8 %ifdef MARK_FUNCS
41 : edgomez 1.9 global %1:function %1.endfunc-%1
42 : Isibaar 1.11 %define ENDFUNC .endfunc
43 : edgomez 1.8 %else
44 :     global %1
45 : Isibaar 1.11 %define ENDFUNC
46 : edgomez 1.8 %endif
47 : suxen_drol 1.1 %endif
48 :     %endmacro
49 :    
50 : edgomez 1.6 ;=============================================================================
51 :     ; Read only data
52 :     ;=============================================================================
53 :    
54 :     %ifdef FORMAT_COFF
55 : edgomez 1.7 SECTION .rodata
56 : edgomez 1.6 %else
57 : edgomez 1.7 SECTION .rodata align=16
58 : edgomez 1.6 %endif
59 :    
60 :     ALIGN 16
61 :     mmx_one:
62 :     times 4 dw 1
63 :    
64 :     ;=============================================================================
65 :     ; Helper macros
66 :     ;=============================================================================
67 :     %macro SADBI_16x16_3DN 0
68 :     movq mm0, [eax] ; src
69 :     movq mm2, [eax+8]
70 :    
71 :     movq mm1, [edx] ; ref1
72 :     movq mm3, [edx+8]
73 :     pavgusb mm1, [ebx] ; ref2
74 :     lea edx, [edx+ecx]
75 :     pavgusb mm3, [ebx+8]
76 :     lea ebx, [ebx+ecx]
77 :    
78 :     movq mm4, mm0
79 :     lea eax, [eax+ecx]
80 :     psubusb mm0, mm1
81 :     movq mm5, mm2
82 :     psubusb mm2, mm3
83 :    
84 :     psubusb mm1, mm4
85 :     por mm0, mm1
86 :     psubusb mm3, mm5
87 :     por mm2, mm3
88 :    
89 :     movq mm1, mm0
90 :     movq mm3, mm2
91 :    
92 :     punpcklbw mm0,mm7
93 :     punpckhbw mm1,mm7
94 :     punpcklbw mm2,mm7
95 :     punpckhbw mm3,mm7
96 :    
97 :     paddusw mm0,mm1
98 :     paddusw mm2,mm3
99 :     paddusw mm6,mm0
100 :     paddusw mm6,mm2
101 :     %endmacro
102 :    
103 :     %macro SADBI_8x8_3DN 0
104 :     movq mm0, [eax] ; src
105 :     movq mm2, [eax+ecx]
106 :    
107 :     movq mm1, [edx] ; ref1
108 :     movq mm3, [edx+ecx]
109 :     pavgusb mm1, [ebx] ; ref2
110 :     lea edx, [edx+2*ecx]
111 :     pavgusb mm3, [ebx+ecx]
112 :     lea ebx, [ebx+2*ecx]
113 :    
114 :     movq mm4, mm0
115 :     lea eax, [eax+2*ecx]
116 :     psubusb mm0, mm1
117 :     movq mm5, mm2
118 :     psubusb mm2, mm3
119 :    
120 :     psubusb mm1, mm4
121 :     por mm0, mm1
122 :     psubusb mm3, mm5
123 :     por mm2, mm3
124 :    
125 :     movq mm1, mm0
126 :     movq mm3, mm2
127 :    
128 :     punpcklbw mm0,mm7
129 :     punpckhbw mm1,mm7
130 :     punpcklbw mm2,mm7
131 :     punpckhbw mm3,mm7
132 :    
133 :     paddusw mm0,mm1
134 :     paddusw mm2,mm3
135 :     paddusw mm6,mm0
136 :     paddusw mm6,mm2
137 :     %endmacro
138 : suxen_drol 1.1
139 : edgomez 1.6 ;=============================================================================
140 :     ; Code
141 :     ;=============================================================================
142 : suxen_drol 1.1
143 : edgomez 1.6 SECTION .text
144 : suxen_drol 1.1
145 :     cglobal sad16bi_3dn
146 :     cglobal sad8bi_3dn
147 :    
148 : edgomez 1.6 ;-----------------------------------------------------------------------------
149 :     ;
150 :     ; uint32_t sad16bi_3dn(const uint8_t * const cur,
151 :     ; const uint8_t * const ref1,
152 :     ; const uint8_t * const ref2,
153 :     ; const uint32_t stride);
154 :     ;
155 :     ;-----------------------------------------------------------------------------
156 :    
157 :     ALIGN 16
158 :     sad16bi_3dn:
159 :     push ebx
160 :     mov eax, [esp+4+ 4] ; Src
161 :     mov edx, [esp+4+ 8] ; Ref1
162 :     mov ebx, [esp+4+12] ; Ref2
163 :     mov ecx, [esp+4+16] ; Stride
164 :    
165 :     pxor mm6, mm6 ; accum2
166 :     pxor mm7, mm7
167 : Isibaar 1.11 .Loop:
168 : edgomez 1.6 SADBI_16x16_3DN
169 :     SADBI_16x16_3DN
170 :     SADBI_16x16_3DN
171 :     SADBI_16x16_3DN
172 :     SADBI_16x16_3DN
173 :     SADBI_16x16_3DN
174 :     SADBI_16x16_3DN
175 :     SADBI_16x16_3DN
176 :    
177 :     SADBI_16x16_3DN
178 :     SADBI_16x16_3DN
179 :     SADBI_16x16_3DN
180 :     SADBI_16x16_3DN
181 :     SADBI_16x16_3DN
182 :     SADBI_16x16_3DN
183 :     SADBI_16x16_3DN
184 :     SADBI_16x16_3DN
185 :    
186 :     pmaddwd mm6, [mmx_one] ; collapse
187 :     movq mm7, mm6
188 :     psrlq mm7, 32
189 :     paddd mm6, mm7
190 :    
191 :     movd eax, mm6
192 :    
193 :     pop ebx
194 :    
195 :     ret
196 : Isibaar 1.11 ENDFUNC
197 : edgomez 1.6
198 :     ;-----------------------------------------------------------------------------
199 :     ;
200 :     ; uint32_t sad8bi_3dn(const uint8_t * const cur,
201 :     ; const uint8_t * const ref1,
202 :     ; const uint8_t * const ref2,
203 :     ; const uint32_t stride);
204 :     ;
205 :     ;-----------------------------------------------------------------------------
206 :    
207 :     ALIGN 16
208 :     sad8bi_3dn:
209 :     push ebx
210 :     mov eax, [esp+4+ 4] ; Src
211 :     mov edx, [esp+4+ 8] ; Ref1
212 :     mov ebx, [esp+4+12] ; Ref2
213 :     mov ecx, [esp+4+16] ; Stride
214 :    
215 :     pxor mm6, mm6 ; accum2
216 :     pxor mm7, mm7
217 : Isibaar 1.11 .Loop:
218 : edgomez 1.6 SADBI_8x8_3DN
219 :     SADBI_8x8_3DN
220 :     SADBI_8x8_3DN
221 :     SADBI_8x8_3DN
222 :    
223 :     pmaddwd mm6, [mmx_one] ; collapse
224 :     movq mm7, mm6
225 :     psrlq mm7, 32
226 :     paddd mm6, mm7
227 : suxen_drol 1.1
228 : edgomez 1.6 movd eax, mm6
229 : suxen_drol 1.1
230 : edgomez 1.6 pop ebx
231 : suxen_drol 1.1
232 : edgomez 1.6 ret
233 : Isibaar 1.11 ENDFUNC
234 : edgomez 1.9
235 : Isibaar 1.10
236 :     %ifidn __OUTPUT_FORMAT__,elf
237 :     section ".note.GNU-stack" noalloc noexec nowrite progbits
238 :     %endif
239 :    

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