[x265] [PATCH] sse_pp16: Better performance result

praveen at multicorewareinc.com praveen at multicorewareinc.com
Thu Aug 8 13:32:46 CEST 2013


# HG changeset patch
# User praveentiwari
# Date 1375961557 -19800
# Node ID 2a771d32dcf7c7ee737b2ac31a53dedf7373fc7a
# Parent  f86aa153a61612c98dce25321818148c0715bdd6
sse_pp16: Better performance result

diff -r f86aa153a616 -r 2a771d32dcf7 source/common/vec/sse.inc
--- a/source/common/vec/sse.inc	Thu Aug 08 16:42:11 2013 +0530
+++ b/source/common/vec/sse.inc	Thu Aug 08 17:02:37 2013 +0530
@@ -111,7 +111,8 @@
 int sse_pp16(pixel* Org, intptr_t strideOrg, pixel* Cur, intptr_t strideCur)
 {
     int rows = ly;
-    __m128i sum = _mm_set1_epi32(0);
+    __m128i sum = _mm_setzero_si128();
+    __m128i zero = _mm_setzero_si128();
 
     for (; rows != 0; rows--)
     {
@@ -119,12 +120,10 @@
         __m128i n1 = _mm_loadu_si128((__m128i const*)(Cur));
 
         __m128i m1lo = _mm_cvtepu8_epi16(m1);
-        __m128i m1hi = _mm_srli_si128(m1, 8);
-        m1hi = _mm_cvtepu8_epi16(m1hi);
+        __m128i m1hi = _mm_unpackhi_epi8(m1, zero);
 
         __m128i n1lo = _mm_cvtepu8_epi16(n1);
-        __m128i n1hi = _mm_srli_si128(n1, 8);
-        n1hi = _mm_cvtepu8_epi16(n1hi);
+        __m128i n1hi = _mm_unpackhi_epi8(n1, zero);
 
         __m128i diff = _mm_sub_epi16(m1lo, n1lo);
         sum = _mm_add_epi32(sum, _mm_madd_epi16(diff, diff));
@@ -136,8 +135,8 @@
         Cur += strideCur;
     }
 
-    sum = _mm_add_epi32(sum, _mm_srli_si128(sum, 8));
-    sum = _mm_add_epi32(sum, _mm_srli_si128(sum, 4));
+    sum = _mm_hadd_epi32(sum, sum);
+    sum = _mm_hadd_epi32(sum, sum);
     return _mm_cvtsi128_si32(sum);
 }
 


More information about the x265-devel mailing list