[x265] [PATCH 3/3] testbench: Fix pixel harness weight_sp function input value range

Gerda Zsejke More GerdaZsejke.More at arm.com
Fri Jul 25 14:01:09 UTC 2025


Hi Chen,

Thank you for your feedback! I've reviewed the specification as well, and I'm wondering — doesn't the part you sent (8.5.3.3.4.2) refer to the output values of the weight_sp function? I re-ran the encodings to double-check, and I still see values that fall outside the tested range.

Thanks, Gerda

>In the HEVC specification, the value of pixel clips to bitDepth









>pbSamples[ x ][ y ] = Clip3( 0, ( 1  <<  bitDepth ) − 1,









>Regards,

>Chen



>At 2025-07-09 19:48:58, "Gerda Zsejke More" <gerdazsejke.more > at arm.com<https://mailman.videolan.org/listinfo/x265-devel>> wrote:

>The existing unit tests assumes that the weight_sp function's input

>data is in the range [SMIN, SMAX]. However running real encodings

>show that values outside of this range can be input values.

>Set the tested value range to [SHORT_MIN, SHORT_MAX].

>

>Change-Id: If83bfacb4232dacf53dacbf52ee874a53415bd59

>---

> source/test/pixelharness.cpp | 9 ++++++---

> source/test/pixelharness.h   | 1 +

> 2 files changed, 7 insertions(+), 3 deletions(-)

>

>diff --git a/source/test/pixelharness.cpp b/source/test/pixelharness.cpp

>index e37ae3cb7..c396623ef 100644

>--- a/source/test/pixelharness.cpp

>+++ b/source/test/pixelharness.cpp

>@@ -39,6 +39,7 @@ PixelHarness::PixelHarness()

>         short_test_buff[0][i]   = (rand() % (2 * SMAX + 1)) - SMAX - 1; // max(SHORT_MIN, min(rand(), SMAX));

>         short_test_buff1[0][i]  = rand() & PIXEL_MAX;                   // For block copy only

>         short_test_buff2[0][i]  = rand() % 16383;                       // for addAvg

>+        short_test_buff3[0][i]  = rand() % SHORT_MAX;                   // for weight_sp

>         int_test_buff[0][i]     = rand() % SHORT_MAX;

>         ushort_test_buff[0][i]  = rand() % ((1 << 16) - 1);

>         uchar_test_buff[0][i]   = rand() % ((1 << 8) - 1);

>@@ -48,6 +49,7 @@ PixelHarness::PixelHarness()

>         short_test_buff[1][i]   = (int16_t)SMIN;

>         short_test_buff1[1][i]  = PIXEL_MIN;

>         short_test_buff2[1][i]  = -16384;

>+        short_test_buff3[1][i]  = SHORT_MIN;

>         int_test_buff[1][i]     = SHORT_MIN;

>         ushort_test_buff[1][i]  = PIXEL_MIN;

>         uchar_test_buff[1][i]   = PIXEL_MIN;

>@@ -58,6 +60,7 @@ PixelHarness::PixelHarness()

>         short_test_buff[2][i]   = SMAX;

>         short_test_buff1[2][i]  = PIXEL_MAX;

>         short_test_buff2[2][i]  = 16383;

>+        short_test_buff3[2][i]  = SHORT_MAX;

>         int_test_buff[2][i]     = SHORT_MAX;

>         ushort_test_buff[2][i]  = ((1 << 16) - 1);

>         uchar_test_buff[2][i]   = 255;

>@@ -308,12 +311,12 @@ bool PixelHarness::check_weightp(weightp_sp_t ref, weightp_sp_t opt)

>     for (int i = 0; i < ITERS; i++)

>     {

>         int index = i % TEST_CASES;

>-        checked(opt, short_test_buff[index] + j, opt_dest, stride, stride + 1, width, height, w0, round << correction, shift + correction, offset);

>-        ref(short_test_buff[index] + j, ref_dest, stride, stride + 1, width, height, w0, round << correction, shift + correction, offset);

>+        checked(opt, short_test_buff3[index] + j, opt_dest, stride, stride + 1, width, height, w0, round << correction, shift + correction, offset);

>+        ref(short_test_buff3[index] + j, ref_dest, stride, stride + 1, width, height, w0, round << correction, shift + correction, offset);

>

>         if (memcmp(ref_dest, opt_dest, 64 * 64 * sizeof(pixel)))

>         {

>-            opt(short_test_buff[index] + j, opt_dest, stride, stride + 1, width, height, w0, round << correction, shift + correction, offset);

>+            opt(short_test_buff3[index] + j, opt_dest, stride, stride + 1, width, height, w0, round << correction, shift + correction, offset);

>             return false;

>         }

>

>diff --git a/source/test/pixelharness.h b/source/test/pixelharness.h

>index 5dd354029..1067bf774 100644

>--- a/source/test/pixelharness.h

>+++ b/source/test/pixelharness.h

>@@ -63,6 +63,7 @@ protected:

>     ALIGN_VAR_64(int16_t,  short_test_buff[TEST_CASES][BUFFSIZE]);

>     ALIGN_VAR_64(int16_t,  short_test_buff1[TEST_CASES][BUFFSIZE]);

>     ALIGN_VAR_64(int16_t,  short_test_buff2[TEST_CASES][BUFFSIZE]);

>+    ALIGN_VAR_64(int16_t,  short_test_buff3[TEST_CASES][BUFFSIZE]);

>     ALIGN_VAR_64(int,      int_test_buff[TEST_CASES][BUFFSIZE]);

>     ALIGN_VAR_64(uint16_t, ushort_test_buff[TEST_CASES][BUFFSIZE]);

>     ALIGN_VAR_64(uint8_t,  uchar_test_buff[TEST_CASES][BUFFSIZE]);

>--

>2.39.5 (Apple Git-154)

>

----

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20250725/a952b7d0/attachment-0001.htm>


More information about the x265-devel mailing list