ref: 08e0da30ca01f22bd9287826ffe26cbe88a7cddb
parent: 9c0680bd4363bdd50dc11e843c91b0e0093e4572
author: Johann <johannkoenig@google.com>
date: Fri Oct 21 11:09:53 EDT 2016
Refactor partial idct test Switch to using correctly sized inputs and outputs. This simplifies adding tests with varying strides. Change-Id: I716a0d8173dcf6a86d56656ac9d3101b7ec27642
--- a/test/partial_idct_test.cc
+++ b/test/partial_idct_test.cc
@@ -41,13 +41,40 @@
partial_itxfm_ = GET_PARAM(2);
tx_size_ = GET_PARAM(3);
last_nonzero_ = GET_PARAM(4);
+
+ switch (tx_size_) {
+ case TX_4X4: size_ = 4; break;
+ case TX_8X8: size_ = 8; break;
+ case TX_16X16: size_ = 16; break;
+ case TX_32X32: size_ = 32; break;
+ default: FAIL() << "Wrong Size!"; break;
+ }
+
+ input_block_ = reinterpret_cast<tran_low_t *>(
+ vpx_memalign(16, sizeof(*input_block_) * size_ * size_));
+ output_block_ = reinterpret_cast<uint8_t *>(
+ vpx_memalign(16, sizeof(*output_block_) * size_ * size_));
+ output_block_ref_ = reinterpret_cast<uint8_t *>(
+ vpx_memalign(16, sizeof(*output_block_ref_) * size_ * size_));
}
- virtual void TearDown() { libvpx_test::ClearSystemState(); }
+ virtual void TearDown() {
+ vpx_free(input_block_);
+ input_block_ = NULL;
+ vpx_free(output_block_);
+ output_block_ = NULL;
+ vpx_free(output_block_ref_);
+ output_block_ref_ = NULL;
+ libvpx_test::ClearSystemState();
+ }
protected:
int last_nonzero_;
TX_SIZE tx_size_;
+ tran_low_t *input_block_;
+ uint8_t *output_block_;
+ uint8_t *output_block_ref_;
+ int size_;
FwdTxfmFunc ftxfm_;
InvTxfmFunc full_itxfm_;
InvTxfmFunc partial_itxfm_;
@@ -55,32 +82,18 @@
TEST_P(PartialIDctTest, RunQuantCheck) {
ACMRandom rnd(ACMRandom::DeterministicSeed());
- int size;
- switch (tx_size_) {
- case TX_4X4: size = 4; break;
- case TX_8X8: size = 8; break;
- case TX_16X16: size = 16; break;
- case TX_32X32: size = 32; break;
- default: FAIL() << "Wrong Size!"; break;
- }
- DECLARE_ALIGNED(16, tran_low_t, test_coef_block1[kMaxNumCoeffs]);
- DECLARE_ALIGNED(16, tran_low_t, test_coef_block2[kMaxNumCoeffs]);
- DECLARE_ALIGNED(16, uint8_t, dst1[kMaxNumCoeffs]);
- DECLARE_ALIGNED(16, uint8_t, dst2[kMaxNumCoeffs]);
const int count_test_block = 1000;
- const int block_size = size * size;
+ const int block_size = size_ * size_;
DECLARE_ALIGNED(16, int16_t, input_extreme_block[kMaxNumCoeffs]);
DECLARE_ALIGNED(16, tran_low_t, output_ref_block[kMaxNumCoeffs]);
- int max_error = 0;
for (int i = 0; i < count_test_block; ++i) {
// clear out destination buffer
- memset(dst1, 0, sizeof(*dst1) * block_size);
- memset(dst2, 0, sizeof(*dst2) * block_size);
- memset(test_coef_block1, 0, sizeof(*test_coef_block1) * block_size);
- memset(test_coef_block2, 0, sizeof(*test_coef_block2) * block_size);
+ memset(input_block_, 0, sizeof(*input_block_) * block_size);
+ memset(output_block_, 0, sizeof(*output_block_) * block_size);
+ memset(output_block_ref_, 0, sizeof(*output_block_ref_) * block_size);
ACMRandom rnd(ACMRandom::DeterministicSeed());
@@ -96,54 +109,37 @@
}
}
- ftxfm_(input_extreme_block, output_ref_block, size);
+ ftxfm_(input_extreme_block, output_ref_block, size_);
// quantization with maximum allowed step sizes
- test_coef_block1[0] = (output_ref_block[0] / 1336) * 1336;
+ input_block_[0] = (output_ref_block[0] / 1336) * 1336;
for (int j = 1; j < last_nonzero_; ++j) {
- test_coef_block1[vp9_default_scan_orders[tx_size_].scan[j]] =
+ input_block_[vp9_default_scan_orders[tx_size_].scan[j]] =
(output_ref_block[j] / 1828) * 1828;
}
}
- ASM_REGISTER_STATE_CHECK(full_itxfm_(test_coef_block1, dst1, size));
- ASM_REGISTER_STATE_CHECK(partial_itxfm_(test_coef_block1, dst2, size));
+ ASM_REGISTER_STATE_CHECK(
+ full_itxfm_(input_block_, output_block_ref_, size_));
+ ASM_REGISTER_STATE_CHECK(
+ partial_itxfm_(input_block_, output_block_, size_));
- for (int j = 0; j < block_size; ++j) {
- const int diff = dst1[j] - dst2[j];
- const int error = diff * diff;
- if (max_error < error) max_error = error;
- }
+ ASSERT_EQ(0, memcmp(output_block_ref_, output_block_,
+ sizeof(*output_block_) * block_size))
+ << "Error: partial inverse transform produces different results";
}
-
- EXPECT_EQ(0, max_error)
- << "Error: partial inverse transform produces different results";
}
TEST_P(PartialIDctTest, ResultsMatch) {
ACMRandom rnd(ACMRandom::DeterministicSeed());
- int size;
- switch (tx_size_) {
- case TX_4X4: size = 4; break;
- case TX_8X8: size = 8; break;
- case TX_16X16: size = 16; break;
- case TX_32X32: size = 32; break;
- default: FAIL() << "Wrong Size!"; break;
- }
- DECLARE_ALIGNED(16, tran_low_t, test_coef_block1[kMaxNumCoeffs]);
- DECLARE_ALIGNED(16, tran_low_t, test_coef_block2[kMaxNumCoeffs]);
- DECLARE_ALIGNED(16, uint8_t, dst1[kMaxNumCoeffs]);
- DECLARE_ALIGNED(16, uint8_t, dst2[kMaxNumCoeffs]);
const int count_test_block = 1000;
const int max_coeff = 32766 / 4;
- const int block_size = size * size;
- int max_error = 0;
+ const int block_size = size_ * size_;
for (int i = 0; i < count_test_block; ++i) {
// clear out destination buffer
- memset(dst1, 0, sizeof(*dst1) * block_size);
- memset(dst2, 0, sizeof(*dst2) * block_size);
- memset(test_coef_block1, 0, sizeof(*test_coef_block1) * block_size);
- memset(test_coef_block2, 0, sizeof(*test_coef_block2) * block_size);
+ memset(input_block_, 0, sizeof(tran_low_t) * block_size);
+ memset(output_block_, 0, sizeof(*output_block_) * block_size);
+ memset(output_block_ref_, 0, sizeof(*output_block_ref_) * block_size);
int max_energy_leftover = max_coeff * max_coeff;
for (int j = 0; j < last_nonzero_; ++j) {
int16_t coef = static_cast<int16_t>(sqrt(1.0 * max_energy_leftover) *
@@ -153,24 +149,18 @@
max_energy_leftover = 0;
coef = 0;
}
- test_coef_block1[vp9_default_scan_orders[tx_size_].scan[j]] = coef;
+ input_block_[vp9_default_scan_orders[tx_size_].scan[j]] = coef;
}
- memcpy(test_coef_block2, test_coef_block1,
- sizeof(*test_coef_block2) * block_size);
+ ASM_REGISTER_STATE_CHECK(
+ full_itxfm_(input_block_, output_block_ref_, size_));
+ ASM_REGISTER_STATE_CHECK(
+ partial_itxfm_(input_block_, output_block_, size_));
- ASM_REGISTER_STATE_CHECK(full_itxfm_(test_coef_block1, dst1, size));
- ASM_REGISTER_STATE_CHECK(partial_itxfm_(test_coef_block2, dst2, size));
-
- for (int j = 0; j < block_size; ++j) {
- const int diff = dst1[j] - dst2[j];
- const int error = diff * diff;
- if (max_error < error) max_error = error;
- }
+ ASSERT_EQ(0, memcmp(output_block_ref_, output_block_,
+ sizeof(*output_block_) * block_size))
+ << "Error: partial inverse transform produces different results";
}
-
- EXPECT_EQ(0, max_error)
- << "Error: partial inverse transform produces different results";
}
using std::tr1::make_tuple;