3 |
; * XVID MPEG-4 VIDEO CODEC |
; * XVID MPEG-4 VIDEO CODEC |
4 |
; * xmm sum of absolute difference |
; * xmm sum of absolute difference |
5 |
; * |
; * |
6 |
|
; * This program is an implementation of a part of one or more MPEG-4 |
7 |
|
; * Video tools as specified in ISO/IEC 14496-2 standard. Those intending |
8 |
|
; * to use this software module in hardware or software products are |
9 |
|
; * advised that its use may infringe existing patents or copyrights, and |
10 |
|
; * any such use would be at such party's own risk. The original |
11 |
|
; * developer of this software module and his/her company, and subsequent |
12 |
|
; * editors and their companies, will have no liability for use of this |
13 |
|
; * software or modifications or derivatives thereof. |
14 |
|
; * |
15 |
; * This program is free software; you can redistribute it and/or modify |
; * This program is free software; you can redistribute it and/or modify |
16 |
; * 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 |
17 |
; * the Free Software Foundation; either version 2 of the License, or |
; * the Free Software Foundation; either version 2 of the License, or |
41 |
; *************************************************************************/ |
; *************************************************************************/ |
42 |
|
|
43 |
bits 32 |
bits 32 |
44 |
|
|
45 |
%macro cglobal 1 |
%macro cglobal 1 |
46 |
%ifdef PREFIX |
%ifdef PREFIX |
47 |
global _%1 |
global _%1 |
68 |
; |
; |
69 |
; uint32_t sad16_xmm(const uint8_t * const cur, |
; uint32_t sad16_xmm(const uint8_t * const cur, |
70 |
; const uint8_t * const ref, |
; const uint8_t * const ref, |
71 |
|
; const uint32_t stride, |
72 |
; const uint32_t best_sad); |
; const uint32_t best_sad); |
73 |
cglobal sad8_xmm |
; |
74 |
;=========================================================================== |
;=========================================================================== |
75 |
|
|
76 |
%macro SAD_16x16_SSE 0 |
%macro SAD_16x16_SSE 0 |
125 |
; |
; |
126 |
;=========================================================================== |
;=========================================================================== |
127 |
|
|
128 |
|
%macro SAD_8x8_SSE 0 |
129 |
|
movq mm0, [eax] |
130 |
|
movq mm1, [eax+ecx] |
131 |
|
|
132 |
|
psadbw mm0, [edx] |
133 |
|
psadbw mm1, [edx+ecx] |
134 |
|
add eax, ebx |
135 |
|
add edx, ebx |
136 |
|
|
137 |
|
paddusw mm5,mm0 |
138 |
|
paddusw mm6,mm1 |
139 |
|
%endmacro |
140 |
|
|
141 |
|
align 16 |
142 |
|
sad8_xmm: |
143 |
|
|
144 |
|
mov eax, [esp+ 4] ; Src1 |
145 |
|
mov edx, [esp+ 8] ; Src2 |
146 |
|
mov ecx, [esp+12] ; Stride |
147 |
|
push ebx |
148 |
|
lea ebx, [ecx+ecx] |
149 |
|
|
150 |
|
pxor mm5, mm5 ; accum1 |
151 |
|
pxor mm6, mm6 ; accum2 |
152 |
|
|
153 |
|
SAD_8x8_SSE |
154 |
|
SAD_8x8_SSE |
155 |
|
SAD_8x8_SSE |
156 |
|
|
157 |
|
movq mm0, [eax] |
158 |
|
movq mm1, [eax+ecx] |
159 |
|
psadbw mm0, [edx] |
160 |
|
psadbw mm1, [edx+ecx] |
161 |
|
|
162 |
|
pop ebx |
163 |
|
|
164 |
|
paddusw mm5,mm0 |
165 |
|
paddusw mm6,mm1 |
166 |
|
|
167 |
|
paddusw mm6,mm5 |
168 |
|
movd eax, mm6 |
169 |
|
|
170 |
|
ret |
171 |
|
|
172 |
|
|
173 |
|
;=========================================================================== |
174 |
|
; |
175 |
|
; uint32_t sad16bi_xmm(const uint8_t * const cur, |
176 |
|
; const uint8_t * const ref1, |
177 |
|
; const uint8_t * const ref2, |
178 |
|
; const uint32_t stride); |
179 |
|
; |
180 |
|
;=========================================================================== |
181 |
|
|
182 |
%macro SADBI_16x16_SSE 0 |
%macro SADBI_16x16_SSE 0 |
183 |
movq mm0, [eax] |
movq mm0, [eax] |
184 |
movq mm1, [eax+8] |
movq mm1, [eax+8] |
244 |
; |
; |
245 |
;=========================================================================== |
;=========================================================================== |
246 |
|
|
247 |
;=========================================================================== |
%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 |
|
248 |
movq mm0, [eax] |
movq mm0, [eax] |
249 |
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 |
|
250 |
|
|
251 |
|
movq mm2, [edx] |
252 |
|
movq mm3, [edx+ecx] |
253 |
|
|
254 |
|
pavgb mm2, [ebx] |
255 |
|
lea edx, [edx+2*ecx] |
256 |
|
|
257 |
|
pavgb mm3, [ebx+ecx] |
258 |
|
lea ebx, [ebx+2*ecx] |
259 |
|
|
260 |
|
psadbw mm0, mm2 |
261 |
|
lea eax, [eax+2*ecx] |
262 |
|
|
263 |
|
psadbw mm1, mm3 |
264 |
paddusw mm5,mm0 |
paddusw mm5,mm0 |
265 |
|
|
266 |
paddusw mm6,mm1 |
paddusw mm6,mm1 |
267 |
%endmacro |
%endmacro |
268 |
|
|
269 |
align 16 |
align 16 |
270 |
sad8_xmm: |
sad8bi_xmm: |
|
|
|
|
mov eax, [esp+ 4] ; Src1 |
|
|
mov edx, [esp+ 8] ; Src2 |
|
|
mov ecx, [esp+12] ; Stride |
|
271 |
push ebx |
push ebx |
272 |
lea ebx, [ecx+ecx] |
mov eax, [esp+4+ 4] ; Src |
273 |
|
mov edx, [esp+4+ 8] ; Ref1 |
274 |
|
mov ebx, [esp+4+12] ; Ref2 |
275 |
|
mov ecx, [esp+4+16] ; Stride |
276 |
|
|
277 |
pxor mm5, mm5 ; accum1 |
pxor mm5, mm5 ; accum1 |
278 |
pxor mm6, mm6 ; accum2 |
pxor mm6, mm6 ; accum2 |
279 |
|
.Loop |
280 |
|
SADBI_8x8_XMM |
281 |
|
SADBI_8x8_XMM |
282 |
|
SADBI_8x8_XMM |
283 |
|
SADBI_8x8_XMM |
284 |
|
|
285 |
SAD_8x8_SSE |
paddusw mm6,mm5 |
286 |
SAD_8x8_SSE |
movd eax, mm6 |
|
SAD_8x8_SSE |
|
|
|
|
|
movq mm0, [eax] |
|
|
movq mm1, [eax+ecx] |
|
|
psadbw mm0, [edx] |
|
|
psadbw mm1, [edx+ecx] |
|
|
|
|
287 |
pop ebx |
pop ebx |
288 |
|
ret |
289 |
|
|
|
paddusw mm5,mm0 |
|
|
paddusw mm6,mm1 |
|
290 |
|
|
291 |
paddusw mm6,mm5 |
;=========================================================================== |
292 |
movd eax, mm6 |
; |
293 |
|
; uint32_t dev16_xmm(const uint8_t * const cur, |
294 |
|
; const uint32_t stride); |
295 |
|
; |
296 |
|
;=========================================================================== |
297 |
|
|
298 |
ret |
%macro MEAN_16x16_SSE 0 |
299 |
movq mm0, [eax] |
movq mm0, [eax] |
300 |
movq mm1, [eax+8] |
movq mm1, [eax+8] |
301 |
psadbw mm0, mm7 |
psadbw mm0, mm7 |
357 |
|
|
358 |
mov eax, [esp+ 4] ; Src |
mov eax, [esp+ 4] ; Src |
359 |
|
|
360 |
|
|
361 |
pxor mm5, mm5 ; sums |
pxor mm5, mm5 ; sums |
362 |
pxor mm6, mm6 |
pxor mm6, mm6 |
363 |
|
|
386 |
|
|
387 |
movd eax, mm6 |
movd eax, mm6 |
388 |
ret |
ret |
389 |
|
|
390 |
|
cglobal sad16v_xmm |
391 |
|
|
392 |
|
;=========================================================================== |
393 |
|
;int sad16v_xmm(const uint8_t * const cur, |
394 |
|
; const uint8_t * const ref, |
395 |
|
; const uint32_t stride, |
396 |
|
; int* sad8); |
397 |
|
;=========================================================================== |
398 |
|
align 16 |
399 |
|
sad16v_xmm: |
400 |
|
push ebx |
401 |
|
mov eax, [esp+4+ 4] ; Src1 |
402 |
|
mov edx, [esp+4+ 8] ; Src2 |
403 |
|
mov ecx, [esp+4+12] ; Stride |
404 |
|
mov ebx, [esp+4+16] ; sad ptr |
405 |
|
|
406 |
|
pxor mm5, mm5 ; accum1 |
407 |
|
pxor mm6, mm6 ; accum2 |
408 |
|
pxor mm7, mm7 ; total |
409 |
|
SAD_16x16_SSE |
410 |
|
SAD_16x16_SSE |
411 |
|
SAD_16x16_SSE |
412 |
|
SAD_16x16_SSE |
413 |
|
SAD_16x16_SSE |
414 |
|
SAD_16x16_SSE |
415 |
|
SAD_16x16_SSE |
416 |
|
SAD_16x16_SSE |
417 |
|
paddusw mm7, mm5 |
418 |
|
paddusw mm7, mm6 |
419 |
|
movd [ebx], mm5 |
420 |
|
movd [ebx+4], mm6 |
421 |
|
|
422 |
|
pxor mm5, mm5 ; accum1 |
423 |
|
pxor mm6, mm6 ; accum2 |
424 |
|
SAD_16x16_SSE |
425 |
|
SAD_16x16_SSE |
426 |
|
SAD_16x16_SSE |
427 |
|
SAD_16x16_SSE |
428 |
|
SAD_16x16_SSE |
429 |
|
SAD_16x16_SSE |
430 |
|
SAD_16x16_SSE |
431 |
|
SAD_16x16_SSE |
432 |
|
paddusw mm7, mm5 |
433 |
|
paddusw mm7, mm6 |
434 |
|
movd [ebx+8], mm5 |
435 |
|
movd [ebx+12], mm6 |
436 |
|
|
437 |
|
movd eax, mm7 |
438 |
|
pop ebx |
439 |
|
ret |
440 |
|
;-------- |
441 |
|
|
442 |
|
|