32 |
; *************************************************************************/ |
; *************************************************************************/ |
33 |
|
|
34 |
bits 32 |
bits 32 |
35 |
|
|
36 |
%macro cglobal 1 |
%macro cglobal 1 |
37 |
%ifdef PREFIX |
%ifdef PREFIX |
38 |
global _%1 |
global _%1 |
59 |
; |
; |
60 |
; uint32_t sad16_xmm(const uint8_t * const cur, |
; uint32_t sad16_xmm(const uint8_t * const cur, |
61 |
; const uint8_t * const ref, |
; const uint8_t * const ref, |
62 |
|
; const uint32_t stride, |
63 |
; const uint32_t best_sad); |
; const uint32_t best_sad); |
64 |
cglobal sad8_xmm |
; |
65 |
;=========================================================================== |
;=========================================================================== |
66 |
|
|
67 |
%macro SAD_16x16_SSE 0 |
%macro SAD_16x16_SSE 0 |
116 |
; |
; |
117 |
;=========================================================================== |
;=========================================================================== |
118 |
|
|
119 |
|
%macro SAD_8x8_SSE 0 |
120 |
|
movq mm0, [eax] |
121 |
|
movq mm1, [eax+ecx] |
122 |
|
|
123 |
|
psadbw mm0, [edx] |
124 |
|
psadbw mm1, [edx+ecx] |
125 |
|
add eax, ebx |
126 |
|
add edx, ebx |
127 |
|
|
128 |
|
paddusw mm5,mm0 |
129 |
|
paddusw mm6,mm1 |
130 |
|
%endmacro |
131 |
|
|
132 |
|
align 16 |
133 |
|
sad8_xmm: |
134 |
|
|
135 |
|
mov eax, [esp+ 4] ; Src1 |
136 |
|
mov edx, [esp+ 8] ; Src2 |
137 |
|
mov ecx, [esp+12] ; Stride |
138 |
|
push ebx |
139 |
|
lea ebx, [ecx+ecx] |
140 |
|
|
141 |
|
pxor mm5, mm5 ; accum1 |
142 |
|
pxor mm6, mm6 ; accum2 |
143 |
|
|
144 |
|
SAD_8x8_SSE |
145 |
|
SAD_8x8_SSE |
146 |
|
SAD_8x8_SSE |
147 |
|
|
148 |
|
movq mm0, [eax] |
149 |
|
movq mm1, [eax+ecx] |
150 |
|
psadbw mm0, [edx] |
151 |
|
psadbw mm1, [edx+ecx] |
152 |
|
|
153 |
|
pop ebx |
154 |
|
|
155 |
|
paddusw mm5,mm0 |
156 |
|
paddusw mm6,mm1 |
157 |
|
|
158 |
|
paddusw mm6,mm5 |
159 |
|
movd eax, mm6 |
160 |
|
|
161 |
|
ret |
162 |
|
|
163 |
|
|
164 |
|
;=========================================================================== |
165 |
|
; |
166 |
|
; uint32_t sad16bi_xmm(const uint8_t * const cur, |
167 |
|
; const uint8_t * const ref1, |
168 |
|
; const uint8_t * const ref2, |
169 |
|
; const uint32_t stride); |
170 |
|
; |
171 |
|
;=========================================================================== |
172 |
|
|
173 |
%macro SADBI_16x16_SSE 0 |
%macro SADBI_16x16_SSE 0 |
174 |
movq mm0, [eax] |
movq mm0, [eax] |
175 |
movq mm1, [eax+8] |
movq mm1, [eax+8] |
235 |
; |
; |
236 |
;=========================================================================== |
;=========================================================================== |
237 |
|
|
238 |
;=========================================================================== |
%macro SADBI_8x8_XMM 0 |
|
; |
|
|
; uint32_t sad8_xmm(const uint8_t * const cur, |
|
|
; const uint8_t * const ref, |
|
|
; const uint32_t stride); |
|
|
; |
|
|
;=========================================================================== |
|
|
|
|
|
%macro SAD_8x8_SSE 0 |
|
239 |
movq mm0, [eax] |
movq mm0, [eax] |
240 |
movq mm1, [eax+ecx] |
movq mm1, [eax+ecx] |
|
%macro MEAN_16x16_SSE 0 |
|
|
psadbw mm0, [edx] |
|
|
psadbw mm1, [edx+ecx] |
|
|
add eax, ebx |
|
|
add edx, ebx |
|
241 |
|
|
242 |
|
movq mm2, [edx] |
243 |
|
movq mm3, [edx+ecx] |
244 |
|
|
245 |
|
pavgb mm2, [ebx] |
246 |
|
lea edx, [edx+2*ecx] |
247 |
|
|
248 |
|
pavgb mm3, [ebx+ecx] |
249 |
|
lea ebx, [ebx+2*ecx] |
250 |
|
|
251 |
|
psadbw mm0, mm2 |
252 |
|
lea eax, [eax+2*ecx] |
253 |
|
|
254 |
|
psadbw mm1, mm3 |
255 |
paddusw mm5,mm0 |
paddusw mm5,mm0 |
256 |
|
|
257 |
paddusw mm6,mm1 |
paddusw mm6,mm1 |
258 |
%endmacro |
%endmacro |
259 |
|
|
260 |
align 16 |
align 16 |
261 |
sad8_xmm: |
sad8bi_xmm: |
|
|
|
|
mov eax, [esp+ 4] ; Src1 |
|
|
mov edx, [esp+ 8] ; Src2 |
|
|
mov ecx, [esp+12] ; Stride |
|
262 |
push ebx |
push ebx |
263 |
lea ebx, [ecx+ecx] |
mov eax, [esp+4+ 4] ; Src |
264 |
|
mov edx, [esp+4+ 8] ; Ref1 |
265 |
|
mov ebx, [esp+4+12] ; Ref2 |
266 |
|
mov ecx, [esp+4+16] ; Stride |
267 |
|
|
268 |
pxor mm5, mm5 ; accum1 |
pxor mm5, mm5 ; accum1 |
269 |
pxor mm6, mm6 ; accum2 |
pxor mm6, mm6 ; accum2 |
270 |
|
.Loop |
271 |
|
SADBI_8x8_XMM |
272 |
|
SADBI_8x8_XMM |
273 |
|
SADBI_8x8_XMM |
274 |
|
SADBI_8x8_XMM |
275 |
|
|
276 |
SAD_8x8_SSE |
paddusw mm6,mm5 |
277 |
SAD_8x8_SSE |
movd eax, mm6 |
|
SAD_8x8_SSE |
|
|
|
|
|
movq mm0, [eax] |
|
|
movq mm1, [eax+ecx] |
|
|
psadbw mm0, [edx] |
|
|
psadbw mm1, [edx+ecx] |
|
|
|
|
278 |
pop ebx |
pop ebx |
279 |
|
ret |
280 |
|
|
|
paddusw mm5,mm0 |
|
|
paddusw mm6,mm1 |
|
281 |
|
|
282 |
paddusw mm6,mm5 |
;=========================================================================== |
283 |
movd eax, mm6 |
; |
284 |
|
; uint32_t dev16_xmm(const uint8_t * const cur, |
285 |
|
; const uint32_t stride); |
286 |
|
; |
287 |
|
;=========================================================================== |
288 |
|
|
289 |
ret |
%macro MEAN_16x16_SSE 0 |
290 |
movq mm0, [eax] |
movq mm0, [eax] |
291 |
movq mm1, [eax+8] |
movq mm1, [eax+8] |
292 |
psadbw mm0, mm7 |
psadbw mm0, mm7 |