[cvs] / xvidcore / src / bitstream / x86_asm / cbp_mmx.asm Repository:
ViewVC logotype

Annotation of /xvidcore/src/bitstream/x86_asm/cbp_mmx.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (view) (download)

1 : Isibaar 1.1 ;/**************************************************************************
2 :     ; *
3 :     ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * mmx cbp calc
5 :     ; *
6 :     ; * This program is an implementation of a part of one or more MPEG-4
7 :     ; * Video tools as specified in ISO/IEC 14496-2 standard. Those intending
8 :     ; * to use this software module in hardware or software products are
9 :     ; * advised that its use may infringe existing patents or copyrights, and
10 :     ; * any such use would be at such party's own risk. The original
11 :     ; * developer of this software module and his/her company, and subsequent
12 :     ; * editors and their companies, will have no liability for use of this
13 :     ; * software or modifications or derivatives thereof.
14 :     ; *
15 :     ; * This program is free software; you can redistribute it and/or modify
16 :     ; * it under the terms of the GNU General Public License as published by
17 :     ; * the Free Software Foundation; either version 2 of the License, or
18 :     ; * (at your option) any later version.
19 :     ; *
20 :     ; * This program is distributed in the hope that it will be useful,
21 :     ; * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 :     ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 :     ; * GNU General Public License for more details.
24 :     ; *
25 :     ; * You should have received a copy of the GNU General Public License
26 :     ; * along with this program; if not, write to the Free Software
27 :     ; * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 :     ; *
29 :     ; *************************************************************************/
30 :    
31 :     ;/**************************************************************************
32 :     ; *
33 :     ; * History:
34 :     ; *
35 : h 1.4 ; * 24.04.2002 had to use sse2's movdqu instead of movdqa (???)
36 : h 1.3 ; * 17.04.2002 sse2 stuff
37 :     ; * 22.03.2002 0.01 ; Min Chen <chenm001@163.com>
38 :     ; * ; use 386 cpu's 'BTS' to replace 'cbp |= 1 << (edx-1)'
39 : Isibaar 1.1 ; * 24.11.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au>
40 :     ; *
41 :     ; *************************************************************************/
42 :    
43 :    
44 :     bits 32
45 :    
46 :     section .data
47 :    
48 :     %macro cglobal 1
49 :     %ifdef PREFIX
50 :     global _%1
51 :     %define %1 _%1
52 :     %else
53 :     global %1
54 :     %endif
55 :     %endmacro
56 :    
57 : h 1.3 align 16
58 :    
59 :     ignore_dc dw 0, -1, -1, -1, -1, -1, -1, -1
60 : Isibaar 1.1
61 :    
62 :     section .text
63 :    
64 :    
65 :     ;===========================================================================
66 :     ;
67 :     ; uint32_t calc_cbp_mmx(const int16_t coeff[6][64]);
68 :     ;
69 :     ;===========================================================================
70 :    
71 :     align 16
72 :     cglobal calc_cbp_mmx
73 :     calc_cbp_mmx
74 :     push ebx
75 :     push ecx
76 :     push edx
77 :     push esi
78 :    
79 :     mov esi, [esp + 16 + 4] ; coeff
80 :     movq mm7, [ignore_dc]
81 :    
82 :     xor eax, eax ; cbp = 0
83 :     mov edx, 6
84 :     .loop
85 :     movq mm0, [esi]
86 :     pand mm0, mm7
87 :     movq mm1, [esi+8]
88 :    
89 :     por mm0, [esi+16]
90 :     por mm1, [esi+24]
91 :    
92 :     por mm0, [esi+32]
93 :     por mm1, [esi+40]
94 :    
95 :     por mm0, [esi+48]
96 :     por mm1, [esi+56]
97 :    
98 :     por mm0, [esi+64]
99 :     por mm1, [esi+72]
100 :    
101 :     por mm0, [esi+80]
102 :     por mm1, [esi+88]
103 :    
104 :     por mm0, [esi+96]
105 :     por mm1, [esi+104]
106 :    
107 :     por mm0, [esi+112]
108 :     por mm1, [esi+120]
109 :    
110 :     por mm0, mm1
111 :     movq mm1, mm0
112 :     psrlq mm1, 32
113 :     por mm0, mm1
114 :     movd ebx, mm0
115 :    
116 :     add esi, 128
117 :    
118 :     or ebx, ebx
119 :     jz .iterate
120 :    
121 :     ; cbp |= 1 << (edx-1)
122 :    
123 : chenm001 1.2 ; Change by Chenm001 <chenm001@163.com>
124 :     ;mov ecx, edx
125 :     ;dec ecx
126 :     ;mov ebx, 1
127 :     ;shl ebx, cl
128 :     ;or eax, ebx
129 :     lea ebx,[edx-1]
130 :     bts eax,ebx
131 : Isibaar 1.1
132 :     .iterate dec edx
133 :     jnz .loop
134 :    
135 :     pop esi
136 :     pop edx
137 :     pop ecx
138 :     pop ebx
139 :    
140 : h 1.3 ret
141 :    
142 :    
143 :    
144 :     ;===========================================================================
145 :     ;
146 :     ; uint32_t calc_cbp_sse2(const int16_t coeff[6][64]);
147 :     ;
148 :     ; not enabled - slower than mmx?
149 :     ;
150 :     ;===========================================================================
151 :    
152 :     align 16
153 :     cglobal calc_cbp_sse2
154 :     calc_cbp_sse2
155 :     push esi
156 :    
157 :     mov esi, [esp + 4 + 4] ; coeff
158 : h 1.4 movdqu xmm7, [ignore_dc] ; mask to ignore dc value
159 : h 1.3
160 :     xor eax, eax ; cbp = 0
161 :     pxor xmm6, xmm6 ; zeroes to help psadbw
162 :    
163 :     .first movdqa xmm0, [esi]
164 :     pand xmm0, xmm7
165 :     movdqa xmm1, [esi+16]
166 :    
167 :     por xmm0, [esi+32]
168 :     por xmm1, [esi+48]
169 :     por xmm0, [esi+64]
170 :     por xmm1, [esi+80]
171 :     por xmm0, [esi+96]
172 :     por xmm1, [esi+112]
173 :    
174 :     por xmm0, xmm1 ; xmm0 = xmm1 = 128 bits worth of info
175 :     psadbw xmm0, xmm6 ; contains 2 dwords with sums
176 :     movhlps xmm1, xmm0 ; move high dword from xmm0 to low xmm1
177 :     por xmm0, xmm1 ; combine
178 :     movd ecx, xmm0 ; if ecx set, values were found
179 :    
180 :     add esi, 128
181 :    
182 :     or ecx, ecx
183 :     jz .second
184 :    
185 :     bts eax, 5
186 :    
187 :     .second movdqa xmm0, [esi]
188 :     pand xmm0, xmm7
189 :     movdqa xmm1, [esi+16]
190 :    
191 :     por xmm0, [esi+32]
192 :     por xmm1, [esi+48]
193 :     por xmm0, [esi+64]
194 :     por xmm1, [esi+80]
195 :     por xmm0, [esi+96]
196 :     por xmm1, [esi+112]
197 :    
198 :     por xmm0, xmm1
199 :     psadbw xmm0, xmm6
200 :     movhlps xmm1, xmm0
201 :     por xmm0, xmm1
202 :     movd ecx, xmm0
203 :    
204 :     add esi, 128
205 :    
206 :     or ecx, ecx
207 :     jz .third
208 :    
209 :     bts eax, 4
210 :    
211 :     .third movdqa xmm0, [esi]
212 :     pand xmm0, xmm7
213 :     movdqa xmm1, [esi+16]
214 :    
215 :     por xmm0, [esi+32]
216 :     por xmm1, [esi+48]
217 :     por xmm0, [esi+64]
218 :     por xmm1, [esi+80]
219 :     por xmm0, [esi+96]
220 :     por xmm1, [esi+112]
221 :    
222 :     por xmm0, xmm1
223 :     psadbw xmm0, xmm6
224 :     movhlps xmm1, xmm0
225 :     por xmm0, xmm1
226 :     movd ecx, xmm0
227 :    
228 :     add esi, 128
229 :    
230 :     or ecx, ecx
231 :     jz .fourth
232 :    
233 :     bts eax, 3
234 :    
235 :     .fourth movdqa xmm0, [esi]
236 :     pand xmm0, xmm7
237 :     movdqa xmm1, [esi+16]
238 :    
239 :     por xmm0, [esi+32]
240 :     por xmm1, [esi+48]
241 :     por xmm0, [esi+64]
242 :     por xmm1, [esi+80]
243 :     por xmm0, [esi+96]
244 :     por xmm1, [esi+112]
245 :    
246 :     por xmm0, xmm1
247 :     psadbw xmm0, xmm6
248 :     movhlps xmm1, xmm0
249 :     por xmm0, xmm1
250 :     movd ecx, xmm0
251 :    
252 :     add esi, 128
253 :    
254 :     or ecx, ecx
255 :     jz .fifth
256 :    
257 :     bts eax, 2
258 :    
259 :     .fifth movdqa xmm0, [esi]
260 :     pand xmm0, xmm7
261 :     movdqa xmm1, [esi+16]
262 :    
263 :     por xmm0, [esi+32]
264 :     por xmm1, [esi+48]
265 :     por xmm0, [esi+64]
266 :     por xmm1, [esi+80]
267 :     por xmm0, [esi+96]
268 :     por xmm1, [esi+112]
269 :    
270 :     por xmm0, xmm1
271 :     psadbw xmm0, xmm6
272 :     movhlps xmm1, xmm0
273 :     por xmm0, xmm1
274 :     movd ecx, xmm0
275 :    
276 :     add esi, 128
277 :    
278 :     or ecx, ecx
279 :     jz .sixth
280 :    
281 :     bts eax, 1
282 :    
283 :     .sixth movdqa xmm0, [esi]
284 :     pand xmm0, xmm7
285 :     movdqa xmm1, [esi+16]
286 :    
287 :     por xmm0, [esi+32]
288 :     por xmm1, [esi+48]
289 :     por xmm0, [esi+64]
290 :     por xmm1, [esi+80]
291 :     por xmm0, [esi+96]
292 :     por xmm1, [esi+112]
293 :    
294 :     por xmm0, xmm1
295 :     psadbw xmm0, xmm6
296 :     movhlps xmm1, xmm0
297 :     por xmm0, xmm1
298 :     movd ecx, xmm0
299 :    
300 :     or ecx, ecx
301 :     jz .end
302 :    
303 :     bts eax, 0
304 :    
305 :     .end pop esi
306 :    
307 : Isibaar 1.1 ret

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