class FwdTrans4x4Test : public ::testing::TestWithParam<int> {
public:
- FwdTrans4x4Test() {SetUpTestTxfm();}
+ FwdTrans4x4Test() { SetUpTestTxfm(); }
~FwdTrans4x4Test() {}
void SetUpTestTxfm() {
- tx_type = GetParam();
- if (tx_type == 0) {
+ tx_type_ = GetParam();
+ if (tx_type_ == 0) {
fwd_txfm = fdct4x4;
inv_txfm = idct4x4_add;
} else {
(*inv_txfm)(in, out, dst, stride, tx_type);
}
- int tx_type;
+ int tx_type_;
void (*fwd_txfm)(int16_t *in, int16_t *out, uint8_t *dst,
int stride, int tx_type);
void (*inv_txfm)(int16_t *in, int16_t *out, uint8_t *dst,
for (int j = 0; j < 16; ++j)
test_input_block[j] = rnd.Rand8() - rnd.Rand8();
- RunFwdTxfm(test_input_block, test_output_block, NULL, pitch, tx_type);
+ RunFwdTxfm(test_input_block, test_output_block, NULL, pitch, tx_type_);
for (int j = 0; j < 16; ++j) {
if (test_output_block[j] < 0)
EXPECT_TRUE(bias_acceptable)
<< "Error: 4x4 FDCT/FHT has a sign bias > 1%"
<< " for input range [-255, 255] at index " << j
- << " tx_type " << tx_type;
+ << " tx_type " << tx_type_;
}
memset(count_sign_block, 0, sizeof(count_sign_block));
for (int j = 0; j < 16; ++j)
test_input_block[j] = (rnd.Rand8() >> 4) - (rnd.Rand8() >> 4);
- RunFwdTxfm(test_input_block, test_output_block, NULL, pitch, tx_type);
+ RunFwdTxfm(test_input_block, test_output_block, NULL, pitch, tx_type_);
for (int j = 0; j < 16; ++j) {
if (test_output_block[j] < 0)
test_input_block[j] = src[j] - dst[j];
const int pitch = 8;
- RunFwdTxfm(test_input_block, test_temp_block, dst, pitch, tx_type);
+ RunFwdTxfm(test_input_block, test_temp_block, dst, pitch, tx_type_);
for (int j = 0; j < 16; ++j) {
if(test_temp_block[j] > 0) {
}
// inverse transform and reconstruct the pixel block
- RunInvTxfm(test_input_block, test_temp_block, dst, pitch, tx_type);
+ RunInvTxfm(test_input_block, test_temp_block, dst, pitch, tx_type_);
for (int j = 0; j < 16; ++j) {
const int diff = dst[j] - src[j];
using libvpx_test::ACMRandom;
namespace {
+void fdct8x8(int16_t *in, int16_t *out, uint8_t *dst, int stride, int tx_type) {
+ vp9_short_fdct8x8_c(in, out, stride);
+}
+void idct8x8_add(int16_t *in, int16_t *out, uint8_t *dst,
+ int stride, int tx_type) {
+ vp9_short_idct8x8_add_c(out, dst, stride >> 1);
+}
+void fht8x8(int16_t *in, int16_t *out, uint8_t *dst, int stride, int tx_type) {
+ vp9_short_fht8x8_c(in, out, stride >> 1, tx_type);
+}
+void iht8x8_add(int16_t *in, int16_t *out, uint8_t *dst,
+ int stride, int tx_type) {
+ vp9_short_iht8x8_add_c(out, dst, stride >> 1, tx_type);
+}
+
+class FwdTrans8x8Test : public ::testing::TestWithParam<int> {
+ public:
+ FwdTrans8x8Test() { SetUpTestTxfm(); }
+ ~FwdTrans8x8Test() {}
+
+ void SetUpTestTxfm() {
+ tx_type_ = GetParam();
+ if (tx_type_ == 0) {
+ fwd_txfm = fdct8x8;
+ inv_txfm = idct8x8_add;
+ } else {
+ fwd_txfm = fht8x8;
+ inv_txfm = iht8x8_add;
+ }
+ }
+
+ protected:
+ void RunFwdTxfm(int16_t *in, int16_t *out, uint8_t *dst,
+ int stride, int tx_type) {
+ (*fwd_txfm)(in, out, dst, stride, tx_type);
+ }
+ void RunInvTxfm(int16_t *in, int16_t *out, uint8_t *dst,
+ int stride, int tx_type) {
+ (*inv_txfm)(in, out, dst, stride, tx_type);
+ }
+
+ int tx_type_;
+ void (*fwd_txfm)(int16_t*, int16_t*, uint8_t*, int, int);
+ void (*inv_txfm)(int16_t*, int16_t*, uint8_t*, int, int);
+};
-TEST(VP9Fdct8x8Test, SignBiasCheck) {
+TEST_P(FwdTrans8x8Test, SignBiasCheck) {
ACMRandom rnd(ACMRandom::DeterministicSeed());
int16_t test_input_block[64];
int16_t test_output_block[64];
for (int j = 0; j < 64; ++j)
test_input_block[j] = rnd.Rand8() - rnd.Rand8();
- vp9_short_fdct8x8_c(test_input_block, test_output_block, pitch);
+ RunFwdTxfm(test_input_block, test_output_block, NULL, pitch, tx_type_);
for (int j = 0; j < 64; ++j) {
if (test_output_block[j] < 0)
const int diff = abs(count_sign_block[j][0] - count_sign_block[j][1]);
const int max_diff = 1125;
EXPECT_LT(diff, max_diff)
- << "Error: 8x8 FDCT has a sign bias > "
+ << "Error: 8x8 FDCT/FHT has a sign bias > "
<< 1. * max_diff / count_test_block * 100 << "%"
<< " for input range [-255, 255] at index " << j
<< " count0: " << count_sign_block[j][0]
for (int j = 0; j < 64; ++j)
test_input_block[j] = (rnd.Rand8() >> 4) - (rnd.Rand8() >> 4);
- vp9_short_fdct8x8_c(test_input_block, test_output_block, pitch);
+ RunFwdTxfm(test_input_block, test_output_block, NULL, pitch, tx_type_);
for (int j = 0; j < 64; ++j) {
if (test_output_block[j] < 0)
const int diff = abs(count_sign_block[j][0] - count_sign_block[j][1]);
const int max_diff = 10000;
EXPECT_LT(diff, max_diff)
- << "Error: 4x4 FDCT has a sign bias > "
+ << "Error: 4x4 FDCT/FHT has a sign bias > "
<< 1. * max_diff / count_test_block * 100 << "%"
<< " for input range [-15, 15] at index " << j
<< " count0: " << count_sign_block[j][0]
<< " count1: " << count_sign_block[j][1]
<< " diff: " << diff;
}
-};
+}
-TEST(VP9Fdct8x8Test, RoundTripErrorCheck) {
+TEST_P(FwdTrans8x8Test, RoundTripErrorCheck) {
ACMRandom rnd(ACMRandom::DeterministicSeed());
int max_error = 0;
double total_error = 0;
test_input_block[j] = src[j] - dst[j];
const int pitch = 16;
- vp9_short_fdct8x8_c(test_input_block, test_temp_block, pitch);
+ RunFwdTxfm(test_input_block, test_temp_block, dst, pitch, tx_type_);
for (int j = 0; j < 64; ++j){
if(test_temp_block[j] > 0) {
test_temp_block[j] += 2;
test_temp_block[j] *= 4;
}
}
- vp9_short_idct8x8_add_c(test_temp_block, dst, 8);
+ RunInvTxfm(test_input_block, test_temp_block, dst, pitch, tx_type_);
for (int j = 0; j < 64; ++j) {
const int diff = dst[j] - src[j];
}
EXPECT_GE(1, max_error)
- << "Error: 8x8 FDCT/IDCT has an individual roundtrip error > 1";
+ << "Error: 8x8 FDCT/IDCT or FHT/IHT has an individual roundtrip error > 1";
EXPECT_GE(count_test_block/5, total_error)
- << "Error: 8x8 FDCT/IDCT has average roundtrip error > 1/5 per block";
-};
+ << "Error: 8x8 FDCT/IDCT or FHT/IHT has average roundtrip "
+ "error > 1/5 per block";
+}
-TEST(VP9Fdct8x8Test, ExtremalCheck) {
+TEST_P(FwdTrans8x8Test, ExtremalCheck) {
ACMRandom rnd(ACMRandom::DeterministicSeed());
int max_error = 0;
double total_error = 0;
test_input_block[j] = src[j] - dst[j];
const int pitch = 16;
- vp9_short_fdct8x8_c(test_input_block, test_temp_block, pitch);
- vp9_short_idct8x8_add_c(test_temp_block, dst, 8);
+ RunFwdTxfm(test_input_block, test_temp_block, dst, pitch, tx_type_);
+ RunInvTxfm(test_input_block, test_temp_block, dst, pitch, tx_type_);
for (int j = 0; j < 64; ++j) {
const int diff = dst[j] - src[j];
}
EXPECT_GE(1, max_error)
- << "Error: Extremal 8x8 FDCT/IDCT has an"
+ << "Error: Extremal 8x8 FDCT/IDCT or FHT/IHT has an"
<< " individual roundtrip error > 1";
EXPECT_GE(count_test_block/5, total_error)
- << "Error: Extremal 8x8 FDCT/IDCT has average"
+ << "Error: Extremal 8x8 FDCT/IDCT or FHT/IHT has average"
<< " roundtrip error > 1/5 per block";
}
-};
+}
+INSTANTIATE_TEST_CASE_P(VP9, FwdTrans8x8Test, ::testing::Range(0, 4));
} // namespace