<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Oct 31, 2013 at 8:03 AM, Min Chen <span dir="ltr"><<a href="mailto:chenm003@163.com" target="_blank">chenm003@163.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Min Chen <<a href="mailto:chenm003@163.com">chenm003@163.com</a>><br>
# Date 1383224503 -28800<br>
# Node ID 4a40c4069ad12bc72a1c443b45a91c65d319d35d<br>
# Parent 21dbf988079b0e33265ae48578c26347cc779fbe<br>
asm: chroma_p2s to replace ipfilter_p2s<br></blockquote><div><br></div><div>the testbench is reporting failures after this change. I'll see if I can patch this myself.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
diff -r 21dbf988079b -r 4a40c4069ad1 source/Lib/TLibCommon/TComPrediction.cpp<br>
--- a/source/Lib/TLibCommon/TComPrediction.cpp Thu Oct 31 21:01:29 2013 +0800<br>
+++ b/source/Lib/TLibCommon/TComPrediction.cpp Thu Oct 31 21:01:43 2013 +0800<br>
@@ -619,10 +619,13 @@<br>
uint32_t cxWidth = width >> 1;<br>
uint32_t cxHeight = height >> 1;<br>
<br>
+ assert(dstStride == MAX_CU_SIZE / 2);<br>
+ assert(((cxWidth | cxHeight) % 2) == 0);<br>
+<br>
if ((yFrac | xFrac) == 0)<br>
{<br>
- primitives.ipfilter_p2s(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight);<br>
- primitives.ipfilter_p2s(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight);<br>
+ primitives.chroma_p2s(refCb, refStride, dstCb, cxWidth, cxHeight);<br>
+ primitives.chroma_p2s(refCr, refStride, dstCr, cxWidth, cxHeight);<br>
}<br>
else if (yFrac == 0)<br>
{<br>
diff -r 21dbf988079b -r 4a40c4069ad1 source/common/ipfilter.cpp<br>
--- a/source/common/ipfilter.cpp Thu Oct 31 21:01:29 2013 +0800<br>
+++ b/source/common/ipfilter.cpp Thu Oct 31 21:01:43 2013 +0800<br>
@@ -264,6 +264,7 @@<br>
}<br>
}<br>
<br>
+template<int dstStride><br>
void filterConvertPelToShort_c(pixel *src, intptr_t srcStride, int16_t *dst, int width, int height)<br>
{<br>
int shift = IF_INTERNAL_PREC - X265_DEPTH;<br>
@@ -278,7 +279,7 @@<br>
}<br>
<br>
src += srcStride;<br>
- dst += MAX_CU_SIZE;<br>
+ dst += dstStride;<br>
}<br>
}<br>
<br>
@@ -489,7 +490,8 @@<br>
<br>
p.ipfilter_p2s = filterConvertPelToShort_c;<br>
p.ipfilter_s2p = filterConvertShortToPel_c;<br>
- p.luma_p2s = filterConvertPelToShort_c;<br>
+ p.luma_p2s = filterConvertPelToShort_c<MAX_CU_SIZE>;<br>
+ p.chroma_p2s = filterConvertPelToShort_c<MAX_CU_SIZE/2>;<br>
<br>
p.extendRowBorder = extendCURowColBorder;<br>
}<br>
diff -r 21dbf988079b -r 4a40c4069ad1 source/common/primitives.h<br>
--- a/source/common/primitives.h Thu Oct 31 21:01:29 2013 +0800<br>
+++ b/source/common/primitives.h Thu Oct 31 21:01:43 2013 +0800<br>
@@ -254,6 +254,7 @@<br>
filter_pp_t luma_vpp[NUM_LUMA_PARTITIONS];<br>
filter_hv_pp_t luma_hvpp[NUM_LUMA_PARTITIONS];<br>
filter_p2s_t luma_p2s;<br>
+ filter_p2s_t chroma_p2s;<br>
<br>
intra_dc_t intra_pred_dc;<br>
intra_planar_t intra_pred_planar;<br>
diff -r 21dbf988079b -r 4a40c4069ad1 source/common/x86/asm-primitives.cpp<br>
--- a/source/common/x86/asm-primitives.cpp Thu Oct 31 21:01:29 2013 +0800<br>
+++ b/source/common/x86/asm-primitives.cpp Thu Oct 31 21:01:43 2013 +0800<br>
@@ -318,6 +318,7 @@<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>
p.luma_p2s = x265_luma_p2s_ssse3;<br>
+ p.chroma_p2s = x265_chroma_p2s_ssse3;<br>
}<br>
if (cpuMask & X265_CPU_SSE4)<br>
{<br>
diff -r 21dbf988079b -r 4a40c4069ad1 source/common/x86/ipfilter8.asm<br>
--- a/source/common/x86/ipfilter8.asm Thu Oct 31 21:01:29 2013 +0800<br>
+++ b/source/common/x86/ipfilter8.asm Thu Oct 31 21:01:43 2013 +0800<br>
@@ -2124,3 +2124,61 @@<br>
jnz .loopH<br>
<br>
RET<br>
+<br>
+<br>
+; TODO: combin of U and V is more performance, but need more register<br>
+; TODO: use two path for height alignment to 4 and otherwise may improvement 10% performance, but code is more complex, so I disable it<br>
+INIT_XMM ssse3<br>
+cglobal chroma_p2s, 3, 7, 6<br>
+<br>
+ ; load width and height<br>
+ mov r3d, r3m<br>
+ mov r4d, r4m<br>
+<br>
+ ; load constant<br>
+ mova m4, [tab_c_128]<br>
+ mova m5, [tab_c_64_n64]<br>
+<br>
+.loopH:<br>
+<br>
+ xor r5d, r5d<br>
+.loopW:<br>
+ lea r6, [r0 + r5]<br>
+<br>
+ movh m0, [r6]<br>
+ punpcklbw m0, m4<br>
+ pmaddubsw m0, m5<br>
+<br>
+ movh m1, [r6 + r1]<br>
+ punpcklbw m1, m6<br>
+ pmaddubsw m1, m7<br>
+<br>
+ add r5d, 8<br>
+ cmp r5d, r3d<br>
+ lea r6, [r2 + r5 * 2]<br>
+ jg .width2<br>
+ movu [r6 + FENC_STRIDE / 2 * 0 - 16], m0<br>
+ movu [r6 + FENC_STRIDE / 2 * 2 - 16], m1<br>
+ je .nextH<br>
+ jmp .loopW<br>
+<br>
+.width4:<br>
+ cmp r3d, 4<br>
+ jl .width2<br>
+ movh [r6 + FENC_STRIDE / 2 * 0 - 16], m0<br>
+ movh [r6 + FENC_STRIDE / 2 * 2 - 16], m1<br>
+ lea r6, [r6 + 8]<br>
+ jz .nextH<br>
+<br>
+.width2:<br>
+ movd [r6 + FENC_STRIDE / 2 * 0 - 16], m0<br>
+ movd [r6 + FENC_STRIDE / 2 * 2 - 16], m1<br>
+<br>
+.nextH:<br>
+ lea r0, [r0 + r1 * 2]<br>
+ add r2, FENC_STRIDE / 2 * 4<br>
+<br>
+ sub r4d, 2<br>
+ jnz .loopH<br>
+<br>
+ RET<br>
diff -r 21dbf988079b -r 4a40c4069ad1 source/common/x86/ipfilter8.h<br>
--- a/source/common/x86/ipfilter8.h Thu Oct 31 21:01:29 2013 +0800<br>
+++ b/source/common/x86/ipfilter8.h Thu Oct 31 21:01:43 2013 +0800<br>
@@ -91,6 +91,7 @@<br>
void x265_interp_8tap_hv_pp_8x8_ssse3(pixel * src, intptr_t srcStride, pixel * dst, intptr_t dstStride, int idxX, int idxY);<br>
void x265_interp_8tap_v_sp_ssse3(int16_t *src, intptr_t srcStride, pixel *dst, intptr_t dstStride, int width, int height, const int coeffIdx);<br>
void x265_luma_p2s_ssse3(pixel *src, intptr_t srcStride, int16_t *dst, int width, int height);<br>
+void x265_chroma_p2s_ssse3(pixel *src, intptr_t srcStride, int16_t *dst, int width, int height);<br>
<br>
#undef SETUP_CHROMA_FUNC_DEF<br>
#undef SETUP_LUMA_FUNC_DEF<br>
diff -r 21dbf988079b -r 4a40c4069ad1 source/test/ipfilterharness.cpp<br>
--- a/source/test/ipfilterharness.cpp Thu Oct 31 21:01:29 2013 +0800<br>
+++ b/source/test/ipfilterharness.cpp Thu Oct 31 21:01:43 2013 +0800<br>
@@ -240,14 +240,15 @@<br>
return true;<br>
}<br>
<br>
-bool IPFilterHarness::check_IPFilter_primitive(filter_p2s_t ref, filter_p2s_t opt)<br>
+bool IPFilterHarness::check_IPFilter_primitive(filter_p2s_t ref, filter_p2s_t opt, int isChroma)<br>
{<br>
- int16_t rand_srcStride;<br>
+ intptr_t rand_srcStride;<br>
+ const int min_size = isChroma ? 2 : 4;<br>
<br>
for (int i = 0; i <= 1000; i++)<br>
{<br>
- int16_t rand_height = (int16_t)rand() % 100; // Randomly generated Height<br>
- int16_t rand_width = (int16_t)rand() % 100; // Randomly generated Width<br>
+ int rand_height = (int16_t)rand() % 100; // Randomly generated Height<br>
+ int rand_width = (int16_t)rand() % 100; // Randomly generated Width<br>
<br>
memset(IPF_vec_output_s, 0, ipf_t_size); // Initialize output buffer to zero<br>
memset(IPF_C_output_s, 0, ipf_t_size); // Initialize output buffer to zero<br>
@@ -256,13 +257,13 @@<br>
if (rand_srcStride < rand_width)<br>
rand_srcStride = rand_width;<br>
<br>
- rand_width %= 4;<br>
- if (rand_width < 4)<br>
- rand_width = 4;<br>
+ rand_width %= min_size;<br>
+ if (rand_width < min_size)<br>
+ rand_width = min_size;<br>
<br>
- rand_height %= 4;<br>
- if (rand_height < 4)<br>
- rand_height = 4;<br>
+ rand_height %= min_size;<br>
+ if (rand_height < min_size)<br>
+ rand_height = min_size;<br>
<br>
ref(pixel_buff,<br>
rand_srcStride,<br>
@@ -461,7 +462,16 @@<br>
<br>
if (opt.luma_p2s)<br>
{<br>
- if (!check_IPFilter_primitive(ref.luma_p2s, opt.luma_p2s))<br>
+ if (!check_IPFilter_primitive(ref.luma_p2s, opt.luma_p2s, 0))<br>
+ {<br>
+ printf("ipfilter_p2s failed\n");<br>
+ return false;<br>
+ }<br>
+ }<br>
+<br>
+ if (opt.chroma_p2s)<br>
+ {<br>
+ if (!check_IPFilter_primitive(ref.chroma_p2s, opt.chroma_p2s, 1))<br>
{<br>
printf("ipfilter_p2s failed\n");<br>
return false;<br>
@@ -586,6 +596,13 @@<br>
pixel_buff, srcStride, IPF_vec_output_s, width, height);<br>
}<br>
<br>
+ if (opt.chroma_p2s)<br>
+ {<br>
+ printf("chroma_p2s\t");<br>
+ REPORT_SPEEDUP(opt.chroma_p2s, ref.chroma_p2s,<br>
+ pixel_buff, srcStride, IPF_vec_output_s, width, height);<br>
+ }<br>
+<br>
if (opt.ipfilter_s2p)<br>
{<br>
printf("ipfilter_s2p\t");<br>
diff -r 21dbf988079b -r 4a40c4069ad1 source/test/ipfilterharness.h<br>
--- a/source/test/ipfilterharness.h Thu Oct 31 21:01:29 2013 +0800<br>
+++ b/source/test/ipfilterharness.h Thu Oct 31 21:01:43 2013 +0800<br>
@@ -45,7 +45,7 @@<br>
bool check_IPFilter_primitive(ipfilter_ps_t ref, ipfilter_ps_t opt);<br>
bool check_IPFilter_primitive(ipfilter_sp_t ref, ipfilter_sp_t opt);<br>
bool check_IPFilter_primitive(ipfilter_p2s_t ref, ipfilter_p2s_t opt);<br>
- bool check_IPFilter_primitive(filter_p2s_t ref, filter_p2s_t opt);<br>
+ bool check_IPFilter_primitive(filter_p2s_t ref, filter_p2s_t opt, int isChroma);<br>
bool check_IPFilter_primitive(ipfilter_s2p_t ref, ipfilter_s2p_t opt);<br>
bool check_IPFilterChroma_primitive(filter_pp_t ref, filter_pp_t opt);<br>
bool check_IPFilterLuma_primitive(filter_pp_t ref, filter_pp_t opt);<br>
<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">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>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Steve Borho
</div></div>