Commit af87a7b0 authored by Angie Chiang's avatar Angie Chiang Committed by Gerrit Code Review
Browse files

Merge changes I6aa75c66,Id5f0fade,I368d365e,Ibaf7b00b into nextgenv2

* changes:
  Refactor and add flip unit test to vp10_inv_txfm2d_test.cc
  Add flip feature to vp10_inv_txfm2d.c
  add unit test for highbd flip transform
  Refactor vp10_fwd_txfm2d_test.cc
parents 09ed43ed fdaad9f6
......@@ -190,6 +190,7 @@ LIBVPX_TEST_SRCS-$(CONFIG_VP9_HIGHBITDEPTH) += hbd_metrics_test.cc
endif
LIBVPX_TEST_SRCS-$(CONFIG_ENCODERS) += sad_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP10) += vp10_txfm_test.h
LIBVPX_TEST_SRCS-$(CONFIG_VP10) += vp10_txfm_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP10) += vp10_fwd_txfm1d_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP10) += vp10_inv_txfm1d_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP10) += vp10_fwd_txfm2d_test.cc
......
......@@ -13,6 +13,7 @@
#include <stdlib.h>
#include "test/acm_random.h"
#include "test/util.h"
#include "test/vp10_txfm_test.h"
#include "vp10/common/vp10_txfm.h"
#include "./vp10_rtcd.h"
......@@ -23,80 +24,156 @@ using libvpx_test::bd;
using libvpx_test::compute_avg_abs_error;
using libvpx_test::Fwd_Txfm2d_Func;
using libvpx_test::TYPE_TXFM;
using libvpx_test::TYPE_DCT;
using libvpx_test::TYPE_ADST;
namespace {
#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};
const TYPE_TXFM type_ls_0[4] = {TYPE_DCT, TYPE_ADST, TYPE_DCT, TYPE_ADST};
const TYPE_TXFM type_ls_1[4] = {TYPE_DCT, TYPE_DCT, TYPE_ADST, TYPE_ADST};
TEST(vp10_fwd_txfm2d, accuracy) {
for (int tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
int txfm_size = 1 << (tx_size + 2);
int sqr_txfm_size = txfm_size * txfm_size;
int16_t* input = new int16_t[sqr_txfm_size];
int32_t* output = new int32_t[sqr_txfm_size];
double* ref_input = new double[sqr_txfm_size];
double* ref_output = new double[sqr_txfm_size];
for (int tx_type = 0; tx_type < 4; ++tx_type) {
TXFM_2D_FLIP_CFG fwd_txfm_flip_cfg =
vp10_get_fwd_txfm_cfg(tx_type, tx_size);
const TXFM_2D_CFG *fwd_txfm_cfg = fwd_txfm_flip_cfg.cfg;
if (fwd_txfm_cfg != NULL) {
Fwd_Txfm2d_Func fwd_txfm_func = fwd_txfm_func_ls[tx_size];
TYPE_TXFM type0 = type_ls_0[tx_type];
TYPE_TXFM type1 = type_ls_1[tx_type];
int amplify_bit = fwd_txfm_cfg->shift[0] + fwd_txfm_cfg->shift[1] +
fwd_txfm_cfg->shift[2];
double amplify_factor =
amplify_bit >= 0 ? (1 << amplify_bit) : (1.0 / (1 << -amplify_bit));
ACMRandom rnd(ACMRandom::DeterministicSeed());
int count = 500;
double avg_abs_error = 0;
for (int ci = 0; ci < count; ci++) {
for (int ni = 0; ni < sqr_txfm_size; ++ni) {
input[ni] = rnd.Rand16() % input_base;
ref_input[ni] = static_cast<double>(input[ni]);
output[ni] = 0;
ref_output[ni] = 0;
}
fwd_txfm_func(input, output, txfm_size, tx_type, bd);
reference_hybrid_2d(ref_input, ref_output, txfm_size, type0, type1);
for (int ni = 0; ni < sqr_txfm_size; ++ni) {
ref_output[ni] = round(ref_output[ni] * amplify_factor);
EXPECT_LE(fabs(output[ni] - ref_output[ni]) / amplify_factor, 70);
}
avg_abs_error += compute_avg_abs_error<int32_t, double>(
output, ref_output, sqr_txfm_size);
}
avg_abs_error /= amplify_factor;
avg_abs_error /= count;
// max_abs_avg_error comes from upper bound of avg_abs_error
// printf("type0: %d type1: %d txfm_size: %d accuracy_avg_abs_error:
// %f\n",
// type0, type1, txfm_size, avg_abs_error);
double max_abs_avg_error = 7;
EXPECT_LE(avg_abs_error, max_abs_avg_error);
// tx_type_, tx_size_, max_error_, max_avg_error_
typedef std::tr1::tuple<TX_TYPE, TX_SIZE, double, double> VP10FwdTxfm2dParam;
class VP10FwdTxfm2d : public ::testing::TestWithParam<VP10FwdTxfm2dParam> {
public:
virtual void SetUp() {
tx_type_ = GET_PARAM(0);
tx_size_ = GET_PARAM(1);
max_error_ = GET_PARAM(2);
max_avg_error_ = GET_PARAM(3);
count_ = 500;
TXFM_2D_FLIP_CFG fwd_txfm_flip_cfg =
vp10_get_fwd_txfm_cfg(tx_type_, tx_size_);
const TXFM_2D_CFG *fwd_txfm_cfg = fwd_txfm_flip_cfg.cfg;
int amplify_bit = fwd_txfm_cfg->shift[0] + fwd_txfm_cfg->shift[1] +
fwd_txfm_cfg->shift[2];
ud_flip_ = fwd_txfm_flip_cfg.ud_flip;
lr_flip_ = fwd_txfm_flip_cfg.lr_flip;
amplify_factor_ =
amplify_bit >= 0 ? (1 << amplify_bit) : (1.0 / (1 << -amplify_bit));
fwd_txfm_ = libvpx_test::fwd_txfm_func_ls[tx_size_];
txfm1d_size_ = libvpx_test::get_txfm1d_size(tx_size_);
txfm2d_size_ = txfm1d_size_ * txfm1d_size_;
get_txfm1d_type(tx_type_, &type0_, &type1_);
input_ = reinterpret_cast<int16_t *>
(vpx_memalign(16, sizeof(int16_t) * txfm2d_size_));
output_ = reinterpret_cast<int32_t *>
(vpx_memalign(16, sizeof(int32_t) * txfm2d_size_));
ref_input_ = reinterpret_cast<double *>
(vpx_memalign(16, sizeof(double) * txfm2d_size_));
ref_output_ = reinterpret_cast<double *>
(vpx_memalign(16, sizeof(double) * txfm2d_size_));
}
void RunFwdAccuracyCheck() {
ACMRandom rnd(ACMRandom::DeterministicSeed());
double avg_abs_error = 0;
for (int ci = 0; ci < count_; ci++) {
for (int ni = 0; ni < txfm2d_size_; ++ni) {
input_[ni] = rnd.Rand16() % input_base;
ref_input_[ni] = static_cast<double>(input_[ni]);
output_[ni] = 0;
ref_output_[ni] = 0;
}
fwd_txfm_(input_, output_, txfm1d_size_, tx_type_, bd);
if (lr_flip_ && ud_flip_)
libvpx_test::fliplrud(ref_input_, txfm1d_size_, txfm1d_size_);
else if (lr_flip_)
libvpx_test::fliplr(ref_input_, txfm1d_size_, txfm1d_size_);
else if (ud_flip_)
libvpx_test::flipud(ref_input_, txfm1d_size_, txfm1d_size_);
reference_hybrid_2d(ref_input_, ref_output_, txfm1d_size_,
type0_, type1_);
for (int ni = 0; ni < txfm2d_size_; ++ni) {
ref_output_[ni] = round(ref_output_[ni] * amplify_factor_);
EXPECT_GE(max_error_,
fabs(output_[ni] - ref_output_[ni]) / amplify_factor_);
}
avg_abs_error += compute_avg_abs_error<int32_t, double>(
output_, ref_output_, txfm2d_size_);
}
delete[] input;
delete[] output;
delete[] ref_input;
delete[] ref_output;
avg_abs_error /= amplify_factor_;
avg_abs_error /= count_;
// max_abs_avg_error comes from upper bound of avg_abs_error
// printf("type0: %d type1: %d txfm_size: %d accuracy_avg_abs_error:
// %f\n", type0_, type1_, 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_);
vpx_free(ref_output_);
}
private:
double max_error_;
double max_avg_error_;
int count_;
double amplify_factor_;
TX_TYPE tx_type_;
TX_SIZE tx_size_;
int txfm1d_size_;
int txfm2d_size_;
Fwd_Txfm2d_Func fwd_txfm_;
TYPE_TXFM type0_;
TYPE_TXFM type1_;
int16_t* input_;
int32_t* output_;
double* ref_input_;
double* ref_output_;
int ud_flip_; // flip upside down
int lr_flip_; // flip left to right
};
TEST_P(VP10FwdTxfm2d, RunFwdAccuracyCheck) {
RunFwdAccuracyCheck();
}
INSTANTIATE_TEST_CASE_P(
C, VP10FwdTxfm2d,
::testing::Values(
#if CONFIG_EXT_TX
VP10FwdTxfm2dParam(FLIPADST_DCT, TX_4X4, 2, 0.2),
VP10FwdTxfm2dParam(DCT_FLIPADST, TX_4X4, 2, 0.2),
VP10FwdTxfm2dParam(FLIPADST_FLIPADST, TX_4X4, 2, 0.2),
VP10FwdTxfm2dParam(ADST_FLIPADST, TX_4X4, 2, 0.2),
VP10FwdTxfm2dParam(FLIPADST_ADST, TX_4X4, 2, 0.2),
VP10FwdTxfm2dParam(FLIPADST_DCT, TX_8X8, 5, 0.6),
VP10FwdTxfm2dParam(DCT_FLIPADST, TX_8X8, 5, 0.6),
VP10FwdTxfm2dParam(FLIPADST_FLIPADST, TX_8X8, 5, 0.6),
VP10FwdTxfm2dParam(ADST_FLIPADST, TX_8X8, 5, 0.6),
VP10FwdTxfm2dParam(FLIPADST_ADST, TX_8X8, 5, 0.6),
VP10FwdTxfm2dParam(FLIPADST_DCT, TX_16X16, 11, 1.5),
VP10FwdTxfm2dParam(DCT_FLIPADST, TX_16X16, 11, 1.5),
VP10FwdTxfm2dParam(FLIPADST_FLIPADST, TX_16X16, 11, 1.5),
VP10FwdTxfm2dParam(ADST_FLIPADST, TX_16X16, 11, 1.5),
VP10FwdTxfm2dParam(FLIPADST_ADST, TX_16X16, 11, 1.5),
VP10FwdTxfm2dParam(FLIPADST_DCT, TX_32X32, 70, 7),
VP10FwdTxfm2dParam(DCT_FLIPADST, TX_32X32, 70, 7),
VP10FwdTxfm2dParam(FLIPADST_FLIPADST, TX_32X32, 70, 7),
VP10FwdTxfm2dParam(ADST_FLIPADST, TX_32X32, 70, 7),
VP10FwdTxfm2dParam(FLIPADST_ADST, TX_32X32, 70, 7),
#endif
VP10FwdTxfm2dParam(DCT_DCT, TX_4X4, 2, 0.2),
VP10FwdTxfm2dParam(ADST_DCT, TX_4X4, 2, 0.2),
VP10FwdTxfm2dParam(DCT_ADST, TX_4X4, 2, 0.2),
VP10FwdTxfm2dParam(ADST_ADST, TX_4X4, 2, 0.2),
VP10FwdTxfm2dParam(DCT_DCT, TX_8X8, 5, 0.6),
VP10FwdTxfm2dParam(ADST_DCT, TX_8X8, 5, 0.6),
VP10FwdTxfm2dParam(DCT_ADST, TX_8X8, 5, 0.6),
VP10FwdTxfm2dParam(ADST_ADST, TX_8X8, 5, 0.6),
VP10FwdTxfm2dParam(DCT_DCT, TX_16X16, 11, 1.5),
VP10FwdTxfm2dParam(ADST_DCT, TX_16X16, 11, 1.5),
VP10FwdTxfm2dParam(DCT_ADST, TX_16X16, 11, 1.5),
VP10FwdTxfm2dParam(ADST_ADST, TX_16X16, 11, 1.5),
VP10FwdTxfm2dParam(DCT_DCT, TX_32X32, 70, 7),
VP10FwdTxfm2dParam(ADST_DCT, TX_32X32, 70, 7),
VP10FwdTxfm2dParam(DCT_ADST, TX_32X32, 70, 7),
VP10FwdTxfm2dParam(ADST_ADST, TX_32X32, 70, 7)));
#endif // CONFIG_VP9_HIGHBITDEPTH
} // namespace
......@@ -14,6 +14,7 @@
#include "./vp10_rtcd.h"
#include "test/acm_random.h"
#include "test/util.h"
#include "test/vp10_txfm_test.h"
#include "vp10/common/vp10_inv_txfm2d_cfg.h"
......@@ -27,90 +28,133 @@ using libvpx_test::Inv_Txfm2d_Func;
namespace {
#if CONFIG_VP9_HIGHBITDEPTH
const int txfm_size_num = 5;
const int txfm_size_ls[5] = {4, 8, 16, 32, 64};
const int txfm_type[4] = {DCT_DCT, DCT_ADST, ADST_ADST, ADST_DCT};
const TXFM_2D_CFG* inv_txfm_cfg_ls[5][4] = {
{&inv_txfm_2d_cfg_dct_dct_4, &inv_txfm_2d_cfg_dct_adst_4,
&inv_txfm_2d_cfg_adst_adst_4, &inv_txfm_2d_cfg_adst_dct_4},
{&inv_txfm_2d_cfg_dct_dct_8, &inv_txfm_2d_cfg_dct_adst_8,
&inv_txfm_2d_cfg_adst_adst_8, &inv_txfm_2d_cfg_adst_dct_8},
{&inv_txfm_2d_cfg_dct_dct_16, &inv_txfm_2d_cfg_dct_adst_16,
&inv_txfm_2d_cfg_adst_adst_16, &inv_txfm_2d_cfg_adst_dct_16},
{&inv_txfm_2d_cfg_dct_dct_32, &inv_txfm_2d_cfg_dct_adst_32,
&inv_txfm_2d_cfg_adst_adst_32, &inv_txfm_2d_cfg_adst_dct_32},
{&inv_txfm_2d_cfg_dct_dct_64, NULL, NULL, NULL}};
const Fwd_Txfm2d_Func fwd_txfm_func_ls[5] = {
vp10_fwd_txfm2d_4x4_c, vp10_fwd_txfm2d_8x8_c, vp10_fwd_txfm2d_16x16_c,
vp10_fwd_txfm2d_32x32_c, vp10_fwd_txfm2d_64x64_c};
const Inv_Txfm2d_Func inv_txfm_func_ls[5] = {
vp10_inv_txfm2d_add_4x4_c, vp10_inv_txfm2d_add_8x8_c,
vp10_inv_txfm2d_add_16x16_c, vp10_inv_txfm2d_add_32x32_c,
vp10_inv_txfm2d_add_64x64_c};
const int txfm_type_num = 4;
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];
const int sqr_txfm_size = txfm_size * txfm_size;
int16_t* input = new int16_t[sqr_txfm_size];
uint16_t* ref_input = new uint16_t[sqr_txfm_size];
int32_t* output = new int32_t[sqr_txfm_size];
for (int txfm_type_idx = 0; txfm_type_idx < txfm_type_num;
++txfm_type_idx) {
const TXFM_2D_CFG* inv_txfm_cfg =
inv_txfm_cfg_ls[txfm_size_idx][txfm_type_idx];
if (inv_txfm_cfg != NULL) {
int tx_type = txfm_type[txfm_type_idx];
const Fwd_Txfm2d_Func fwd_txfm_func = fwd_txfm_func_ls[txfm_size_idx];
const Inv_Txfm2d_Func inv_txfm_func = inv_txfm_func_ls[txfm_size_idx];
const int count = 1000;
double avg_abs_error = 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);
// VP10InvTxfm2dParam argument list:
// tx_type_, tx_size_, max_error_, max_avg_error_
typedef std::tr1::tuple<TX_TYPE, TX_SIZE, double, double> VP10InvTxfm2dParam;
class VP10InvTxfm2d : public ::testing::TestWithParam<VP10InvTxfm2dParam> {
public:
virtual void SetUp() {
tx_type_ = GET_PARAM(0);
tx_size_ = GET_PARAM(1);
max_error_ = GET_PARAM(2);
max_avg_error_ = GET_PARAM(3);
txfm1d_size_ = libvpx_test::get_txfm1d_size(tx_size_);
txfm2d_size_ = txfm1d_size_ * txfm1d_size_;
count_ = 500;
input_ = new int16_t[txfm2d_size_];
ref_input_ = new uint16_t[txfm2d_size_];
output_ = new int32_t[txfm2d_size_];
input_ = reinterpret_cast<int16_t *>
(vpx_memalign(16, sizeof(int16_t) * txfm2d_size_));
ref_input_ = reinterpret_cast<uint16_t *>
(vpx_memalign(16, sizeof(uint16_t) * txfm2d_size_));
output_ = reinterpret_cast<int32_t *>
(vpx_memalign(16, sizeof(int32_t) * txfm2d_size_));
}
void RunRoundtripCheck() {
const Fwd_Txfm2d_Func fwd_txfm_func =
libvpx_test::fwd_txfm_func_ls[tx_size_];
const Inv_Txfm2d_Func inv_txfm_func =
libvpx_test::inv_txfm_func_ls[tx_size_];
double avg_abs_error = 0;
ACMRandom rnd(ACMRandom::DeterministicSeed());
for (int ci = 0; ci < count_; ci++) {
for (int ni = 0; ni < txfm2d_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_, txfm1d_size_, tx_type_, bd);
inv_txfm_func(output_, ref_input_, txfm1d_size_, tx_type_, bd);
avg_abs_error /= count;
// max_abs_avg_error comes from upper bound of
// 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);
for (int ni = 0; ni < txfm2d_size_; ++ni) {
EXPECT_GE(max_error_, abs(input_[ni] - ref_input_[ni]));
}
avg_abs_error += compute_avg_abs_error<int16_t, uint16_t>(
input_, ref_input_, txfm2d_size_);
}
delete[] input;
delete[] ref_input;
delete[] output;
avg_abs_error /= count_;
// max_abs_avg_error comes from upper bound of
// 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
} // namespace
/*
* Copyright (c) 2015 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include <stdio.h>
#include "test/vp10_txfm_test.h"
namespace libvpx_test {
int get_txfm1d_size(TX_SIZE tx_size) {
return 1 << (tx_size + 2);
}
void get_txfm1d_type(TX_TYPE txfm2d_type, TYPE_TXFM* type0,
TYPE_TXFM* type1) {
switch (txfm2d_type) {
case DCT_DCT:
*type0 = TYPE_DCT;
*type1 = TYPE_DCT;
break;
case ADST_DCT:
*type0 = TYPE_ADST;
*type1 = TYPE_DCT;
break;
case DCT_ADST:
*type0 = TYPE_DCT;
*type1 = TYPE_ADST;
break;
case ADST_ADST:
*type0 = TYPE_ADST;
*type1 = TYPE_ADST;
break;
#if CONFIG_EXT_TX
case FLIPADST_DCT:
*type0 = TYPE_ADST;
*type1 = TYPE_DCT;
break;
case DCT_FLIPADST:
*type0 = TYPE_DCT;
*type1 = TYPE_ADST;
break;
case FLIPADST_FLIPADST:
*type0 = TYPE_ADST;
*type1 = TYPE_ADST;
break;
case ADST_FLIPADST:
*type0 = TYPE_ADST;
*type1 = TYPE_ADST;
break;
case FLIPADST_ADST:
*type0 = TYPE_ADST;
*type1 = TYPE_ADST;
break;
#endif // CONFIG_EXT_TX
default:
*type0 = TYPE_DCT;
*type1 = TYPE_DCT;
assert(0);
break;
}
}
double invSqrt2 = 1 / pow(2, 0.5);
void reference_dct_1d(const double* in, double* out, int size) {
for (int k = 0; k < size; ++k) {
out[k] = 0;
for (int n = 0; n < size; ++n) {
out[k] += in[n] * cos(M_PI * (2 * n + 1) * k / (2 * size));
}
if (k == 0) out[k] = out[k] * invSqrt2;
}
}
void reference_adst_1d(const double* in, double* out, int size) {
for (int k = 0; k < size; ++k) {
out[k] = 0;
for (int n = 0; n < size; ++n) {
out[k] += in[n] * sin(M_PI * (2 * n + 1) * (2 * k + 1) / (4 * size));
}
}
}
void reference_hybrid_1d(double* in, double* out, int size, int type) {
if (type == TYPE_DCT)
reference_dct_1d(in, out, size);
else
reference_adst_1d(in, out, size);
}
void reference_hybrid_2d(double* in, double* out, int size,
int type0, int type1) {
double* tempOut = new double[size * size];
for (int r = 0; r < size; r++) {
// out ->tempOut
for (int c = 0; c < size; c++) {
tempOut[r * size + c] = in[c * size + r];
}
}
// dct each row: in -> out
for (int r = 0; r < size; r++) {
reference_hybrid_1d(tempOut + r * size, out + r * size, size, type0);
}
for (int r = 0; r < size; r++) {
// out ->tempOut
for (int c = 0; c < size; c++) {
tempOut[r * size + c] = out[c * size + r];
}
}
for (int r = 0; r < size; r++) {
reference_hybrid_1d(tempOut + r * size, out + r * size, size, type1);
}
delete[] tempOut;
}
template<typename Type>
void fliplr(Type *dest, int stride, int length) {
int i, j;
for (i = 0; i < length; ++i) {
for (j = 0; j < length / 2; ++j) {
const Type tmp = dest[i * stride + j];
dest[i * stride + j] = dest[i * stride + length - 1 - j];
dest[i * stride + length - 1 - j] = tmp;
}
}
}
template<typename Type>
void flipud(Type *dest, int stride, int length) {