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

Annotation of /branches/dev-api-4/xvidcore/src/utils/x86_asm/mem_transfer_mmx.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1192 - (view) (download)

1 : edgomez 1192 ;/****************************************************************************
2 : Isibaar 3 ; *
3 : edgomez 1192 ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * - 8<->16 bit transfer functions -
5 : Isibaar 3 ; *
6 : edgomez 1192 ; * Copyright (C) 2001 Peter Ross <pross@xvid.org>
7 :     ; * 2001 Michael Militzer <isibaar@xvid.org>
8 :     ; * 2002 Pascal Massimino <skal@planet-d.net>
9 : Isibaar 3 ; *
10 : edgomez 1192 ; * This program is free software ; you can redistribute it and/or modify
11 :     ; * it under the terms of the GNU General Public License as published by
12 :     ; * the Free Software Foundation ; either version 2 of the License, or
13 :     ; * (at your option) any later version.
14 : Isibaar 3 ; *
15 : edgomez 1192 ; * This program is distributed in the hope that it will be useful,
16 :     ; * but WITHOUT ANY WARRANTY ; without even the implied warranty of
17 :     ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 :     ; * GNU General Public License for more details.
19 : Isibaar 3 ; *
20 : edgomez 1192 ; * You should have received a copy of the GNU General Public License
21 :     ; * along with this program ; if not, write to the Free Software
22 :     ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 : Isibaar 3 ; *
24 : edgomez 1192 ; * $Id: mem_transfer_mmx.asm,v 1.9.2.1 2003-10-28 22:23:03 edgomez Exp $
25 : Isibaar 3 ; *
26 : edgomez 1192 ; ***************************************************************************/
27 : Isibaar 3
28 : edgomez 1192 BITS 32
29 : Isibaar 3
30 : edgomez 1192 %macro cglobal 1
31 : Isibaar 3 %ifdef PREFIX
32 : edgomez 1192 global _%1
33 : Isibaar 3 %define %1 _%1
34 :     %else
35 :     global %1
36 :     %endif
37 :     %endmacro
38 :    
39 : edgomez 1192 ;=============================================================================
40 :     ; Code
41 :     ;=============================================================================
42 : Isibaar 3
43 : edgomez 1192 SECTION .text
44 : Isibaar 3
45 : Isibaar 226 cglobal transfer_8to16copy_mmx
46 :     cglobal transfer_16to8copy_mmx
47 :     cglobal transfer_8to16sub_mmx
48 : edgomez 851 cglobal transfer_8to16subro_mmx
49 : Isibaar 226 cglobal transfer_8to16sub2_mmx
50 :     cglobal transfer_8to16sub2_xmm
51 :     cglobal transfer_16to8add_mmx
52 :     cglobal transfer8x8_copy_mmx
53 : Isibaar 3
54 : edgomez 1192 ;-----------------------------------------------------------------------------
55 : Isibaar 3 ;
56 :     ; void transfer_8to16copy_mmx(int16_t * const dst,
57 :     ; const uint8_t * const src,
58 :     ; uint32_t stride);
59 :     ;
60 : edgomez 1192 ;-----------------------------------------------------------------------------
61 : Isibaar 3
62 : Isibaar 226 %macro COPY_8_TO_16 1
63 :     movq mm0, [eax]
64 :     movq mm1, [eax+edx]
65 :     movq mm2, mm0
66 :     movq mm3, mm1
67 :     punpcklbw mm0, mm7
68 :     movq [ecx+%1*32], mm0
69 :     punpcklbw mm1, mm7
70 :     movq [ecx+%1*32+16], mm1
71 :     punpckhbw mm2, mm7
72 :     punpckhbw mm3, mm7
73 : edgomez 1192 lea eax, [eax+2*edx]
74 : Isibaar 226 movq [ecx+%1*32+8], mm2
75 :     movq [ecx+%1*32+24], mm3
76 :     %endmacro
77 :    
78 : edgomez 1192 ALIGN 16
79 : Isibaar 226 transfer_8to16copy_mmx:
80 : Isibaar 3
81 : Isibaar 226 mov ecx, [esp+ 4] ; Dst
82 :     mov eax, [esp+ 8] ; Src
83 :     mov edx, [esp+12] ; Stride
84 : edgomez 1192 pxor mm7, mm7
85 : Isibaar 3
86 : Isibaar 226 COPY_8_TO_16 0
87 :     COPY_8_TO_16 1
88 :     COPY_8_TO_16 2
89 :     COPY_8_TO_16 3
90 :     ret
91 : Isibaar 3
92 : edgomez 1192 ;-----------------------------------------------------------------------------
93 : Isibaar 3 ;
94 :     ; void transfer_16to8copy_mmx(uint8_t * const dst,
95 :     ; const int16_t * const src,
96 :     ; uint32_t stride);
97 :     ;
98 : edgomez 1192 ;-----------------------------------------------------------------------------
99 : Isibaar 3
100 : Isibaar 226 %macro COPY_16_TO_8 1
101 :     movq mm0, [eax+%1*32]
102 :     movq mm1, [eax+%1*32+8]
103 :     packuswb mm0, mm1
104 :     movq [ecx], mm0
105 :     movq mm2, [eax+%1*32+16]
106 :     movq mm3, [eax+%1*32+24]
107 :     packuswb mm2, mm3
108 :     movq [ecx+edx], mm2
109 :     %endmacro
110 :    
111 : edgomez 1192 ALIGN 16
112 : Isibaar 226 transfer_16to8copy_mmx:
113 : Isibaar 3
114 : Isibaar 226 mov ecx, [esp+ 4] ; Dst
115 :     mov eax, [esp+ 8] ; Src
116 :     mov edx, [esp+12] ; Stride
117 : Isibaar 3
118 : Isibaar 226 COPY_16_TO_8 0
119 :     lea ecx,[ecx+2*edx]
120 :     COPY_16_TO_8 1
121 :     lea ecx,[ecx+2*edx]
122 :     COPY_16_TO_8 2
123 :     lea ecx,[ecx+2*edx]
124 :     COPY_16_TO_8 3
125 :     ret
126 : Isibaar 3
127 : edgomez 1192 ;-----------------------------------------------------------------------------
128 : Isibaar 3 ;
129 :     ; void transfer_8to16sub_mmx(int16_t * const dct,
130 :     ; uint8_t * const cur,
131 :     ; const uint8_t * const ref,
132 :     ; const uint32_t stride);
133 :     ;
134 : edgomez 1192 ;-----------------------------------------------------------------------------
135 : Isibaar 3
136 : edgomez 851 ; when second argument == 1, reference (ebx) block is to current (eax)
137 :     %macro COPY_8_TO_16_SUB 2
138 : Isibaar 226 movq mm0, [eax] ; cur
139 :     movq mm2, [eax+edx]
140 :     movq mm1, mm0
141 :     movq mm3, mm2
142 : Isibaar 3
143 : Isibaar 226 punpcklbw mm0, mm7
144 :     punpcklbw mm2, mm7
145 :     movq mm4, [ebx] ; ref
146 : edgomez 851 punpckhbw mm1, mm7
147 :     punpckhbw mm3, mm7
148 : Isibaar 226 movq mm5, [ebx+edx] ; ref
149 : Isibaar 3
150 : Isibaar 226 movq mm6, mm4
151 : edgomez 851 %if %2 == 1
152 : Isibaar 226 movq [eax], mm4
153 :     movq [eax+edx], mm5
154 : edgomez 851 %endif
155 : Isibaar 226 punpcklbw mm4, mm7
156 :     punpckhbw mm6, mm7
157 :     psubsw mm0, mm4
158 :     psubsw mm1, mm6
159 :     movq mm6, mm5
160 :     punpcklbw mm5, mm7
161 :     punpckhbw mm6, mm7
162 :     psubsw mm2, mm5
163 : edgomez 1192 lea eax, [eax+2*edx]
164 : Isibaar 226 psubsw mm3, mm6
165 :     lea ebx,[ebx+2*edx]
166 : Isibaar 3
167 : Isibaar 226 movq [ecx+%1*32+ 0], mm0 ; dst
168 : edgomez 851 movq [ecx+%1*32+ 8], mm1
169 :     movq [ecx+%1*32+16], mm2
170 :     movq [ecx+%1*32+24], mm3
171 : Isibaar 226 %endmacro
172 : Isibaar 3
173 : edgomez 1192 ALIGN 16
174 : Isibaar 226 transfer_8to16sub_mmx:
175 :     mov ecx, [esp + 4] ; Dst
176 :     mov eax, [esp + 8] ; Cur
177 :     push ebx
178 :     mov ebx, [esp+4+12] ; Ref
179 :     mov edx, [esp+4+16] ; Stride
180 :     pxor mm7, mm7
181 : Isibaar 3
182 : edgomez 851 COPY_8_TO_16_SUB 0, 1
183 :     COPY_8_TO_16_SUB 1, 1
184 :     COPY_8_TO_16_SUB 2, 1
185 :     COPY_8_TO_16_SUB 3, 1
186 : Isibaar 3
187 : Isibaar 226 pop ebx
188 :     ret
189 : Isibaar 3
190 : edgomez 851
191 : edgomez 1192 ALIGN 16
192 : edgomez 851 transfer_8to16subro_mmx:
193 :     mov ecx, [esp + 4] ; Dst
194 :     mov eax, [esp + 8] ; Cur
195 :     push ebx
196 :     mov ebx, [esp+4+12] ; Ref
197 :     mov edx, [esp+4+16] ; Stride
198 :     pxor mm7, mm7
199 :    
200 :     COPY_8_TO_16_SUB 0, 0
201 :     COPY_8_TO_16_SUB 1, 0
202 :     COPY_8_TO_16_SUB 2, 0
203 :     COPY_8_TO_16_SUB 3, 0
204 :    
205 :     pop ebx
206 :     ret
207 :    
208 :    
209 : edgomez 1192 ;-----------------------------------------------------------------------------
210 : Isibaar 226 ;
211 :     ; void transfer_8to16sub2_mmx(int16_t * const dct,
212 :     ; uint8_t * const cur,
213 :     ; const uint8_t * ref1,
214 :     ; const uint8_t * ref2,
215 :     ; const uint32_t stride)
216 :     ;
217 : edgomez 1192 ;-----------------------------------------------------------------------------
218 : Isibaar 3
219 : Isibaar 226 %macro COPY_8_TO_16_SUB2_MMX 1
220 :     movq mm0, [eax] ; cur
221 :     movq mm2, [eax+edx]
222 : Isibaar 3
223 : edgomez 1192 ; mm4 <- (ref1+ref2+1) / 2
224 : Isibaar 226 movq mm4, [ebx] ; ref1
225 :     movq mm1, [esi] ; ref2
226 :     movq mm6, mm4
227 :     movq mm3, mm1
228 :     punpcklbw mm4, mm7
229 :     punpcklbw mm1, mm7
230 :     punpckhbw mm6, mm7
231 :     punpckhbw mm3, mm7
232 :     paddusw mm4, mm1
233 :     paddusw mm6, mm3
234 : edgomez 1192 psrlw mm4, 1
235 :     psrlw mm6, 1
236 : Isibaar 226 packuswb mm4, mm6
237 : Isibaar 3
238 : Isibaar 226 ; mm5 <- (ref1+ref2+1) / 2
239 :     movq mm5, [ebx+edx] ; ref1
240 :     movq mm1, [esi+edx] ; ref2
241 :     movq mm6, mm5
242 :     movq mm3, mm1
243 :     punpcklbw mm5, mm7
244 :     punpcklbw mm1, mm7
245 :     punpckhbw mm6, mm7
246 : edgomez 1192 punpckhbw mm3, mm7
247 : Isibaar 226 paddusw mm5, mm1
248 :     paddusw mm6, mm3
249 : edgomez 1192 lea esi, [esi+2*edx]
250 :     psrlw mm5, 1
251 :     psrlw mm6, 1
252 : Isibaar 226 packuswb mm5, mm6
253 : Isibaar 3
254 :    
255 : Isibaar 226 movq mm1, mm0
256 :     movq mm3, mm2
257 :     punpcklbw mm0, mm7
258 :     punpcklbw mm2, mm7
259 : edgomez 1192 punpckhbw mm1, mm7
260 :     punpckhbw mm3, mm7
261 : Isibaar 3
262 : Isibaar 226 movq mm6, mm4
263 :     punpcklbw mm4, mm7
264 :     punpckhbw mm6, mm7
265 :     psubsw mm0, mm4
266 :     psubsw mm1, mm6
267 :     movq mm6, mm5
268 :     punpcklbw mm5, mm7
269 :     punpckhbw mm6, mm7
270 :     psubsw mm2, mm5
271 : edgomez 1192 lea eax, [eax+2*edx]
272 : Isibaar 226 psubsw mm3, mm6
273 : edgomez 1192 lea ebx, [ebx+2*edx]
274 : Isibaar 3
275 : Isibaar 226 movq [ecx+%1*32+ 0], mm0 ; dst
276 : edgomez 1192 movq [ecx+%1*32+ 8], mm1
277 :     movq [ecx+%1*32+16], mm2
278 :     movq [ecx+%1*32+24], mm3
279 : Isibaar 226 %endmacro
280 : Isibaar 3
281 : edgomez 1192 ALIGN 16
282 : Isibaar 226 transfer_8to16sub2_mmx:
283 :     mov ecx, [esp + 4] ; Dst
284 :     mov eax, [esp + 8] ; Cur
285 :     push ebx
286 :     mov ebx, [esp+4+12] ; Ref1
287 :     push esi
288 :     mov esi, [esp+8+16] ; Ref2
289 :     mov edx, [esp+8+20] ; Stride
290 :     pxor mm7, mm7
291 : Isibaar 3
292 : Isibaar 226 COPY_8_TO_16_SUB2_MMX 0
293 :     COPY_8_TO_16_SUB2_MMX 1
294 :     COPY_8_TO_16_SUB2_MMX 2
295 :     COPY_8_TO_16_SUB2_MMX 3
296 : Isibaar 3
297 : Isibaar 226 pop esi
298 :     pop ebx
299 :     ret
300 : Isibaar 3
301 : edgomez 1192 ;-----------------------------------------------------------------------------
302 : edgomez 215 ;
303 :     ; void transfer_8to16sub2_xmm(int16_t * const dct,
304 : Isibaar 226 ; uint8_t * const cur,
305 :     ; const uint8_t * ref1,
306 :     ; const uint8_t * ref2,
307 :     ; const uint32_t stride)
308 : edgomez 215 ;
309 : edgomez 1192 ;-----------------------------------------------------------------------------
310 : Isibaar 3
311 : Isibaar 226 %macro COPY_8_TO_16_SUB2_SSE 1
312 :     movq mm0, [eax] ; cur
313 :     movq mm2, [eax+edx]
314 :     movq mm1, mm0
315 :     movq mm3, mm2
316 : edgomez 215
317 : Isibaar 226 punpcklbw mm0, mm7
318 :     punpcklbw mm2, mm7
319 : edgomez 1192 movq mm4, [ebx] ; ref1
320 : Isibaar 226 pavgb mm4, [esi] ; ref2
321 : edgomez 1192 punpckhbw mm1, mm7
322 :     punpckhbw mm3, mm7
323 :     movq mm5, [ebx+edx] ; ref
324 : Isibaar 226 pavgb mm5, [esi+edx] ; ref2
325 : edgomez 215
326 : Isibaar 226 movq mm6, mm4
327 :     punpcklbw mm4, mm7
328 :     punpckhbw mm6, mm7
329 :     psubsw mm0, mm4
330 :     psubsw mm1, mm6
331 : edgomez 1192 lea esi, [esi+2*edx]
332 : Isibaar 226 movq mm6, mm5
333 :     punpcklbw mm5, mm7
334 :     punpckhbw mm6, mm7
335 :     psubsw mm2, mm5
336 : edgomez 1192 lea eax, [eax+2*edx]
337 : Isibaar 226 psubsw mm3, mm6
338 : edgomez 1192 lea ebx, [ebx+2*edx]
339 : edgomez 215
340 : Isibaar 226 movq [ecx+%1*32+ 0], mm0 ; dst
341 : edgomez 1192 movq [ecx+%1*32+ 8], mm1
342 :     movq [ecx+%1*32+16], mm2
343 :     movq [ecx+%1*32+24], mm3
344 : Isibaar 226 %endmacro
345 : edgomez 215
346 : edgomez 1192 ALIGN 16
347 : Isibaar 226 transfer_8to16sub2_xmm:
348 :     mov ecx, [esp + 4] ; Dst
349 :     mov eax, [esp + 8] ; Cur
350 :     push ebx
351 :     mov ebx, [esp+4+12] ; Ref1
352 :     push esi
353 :     mov esi, [esp+8+16] ; Ref2
354 :     mov edx, [esp+8+20] ; Stride
355 :     pxor mm7, mm7
356 : edgomez 215
357 : Isibaar 226 COPY_8_TO_16_SUB2_SSE 0
358 :     COPY_8_TO_16_SUB2_SSE 1
359 :     COPY_8_TO_16_SUB2_SSE 2
360 :     COPY_8_TO_16_SUB2_SSE 3
361 : edgomez 215
362 : Isibaar 226 pop esi
363 :     pop ebx
364 :     ret
365 : edgomez 215
366 : edgomez 1192 ;-----------------------------------------------------------------------------
367 : Isibaar 3 ;
368 :     ; void transfer_16to8add_mmx(uint8_t * const dst,
369 :     ; const int16_t * const src,
370 :     ; uint32_t stride);
371 :     ;
372 : edgomez 1192 ;-----------------------------------------------------------------------------
373 : Isibaar 3
374 : Isibaar 226 %macro COPY_16_TO_8_ADD 1
375 :     movq mm0, [ecx]
376 :     movq mm2, [ecx+edx]
377 :     movq mm1, mm0
378 :     movq mm3, mm2
379 :     punpcklbw mm0, mm7
380 :     punpcklbw mm2, mm7
381 :     punpckhbw mm1, mm7
382 :     punpckhbw mm3, mm7
383 :     paddsw mm0, [eax+%1*32+ 0]
384 :     paddsw mm1, [eax+%1*32+ 8]
385 :     paddsw mm2, [eax+%1*32+16]
386 :     paddsw mm3, [eax+%1*32+24]
387 :     packuswb mm0, mm1
388 :     movq [ecx], mm0
389 :     packuswb mm2, mm3
390 :     movq [ecx+edx], mm2
391 :     %endmacro
392 : Isibaar 3
393 :    
394 : edgomez 1192 ALIGN 16
395 : Isibaar 226 transfer_16to8add_mmx:
396 :     mov ecx, [esp+ 4] ; Dst
397 :     mov eax, [esp+ 8] ; Src
398 :     mov edx, [esp+12] ; Stride
399 :     pxor mm7, mm7
400 : Isibaar 3
401 : Isibaar 226 COPY_16_TO_8_ADD 0
402 :     lea ecx,[ecx+2*edx]
403 :     COPY_16_TO_8_ADD 1
404 :     lea ecx,[ecx+2*edx]
405 :     COPY_16_TO_8_ADD 2
406 :     lea ecx,[ecx+2*edx]
407 :     COPY_16_TO_8_ADD 3
408 :     ret
409 : Isibaar 3
410 : edgomez 1192 ;-----------------------------------------------------------------------------
411 : Isibaar 3 ;
412 :     ; void transfer8x8_copy_mmx(uint8_t * const dst,
413 :     ; const uint8_t * const src,
414 :     ; const uint32_t stride);
415 :     ;
416 :     ;
417 : edgomez 1192 ;-----------------------------------------------------------------------------
418 : Isibaar 3
419 : Isibaar 226 %macro COPY_8_TO_8 0
420 :     movq mm0, [eax]
421 :     movq mm1, [eax+edx]
422 :     movq [ecx], mm0
423 : edgomez 1192 lea eax, [eax+2*edx]
424 : Isibaar 226 movq [ecx+edx], mm1
425 :     %endmacro
426 :    
427 : edgomez 1192 ALIGN 16
428 : Isibaar 226 transfer8x8_copy_mmx:
429 :     mov ecx, [esp+ 4] ; Dst
430 :     mov eax, [esp+ 8] ; Src
431 :     mov edx, [esp+12] ; Stride
432 : Isibaar 3
433 : Isibaar 226 COPY_8_TO_8
434 :     lea ecx,[ecx+2*edx]
435 :     COPY_8_TO_8
436 :     lea ecx,[ecx+2*edx]
437 :     COPY_8_TO_8
438 :     lea ecx,[ecx+2*edx]
439 :     COPY_8_TO_8
440 :     ret

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