[x265] [PATCH 2 of 2] testbench: verify support on saoCuStatsE3

Min Chen chenm003 at 163.com
Sat May 23 00:52:08 CEST 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1432333002 25200
# Node ID 75045e2ccf7a46b84e0c804f2ed0ecc02a176a6d
# Parent  3ce8e58d2d1cc58527be38bfe69ee42d82c3ccee
testbench: verify support on saoCuStatsE3
---
 source/encoder/sao.cpp       |    4 ++
 source/test/pixelharness.cpp |   67 ++++++++++++++++++++++++++++++++++++++++++
 source/test/pixelharness.h   |    1 +
 3 files changed, 72 insertions(+), 0 deletions(-)

diff -r 3ce8e58d2d1c -r 75045e2ccf7a source/encoder/sao.cpp
--- a/source/encoder/sao.cpp	Fri May 22 15:11:16 2015 -0700
+++ b/source/encoder/sao.cpp	Fri May 22 15:16:42 2015 -0700
@@ -1644,6 +1644,9 @@
 // NOTE: must put in namespace x265 since we need class SAO
 void saoCuStatsE3_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");
+    X265_CHECK(endY < MAX_CU_SIZE, "endY check failure\n");
+
     int x, y;
     int32_t tmp_stats[SAO::NUM_EDGETYPE];
     int32_t tmp_count[SAO::NUM_EDGETYPE];
@@ -1657,6 +1660,7 @@
         {
             int signDown = signOf2(rec[x], rec[x + stride - 1]);
             X265_CHECK(signDown == signOf(rec[x] - rec[x + stride - 1]), "signDown check failure\n");
+            X265_CHECK(abs(upBuff1[x]) <= 1, "upBuffer1 check failure\n");
 
             uint32_t edgeType = signDown + upBuff1[x] + 2;
             upBuff1[x - 1] = (int8_t)(-signDown);
diff -r 3ce8e58d2d1c -r 75045e2ccf7a source/test/pixelharness.cpp
--- a/source/test/pixelharness.cpp	Fri May 22 15:11:16 2015 -0700
+++ b/source/test/pixelharness.cpp	Fri May 22 15:16:42 2015 -0700
@@ -1016,6 +1016,55 @@
     return true;
 }
 
+bool PixelHarness::check_saoCuStatsE3_t(saoCuStatsE3_t ref, saoCuStatsE3_t opt)
+{
+    enum { NUM_EDGETYPE = 5 };
+    int32_t stats_ref[NUM_EDGETYPE];
+    int32_t stats_vec[NUM_EDGETYPE];
+
+    int32_t count_ref[NUM_EDGETYPE];
+    int32_t count_vec[NUM_EDGETYPE];
+
+    int8_t _upBuff1_ref[MAX_CU_SIZE + 2], *upBuff1_ref = _upBuff1_ref + 1;
+    int8_t _upBuff1_vec[MAX_CU_SIZE + 2], *upBuff1_vec = _upBuff1_vec + 1;
+
+    int j = 0;
+
+    // (const pixel *fenc, const pixel *rec, intptr_t stride, int8_t *upBuff1, int endX, int endY, int32_t *stats, int32_t *count)
+    for (int i = 0; i < ITERS; i++)
+    {
+        // initialize input data to random, the dynamic range wrong but good to verify our asm code
+        for (int x = 0; x < NUM_EDGETYPE; x++)
+        {
+            stats_ref[x] = stats_vec[x] = rand();
+            count_ref[x] = count_vec[x] = rand();
+        }
+
+        // initial sign
+        for (int x = 0; x < (int)sizeof(_upBuff1_ref); x++)
+        {
+            _upBuff1_ref[x] = _upBuff1_vec[x] = (rand() % 3) - 1;
+        }
+
+        intptr_t stride = 16 * (rand() % 4 + 1);
+        int endX = MAX_CU_SIZE - (rand() % 5) - 1;
+        int endY = MAX_CU_SIZE - (rand() % 4) - 1;
+
+        ref(pbuf2, pbuf3, stride, upBuff1_ref, endX, endY, stats_ref, count_ref);
+        checked(opt, pbuf2, pbuf3, stride, upBuff1_vec, endX, endY, stats_vec, count_vec);
+
+        if (   memcmp(_upBuff1_ref, _upBuff1_vec, sizeof(_upBuff1_ref))
+            || memcmp(stats_ref, stats_vec, sizeof(stats_ref))
+            || memcmp(count_ref, count_vec, sizeof(count_ref)))
+            return false;
+
+        reportfail();
+        j += INCR;
+    }
+
+    return true;
+}
+
 bool PixelHarness::check_saoCuOrgE3_32_t(saoCuOrgE3_t ref, saoCuOrgE3_t opt)
 {
     ALIGN_VAR_16(pixel, ref_dest[64 * 64]);
@@ -1845,6 +1894,15 @@
         }
     }
 
+    if (opt.saoCuStatsE3)
+    {
+        if (!check_saoCuStatsE3_t(ref.saoCuStatsE3, opt.saoCuStatsE3))
+        {
+            printf("saoCuStatsE3 failed\n");
+            return false;
+        }
+    }
+
     if (opt.planecopy_sp)
     {
         if (!check_planecopy_sp(ref.planecopy_sp, opt.planecopy_sp))
@@ -2246,6 +2304,15 @@
         REPORT_SPEEDUP(opt.saoCuOrgB0, ref.saoCuOrgB0, pbuf1, psbuf1, 64, 64, 64);
     }
 
+    if (opt.saoCuStatsE3)
+    {
+        int8_t upBuff1[MAX_CU_SIZE + 2];
+        int32_t stats[5], count[5];
+        memset(upBuff1, 1, sizeof(upBuff1));
+        HEADER0("saoCuStatsE3");
+        REPORT_SPEEDUP(opt.saoCuStatsE3, ref.saoCuStatsE3, pbuf2, pbuf3, 64, upBuff1 + 1, 60, 61, stats, count);
+    }
+
     if (opt.planecopy_sp)
     {
         HEADER0("planecopy_sp");
diff -r 3ce8e58d2d1c -r 75045e2ccf7a source/test/pixelharness.h
--- a/source/test/pixelharness.h	Fri May 22 15:11:16 2015 -0700
+++ b/source/test/pixelharness.h	Fri May 22 15:16:42 2015 -0700
@@ -100,6 +100,7 @@
     bool check_saoCuOrgE3_t(saoCuOrgE3_t ref, saoCuOrgE3_t opt);
     bool check_saoCuOrgE3_32_t(saoCuOrgE3_t ref, saoCuOrgE3_t opt);
     bool check_saoCuOrgB0_t(saoCuOrgB0_t ref, saoCuOrgB0_t opt);
+    bool check_saoCuStatsE3_t(saoCuStatsE3_t ref, saoCuStatsE3_t opt);
     bool check_planecopy_sp(planecopy_sp_t ref, planecopy_sp_t opt);
     bool check_planecopy_cp(planecopy_cp_t ref, planecopy_cp_t opt);
     bool check_cutree_propagate_cost(cutree_propagate_cost ref, cutree_propagate_cost opt);



More information about the x265-devel mailing list