shithub: libvpx

Download patch

ref: 9578a84205779b5423ccbd9b84e39da639f999fa
parent: 787970a62519a0082dca723224ca757529014b9f
author: Johann <johannkoenig@google.com>
date: Wed Aug 2 06:24:19 EDT 2017

quantize test: consolidate sizes

Pass a max txfm size parameter and combine the base quantize
test with the 32x32 test.

Change-Id: I72ddf020fe6888e864ea9f3642ee2d9a8e48a04b

--- a/test/vp9_quantize_test.cc
+++ b/test/vp9_quantize_test.cc
@@ -16,6 +16,7 @@
 
 #include "./vpx_config.h"
 #include "./vpx_dsp_rtcd.h"
+#include "./vp9_rtcd.h"
 #include "test/acm_random.h"
 #include "test/buffer.h"
 #include "test/clear_system_state.h"
@@ -40,104 +41,130 @@
                              tran_low_t *dqcoeff, const int16_t *dequant,
                              uint16_t *eob, const int16_t *scan,
                              const int16_t *iscan);
-typedef std::tr1::tuple<QuantizeFunc, QuantizeFunc, vpx_bit_depth_t>
+typedef std::tr1::tuple<QuantizeFunc, QuantizeFunc, vpx_bit_depth_t,
+                        int /*max_size*/>
     QuantizeParam;
 
