diff --git a/test/acm_random.h b/test/acm_random.h index 2e9fe56518c..15e8c9cc2e8 100644 --- a/test/acm_random.h +++ b/test/acm_random.h @@ -52,12 +52,6 @@ class ACMRandom { return static_cast(Rand15()) - (1 << 14); } - int16_t Rand13Signed() { - // Use 13 bits: values between 4095 and -4096. - const uint32_t value = random_.Generate(8192); - return static_cast(value) - 4096; - } - uint16_t Rand12() { const uint32_t value = random_.Generate(testing::internal::Random::kMaxRange); @@ -65,12 +59,6 @@ class ACMRandom { return (value >> 19) & 0xfff; } - int16_t Rand9Signed() { - // Use 9 bits: values between 255 (0x0FF) and -256 (0x100). - const uint32_t value = random_.Generate(512); - return static_cast(value) - 256; - } - uint8_t Rand8() { const uint32_t value = random_.Generate(testing::internal::Random::kMaxRange); diff --git a/test/hadamard_test.cc b/test/hadamard_test.cc index 628005babb4..fc306e623d3 100644 --- a/test/hadamard_test.cc +++ b/test/hadamard_test.cc @@ -242,6 +242,12 @@ class HadamardTestBase virtual void SetUp() { rnd_.Reset(ACMRandom::DeterministicSeed()); } + // The Rand() function generates values in the range [-((1 << BitDepth) - 1), + // (1 << BitDepth) - 1]. This is because the input to the Hadamard transform + // is the residual pixel, which is defined as 'source pixel - predicted + // pixel'. Source pixel and predicted pixel take values in the range + // [0, (1 << BitDepth) - 1] and thus the residual pixel ranges from + // -((1 << BitDepth) - 1) to ((1 << BitDepth) - 1). virtual int16_t Rand() = 0; void CompareReferenceRandom() { @@ -344,7 +350,12 @@ class HadamardTestBase class HadamardLowbdTest : public HadamardTestBase { public: HadamardLowbdTest() : HadamardTestBase(GetParam(), /*do_shift=*/true) {} - virtual int16_t Rand() { return rnd_.Rand9Signed(); } + // Use values between -255 (0xFF01) and 255 (0x00FF) + virtual int16_t Rand() { + int16_t src = rnd_.Rand8(); + int16_t pred = rnd_.Rand8(); + return src - pred; + } }; TEST_P(HadamardLowbdTest, CompareReferenceRandom) { CompareReferenceRandom(); } @@ -395,7 +406,12 @@ INSTANTIATE_TEST_SUITE_P( class HadamardHighbdTest : public HadamardTestBase { protected: HadamardHighbdTest() : HadamardTestBase(GetParam(), /*do_shift=*/true) {} - virtual int16_t Rand() { return rnd_.Rand13Signed(); } + // Use values between -4095 (0xF001) and 4095 (0x0FFF) + virtual int16_t Rand() { + int16_t src = rnd_.Rand12(); + int16_t pred = rnd_.Rand12(); + return src - pred; + } }; TEST_P(HadamardHighbdTest, CompareReferenceRandom) { CompareReferenceRandom(); } @@ -430,7 +446,12 @@ INSTANTIATE_TEST_SUITE_P( class HadamardLowbdLPTest : public HadamardTestBase { public: HadamardLowbdLPTest() : HadamardTestBase(GetParam(), /*do_shift=*/false) {} - virtual int16_t Rand() { return rnd_.Rand9Signed(); } + // Use values between -255 (0xFF01) and 255 (0x00FF) + virtual int16_t Rand() { + int16_t src = rnd_.Rand8(); + int16_t pred = rnd_.Rand8(); + return src - pred; + } }; TEST_P(HadamardLowbdLPTest, CompareReferenceRandom) { @@ -475,7 +496,12 @@ class HadamardLowbdLP8x8DualTest public: HadamardLowbdLP8x8DualTest() : HadamardTestBase(GetParam(), /*do_shift=*/false) {} - virtual int16_t Rand() { return rnd_.Rand9Signed(); } + // Use values between -255 (0xFF01) and 255 (0x00FF) + virtual int16_t Rand() { + int16_t src = rnd_.Rand8(); + int16_t pred = rnd_.Rand8(); + return src - pred; + } }; TEST_P(HadamardLowbdLP8x8DualTest, CompareReferenceRandom) {