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

Diff of /trunk/xvidcore/src/utils/x86_asm/mem_transfer_mmx.asm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 654, Sun Nov 17 00:51:11 2002 UTC revision 1583, Sun Dec 19 13:16:50 2004 UTC
# Line 1  Line 1 
1  ;/**************************************************************************  ;/****************************************************************************
2  ; *  ; *
3  ; *     XVID MPEG-4 VIDEO CODEC  ; *     XVID MPEG-4 VIDEO CODEC
4  ; *     mmx 8bit<->16bit transfers  ; *  - 8<->16 bit transfer functions -
5  ; *  ; *
6  ; *  This file is part of XviD, a free MPEG-4 video encoder/decoder  ; *  Copyright (C) 2001 Peter Ross <pross@xvid.org>
7    ; *                2001 Michael Militzer <isibaar@xvid.org>
8    ; *                2002 Pascal Massimino <skal@planet-d.net>
9  ; *  ; *
10  ; *  XviD is free software; you can redistribute it and/or modify it  ; *  This program is free software ; you can redistribute it and/or modify
11  ; *  under the terms of the GNU General Public License as published by  ; *  it under the terms of the GNU General Public License as published by
12  ; *  the Free Software Foundation; either version 2 of the License, or  ; *  the Free Software Foundation; either version 2 of the License, or
13  ; *  (at your option) any later version.  ; *  (at your option) any later version.
14  ; *  ; *
# Line 19  Line 21 
21  ; *  along with this program; if not, write to the Free Software  ; *  along with this program; if not, write to the Free Software
22  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
23  ; *  ; *
24  ; *  Under section 8 of the GNU General Public License, the copyright  ; * $Id: mem_transfer_mmx.asm,v 1.16 2004-12-19 13:16:50 syskin Exp $
 ; *  holders of XVID explicitly forbid distribution in the following  
 ; *  countries:  
25  ; *  ; *
26  ; *    - Japan  ; ***************************************************************************/
 ; *    - United States of America  
 ; *  
 ; *  Linking XviD statically or dynamically with other modules is making a  
 ; *  combined work based on XviD.  Thus, the terms and conditions of the  
 ; *  GNU General Public License cover the whole combination.  
 ; *  
 ; *  As a special exception, the copyright holders of XviD give you  
 ; *  permission to link XviD with independent modules that communicate with  
 ; *  XviD solely through the VFW1.1 and DShow interfaces, regardless of the  
 ; *  license terms of these independent modules, and to copy and distribute  
 ; *  the resulting combined work under terms of your choice, provided that  
 ; *  every copy of the combined work is accompanied by a complete copy of  
 ; *  the source code of XviD (the version of XviD used to produce the  
 ; *  combined work), being distributed under the terms of the GNU General  
 ; *  Public License plus this exception.  An independent module is a module  
 ; *  which is not derived from or based on XviD.  
 ; *  
 ; *  Note that people who make modified versions of XviD are not obligated  
 ; *  to grant this special exception for their modified versions; it is  
 ; *  their choice whether to do so.  The GNU General Public License gives  
 ; *  permission to release a modified version without this exception; this  
 ; *  exception also makes it possible to release a modified version which  
 ; *  carries forward this exception.  
 ; *  
 ; * $Id: mem_transfer_mmx.asm,v 1.8 2002-11-17 00:51:11 edgomez Exp $  
 ; *  
 ; *************************************************************************/  
27    
28  ;/**************************************************************************  BITS 32
 ; *  
 ; *     History:  
 ; *  
 ; * 04.06.2002  speed enhancement (unroll+overlap). -Skal-  
 ; *             + added transfer_8to16sub2_mmx/xmm  
 ; * 07.01.2002  merge functions from compensate_mmx; rename functions  
 ; *     07.11.2001      initial version; (c)2001 peter ross <pross@xvid.org>  
 ; *  
 ; *************************************************************************/  
   
   
 bits 32  
