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

Annotation of /branches/dev-api-4/xvidcore/src/motion/x86_asm/sad_sse2.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1199 - (view) (download)

1 : edgomez 1192 ;/****************************************************************************
2 : Isibaar 262 ; *
3 : edgomez 1192 ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * - SSE2 optimized SAD operators -
5 : Isibaar 262 ; *
6 : edgomez 1192 ; * Copyright(C) 2003 Pascal Massimino <skal@planet-d.net>
7 : Isibaar 262 ; *
8 :     ; *
9 : edgomez 1192 ; * This program is free software; you can redistribute it and/or modify it
10 :     ; * under the terms of the GNU General Public License as published by
11 :     ; * the Free Software Foundation; either version 2 of the License, or
12 :     ; * (at your option) any later version.
13 : Isibaar 262 ; *
14 : edgomez 1192 ; * This program is distributed in the hope that it will be useful,
15 :     ; * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 :     ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 :     ; * GNU General Public License for more details.
18 : Isibaar 262 ; *
19 : edgomez 1192 ; * You should have received a copy of the GNU General Public License
20 :     ; * along with this program; if not, write to the Free Software
21 :     ; * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 : Isibaar 262 ; *
23 : edgomez 1199 ; * $Id: sad_sse2.asm,v 1.8.2.3 2003-11-03 19:58:16 edgomez Exp $
24 : edgomez 652 ; *
25 : edgomez 1192 ; ***************************************************************************/
26 : Isibaar 262
27 : edgomez 1192 BITS 32
28 : Isibaar 262
29 : edgomez 1192 %macro cglobal 1
30 : Isibaar 262 %ifdef PREFIX
31 : edgomez 1192 global _%1
32 : Isibaar 262 %define %1 _%1
33 :     %else
34 :     global %1
35 :     %endif
36 :     %endmacro
37 :    
38 : edgomez 1192 ;=============================================================================
39 :     ; Read only data
40 :     ;=============================================================================
41 : Isibaar 262
42 : edgomez 1198 %ifdef FORMAT_COFF
43 :     SECTION .rodata data
44 :     %else
45 :     SECTION .rodata data align=16
46 :     %endif
47 : Isibaar 262
48 : edgomez 1192 ALIGN 64
49 : Isibaar 262 zero times 4 dd 0
50 :    
51 : edgomez 1192 ;=============================================================================
52 :     ; Code
53 :     ;=============================================================================
54 : Isibaar 262
55 : edgomez 1192 SECTION .text
56 :    
57 : Isibaar 262 cglobal sad16_sse2
58 :     cglobal dev16_sse2
59 :    
60 : edgomez 1192 ;-----------------------------------------------------------------------------
61 :     ; uint32_t sad16_sse2 (const uint8_t * const cur, <- assumed aligned!
62 :     ; const uint8_t * const ref,
63 :     ; const uint32_t stride,
64 :     ; const uint32_t /*ignored*/);
65 :     ;-----------------------------------------------------------------------------
66 : Isibaar 262
67 :    
68 : edgomez 1192 %macro SAD_16x16_SSE2 0
69 :     movdqu xmm0, [edx]
70 :     movdqu xmm1, [edx+ecx]
71 :     lea edx,[edx+2*ecx]
72 :     movdqa xmm2, [eax]
73 :     movdqa xmm3, [eax+ecx]
74 :     lea eax,[eax+2*ecx]
75 :     psadbw xmm0, xmm2
76 :     paddusw xmm6,xmm0
77 :     psadbw xmm1, xmm3
78 :     paddusw xmm6,xmm1
79 : Isibaar 262 %endmacro
80 :    
81 : edgomez 1199 ALIGN 16
82 : edgomez 1192 sad16_sse2:
83 :     mov eax, [esp+ 4] ; cur (assumed aligned)
84 :     mov edx, [esp+ 8] ; ref
85 :     mov ecx, [esp+12] ; stride
86 : Isibaar 262
87 : edgomez 1192 pxor xmm6, xmm6 ; accum
88 : Isibaar 262
89 : edgomez 1192 SAD_16x16_SSE2
90 :     SAD_16x16_SSE2
91 :     SAD_16x16_SSE2
92 :     SAD_16x16_SSE2
93 :     SAD_16x16_SSE2
94 :     SAD_16x16_SSE2
95 :     SAD_16x16_SSE2
96 :     SAD_16x16_SSE2
97 : Isibaar 262
98 : edgomez 1192 pshufd xmm5, xmm6, 00000010b
99 :     paddusw xmm6, xmm5
100 :     pextrw eax, xmm6, 0
101 :     ret
102 : Isibaar 262
103 :    
104 : edgomez 1192 ;-----------------------------------------------------------------------------
105 :     ; uint32_t dev16_sse2(const uint8_t * const cur, const uint32_t stride);
106 :     ;-----------------------------------------------------------------------------
107 : Isibaar 262
108 : edgomez 1192 %macro MEAN_16x16_SSE2 0 ; eax: src, ecx:stride, mm7: zero or mean => mm6: result
109 :     movdqu xmm0, [eax]
110 :     movdqu xmm1, [eax+ecx]
111 :     lea eax, [eax+2*ecx] ; + 2*stride
112 :     psadbw xmm0, xmm7
113 :     paddusw xmm6, xmm0
114 :     psadbw xmm1, xmm7
115 :     paddusw xmm6, xmm1
116 : Isibaar 262 %endmacro
117 :    
118 :    
119 : edgomez 1199 ALIGN 16
120 : edgomez 1192 dev16_sse2:
121 :     mov eax, [esp+ 4] ; src
122 :     mov ecx, [esp+ 8] ; stride
123 : Isibaar 262
124 : edgomez 1192 pxor xmm6, xmm6 ; accum
125 :     pxor xmm7, xmm7 ; zero
126 : Isibaar 262
127 : edgomez 1192 MEAN_16x16_SSE2
128 :     MEAN_16x16_SSE2
129 :     MEAN_16x16_SSE2
130 :     MEAN_16x16_SSE2
131 : Isibaar 262
132 : edgomez 1192 MEAN_16x16_SSE2
133 :     MEAN_16x16_SSE2
134 :     MEAN_16x16_SSE2
135 :     MEAN_16x16_SSE2
136 : Isibaar 262
137 : edgomez 1192 mov eax, [esp+ 4] ; src again
138 : Isibaar 262
139 : edgomez 1199 pshufd xmm7, xmm6, 10b
140 : edgomez 1192 paddusw xmm7, xmm6
141 :     pxor xmm6, xmm6 ; zero accum
142 :     psrlw xmm7, 8 ; => Mean
143 :     pshuflw xmm7, xmm7, 0 ; replicate Mean
144 : edgomez 1199 packuswb xmm7, xmm7
145 :     pshufd xmm7, xmm7, 00000000b
146 : Isibaar 262
147 : edgomez 1192 MEAN_16x16_SSE2
148 :     MEAN_16x16_SSE2
149 :     MEAN_16x16_SSE2
150 :     MEAN_16x16_SSE2
151 : Isibaar 262
152 : edgomez 1192 MEAN_16x16_SSE2
153 :     MEAN_16x16_SSE2
154 :     MEAN_16x16_SSE2
155 :     MEAN_16x16_SSE2
156 : Isibaar 262
157 : edgomez 1199 pshufd xmm7, xmm6, 10b
158 :     paddusw xmm7, xmm6
159 :     pextrw eax, xmm7, 0
160 : edgomez 1192 ret

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