-class VP9QuantizeTest : public ::testing::TestWithParam<QuantizeParam> {
+class VP9QuantizeBase {
  public:
-  virtual ~VP9QuantizeTest() {}
-  virtual void SetUp() {
-    quantize_op_ = GET_PARAM(0);
-    ref_quantize_op_ = GET_PARAM(1);
-    bit_depth_ = GET_PARAM(2);
+  VP9QuantizeBase(vpx_bit_depth_t bit_depth, int max_size)
+      : bit_depth_(bit_depth), max_size_(max_size) {
     max_value_ = (1 << bit_depth_) - 1;
+    zbin_ptr_ =
+        reinterpret_cast<int16_t *>(vpx_memalign(16, 8 * sizeof(*zbin_ptr_)));
+    round_ptr_ =
+        reinterpret_cast<int16_t *>(vpx_memalign(16, 8 * sizeof(*round_ptr_)));
+    quant_ptr_ =
+        reinterpret_cast<int16_t *>(vpx_memalign(16, 8 * sizeof(*quant_ptr_)));
+    quant_shift_ptr_ = reinterpret_cast<int16_t *>(
+        vpx_memalign(16, 8 * sizeof(*quant_shift_ptr_)));
+    dequant_ptr_ = reinterpret_cast<int16_t *>(
+        vpx_memalign(16, 8 * sizeof(*dequant_ptr_)));
   }
 
-  virtual void TearDown() { libvpx_test::ClearSystemState(); }
+  ~VP9QuantizeBase() {
+    vpx_free(zbin_ptr_);
+    vpx_free(round_ptr_);
+    vpx_free(quant_ptr_);
+    vpx_free(quant_shift_ptr_);
+    vpx_free(dequant_ptr_);
+    zbin_ptr_ = NULL;
+    round_ptr_ = NULL;
+    quant_ptr_ = NULL;
+    quant_shift_ptr_ = NULL;
+    dequant_ptr_ = NULL;
+    libvpx_test::ClearSystemState();
+  }
 
  protected:
-  vpx_bit_depth_t bit_depth_;
+  int16_t *zbin_ptr_;
+  int16_t *round_ptr_;
+  int16_t *quant_ptr_;
+  int16_t *quant_shift_ptr_;
+  int16_t *dequant_ptr_;
+  const vpx_bit_depth_t bit_depth_;
   int max_value_;
-  QuantizeFunc quantize_op_;
-  QuantizeFunc ref_quantize_op_;
+  const int max_size_;
 };
 
-class VP9Quantize32Test : public ::testing::TestWithParam<QuantizeParam> {
+class VP9QuantizeTest : public VP9QuantizeBase,
+                        public ::testing::TestWithParam<QuantizeParam> {
  public:
-  virtual ~VP9Quantize32Test() {}
-  virtual void SetUp() {
-    quantize_op_ = GET_PARAM(0);
-    ref_quantize_op_ = GET_PARAM(1);
-    bit_depth_ = GET_PARAM(2);
-    max_value_ = (1 << bit_depth_) - 1;
-  }
+  VP9QuantizeTest()
+      : VP9QuantizeBase(GET_PARAM(2), GET_PARAM(3)), quantize_op_(GET_PARAM(0)),
+        ref_quantize_op_(GET_PARAM(1)) {}
 
-  virtual void TearDown() { libvpx_test::ClearSystemState(); }
-
  protected:
-  vpx_bit_depth_t bit_depth_;
-  int max_value_;
-  QuantizeFunc quantize_op_;
-  QuantizeFunc ref_quantize_op_;
+  const QuantizeFunc quantize_op_;
+  const QuantizeFunc ref_quantize_op_;
 };
 
+void GenerateHelperArrays(ACMRandom *rnd, int16_t *zbin, int16_t *round,
+                          int16_t *quant, int16_t *quant_shift,
+                          int16_t *dequant) {
+  for (int j = 0; j < 2; j++) {
+    // Values determined by deconstructing vp9_init_quantizer().
+    // zbin may be up to 1143 for 8 and 10 bit Y values, or 1200 for 12 bit Y
+    // values or U/V values of any bit depth. This is because y_delta is not
+    // factored into the vp9_ac_quant() call.
+    zbin[j] = rnd->RandRange(1200);
+    // round may be up to 685 for Y values or 914 for U/V.
+    round[j] = rnd->RandRange(914);
+    // quant ranges from 1 to -32703
+    quant[j] = static_cast<int>(rnd->RandRange(32704)) - 32703;
+    // quant_shift goes up to 1 << 16.
+    quant_shift[j] = rnd->RandRange(16384);
+    // dequant maxes out at 1828 for all cases.
+    dequant[j] = rnd->RandRange(1828);
+  }
+  for (int j = 2; j < 8; j++) {
+    zbin[j] = zbin[1];
+    round[j] = round[1];
+    quant[j] = quant[1];
+    quant_shift[j] = quant_shift[1];
+    dequant[j] = dequant[1];
+  }
+}
+
 TEST_P(VP9QuantizeTest, OperationCheck) {
   ACMRandom rnd(ACMRandom::DeterministicSeed());
-  Buffer<tran_low_t> coeff = Buffer<tran_low_t>(16, 16, 0, 16);
+  Buffer<tran_low_t> coeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 16);
   ASSERT_TRUE(coeff.Init());
-  DECLARE_ALIGNED(16, int16_t, zbin_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, round_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, quant_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, quant_shift_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, dequant_ptr[8]);
-  Buffer<tran_low_t> qcoeff = Buffer<tran_low_t>(16, 16, 0, 32);
+  Buffer<tran_low_t> qcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 32);
   ASSERT_TRUE(qcoeff.Init());
-  Buffer<tran_low_t> dqcoeff = Buffer<tran_low_t>(16, 16, 0, 32);
+  Buffer<tran_low_t> dqcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 32);
   ASSERT_TRUE(dqcoeff.Init());
-  Buffer<tran_low_t> ref_qcoeff = Buffer<tran_low_t>(16, 16, 0);
+  Buffer<tran_low_t> ref_qcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0);
   ASSERT_TRUE(ref_qcoeff.Init());
