[x265] [PATCH] testbench: code for testing input pixel upShift/downShift primitives

murugan at multicorewareinc.com murugan at multicorewareinc.com
Fri Mar 14 14:06:37 CET 2014


# HG changeset patch
# User Murugan Vairavel <murugan at multicorewareinc.com>
# Date 1394697912 -19800
#      Thu Mar 13 13:35:12 2014 +0530
# Node ID ea43e61d88dacb1942f491d630e6fcd11a2e658e
# Parent  24ff000ca31e566e8070cf2ac75f3ddc79a108b4
testbench: code for testing input pixel upShift/downShift primitives

diff -r 24ff000ca31e -r ea43e61d88da source/test/pixelharness.cpp
--- a/source/test/pixelharness.cpp	Fri Mar 14 13:40:29 2014 +0530
+++ b/source/test/pixelharness.cpp	Thu Mar 13 13:35:12 2014 +0530
@@ -59,6 +59,8 @@
     CHECKED_MALLOC(short_test_buff1, int16_t*, TEST_CASES);
     CHECKED_MALLOC(short_test_buff2, int16_t*, TEST_CASES);
     CHECKED_MALLOC(int_test_buff, int*, TEST_CASES);
+    CHECKED_MALLOC(ushort_test_buff, uint16_t*, TEST_CASES);
+    CHECKED_MALLOC(uchar_test_buff, uint8_t*, TEST_CASES);
 
     for (int i = 0; i < TEST_CASES; i++)
     {
@@ -67,6 +69,8 @@
         CHECKED_MALLOC(short_test_buff1[i], int16_t, BUFFSIZE);
         CHECKED_MALLOC(short_test_buff2[i], int16_t, BUFFSIZE);
         CHECKED_MALLOC(int_test_buff[i], int, BUFFSIZE);
+        CHECKED_MALLOC(ushort_test_buff[i], uint16_t, BUFFSIZE);
+        CHECKED_MALLOC(uchar_test_buff[i], uint8_t, BUFFSIZE);
     }
 
     /* [0] --- Random values
@@ -79,16 +83,22 @@
         short_test_buff1[0][i]  = rand() & PIXEL_MAX;                   // For block copy only
         short_test_buff2[0][i]  = rand() % 16383;                       // for addAvg
         int_test_buff[0][i]     = rand() % SHORT_MAX;
+        ushort_test_buff[0][i]  = rand() % ((1 << 10) - 1);
+        uchar_test_buff[0][i]  = rand() % ((1 << 8) - 1);
         pixel_test_buff[1][i]   = PIXEL_MIN;
         short_test_buff[1][i]   = SMIN;
         short_test_buff1[1][i]  = PIXEL_MIN;
         short_test_buff2[1][i]  = -16384;
         int_test_buff[1][i]     = SHORT_MIN;
+        ushort_test_buff[1][i]  = PIXEL_MIN;
+        uchar_test_buff[1][i]  = PIXEL_MIN;
         pixel_test_buff[2][i]   = PIXEL_MAX;
         short_test_buff[2][i]   = SMAX;
         short_test_buff1[2][i]  = PIXEL_MAX;
         short_test_buff2[2][i]  = 16383;
         int_test_buff[2][i]     = SHORT_MAX;
+        ushort_test_buff[2][i]  = ((1 << 10) - 1);
+        uchar_test_buff[2][i]  = 255;
     }
     for (int i = 0; i < bufsize; i++)
     {
@@ -122,13 +132,19 @@
         X265_FREE(pixel_test_buff[i]);
         X265_FREE(short_test_buff[i]);
         X265_FREE(short_test_buff1[i]);
+        X265_FREE(short_test_buff2[i]);
         X265_FREE(int_test_buff[i]);
+        X265_FREE(ushort_test_buff[i]);
+        X265_FREE(uchar_test_buff[i]);
     }
 
     X265_FREE(pixel_test_buff);
     X265_FREE(short_test_buff);
     X265_FREE(short_test_buff1);
+    X265_FREE(short_test_buff2);
     X265_FREE(int_test_buff);
+    X265_FREE(ushort_test_buff);
+    X265_FREE(uchar_test_buff);
 }
 
 bool PixelHarness::check_pixelcmp(pixelcmp_t ref, pixelcmp_t opt)
@@ -918,6 +934,64 @@
     return true;
 }
 
+bool PixelHarness::check_planecopy_sp(planecopy_sp ref, planecopy_sp opt)
+{
+    ALIGN_VAR_16(pixel, ref_dest[64 * 64]);
+    ALIGN_VAR_16(pixel, opt_dest[64 * 64]);
+
+    memset(ref_dest, 0xCD, sizeof(ref_dest));
+    memset(opt_dest, 0xCD, sizeof(opt_dest));
+
+    int srcStride = 64;
+    int dstStride = 64;
+    int width = (rand() % 3 + 1) * 16;
+    int height = rand() % 64;
+    int j = 0;
+
+    for (int i = 0; i < ITERS; i++)
+    {
+        int index = i % TEST_CASES;
+        opt(ushort_test_buff[index] + j, srcStride, opt_dest, dstStride, width, height, 2, 255);
+        ref(ushort_test_buff[index] + j, srcStride, ref_dest, dstStride, width, height, 2, 255);
+
+        if (memcmp(ref_dest, opt_dest, 64 * 64 * sizeof(pixel)))
+            return false;
+
+        j += INCR;
+    }
+
+    return true;
+}
+
+bool PixelHarness::check_planecopy_cp(planecopy_cp ref, planecopy_cp opt)
+{
+    ALIGN_VAR_16(pixel, ref_dest[64 * 64]);
+    ALIGN_VAR_16(pixel, opt_dest[64 * 64]);
+
+    memset(ref_dest, 0xCD, sizeof(ref_dest));
+    memset(opt_dest, 0xCD, sizeof(opt_dest));
+
+    int srcStride = 64;
+    int dstStride = 64;
+    int width = (rand() % 3 + 1) * 16;
+    int height = rand() % 64;
+    int j = 0;
+
+    for (int i = 0; i < ITERS; i++)
+    {
+        int index = i % TEST_CASES;
+        opt(uchar_test_buff[index] + j, srcStride, opt_dest, dstStride, width, height);
+        ref(uchar_test_buff[index] + j, srcStride, ref_dest, dstStride, width, height);
+
+        if (memcmp(ref_dest, opt_dest, 64 * 64 * sizeof(pixel)))
+            return false;
+
+        j += INCR;
+    }
+
+    return true;
+}
+
 bool PixelHarness::testPartition(int part, const EncoderPrimitives& ref, const EncoderPrimitives& opt)
 {
     if (opt.satd[part])
@@ -1327,6 +1401,24 @@
         }
     }
 
+    if (opt.downShift)
+    {
+        if (!check_planecopy_sp(ref.downShift, opt.downShift))
+        {
+            printf("downShift failed\n");
+            return false;
+        }
+    }
+
+    if (opt.upShift)
+    {
+        if (!check_planecopy_cp(ref.upShift, opt.upShift))
+        {
+            printf("upShift failed\n");
+            return false;
+        }
+    }
+
     return true;
 }
 
@@ -1619,7 +1711,19 @@
 
     if (opt.saoCuOrgE0)
     {
-        printf("SAO_EO_0");
+        HEADER0("SAO_EO_0");
         REPORT_SPEEDUP(opt.saoCuOrgE0, ref.saoCuOrgE0, pbuf1, psbuf1, 64, 1);
     }
+
+    if (opt.downShift)
+    {
+        HEADER0("downShift");
+        REPORT_SPEEDUP(opt.downShift, ref.downShift, ushort_test_buff[0], 64, pbuf1, 64, 64, 64, 2, 255);
+    }
+
+    if (opt.upShift)
+    {
+        HEADER0("upShift");
+        REPORT_SPEEDUP(opt.upShift, ref.upShift, uchar_test_buff[0], 64, pbuf1, 64, 64, 64);
+    }
 }
diff -r 24ff000ca31e -r ea43e61d88da source/test/pixelharness.h
--- a/source/test/pixelharness.h	Fri Mar 14 13:40:29 2014 +0530
+++ b/source/test/pixelharness.h	Thu Mar 13 13:35:12 2014 +0530
@@ -35,6 +35,8 @@
     int *ibuf1, **int_test_buff;
     int8_t *psbuf1;
     int16_t *sbuf1, *sbuf2, *sbuf3, **short_test_buff, **short_test_buff1, **short_test_buff2;
+    uint16_t **ushort_test_buff;
+    uint8_t **uchar_test_buff;
     bool check_pixelcmp(pixelcmp_t ref, pixelcmp_t opt);
     bool check_pixelcmp_sp(pixelcmp_sp_t ref, pixelcmp_sp_t opt);
     bool check_pixelcmp_ss(pixelcmp_ss_t ref, pixelcmp_ss_t opt);
@@ -65,6 +67,8 @@
     bool check_ssim_end(ssim_end4_t ref, ssim_end4_t opt);
     bool check_addAvg(addAvg_t, addAvg_t);
     bool check_saoCuOrgE0_t(saoCuOrgE0_t ref, saoCuOrgE0_t opt);
+    bool check_planecopy_sp(planecopy_sp ref, planecopy_sp opt);
+    bool check_planecopy_cp(planecopy_cp ref, planecopy_cp opt);
 public:
 
     PixelHarness();


More information about the x265-devel mailing list