Commit 089315fc authored by Debargha Mukherjee's avatar Debargha Mukherjee Committed by Gerrit Code Review
Browse files

Merge "Enable test system to detect transforms misusing 'stride' parameter" into nextgenv2

parents a720f4b3 7825022d
......@@ -68,6 +68,7 @@ class AV1Trans16x16HT : public libaom_test::TransformTestBase,
inv_txfm_ = GET_PARAM(1);
tx_type_ = GET_PARAM(2);
pitch_ = 16;
height_ = 16;
fwd_txfm_ref = fht16x16_ref;
bit_depth_ = GET_PARAM(3);
mask_ = (1 << bit_depth_) - 1;
......
......@@ -47,6 +47,7 @@ class AV1Trans16x32HT : public libaom_test::TransformTestBase,
inv_txfm_ = GET_PARAM(1);
tx_type_ = GET_PARAM(2);
pitch_ = 16;
height_ = 32;
fwd_txfm_ref = fht16x32_ref;
inv_txfm_ref = iht16x32_ref;
bit_depth_ = GET_PARAM(3);
......
......@@ -43,6 +43,7 @@ class AV1Trans16x8HT : public libaom_test::TransformTestBase,
inv_txfm_ = GET_PARAM(1);
tx_type_ = GET_PARAM(2);
pitch_ = 16;
height_ = 8;
fwd_txfm_ref = fht16x8_ref;
bit_depth_ = GET_PARAM(3);
mask_ = (1 << bit_depth_) - 1;
......
......@@ -47,6 +47,7 @@ class AV1Trans32x16HT : public libaom_test::TransformTestBase,
inv_txfm_ = GET_PARAM(1);
tx_type_ = GET_PARAM(2);
pitch_ = 32;
height_ = 16;
fwd_txfm_ref = fht32x16_ref;
inv_txfm_ref = iht32x16_ref;
bit_depth_ = GET_PARAM(3);
......
......@@ -59,6 +59,7 @@ class AV1Trans4x4HT : public libaom_test::TransformTestBase,
inv_txfm_ = GET_PARAM(1);
tx_type_ = GET_PARAM(2);
pitch_ = 4;
height_ = 4;
fwd_txfm_ref = fht4x4_ref;
bit_depth_ = GET_PARAM(3);
mask_ = (1 << bit_depth_) - 1;
......
......@@ -47,6 +47,7 @@ class AV1Trans4x8HT : public libaom_test::TransformTestBase,
inv_txfm_ = GET_PARAM(1);
tx_type_ = GET_PARAM(2);
pitch_ = 4;
height_ = 8;
fwd_txfm_ref = fht4x8_ref;
inv_txfm_ref = iht4x8_ref;
bit_depth_ = GET_PARAM(3);
......
......@@ -43,6 +43,7 @@ class AV1Trans8x16HT : public libaom_test::TransformTestBase,
inv_txfm_ = GET_PARAM(1);
tx_type_ = GET_PARAM(2);
pitch_ = 8;
height_ = 16;
fwd_txfm_ref = fht8x16_ref;
bit_depth_ = GET_PARAM(3);
mask_ = (1 << bit_depth_) - 1;
......
......@@ -47,6 +47,7 @@ class AV1Trans8x4HT : public libaom_test::TransformTestBase,
inv_txfm_ = GET_PARAM(1);
tx_type_ = GET_PARAM(2);
pitch_ = 8;
height_ = 4;
fwd_txfm_ref = fht8x4_ref;
inv_txfm_ref = iht8x4_ref;
bit_depth_ = GET_PARAM(3);
......
......@@ -58,6 +58,7 @@ class AV1Trans8x8HT : public libaom_test::TransformTestBase,
inv_txfm_ = GET_PARAM(1);
tx_type_ = GET_PARAM(2);
pitch_ = 8;
height_ = 8;
fwd_txfm_ref = fht8x8_ref;
bit_depth_ = GET_PARAM(3);
mask_ = (1 << bit_depth_) - 1;
......
......@@ -44,7 +44,8 @@ class AV1Trans16x8IHT : public libaom_test::TransformTestBase,
virtual void SetUp() {
inv_txfm_ = GET_PARAM(0);
tx_type_ = GET_PARAM(1);
pitch_ = 8;
pitch_ = 16;
height_ = 8;
inv_txfm_ref = iht16x8_ref;
fwd_txfm_ref = fht16x8_ref;
bit_depth_ = GET_PARAM(2);
......
......@@ -45,6 +45,7 @@ class AV1Trans8x16IHT : public libaom_test::TransformTestBase,
inv_txfm_ = GET_PARAM(0);
tx_type_ = GET_PARAM(1);
pitch_ = 8;
height_ = 16;
inv_txfm_ref = iht8x16_ref;
fwd_txfm_ref = fht8x16_ref;
bit_depth_ = GET_PARAM(2);
......
......@@ -100,6 +100,7 @@ class Trans4x4DCT : public libaom_test::TransformTestBase,
inv_txfm_ = GET_PARAM(1);
tx_type_ = GET_PARAM(2);
pitch_ = 4;
height_ = 4;
fwd_txfm_ref = fdct4x4_ref;
bit_depth_ = GET_PARAM(3);
mask_ = (1 << bit_depth_) - 1;
......@@ -137,6 +138,7 @@ class Trans4x4HT : public libaom_test::TransformTestBase,
inv_txfm_ = GET_PARAM(1);
tx_type_ = GET_PARAM(2);
pitch_ = 4;
height_ = 4;
fwd_txfm_ref = fht4x4_ref;
bit_depth_ = GET_PARAM(3);
mask_ = (1 << bit_depth_) - 1;
......@@ -175,6 +177,7 @@ class Trans4x4WHT : public libaom_test::TransformTestBase,
inv_txfm_ = GET_PARAM(1);
tx_type_ = GET_PARAM(2);
pitch_ = 4;
height_ = 4;
fwd_txfm_ref = fwht4x4_ref;
bit_depth_ = GET_PARAM(3);
mask_ = (1 << bit_depth_) - 1;
......
......@@ -123,33 +123,46 @@ class TransformTestBase {
ACMRandom rnd(ACMRandom::DeterministicSeed());
const int count_test_block = 5000;
// Use a stride value which is not the width of any transform, to catch
// cases where the transforms use the stride incorrectly.
int stride = 96;
int16_t *input_block = reinterpret_cast<int16_t *>(
aom_memalign(16, sizeof(int16_t) * num_coeffs_));
aom_memalign(16, sizeof(int16_t) * stride * height_));
tran_low_t *output_ref_block = reinterpret_cast<tran_low_t *>(
aom_memalign(16, sizeof(tran_low_t) * num_coeffs_));
tran_low_t *output_block = reinterpret_cast<tran_low_t *>(
aom_memalign(16, sizeof(tran_low_t) * num_coeffs_));
for (int i = 0; i < count_test_block; ++i) {
for (int j = 0; j < num_coeffs_; ++j) {
input_block[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_);
if (bit_depth_ == AOM_BITS_8) {
output_block[j] = output_ref_block[j] = rnd.Rand8();
int j, k;
for (j = 0; j < height_; ++j) {
for (k = 0; k < pitch_; ++k) {
int in_idx = j * stride + k;
int out_idx = j * pitch_ + k;
input_block[in_idx] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_);
if (bit_depth_ == AOM_BITS_8) {
output_block[out_idx] = output_ref_block[out_idx] = rnd.Rand8();
#if CONFIG_AOM_HIGHBITDEPTH
} else {
output_block[j] = output_ref_block[j] = rnd.Rand16() & mask_;
} else {
output_block[out_idx] = output_ref_block[out_idx] =
rnd.Rand16() & mask_;
#endif
}
}
}
fwd_txfm_ref(input_block, output_ref_block, pitch_, tx_type_);
ASM_REGISTER_STATE_CHECK(RunFwdTxfm(input_block, output_block, pitch_));
fwd_txfm_ref(input_block, output_ref_block, stride, tx_type_);
ASM_REGISTER_STATE_CHECK(RunFwdTxfm(input_block, output_block, stride));
// The minimum quant value is 4.
for (int j = 0; j < num_coeffs_; ++j) {
ASSERT_EQ(output_block[j], output_ref_block[j])
<< "Error: not bit-exact result at index: " << j
<< " at test block: " << i;
for (j = 0; j < height_; ++j) {
for (k = 0; k < pitch_; ++k) {
int out_idx = j * pitch_ + k;
ASSERT_EQ(output_block[out_idx], output_ref_block[out_idx])
<< "Error: not bit-exact result at index: " << out_idx
<< " at test block: " << i;
}
}
}
aom_free(input_block);
......@@ -161,32 +174,44 @@ class TransformTestBase {
ACMRandom rnd(ACMRandom::DeterministicSeed());
const int count_test_block = 5000;
// Use a stride value which is not the width of any transform, to catch
// cases where the transforms use the stride incorrectly.
int stride = 96;
int16_t *input_block = reinterpret_cast<int16_t *>(
aom_memalign(16, sizeof(int16_t) * num_coeffs_));
tran_low_t *trans_block = reinterpret_cast<tran_low_t *>(
aom_memalign(16, sizeof(tran_low_t) * num_coeffs_));
uint8_t *output_block = reinterpret_cast<uint8_t *>(
aom_memalign(16, sizeof(uint8_t) * num_coeffs_));
aom_memalign(16, sizeof(uint8_t) * stride * height_));
uint8_t *output_ref_block = reinterpret_cast<uint8_t *>(
aom_memalign(16, sizeof(uint8_t) * num_coeffs_));
aom_memalign(16, sizeof(uint8_t) * stride * height_));
for (int i = 0; i < count_test_block; ++i) {
// Initialize a test block with input range [-mask_, mask_].
for (int j = 0; j < num_coeffs_; ++j) {
input_block[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_);
output_ref_block[j] = rnd.Rand16() & mask_;
output_block[j] = output_ref_block[j];
int j, k;
for (j = 0; j < height_; ++j) {
for (k = 0; k < pitch_; ++k) {
int in_idx = j * pitch_ + k;
int out_idx = j * stride + k;
input_block[in_idx] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_);
output_ref_block[out_idx] = rnd.Rand16() & mask_;
output_block[out_idx] = output_ref_block[out_idx];
}
}
fwd_txfm_ref(input_block, trans_block, pitch_, tx_type_);
inv_txfm_ref(trans_block, output_ref_block, pitch_, tx_type_);
ASM_REGISTER_STATE_CHECK(RunInvTxfm(trans_block, output_block, pitch_));
inv_txfm_ref(trans_block, output_ref_block, stride, tx_type_);
ASM_REGISTER_STATE_CHECK(RunInvTxfm(trans_block, output_block, stride));
for (int j = 0; j < num_coeffs_; ++j) {
ASSERT_EQ(output_block[j], output_ref_block[j])
<< "Error: not bit-exact result at index: " << j
<< " at test block: " << i;
for (j = 0; j < height_; ++j) {
for (k = 0; k < pitch_; ++k) {
int out_idx = j * stride + k;
ASSERT_EQ(output_block[out_idx], output_ref_block[out_idx])
<< "Error: not bit-exact result at index: " << out_idx
<< " at test block: " << i;
}
}
}
aom_free(input_block);
......@@ -305,6 +330,7 @@ class TransformTestBase {
}
int pitch_;
int height_;
int tx_type_;
FhtFunc fwd_txfm_ref;
IhtFunc inv_txfm_ref;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment