[cvs] / xvidcore / src / utils / x86_asm / mem_transfer_3dne.asm Repository:
ViewVC logotype

Annotation of /xvidcore/src/utils/x86_asm/mem_transfer_3dne.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (view) (download)

1 : edgomez 1.3 ;/****************************************************************************
2 : edgomez 1.2 ; *
3 : edgomez 1.3 ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * - 8<->16 bit transfer functions -
5 : edgomez 1.2 ; *
6 : edgomez 1.3 ; * Copyright (C) 2002 Jaan Kalda
7 : edgomez 1.2 ; *
8 : edgomez 1.3 ; * This program is free software ; you can redistribute it and/or modify
9 :     ; * it 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 : edgomez 1.2 ; *
13 : edgomez 1.3 ; * 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.2 ; *
18 : edgomez 1.3 ; * 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.2 ; *
22 : Isibaar 1.10 ; * $Id: mem_transfer_3dne.asm,v 1.9 2008/08/19 09:06:48 Isibaar Exp $
23 : edgomez 1.3 ; *
24 :     ; ***************************************************************************/
25 :    
26 :     ; these 3dne functions are compatible with iSSE, but are optimized specifically
27 :     ; for K7 pipelines
28 :    
29 :     BITS 32
30 : edgomez 1.2
31 : edgomez 1.3 %macro cglobal 1
32 :     %ifdef PREFIX
33 : edgomez 1.5 %ifdef MARK_FUNCS
34 : edgomez 1.6 global _%1:function %1.endfunc-%1
35 :     %define %1 _%1:function %1.endfunc-%1
36 : Isibaar 1.10 %define ENDFUNC .endfunc
37 : edgomez 1.5 %else
38 :     global _%1
39 :     %define %1 _%1
40 : Isibaar 1.10 %define ENDFUNC
41 : edgomez 1.5 %endif
42 : edgomez 1.3 %else
43 : edgomez 1.5 %ifdef MARK_FUNCS
44 : edgomez 1.6 global %1:function %1.endfunc-%1
45 : Isibaar 1.10 %define ENDFUNC .endfunc
46 : edgomez 1.5 %else
47 :     global %1
48 : Isibaar 1.10 %define ENDFUNC
49 : edgomez 1.5 %endif
50 : edgomez 1.3 %endif
51 :     %endmacro
52 : edgomez 1.2
53 : edgomez 1.3 ;=============================================================================
54 :     ; Read only data
55 :     ;=============================================================================
56 : edgomez 1.2
57 :     %ifdef FORMAT_COFF
58 : edgomez 1.4 SECTION .rodata
59 : edgomez 1.2 %else
60 : edgomez 1.4 SECTION .rodata align=16
61 : edgomez 1.2 %endif
62 :    
63 : edgomez 1.3 ALIGN 8
64 : edgomez 1.2 mm_zero:
65 : edgomez 1.3 dd 0,0
66 :     ;=============================================================================
67 :     ; Macros
68 :     ;=============================================================================
69 : edgomez 1.2
70 :     %macro nop4 0
71 : edgomez 1.3 db 08Dh, 074h, 026h, 0
72 : edgomez 1.2 %endmacro
73 :    
74 : edgomez 1.3 ;=============================================================================
75 :     ; Code
76 :     ;=============================================================================
77 :    
78 :     SECTION .text
79 : edgomez 1.2
80 :     cglobal transfer_8to16copy_3dne
81 :     cglobal transfer_16to8copy_3dne
82 :     cglobal transfer_8to16sub_3dne
83 :     cglobal transfer_8to16subro_3dne
84 :     cglobal transfer_8to16sub2_3dne
85 :     cglobal transfer_16to8add_3dne
86 :     cglobal transfer8x8_copy_3dne
87 : suxen_drol 1.7 cglobal transfer8x4_copy_3dne
88 : edgomez 1.2
89 : edgomez 1.3 ;-----------------------------------------------------------------------------
90 : edgomez 1.2 ;
91 :     ; void transfer_8to16copy_3dne(int16_t * const dst,
92 :     ; const uint8_t * const src,
93 :     ; uint32_t stride);
94 :     ;
95 : edgomez 1.3 ;-----------------------------------------------------------------------------
96 : edgomez 1.2
97 : edgomez 1.3 ALIGN 16
98 : edgomez 1.2 transfer_8to16copy_3dne:
99 :    
100 :     mov eax, [esp+ 8] ; Src
101 :     mov edx, [esp+12] ; Stride
102 :     mov ecx, [esp+ 4] ; Dst
103 :     punpcklbw mm0, [byte eax]
104 :     punpcklbw mm1, [eax+4]
105 : edgomez 1.3 movq mm2, [eax+edx]
106 :     movq mm3, [eax+edx]
107 :     pxor mm7, mm7
108 :     lea eax, [eax+2*edx]
109 :     punpcklbw mm2, mm7
110 :     punpckhbw mm3, mm7
111 :     psrlw mm0, 8
112 :     psrlw mm1, 8
113 : edgomez 1.2 punpcklbw mm4, [eax]
114 :     punpcklbw mm5, [eax+edx+4]
115 :     movq [byte ecx+0*64], mm0
116 :     movq [ecx+0*64+8], mm1
117 :     punpcklbw mm6, [eax+edx]
118 :     punpcklbw mm7, [eax+4]
119 : edgomez 1.3 lea eax, [byte eax+2*edx]
120 :     psrlw mm4, 8
121 :     psrlw mm5, 8
122 : edgomez 1.2 punpcklbw mm0, [eax]
123 :     punpcklbw mm1, [eax+edx+4]
124 :     movq [ecx+0*64+16], mm2
125 :     movq [ecx+0*64+24], mm3
126 : edgomez 1.3 psrlw mm6, 8
127 :     psrlw mm7, 8
128 : edgomez 1.2 punpcklbw mm2, [eax+edx]
129 :     punpcklbw mm3, [eax+4]
130 : edgomez 1.3 lea eax, [byte eax+2*edx]
131 : edgomez 1.2 movq [byte ecx+0*64+32], mm4
132 :     movq [ecx+0*64+56], mm5
133 : edgomez 1.3 psrlw mm0, 8
134 :     psrlw mm1, 8
135 : edgomez 1.2 punpcklbw mm4, [eax]
136 :     punpcklbw mm5, [eax+edx+4]
137 :     movq [byte ecx+0*64+48], mm6
138 :     movq [ecx+0*64+40], mm7
139 : edgomez 1.3 psrlw mm2, 8
140 :     psrlw mm3, 8
141 : edgomez 1.2 punpcklbw mm6, [eax+edx]
142 :     punpcklbw mm7, [eax+4]
143 :     movq [byte ecx+1*64], mm0
144 :     movq [ecx+1*64+24], mm1
145 : edgomez 1.3 psrlw mm4, 8
146 :     psrlw mm5, 8
147 : edgomez 1.2 movq [ecx+1*64+16], mm2
148 :     movq [ecx+1*64+8], mm3
149 : edgomez 1.3 psrlw mm6, 8
150 :     psrlw mm7, 8
151 : edgomez 1.2 movq [byte ecx+1*64+32], mm4
152 : edgomez 1.3 movq [ecx+1*64+56], mm5
153 : edgomez 1.2 movq [byte ecx+1*64+48], mm6
154 :     movq [ecx+1*64+40], mm7
155 : edgomez 1.3 ret
156 : Isibaar 1.10 ENDFUNC
157 : edgomez 1.2
158 : edgomez 1.3
159 :     ;-----------------------------------------------------------------------------
160 : edgomez 1.2 ;
161 :     ; void transfer_16to8copy_3dne(uint8_t * const dst,
162 :     ; const int16_t * const src,
163 :     ; uint32_t stride);
164 :     ;
165 : edgomez 1.3 ;-----------------------------------------------------------------------------
166 : edgomez 1.2
167 : edgomez 1.3 ALIGN 16
168 : edgomez 1.2 transfer_16to8copy_3dne:
169 :    
170 :     mov eax, [esp+ 8] ; Src
171 :     mov ecx, [esp+ 4] ; Dst
172 :     mov edx, [esp+12] ; Stride
173 :    
174 :     movq mm0, [byte eax+0*32]
175 : edgomez 1.3 packuswb mm0, [eax+0*32+8]
176 : edgomez 1.2 movq mm1, [eax+0*32+16]
177 : edgomez 1.3 packuswb mm1, [eax+0*32+24]
178 : edgomez 1.2 movq mm5, [eax+2*32+16]
179 :     movq mm2, [eax+1*32]
180 : edgomez 1.3 packuswb mm2, [eax+1*32+8]
181 : edgomez 1.2 movq mm3, [eax+1*32+16]
182 :     packuswb mm3, [eax+1*32+24]
183 : edgomez 1.3 movq mm6, [eax+3*32]
184 : edgomez 1.2 movq mm4, [eax+2*32]
185 : edgomez 1.3 packuswb mm4, [eax+2*32+8]
186 : edgomez 1.2 packuswb mm5, [eax+2*32+24]
187 :     movq mm7, [eax+3*32+16]
188 :     packuswb mm7, [eax+3*32+24]
189 : edgomez 1.3 packuswb mm6, [eax+3*32+8]
190 : edgomez 1.2 movq [ecx], mm0
191 : edgomez 1.3 lea eax, [3*edx]
192 :     add eax, ecx
193 : edgomez 1.2 movq [ecx+edx], mm1
194 :     movq [ecx+2*edx], mm2
195 :     movq [byte eax], mm3
196 :     movq [ecx+4*edx], mm4
197 : edgomez 1.3 lea ecx, [byte ecx+4*edx]
198 : edgomez 1.2 movq [eax+2*edx], mm5
199 :     movq [eax+4*edx], mm7
200 :     movq [ecx+2*edx], mm6
201 :     ret
202 : Isibaar 1.10 ENDFUNC
203 : edgomez 1.2
204 : edgomez 1.3 ;-----------------------------------------------------------------------------
205 : edgomez 1.2 ;
206 :     ; void transfer_8to16sub_3dne(int16_t * const dct,
207 :     ; uint8_t * const cur,
208 :     ; const uint8_t * const ref,
209 :     ; const uint32_t stride);
210 :     ;
211 : edgomez 1.3 ;-----------------------------------------------------------------------------
212 : edgomez 1.2
213 :     ; when second argument == 1, reference (ebx) block is to current (eax)
214 :     %macro COPY_8_TO_16_SUB 2
215 :     movq mm1, [eax] ; cur
216 :     movq mm0, mm1
217 :     movq mm4, [ecx] ; ref
218 :     movq mm6, mm4
219 :     %if %2 == 1
220 :     movq [eax], mm4
221 :     %endif
222 :     punpckhbw mm1, mm7
223 :     punpckhbw mm6, mm7
224 :     punpcklbw mm4, mm7
225 : edgomez 1.3 ALIGN 8
226 : edgomez 1.2 movq mm2, [byte eax+edx]
227 :     punpcklbw mm0, mm7
228 :     movq mm3, [byte eax+edx]
229 :     punpcklbw mm2, mm7
230 :     movq mm5, [byte ecx+edx] ; ref
231 :     punpckhbw mm3, mm7
232 :     %if %2 == 1
233 :     movq [byte eax+edx], mm5
234 :     %endif
235 :     psubsw mm1, mm6
236 :    
237 :     movq mm6, mm5
238 :     psubsw mm0, mm4
239 : edgomez 1.3 %if (%1 < 3)
240 : edgomez 1.2 lea eax,[eax+2*edx]
241 :     lea ecx,[ecx+2*edx]
242 :     %else
243 :     mov ecx,[esp]
244 :     add esp,byte 4
245 :     %endif
246 :     movq [edi+%1*32+ 8], mm1
247 :     movq [byte edi+%1*32+ 0], mm0 ; dst
248 :     punpcklbw mm5, mm7
249 :     punpckhbw mm6, mm7
250 :     psubsw mm2, mm5
251 :     psubsw mm3, mm6
252 :     movq [edi+%1*32+16], mm2
253 :     movq [edi+%1*32+24], mm3
254 :     %endmacro
255 :    
256 : edgomez 1.3 ALIGN 16
257 : edgomez 1.2 transfer_8to16sub_3dne:
258 :     mov eax, [esp + 8] ; Cur
259 :     mov ecx, [esp +12] ; Ref
260 :     push edi
261 : suxen_drol 1.8 mov edx, [esp+4+16] ; Stride
262 : edgomez 1.2 mov edi, [esp+4+ 4] ; Dst
263 :     pxor mm7, mm7
264 :     nop
265 : edgomez 1.3 ALIGN 4
266 : edgomez 1.2 COPY_8_TO_16_SUB 0, 1
267 :     COPY_8_TO_16_SUB 1, 1
268 :     COPY_8_TO_16_SUB 2, 1
269 :     COPY_8_TO_16_SUB 3, 1
270 : edgomez 1.3 mov edi, ecx
271 : edgomez 1.2 ret
272 : Isibaar 1.10 ENDFUNC
273 : edgomez 1.2
274 : edgomez 1.3 ALIGN 16
275 : edgomez 1.2 transfer_8to16subro_3dne:
276 :     mov eax, [esp + 8] ; Cur
277 :     mov ecx, [esp +12] ; Ref
278 :     push edi
279 : suxen_drol 1.8 mov edx, [esp+4+16] ; Stride
280 : edgomez 1.2 mov edi, [esp+4+ 4] ; Dst
281 :     pxor mm7, mm7
282 :     nop
283 : edgomez 1.3 ALIGN 4
284 : edgomez 1.2 COPY_8_TO_16_SUB 0, 0
285 :     COPY_8_TO_16_SUB 1, 0
286 :     COPY_8_TO_16_SUB 2, 0
287 :     COPY_8_TO_16_SUB 3, 0
288 : edgomez 1.3 mov edi, ecx
289 : edgomez 1.2 ret
290 : Isibaar 1.10 ENDFUNC
291 : edgomez 1.2
292 :    
293 : edgomez 1.3 ;-----------------------------------------------------------------------------
294 : edgomez 1.2 ;
295 :     ; void transfer_8to16sub2_3dne(int16_t * const dct,
296 :     ; uint8_t * const cur,
297 :     ; const uint8_t * ref1,
298 :     ; const uint8_t * ref2,
299 :     ; const uint32_t stride)
300 :     ;
301 : edgomez 1.3 ;-----------------------------------------------------------------------------
302 : edgomez 1.2
303 :     %macro COPY_8_TO_16_SUB2_SSE 1
304 : edgomez 1.3 db 0Fh, 6Fh, 44h, 20h, 00 ;movq mm0, [byte eax] ; cur
305 : edgomez 1.2 punpcklbw mm0, mm7
306 :     movq mm2, [byte eax+edx]
307 :     punpcklbw mm2, mm7
308 :     db 0Fh, 6Fh, 4ch, 20h, 00 ;movq mm1, [byte eax]
309 :     punpckhbw mm1, mm7
310 :     movq mm3, [byte eax+edx]
311 :     punpckhbw mm3, mm7
312 : edgomez 1.3
313 : edgomez 1.2 movq mm4, [byte ebx] ; ref1
314 :     pavgb mm4, [byte esi] ; ref2
315 : edgomez 1.3 movq [eax], mm4
316 : edgomez 1.2 movq mm5, [ebx+edx] ; ref
317 :     pavgb mm5, [esi+edx] ; ref2
318 : edgomez 1.3 movq [eax+edx], mm5
319 : edgomez 1.2 movq mm6, mm4
320 :     punpcklbw mm4, mm7
321 :     punpckhbw mm6, mm7
322 :     %if (%1 < 3)
323 :     lea esi,[esi+2*edx]
324 :     lea ebx,[byte ebx+2*edx]
325 :     lea eax,[eax+2*edx]
326 :     %else
327 :     mov esi,[esp]
328 :     mov ebx,[esp+4]
329 :     add esp,byte 8
330 : edgomez 1.3 %endif
331 : edgomez 1.2 psubsw mm0, mm4
332 :     psubsw mm1, mm6
333 :     movq mm6, mm5
334 :     punpcklbw mm5, mm7
335 :     punpckhbw mm6, mm7
336 :     psubsw mm2, mm5
337 :     psubsw mm3, mm6
338 :     movq [byte ecx+%1*32+ 0], mm0 ; dst
339 :     movq [ecx+%1*32+ 8], mm1
340 :     movq [ecx+%1*32+16], mm2
341 :     movq [ecx+%1*32+24], mm3
342 :     %endmacro
343 :    
344 : edgomez 1.3 ALIGN 16
345 : edgomez 1.2 transfer_8to16sub2_3dne:
346 :     mov edx, [esp +20] ; Stride
347 :     mov ecx, [esp + 4] ; Dst
348 :     mov eax, [esp + 8] ; Cur
349 :     push ebx
350 :     lea ebp,[byte ebp]
351 :     mov ebx, [esp+4+12] ; Ref1
352 :     push esi
353 :     pxor mm7, mm7
354 :     mov esi, [esp+8+16] ; Ref2
355 : edgomez 1.3 nop4
356 : edgomez 1.2 COPY_8_TO_16_SUB2_SSE 0
357 :     COPY_8_TO_16_SUB2_SSE 1
358 :     COPY_8_TO_16_SUB2_SSE 2
359 :     COPY_8_TO_16_SUB2_SSE 3
360 :    
361 :     ret
362 : Isibaar 1.10 ENDFUNC
363 : edgomez 1.2
364 :    
365 : edgomez 1.3 ;-----------------------------------------------------------------------------
366 : edgomez 1.2 ;
367 :     ; void transfer_16to8add_3dne(uint8_t * const dst,
368 :     ; const int16_t * const src,
369 :     ; uint32_t stride);
370 :     ;
371 : edgomez 1.3 ;-----------------------------------------------------------------------------
372 : edgomez 1.2
373 :     %macro COPY_16_TO_8_ADD 1
374 :     db 0Fh, 6Fh, 44h, 21h, 00 ;movq mm0, [byte ecx]
375 :     punpcklbw mm0, mm7
376 :     movq mm2, [byte ecx+edx]
377 :     punpcklbw mm2, mm7
378 :     db 0Fh, 6Fh, 4ch, 21h, 00 ;movq mm1, [byte ecx]
379 :     punpckhbw mm1, mm7
380 :     movq mm3, [byte ecx+edx]
381 :     punpckhbw mm3, mm7
382 :     paddsw mm0, [byte eax+%1*32+ 0]
383 :     paddsw mm1, [eax+%1*32+ 8]
384 :     paddsw mm2, [eax+%1*32+16]
385 :     paddsw mm3, [eax+%1*32+24]
386 :     packuswb mm0, mm1
387 :     packuswb mm2, mm3
388 : edgomez 1.3 mov esp,esp
389 : edgomez 1.2 movq [byte ecx], mm0
390 :     movq [ecx+edx], mm2
391 :     %endmacro
392 :    
393 :    
394 : edgomez 1.3 ALIGN 16
395 : edgomez 1.2 transfer_16to8add_3dne:
396 :     mov ecx, [esp+ 4] ; Dst
397 :     mov edx, [esp+12] ; Stride
398 :     mov eax, [esp+ 8] ; Src
399 :     pxor mm7, mm7
400 :     nop
401 :    
402 :     COPY_16_TO_8_ADD 0
403 :     lea ecx,[byte ecx+2*edx]
404 :     COPY_16_TO_8_ADD 1
405 :     lea ecx,[byte ecx+2*edx]
406 :     COPY_16_TO_8_ADD 2
407 :     lea ecx,[byte ecx+2*edx]
408 :     COPY_16_TO_8_ADD 3
409 :     ret
410 : Isibaar 1.10 ENDFUNC
411 : edgomez 1.2
412 : edgomez 1.3 ;-----------------------------------------------------------------------------
413 : edgomez 1.2 ;
414 :     ; void transfer8x8_copy_3dne(uint8_t * const dst,
415 :     ; const uint8_t * const src,
416 :     ; const uint32_t stride);
417 :     ;
418 :     ;
419 : edgomez 1.3 ;-----------------------------------------------------------------------------
420 : edgomez 1.2
421 :     %macro COPY_8_TO_8 0
422 :     movq mm0, [byte eax]
423 :     movq mm1, [eax+edx]
424 :     movq [byte ecx], mm0
425 :     lea eax,[byte eax+2*edx]
426 :     movq [ecx+edx], mm1
427 :     %endmacro
428 :    
429 : edgomez 1.3 ALIGN 16
430 : edgomez 1.2 transfer8x8_copy_3dne:
431 :     mov eax, [esp+ 8] ; Src
432 :     mov edx, [esp+12] ; Stride
433 :     mov ecx, [esp+ 4] ; Dst
434 :    
435 :     COPY_8_TO_8
436 :     lea ecx,[byte ecx+2*edx]
437 :     COPY_8_TO_8
438 :     lea ecx,[byte ecx+2*edx]
439 :     COPY_8_TO_8
440 :     lea ecx,[byte ecx+2*edx]
441 :     COPY_8_TO_8
442 :     ret
443 : Isibaar 1.10 ENDFUNC
444 : edgomez 1.6
445 : suxen_drol 1.7 ;-----------------------------------------------------------------------------
446 :     ;
447 :     ; void transfer8x4_copy_3dne(uint8_t * const dst,
448 :     ; const uint8_t * const src,
449 :     ; const uint32_t stride);
450 :     ;
451 :     ;
452 :     ;-----------------------------------------------------------------------------
453 :    
454 :     ALIGN 16
455 :     transfer8x4_copy_3dne:
456 :     mov eax, [esp+ 8] ; Src
457 :     mov edx, [esp+12] ; Stride
458 :     mov ecx, [esp+ 4] ; Dst
459 :    
460 :     COPY_8_TO_8
461 :     lea ecx,[byte ecx+2*edx]
462 :     COPY_8_TO_8
463 :     ret
464 : Isibaar 1.10 ENDFUNC
465 : suxen_drol 1.7
466 : Isibaar 1.9
467 :     %ifidn __OUTPUT_FORMAT__,elf
468 :     section ".note.GNU-stack" noalloc noexec nowrite progbits
469 :     %endif
470 :    

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