-  Buffer<tran_low_t> ref_dqcoeff = Buffer<tran_low_t>(16, 16, 0);
+  Buffer<tran_low_t> ref_dqcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0);
   ASSERT_TRUE(ref_dqcoeff.Init());
   uint16_t eob, ref_eob;
 
   for (int i = 0; i < number_of_iterations; ++i) {
     const int skip_block = i == 0;
-    const TX_SIZE sz = (TX_SIZE)(i % 3);  // TX_4X4, TX_8X8 TX_16X16
+    TX_SIZE sz;
+    if (max_size_ == 16) {
+      sz = (TX_SIZE)(i % 3);  // TX_4X4, TX_8X8 TX_16X16
+    } else {
+      sz = TX_32X32;
+    }
     const TX_TYPE tx_type = (TX_TYPE)((i >> 2) % 3);
     const scan_order *scan_order = &vp9_scan_orders[sz][tx_type];
     const int count = (4 << sz) * (4 << sz);  // 16, 64, 256
     coeff.Set(&rnd, 0, max_value_);
-    for (int j = 0; j < 2; j++) {
-      // Values determined by deconstructing vp9_init_quantizer().
-      // zbin may be up to 1143 for 8 and 10 bit Y values, or 1200 for 12 bit Y
-      // values or U/V values of any bit depth. This is because y_delta is not
-      // factored into the vp9_ac_quant() call.
-      zbin_ptr[j] = rnd.RandRange(1200);
-      // round may be up to 685 for Y values or 914 for U/V.
-      round_ptr[j] = rnd.RandRange(914);
-      // quant ranges from 1 to -32703
-      quant_ptr[j] = static_cast<int>(rnd.RandRange(32704)) - 32703;
-      // quant_shift goes up to 1 << 16.
-      quant_shift_ptr[j] = rnd.RandRange(16384);
-      // dequant maxes out at 1828 for all cases.
-      dequant_ptr[j] = rnd.RandRange(1828);
-    }
-    for (int j = 2; j < 8; j++) {
-      zbin_ptr[j] = zbin_ptr[1];
-      round_ptr[j] = round_ptr[1];
-      quant_ptr[j] = quant_ptr[1];
-      quant_shift_ptr[j] = quant_shift_ptr[1];
-      dequant_ptr[j] = dequant_ptr[1];
-    }
+    GenerateHelperArrays(&rnd, zbin_ptr_, round_ptr_, quant_ptr_,
+                         quant_shift_ptr_, dequant_ptr_);
 
-    ref_quantize_op_(
-        coeff.TopLeftPixel(), count, skip_block, zbin_ptr, round_ptr, quant_ptr,
-        quant_shift_ptr, ref_qcoeff.TopLeftPixel(), ref_dqcoeff.TopLeftPixel(),
-        dequant_ptr, &ref_eob, scan_order->scan, scan_order->iscan);
-    ASM_REGISTER_STATE_CHECK(quantize_op_(
-        coeff.TopLeftPixel(), count, skip_block, zbin_ptr, round_ptr, quant_ptr,
-        quant_shift_ptr, qcoeff.TopLeftPixel(), dqcoeff.TopLeftPixel(),
-        dequant_ptr, &eob, scan_order->scan, scan_order->iscan));
+    ref_quantize_op_(coeff.TopLeftPixel(), count, skip_block, zbin_ptr_,
+                     round_ptr_, quant_ptr_, quant_shift_ptr_,
+                     ref_qcoeff.TopLeftPixel(), ref_dqcoeff.TopLeftPixel(),
+                     dequant_ptr_, &ref_eob, scan_order->scan,
+                     scan_order->iscan);
+    ASM_REGISTER_STATE_CHECK(
+        quantize_op_(coeff.TopLeftPixel(), count, skip_block, zbin_ptr_,
+                     round_ptr_, quant_ptr_, quant_shift_ptr_,
+                     qcoeff.TopLeftPixel(), dqcoeff.TopLeftPixel(),
+                     dequant_ptr_, &eob, scan_order->scan, scan_order->iscan));
 
     EXPECT_TRUE(qcoeff.CheckValues(ref_qcoeff));
     EXPECT_TRUE(dqcoeff.CheckValues(ref_dqcoeff));
@@ -153,92 +180,28 @@
   }
 }
 
