Commit 56d8b95f authored by Cheng Chen's avatar Cheng Chen

JNT_COMP: unit tests for av1_highbd_jnt_convolve_2d_sse4_1

Change-Id: I9ab059d996e1a033f50ddd5b369ffe3c6635c157
parent 501acee3
......@@ -16,31 +16,36 @@ using std::tr1::tuple;
using std::tr1::make_tuple;
using libaom_test::ACMRandom;
using libaom_test::AV1Convolve2D::AV1Convolve2DTest;
#if CONFIG_JNT_COMP
using libaom_test::AV1Convolve2D::AV1JntConvolve2DTest;
#endif
#if CONFIG_HIGHBITDEPTH
using libaom_test::AV1HighbdConvolve2D::AV1HighbdConvolve2DTest;
#if CONFIG_JNT_COMP
using libaom_test::AV1HighbdConvolve2D::AV1HighbdJntConvolve2DTest;
#endif
#endif
namespace {
#if CONFIG_JNT_COMP
TEST_P(AV1Convolve2DTest, CheckOutput) { RunCheckOutput(GET_PARAM(2)); }
#if HAVE_SSE4_1
TEST_P(AV1Convolve2DTest, CheckOutput2) { RunCheckOutput2(GET_PARAM(3)); }
#endif
INSTANTIATE_TEST_CASE_P(SSE4_1, AV1Convolve2DTest,
libaom_test::AV1Convolve2D::BuildParams(
av1_convolve_2d_sse2, av1_jnt_convolve_2d_sse4_1));
#else
TEST_P(AV1Convolve2DTest, CheckOutput) { RunCheckOutput(GET_PARAM(2)); }
INSTANTIATE_TEST_CASE_P(
SSE2, AV1Convolve2DTest,
libaom_test::AV1Convolve2D::BuildParams(av1_convolve_2d_sse2));
#if HAVE_AVX2
INSTANTIATE_TEST_CASE_P(
AVX2, AV1Convolve2DTest,
libaom_test::AV1Convolve2D::BuildParams(av1_convolve_2d_avx2));
#endif // CONFIG_JNT_COMP
#endif
#if CONFIG_JNT_COMP && HAVE_SSE4_1
TEST_P(AV1JntConvolve2DTest, CheckOutput) { RunCheckOutput(GET_PARAM(2)); }
INSTANTIATE_TEST_CASE_P(
SSE4_1, AV1JntConvolve2DTest,
libaom_test::AV1Convolve2D::BuildParams(av1_jnt_convolve_2d_sse4_1));
#endif
#if CONFIG_HIGHBITDEPTH && HAVE_SSSE3
TEST_P(AV1HighbdConvolve2DTest, CheckOutput) { RunCheckOutput(GET_PARAM(3)); }
......@@ -48,10 +53,21 @@ TEST_P(AV1HighbdConvolve2DTest, CheckOutput) { RunCheckOutput(GET_PARAM(3)); }
INSTANTIATE_TEST_CASE_P(SSSE3, AV1HighbdConvolve2DTest,
libaom_test::AV1HighbdConvolve2D::BuildParams(
av1_highbd_convolve_2d_ssse3));
#if HAVE_AVX2
INSTANTIATE_TEST_CASE_P(
AVX2, AV1HighbdConvolve2DTest,
libaom_test::AV1HighbdConvolve2D::BuildParams(av1_highbd_convolve_2d_avx2));
#endif
#if CONFIG_JNT_COMP && HAVE_SSE4_1
TEST_P(AV1HighbdJntConvolve2DTest, CheckOutput) {
RunCheckOutput(GET_PARAM(3));
}
INSTANTIATE_TEST_CASE_P(SSE4_1, AV1HighbdJntConvolve2DTest,
libaom_test::AV1HighbdConvolve2D::BuildParams(
av1_highbd_jnt_convolve_2d_sse4_1));
#endif // CONFIG_JNT_COMP
#endif
} // namespace
......@@ -21,17 +21,6 @@ namespace libaom_test {
namespace AV1Convolve2D {
#if CONFIG_JNT_COMP
::testing::internal::ParamGenerator<Convolve2DParam> BuildParams(
convolve_2d_func filter, convolve_2d_func filter2) {
const Convolve2DParam params[] = {
make_tuple(4, 4, filter, filter2), make_tuple(8, 8, filter, filter2),
make_tuple(64, 64, filter, filter2), make_tuple(4, 16, filter, filter2),
make_tuple(32, 8, filter, filter2),
};
return ::testing::ValuesIn(params);
}
#else
::testing::internal::ParamGenerator<Convolve2DParam> BuildParams(
convolve_2d_func filter) {
const Convolve2DParam params[] = {
......@@ -41,7 +30,6 @@ namespace AV1Convolve2D {
};
return ::testing::ValuesIn(params);
}
#endif // CONFIG_JNT_COMP
AV1Convolve2DTest::~AV1Convolve2DTest() {}
void AV1Convolve2DTest::SetUp() { rnd_.Reset(ACMRandom::DeterministicSeed()); }
......@@ -112,7 +100,14 @@ void AV1Convolve2DTest::RunCheckOutput(convolve_2d_func test_impl) {
}
#if CONFIG_JNT_COMP
void AV1Convolve2DTest::RunCheckOutput2(convolve_2d_func test_impl) {
AV1JntConvolve2DTest::~AV1JntConvolve2DTest() {}
void AV1JntConvolve2DTest::SetUp() {
rnd_.Reset(ACMRandom::DeterministicSeed());
}
void AV1JntConvolve2DTest::TearDown() { libaom_test::ClearSystemState(); }
void AV1JntConvolve2DTest::RunCheckOutput(convolve_2d_func test_impl) {
const int w = 128, h = 128;
const int out_w = GET_PARAM(0), out_h = GET_PARAM(1);
int i, j, k, l, m;
......@@ -139,7 +134,7 @@ void AV1Convolve2DTest::RunCheckOutput2(convolve_2d_func test_impl) {
ConvolveParams conv_params2 =
get_conv_params_no_round(0, do_average, 0, output2, MAX_SB_SIZE, 1);
// Test special case where fwd and bck offsets are -1
// Test special case where jnt_comp_avg is not used
conv_params1.use_jnt_comp_avg = 0;
conv_params2.use_jnt_comp_avg = 0;
......@@ -315,6 +310,127 @@ void AV1HighbdConvolve2DTest::RunCheckOutput(
delete[] output;
delete[] output2;
}
#if CONFIG_JNT_COMP
AV1HighbdJntConvolve2DTest::~AV1HighbdJntConvolve2DTest() {}
void AV1HighbdJntConvolve2DTest::SetUp() {
rnd_.Reset(ACMRandom::DeterministicSeed());
}
void AV1HighbdJntConvolve2DTest::TearDown() { libaom_test::ClearSystemState(); }
void AV1HighbdJntConvolve2DTest::RunCheckOutput(
highbd_convolve_2d_func test_impl) {
const int w = 128, h = 128;
const int out_w = GET_PARAM(0), out_h = GET_PARAM(1);
const int bd = GET_PARAM(2);
int i, j, k, l, m;
uint16_t *input = new uint16_t[h * w];
int output_n = out_h * MAX_SB_SIZE;
CONV_BUF_TYPE *output = new CONV_BUF_TYPE[output_n];
CONV_BUF_TYPE *output2 = new CONV_BUF_TYPE[output_n];
for (i = 0; i < h; ++i)
for (j = 0; j < w; ++j) input[i * w + j] = rnd_.Rand16() & ((1 << bd) - 1);
int hfilter, vfilter, subx, suby;
for (hfilter = EIGHTTAP_REGULAR; hfilter < INTERP_FILTERS_ALL; ++hfilter) {
for (vfilter = EIGHTTAP_REGULAR; vfilter < INTERP_FILTERS_ALL; ++vfilter) {
InterpFilterParams filter_params_x =
av1_get_interp_filter_params((InterpFilter)hfilter);
InterpFilterParams filter_params_y =
av1_get_interp_filter_params((InterpFilter)vfilter);
ConvolveParams conv_params1 =
get_conv_params_no_round(0, 0, 0, output, MAX_SB_SIZE);
ConvolveParams conv_params2 =
get_conv_params_no_round(0, 0, 0, output2, MAX_SB_SIZE);
// Test special case where jnt_comp_avg is not used
conv_params1.use_jnt_comp_avg = 0;
conv_params2.use_jnt_comp_avg = 0;
for (subx = 0; subx < 16; ++subx)
for (suby = 0; suby < 16; ++suby) {
// av1_convolve_2d is designed for accumulate two predicted blocks for
// compound mode, so we set num_iter to two here.
// A larger number may introduce overflow
const int num_iters = 2;
memset(output, 0, output_n * sizeof(*output));
memset(output2, 0, output_n * sizeof(*output2));
for (i = 0; i < num_iters; ++i) {
// Choose random locations within the source block
int offset_r = 3 + rnd_.PseudoUniform(h - out_h - 7);
int offset_c = 3 + rnd_.PseudoUniform(w - out_w - 7);
av1_highbd_jnt_convolve_2d_c(input + offset_r * w + offset_c, w,
output, MAX_SB_SIZE, out_w, out_h,
&filter_params_x, &filter_params_y,
subx, suby, &conv_params1, bd);
test_impl(input + offset_r * w + offset_c, w, output2, MAX_SB_SIZE,
out_w, out_h, &filter_params_x, &filter_params_y, subx,
suby, &conv_params2, bd);
for (j = 0; j < out_h; ++j)
for (k = 0; k < out_w; ++k) {
int idx = j * MAX_SB_SIZE + k;
ASSERT_EQ(output[idx], output2[idx])
<< "Pixel mismatch at index " << idx << " = (" << j << ", "
<< k << "), sub pixel offset = (" << suby << ", " << subx
<< ")";
}
}
}
// Test different combination of fwd and bck offset weights
for (l = 0; l < 2; ++l) {
for (m = 0; m < 4; ++m) {
conv_params1.use_jnt_comp_avg = 1;
conv_params2.use_jnt_comp_avg = 1;
conv_params1.fwd_offset = quant_dist_lookup_table[l][m][0];
conv_params1.bck_offset = quant_dist_lookup_table[l][m][1];
conv_params2.fwd_offset = quant_dist_lookup_table[l][m][0];
conv_params2.bck_offset = quant_dist_lookup_table[l][m][1];
for (subx = 0; subx < 16; ++subx)
for (suby = 0; suby < 16; ++suby) {
// av1_convolve_2d is designed for accumulate two predicted blocks
// for compound mode, so we set num_iter to two here.
// A larger number may introduce overflow
const int num_iters = 2;
memset(output, 0, output_n * sizeof(*output));
memset(output2, 0, output_n * sizeof(*output2));
for (i = 0; i < num_iters; ++i) {
// Choose random locations within the source block
int offset_r = 3 + rnd_.PseudoUniform(h - out_h - 7);
int offset_c = 3 + rnd_.PseudoUniform(w - out_w - 7);
av1_highbd_jnt_convolve_2d_c(input + offset_r * w + offset_c, w,
output, MAX_SB_SIZE, out_w, out_h,
&filter_params_x, &filter_params_y,
subx, suby, &conv_params1, bd);
test_impl(input + offset_r * w + offset_c, w, output2,
MAX_SB_SIZE, out_w, out_h, &filter_params_x,
&filter_params_y, subx, suby, &conv_params2, bd);
for (j = 0; j < out_h; ++j)
for (k = 0; k < out_w; ++k) {
int idx = j * MAX_SB_SIZE + k;
ASSERT_EQ(output[idx], output2[idx])
<< "Mismatch at unit tests for av1_jnt_convolve_2d\n"
<< "Pixel mismatch at index " << idx << " = (" << j
<< ", " << k << "), sub pixel offset = (" << suby
<< ", " << subx << ")";
}
}
}
}
}
}
}
delete[] input;
delete[] output;
delete[] output2;
}
#endif // CONFIG_JNT_COMP
} // namespace AV1HighbdConvolve2D
#endif // CONFIG_HIGHBITDEPTH
} // namespace libaom_test
......@@ -31,18 +31,10 @@ typedef void (*convolve_2d_func)(const uint8_t *src, int src_stride,
const int subpel_x_q4, const int subpel_y_q4,
ConvolveParams *conv_params);
#if CONFIG_JNT_COMP
typedef std::tr1::tuple<int, int, convolve_2d_func, convolve_2d_func>
Convolve2DParam;
::testing::internal::ParamGenerator<Convolve2DParam> BuildParams(
convolve_2d_func filter, convolve_2d_func filter2);
#else
typedef std::tr1::tuple<int, int, convolve_2d_func> Convolve2DParam;
::testing::internal::ParamGenerator<Convolve2DParam> BuildParams(
convolve_2d_func filter);
#endif // CONFIG_JNT_COMP
class AV1Convolve2DTest : public ::testing::TestWithParam<Convolve2DParam> {
public:
......@@ -53,12 +45,24 @@ class AV1Convolve2DTest : public ::testing::TestWithParam<Convolve2DParam> {
protected:
void RunCheckOutput(convolve_2d_func test_impl);
libaom_test::ACMRandom rnd_;
};
#if CONFIG_JNT_COMP
void RunCheckOutput2(convolve_2d_func test_impl);
#endif
class AV1JntConvolve2DTest : public ::testing::TestWithParam<Convolve2DParam> {
public:
virtual ~AV1JntConvolve2DTest();
virtual void SetUp();
virtual void TearDown();
protected:
void RunCheckOutput(convolve_2d_func test_impl);
libaom_test::ACMRandom rnd_;
};
#endif // CONFIG_JNT_COMP
} // namespace AV1Convolve2D
......@@ -90,6 +94,22 @@ class AV1HighbdConvolve2DTest
libaom_test::ACMRandom rnd_;
};
#if CONFIG_JNT_COMP
class AV1HighbdJntConvolve2DTest
: public ::testing::TestWithParam<HighbdConvolve2DParam> {
public:
virtual ~AV1HighbdJntConvolve2DTest();
virtual void SetUp();
virtual void TearDown();
protected:
void RunCheckOutput(highbd_convolve_2d_func test_impl);
libaom_test::ACMRandom rnd_;
};
#endif // CONFIG_JNT_COMP
} // namespace AV1HighbdConvolve2D
#endif // CONFIG_HIGHBITDEPTH
......
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