<div dir="ltr"><br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername"></b> <span dir="ltr"><<a href="mailto:yuvaraj@multicorewareinc.com" target="_blank">yuvaraj@multicorewareinc.com</a>></span><br>
Date: Wed, Oct 30, 2013 at 2:38 PM<br>Subject: [x265] [PATCH] assembly code for pixel_sad_x3_24x32<br>To: <a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br><br><br># HG changeset patch<br>
# User Yuvaraj Venkatesh <<a href="mailto:yuvaraj@multicorewareinc.com" target="_blank">yuvaraj@multicorewareinc.com</a>><br>
# Date 1383124045 -19800<br>
# Wed Oct 30 14:37:25 2013 +0530<br>
# Node ID eca1142d1cec9303afad71108494f9076586ce05<br>
# Parent 65462024832b4498cd9f05a5a81cb6b559bf378b<br>
assembly code for pixel_sad_x3_24x32<br>
<br>
diff -r 65462024832b -r eca1142d1cec source/common/x86/asm-primitives.cpp<br>
--- a/source/common/x86/asm-primitives.cpp Wed Oct 30 01:54:16 2013 -0500<br>
+++ b/source/common/x86/asm-primitives.cpp Wed Oct 30 14:37:25 2013 +0530<br>
@@ -292,6 +292,7 @@<br>
p.sad_x4[LUMA_16x32] = x265_pixel_sad_x4_16x32_ssse3;<br>
p.sad_x3[LUMA_16x64] = x265_pixel_sad_x3_16x64_ssse3;<br>
p.sad_x4[LUMA_16x64] = x265_pixel_sad_x4_16x64_ssse3;<br>
+ p.sad_x3[LUMA_24x32] = x265_pixel_sad_x3_24x32_ssse3;<br>
<br>
p.luma_hvpp[LUMA_8x8] = x265_interp_8tap_hv_pp_8x8_ssse3;<br>
p.ipfilter_sp[FILTER_V_S_P_8] = x265_interp_8tap_v_sp_ssse3;<br>
@@ -325,6 +326,7 @@<br>
p.sad_x4[LUMA_16x32] = x265_pixel_sad_x4_16x32_avx;<br>
p.sad_x3[LUMA_16x64] = x265_pixel_sad_x3_16x64_avx;<br>
p.sad_x4[LUMA_16x64] = x265_pixel_sad_x4_16x64_avx;<br>
+ p.sad_x3[LUMA_24x32] = x265_pixel_sad_x3_24x32_avx;<br>
}<br>
if (cpuMask & X265_CPU_XOP)<br>
{<br>
diff -r 65462024832b -r eca1142d1cec source/common/x86/pixel.h<br>
--- a/source/common/x86/pixel.h Wed Oct 30 01:54:16 2013 -0500<br>
+++ b/source/common/x86/pixel.h Wed Oct 30 14:37:25 2013 +0530<br>
@@ -47,6 +47,7 @@<br>
ret x265_pixel_ ## name ## _32x24_ ## suffix args; \<br>
ret x265_pixel_ ## name ## _32x32_ ## suffix args; \<br>
ret x265_pixel_ ## name ## _32x64_ ## suffix args; \<br>
+ ret x265_pixel_ ## name ## _24x32_ ## suffix args; \<br>
<br>
#define DECL_X1(name, suffix) \<br>
DECL_PIXELS(int, name, suffix, (pixel *, intptr_t, pixel *, intptr_t))<br>
diff -r 65462024832b -r eca1142d1cec source/common/x86/sad-a.asm<br>
--- a/source/common/x86/sad-a.asm Wed Oct 30 01:54:16 2013 -0500<br>
+++ b/source/common/x86/sad-a.asm Wed Oct 30 14:37:25 2013 +0530<br>
@@ -1988,6 +1988,117 @@<br>
RET<br>
%endmacro<br>
<br>
+%macro SAD_X3_24x4 0<br>
+ mova m3, [r0]<br>
+ mova m4, [r0 + 16]<br>
+ movu m5, [r1]<br>
+ movu m6, [r1 + 16]<br>
+ psadbw m5, m3<br>
+ psadbw m6, m4<br>
+ pshufd m6, m6, 84<br>
+ paddd m5, m6<br>
+ paddd m0, m5<br>
+ movu m5, [r2]<br>
+ movu m6, [r2 + 16]<br>
+ psadbw m5, m3<br>
+ psadbw m6, m4<br>
+ pshufd m6, m6, 84<br>
+ paddd m5, m6<br>
+ paddd m1, m5<br>
+ movu m5, [r3]<br>
+ movu m6, [r3 + 16]<br>
+ psadbw m5, m3<br>
+ psadbw m6, m4<br>
+ pshufd m6, m6, 84<br>
+ paddd m5, m6<br>
+ paddd m2, m5<br>
+ lea r0, [r0 + FENC_STRIDE]<br>
+ lea r1, [r1 + r4]<br>
+ lea r2, [r2 + r4]<br>
+ lea r3, [r3 + r4]<br>
+ mova m3, [r0]<br>
+ mova m4, [r0 + 16]<br>
+ movu m5, [r1]<br>
+ movu m6, [r1 + 16]<br>
+ psadbw m5, m3<br>
+ psadbw m6, m4<br>
+ pshufd m6, m6, 84<br>
+ paddd m5, m6<br>
+ paddd m0, m5<br>
+ movu m5, [r2]<br>
+ movu m6, [r2 + 16]<br>
+ psadbw m5, m3<br>
+ psadbw m6, m4<br>
+ pshufd m6, m6, 84<br>
+ paddd m5, m6<br>
+ paddd m1, m5<br>
+ movu m5, [r3]<br>
+ movu m6, [r3 + 16]<br>
+ psadbw m5, m3<br>
+ psadbw m6, m4<br>
+ pshufd m6, m6, 84<br>
+ paddd m5, m6<br>
+ paddd m2, m5<br>>>+ lea r0, [r0 + FENC_STRIDE]<br>>>+ lea r1, [r1 + r4]<br>>>+ lea r2, [r2 + r4]<br>>>+ lea r3, [r3 + r4]<br>>>+ mova m3, [r0]<br>
>>+ mova m4, [r0 + 16]<br>>>+ movu m5, [r1]<br>>>+ movu m6, [r1 + 16]</div><div class="gmail_quote"><br></div><div class="gmail_quote">You don't need to load address every time. you can calculate it like</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">mova m4, [r0 + 2 * r4]</div><div class="gmail_quote">mova m4, [r0 + 4 * r4]<br></div><div class="gmail_quote">mova m4, [r0 + 8 * r4]<br></div><div class="gmail_quote">
<br></div><div class="gmail_quote">or even like</div><div class="gmail_quote"><br></div><div class="gmail_quote">mova m4, [r0 + 2 * r4 + constant] </div><div class="gmail_quote"><br></div><div class="gmail_quote">use this concept to eliminate lea instructions. Multiplication with 1, 2, 4 and 8 are allowed.</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">
+ psadbw m5, m3<br>
+ psadbw m6, m4<br>
+ pshufd m6, m6, 84<br>
+ paddd m5, m6<br>
+ paddd m0, m5<br>
+ movu m5, [r2]<br>
+ movu m6, [r2 + 16]<br>
+ psadbw m5, m3<br>
+ psadbw m6, m4<br>
+ pshufd m6, m6, 84<br>
+ paddd m5, m6<br>
+ paddd m1, m5<br>
+ movu m5, [r3]<br>
+ movu m6, [r3 + 16]<br>
+ psadbw m5, m3<br>
+ psadbw m6, m4<br>
+ pshufd m6, m6, 84<br>
+ paddd m5, m6<br>
+ paddd m2, m5<br>
+ lea r0, [r0 + FENC_STRIDE]<br>
+ lea r1, [r1 + r4]<br>
+ lea r2, [r2 + r4]<br>
+ lea r3, [r3 + r4]<br>
+ mova m3, [r0]<br>
+ mova m4, [r0 + 16]<br>
+ movu m5, [r1]<br>
+ movu m6, [r1 + 16]<br>
+ psadbw m5, m3<br>
+ psadbw m6, m4<br>
+ pshufd m6, m6, 84<br>
+ paddd m5, m6<br>
+ paddd m0, m5<br>
+ movu m5, [r2]<br>
+ movu m6, [r2 + 16]<br>
+ psadbw m5, m3<br>
+ psadbw m6, m4<br>
+ pshufd m6, m6, 84<br>
+ paddd m5, m6<br>
+ paddd m1, m5<br>
+ movu m5, [r3]<br>
+ movu m6, [r3 + 16]<br>
+ psadbw m5, m3<br>
+ psadbw m6, m4<br>
+ pshufd m6, m6, 84<br>
+ paddd m5, m6<br>
+ paddd m2, m5<br>
+ lea r0, [r0 + FENC_STRIDE]<br>
+ lea r1, [r1 + r4]<br>
+ lea r2, [r2 + r4]<br>
+ lea r3, [r3 + r4]<br>
+%endmacro<br>
+<br>
;-----------------------------------------------------------------------------<br>
; void pixel_sad_x3_16x16( uint8_t *fenc, uint8_t *pix0, uint8_t *pix1,<br>
; uint8_t *pix2, intptr_t i_stride, int scores[3] )<br>
@@ -2006,6 +2117,25 @@<br>
%endif<br>
%endmacro<br>
<br>
+%macro SAD_X3_W24 0<br>
+cglobal pixel_sad_x3_24x32, 5, 6, 8<br>
+ pxor m0, m0<br>
+ pxor m1, m1<br>
+ pxor m2, m2<br>
+ mov r6, 32<br>
+<br>
+.loop<br>
+ SAD_X3_24x4<br>
+ SAD_X3_24x4<br>
+ SAD_X3_24x4<br>
+ SAD_X3_24x4<br>
+<br>
+ sub r6, 16<br>
+ cmp r6, 0<br>
+jnz .loop<br>
+ SAD_X3_END_SSE2 1<br>
+%endmacro<br>
+<br>
INIT_XMM sse2<br>
SAD_X_SSE2 3, 16, 16, 7<br>
SAD_X_SSE2 3, 16, 8, 7<br>
@@ -2037,6 +2167,7 @@<br>
%endmacro<br>
<br>
INIT_XMM ssse3<br>
+SAD_X3_W24<br>
SAD_X_SSE2 3, 16, 64, 7<br>
SAD_X_SSE2 3, 16, 32, 7<br>
SAD_X_SSE2 3, 16, 16, 7<br>
@@ -2055,6 +2186,7 @@<br>
SAD_X_SSSE3 4, 8, 4<br>
<br>
INIT_XMM avx<br>
+SAD_X3_W24<br>
SAD_X_SSE2 3, 16, 64, 7<br>
SAD_X_SSE2 3, 16, 32, 6<br>
SAD_X_SSE2 3, 16, 16, 6<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</div><br></div>