-TEST_P(VP9Quantize32Test, OperationCheck) {
-  ACMRandom rnd(ACMRandom::DeterministicSeed());
-  Buffer<tran_low_t> coeff = Buffer<tran_low_t>(32, 32, 0, 16);
-  ASSERT_TRUE(coeff.Init());
-  DECLARE_ALIGNED(16, int16_t, zbin_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, round_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, quant_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, quant_shift_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, dequant_ptr[8]);
-  Buffer<tran_low_t> qcoeff = Buffer<tran_low_t>(32, 32, 0, 32);
-  ASSERT_TRUE(qcoeff.Init());
-  Buffer<tran_low_t> dqcoeff = Buffer<tran_low_t>(32, 32, 0, 32);
-  ASSERT_TRUE(dqcoeff.Init());
-  Buffer<tran_low_t> ref_qcoeff = Buffer<tran_low_t>(32, 32, 0);
-  ASSERT_TRUE(ref_qcoeff.Init());
-  Buffer<tran_low_t> ref_dqcoeff = Buffer<tran_low_t>(32, 32, 0);
-  ASSERT_TRUE(ref_dqcoeff.Init());
-  uint16_t eob, ref_eob;
-
-  for (int i = 0; i < number_of_iterations; ++i) {
-    const int skip_block = i == 0;
-    const TX_SIZE sz = TX_32X32;
-    const TX_TYPE tx_type = (TX_TYPE)(i % 4);
-    const scan_order *scan_order = &vp9_scan_orders[sz][tx_type];
-    const int count = (4 << sz) * (4 << sz);  // 1024
-    coeff.Set(&rnd, 0, max_value_);
-    for (int j = 0; j < 2; j++) {
-      zbin_ptr[j] = rnd.RandRange(1200);
-      round_ptr[j] = rnd.RandRange(914);
-      quant_ptr[j] = static_cast<int>(rnd.RandRange(32704)) - 32703;
-      quant_shift_ptr[j] = rnd.RandRange(16384);
-      dequant_ptr[j] = rnd.RandRange(1828);
-    }
-    for (int j = 2; j < 8; j++) {
-      zbin_ptr[j] = zbin_ptr[1];
-      round_ptr[j] = round_ptr[1];
-      quant_ptr[j] = quant_ptr[1];
-      quant_shift_ptr[j] = quant_shift_ptr[1];
-      dequant_ptr[j] = dequant_ptr[1];
-    }
-
-    ref_quantize_op_(
-        coeff.TopLeftPixel(), count, skip_block, zbin_ptr, round_ptr, quant_ptr,
-        quant_shift_ptr, ref_qcoeff.TopLeftPixel(), ref_dqcoeff.TopLeftPixel(),
-        dequant_ptr, &ref_eob, scan_order->scan, scan_order->iscan);
-    ASM_REGISTER_STATE_CHECK(quantize_op_(
-        coeff.TopLeftPixel(), count, skip_block, zbin_ptr, round_ptr, quant_ptr,
-        quant_shift_ptr, qcoeff.TopLeftPixel(), dqcoeff.TopLeftPixel(),
-        dequant_ptr, &eob, scan_order->scan, scan_order->iscan));
-
-    EXPECT_TRUE(qcoeff.CheckValues(ref_qcoeff));
-    EXPECT_TRUE(dqcoeff.CheckValues(ref_dqcoeff));
-
-    EXPECT_EQ(eob, ref_eob);
-
-    if (HasFailure()) {
-      printf("Failure on iteration %d.\n", i);
-      qcoeff.PrintDifference(ref_qcoeff);
-      dqcoeff.PrintDifference(ref_dqcoeff);
-      return;
-    }
-  }
-}
-
 TEST_P(VP9QuantizeTest, EOBCheck) {
   ACMRandom rnd(ACMRandom::DeterministicSeed());
-  Buffer<tran_low_t> coeff = Buffer<tran_low_t>(16, 16, 0, 16);
+  Buffer<tran_low_t> coeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 16);
   ASSERT_TRUE(coeff.Init());
-  DECLARE_ALIGNED(16, int16_t, zbin_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, round_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, quant_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, quant_shift_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, dequant_ptr[8]);
-  Buffer<tran_low_t> qcoeff = Buffer<tran_low_t>(16, 16, 0, 32);
+  Buffer<tran_low_t> qcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 32);
   ASSERT_TRUE(qcoeff.Init());
-  Buffer<tran_low_t> dqcoeff = Buffer<tran_low_t>(16, 16, 0, 32);
+  Buffer<tran_low_t> dqcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 32);
   ASSERT_TRUE(dqcoeff.Init());
-  Buffer<tran_low_t> ref_qcoeff = Buffer<tran_low_t>(16, 16, 0);
+  Buffer<tran_low_t> ref_qcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0);
   ASSERT_TRUE(ref_qcoeff.Init());