29    
30  %macro cglobal 1  %macro cglobal 1
31          %ifdef PREFIX          %ifdef PREFIX
32                    %ifdef MARK_FUNCS
33                            global _%1:function %1.endfunc-%1
34                            %define %1 _%1:function %1.endfunc-%1
35                    %else
36                  global _%1                  global _%1
37                  %define %1 _%1                  %define %1 _%1
38                    %endif
39            %else
40                    %ifdef MARK_FUNCS
41                            global %1:function %1.endfunc-%1
42          %else          %else
43                  global %1                  global %1
44          %endif          %endif
45            %endif
46  %endmacro  %endmacro
47    
48    ;=============================================================================
49    ; Read only data
50    ;=============================================================================
51    
52    %ifdef FORMAT_COFF
53    SECTION .rodata
54    %else
55    SECTION .rodata align=16
56    %endif
57    
58    ALIGN 16
59    mmx_one:
60            dw 1, 1, 1, 1
61    
62    ;=============================================================================
63    ; Code
64    ;=============================================================================
65    
66  section .text  SECTION .text
67    
68  cglobal transfer_8to16copy_mmx  cglobal transfer_8to16copy_mmx
69  cglobal transfer_16to8copy_mmx  cglobal transfer_16to8copy_mmx
70  cglobal transfer_8to16sub_mmx  cglobal transfer_8to16sub_mmx
71    cglobal transfer_8to16subro_mmx
72  cglobal transfer_8to16sub2_mmx  cglobal transfer_8to16sub2_mmx
73  cglobal transfer_8to16sub2_xmm  cglobal transfer_8to16sub2_xmm
74    cglobal transfer_8to16sub2ro_xmm
75  cglobal transfer_16to8add_mmx  cglobal transfer_16to8add_mmx
76  cglobal transfer8x8_copy_mmx  cglobal transfer8x8_copy_mmx
77    
78  ;===========================================================================  ;-----------------------------------------------------------------------------
79  ;  ;
80  ; void transfer_8to16copy_mmx(int16_t * const dst,  ; void transfer_8to16copy_mmx(int16_t * const dst,
81  ;                                                       const uint8_t * const src,  ;                                                       const uint8_t * const src,
82  ;                                                       uint32_t stride);  ;                                                       uint32_t stride);
83  ;  ;
84  ;===========================================================================  ;-----------------------------------------------------------------------------
85    
86  %macro COPY_8_TO_16 1  %macro COPY_8_TO_16 1
87    movq mm0, [eax]    movq mm0, [eax]
# Line 110  Line 99 
99    movq [ecx+%1*32+24], mm3    movq [ecx+%1*32+24], mm3
100  %endmacro  %endmacro
101    
102  align 16  ALIGN 16
103  transfer_8to16copy_mmx:  transfer_8to16copy_mmx:
104    
105    mov ecx, [esp+ 4] ; Dst    mov ecx, [esp+ 4] ; Dst
# Line 123  Line 112 
112    COPY_8_TO_16 2    COPY_8_TO_16 2
113    COPY_8_TO_16 3    COPY_8_TO_16 3
114    ret    ret
115    .endfunc
116    
117  ;===========================================================================  ;-----------------------------------------------------------------------------
118  ;  ;
119  ; void transfer_16to8copy_mmx(uint8_t * const dst,  ; void transfer_16to8copy_mmx(uint8_t * const dst,
120  ;                                                       const int16_t * const src,  ;                                                       const int16_t * const src,
121  ;                                                       uint32_t stride);  ;                                                       uint32_t stride);
122  ;  ;
123  ;===========================================================================  ;-----------------------------------------------------------------------------
124    
125  %macro COPY_16_TO_8 1  %macro COPY_16_TO_8 1
126    movq mm0, [eax+%1*32]    movq mm0, [eax+%1*32]
# Line 143  Line 133 
133    movq [ecx+edx], mm2    movq [ecx+edx], mm2
134  %endmacro  %endmacro
135    
136  align 16  ALIGN 16
137  transfer_16to8copy_mmx:  transfer_16to8copy_mmx:
138    
139    mov ecx, [esp+ 4] ; Dst    mov ecx, [esp+ 4] ; Dst
# Line 158  Line 148 
148    lea ecx,[ecx+2*edx]    lea ecx,[ecx+2*edx]
149    COPY_16_TO_8 3    COPY_16_TO_8 3
150    ret    ret
151    .endfunc
152    
153  ;===========================================================================  ;-----------------------------------------------------------------------------
154  ;  ;
155  ; void transfer_8to16sub_mmx(int16_t * const dct,  ; void transfer_8to16sub_mmx(int16_t * const dct,
156  ;                               uint8_t * const cur,  ;                               uint8_t * const cur,
157  ;                               const uint8_t * const ref,  ;                               const uint8_t * const ref,
158  ;                               const uint32_t stride);  ;                               const uint32_t stride);
159  ;  ;
160  ;===========================================================================  ;-----------------------------------------------------------------------------
 ;/**************************************************************************  
 ; *  
 ; *     History:  
 ; *  
 ; * 27.12.2001  renamed from 'compensate' to 'transfer_8to16sub'  
 ; * 02.12.2001  loop unrolled, code runs 10% faster now (Isibaar)  
 ; * 30.11.2001  16 pixels are processed per iteration (Isibaar)  
 ; * 30.11.2001  .text missing  
 ; *     06.11.2001      inital version; (c)2001 peter ross <pross@xvid.org>  
 ; *  
 ; *************************************************************************/  
