Enable test system to detect transforms misusing 'stride' parameter
This would have caught the bug introduced in patch set 1 of
https://chromium-review.googlesource.com/#/c/397378/
Change-Id: I9c6d5d9c4c98aed5ac48c4fb1c4ff4131b0df1d5
diff --git a/test/av1_fht16x16_test.cc b/test/av1_fht16x16_test.cc
index 51fead7..4a44e16 100644
--- a/test/av1_fht16x16_test.cc
+++ b/test/av1_fht16x16_test.cc
@@ -68,6 +68,7 @@
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;
diff --git a/test/av1_fht16x32_test.cc b/test/av1_fht16x32_test.cc
index 9a55f3d..8ff96b3 100644
--- a/test/av1_fht16x32_test.cc
+++ b/test/av1_fht16x32_test.cc
@@ -47,6 +47,7 @@
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);
diff --git a/test/av1_fht16x8_test.cc b/test/av1_fht16x8_test.cc
index 3917bf5..df429e1 100644
--- a/test/av1_fht16x8_test.cc
+++ b/test/av1_fht16x8_test.cc
@@ -43,6 +43,7 @@
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;
diff --git a/test/av1_fht32x16_test.cc b/test/av1_fht32x16_test.cc
index 3a7ca9b..41c0b1c 100644
--- a/test/av1_fht32x16_test.cc
+++ b/test/av1_fht32x16_test.cc
@@ -47,6 +47,7 @@
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);
diff --git a/test/av1_fht4x4_test.cc b/test/av1_fht4x4_test.cc
index 104b865..075646c 100644
--- a/test/av1_fht4x4_test.cc
+++ b/test/av1_fht4x4_test.cc
@@ -59,6 +59,7 @@
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;
diff --git a/test/av1_fht4x8_test.cc b/test/av1_fht4x8_test.cc
index a344532..4a5f3ff 100644
--- a/test/av1_fht4x8_test.cc
+++ b/test/av1_fht4x8_test.cc
@@ -47,6 +47,7 @@
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);
diff --git a/test/av1_fht8x16_test.cc b/test/av1_fht8x16_test.cc
index be50d7c..40390e5 100644
--- a/test/av1_fht8x16_test.cc
+++ b/test/av1_fht8x16_test.cc
@@ -43,6 +43,7 @@
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;
diff --git a/test/av1_fht8x4_test.cc b/test/av1_fht8x4_test.cc
index ee89e96..46e8c62 100644
--- a/test/av1_fht8x4_test.cc
+++ b/test/av1_fht8x4_test.cc
@@ -47,6 +47,7 @@
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);
diff --git a/test/av1_fht8x8_test.cc b/test/av1_fht8x8_test.cc
index 3e8a4c8..54cb405 100644
--- a/test/av1_fht8x8_test.cc
+++ b/test/av1_fht8x8_test.cc
@@ -58,6 +58,7 @@
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;
diff --git a/test/av1_iht16x8_test.cc b/test/av1_iht16x8_test.cc
index 0d4406d..60adb33 100644
--- a/test/av1_iht16x8_test.cc
+++ b/test/av1_iht16x8_test.cc
@@ -44,7 +44,8 @@
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);
diff --git a/test/av1_iht8x16_test.cc b/test/av1_iht8x16_test.cc
index 21fdc6b..feb5735 100644
--- a/test/av1_iht8x16_test.cc
+++ b/test/av1_iht8x16_test.cc
@@ -45,6 +45,7 @@
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);
diff --git a/test/fdct4x4_test.cc b/test/fdct4x4_test.cc
index 471f5b4..f7b0932 100644
--- a/test/fdct4x4_test.cc
+++ b/test/fdct4x4_test.cc
@@ -100,6 +100,7 @@
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 @@
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 @@
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;
diff --git a/test/transform_test_base.h b/test/transform_test_base.h
index fd39d33..195058e 100644
--- a/test/transform_test_base.h
+++ b/test/transform_test_base.h
@@ -123,33 +123,46 @@
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 @@
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 @@
}
int pitch_;
+ int height_;
int tx_type_;
FhtFunc fwd_txfm_ref;
IhtFunc inv_txfm_ref;