[x265] [PATCH] testbench: fix bug in generate weight input data

Min Chen chenm003 at 163.com
Mon Jan 5 09:20:29 CET 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1420446007 -28800
# Node ID 2fd5ed831fa5b23294f165fbfa052e4bc8ffc7e5
# Parent  f255e8d06423231cb8c58ab5d3b10de7fb27b424
testbench: fix bug in generate weight input data
---
 source/test/pixelharness.cpp |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff -r f255e8d06423 -r 2fd5ed831fa5 source/test/pixelharness.cpp
--- a/source/test/pixelharness.cpp	Fri Jan 02 18:22:38 2015 +0530
+++ b/source/test/pixelharness.cpp	Mon Jan 05 16:20:07 2015 +0800
@@ -250,15 +250,16 @@
     int width = 2 * (rand() % 32 + 1);
     int height = 8;
     int w0 = rand() % 128;
-    int shift = rand() % 15;
+    int shift = rand() % 8; // maximum is 7, see setFromWeightAndOffset()
     int round = shift ? (1 << (shift - 1)) : 0;
     int offset = (rand() % 256) - 128;
     intptr_t stride = 64;
+    const int correction = (IF_INTERNAL_PREC - X265_DEPTH);
     for (int i = 0; i < ITERS; i++)
     {
         int index = i % TEST_CASES;
-        checked(opt, short_test_buff[index] + j, opt_dest, stride, stride, width, height, w0, round, shift, offset);
-        ref(short_test_buff[index] + j, ref_dest, stride, stride, width, height, w0, round, shift, offset);
+        checked(opt, short_test_buff[index] + j, opt_dest, stride, stride, width, height, w0, round << correction, shift + correction, offset);
+        ref(short_test_buff[index] + j, ref_dest, stride, stride, width, height, w0, round << correction, shift + correction, offset);
 
         if (memcmp(ref_dest, opt_dest, 64 * 64 * sizeof(pixel)))
             return false;
@@ -281,15 +282,16 @@
     int width = 16 * (rand() % 4 + 1);
     int height = 8;
     int w0 = rand() % 128;
-    int shift = rand() % 15;
+    int shift = rand() % 8; // maximum is 7, see setFromWeightAndOffset()
     int round = shift ? (1 << (shift - 1)) : 0;
     int offset = (rand() % 256) - 128;
     intptr_t stride = 64;
+    const int correction = (IF_INTERNAL_PREC - X265_DEPTH);
     for (int i = 0; i < ITERS; i++)
     {
         int index = i % TEST_CASES;
-        checked(opt, pixel_test_buff[index] + j, opt_dest, stride, width, height, w0, round, shift, offset);
-        ref(pixel_test_buff[index] + j, ref_dest, stride, width, height, w0, round, shift, offset);
+        checked(opt, pixel_test_buff[index] + j, opt_dest, stride, width, height, w0, round << correction, shift + correction, offset);
+        ref(pixel_test_buff[index] + j, ref_dest, stride, width, height, w0, round << correction, shift + correction, offset);
 
         if (memcmp(ref_dest, opt_dest, 64 * 64 * sizeof(pixel)))
             return false;



More information about the x265-devel mailing list