Commit fdaad9f6 authored by Angie Chiang's avatar Angie Chiang

Refactor and add flip unit test to vp10_inv_txfm2d_test.cc

Change-Id: I6aa75c66429a0178852cf8df88f16eaa8e36b629
parent 909bbe73
...@@ -27,11 +27,6 @@ using libvpx_test::TYPE_TXFM; ...@@ -27,11 +27,6 @@ using libvpx_test::TYPE_TXFM;
namespace { namespace {
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
const Fwd_Txfm2d_Func fwd_txfm_func_ls[TX_SIZES] = {
vp10_fwd_txfm2d_4x4_c, vp10_fwd_txfm2d_8x8_c, vp10_fwd_txfm2d_16x16_c,
vp10_fwd_txfm2d_32x32_c};
// VP10FwdTxfm2dParam argument list:
// tx_type_, tx_size_, max_error_, max_avg_error_ // tx_type_, tx_size_, max_error_, max_avg_error_
typedef std::tr1::tuple<TX_TYPE, TX_SIZE, double, double> VP10FwdTxfm2dParam; typedef std::tr1::tuple<TX_TYPE, TX_SIZE, double, double> VP10FwdTxfm2dParam;
...@@ -53,7 +48,7 @@ class VP10FwdTxfm2d : public ::testing::TestWithParam<VP10FwdTxfm2dParam> { ...@@ -53,7 +48,7 @@ class VP10FwdTxfm2d : public ::testing::TestWithParam<VP10FwdTxfm2dParam> {
amplify_factor_ = amplify_factor_ =
amplify_bit >= 0 ? (1 << amplify_bit) : (1.0 / (1 << -amplify_bit)); amplify_bit >= 0 ? (1 << amplify_bit) : (1.0 / (1 << -amplify_bit));
fwd_txfm_ = fwd_txfm_func_ls[tx_size_]; fwd_txfm_ = libvpx_test::fwd_txfm_func_ls[tx_size_];
txfm1d_size_ = libvpx_test::get_txfm1d_size(tx_size_); txfm1d_size_ = libvpx_test::get_txfm1d_size(tx_size_);
txfm2d_size_ = txfm1d_size_ * txfm1d_size_; txfm2d_size_ = txfm1d_size_ * txfm1d_size_;
get_txfm1d_type(tx_type_, &type0_, &type1_); get_txfm1d_type(tx_type_, &type0_, &type1_);
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "./vp10_rtcd.h" #include "./vp10_rtcd.h"
#include "test/acm_random.h" #include "test/acm_random.h"
#include "test/util.h"
#include "test/vp10_txfm_test.h" #include "test/vp10_txfm_test.h"
#include "vp10/common/vp10_inv_txfm2d_cfg.h" #include "vp10/common/vp10_inv_txfm2d_cfg.h"
...@@ -27,90 +28,133 @@ using libvpx_test::Inv_Txfm2d_Func; ...@@ -27,90 +28,133 @@ using libvpx_test::Inv_Txfm2d_Func;
namespace { namespace {
#if CONFIG_VP9_HIGHBITDEPTH #if CONFIG_VP9_HIGHBITDEPTH
const int txfm_size_num = 5; // VP10InvTxfm2dParam argument list:
const int txfm_size_ls[5] = {4, 8, 16, 32, 64}; // tx_type_, tx_size_, max_error_, max_avg_error_
const int txfm_type[4] = {DCT_DCT, DCT_ADST, ADST_ADST, ADST_DCT}; typedef std::tr1::tuple<TX_TYPE, TX_SIZE, double, double> VP10InvTxfm2dParam;
const TXFM_2D_CFG* inv_txfm_cfg_ls[5][4] = {
{&inv_txfm_2d_cfg_dct_dct_4, &inv_txfm_2d_cfg_dct_adst_4, class VP10InvTxfm2d : public ::testing::TestWithParam<VP10InvTxfm2dParam> {
&inv_txfm_2d_cfg_adst_adst_4, &inv_txfm_2d_cfg_adst_dct_4}, public:
{&inv_txfm_2d_cfg_dct_dct_8, &inv_txfm_2d_cfg_dct_adst_8, virtual void SetUp() {
&inv_txfm_2d_cfg_adst_adst_8, &inv_txfm_2d_cfg_adst_dct_8}, tx_type_ = GET_PARAM(0);
{&inv_txfm_2d_cfg_dct_dct_16, &inv_txfm_2d_cfg_dct_adst_16, tx_size_ = GET_PARAM(1);
&inv_txfm_2d_cfg_adst_adst_16, &inv_txfm_2d_cfg_adst_dct_16}, max_error_ = GET_PARAM(2);
{&inv_txfm_2d_cfg_dct_dct_32, &inv_txfm_2d_cfg_dct_adst_32, max_avg_error_ = GET_PARAM(3);
&inv_txfm_2d_cfg_adst_adst_32, &inv_txfm_2d_cfg_adst_dct_32}, txfm1d_size_ = libvpx_test::get_txfm1d_size(tx_size_);
{&inv_txfm_2d_cfg_dct_dct_64, NULL, NULL, NULL}}; txfm2d_size_ = txfm1d_size_ * txfm1d_size_;
count_ = 500;
const Fwd_Txfm2d_Func fwd_txfm_func_ls[5] = { input_ = new int16_t[txfm2d_size_];
vp10_fwd_txfm2d_4x4_c, vp10_fwd_txfm2d_8x8_c, vp10_fwd_txfm2d_16x16_c, ref_input_ = new uint16_t[txfm2d_size_];
vp10_fwd_txfm2d_32x32_c, vp10_fwd_txfm2d_64x64_c}; output_ = new int32_t[txfm2d_size_];
const Inv_Txfm2d_Func inv_txfm_func_ls[5] = {
vp10_inv_txfm2d_add_4x4_c, vp10_inv_txfm2d_add_8x8_c, input_ = reinterpret_cast<int16_t *>
vp10_inv_txfm2d_add_16x16_c, vp10_inv_txfm2d_add_32x32_c, (vpx_memalign(16, sizeof(int16_t) * txfm2d_size_));
vp10_inv_txfm2d_add_64x64_c}; ref_input_ = reinterpret_cast<uint16_t *>
(vpx_memalign(16, sizeof(uint16_t) * txfm2d_size_));
const int txfm_type_num = 4; output_ = reinterpret_cast<int32_t *>
(vpx_memalign(16, sizeof(int32_t) * txfm2d_size_));
TEST(vp10_inv_txfm2d, round_trip) { }
for (int txfm_size_idx = 0; txfm_size_idx < txfm_size_num; ++txfm_size_idx) {
const int txfm_size = txfm_size_ls[txfm_size_idx]; void RunRoundtripCheck() {
const int sqr_txfm_size = txfm_size * txfm_size; const Fwd_Txfm2d_Func fwd_txfm_func =
int16_t* input = new int16_t[sqr_txfm_size]; libvpx_test::fwd_txfm_func_ls[tx_size_];
uint16_t* ref_input = new uint16_t[sqr_txfm_size]; const Inv_Txfm2d_Func inv_txfm_func =
int32_t* output = new int32_t[sqr_txfm_size]; libvpx_test::inv_txfm_func_ls[tx_size_];
double avg_abs_error = 0;
for (int txfm_type_idx = 0; txfm_type_idx < txfm_type_num; ACMRandom rnd(ACMRandom::DeterministicSeed());
++txfm_type_idx) { for (int ci = 0; ci < count_; ci++) {
const TXFM_2D_CFG* inv_txfm_cfg = for (int ni = 0; ni < txfm2d_size_; ++ni) {
inv_txfm_cfg_ls[txfm_size_idx][txfm_type_idx]; if (ci == 0) {
if (inv_txfm_cfg != NULL) { int extreme_input = input_base - 1;
int tx_type = txfm_type[txfm_type_idx]; input_[ni] = extreme_input; // extreme case
const Fwd_Txfm2d_Func fwd_txfm_func = fwd_txfm_func_ls[txfm_size_idx]; ref_input_[ni] = 0;
const Inv_Txfm2d_Func inv_txfm_func = inv_txfm_func_ls[txfm_size_idx]; } else {
const int count = 1000; input_[ni] = rnd.Rand16() % input_base;
double avg_abs_error = 0; ref_input_[ni] = 0;
if (txfm_size == 64 && tx_type != DCT_DCT)
continue;
ACMRandom rnd(ACMRandom::DeterministicSeed());
for (int ci = 0; ci < count; ci++) {
for (int ni = 0; ni < sqr_txfm_size; ++ni) {
if (ci == 0) {
int extreme_input = input_base - 1;
input[ni] = extreme_input; // extreme case
ref_input[ni] = 0;
} else {
input[ni] = rnd.Rand16() % input_base;
ref_input[ni] = 0;
}
}
fwd_txfm_func(input, output, txfm_size, tx_type, bd);
inv_txfm_func(output, ref_input, txfm_size, tx_type, bd);
for (int ni = 0; ni < sqr_txfm_size; ++ni) {
EXPECT_LE(abs(input[ni] - ref_input[ni]), 4);
}
avg_abs_error += compute_avg_abs_error<int16_t, uint16_t>(
input, ref_input, sqr_txfm_size);
} }
}
fwd_txfm_func(input_, output_, txfm1d_size_, tx_type_, bd);
inv_txfm_func(output_, ref_input_, txfm1d_size_, tx_type_, bd);
avg_abs_error /= count; for (int ni = 0; ni < txfm2d_size_; ++ni) {
// max_abs_avg_error comes from upper bound of EXPECT_GE(max_error_, abs(input_[ni] - ref_input_[ni]));
// printf("txfm_size: %d accuracy_avg_abs_error: %f\n",
// txfm_size, avg_abs_error);
// TODO(angiebird): this upper bound is from adst_adst_8
const double max_abs_avg_error = 0.4;
EXPECT_LE(avg_abs_error, max_abs_avg_error);
} }
avg_abs_error += compute_avg_abs_error<int16_t, uint16_t>(
input_, ref_input_, txfm2d_size_);
} }
delete[] input; avg_abs_error /= count_;
delete[] ref_input; // max_abs_avg_error comes from upper bound of
delete[] output; // printf("txfm1d_size: %d accuracy_avg_abs_error: %f\n",
// txfm1d_size_, avg_abs_error);
EXPECT_GE(max_avg_error_, avg_abs_error);
} }
}
virtual void TearDown() {
vpx_free(input_);
vpx_free(output_);
vpx_free(ref_input_);
}
private:
int count_;
int max_error_;
double max_avg_error_;
TX_TYPE tx_type_;
TX_SIZE tx_size_;
int txfm1d_size_;
int txfm2d_size_;
Fwd_Txfm2d_Func fwd_txfm_;
Inv_Txfm2d_Func inv_txfm_;
int16_t* input_;
uint16_t* ref_input_;
int32_t* output_;
};
TEST_P(VP10InvTxfm2d, RunRoundtripCheck) { RunRoundtripCheck(); }
INSTANTIATE_TEST_CASE_P(
C, VP10InvTxfm2d,
::testing::Values(
#if CONFIG_EXT_TX
VP10InvTxfm2dParam(FLIPADST_DCT, TX_4X4, 2, 0.002),
VP10InvTxfm2dParam(DCT_FLIPADST, TX_4X4, 2, 0.002),
VP10InvTxfm2dParam(FLIPADST_FLIPADST, TX_4X4, 2, 0.002),
VP10InvTxfm2dParam(ADST_FLIPADST, TX_4X4, 2, 0.002),
VP10InvTxfm2dParam(FLIPADST_ADST, TX_4X4, 2, 0.002),
VP10InvTxfm2dParam(FLIPADST_DCT, TX_8X8, 2, 0.02),
VP10InvTxfm2dParam(DCT_FLIPADST, TX_8X8, 2, 0.02),
VP10InvTxfm2dParam(FLIPADST_FLIPADST, TX_8X8, 2, 0.02),
VP10InvTxfm2dParam(ADST_FLIPADST, TX_8X8, 2, 0.02),
VP10InvTxfm2dParam(FLIPADST_ADST, TX_8X8, 2, 0.02),
VP10InvTxfm2dParam(FLIPADST_DCT, TX_16X16, 2, 0.04),
VP10InvTxfm2dParam(DCT_FLIPADST, TX_16X16, 2, 0.04),
VP10InvTxfm2dParam(FLIPADST_FLIPADST, TX_16X16, 11, 0.04),
VP10InvTxfm2dParam(ADST_FLIPADST, TX_16X16, 2, 0.04),
VP10InvTxfm2dParam(FLIPADST_ADST, TX_16X16, 2, 0.04),
VP10InvTxfm2dParam(FLIPADST_DCT, TX_32X32, 4, 0.4),
VP10InvTxfm2dParam(DCT_FLIPADST, TX_32X32, 4, 0.4),
VP10InvTxfm2dParam(FLIPADST_FLIPADST, TX_32X32, 4, 0.4),
VP10InvTxfm2dParam(ADST_FLIPADST, TX_32X32, 4, 0.4),
VP10InvTxfm2dParam(FLIPADST_ADST, TX_32X32, 4, 0.4),
#endif
VP10InvTxfm2dParam(DCT_DCT, TX_4X4, 2, 0.002),
VP10InvTxfm2dParam(ADST_DCT, TX_4X4, 2, 0.002),
VP10InvTxfm2dParam(DCT_ADST, TX_4X4, 2, 0.002),
VP10InvTxfm2dParam(ADST_ADST, TX_4X4, 2, 0.002),
VP10InvTxfm2dParam(DCT_DCT, TX_8X8, 2, 0.02),
VP10InvTxfm2dParam(ADST_DCT, TX_8X8, 2, 0.02),
VP10InvTxfm2dParam(DCT_ADST, TX_8X8, 2, 0.02),
VP10InvTxfm2dParam(ADST_ADST, TX_8X8, 2, 0.02),
VP10InvTxfm2dParam(DCT_DCT, TX_16X16, 2, 0.04),
VP10InvTxfm2dParam(ADST_DCT, TX_16X16, 2, 0.04),
VP10InvTxfm2dParam(DCT_ADST, TX_16X16, 2, 0.04),
VP10InvTxfm2dParam(ADST_ADST, TX_16X16, 2, 0.04),
VP10InvTxfm2dParam(DCT_DCT, TX_32X32, 4, 0.4),
VP10InvTxfm2dParam(ADST_DCT, TX_32X32, 4, 0.4),
VP10InvTxfm2dParam(DCT_ADST, TX_32X32, 4, 0.4),
VP10InvTxfm2dParam(ADST_ADST, TX_32X32, 4, 0.4)));
#endif // CONFIG_VP9_HIGHBITDEPTH #endif // CONFIG_VP9_HIGHBITDEPTH
} // namespace } // namespace
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "test/acm_random.h" #include "test/acm_random.h"
#include "vp10/common/enums.h" #include "vp10/common/enums.h"
#include "vp10/common/vp10_txfm.h" #include "vp10/common/vp10_txfm.h"
#include "./vp10_rtcd.h"
namespace libvpx_test { namespace libvpx_test {
typedef enum { typedef enum {
...@@ -74,5 +75,16 @@ typedef void (*Inv_Txfm2d_Func)(const int32_t*, uint16_t*, int, int, int); ...@@ -74,5 +75,16 @@ typedef void (*Inv_Txfm2d_Func)(const int32_t*, uint16_t*, int, int, int);
static const int bd = 10; static const int bd = 10;
static const int input_base = (1 << bd); static const int input_base = (1 << bd);
#if CONFIG_VP9_HIGHBITDEPTH
static const Fwd_Txfm2d_Func fwd_txfm_func_ls[TX_SIZES] = {
vp10_fwd_txfm2d_4x4_c, vp10_fwd_txfm2d_8x8_c, vp10_fwd_txfm2d_16x16_c,
vp10_fwd_txfm2d_32x32_c};
static const Inv_Txfm2d_Func inv_txfm_func_ls[TX_SIZES] = {
vp10_inv_txfm2d_add_4x4_c, vp10_inv_txfm2d_add_8x8_c,
vp10_inv_txfm2d_add_16x16_c, vp10_inv_txfm2d_add_32x32_c};
#endif // CONFIG_VP9_HIGHBITDEPTH
} // namespace libvpx_test } // namespace libvpx_test
#endif // VP10_TXFM_TEST_H_ #endif // VP10_TXFM_TEST_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment