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