-  Buffer<tran_low_t> ref_dqcoeff = Buffer<tran_low_t>(16, 16, 0);
+  Buffer<tran_low_t> ref_dqcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0);
   ASSERT_TRUE(ref_dqcoeff.Init());
   uint16_t eob, ref_eob;
 
   for (int i = 0; i < number_of_iterations; ++i) {
     int skip_block = i == 0;
-    TX_SIZE sz = (TX_SIZE)(i % 3);  // TX_4X4, TX_8X8 TX_16X16
+    TX_SIZE sz;
+    if (max_size_ == 16) {
+      sz = (TX_SIZE)(i % 3);  // TX_4X4, TX_8X8 TX_16X16
+    } else {
+      sz = TX_32X32;
+    }
     TX_TYPE tx_type = (TX_TYPE)((i >> 2) % 3);
     const scan_order *scan_order = &vp9_scan_orders[sz][tx_type];
     int count = (4 << sz) * (4 << sz);  // 16, 64, 256
@@ -246,29 +209,19 @@
     coeff.Set(0);
     coeff.TopLeftPixel()[rnd(count)] = rnd.RandRange(max_value_);
     coeff.TopLeftPixel()[rnd(count)] = rnd.RandRange(max_value_);
-    for (int j = 0; j < 2; j++) {
-      zbin_ptr[j] = rnd.RandRange(1200);
-      round_ptr[j] = rnd.RandRange(914);
-      quant_ptr[j] = static_cast<int>(rnd.RandRange(32704)) - 32703;
-      quant_shift_ptr[j] = rnd.RandRange(16384);
-      dequant_ptr[j] = rnd.RandRange(1828);
-    }
-    for (int j = 2; j < 8; j++) {
-      zbin_ptr[j] = zbin_ptr[1];
-      round_ptr[j] = round_ptr[1];
-      quant_ptr[j] = quant_ptr[1];
-      quant_shift_ptr[j] = quant_shift_ptr[1];
-      dequant_ptr[j] = dequant_ptr[1];
-    }
+    GenerateHelperArrays(&rnd, zbin_ptr_, round_ptr_, quant_ptr_,
+                         quant_shift_ptr_, dequant_ptr_);
 
-    ref_quantize_op_(
-        coeff.TopLeftPixel(), count, skip_block, zbin_ptr, round_ptr, quant_ptr,
-        quant_shift_ptr, ref_qcoeff.TopLeftPixel(), ref_dqcoeff.TopLeftPixel(),
-        dequant_ptr, &ref_eob, scan_order->scan, scan_order->iscan);
-    ASM_REGISTER_STATE_CHECK(quantize_op_(
-        coeff.TopLeftPixel(), count, skip_block, zbin_ptr, round_ptr, quant_ptr,
-        quant_shift_ptr, qcoeff.TopLeftPixel(), dqcoeff.TopLeftPixel(),
-        dequant_ptr, &eob, scan_order->scan, scan_order->iscan));
+    ref_quantize_op_(coeff.TopLeftPixel(), count, skip_block, zbin_ptr_,
+                     round_ptr_, quant_ptr_, quant_shift_ptr_,
+                     ref_qcoeff.TopLeftPixel(), ref_dqcoeff.TopLeftPixel(),
+                     dequant_ptr_, &ref_eob, scan_order->scan,
+                     scan_order->iscan);
+    ASM_REGISTER_STATE_CHECK(
+        quantize_op_(coeff.TopLeftPixel(), count, skip_block, zbin_ptr_,
+                     round_ptr_, quant_ptr_, quant_shift_ptr_,
+                     qcoeff.TopLeftPixel(), dqcoeff.TopLeftPixel(),
+                     dequant_ptr_, &eob, scan_order->scan, scan_order->iscan));
 
     EXPECT_TRUE(qcoeff.CheckValues(ref_qcoeff));
     EXPECT_TRUE(dqcoeff.CheckValues(ref_dqcoeff));
@@ -284,90 +237,28 @@
   }
 }
 
