[svn] / trunk / xvidcore / src / utils / x86_asm / mem_transfer_mmx.asm Repository:
ViewVC logotype

Annotation of /trunk/xvidcore/src/utils/x86_asm/mem_transfer_mmx.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1424 - (view) (download)

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

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