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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1540 - (view) (download)

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

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