[svn] / trunk / xvidcore / src / motion / x86_asm / sad_3dn.asm Repository:
ViewVC logotype

Diff of /trunk/xvidcore/src/motion/x86_asm/sad_3dn.asm

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

revision 430, Fri Sep 6 16:59:47 2002 UTC revision 1877, Wed Sep 16 17:11:39 2009 UTC
# Line 1  Line 1 
1  ;/*****************************************************************************  ;/****************************************************************************
2  ; *  ; *
3  ; *  XVID MPEG-4 VIDEO CODEC  ; *  XVID MPEG-4 VIDEO CODEC
4  ; *  3dnow (*but without xmm*) sum of absolute difference  ; *  - 3DNow sad operators w/o XMM instructions -
5  ; *  ; *
6  ; *  Copyright(C) 2002 Peter Ross <pross@xvid.org>  ; *  Copyright(C) 2002 Peter ross <pross@xvid.org>
7  ; *  ; *
8  ; *  This program is an implementation of a part of one or more MPEG-4  ; *  This program is free software; you can redistribute it and/or modify it
9  ; *  Video tools as specified in ISO/IEC 14496-2 standard.  Those intending  ; *  under the terms of the GNU General Public License as published by
 ; *  to use this software module in hardware or software products are  
 ; *  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.  
 ; *  
 ; *  This program is free software; you can redistribute it and/or modify  
 ; *  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  ; *  the Free Software Foundation; either version 2 of the License, or
11  ; *  (at your option) any later version.  ; *  (at your option) any later version.
12  ; *  ; *
# Line 28  Line 19 
19  ; *  along with this program; if not, write to the Free Software  ; *  along with this program; if not, write to the Free Software
20  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA  ; *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21  ; *  ; *
22  , ****************************************************************************/  ; * $Id: sad_3dn.asm,v 1.14 2009-09-16 17:07:58 Isibaar Exp $
23    ; *
24    ; ***************************************************************************/
25    
26  bits 32  %include "nasm.inc"
27    
28  %macro cglobal 1  ;=============================================================================
29          %ifdef PREFIX  ; Read only data
30                  global _%1  ;=============================================================================
                 %define %1 _%1  
         %else  
                 global %1  
         %endif  
 %endmacro  
31    
32  section .data  DATA
33    
34  align 16  ALIGN SECTION_ALIGN
35  mmx_one times 4 dw 1  mmx_one:
36            times 4 dw 1
37    
38  section .text  ;=============================================================================
39    ; Helper macros
40    ;=============================================================================
41    %macro SADBI_16x16_3DN 0
42      movq mm0, [_EAX] ; src
43      movq mm2, [_EAX+8]
44    
45  cglobal  sad16bi_3dn    movq mm1, [TMP1] ; ref1
46  cglobal  sad8bi_3dn    movq mm3, [TMP1+8]
47      pavgusb mm1, [_EBX] ; ref2
48      lea TMP1, [TMP1+TMP0]
49      pavgusb mm3, [_EBX+8]
50      lea _EBX, [_EBX+TMP0]
51    
52  ;===========================================================================    movq mm4, mm0
53  ;    lea _EAX, [_EAX+TMP0]
54  ; uint32_t sad16bi_3dn(const uint8_t * const cur,    psubusb mm0, mm1
55  ; const uint8_t * const ref1,    movq mm5, mm2
56  ; const uint8_t * const ref2,    psubusb mm2, mm3
 ; const uint32_t stride);  
 ;  
 ;===========================================================================  