161    
162  %macro COPY_8_TO_16_SUB 1  ; when second argument == 1, reference (ebx) block is to current (eax)
163    %macro COPY_8_TO_16_SUB 2
164    movq mm0, [eax]      ; cur    movq mm0, [eax]      ; cur
165    movq mm2, [eax+edx]    movq mm2, [eax+edx]
166    movq mm1, mm0    movq mm1, mm0
# Line 193  Line 174 
174    movq mm5, [ebx+edx]  ; ref    movq mm5, [ebx+edx]  ; ref
175    
176    movq mm6, mm4    movq mm6, mm4
177    %if %2 == 1
178    movq [eax], mm4    movq [eax], mm4
179    movq [eax+edx], mm5    movq [eax+edx], mm5
180    %endif
181    punpcklbw mm4, mm7    punpcklbw mm4, mm7
182    punpckhbw mm6, mm7    punpckhbw mm6, mm7
183    psubsw mm0, mm4    psubsw mm0, mm4
# Line 213  Line 196 
196          movq [ecx+%1*32+24], mm3          movq [ecx+%1*32+24], mm3
197  %endmacro  %endmacro
198    
199  align 16  ALIGN 16
200  transfer_8to16sub_mmx:  transfer_8to16sub_mmx:
201    mov ecx, [esp  + 4] ; Dst    mov ecx, [esp  + 4] ; Dst
202    mov eax, [esp  + 8] ; Cur    mov eax, [esp  + 8] ; Cur
# Line 222  Line 205 
205    mov edx, [esp+4+16] ; Stride    mov edx, [esp+4+16] ; Stride
206    pxor mm7, mm7    pxor mm7, mm7
207    
208    COPY_8_TO_16_SUB 0    COPY_8_TO_16_SUB 0, 1
209    COPY_8_TO_16_SUB 1    COPY_8_TO_16_SUB 1, 1
210    COPY_8_TO_16_SUB 2    COPY_8_TO_16_SUB 2, 1
211    COPY_8_TO_16_SUB 3    COPY_8_TO_16_SUB 3, 1
212    
213    pop ebx    pop ebx
214    ret    ret
215    .endfunc
216    
217  ;===========================================================================  
218    ALIGN 16
219    transfer_8to16subro_mmx:
220      mov ecx, [esp  + 4] ; Dst
221      mov eax, [esp  + 8] ; Cur
222      push ebx
223      mov ebx, [esp+4+12] ; Ref
224      mov edx, [esp+4+16] ; Stride
225      pxor mm7, mm7
226    
227      COPY_8_TO_16_SUB 0, 0
228      COPY_8_TO_16_SUB 1, 0
229      COPY_8_TO_16_SUB 2, 0
230      COPY_8_TO_16_SUB 3, 0
231    
232      pop ebx
233      ret
234    .endfunc
235    
236    
237    ;-----------------------------------------------------------------------------
238  ;  ;
239  ; void transfer_8to16sub2_mmx(int16_t * const dct,  ; void transfer_8to16sub2_mmx(int16_t * const dct,
240  ;                               uint8_t * const cur,  ;                               uint8_t * const cur,
# Line 238  Line 242 
242  ;                               const uint8_t * ref2,  ;                               const uint8_t * ref2,
243  ;                               const uint32_t stride)  ;                               const uint32_t stride)
244  ;  ;
245  ;===========================================================================  ;-----------------------------------------------------------------------------
246    
247  %macro COPY_8_TO_16_SUB2_MMX 1  %macro COPY_8_TO_16_SUB2_MMX 1
248    movq mm0, [eax]      ; cur    movq mm0, [eax]      ; cur
# Line 255  Line 259 
259    punpckhbw mm3, mm7    punpckhbw mm3, mm7
260    paddusw mm4, mm1    paddusw mm4, mm1
261    paddusw mm6, mm3    paddusw mm6, mm3
262      paddusw mm4, [mmx_one]
263      paddusw mm6, [mmx_one]
264    psrlw mm4,1    psrlw mm4,1
265    psrlw mm6,1    psrlw mm6,1
266    packuswb mm4, mm6    packuswb mm4, mm6
267      movq [eax], mm4
268    
269      ; mm5 <- (ref1+ref2+1) / 2      ; mm5 <- (ref1+ref2+1) / 2
270    movq mm5, [ebx+edx]  ; ref1    movq mm5, [ebx+edx]  ; ref1
# Line 270  Line 277 
277    punpckhbw mm3, mm7    punpckhbw mm3, mm7
278    paddusw mm5, mm1    paddusw mm5, mm1
279    paddusw mm6, mm3    paddusw mm6, mm3
280      paddusw mm5, [mmx_one]
281      paddusw mm6, [mmx_one]
282    lea esi,[esi+2*edx]    lea esi,[esi+2*edx]
283    psrlw mm5,1    psrlw mm5,1
284    psrlw mm6,1    psrlw mm6,1
285    packuswb mm5, mm6    packuswb mm5, mm6
286      movq [eax+edx], mm5
287    
288    movq mm1, mm0    movq mm1, mm0
289    movq mm3, mm2    movq mm3, mm2
# Line 302  Line 311 
311          movq [ecx+%1*32+24], mm3          movq [ecx+%1*32+24], mm3
312  %endmacro  %endmacro
313    
314  align 16  ALIGN 16
315  transfer_8to16sub2_mmx:  transfer_8to16sub2_mmx:
316    mov ecx, [esp  + 4] ; Dst    mov ecx, [esp  + 4] ; Dst
317    mov eax, [esp  + 8] ; Cur    mov eax, [esp  + 8] ; Cur
# Line 321  Line 330 
330    pop esi    pop esi
331    pop ebx    pop ebx
332    ret    ret
333    .endfunc
334    
335  ;===========================================================================  ;-----------------------------------------------------------------------------
336  ;  ;
337  ; void transfer_8to16sub2_xmm(int16_t * const dct,  ; void transfer_8to16sub2_xmm(int16_t * const dct,
338  ;                               uint8_t * const cur,  ;                               uint8_t * const cur,
# Line 330  Line 340 
340  ;                               const uint8_t * ref2,  ;                               const uint8_t * ref2,
341  ;                               const uint32_t stride)  ;                               const uint32_t stride)
342  ;  ;
343  ;===========================================================================  ;-----------------------------------------------------------------------------
344    
345  %macro COPY_8_TO_16_SUB2_SSE 1  %macro COPY_8_TO_16_SUB2_SSE 1
346    movq mm0, [eax]      ; cur    movq mm0, [eax]      ; cur
# Line 342  Line 352 
352    punpcklbw mm2, mm7    punpcklbw mm2, mm7
353    movq mm4, [ebx]      ; ref1    movq mm4, [ebx]      ; ref1
354    pavgb mm4, [esi]     ; ref2    pavgb mm4, [esi]     ; ref2
355      movq [eax], mm4
356          punpckhbw mm1, mm7          punpckhbw mm1, mm7
357          punpckhbw mm3, mm7          punpckhbw mm3, mm7
358    movq mm5, [ebx+edx]  ; ref    movq mm5, [ebx+edx]  ; ref
359    pavgb mm5, [esi+edx] ; ref2    pavgb mm5, [esi+edx] ; ref2
360      movq [eax+edx], mm5
361    
362    movq mm6, mm4    movq mm6, mm4
363    punpcklbw mm4, mm7    punpcklbw mm4, mm7
# Line 367  Line 379 
379          movq [ecx+%1*32+24], mm3          movq [ecx+%1*32+24], mm3
380  %endmacro  %endmacro
381    
382  align 16  ALIGN 16
383  transfer_8to16sub2_xmm:  transfer_8to16sub2_xmm:
384    mov ecx, [esp  + 4] ; Dst    mov ecx, [esp  + 4] ; Dst
385    mov eax, [esp  + 8] ; Cur    mov eax, [esp  + 8] ; Cur
# Line 386  Line 398 
398    pop esi    pop esi
399    pop ebx    pop ebx
400    ret    ret
401    .endfunc
402    
403  ;===========================================================================  
404    ;-----------------------------------------------------------------------------
405    ;
406    ; void transfer_8to16sub2ro_xmm(int16_t * const dct,
407    ;                               const uint8_t * const cur,
408    ;                               const uint8_t * ref1,
409    ;                               const uint8_t * ref2,
410    ;                               const uint32_t stride)
411    ;
412    ;-----------------------------------------------------------------------------
413    
414    %macro COPY_8_TO_16_SUB2RO_SSE 1
415      movq mm0, [eax]      ; cur
416      movq mm2, [eax+edx]
417      movq mm1, mm0
418      movq mm3, mm2
419    
420      punpcklbw mm0, mm7
421      punpcklbw mm2, mm7
422      movq mm4, [ebx]     ; ref1
423      pavgb mm4, [esi]     ; ref2
424      punpckhbw mm1, mm7
425      punpckhbw mm3, mm7
426      movq mm5, [ebx+edx] ; ref
427      pavgb mm5, [esi+edx] ; ref2
428    
429      movq mm6, mm4
430      punpcklbw mm4, mm7
431      punpckhbw mm6, mm7
432      psubsw mm0, mm4
433      psubsw mm1, mm6
434      lea esi, [esi+2*edx]
435      movq mm6, mm5
436      punpcklbw mm5, mm7
437      punpckhbw mm6, mm7
438      psubsw mm2, mm5
439      lea eax, [eax+2*edx]
440      psubsw mm3, mm6
441      lea ebx, [ebx+2*edx]
442    
443      movq [ecx+%1*32+ 0], mm0 ; dst
444      movq [ecx+%1*32+ 8], mm1
445      movq [ecx+%1*32+16], mm2
446      movq [ecx+%1*32+24], mm3
447    %endmacro
448    
449    ALIGN 16
450    transfer_8to16sub2ro_xmm:
451      pxor mm7, mm7
452      mov ecx, [esp  + 4] ; Dst
453      mov eax, [esp  + 8] ; Cur
454      push ebx
455      mov ebx, [esp+4+12] ; Ref1
456      push esi
457      mov esi, [esp+8+16] ; Ref2
458      mov edx, [esp+8+20] ; Stride
459    
460      COPY_8_TO_16_SUB2RO_SSE 0
461      COPY_8_TO_16_SUB2RO_SSE 1
462      COPY_8_TO_16_SUB2RO_SSE 2
463      COPY_8_TO_16_SUB2RO_SSE 3
464    
465      pop esi
466      pop ebx
467      ret
468    .endfunc
469    
470    
471    ;-----------------------------------------------------------------------------
472  ;  ;
473  ; void transfer_16to8add_mmx(uint8_t * const dst,  ; void transfer_16to8add_mmx(uint8_t * const dst,
474  ;                                               const int16_t * const src,  ;                                               const int16_t * const src,
475  ;                                               uint32_t stride);  ;                                               uint32_t stride);
476  ;  ;
477  ;===========================================================================  ;-----------------------------------------------------------------------------
478    
479  %macro COPY_16_TO_8_ADD 1  %macro COPY_16_TO_8_ADD 1
480    movq mm0, [ecx]    movq mm0, [ecx]
# Line 415  Line 496 
496  %endmacro  %endmacro
497    
498    
499  align 16  ALIGN 16
500  transfer_16to8add_mmx:  transfer_16to8add_mmx:
501    mov ecx, [esp+ 4] ; Dst    mov ecx, [esp+ 4] ; Dst
502    mov eax, [esp+ 8] ; Src    mov eax, [esp+ 8] ; Src
# Line 430  Line 511 
511    lea ecx,[ecx+2*edx]    lea ecx,[ecx+2*edx]
512    COPY_16_TO_8_ADD 3    COPY_16_TO_8_ADD 3
513    ret    ret
514    .endfunc
515    
516  ;===========================================================================  ;-----------------------------------------------------------------------------
517  ;  ;
518  ; void transfer8x8_copy_mmx(uint8_t * const dst,  ; void transfer8x8_copy_mmx(uint8_t * const dst,
519  ;                                       const uint8_t * const src,  ;                                       const uint8_t * const src,
520  ;                                       const uint32_t stride);  ;                                       const uint32_t stride);
521  ;  ;
522  ;  ;
523  ;===========================================================================  ;-----------------------------------------------------------------------------
524    
525  %macro COPY_8_TO_8 0  %macro COPY_8_TO_8 0
526    movq mm0, [eax]    movq mm0, [eax]
# Line 448  Line 530 
530    movq [ecx+edx], mm1    movq [ecx+edx], mm1
531  %endmacro  %endmacro
532    
533  align 16  ALIGN 16
534  transfer8x8_copy_mmx:  transfer8x8_copy_mmx:
535    mov ecx, [esp+ 4] ; Dst    mov ecx, [esp+ 4] ; Dst
536    mov eax, [esp+ 8] ; Src    mov eax, [esp+ 8] ; Src
# Line 462  Line 544 
544    lea ecx,[ecx+2*edx]    lea ecx,[ecx+2*edx]
545    COPY_8_TO_8    COPY_8_TO_8
546    ret    ret
547    .endfunc
548    

Legend:
Removed from v.654  
changed lines
  Added in v.1583

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