; where NxN = 64x64, 32x32, 16x16, 16x8, 8x16 or 8x8
%macro HIGH_SADNXN4D 2
%if UNIX64
-cglobal highbd_sad%1x%2x4d, 5, 9, 8, src, src_stride, ref1, ref_stride, \
- res, ref2, ref3, ref4, one
+cglobal highbd_sad%1x%2x4d, 5, 8, 8, src, src_stride, ref1, ref_stride, \
+ res, ref2, ref3, ref4
%else
-cglobal highbd_sad%1x%2x4d, 4, 8, 8, src, src_stride, ref1, ref_stride, \
- ref2, ref3, ref4, one
+cglobal highbd_sad%1x%2x4d, 4, 7, 8, src, src_stride, ref1, ref_stride, \
+ ref2, ref3, ref4
%endif
+; set m1
+ push srcq
+ mov srcd, 0x00010001
+ movd m1, srcd
+ pshufd m1, m1, 0x0
+ pop srcq
+
movsxdifnidn src_strideq, src_strided
movsxdifnidn ref_strideq, ref_strided
mov ref2q, [ref1q+gprsize*1]
shl ref4q, 1
shl ref1q, 1
- mov oned, 0x00010001
- movd m1, oned
- pshufd m1, m1, 0x0
-
HIGH_PROCESS_%1x2x4 1, 0, 0, src_strideq, ref_strideq, 1
%rep (%2-4)/2
HIGH_PROCESS_%1x2x4 0, 0, 0, src_strideq, ref_strideq, 1
%if %1 < 16
sar h, 1
%endif
+%if %2 == 1 ; avg
+ shl sec_str, 1
+%endif
; FIXME(rbultje) replace by jumptable?
test x_offsetd, x_offsetd
lea srcq, [srcq + src_strideq*2]
lea dstq, [dstq + dst_strideq*2]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*2]
+ add secq, sec_str
%endif
%else ; %1 < 16
movu m0, [srcq]
mova m3, [dstq + dst_strideq*2]
%if %2 == 1 ; avg
pavgw m0, [secq]
- pavgw m2, [secq + sec_str*2]
+ add secq, sec_str
+ pavgw m2, [secq]
%endif
SUM_SSE m0, m1, m2, m3, m6, m7
lea srcq, [srcq + src_strideq*4]
lea dstq, [dstq + dst_strideq*4]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*4]
+ add secq, sec_str
%endif
%endif
dec h
lea srcq, [srcq + src_strideq*2]
lea dstq, [dstq + dst_strideq*2]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*2]
+ add secq, sec_str
%endif
%else ; %1 < 16
movu m0, [srcq]
pavgw m1, m5
%if %2 == 1 ; avg
pavgw m0, [secq]
- pavgw m1, [secq+sec_str*2]
+ add secq, sec_str
+ pavgw m1, [secq]
%endif
SUM_SSE m0, m2, m1, m3, m6, m7
lea srcq, [srcq + src_strideq*4]
lea dstq, [dstq + dst_strideq*4]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*4]
+ add secq, sec_str
%endif
%endif
dec h
lea srcq, [srcq + src_strideq*2]
lea dstq, [dstq + dst_strideq*2]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*2]
+ add secq, sec_str
%endif
%else ; %1 < 16
movu m0, [srcq]
psrlw m0, 4
%if %2 == 1 ; avg
pavgw m0, [secq]
- pavgw m1, [secq+sec_str*2]
+ add secq, sec_str
+ pavgw m1, [secq]
%endif
SUM_SSE m0, m2, m1, m3, m6, m7
lea srcq, [srcq + src_strideq*4]
lea dstq, [dstq + dst_strideq*4]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*4]
+ add secq, sec_str
%endif
%endif
dec h
lea srcq, [srcq + src_strideq*2]
lea dstq, [dstq + dst_strideq*2]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*2]
+ add secq, sec_str
%endif
%else ; %1 < 16
movu m0, [srcq]
pavgw m1, m5
%if %2 == 1 ; avg
pavgw m0, [secq]
- pavgw m1, [secq+sec_str*2]
+ add secq, sec_str
+ pavgw m1, [secq]
%endif
SUM_SSE m0, m2, m1, m3, m6, m7
lea srcq, [srcq + src_strideq*4]
lea dstq, [dstq + dst_strideq*4]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*4]
+ add secq, sec_str
%endif
%endif
dec h
lea srcq, [srcq + src_strideq*2]
lea dstq, [dstq + dst_strideq*2]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*2]
+ add secq, sec_str
%endif
%else ; %1 < 16
movu m0, [srcq]
mova m5, [dstq + dst_strideq*2]
%if %2 == 1 ; avg
pavgw m0, [secq]
- pavgw m2, [secq+sec_str*2]
+ add secq, sec_str
+ pavgw m2, [secq]
%endif
SUM_SSE m0, m4, m2, m5, m6, m7
mova m0, m3
lea srcq, [srcq + src_strideq*4]
lea dstq, [dstq + dst_strideq*4]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*4]
+ add secq, sec_str
%endif
%endif
dec h
lea srcq, [srcq + src_strideq*2]
lea dstq, [dstq + dst_strideq*2]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*2]
+ add secq, sec_str
%endif
%else ; %1 < 16
movu m0, [srcq]
mova m3, [dstq+dst_strideq*2]
%if %2 == 1 ; avg
pavgw m0, [secq]
- pavgw m4, [secq+sec_str*2]
+ add secq, sec_str
+ pavgw m4, [secq]
%endif
SUM_SSE m0, m2, m4, m3, m6, m7
mova m0, m5
lea srcq, [srcq + src_strideq*4]
lea dstq, [dstq + dst_strideq*4]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*4]
+ add secq, sec_str
%endif
%endif
dec h
lea srcq, [srcq+src_strideq*2]
lea dstq, [dstq+dst_strideq*2]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*2]
+ add secq, sec_str
%endif
%else ; %1 < 16
movu m0, [srcq]
psrlw m0, 4
%if %2 == 1 ; avg
pavgw m0, [secq]
- pavgw m1, [secq+sec_str*2]
+ add secq, sec_str
+ pavgw m1, [secq]
%endif
SUM_SSE m0, m4, m1, m5, m6, m7
lea srcq, [srcq+src_strideq*4]
lea dstq, [dstq+dst_strideq*4]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*4]
+ add secq, sec_str
%endif
%endif
dec h
lea srcq, [srcq+src_strideq*2]
lea dstq, [dstq+dst_strideq*2]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*2]
+ add secq, sec_str
%endif
%else ; %1 < 16
movu m0, [srcq]
pavgw m2, m3
%if %2 == 1 ; avg
pavgw m0, [secq]
- pavgw m2, [secq+sec_str*2]
+ add secq, sec_str
+ pavgw m2, [secq]
%endif
SUM_SSE m0, m4, m2, m5, m6, m7
mova m0, m3
lea srcq, [srcq+src_strideq*4]
lea dstq, [dstq+dst_strideq*4]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*4]
+ add secq, sec_str
%endif
%endif
dec h
INC_SRC_BY_SRC_STRIDE
lea dstq, [dstq + dst_strideq * 2]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*2]
+ add secq, sec_str
%endif
%else ; %1 < 16
movu m0, [srcq]
mova m3, [dstq+dst_strideq*2]
%if %2 == 1 ; avg
pavgw m0, [secq]
- pavgw m4, [secq+sec_str*2]
+ add secq, sec_str
+ pavgw m4, [secq]
%endif
SUM_SSE m0, m2, m4, m3, m6, m7
mova m0, m5
INC_SRC_BY_SRC_2STRIDE
lea dstq, [dstq + dst_strideq * 4]
%if %2 == 1 ; avg
- lea secq, [secq + sec_str*4]
+ add secq, sec_str
%endif
%endif
dec h