[svn] / branches / dev-api-4 / xvidcore / src / utils / x86_asm / mem_transfer_3dne.asm Repository:
ViewVC logotype

Annotation of /branches/dev-api-4/xvidcore/src/utils/x86_asm/mem_transfer_3dne.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1192 - (view) (download)

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

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