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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1793 - (view) (download)

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

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