[x265] [PATCH 4 of 6] testbench: fix testbench crash when no coeff in block

Min Chen chenm003 at 163.com
Wed Apr 22 15:31:58 CEST 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1429709475 -28800
# Node ID 563f0e586018fc223d499a6418d9210fb68d4a7e
# Parent  205207ec0a85858b50f7e0e7ddd7367090e79131
testbench: fix testbench crash when no coeff in block
---
 source/test/pixelharness.cpp |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff -r 205207ec0a85 -r 563f0e586018 source/test/pixelharness.cpp
--- a/source/test/pixelharness.cpp	Wed Apr 22 21:31:11 2015 +0800
+++ b/source/test/pixelharness.cpp	Wed Apr 22 21:31:15 2015 +0800
@@ -1211,7 +1211,13 @@
     for (int i = 0; i < 32 * 32; i++)
     {
         ref_src[i] = rand() & SHORT_MAX;
-        if (rand() & 1)
+
+        // more zero coeff
+        if (ref_src[i] < SHORT_MAX * 2 / 3)
+            ref_src[i] = 0;
+
+        // more negtive
+        if ((rand() % 10) < 8)
             ref_src[i] *= -1;
         totalCoeffs += (ref_src[i] != 0);
     }
@@ -1240,6 +1246,13 @@
         for (int j = 0; j < 1 << (2 * (rand_scan_size + 2)); j++)
             rand_numCoeff += (ref_src[i + j] != 0);
 
+        // at least one coeff in transform block
+        if (rand_numCoeff == 0)
+        {
+            ref_src[i + (1 << (2 * (rand_scan_size + 2))) - 1] = -1;
+            rand_numCoeff = 1;
+        }
+
         const int trSize = (1 << (rand_scan_size + 2));
         const uint16_t* const scanTbl = g_scanOrder[rand_scan_type][rand_scan_size];
         const uint16_t* const scanTblCG4x4 = g_scan4x4[rand_scan_type];
@@ -1264,6 +1277,9 @@
             rand_numCoeff -= ref_coeffNum[j];
         }
 
+        if (rand_numCoeff != 0)
+            return false;
+
         reportfail();
     }
 



More information about the x265-devel mailing list