[x265] [PATCH] Test code for xCalQuantCoefEAdp

praveen at multicorewareinc.com praveen at multicorewareinc.com
Thu Jun 27 14:30:28 CEST 2013


# HG changeset patch
# User praveentiwari
# Date 1372336213 -19800
# Node ID 636817b0f2b65010fcdc4d29a8a077652573784b
# Parent  2e227fd23fe25e9fe6dfcca2f1dac21474f4a7a0
Test code for xCalQuantCoefEAdp

diff -r 2e227fd23fe2 -r 636817b0f2b6 source/test/mbdstharness.cpp
--- a/source/test/mbdstharness.cpp	Thu Jun 27 17:57:42 2013 +0530
+++ b/source/test/mbdstharness.cpp	Thu Jun 27 18:00:13 2013 +0530
@@ -68,6 +68,10 @@
     mintbuf2 = (int*)TestHarness::alignedMalloc(sizeof(int), mb_t_size, 32);
     mintbuf3 = (int*)TestHarness::alignedMalloc(sizeof(int), mem_cmp_size, 32);
     mintbuf4 = (int*)TestHarness::alignedMalloc(sizeof(int), mem_cmp_size, 32);
+    mintbuf5 = (int*)TestHarness::alignedMalloc(sizeof(int), mem_cmp_size, 32);
+    mintbuf6 = (int*)TestHarness::alignedMalloc(sizeof(int), mem_cmp_size, 32);
+    mintbuf7 = (int*)TestHarness::alignedMalloc(sizeof(int), mem_cmp_size, 32);
+    mintbuf8 = (int*)TestHarness::alignedMalloc(sizeof(int), mem_cmp_size, 32);
 
     if (!mbuf1 || !mbuf2 || !mbuf3 || !mbuf4 || !mbufdct)
     {
@@ -75,7 +79,7 @@
         exit(1);
     }
 
-    if (!mintbuf1 || !mintbuf2 || !mintbuf3 || !mintbuf4)
+    if (!mintbuf1 || !mintbuf2 || !mintbuf3 || !mintbuf4 || !mintbuf5 || !mintbuf6 || !mintbuf7 || !mintbuf8)
     {
         fprintf(stderr, "malloc failed, unable to initiate tests!\n");
         exit(1);
@@ -103,7 +107,11 @@
 
     memset(mintbuf3, 0, mem_cmp_size);
     memset(mintbuf4, 0, mem_cmp_size);
-#endif
+    memset(mintbuf5, 0, mem_cmp_size);
+    memset(mintbuf6, 0, mem_cmp_size);
+    memset(mintbuf7, 0, mem_cmp_size);
+    memset(mintbuf8, 0, mem_cmp_size);
+#endif // if _DEBUG
 }
 
 MBDstHarness::~MBDstHarness()
@@ -119,6 +127,10 @@
     TestHarness::alignedFree(mintbuf2);
     TestHarness::alignedFree(mintbuf3);
     TestHarness::alignedFree(mintbuf4);
+    TestHarness::alignedFree(mintbuf5);
+    TestHarness::alignedFree(mintbuf6);
+    TestHarness::alignedFree(mintbuf7);
+    TestHarness::alignedFree(mintbuf8);
 }
 
 bool MBDstHarness::check_dct_primitive(dct_t ref, dct_t opt, int width)
@@ -221,6 +233,59 @@
     return true;
 }
 
