<div dir="ltr"><br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername"></b> <span dir="ltr"><<a href="mailto:dnyaneshwar@multicorewareinc.com">dnyaneshwar@multicorewareinc.com</a>></span><br>
Date: Wed, Oct 30, 2013 at 7:47 PM<br>Subject: [x265] [PATCH] asm: assembly code for pixel_sad_12x16<br>To: <a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br><br><br># HG changeset patch<br>
# User Dnyaneshwar Gorade <<a href="mailto:dnyaneshwar@multicorewareinc.com">dnyaneshwar@multicorewareinc.com</a>><br>
# Date 1383142575 -19800<br>
# Wed Oct 30 19:46:15 2013 +0530<br>
# Node ID 5037cc891114619e32ceeff332884d0abfd138fd<br>
# Parent 62a51fe2fcbfd76fc8476a6f714f961b3f3f23ef<br>
asm: assembly code for pixel_sad_12x16<br>
<br>
diff -r 62a51fe2fcbf -r 5037cc891114 source/common/x86/asm-primitives.cpp<br>
--- a/source/common/x86/asm-primitives.cpp Wed Oct 30 18:11:01 2013 +0530<br>
+++ b/source/common/x86/asm-primitives.cpp Wed Oct 30 19:46:15 2013 +0530<br>
@@ -253,6 +253,7 @@<br>
<br>
p.sad[LUMA_48x64] = x265_pixel_sad_48x64_sse2;<br>
p.sad[LUMA_24x32] = x265_pixel_sad_24x32_sse2;<br>
+ p.sad[LUMA_12x16] = x265_pixel_sad_12x16_sse2;<br>
<br>
ASSGN_SSE(sse2);<br>
INIT2(sad, _sse2);<br>
diff -r 62a51fe2fcbf -r 5037cc891114 source/common/x86/pixel.h<br>
--- a/source/common/x86/pixel.h Wed Oct 30 18:11:01 2013 +0530<br>
+++ b/source/common/x86/pixel.h Wed Oct 30 19:46:15 2013 +0530<br>
@@ -53,6 +53,7 @@<br>
ret x265_pixel_ ## name ## _64x64_ ## suffix args; \<br>
ret x265_pixel_ ## name ## _48x64_ ## suffix args; \<br>
ret x265_pixel_ ## name ## _24x32_ ## suffix args; \<br>
+ ret x265_pixel_ ## name ## _12x16_ ## suffix args; \<br>
<br>
#define DECL_X1(name, suffix) \<br>
DECL_PIXELS(int, name, suffix, (pixel *, intptr_t, pixel *, intptr_t))<br>
diff -r 62a51fe2fcbf -r 5037cc891114 source/common/x86/sad-a.asm<br>
--- a/source/common/x86/sad-a.asm Wed Oct 30 18:11:01 2013 +0530<br>
+++ b/source/common/x86/sad-a.asm Wed Oct 30 19:46:15 2013 +0530<br>
@@ -31,8 +31,9 @@<br>
<br>
SECTION_RODATA 32<br>
<br>
+MSK: db 255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0<br>
pb_shuf8x8c2: times 2 db 0,0,0,0,8,8,8,8,-1,-1,-1,-1,-1,-1,-1,-1<br>
-hpred_shuf: db 0,0,2,2,8,8,10,10,1,1,3,3,9,9,11,11<br>
+hpred_shuf: db 0,0,2,2,8,8,10,10,1,1,3,3,9,9,11,11<br>
<br>
SECTION .text<br>
<br>
@@ -119,6 +120,39 @@<br>
RET<br>
%endmacro<br>
<br>
+%macro PROCESS_SAD_12x4 0<br>
+ movu m1, [r2]<br>
+ movu m2, [r0]<br>
+ pand m1, m4<br>
+ pand m2, m4<br>
+ psadbw m1, m2<br>
+ paddd m0, m1<br>
+ lea r2, [r2 + r3]<br>
+ lea r0, [r0 + r1]<br>
+ movu m1, [r2]<br>
+ movu m2, [r0]<br>
+ pand m1, m4<br>
+ pand m2, m4<br>
+ psadbw m1, m2<br>
+ paddd m0, m1</div><div class="gmail_quote">>>+ lea r2, [r2 + r3]<br>>>+ lea r0, [r0 + r1]</div><div class="gmail_quote">>>+ movu m1, [r2]<br>>>+ movu m2, [r0]</div>
<div class="gmail_quote"><br></div><div class="gmail_quote"><div class="gmail_quote">we don't need to load address every time when we are adding stride to it. we should try to calculate address first using multiply by 1, 2, 4, or 8 if it not the case then we should load it.</div>
<div class="gmail_quote"> like above four instruction can be replaced with these two only.</div><div class="gmail_quote"><br></div><div class="gmail_quote">movu m1, [r2 + 2 * r3]</div>movu m2, [r0 + 2 * r1]<br></div>
<div class="gmail_quote"><br>
+ pand m1, m4<br>
+ pand m2, m4<br>
+ psadbw m1, m2<br>
+ paddd m0, m1<br>
+ lea r2, [r2 + r3]<br>
+ lea r0, [r0 + r1]<br>
+ movu m1, [r2]<br>
+ movu m2, [r0]<br>
+ pand m1, m4<br>
+ pand m2, m4<br>
+ psadbw m1, m2<br>
+ paddd m0, m1<br>
+%endmacro<br>
+<br>
%macro PROCESS_SAD_16x4 0<br>
movu m1, [r2]<br>
movu m2, [r2 + r3]<br>
@@ -1007,6 +1041,29 @@<br>
movd eax, m0<br>
RET<br>
<br>
+;-----------------------------------------------------------------------------<br>
+; int pixel_sad_12x16( uint8_t *, intptr_t, uint8_t *, intptr_t )<br>
+;-----------------------------------------------------------------------------<br>
+cglobal pixel_sad_12x16, 4,4,4<br>
+ mova m4, [MSK]<br>
+ pxor m0, m0<br>
+<br>
+ PROCESS_SAD_12x4<br>
+ lea r2, [r2 + r3]<br>
+ lea r0, [r0 + r1]<br>
+ PROCESS_SAD_12x4<br>
+ lea r2, [r2 + r3]<br>
+ lea r0, [r0 + r1]<br>
+ PROCESS_SAD_12x4<br>
+ lea r2, [r2 + r3]<br>
+ lea r0, [r0 + r1]<br>
+ PROCESS_SAD_12x4<br>
+<br>
+ movhlps m1, m0<br>
+ paddd m0, m1<br>
+ movd eax, m0<br>
+ RET<br>
+<br>
%endmacro<br><br>
</div><div class="gmail_quote">overuse of lea instruction please eliminate them, use available registers to save loads operations.</div><br></div>