]> granicus.if.org Git - libvpx/commitdiff
Enable test system to detect transforms misusing 'stride' parameter
authorDavid Barker <david.barker@argondesign.com>
Thu, 13 Oct 2016 14:10:14 +0000 (15:10 +0100)
committerDavid Barker <david.barker@argondesign.com>
Thu, 13 Oct 2016 14:50:44 +0000 (15:50 +0100)
This would have caught the bug introduced in patch set 1 of
https://chromium-review.googlesource.com/#/c/397378/

Change-Id: I9c6d5d9c4c98aed5ac48c4fb1c4ff4131b0df1d5

13 files changed:
test/av1_fht16x16_test.cc
test/av1_fht16x32_test.cc
test/av1_fht16x8_test.cc
test/av1_fht32x16_test.cc
test/av1_fht4x4_test.cc
test/av1_fht4x8_test.cc
test/av1_fht8x16_test.cc
test/av1_fht8x4_test.cc
test/av1_fht8x8_test.cc
test/av1_iht16x8_test.cc
test/av1_iht8x16_test.cc
test/fdct4x4_test.cc
test/transform_test_base.h

index 51fead7bd07dc8599fe0292a3c7b6c5a16001e65..4a44e16d74ed2d2baa79f6fde32ff816bbf6ec55 100644 (file)
@@ -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;
index 9a55f3d59544501092107ca7c739d7a64a1343f5..8ff96b39b0e91e18ae9e6a6b15e66dffb58bc357 100644 (file)
@@ -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);
index 3917bf59a9ae37558e1c40cadca4aa101f450ae8..df429e1565f309b4f0ca1b6bdcee8c129a49ebe5 100644 (file)
@@ -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;
index 3a7ca9b6de216ddc70d3a5042c98ceb517d00302..41c0b1cade2c6f09bf31271059d30bad14f15ffd 100644 (file)
@@ -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);
index 104b86527caf0631ad2ee7683edf545c6ddfbcb3..075646c71376f5e97ea4f574de06f2f39d78c8a9 100644 (file)
@@ -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;
index a344532584b9b7d22c070d713bec7e84395cb3a5..4a5f3ff1ab888e8817077a238161dcb53af1d77a 100644 (file)
@@ -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);
index be50d7cbfe061ec0ccfe58c9e16fd7bace98d2e5..40390e5b29c50c0292643ec69c086a653743e125 100644 (file)
@@ -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;
index ee89e96485244e4d836a806cab6f74f0920551c5..46e8c624a05f960402470180ef59d303d855bde6 100644 (file)
@@ -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);
index 3e8a4c8294915de25ba2d4b6b8352e2316b7bfb9..54cb405e28e3be56344a971299ba344a9aae9f05 100644 (file)
@@ -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;
index 0d4406d4b054931b8b3939b264ac45eb027d93b9..60adb333f93107472ed08eb0614b0faab31a3e94 100644 (file)
@@ -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);
index 21fdc6b6d23a60828a2e6b76797a4c47dc51fcae..feb573577a94b8c1215b915a7956f8a73bc90999 100644 (file)
@@ -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);
index 471f5b4338bd84c0844325475b183504f67b5905..f7b093256e69e5481e03d1edfb03d333a0ffcbd1 100644 (file)
@@ -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;
index fd39d338a583f0a6ec2df028871e04c16623dcd2..195058ee97e37f50ccf3dd235103854343783974 100644 (file)
@@ -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;