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

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

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

revision 1.6, Thu Jun 20 10:22:02 2002 UTC revision 1.18, Tue Aug 19 09:06:48 2008 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 program is an implementation of a part of one or more MPEG-4  ; *  Copyright (C) 2001 Peter Ross <pross@xvid.org>
7  ; *     Video tools as specified in ISO/IEC 14496-2 standard.  Those intending  ; *                2001 Michael Militzer <isibaar@xvid.org>
8  ; *     to use this software module in hardware or software products are  ; *                2002 Pascal Massimino <skal@planet-d.net>
 ; *     advised that its use may infringe existing patents or copyrights, and  
 ; *     any such use would be at such party's own risk.  The original  
 ; *     developer of this software module and his/her company, and subsequent  
 ; *     editors and their companies, will have no liability for use of this  
 ; *     software or modifications or derivatives thereof.  
9  ; *  ; *
10  ; *     This program is free software; you can redistribute it and/or modify  ; *     This program is free software; you can redistribute it and/or modify
11  ; *     it 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
# Line 24  Line 19 
19  ; *  ; *
20  ; *     You should have received a copy of the GNU General Public License  ; *     You should have received a copy of the GNU General Public License
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., 675 Mass Ave, Cambridge, MA 02139, USA.  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
23  ; *  ; *
24  ; *************************************************************************/  ; * $Id$
   
 ;/**************************************************************************  
 ; *  
 ; *     History:  
25  ; *  ; *
26  ; * 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@cs.rmit.edu.au>  
 ; *  
 ; *************************************************************************/  
   
27    
28  bits 32  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  section .text  ALIGN 16
59    mmx_one:
60            dw 1, 1, 1, 1
61    
62    ;=============================================================================
63    ; Code
64    ;=============================================================================
65    
66    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    cglobal transfer8x4_copy_mmx
78    
79  ;===========================================================================  ;-----------------------------------------------------------------------------
80  ;  ;
81  ; void transfer_8to16copy_mmx(int16_t * const dst,  ; void transfer_8to16copy_mmx(int16_t * const dst,
82  ;                                                       const uint8_t * const src,  ;                                                       const uint8_t * const src,
83  ;                                                       uint32_t stride);  ;                                                       uint32_t stride);
84  ;  ;
85  ;===========================================================================  ;-----------------------------------------------------------------------------
86    
87  %macro COPY_8_TO_16 1  %macro COPY_8_TO_16 1
88    movq mm0, [eax]    movq mm0, [eax]
# Line 86  Line 100 
100    movq [ecx+%1*32+24], mm3    movq [ecx+%1*32+24], mm3
101  %endmacro  %endmacro
102    
103  align 16  ALIGN 16
104  transfer_8to16copy_mmx:  transfer_8to16copy_mmx:
105    
106    mov ecx, [esp+ 4] ; Dst    mov ecx, [esp+ 4] ; Dst
# Line 99  Line 113 
113    COPY_8_TO_16 2    COPY_8_TO_16 2
114    COPY_8_TO_16 3    COPY_8_TO_16 3
115    ret    ret
116    .endfunc
117    
118  ;===========================================================================  ;-----------------------------------------------------------------------------
119  ;  ;
120  ; void transfer_16to8copy_mmx(uint8_t * const dst,  ; void transfer_16to8copy_mmx(uint8_t * const dst,
121  ;                                                       const int16_t * const src,  ;                                                       const int16_t * const src,
122  ;                                                       uint32_t stride);  ;                                                       uint32_t stride);
123  ;  ;
124  ;===========================================================================  ;-----------------------------------------------------------------------------
125    
126  %macro COPY_16_TO_8 1  %macro COPY_16_TO_8 1
127    movq mm0, [eax+%1*32]    movq mm0, [eax+%1*32]
# Line 119  Line 134 
134    movq [ecx+edx], mm2    movq [ecx+edx], mm2
135  %endmacro  %endmacro
136    
137  align 16  ALIGN 16
138  transfer_16to8copy_mmx:  transfer_16to8copy_mmx:
139    
140    mov ecx, [esp+ 4] ; Dst    mov ecx, [esp+ 4] ; Dst
# Line 134  Line 149 
149    lea ecx,[ecx+2*edx]    lea ecx,[ecx+2*edx]
150    COPY_16_TO_8 3    COPY_16_TO_8 3
151    ret    ret
152    .endfunc
153    
154  ;===========================================================================  ;-----------------------------------------------------------------------------
155  ;  ;
156  ; void transfer_8to16sub_mmx(int16_t * const dct,  ; void transfer_8to16sub_mmx(int16_t * const dct,
157  ;                               uint8_t * const cur,  ;                               uint8_t * const cur,
158  ;                               const uint8_t * const ref,  ;                               const uint8_t * const ref,
159  ;                               const uint32_t stride);  ;                               const uint32_t stride);
160  ;  ;
161  ;===========================================================================  ;-----------------------------------------------------------------------------
 ;/**************************************************************************  
 ; *  
 ; *     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@cs.rmit.edu.au>  
 ; *  
 ; *************************************************************************/  