-TEST_P(VP9Quantize32Test, EOBCheck) {
-  ACMRandom rnd(ACMRandom::DeterministicSeed());
-  Buffer<tran_low_t> coeff = Buffer<tran_low_t>(32, 32, 0, 16);
-  ASSERT_TRUE(coeff.Init());
-  DECLARE_ALIGNED(16, int16_t, zbin_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, round_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, quant_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, quant_shift_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, dequant_ptr[8]);
-  Buffer<tran_low_t> qcoeff = Buffer<tran_low_t>(32, 32, 0, 32);
-  ASSERT_TRUE(qcoeff.Init());
-  Buffer<tran_low_t> dqcoeff = Buffer<tran_low_t>(32, 32, 0, 32);
-  ASSERT_TRUE(dqcoeff.Init());
-  Buffer<tran_low_t> ref_qcoeff = Buffer<tran_low_t>(32, 32, 0);
-  ASSERT_TRUE(ref_qcoeff.Init());
-  Buffer<tran_low_t> ref_dqcoeff = Buffer<tran_low_t>(32, 32, 0);
-  ASSERT_TRUE(ref_dqcoeff.Init());
-  uint16_t eob, ref_eob;
-
-  for (int i = 0; i < number_of_iterations; ++i) {
-    int skip_block = i == 0;
-    TX_SIZE sz = TX_32X32;
-    TX_TYPE tx_type = (TX_TYPE)(i % 4);
-    const scan_order *scan_order = &vp9_scan_orders[sz][tx_type];
-    int count = (4 << sz) * (4 << sz);  // 1024
-    coeff.Set(0);
-    // Two random entries
-    coeff.TopLeftPixel()[rnd(count)] = rnd.RandRange(max_value_);
-    coeff.TopLeftPixel()[rnd(count)] = rnd.RandRange(max_value_);
-    for (int j = 0; j < 2; j++) {
-      zbin_ptr[j] = rnd.RandRange(1200);
-      round_ptr[j] = rnd.RandRange(914);
-      quant_ptr[j] = static_cast<int>(rnd.RandRange(32704)) - 32703;
-      quant_shift_ptr[j] = rnd.RandRange(16384);
-      dequant_ptr[j] = rnd.RandRange(1828);
-    }
-    for (int j = 2; j < 8; j++) {
-      zbin_ptr[j] = zbin_ptr[1];
-      round_ptr[j] = round_ptr[1];
-      quant_ptr[j] = quant_ptr[1];
-      quant_shift_ptr[j] = quant_shift_ptr[1];
-      dequant_ptr[j] = dequant_ptr[1];
-    }
-
-    ref_quantize_op_(
-        coeff.TopLeftPixel(), count, skip_block, zbin_ptr, round_ptr, quant_ptr,
-        quant_shift_ptr, ref_qcoeff.TopLeftPixel(), ref_dqcoeff.TopLeftPixel(),
-        dequant_ptr, &ref_eob, scan_order->scan, scan_order->iscan);
-    ASM_REGISTER_STATE_CHECK(quantize_op_(
-        coeff.TopLeftPixel(), count, skip_block, zbin_ptr, round_ptr, quant_ptr,
-        quant_shift_ptr, qcoeff.TopLeftPixel(), dqcoeff.TopLeftPixel(),
-        dequant_ptr, &eob, scan_order->scan, scan_order->iscan));
-
-    EXPECT_TRUE(qcoeff.CheckValues(ref_qcoeff));
-    EXPECT_TRUE(dqcoeff.CheckValues(ref_dqcoeff));
-
-    EXPECT_EQ(eob, ref_eob);
-
-    if (HasFailure()) {
-      printf("Failure on iteration %d.\n", i);
-      qcoeff.PrintDifference(ref_qcoeff);
-      dqcoeff.PrintDifference(ref_dqcoeff);
-      return;
-    }
-  }
-}
-
 TEST_P(VP9QuantizeTest, DISABLED_Speed) {
   ACMRandom rnd(ACMRandom::DeterministicSeed());
-  Buffer<tran_low_t> coeff = Buffer<tran_low_t>(16, 16, 0, 16);
+  Buffer<tran_low_t> coeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 16);
   ASSERT_TRUE(coeff.Init());
-  DECLARE_ALIGNED(16, int16_t, zbin_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, round_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, quant_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, quant_shift_ptr[8]);
-  DECLARE_ALIGNED(16, int16_t, dequant_ptr[8]);
-  Buffer<tran_low_t> qcoeff = Buffer<tran_low_t>(16, 16, 0, 32);
+  Buffer<tran_low_t> qcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 32);
   ASSERT_TRUE(qcoeff.Init());
-  Buffer<tran_low_t> dqcoeff = Buffer<tran_low_t>(16, 16, 0, 32);
+  Buffer<tran_low_t> dqcoeff = Buffer<tran_low_t>(max_size_, max_size_, 0, 32);
   ASSERT_TRUE(dqcoeff.Init());
   uint16_t eob;
+  int starting_sz, ending_sz;
 
