[svn] / branches / release-1_2-branch / xvidcore / src / motion / x86_asm / sad_sse2.asm Repository:
ViewVC logotype

Annotation of /branches/release-1_2-branch/xvidcore/src/motion/x86_asm/sad_sse2.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1877 - (view) (download)

1 : edgomez 1382 ;/****************************************************************************
2 : Isibaar 262 ; *
3 : edgomez 1382 ; * XVID MPEG-4 VIDEO CODEC
4 :     ; * - SSE2 optimized SAD operators -
5 : Isibaar 262 ; *
6 : edgomez 1382 ; * Copyright(C) 2003 Pascal Massimino <skal@planet-d.net>
7 : Isibaar 262 ; *
8 :     ; *
9 : edgomez 1382 ; * 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 1382 ; * 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 1382 ; * 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 : Isibaar 1877 ; * $Id: sad_sse2.asm,v 1.16.2.3 2009-09-16 17:11:39 Isibaar Exp $
24 : edgomez 652 ; *
25 : edgomez 1382 ; ***************************************************************************/
26 : Isibaar 262
27 : Isibaar 1795 %include "nasm.inc"
28 : Isibaar 262
29 : edgomez 1382 ;=============================================================================
30 :     ; Read only data
31 :     ;=============================================================================
32 : Isibaar 262
33 : Isibaar 1795 DATA
34 : Isibaar 262
35 : Isibaar 1795 ALIGN SECTION_ALIGN
36 : Isibaar 262 zero times 4 dd 0
37 :    
38 : edgomez 1382 ;=============================================================================
39 :     ; Code
40 :     ;=============================================================================
41 : Isibaar 262
42 : Isibaar 1865 TEXT
43 : edgomez 1382
44 : Isibaar 262 cglobal sad16_sse2
45 :     cglobal dev16_sse2
46 :    
47 : Isibaar 1764 cglobal sad16_sse3
48 :     cglobal dev16_sse3
49 :    
50 : edgomez 1382 ;-----------------------------------------------------------------------------
51 :     ; uint32_t sad16_sse2 (const uint8_t * const cur, <- assumed aligned!
52 :     ; const uint8_t * const ref,
53 :     ; const uint32_t stride,
54 :     ; const uint32_t /*ignored*/);
55 :     ;-----------------------------------------------------------------------------
56 : Isibaar 262
57 :    
58 : Isibaar 1764 %macro SAD_16x16_SSE2 1
59 : Isibaar 1795 %1 xmm0, [TMP1]
60 :     %1 xmm1, [TMP1+TMP0]
61 :     lea TMP1,[TMP1+2*TMP0]
62 :     movdqa xmm2, [_EAX]
63 :     movdqa xmm3, [_EAX+TMP0]
64 :     lea _EAX,[_EAX+2*TMP0]
65 : edgomez 1382 psadbw xmm0, xmm2
66 :     paddusw xmm6,xmm0
67 :     psadbw xmm1, xmm3
68 :     paddusw xmm6,xmm1
69 : Isibaar 262 %endmacro
70 :    
71 : Isibaar 1764 %macro SAD16_SSE2_SSE3 1
72 : Isibaar 1838 PUSH_XMM6_XMM7
73 : Isibaar 1795 mov _EAX, prm1 ; cur (assumed aligned)
74 :     mov TMP1, prm2 ; ref
75 :     mov TMP0, prm3 ; stride
76 : Isibaar 262
77 : edgomez 1382 pxor xmm6, xmm6 ; accum
78 : Isibaar 262
79 : Isibaar 1764 SAD_16x16_SSE2 %1
80 :     SAD_16x16_SSE2 %1
81 :     SAD_16x16_SSE2 %1
82 :     SAD_16x16_SSE2 %1
83 :     SAD_16x16_SSE2 %1
84 :     SAD_16x16_SSE2 %1
85 :     SAD_16x16_SSE2 %1
86 :     SAD_16x16_SSE2 %1
87 : Isibaar 262
88 : edgomez 1382 pshufd xmm5, xmm6, 00000010b
89 :     paddusw xmm6, xmm5
90 :     pextrw eax, xmm6, 0
91 : Isibaar 1838
92 :     POP_XMM6_XMM7
93 : edgomez 1382 ret
94 : Isibaar 1764 %endmacro
95 :    
96 : Isibaar 1795 ALIGN SECTION_ALIGN
97 : Isibaar 1764 sad16_sse2:
98 :     SAD16_SSE2_SSE3 movdqu
99 : Isibaar 1793 ENDFUNC
100 : Isibaar 262
101 :    
102 : Isibaar 1795 ALIGN SECTION_ALIGN
103 : Isibaar 1764 sad16_sse3:
104 :     SAD16_SSE2_SSE3 lddqu
105 : Isibaar 1793 ENDFUNC
106 : Isibaar 1764
107 :    
108 : edgomez 1382 ;-----------------------------------------------------------------------------
109 :     ; uint32_t dev16_sse2(const uint8_t * const cur, const uint32_t stride);
110 :     ;-----------------------------------------------------------------------------
111 : Isibaar 262
112 : Isibaar 1795 %macro MEAN_16x16_SSE2 1 ; _EAX: src, TMP0:stride, mm7: zero or mean => mm6: result
113 :     %1 xmm0, [_EAX]
114 :     %1 xmm1, [_EAX+TMP0]
115 :     lea _EAX, [_EAX+2*TMP0] ; + 2*stride
116 : edgomez 1382 psadbw xmm0, xmm7
117 :     paddusw xmm6, xmm0
118 :     psadbw xmm1, xmm7
119 :     paddusw xmm6, xmm1
120 : Isibaar 262 %endmacro
121 :    
122 :    
123 : Isibaar 1764 %macro MEAN16_SSE2_SSE3 1
124 : Isibaar 1838 PUSH_XMM6_XMM7
125 : Isibaar 1795 mov _EAX, prm1 ; src
126 :     mov TMP0, prm2 ; stride
127 : Isibaar 262
128 : edgomez 1382 pxor xmm6, xmm6 ; accum
129 :     pxor xmm7, xmm7 ; zero
130 : Isibaar 262
131 : Isibaar 1764 MEAN_16x16_SSE2 %1
132 :     MEAN_16x16_SSE2 %1
133 :     MEAN_16x16_SSE2 %1
134 :     MEAN_16x16_SSE2 %1
135 : Isibaar 262
136 : Isibaar 1764 MEAN_16x16_SSE2 %1
137 :     MEAN_16x16_SSE2 %1
138 :     MEAN_16x16_SSE2 %1
139 :     MEAN_16x16_SSE2 %1
140 : Isibaar 262
141 : Isibaar 1795 mov _EAX, prm1 ; src again
142 : Isibaar 262
143 : edgomez 1382 pshufd xmm7, xmm6, 10b
144 :     paddusw xmm7, xmm6
145 :     pxor xmm6, xmm6 ; zero accum
146 :     psrlw xmm7, 8 ; => Mean
147 :     pshuflw xmm7, xmm7, 0 ; replicate Mean
148 :     packuswb xmm7, xmm7
149 :     pshufd xmm7, xmm7, 00000000b
150 : Isibaar 262
151 : Isibaar 1764 MEAN_16x16_SSE2 %1
152 :     MEAN_16x16_SSE2 %1
153 :     MEAN_16x16_SSE2 %1
154 :     MEAN_16x16_SSE2 %1
155 : Isibaar 262
156 : Isibaar 1764 MEAN_16x16_SSE2 %1
157 :     MEAN_16x16_SSE2 %1
158 :     MEAN_16x16_SSE2 %1
159 :     MEAN_16x16_SSE2 %1
160 : Isibaar 262
161 : edgomez 1382 pshufd xmm7, xmm6, 10b
162 :     paddusw xmm7, xmm6
163 :     pextrw eax, xmm7, 0
164 : Isibaar 1838
165 :     POP_XMM6_XMM7
166 : edgomez 1382 ret
167 : Isibaar 1764 %endmacro
168 :    
169 : Isibaar 1795 ALIGN SECTION_ALIGN
170 : Isibaar 1764 dev16_sse2:
171 :     MEAN16_SSE2_SSE3 movdqu
172 : Isibaar 1793 ENDFUNC
173 : edgomez 1540
174 : Isibaar 1795 ALIGN SECTION_ALIGN
175 : Isibaar 1764 dev16_sse3:
176 :     MEAN16_SSE2_SSE3 lddqu
177 : Isibaar 1793 ENDFUNC
178 : Isibaar 1790
179 : Isibaar 1877 NON_EXEC_STACK

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