162    
163  %macro COPY_8_TO_16_SUB 1  ; when second argument == 1, reference (ebx) block is to current (eax)
164    %macro COPY_8_TO_16_SUB 2
165    movq mm0, [eax]      ; cur    movq mm0, [eax]      ; cur
166    movq mm2, [eax+edx]    movq mm2, [eax+edx]
167    movq mm1, mm0    movq mm1, mm0
# Line 169  Line 175 
175    movq mm5, [ebx+edx]  ; ref    movq mm5, [ebx+edx]  ; ref
176    
177    movq mm6, mm4    movq mm6, mm4
178    %if %2 == 1
179    movq [eax], mm4    movq [eax], mm4
180    movq [eax+edx], mm5    movq [eax+edx], mm5
181    %endif
182    punpcklbw mm4, mm7    punpcklbw mm4, mm7
183    punpckhbw mm6, mm7    punpckhbw mm6, mm7
184    psubsw mm0, mm4    psubsw mm0, mm4
# Line 189  Line 197 
197          movq [ecx+%1*32+24], mm3          movq [ecx+%1*32+24], mm3
198  %endmacro  %endmacro
199    
200  align 16  ALIGN 16
201  transfer_8to16sub_mmx:  transfer_8to16sub_mmx:
202    mov ecx, [esp  + 4] ; Dst    mov ecx, [esp  + 4] ; Dst
203    mov eax, [esp  + 8] ; Cur    mov eax, [esp  + 8] ; Cur
# Line 198  Line 206 
206    mov edx, [esp+4+16] ; Stride    mov edx, [esp+4+16] ; Stride
207    pxor mm7, mm7    pxor mm7, mm7
208    
209    COPY_8_TO_16_SUB 0    COPY_8_TO_16_SUB 0, 1
210    COPY_8_TO_16_SUB 1    COPY_8_TO_16_SUB 1, 1
211    COPY_8_TO_16_SUB 2    COPY_8_TO_16_SUB 2, 1
212    COPY_8_TO_16_SUB 3    COPY_8_TO_16_SUB 3, 1
213    
214      pop ebx
215      ret
216    .endfunc
217    
218    
219    ALIGN 16
220    transfer_8to16subro_mmx:
221      mov ecx, [esp  + 4] ; Dst
222      mov eax, [esp  + 8] ; Cur
223      push ebx
224      mov ebx, [esp+4+12] ; Ref
225      mov edx, [esp+4+16] ; Stride
226      pxor mm7, mm7
227    
228      COPY_8_TO_16_SUB 0, 0
229      COPY_8_TO_16_SUB 1, 0
230      COPY_8_TO_16_SUB 2, 0
231      COPY_8_TO_16_SUB 3, 0
232    
233    pop ebx    pop ebx
234    ret    ret
235    .endfunc
236    
237  ;===========================================================================  
238    ;-----------------------------------------------------------------------------
239  ;  ;
240  ; void transfer_8to16sub2_mmx(int16_t * const dct,  ; void transfer_8to16sub2_mmx(int16_t * const dct,
241  ;                               uint8_t * const cur,  ;                               uint8_t * const cur,
# Line 214  Line 243 
243  ;                               const uint8_t * ref2,  ;                               const uint8_t * ref2,
244  ;                               const uint32_t stride)  ;                               const uint32_t stride)
245  ;  ;
246  ;===========================================================================  ;-----------------------------------------------------------------------------
247    
248  %macro COPY_8_TO_16_SUB2_MMX 1  %macro COPY_8_TO_16_SUB2_MMX 1
249    movq mm0, [eax]      ; cur    movq mm0, [eax]      ; cur
# Line 231  Line 260 
260    punpckhbw mm3, mm7    punpckhbw mm3, mm7
261    paddusw mm4, mm1    paddusw mm4, mm1
262    paddusw mm6, mm3    paddusw mm6, mm3
263      paddusw mm4, [mmx_one]
264      paddusw mm6, [mmx_one]
265    psrlw mm4,1    psrlw mm4,1
266    psrlw mm6,1    psrlw mm6,1
267    packuswb mm4, mm6    packuswb mm4, mm6
268      movq [eax], mm4
269    
270      ; mm5 <- (ref1+ref2+1) / 2      ; mm5 <- (ref1+ref2+1) / 2
271    movq mm5, [ebx+edx]  ; ref1    movq mm5, [ebx+edx]  ; ref1
# Line 246  Line 278 
278    punpckhbw mm3, mm7    punpckhbw mm3, mm7
279    paddusw mm5, mm1    paddusw mm5, mm1
280    paddusw mm6, mm3    paddusw mm6, mm3
281      paddusw mm5, [mmx_one]
282      paddusw mm6, [mmx_one]
283    lea esi,[esi+2*edx]    lea esi,[esi+2*edx]
284    psrlw mm5,1    psrlw mm5,1
285    psrlw mm6,1    psrlw mm6,1
286    packuswb mm5, mm6    packuswb mm5, mm6
287      movq [eax+edx], mm5
288    
289    movq mm1, mm0    movq mm1, mm0
290    movq mm3, mm2    movq mm3, mm2
# Line 278  Line 312 
312          movq [ecx+%1*32+24], mm3          movq [ecx+%1*32+24], mm3
313  %endmacro  %endmacro
314    
315  align 16  ALIGN 16
316  transfer_8to16sub2_mmx:  transfer_8to16sub2_mmx:
317    mov ecx, [esp  + 4] ; Dst    mov ecx, [esp  + 4] ; Dst
318    mov eax, [esp  + 8] ; Cur    mov eax, [esp  + 8] ; Cur
# Line 297  Line 331 
331    pop esi    pop esi
332    pop ebx    pop ebx
333    ret    ret
334    .endfunc
335    
336  ;===========================================================================  ;-----------------------------------------------------------------------------
337  ;  ;
338  ; void transfer_8to16sub2_xmm(int16_t * const dct,  ; void transfer_8to16sub2_xmm(int16_t * const dct,
339  ;                               uint8_t * const cur,  ;                               uint8_t * const cur,
# Line 306  Line 341 
341  ;                               const uint8_t * ref2,  ;                               const uint8_t * ref2,
342  ;                               const uint32_t stride)  ;                               const uint32_t stride)
343  ;  ;
344  ;===========================================================================  ;-----------------------------------------------------------------------------
345    
346  %macro COPY_8_TO_16_SUB2_SSE 1  %macro COPY_8_TO_16_SUB2_SSE 1
347    movq mm0, [eax]      ; cur    movq mm0, [eax]      ; cur
# Line 318  Line 353 
353    punpcklbw mm2, mm7    punpcklbw mm2, mm7
354    movq mm4, [ebx]      ; ref1    movq mm4, [ebx]      ; ref1
355    pavgb mm4, [esi]     ; ref2    pavgb mm4, [esi]     ; ref2
356      movq [eax], mm4
357          punpckhbw mm1, mm7          punpckhbw mm1, mm7
358          punpckhbw mm3, mm7          punpckhbw mm3, mm7
359    movq mm5, [ebx+edx]  ; ref    movq mm5, [ebx+edx]  ; ref
360    pavgb mm5, [esi+edx] ; ref2    pavgb mm5, [esi+edx] ; ref2
361      movq [eax+edx], mm5
362    
363    movq mm6, mm4    movq mm6, mm4
364    punpcklbw mm4, mm7    punpcklbw mm4, mm7
# Line 343  Line 380 
380          movq [ecx+%1*32+24], mm3          movq [ecx+%1*32+24], mm3
381  %endmacro  %endmacro
382    
383  align 16  ALIGN 16
384  transfer_8to16sub2_xmm:  transfer_8to16sub2_xmm:
385    mov ecx, [esp  + 4] ; Dst    mov ecx, [esp  + 4] ; Dst
386    mov eax, [esp  + 8] ; Cur    mov eax, [esp  + 8] ; Cur
# Line 362  Line 399 
399    pop esi    pop esi
400    pop ebx    pop ebx
401    ret    ret
402    .endfunc
403    
404    
405  ;===========================================================================  ;-----------------------------------------------------------------------------
406    ;
407    ; void transfer_8to16sub2ro_xmm(int16_t * const dct,
408    ;                               const uint8_t * const cur,
409    ;                               const uint8_t * ref1,
410    ;                               const uint8_t * ref2,
411    ;                               const uint32_t stride)
412    ;
413    ;-----------------------------------------------------------------------------
414    
415    %macro COPY_8_TO_16_SUB2RO_SSE 1
416      movq mm0, [eax]      ; cur
417      movq mm2, [eax+edx]
418      movq mm1, mm0
419      movq mm3, mm2
420    
421      punpcklbw mm0, mm7
422      punpcklbw mm2, mm7
423      movq mm4, [ebx]     ; ref1
424      pavgb mm4, [esi]     ; ref2
425      punpckhbw mm1, mm7
426      punpckhbw mm3, mm7
427      movq mm5, [ebx+edx] ; ref
428      pavgb mm5, [esi+edx] ; ref2
429    
430      movq mm6, mm4
431      punpcklbw mm4, mm7
432      punpckhbw mm6, mm7
433      psubsw mm0, mm4
434      psubsw mm1, mm6
435      lea esi, [esi+2*edx]
436      movq mm6, mm5
437      punpcklbw mm5, mm7
438      punpckhbw mm6, mm7
439      psubsw mm2, mm5
440      lea eax, [eax+2*edx]
441      psubsw mm3, mm6
442      lea ebx, [ebx+2*edx]
443    
444      movq [ecx+%1*32+ 0], mm0 ; dst
445      movq [ecx+%1*32+ 8], mm1
446      movq [ecx+%1*32+16], mm2
447      movq [ecx+%1*32+24], mm3
448    %endmacro
449    
450    ALIGN 16
451    transfer_8to16sub2ro_xmm:
452      pxor mm7, mm7
453      mov ecx, [esp  + 4] ; Dst
454      mov eax, [esp  + 8] ; Cur
455      push ebx
456      mov ebx, [esp+4+12] ; Ref1
457      push esi
458      mov esi, [esp+8+16] ; Ref2
459      mov edx, [esp+8+20] ; Stride
460    
461      COPY_8_TO_16_SUB2RO_SSE 0
462      COPY_8_TO_16_SUB2RO_SSE 1
463      COPY_8_TO_16_SUB2RO_SSE 2
464      COPY_8_TO_16_SUB2RO_SSE 3
465    
466      pop esi
467      pop ebx
468      ret
469    .endfunc
470    
471    
472    ;-----------------------------------------------------------------------------
473  ;  ;
474  ; void transfer_16to8add_mmx(uint8_t * const dst,  ; void transfer_16to8add_mmx(uint8_t * const dst,
475  ;                                               const int16_t * const src,  ;                                               const int16_t * const src,
476  ;                                               uint32_t stride);  ;                                               uint32_t stride);
477  ;  ;
478  ;===========================================================================  ;-----------------------------------------------------------------------------
479    
480  %macro COPY_16_TO_8_ADD 1  %macro COPY_16_TO_8_ADD 1
481    movq mm0, [ecx]    movq mm0, [ecx]
# Line 391  Line 497 
497  %endmacro  %endmacro
498    
499    
500  align 16  ALIGN 16
501  transfer_16to8add_mmx:  transfer_16to8add_mmx:
502    mov ecx, [esp+ 4] ; Dst    mov ecx, [esp+ 4] ; Dst
503    mov eax, [esp+ 8] ; Src    mov eax, [esp+ 8] ; Src
# Line 406  Line 512 
512    lea ecx,[ecx+2*edx]    lea ecx,[ecx+2*edx]
513    COPY_16_TO_8_ADD 3    COPY_16_TO_8_ADD 3
514    ret    ret
515    .endfunc
516    
517  ;===========================================================================  ;-----------------------------------------------------------------------------
518  ;  ;
519  ; void transfer8x8_copy_mmx(uint8_t * const dst,  ; void transfer8x8_copy_mmx(uint8_t * const dst,
520  ;                                       const uint8_t * const src,  ;                                       const uint8_t * const src,
521  ;                                       const uint32_t stride);  ;                                       const uint32_t stride);
522  ;  ;
523  ;  ;
524  ;===========================================================================  ;-----------------------------------------------------------------------------
525    
526  %macro COPY_8_TO_8 0  %macro COPY_8_TO_8 0
527    movq mm0, [eax]    movq mm0, [eax]
# Line 424  Line 531 
531    movq [ecx+edx], mm1    movq [ecx+edx], mm1
532  %endmacro  %endmacro
533    
534  align 16  ALIGN 16
535  transfer8x8_copy_mmx:  transfer8x8_copy_mmx:
536    mov ecx, [esp+ 4] ; Dst    mov ecx, [esp+ 4] ; Dst
537    mov eax, [esp+ 8] ; Src    mov eax, [esp+ 8] ; Src
# Line 438  Line 545 
545    lea ecx,[ecx+2*edx]    lea ecx,[ecx+2*edx]
546    COPY_8_TO_8    COPY_8_TO_8
547    ret    ret
548    .endfunc
549    
550    ;-----------------------------------------------------------------------------
551    ;
552    ; void transfer8x4_copy_mmx(uint8_t * const dst,
553    ;                                       const uint8_t * const src,
554    ;                                       const uint32_t stride);
555    ;
556    ;
557    ;-----------------------------------------------------------------------------
558    
559    ALIGN 16
560    transfer8x4_copy_mmx:
561      mov ecx, [esp+ 4] ; Dst
562      mov eax, [esp+ 8] ; Src
563      mov edx, [esp+12] ; Stride
564    
565      COPY_8_TO_8
566      lea ecx,[ecx+2*edx]
567      COPY_8_TO_8
568      ret
569    .endfunc
570    
571    
572    %ifidn __OUTPUT_FORMAT__,elf
573    section ".note.GNU-stack" noalloc noexec nowrite progbits
574    %endif
575    

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.18

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