[x265] [PATCH 2 of 3] sao: created new primitive for saoCuStatsE0

dnyaneshwar at multicorewareinc.com dnyaneshwar at multicorewareinc.com
Thu Jul 2 14:01:24 CEST 2015


# HG changeset patch
# User Dnyaneshwar G <dnyaneshwar at multicorewareinc.com>
# Date 1435749632 -19800
#      Wed Jul 01 16:50:32 2015 +0530
# Node ID 915d02816797d3c70004e652a13b3804571c251b
# Parent  18151ada638dd19843551e2a6d5d8b2cc9bd28be
sao: created new primitive for saoCuStatsE0

diff -r 18151ada638d -r 915d02816797 source/common/primitives.h
--- a/source/common/primitives.h	Wed Jul 01 16:49:24 2015 +0530
+++ b/source/common/primitives.h	Wed Jul 01 16:50:32 2015 +0530
@@ -174,6 +174,7 @@
 typedef void (*saoCuOrgE3_t)(pixel* rec, int8_t* upBuff1, int8_t* m_offsetEo, intptr_t stride, int startX, int endX);
 typedef void (*saoCuOrgB0_t)(pixel* rec, const int8_t* offsetBo, int ctuWidth, int ctuHeight, intptr_t stride);
 
+typedef void (*saoCuStatsE0_t)(const pixel *fenc, const pixel *rec, intptr_t stride, int endX, int endY, int32_t *stats, int32_t *count);
 typedef void (*saoCuStatsE1_t)(const pixel *fenc, const pixel *rec, intptr_t stride, int8_t *upBuff1, int endX, int endY, int32_t *stats, int32_t *count);
 typedef void (*saoCuStatsE2_t)(const pixel *fenc, const pixel *rec, intptr_t stride, int8_t *upBuff1, int8_t *upBuff, int endX, int endY, int32_t *stats, int32_t *count);
 typedef void (*saoCuStatsE3_t)(const pixel *fenc, const pixel *rec, intptr_t stride, int8_t *upBuff1, int endX, int endY, int32_t *stats, int32_t *count);
@@ -298,6 +299,7 @@
     saoCuOrgE3_t          saoCuOrgE3[2];
     saoCuOrgB0_t          saoCuOrgB0;
 
+    saoCuStatsE0_t        saoCuStatsE0;
     saoCuStatsE1_t        saoCuStatsE1;
     saoCuStatsE2_t        saoCuStatsE2;
     saoCuStatsE3_t        saoCuStatsE3;
diff -r 18151ada638d -r 915d02816797 source/encoder/sao.cpp
--- a/source/encoder/sao.cpp	Wed Jul 01 16:49:24 2015 +0530
+++ b/source/encoder/sao.cpp	Wed Jul 01 16:50:32 2015 +0530
@@ -706,11 +706,6 @@
     int8_t _upBuff1[MAX_CU_SIZE + 2], *upBuff1 = _upBuff1 + 1;
     int8_t _upBufft[MAX_CU_SIZE + 2], *upBufft = _upBufft + 1;
 
-    // Dynamic Range: 64x64x14bpp = 24bits
-    int32_t tmp_stats[NUM_EDGETYPE];
-    // TODO: improve by uint64_t, but need Haswell SHLX
-    uint16_t tmp_count[NUM_EDGETYPE];
-
     // SAO_BO:
     {
         const int boShift = X265_DEPTH - SAO_BO_BITS;
@@ -752,41 +747,10 @@
                 skipR = plane ? 3 : 5;
             }
 
-            fenc = fenc0;
-            rec  = rec0;
-
             startX = !lpelx;
             endX   = (rpelx == picWidth) ? ctuWidth - 1 : ctuWidth - skipR;
 
-            memset(tmp_stats, 0, sizeof(tmp_stats));
-            memset(tmp_count, 0, sizeof(tmp_count));
-
-            for (y = 0; y < ctuHeight - skipB; y++)
-            {
-                int signLeft = signOf(rec[startX] - rec[startX - 1]);
-                for (x = startX; x < endX; x++)
-                {
-                    int signRight = signOf2(rec[x], rec[x + 1]);
-                    X265_CHECK(signRight == signOf(rec[x] - rec[x + 1]), "signDown check failure\n");
-                    uint32_t edgeType = signRight + signLeft + 2;
-                    signLeft = -signRight;
-
-                    X265_CHECK(edgeType <= 4, "edgeType check failure\n");
-                    tmp_stats[edgeType] += (fenc[x] - rec[x]);
-                    tmp_count[edgeType]++;
-                }
-
-                fenc += stride;
-                rec += stride;
-            }
-
-            stats = m_offsetOrg[plane][SAO_EO_0];
-            count = m_count[plane][SAO_EO_0];
-            for (x = 0; x < NUM_EDGETYPE; x++)
-            {
-                stats[s_eoTable[x]] += tmp_stats[x];
-                count[s_eoTable[x]] += tmp_count[x];
-            }
+            primitives.saoCuStatsE0(fenc0 + startX, rec0 + startX, stride, endX - startX, ctuHeight - skipB, m_offsetOrg[plane][SAO_EO_0], m_count[plane][SAO_EO_0]);
         }
 
         // SAO_EO_1: // dir: |
@@ -1588,6 +1552,41 @@
 }
 
 // NOTE: must put in namespace X265_NS since we need class SAO
+void saoCuStatsE0_c(const pixel *fenc, const pixel *rec, intptr_t stride, int endX, int endY, int32_t *stats, int32_t *count)
+{
+    int x, y;
+    int32_t tmp_stats[SAO::NUM_EDGETYPE];
+    int32_t tmp_count[SAO::NUM_EDGETYPE];
+
+    memset(tmp_stats, 0, sizeof(tmp_stats));
+    memset(tmp_count, 0, sizeof(tmp_count));
+
+    for (y = 0; y < endY; y++)
+    {
+        int signLeft = signOf(rec[0] - rec[-1]);
+        for (x = 0; x < endX; x++)
+        {
+            int signRight = signOf2(rec[x], rec[x + 1]);
+            X265_CHECK(signRight == signOf(rec[x] - rec[x + 1]), "signDown check failure\n");
+            uint32_t edgeType = signRight + signLeft + 2;
+            signLeft = -signRight;
+
+            X265_CHECK(edgeType <= 4, "edgeType check failure\n");
+            tmp_stats[edgeType] += (fenc[x] - rec[x]);
+            tmp_count[edgeType]++;
+        }
+
+        fenc += stride;
+        rec += stride;
+    }
+
+    for (x = 0; x < SAO::NUM_EDGETYPE; x++)
+    {
+        stats[SAO::s_eoTable[x]] += tmp_stats[x];
+        count[SAO::s_eoTable[x]] += tmp_count[x];
+    }
+}
+
 void saoCuStatsE1_c(const pixel *fenc, const pixel *rec, intptr_t stride, int8_t *upBuff1, int endX, int endY, int32_t *stats, int32_t *count)
 {
     X265_CHECK(endX <= MAX_CU_SIZE, "endX check failure\n");
@@ -1703,6 +1702,7 @@
 void setupSaoPrimitives_c(EncoderPrimitives &p)
 {
     // TODO: move other sao functions to here
+    p.saoCuStatsE0 = saoCuStatsE0_c;
     p.saoCuStatsE1 = saoCuStatsE1_c;
     p.saoCuStatsE2 = saoCuStatsE2_c;
     p.saoCuStatsE3 = saoCuStatsE3_c;


More information about the x265-devel mailing list