-  // TX_4X4, TX_8X8 TX_16X16
-  for (TX_SIZE sz = 0; sz < 3; ++sz) {
+  if (max_size_ == 16) {
+    // TX_4X4, TX_8X8 TX_16X16
+    starting_sz = 0;
+    ending_sz = 2;
+  } else {
+    // TX_32X32
+    starting_sz = 3;
+    ending_sz = 3;
+  }
+
+  for (TX_SIZE sz = starting_sz; sz <= ending_sz; ++sz) {
     // skip_block, zbin > coeff, zbin < coeff.
     for (int i = 0; i < 3; ++i) {
       const int skip_block = i == 0;
@@ -376,40 +267,30 @@
       const TX_TYPE tx_type = DCT_DCT;
       const scan_order *scan_order = &vp9_scan_orders[sz][tx_type];
       const int count = (4 << sz) * (4 << sz);  // 16, 64, 256
+
+      GenerateHelperArrays(&rnd, zbin_ptr_, round_ptr_, quant_ptr_,
+                           quant_shift_ptr_, dequant_ptr_);
+
       if (i == 0) {
         // zbin values are unused when skip_block == 1.
-        zbin_ptr[0] = zbin_ptr[1] = 0;
+        zbin_ptr_[0] = zbin_ptr_[1] = 0;
         coeff.Set(0);
       } else if (i == 1) {
         // When |coeff values| are less than zbin the results are 0.
-        zbin_ptr[0] = zbin_ptr[1] = 100;
+        zbin_ptr_[0] = zbin_ptr_[1] = 100;
         coeff.Set(&rnd, -99, 99);
       } else if (i == 2) {
-        zbin_ptr[0] = zbin_ptr[1] = 50;
+        zbin_ptr_[0] = zbin_ptr_[1] = 50;
         coeff.Set(&rnd, -500, 500);
       }
-      for (int j = 0; j < 2; j++) {
-        // Chosen by fair dice roll.
-        round_ptr[j] = 10;
-        quant_ptr[j] = -10;
-        quant_shift_ptr[j] = 10;
-        dequant_ptr[j] = 10;
-      }
-      for (int j = 2; j < 8; j++) {
-        zbin_ptr[j] = zbin_ptr[1];
-        round_ptr[j] = round_ptr[1];
-        quant_ptr[j] = quant_ptr[1];
-        quant_shift_ptr[j] = quant_shift_ptr[1];
-        dequant_ptr[j] = dequant_ptr[1];
-      }
 
       vpx_usec_timer timer;
       vpx_usec_timer_start(&timer);
       for (int j = 0; j < 100000000 / count; ++j) {
-        quantize_op_(coeff.TopLeftPixel(), count, skip_block, zbin_ptr,
-                     round_ptr, quant_ptr, quant_shift_ptr,
-                     qcoeff.TopLeftPixel(), dqcoeff.TopLeftPixel(), dequant_ptr,
-                     &eob, scan_order->scan, scan_order->iscan);
+        quantize_op_(coeff.TopLeftPixel(), count, skip_block, zbin_ptr_,
+                     round_ptr_, quant_ptr_, quant_shift_ptr_,
+                     qcoeff.TopLeftPixel(), dqcoeff.TopLeftPixel(),
+                     dequant_ptr_, &eob, scan_order->scan, scan_order->iscan);
       }
       vpx_usec_timer_mark(&timer);
       const int elapsed_time = static_cast<int>(vpx_usec_timer_elapsed(&timer));
@@ -431,39 +312,35 @@
 // make_tuple(&vpx_quantize_b_sse2, &vpx_highbd_quantize_b_c, VPX_BITS_8),
 INSTANTIATE_TEST_CASE_P(
     SSE2, VP9QuantizeTest,
-    ::testing::Values(make_tuple(&vpx_highbd_quantize_b_sse2,
-                                 &vpx_highbd_quantize_b_c, VPX_BITS_8),
-                      make_tuple(&vpx_highbd_quantize_b_sse2,
-                                 &vpx_highbd_quantize_b_c, VPX_BITS_10),
-                      make_tuple(&vpx_highbd_quantize_b_sse2,
-                                 &vpx_highbd_quantize_b_c, VPX_BITS_12)));
-INSTANTIATE_TEST_CASE_P(
-    SSE2, VP9Quantize32Test,
-    ::testing::Values(make_tuple(&vpx_highbd_quantize_b_32x32_sse2,
-                                 &vpx_highbd_quantize_b_32x32_c, VPX_BITS_8),
-                      make_tuple(&vpx_highbd_quantize_b_32x32_sse2,
-                                 &vpx_highbd_quantize_b_32x32_c, VPX_BITS_10),
-                      make_tuple(&vpx_highbd_quantize_b_32x32_sse2,
-                                 &vpx_highbd_quantize_b_32x32_c, VPX_BITS_12)));
+    ::testing::Values(
+        make_tuple(&vpx_highbd_quantize_b_sse2, &vpx_highbd_quantize_b_c,
+                   VPX_BITS_8, 16),
+        make_tuple(&vpx_highbd_quantize_b_sse2, &vpx_highbd_quantize_b_c,
+                   VPX_BITS_10, 16),
+        make_tuple(&vpx_highbd_quantize_b_sse2, &vpx_highbd_quantize_b_c,
+                   VPX_BITS_12, 16),
+        make_tuple(&vpx_highbd_quantize_b_32x32_sse2,
+                   &vpx_highbd_quantize_b_32x32_c, VPX_BITS_8, 32),
+        make_tuple(&vpx_highbd_quantize_b_32x32_sse2,
+                   &vpx_highbd_quantize_b_32x32_c, VPX_BITS_10, 32),
+        make_tuple(&vpx_highbd_quantize_b_32x32_sse2,
+                   &vpx_highbd_quantize_b_32x32_c, VPX_BITS_12, 32)));
 #else
 INSTANTIATE_TEST_CASE_P(SSE2, VP9QuantizeTest,
                         ::testing::Values(make_tuple(&vpx_quantize_b_sse2,
                                                      &vpx_quantize_b_c,
-                                                     VPX_BITS_8)));
+                                                     VPX_BITS_8, 16)));
 #endif  // CONFIG_VP9_HIGHBITDEPTH
 #endif  // HAVE_SSE2
 
 // TODO(johannkoenig): SSSE3 optimizations do not yet pass these tests.
 #if HAVE_SSSE3 && ARCH_X86_64
