ref: ed2c2405380eb5f418b47c02d786a0a21b8723ee
parent: 08e0da30ca01f22bd9287826ffe26cbe88a7cddb
author: Johann <[email protected]>
date: Wed Oct 26 17:19:36 EDT 2016
partial_idct_test: consolidate block size Use *input_block_ for sizeof() calculation like the other test Change-Id: I1e4bd227131662056405af78c5052ad6ef769e9f
--- a/test/partial_idct_test.cc
+++ b/test/partial_idct_test.cc
@@ -49,13 +49,14 @@
case TX_32X32: size_ = 32; break;
default: FAIL() << "Wrong Size!"; break;
}
+ block_size_ = size_ * size_;
input_block_ = reinterpret_cast<tran_low_t *>(
- vpx_memalign(16, sizeof(*input_block_) * size_ * size_));
+ vpx_memalign(16, sizeof(*input_block_) * block_size_));
output_block_ = reinterpret_cast<uint8_t *>(
- vpx_memalign(16, sizeof(*output_block_) * size_ * size_));
+ vpx_memalign(16, sizeof(*output_block_) * block_size_));
output_block_ref_ = reinterpret_cast<uint8_t *>(
- vpx_memalign(16, sizeof(*output_block_ref_) * size_ * size_));
+ vpx_memalign(16, sizeof(*output_block_ref_) * block_size_));
}
virtual void TearDown() {
@@ -75,6 +76,7 @@
uint8_t *output_block_;
uint8_t *output_block_ref_;
int size_;
+ int block_size_;
FwdTxfmFunc ftxfm_;
InvTxfmFunc full_itxfm_;
InvTxfmFunc partial_itxfm_;
@@ -84,7 +86,6 @@
ACMRandom rnd(ACMRandom::DeterministicSeed());
const int count_test_block = 1000;
- 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]);
@@ -91,9 +92,9 @@
for (int i = 0; i < count_test_block; ++i) {
// clear out destination buffer
- 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);
+ 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());
@@ -100,11 +101,11 @@
for (int i = 0; i < count_test_block; ++i) {
// Initialize a test block with input range [-255, 255].
if (i == 0) {
- for (int j = 0; j < block_size; ++j) input_extreme_block[j] = 255;
+ for (int j = 0; j < block_size_; ++j) input_extreme_block[j] = 255;
} else if (i == 1) {
- for (int j = 0; j < block_size; ++j) input_extreme_block[j] = -255;
+ for (int j = 0; j < block_size_; ++j) input_extreme_block[j] = -255;
} else {
- for (int j = 0; j < block_size; ++j) {
+ for (int j = 0; j < block_size_; ++j) {
input_extreme_block[j] = rnd.Rand8() % 2 ? 255 : -255;
}
}
@@ -125,7 +126,7 @@
partial_itxfm_(input_block_, output_block_, size_));
ASSERT_EQ(0, memcmp(output_block_ref_, output_block_,
- sizeof(*output_block_) * block_size))
+ sizeof(*output_block_) * block_size_))
<< "Error: partial inverse transform produces different results";
}
}
@@ -134,12 +135,11 @@
ACMRandom rnd(ACMRandom::DeterministicSeed());
const int count_test_block = 1000;
const int max_coeff = 32766 / 4;
- const int block_size = size_ * size_;
for (int i = 0; i < count_test_block; ++i) {
// clear out destination buffer
- 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);
+ 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_);
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) *
@@ -158,7 +158,7 @@
partial_itxfm_(input_block_, output_block_, size_));
ASSERT_EQ(0, memcmp(output_block_ref_, output_block_,
- sizeof(*output_block_) * block_size))
+ sizeof(*output_block_) * block_size_))
<< "Error: partial inverse transform produces different results";
}
}