57    
58  %macro SADBI_16x16_3DN 0    psubusb mm1, mm4
59     movq mm0, [eax] ; src    por mm0, mm1
60     movq mm2, [eax+8]    psubusb mm3, mm5
61      por mm2, mm3
62    
63     movq mm1, [edx] ; ref1    movq mm1, mm0
64     movq mm3, [edx+8]    movq mm3, mm2
65     pavgusb mm1, [ebx] ; ref2  
66     lea edx,[edx+ecx]    punpcklbw mm0,mm7
67     pavgusb mm3, [ebx+8]    punpckhbw mm1,mm7
68     lea ebx,[ebx+ecx]    punpcklbw mm2,mm7
69      punpckhbw mm3,mm7
70    
71      paddusw mm0,mm1
72      paddusw mm2,mm3
73      paddusw mm6,mm0
74      paddusw mm6,mm2
75    %endmacro
76    
77    %macro SADBI_8x8_3DN 0
78      movq mm0, [_EAX] ; src
79      movq mm2, [_EAX+TMP0]
80    
81      movq mm1, [TMP1] ; ref1
82      movq mm3, [TMP1+TMP0]
83      pavgusb mm1, [_EBX] ; ref2
84      lea TMP1, [TMP1+2*TMP0]
85      pavgusb mm3, [_EBX+TMP0]
86      lea _EBX, [_EBX+2*TMP0]
87    
88     movq mm4, mm0     movq mm4, mm0
89     lea eax,[eax+ecx]    lea _EAX, [_EAX+2*TMP0]
90     psubusb mm0, mm1     psubusb mm0, mm1
91     movq mm5, mm2     movq mm5, mm2
92     psubusb mm2, mm3     psubusb mm2, mm3
# Line 96  Line 110 
110     paddusw mm6,mm2     paddusw mm6,mm2
111  %endmacro  %endmacro
112    
113  align 16  ;=============================================================================
114    ; Code
115    ;=============================================================================
116    
117    TEXT
118    
119    cglobal  sad16bi_3dn
120    cglobal  sad8bi_3dn
121    
122    ;-----------------------------------------------------------------------------
123    ;
124    ; uint32_t sad16bi_3dn(const uint8_t * const cur,
125    ; const uint8_t * const ref1,
126    ; const uint8_t * const ref2,
127    ; const uint32_t stride);
128    ;
129    ;-----------------------------------------------------------------------------
130    
131    ALIGN SECTION_ALIGN
132  sad16bi_3dn:  sad16bi_3dn:
133     push ebx    mov _EAX, prm1 ; Src
134     mov eax, [esp+4+ 4] ; Src    mov TMP1, prm2 ; Ref1
135     mov edx, [esp+4+ 8] ; Ref1    mov TMP0, prm4 ; Stride
136     mov ebx, [esp+4+12] ; Ref2  
137     mov ecx, [esp+4+16] ; Stride    push _EBX
138    %ifdef ARCH_IS_X86_64
139      mov _EBX, prm3
140    %else
141      mov _EBX, [_ESP+4+12] ; Ref2
142    %endif
143    
144     pxor mm6, mm6 ; accum2     pxor mm6, mm6 ; accum2
145  pxor mm7, mm7  pxor mm7, mm7
146  .Loop  .Loop:
147     SADBI_16x16_3DN     SADBI_16x16_3DN
148     SADBI_16x16_3DN     SADBI_16x16_3DN
149     SADBI_16x16_3DN     SADBI_16x16_3DN
# Line 132  Line 169 
169    
170     movd eax, mm6     movd eax, mm6
171    
172     pop ebx    pop _EBX
173    
174     ret     ret
175    ENDFUNC
176    
177    ;-----------------------------------------------------------------------------
   
 ;===========================================================================  
178  ;  ;
179  ; uint32_t sad8bi_3dn(const uint8_t * const cur,  ; uint32_t sad8bi_3dn(const uint8_t * const cur,
180  ; const uint8_t * const ref1,  ; const uint8_t * const ref1,
181  ; const uint8_t * const ref2,  ; const uint8_t * const ref2,
182  ; const uint32_t stride);  ; const uint32_t stride);
183  ;  ;
184  ;===========================================================================  ;-----------------------------------------------------------------------------
   
 %macro SADBI_8x8_3DN 0  
    movq mm0, [eax] ; src  
    movq mm2, [eax+ecx]  
   
    movq mm1, [edx] ; ref1  
    movq mm3, [edx+ecx]  
    pavgusb mm1, [ebx] ; ref2  
    lea edx,[edx+2*ecx]  
    pavgusb mm3, [ebx+ecx]  
    lea ebx,[ebx+2*ecx]  
   
    movq mm4, mm0  
    lea eax,[eax+2*ecx]  
    psubusb mm0, mm1  
    movq mm5, mm2  
    psubusb mm2, mm3  
   
    psubusb mm1, mm4  
    por mm0, mm1  
    psubusb mm3, mm5  
    por mm2, mm3  
185    
186     movq mm1,mm0  ALIGN SECTION_ALIGN
    movq mm3,mm2  
   
    punpcklbw mm0,mm7  
    punpckhbw mm1,mm7  
    punpcklbw mm2,mm7  
    punpckhbw mm3,mm7  
   
    paddusw mm0,mm1  
    paddusw mm2,mm3  
    paddusw mm6,mm0  
    paddusw mm6,mm2  
 %endmacro  
   
 align 16  
187  sad8bi_3dn:  sad8bi_3dn:
188     push ebx    mov _EAX, prm1 ; Src
189     mov eax, [esp+4+ 4] ; Src    mov TMP1, prm2 ; Ref1
190     mov edx, [esp+4+ 8] ; Ref1    mov TMP0, prm4 ; Stride
191     mov ebx, [esp+4+12] ; Ref2  
192     mov ecx, [esp+4+16] ; Stride    push _EBX
193    %ifdef ARCH_IS_X86_64
194      mov _EBX, prm3
195    %else
196      mov _EBX, [_ESP+4+12] ; Ref2
197    %endif
198    
199     pxor mm6, mm6 ; accum2     pxor mm6, mm6 ; accum2
200  pxor mm7, mm7  pxor mm7, mm7
201  .Loop  .Loop:
202     SADBI_8x8_3DN     SADBI_8x8_3DN
203     SADBI_8x8_3DN     SADBI_8x8_3DN
204     SADBI_8x8_3DN     SADBI_8x8_3DN
# Line 206  Line 211 
211    
212     movd eax, mm6     movd eax, mm6
213    
214     pop ebx    pop _EBX
215    
216     ret     ret
217    ENDFUNC
218    
219    NON_EXEC_STACK

Legend:
Removed from v.430  
changed lines
  Added in v.1877

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