[x265] [PATCH] testbench: added stress test cases for all functions in mbdstharness.cpp

murugan at multicorewareinc.com murugan at multicorewareinc.com
Thu Feb 13 14:58:40 CET 2014


# HG changeset patch
# User Murugan Vairavel <murugan at multicorewareinc.com>
# Date 1392299910 -19800
#      Thu Feb 13 19:28:30 2014 +0530
# Node ID 60bdec044f33d5e4cc130c000b8803af5ba772dc
# Parent  df4531a24c4db893b5197180466922bccc4b2c54
testbench: added stress test cases for all functions in mbdstharness.cpp

diff -r df4531a24c4d -r 60bdec044f33 source/test/ipfilterharness.cpp
--- a/source/test/ipfilterharness.cpp	Thu Feb 13 02:48:38 2014 -0600
+++ b/source/test/ipfilterharness.cpp	Thu Feb 13 19:28:30 2014 +0530
@@ -41,12 +41,12 @@
 IPFilterHarness::IPFilterHarness()
 {
     ipf_t_size = 200 * 200;
-    pixel_buff = (pixel*)malloc(ipf_t_size * sizeof(pixel));     // Assuming max_height = max_width = max_srcStride = max_dstStride = 100
+    pixel_buff = X265_MALLOC(pixel, ipf_t_size);           // Assuming max_height = max_width = max_srcStride = max_dstStride = 100
     short_buff = X265_MALLOC(int16_t, ipf_t_size);
-    IPF_vec_output_s = (int16_t*)malloc(ipf_t_size * sizeof(int16_t)); // Output Buffer1
-    IPF_C_output_s = (int16_t*)malloc(ipf_t_size * sizeof(int16_t));   // Output Buffer2
-    IPF_vec_output_p = (pixel*)malloc(ipf_t_size * sizeof(pixel)); // Output Buffer1
-    IPF_C_output_p = (pixel*)malloc(ipf_t_size * sizeof(pixel));   // Output Buffer2
+    IPF_vec_output_s = X265_MALLOC(int16_t, ipf_t_size);   // Output Buffer1
+    IPF_C_output_s   = X265_MALLOC(int16_t, ipf_t_size);   // Output Buffer2
+    IPF_vec_output_p = X265_MALLOC(pixel, ipf_t_size);     // Output Buffer1
+    IPF_C_output_p   = X265_MALLOC(pixel, ipf_t_size);     // Output Buffer2
 
     /* Array of pixel buffers */
     pixel_test_buff = X265_MALLOC(pixel*, TEST_CASES);
@@ -102,12 +102,12 @@
 
 IPFilterHarness::~IPFilterHarness()
 {
-    free(IPF_vec_output_s);
-    free(IPF_C_output_s);
-    free(IPF_vec_output_p);
-    free(IPF_C_output_p);
+    X265_FREE(IPF_vec_output_s);
+    X265_FREE(IPF_C_output_s);
+    X265_FREE(IPF_vec_output_p);
+    X265_FREE(IPF_C_output_p);
     X265_FREE(short_buff);
-    free(pixel_buff);
+    X265_FREE(pixel_buff);
     for (int i = 0; i < TEST_CASES; i++)
     {
         X265_FREE(pixel_test_buff[i]);
@@ -738,7 +738,7 @@
         {
             printf("luma_hv [%s]\t", lumaPartStr[value]);
             REPORT_SPEEDUP(opt.luma_hvpp[value], ref.luma_hvpp[value],
-                           pixel_buff + srcStride, srcStride, IPF_vec_output_p, dstStride, 1, 3);
+                           pixel_buff + 3 * srcStride, srcStride, IPF_vec_output_p, srcStride, 1, 3);
         }
     }
 
diff -r df4531a24c4d -r 60bdec044f33 source/test/mbdstharness.cpp
--- a/source/test/mbdstharness.cpp	Thu Feb 13 02:48:38 2014 -0600
+++ b/source/test/mbdstharness.cpp	Thu Feb 13 19:28:30 2014 +0530
@@ -30,8 +30,12 @@
 #include <string.h>
 #include <stdio.h>
 
+#define ITERS  100
+#define TEST_CASES 3
+#define SMAX (1 << 12)
+#define SMIN (-1 << 12)
+
 using namespace x265;
-#define ITERS  100
 
 struct DctConf_t
 {
@@ -76,16 +80,40 @@
     mintbuf7 = X265_MALLOC(int, mem_cmp_size);
     mintbuf8 = X265_MALLOC(int, mem_cmp_size);
 
-    if (!mbuf1 || !mbuf2 || !mbuf3 || !mbuf4 || !mbufdct)
+    short_test_buff  = (int16_t**)X265_MALLOC(int16_t*, TEST_CASES);
+    int_test_buff    = (int**)X265_MALLOC(int*, TEST_CASES);
+
+    if (!mbuf1 || !mbuf2 || !mbuf3 || !mbuf4 || !mbufdct || !mintbuf1 || !mintbuf2 || !mintbuf3 || !mintbuf4 || !mintbuf5 || !mintbuf6 || !mintbuf7 || !mintbuf8 || !short_test_buff || !int_test_buff)
     {
         fprintf(stderr, "malloc failed, unable to initiate tests!\n");
         exit(1);
     }
 
-    if (!mintbuf1 || !mintbuf2 || !mintbuf3 || !mintbuf4 || !mintbuf5 || !mintbuf6 || !mintbuf7 || !mintbuf8)
+    for (int i = 0; i < TEST_CASES; i++)
     {
-        fprintf(stderr, "malloc failed, unable to initiate tests!\n");
-        exit(1);
+        short_test_buff[i]  = (int16_t*)X265_MALLOC(int16_t, mb_t_size);
+        int_test_buff[i]  = (int*)X265_MALLOC(int, mb_t_size);
+        if (!short_test_buff[i] || !int_test_buff[i])
+        {
+            fprintf(stderr, "Init_Test_Case_buffers: malloc failed, unable to initiate tests!\n");
+            exit(-1);
+        }
+    }
+
+    /*[0] --- Random values  */
+    /*[1] --- Minimum        */
+    /*[2] --- Maximum        */
+
+    for (int i = 0; i < mb_t_size; i++)
+    {
+        short_test_buff[0][i]   = (rand() & PIXEL_MAX) - (rand() & PIXEL_MAX);
+        int_test_buff[0][i]     = rand() % SMAX;
+
+        short_test_buff[1][i]   = -PIXEL_MAX;
+        int_test_buff[1][i]     = 0;
+
+        short_test_buff[2][i]   = PIXEL_MAX;
+        int_test_buff[2][i]     = SMAX - 1;
     }
 
     const int idct_max = (1 << (BIT_DEPTH + 4)) - 1;
@@ -134,6 +162,13 @@
     X265_FREE(mintbuf6);
     X265_FREE(mintbuf7);
     X265_FREE(mintbuf8);
+    for (int i = 0; i < TEST_CASES; i++)
+    {
+        X265_FREE(short_test_buff[i]);
+        X265_FREE(int_test_buff[i]);
+    }
+    X265_FREE(short_test_buff);
+    X265_FREE(int_test_buff);
 }
 
 bool MBDstHarness::check_dct_primitive(dct_t ref, dct_t opt, int width)
@@ -143,15 +178,16 @@
 
     for (int i = 0; i <= 100; i++)
     {
-        ref(mbufdct + j, mintbuf1, width);
-        opt(mbufdct + j, mintbuf2, width);
+        int index = rand() % TEST_CASES;
+        ref(short_test_buff[index] + j, mintbuf3, width);
+        opt(short_test_buff[index] + j, mintbuf4, width);
 
-        if (memcmp(mintbuf1, mintbuf2, cmp_size))
+        if (memcmp(mintbuf3, mintbuf4, cmp_size))
         {
 #if _DEBUG
             // redo for debug
-            ref(mbufdct + j, mintbuf1, width);
-            opt(mbufdct + j, mintbuf2, width);
+            ref(short_test_buff[index] + j, mintbuf3, width);
+            opt(short_test_buff[index] + j, mintbuf4, width);
 #endif
             return false;
         }
@@ -173,15 +209,16 @@
 
     for (int i = 0; i <= 100; i++)
     {
-        ref(mbufidct + j, mbuf2, width);
-        opt(mbufidct + j, mbuf3, width);
+        int index = rand() % TEST_CASES;
+        ref(int_test_buff[index] + j, mbuf2, width);
+        opt(int_test_buff[index] + j, mbuf3, width);
 
         if (memcmp(mbuf2, mbuf3, cmp_size))
         {
 #if _DEBUG
             // redo for debug
-            ref(mbufidct + j, mbuf2, width);
-            opt(mbufidct + j, mbuf3, width);
+            ref(int_test_buff[index] + j, mbuf2, width);
+            opt(int_test_buff[index] + j, mbuf3, width);
 #endif
             return false;
         }
@@ -216,9 +253,10 @@
         int shift = QUANT_IQUANT_SHIFT - QUANT_SHIFT - transformShift;
 
         int cmp_size = sizeof(int) * height * width;
+        int index = rand() % TEST_CASES;
 
-        ref(mintbuf1 + j, mintbuf3, width * height, scale, shift);
-        opt(mintbuf1 + j, mintbuf4, width * height, scale, shift);
+        ref(int_test_buff[index] + j, mintbuf3, width * height, scale, shift);
+        opt(int_test_buff[index] + j, mintbuf4, width * height, scale, shift);
 
         if (memcmp(mintbuf3, mintbuf4, cmp_size))
             return false;
@@ -250,9 +288,11 @@
         int shift = QUANT_IQUANT_SHIFT - QUANT_SHIFT - transformShift;
 
         int cmp_size = sizeof(int) * height * width;
+        int index1 = rand() % TEST_CASES;
+        int index2 = rand() % TEST_CASES;
 
-        ref(mintbuf1 + j, mintbuf3, mintbuf2 + j, width * height, per, shift);
-        opt(mintbuf1 + j, mintbuf4, mintbuf2 + j, width * height, per, shift);
+        ref(int_test_buff[index1] + j, mintbuf3, int_test_buff[index2] + j, width * height, per, shift);
+        opt(int_test_buff[index1] + j, mintbuf4, int_test_buff[index2] + j, width * height, per, shift);
 
         if (memcmp(mintbuf3, mintbuf4, cmp_size))
             return false;
@@ -270,14 +310,6 @@
 bool MBDstHarness::check_quant_primitive(quant_t ref, quant_t opt)
 {
     int j = 0;
-
-    // fill again to avoid error Q value
-    for (int i = 0; i < mb_t_size; i++)
-    {
-        mintbuf1[i] = rand() & PIXEL_MAX;
-        mintbuf2[i] = rand() & PIXEL_MAX;
-    }
-
     for (int i = 0; i <= ITERS; i++)
     {
         int width = (rand() % 4 + 1) * 4;
@@ -297,8 +329,11 @@
         int numCoeff = height * width;
         int optLastPos = -1, refLastPos = -1;
 
-        refReturnValue = ref(mintbuf1 + j, mintbuf2 + j, mintbuf5, mintbuf6, bits, valueToAdd, numCoeff, &refLastPos);
-        optReturnValue = opt(mintbuf1 + j, mintbuf2 + j, mintbuf3, mintbuf4, bits, valueToAdd, numCoeff, &optLastPos);
+        int index1 = rand() % TEST_CASES;
+        int index2 = rand() % TEST_CASES;
+
+        refReturnValue = ref(int_test_buff[index1] + j, int_test_buff[index2] + j, mintbuf5, mintbuf6, bits, valueToAdd, numCoeff, &refLastPos);
+        optReturnValue = opt(int_test_buff[index1] + j, int_test_buff[index2] + j, mintbuf3, mintbuf4, bits, valueToAdd, numCoeff, &optLastPos);
 
         if (memcmp(mintbuf3, mintbuf5, cmp_size))
             return false;
@@ -379,7 +414,7 @@
         if (opt.dct[value])
         {
             printf("%s\t", DctConf_infos[value].name);
-            REPORT_SPEEDUP(opt.dct[value], ref.dct[value], mbuf1, mintbuf1, DctConf_infos[value].width);
+            REPORT_SPEEDUP(opt.dct[value], ref.dct[value], mbuf1, mintbuf3, DctConf_infos[value].width);
         }
     }
 
diff -r df4531a24c4d -r 60bdec044f33 source/test/mbdstharness.h
--- a/source/test/mbdstharness.h	Thu Feb 13 02:48:38 2014 -0600
+++ b/source/test/mbdstharness.h	Thu Feb 13 19:28:30 2014 +0530
@@ -34,9 +34,8 @@
 {
 protected:
 
-    int16_t *mbuf1, *mbuf2, *mbuf3, *mbuf4, *mbufdct;
-    int *mbufidct;
-    int *mintbuf1, *mintbuf2, *mintbuf3, *mintbuf4, *mintbuf5, *mintbuf6, *mintbuf7, *mintbuf8;
+    int16_t *mbuf1, *mbuf2, *mbuf3, *mbuf4, *mbufdct, **short_test_buff;
+    int *mbufidct, *mintbuf1, *mintbuf2, *mintbuf3, *mintbuf4, *mintbuf5, *mintbuf6, *mintbuf7, *mintbuf8, **int_test_buff;
     static const int mb_t_size = 6400;
     static const int mem_cmp_size = 32 * 32;
 


More information about the x265-devel mailing list