+bool MBDstHarness::check_xCalQuantCoefEAdp_primitive(quantCoefEAdp ref, quantCoefEAdp opt)
+{
+    int j = 0;
+
+    for (int i = 0; i <= 5; i++)
+    {
+        int iWidth = (rand() % 4 + 1) * 4;
+
+        if (iWidth == 12)
+        {
+            iWidth = 32;
+        }
+        int iHeight = iWidth;
+
+        unsigned int tmp1 = 0;
+        unsigned int tmp2 = 0;
+
+        int iQBitsC = rand() % 15;
+        int iQBits = rand() % 23;
+        int iAdd = rand() % 2147483647;
+        int cmp_size = sizeof(int) * iWidth * iWidth;
+        int numCoeff = iHeight * iWidth;
+
+        tmp1 = opt(mintbuf1 + j, mintbuf2 + j, mintbuf3, mintbuf4, mintbuf5, iQBitsC, iQBits, iAdd, numCoeff);
+        tmp2 = ref(mintbuf1 + j, mintbuf2 + j, mintbuf6, mintbuf7, mintbuf8, iQBitsC, iQBits, iAdd, numCoeff);
+
+        if (memcmp(mintbuf3, mintbuf6, cmp_size))
+            return false;
+
+        if (memcmp(mintbuf4, mintbuf7, cmp_size))
+            return false;
+
+        if (memcmp(mintbuf5, mintbuf8, cmp_size))
+            return false;
+
+        if (tmp1 != tmp2)
+            return false;
+
+        j += 16;
+
+#if _DEBUG
+        memset(mintbuf3, 0, mem_cmp_size);
+        memset(mintbuf4, 0, mem_cmp_size);
+        memset(mintbuf5, 0, mem_cmp_size);
+        memset(mintbuf6, 0, mem_cmp_size);
+        memset(mintbuf7, 0, mem_cmp_size);
+        memset(mintbuf8, 0, mem_cmp_size);
+#endif
+    }
+
+    return true;
+}
+
 bool MBDstHarness::testCorrectness(const EncoderPrimitives& ref, const EncoderPrimitives& opt)
 {
     for (int i = 0; i < NUM_DCTS; i++)
@@ -256,6 +321,15 @@
         }
     }
 
+    if (opt.calQuantCoefEAdp)
+    {
+        if (!check_xCalQuantCoefEAdp_primitive(ref.calQuantCoefEAdp, opt.calQuantCoefEAdp))
+        {
+            printf("xCalQuantCoefEAdp: Failed!\n");
+            return false;
+        }
+    }
+
     return true;
 }
 
@@ -284,4 +358,10 @@
         printf("xDeQuant\t\t");
         REPORT_SPEEDUP(opt.deQuant, ref.deQuant, 8, mintbuf1, mintbuf3, 32, 32, 5, 2, false, 5, mintbuf2);
     }
+
+    if (opt.calQuantCoefEAdp)
+    {
+        printf("xCalQuantCoefEAdp\t");
+        REPORT_SPEEDUP(ref.calQuantCoefEAdp, opt.calQuantCoefEAdp, mintbuf1, mintbuf2, mintbuf3, mintbuf4, mintbuf5, 15, 23, 23785, 32 * 32);
+    }
 }
diff -r 2e227fd23fe2 -r 636817b0f2b6 source/test/mbdstharness.h
--- a/source/test/mbdstharness.h	Thu Jun 27 17:57:42 2013 +0530
+++ b/source/test/mbdstharness.h	Thu Jun 27 18:00:13 2013 +0530
@@ -34,11 +34,12 @@
 
     short *mbuf1, *mbuf2, *mbuf3, *mbuf4, *mbufdct;
     int *mbufidct;
-    int *mintbuf1, *mintbuf2, *mintbuf3, *mintbuf4;
+    int *mintbuf1, *mintbuf2, *mintbuf3, *mintbuf4, *mintbuf5, *mintbuf6, *mintbuf7, *mintbuf8;
     static const int mb_t_size = 6400;
     static const int mem_cmp_size = 32 * 32;
 
     bool check_xdequant_primitive(x265::quant ref, x265::quant opt);
+    bool check_xCalQuantCoefEAdp_primitive(x265::quantCoefEAdp ref, x265::quantCoefEAdp opt);
     bool check_dct_primitive(x265::dct_t ref, x265::dct_t opt, int width);
     bool check_idct_primitive(x265::idct_t ref, x265::idct_t opt, int width);
 


More information about the x265-devel mailing list