Modify warp unit-test for different params
AV1WarpFilterTest and AV1HighbdWarpFilterTest have been modified
to test for different values of alpha, beta, gamma and delta.
Change-Id: If5767e6f79a73cdf8d1892f556524d1795630281
diff --git a/test/warp_filter_test.cc b/test/warp_filter_test.cc
index 15f8a28..f251a6d 100644
--- a/test/warp_filter_test.cc
+++ b/test/warp_filter_test.cc
@@ -18,15 +18,19 @@
namespace {
#if HAVE_SSE4_1
-TEST_P(AV1WarpFilterTest, CheckOutput) { RunCheckOutput(GET_PARAM(3)); }
-TEST_P(AV1WarpFilterTest, DISABLED_Speed) { RunSpeedTest(GET_PARAM(3)); }
+TEST_P(AV1WarpFilterTest, CheckOutput) { RunCheckOutput(GET_PARAM(0).func); }
+TEST_P(AV1WarpFilterTest, DISABLED_Speed) { RunSpeedTest(GET_PARAM(0).func); }
INSTANTIATE_TEST_CASE_P(
SSE4_1, AV1WarpFilterTest,
libaom_test::AV1WarpFilter::BuildParams(av1_warp_affine_sse4_1));
-TEST_P(AV1HighbdWarpFilterTest, CheckOutput) { RunCheckOutput(GET_PARAM(4)); }
-TEST_P(AV1HighbdWarpFilterTest, DISABLED_Speed) { RunSpeedTest(GET_PARAM(4)); }
+TEST_P(AV1HighbdWarpFilterTest, CheckOutput) {
+ RunCheckOutput(GET_PARAM(0).func);
+}
+TEST_P(AV1HighbdWarpFilterTest, DISABLED_Speed) {
+ RunSpeedTest(GET_PARAM(0).func);
+}
INSTANTIATE_TEST_CASE_P(SSE4_1, AV1HighbdWarpFilterTest,
libaom_test::AV1HighbdWarpFilter::BuildParams(
diff --git a/test/warp_filter_test_util.cc b/test/warp_filter_test_util.cc
index b341cd0..65c9711 100644
--- a/test/warp_filter_test_util.cc
+++ b/test/warp_filter_test_util.cc
@@ -28,22 +28,35 @@
void generate_warped_model(libaom_test::ACMRandom *rnd, int32_t *mat,
int16_t *alpha, int16_t *beta, int16_t *gamma,
- int16_t *delta) {
+ int16_t *delta, const int is_alpha_zero,
+ const int is_beta_zero, const int is_gamma_zero,
+ const int is_delta_zero) {
while (1) {
+ int rnd8 = rnd->Rand8() & 3;
mat[0] = random_warped_param(rnd, WARPEDMODEL_PREC_BITS + 6);
mat[1] = random_warped_param(rnd, WARPEDMODEL_PREC_BITS + 6);
mat[2] = (random_warped_param(rnd, WARPEDMODEL_PREC_BITS - 3)) +
(1 << WARPEDMODEL_PREC_BITS);
mat[3] = random_warped_param(rnd, WARPEDMODEL_PREC_BITS - 3);
- // 50/50 chance of generating ROTZOOM vs. AFFINE models
- if (rnd->Rand8() & 1) {
+
+ if (rnd8 <= 1) {
// AFFINE
mat[4] = random_warped_param(rnd, WARPEDMODEL_PREC_BITS - 3);
mat[5] = (random_warped_param(rnd, WARPEDMODEL_PREC_BITS - 3)) +
(1 << WARPEDMODEL_PREC_BITS);
- } else {
+ } else if (rnd8 == 2) {
mat[4] = -mat[3];
mat[5] = mat[2];
+ } else {
+ mat[4] = random_warped_param(rnd, WARPEDMODEL_PREC_BITS - 3);
+ mat[5] = (random_warped_param(rnd, WARPEDMODEL_PREC_BITS - 3)) +
+ (1 << WARPEDMODEL_PREC_BITS);
+ if (is_alpha_zero == 1) mat[2] = 1 << WARPEDMODEL_PREC_BITS;
+ if (is_beta_zero == 1) mat[3] = 0;
+ if (is_gamma_zero == 1) mat[4] = 0;
+ if (is_delta_zero == 1)
+ mat[5] = (((int64_t)mat[3] * mat[4] + (mat[2] / 2)) / mat[2]) +
+ (1 << WARPEDMODEL_PREC_BITS);
}
// Calculate the derived parameters and check that they are suitable
@@ -78,14 +91,16 @@
}
namespace AV1WarpFilter {
-::testing::internal::ParamGenerator<WarpTestParam> BuildParams(
+::testing::internal::ParamGenerator<WarpTestParams> BuildParams(
warp_affine_func filter) {
- const WarpTestParam params[] = {
- make_tuple(4, 4, 50000, filter), make_tuple(8, 8, 50000, filter),
- make_tuple(64, 64, 1000, filter), make_tuple(4, 16, 20000, filter),
- make_tuple(32, 8, 10000, filter),
+ WarpTestParam params[] = {
+ { 4, 4, 50000, filter }, { 8, 8, 50000, filter },
+ { 64, 64, 1000, filter }, { 4, 16, 20000, filter },
+ { 32, 8, 10000, filter },
};
- return ::testing::ValuesIn(params);
+ return ::testing::Combine(::testing::ValuesIn(params),
+ ::testing::Values(0, 1), ::testing::Values(0, 1),
+ ::testing::Values(0, 1), ::testing::Values(0, 1));
}
AV1WarpFilterTest::~AV1WarpFilterTest() {}
@@ -97,7 +112,12 @@
const int w = 128, h = 128;
const int border = 16;
const int stride = w + 2 * border;
- const int out_w = GET_PARAM(0), out_h = GET_PARAM(1);
+ WarpTestParam params = GET_PARAM(0);
+ const int out_w = params.out_w, out_h = params.out_h;
+ const int is_alpha_zero = GET_PARAM(1);
+ const int is_beta_zero = GET_PARAM(2);
+ const int is_gamma_zero = GET_PARAM(3);
+ const int is_delta_zero = GET_PARAM(4);
int sub_x, sub_y;
const int bd = 8;
@@ -112,8 +132,9 @@
int16_t alpha, beta, gamma, delta;
ConvolveParams conv_params = get_conv_params(0, 0, 0, bd);
CONV_BUF_TYPE *dsta = new CONV_BUF_TYPE[output_n];
-
- generate_warped_model(&rnd_, mat, &alpha, &beta, &gamma, &delta);
+ generate_warped_model(&rnd_, mat, &alpha, &beta, &gamma, &delta,
+ is_alpha_zero, is_beta_zero, is_gamma_zero,
+ is_delta_zero);
for (int r = 0; r < h; ++r)
for (int c = 0; c < w; ++c) input[r * stride + c] = rnd_.Rand8();
@@ -150,8 +171,13 @@
const int w = 128, h = 128;
const int border = 16;
const int stride = w + 2 * border;
- const int out_w = GET_PARAM(0), out_h = GET_PARAM(1);
- const int num_iters = GET_PARAM(2);
+ WarpTestParam params = GET_PARAM(0);
+ const int is_alpha_zero = GET_PARAM(1);
+ const int is_beta_zero = GET_PARAM(2);
+ const int is_gamma_zero = GET_PARAM(3);
+ const int is_delta_zero = GET_PARAM(4);
+ const int out_w = params.out_w, out_h = params.out_h;
+ const int num_iters = params.num_iter;
int i, j, sub_x, sub_y;
const int bd = 8;
@@ -180,7 +206,10 @@
const int use_no_round = rnd_.Rand8() & 1;
for (sub_x = 0; sub_x < 2; ++sub_x)
for (sub_y = 0; sub_y < 2; ++sub_y) {
- generate_warped_model(&rnd_, mat, &alpha, &beta, &gamma, &delta);
+ generate_warped_model(&rnd_, mat, &alpha, &beta, &gamma, &delta,
+ is_alpha_zero, is_beta_zero, is_gamma_zero,
+ is_delta_zero);
+
for (int ii = 0; ii < 2; ++ii) {
for (int jj = 0; jj < 5; ++jj) {
for (int do_average = 0; do_average <= 1; ++do_average) {
@@ -246,19 +275,21 @@
} // namespace AV1WarpFilter
namespace AV1HighbdWarpFilter {
-::testing::internal::ParamGenerator<HighbdWarpTestParam> BuildParams(
+::testing::internal::ParamGenerator<HighbdWarpTestParams> BuildParams(
highbd_warp_affine_func filter) {
const HighbdWarpTestParam params[] = {
- make_tuple(4, 4, 100, 8, filter), make_tuple(8, 8, 100, 8, filter),
- make_tuple(64, 64, 100, 8, filter), make_tuple(4, 16, 100, 8, filter),
- make_tuple(32, 8, 100, 8, filter), make_tuple(4, 4, 100, 10, filter),
- make_tuple(8, 8, 100, 10, filter), make_tuple(64, 64, 100, 10, filter),
- make_tuple(4, 16, 100, 10, filter), make_tuple(32, 8, 100, 10, filter),
- make_tuple(4, 4, 100, 12, filter), make_tuple(8, 8, 100, 12, filter),
- make_tuple(64, 64, 100, 12, filter), make_tuple(4, 16, 100, 12, filter),
- make_tuple(32, 8, 100, 12, filter),
+ { 4, 4, 100, 8, filter }, { 8, 8, 100, 8, filter },
+ { 64, 64, 100, 8, filter }, { 4, 16, 100, 8, filter },
+ { 32, 8, 100, 8, filter }, { 4, 4, 100, 10, filter },
+ { 8, 8, 100, 10, filter }, { 64, 64, 100, 10, filter },
+ { 4, 16, 100, 10, filter }, { 32, 8, 100, 10, filter },
+ { 4, 4, 100, 12, filter }, { 8, 8, 100, 12, filter },
+ { 64, 64, 100, 12, filter }, { 4, 16, 100, 12, filter },
+ { 32, 8, 100, 12, filter },
};
- return ::testing::ValuesIn(params);
+ return ::testing::Combine(::testing::ValuesIn(params),
+ ::testing::Values(0, 1), ::testing::Values(0, 1),
+ ::testing::Values(0, 1), ::testing::Values(0, 1));
}
AV1HighbdWarpFilterTest::~AV1HighbdWarpFilterTest() {}
@@ -272,8 +303,13 @@
const int w = 128, h = 128;
const int border = 16;
const int stride = w + 2 * border;
- const int out_w = GET_PARAM(0), out_h = GET_PARAM(1);
- const int bd = GET_PARAM(3);
+ HighbdWarpTestParam param = GET_PARAM(0);
+ const int is_alpha_zero = GET_PARAM(1);
+ const int is_beta_zero = GET_PARAM(2);
+ const int is_gamma_zero = GET_PARAM(3);
+ const int is_delta_zero = GET_PARAM(4);
+ const int out_w = param.out_w, out_h = param.out_h;
+ const int bd = param.bd;
const int mask = (1 << bd) - 1;
int sub_x, sub_y;
@@ -288,7 +324,9 @@
ConvolveParams conv_params = get_conv_params(0, 0, 0, bd);
CONV_BUF_TYPE *dsta = new CONV_BUF_TYPE[output_n];
- generate_warped_model(&rnd_, mat, &alpha, &beta, &gamma, &delta);
+ generate_warped_model(&rnd_, mat, &alpha, &beta, &gamma, &delta,
+ is_alpha_zero, is_beta_zero, is_gamma_zero,
+ is_delta_zero);
// Generate an input block and extend its borders horizontally
for (int r = 0; r < h; ++r)
for (int c = 0; c < w; ++c) input[r * stride + c] = rnd_.Rand16() & mask;
@@ -328,9 +366,14 @@
const int w = 128, h = 128;
const int border = 16;
const int stride = w + 2 * border;
- const int out_w = GET_PARAM(0), out_h = GET_PARAM(1);
- const int num_iters = GET_PARAM(2);
- const int bd = GET_PARAM(3);
+ HighbdWarpTestParam param = GET_PARAM(0);
+ const int is_alpha_zero = GET_PARAM(1);
+ const int is_beta_zero = GET_PARAM(2);
+ const int is_gamma_zero = GET_PARAM(3);
+ const int is_delta_zero = GET_PARAM(4);
+ const int out_w = param.out_w, out_h = param.out_h;
+ const int bd = param.bd;
+ const int num_iters = param.num_iter;
const int mask = (1 << bd) - 1;
int i, j, sub_x, sub_y;
@@ -361,7 +404,9 @@
const int use_no_round = rnd_.Rand8() & 1;
for (sub_x = 0; sub_x < 2; ++sub_x)
for (sub_y = 0; sub_y < 2; ++sub_y) {
- generate_warped_model(&rnd_, mat, &alpha, &beta, &gamma, &delta);
+ generate_warped_model(&rnd_, mat, &alpha, &beta, &gamma, &delta,
+ is_alpha_zero, is_beta_zero, is_gamma_zero,
+ is_delta_zero);
for (int ii = 0; ii < 2; ++ii) {
for (int jj = 0; jj < 5; ++jj) {
for (int do_average = 0; do_average <= 1; ++do_average) {
diff --git a/test/warp_filter_test_util.h b/test/warp_filter_test_util.h
index cf72d9d..bfc2bfa 100644
--- a/test/warp_filter_test_util.h
+++ b/test/warp_filter_test_util.h
@@ -28,7 +28,8 @@
void generate_warped_model(libaom_test::ACMRandom *rnd, int32_t *mat,
int16_t *alpha, int16_t *beta, int16_t *gamma,
- int16_t *delta);
+ int16_t *delta, int is_alpha_zero, int is_beta_zero,
+ int is_gamma_zero, int is_delta_zero);
namespace AV1WarpFilter {
@@ -40,12 +41,19 @@
ConvolveParams *conv_params, int16_t alpha,
int16_t beta, int16_t gamma, int16_t delta);
-typedef ::testing::tuple<int, int, int, warp_affine_func> WarpTestParam;
+typedef struct WarpTestParam {
+ int out_w;
+ int out_h;
+ int num_iter;
+ warp_affine_func func;
+} WarpTestParam;
-::testing::internal::ParamGenerator<WarpTestParam> BuildParams(
+typedef ::testing::tuple<WarpTestParam, int, int, int, int> WarpTestParams;
+
+::testing::internal::ParamGenerator<WarpTestParams> BuildParams(
warp_affine_func filter);
-class AV1WarpFilterTest : public ::testing::TestWithParam<WarpTestParam> {
+class AV1WarpFilterTest : public ::testing::TestWithParam<WarpTestParams> {
public:
virtual ~AV1WarpFilterTest();
virtual void SetUp();
@@ -71,14 +79,22 @@
int16_t alpha, int16_t beta,
int16_t gamma, int16_t delta);
-typedef ::testing::tuple<int, int, int, int, highbd_warp_affine_func>
- HighbdWarpTestParam;
+typedef struct HighbdWarpTestParam {
+ int out_w;
+ int out_h;
+ int num_iter;
+ int bd;
+ highbd_warp_affine_func func;
+} HighbdWarpTestParam;
-::testing::internal::ParamGenerator<HighbdWarpTestParam> BuildParams(
+typedef ::testing::tuple<HighbdWarpTestParam, int, int, int, int>
+ HighbdWarpTestParams;
+
+::testing::internal::ParamGenerator<HighbdWarpTestParams> BuildParams(
highbd_warp_affine_func filter);
class AV1HighbdWarpFilterTest
- : public ::testing::TestWithParam<HighbdWarpTestParam> {
+ : public ::testing::TestWithParam<HighbdWarpTestParams> {
public:
virtual ~AV1HighbdWarpFilterTest();
virtual void SetUp();