-INSTANTIATE_TEST_CASE_P(DISABLED_SSSE3, VP9QuantizeTest,
-                        ::testing::Values(make_tuple(&vpx_quantize_b_ssse3,
-                                                     &vpx_quantize_b_c,
-                                                     VPX_BITS_8)));
-
 INSTANTIATE_TEST_CASE_P(
-    DISABLED_SSSE3, VP9Quantize32Test,
-    ::testing::Values(make_tuple(&vpx_quantize_b_32x32_ssse3,
-                                 &vpx_quantize_b_32x32_c, VPX_BITS_8)));
+    DISABLED_SSSE3, VP9QuantizeTest,
+    ::testing::Values(make_tuple(&vpx_quantize_b_ssse3, &vpx_quantize_b_c,
+                                 VPX_BITS_8, 16),
+                      make_tuple(&vpx_quantize_b_32x32_ssse3,
+                                 &vpx_quantize_b_32x32_c, VPX_BITS_8, 32)));
 #endif  // HAVE_SSSE3 && ARCH_X86_64
 
 // TODO(johannkoenig): AVX optimizations do not yet pass the 32x32 test or
@@ -472,12 +349,11 @@
 INSTANTIATE_TEST_CASE_P(AVX, VP9QuantizeTest,
                         ::testing::Values(make_tuple(&vpx_quantize_b_avx,
                                                      &vpx_quantize_b_c,
-                                                     VPX_BITS_8)));
-
-INSTANTIATE_TEST_CASE_P(DISABLED_AVX, VP9Quantize32Test,
+                                                     VPX_BITS_8, 16)));
+INSTANTIATE_TEST_CASE_P(DISABLED_AVX, VP9QuantizeTest,
                         ::testing::Values(make_tuple(&vpx_quantize_b_32x32_avx,
                                                      &vpx_quantize_b_32x32_c,
-                                                     VPX_BITS_8)));
+                                                     VPX_BITS_8, 32)));
 #endif  // HAVE_AVX && ARCH_X86_64 && !CONFIG_VP9_HIGHBITDEPTH
 
 // TODO(webm:1448): dqcoeff is not handled correctly in HBD builds.
@@ -485,7 +361,7 @@
 INSTANTIATE_TEST_CASE_P(NEON, VP9QuantizeTest,
                         ::testing::Values(make_tuple(&vpx_quantize_b_neon,
                                                      &vpx_quantize_b_c,
-                                                     VPX_BITS_8)));
+                                                     VPX_BITS_8, 16)));
 #endif  // HAVE_NEON && !CONFIG_VP9_HIGHBITDEPTH
 
 // Only useful to compare "Speed" test results.
@@ -492,5 +368,5 @@
 INSTANTIATE_TEST_CASE_P(DISABLED_C, VP9QuantizeTest,
                         ::testing::Values(make_tuple(&vpx_quantize_b_c,
                                                      &vpx_quantize_b_c,
-                                                     VPX_BITS_8)));
+                                                     VPX_BITS_8, 16)));
 }  // namespace