Clean up FunctionEquivalenceTest.
remove use of tuple in favor of struct.
Change-Id: If3b1aa5c2fc3cfe1446fff7a8fd270f2ca85fedf
diff --git a/test/blend_a64_mask_1d_test.cc b/test/blend_a64_mask_1d_test.cc
index 03e9b7d..ba63afa 100644
--- a/test/blend_a64_mask_1d_test.cc
+++ b/test/blend_a64_mask_1d_test.cc
@@ -23,14 +23,11 @@
#include "./vp10_rtcd.h"
-#include "test/acm_random.h"
#include "vp10/common/enums.h"
#include "vpx_dsp/blend.h"
-using libvpx_test::ACMRandom;
using libvpx_test::FunctionEquivalenceTest;
-using std::tr1::make_tuple;
namespace {
@@ -44,29 +41,27 @@
static const int kMaxMaskWidth = 2 * MAX_SB_SIZE;
static const int kMaxMaskSize = kMaxMaskWidth;
- BlendA64Mask1DTest() : rng_(ACMRandom::DeterministicSeed()) {}
-
virtual ~BlendA64Mask1DTest() {}
- virtual void Execute(T *p_src0, T *p_src1) = 0;
+ virtual void Execute(const T *p_src0, const T *p_src1) = 0;
void Common() {
- w_ = 1 << rng_(MAX_SB_SIZE_LOG2 + 1);
- h_ = 1 << rng_(MAX_SB_SIZE_LOG2 + 1);
+ w_ = 1 << this->rng_(MAX_SB_SIZE_LOG2 + 1);
+ h_ = 1 << this->rng_(MAX_SB_SIZE_LOG2 + 1);
- dst_offset_ = rng_(33);
- dst_stride_ = rng_(kMaxWidth + 1 - w_) + w_;
+ dst_offset_ = this->rng_(33);
+ dst_stride_ = this->rng_(kMaxWidth + 1 - w_) + w_;
- src0_offset_ = rng_(33);
- src0_stride_ = rng_(kMaxWidth + 1 - w_) + w_;
+ src0_offset_ = this->rng_(33);
+ src0_stride_ = this->rng_(kMaxWidth + 1 - w_) + w_;
- src1_offset_ = rng_(33);
- src1_stride_ = rng_(kMaxWidth + 1 - w_) + w_;
+ src1_offset_ = this->rng_(33);
+ src1_stride_ = this->rng_(kMaxWidth + 1 - w_) + w_;
T *p_src0;
T *p_src1;
- switch (rng_(3)) {
+ switch (this->rng_(3)) {
case 0: // Separate sources
p_src0 = src0_;
p_src1 = src1_;
@@ -97,8 +92,6 @@
}
}
- ACMRandom rng_;
-
T dst_ref_[kBufSize];
T dst_tst_[kBufSize];
size_t dst_stride_;
@@ -126,19 +119,18 @@
const uint8_t *src0, uint32_t src0_stride,
const uint8_t *src1, uint32_t src1_stride,
const uint8_t *mask, int h, int w);
+typedef libvpx_test::FuncParam<F8B> TestFuncs;
class BlendA64Mask1DTest8B : public BlendA64Mask1DTest<F8B, uint8_t> {
protected:
- void Execute(uint8_t *p_src0, uint8_t *p_src1) {
- ref_func_(dst_ref_ + dst_offset_, dst_stride_,
- p_src0 + src0_offset_, src0_stride_,
- p_src1 + src1_offset_, src1_stride_,
- mask_, h_, w_);
-
- tst_func_(dst_tst_ + dst_offset_, dst_stride_,
- p_src0 + src0_offset_, src0_stride_,
- p_src1 + src1_offset_, src1_stride_,
- mask_, h_, w_);
+ void Execute(const uint8_t *p_src0, const uint8_t *p_src1) {
+ params_.ref_func(dst_ref_ + dst_offset_, dst_stride_,
+ p_src0 + src0_offset_, src0_stride_,
+ p_src1 + src1_offset_, src1_stride_, mask_, h_, w_);
+ ASM_REGISTER_STATE_CHECK(
+ params_.tst_func(dst_tst_ + dst_offset_, dst_stride_,
+ p_src0 + src0_offset_, src0_stride_,
+ p_src1 + src1_offset_, src1_stride_, mask_, h_, w_));
}
};
@@ -215,16 +207,15 @@
INSTANTIATE_TEST_CASE_P(
C, BlendA64Mask1DTest8B,
- ::testing::Values(
- make_tuple(blend_a64_hmask_ref, vpx_blend_a64_hmask_c),
- make_tuple(blend_a64_vmask_ref, vpx_blend_a64_vmask_c)));
+ ::testing::Values(TestFuncs(blend_a64_hmask_ref, vpx_blend_a64_hmask_c),
+ TestFuncs(blend_a64_vmask_ref, vpx_blend_a64_vmask_c)));
#if HAVE_SSE4_1
INSTANTIATE_TEST_CASE_P(
SSE4_1, BlendA64Mask1DTest8B,
::testing::Values(
- make_tuple(blend_a64_hmask_ref, vpx_blend_a64_hmask_sse4_1),
- make_tuple(blend_a64_vmask_ref, vpx_blend_a64_vmask_sse4_1)));
+ TestFuncs(blend_a64_hmask_ref, vpx_blend_a64_hmask_sse4_1),
+ TestFuncs(blend_a64_vmask_ref, vpx_blend_a64_vmask_sse4_1)));
#endif // HAVE_SSE4_1
#if CONFIG_VP9_HIGHBITDEPTH
@@ -236,20 +227,20 @@
const uint8_t *src0, uint32_t src0_stride,
const uint8_t *src1, uint32_t src1_stride,
const uint8_t *mask, int h, int w, int bd);
+typedef libvpx_test::FuncParam<FHBD> TestFuncsHBD;
class BlendA64Mask1DTestHBD : public BlendA64Mask1DTest<FHBD, uint16_t> {
protected:
- void Execute(uint16_t *p_src0, uint16_t *p_src1) {
- ref_func_(CONVERT_TO_BYTEPTR(dst_ref_ + dst_offset_), dst_stride_,
- CONVERT_TO_BYTEPTR(p_src0 + src0_offset_), src0_stride_,
- CONVERT_TO_BYTEPTR(p_src1 + src1_offset_), src1_stride_,
- mask_, h_, w_, bit_depth_);
-
- ASM_REGISTER_STATE_CHECK(
- tst_func_(CONVERT_TO_BYTEPTR(dst_tst_ + dst_offset_), dst_stride_,
- CONVERT_TO_BYTEPTR(p_src0 + src0_offset_), src0_stride_,
- CONVERT_TO_BYTEPTR(p_src1 + src1_offset_), src1_stride_,
- mask_, h_, w_, bit_depth_));
+ void Execute(const uint16_t *p_src0, const uint16_t *p_src1) {
+ params_.ref_func(CONVERT_TO_BYTEPTR(dst_ref_ + dst_offset_), dst_stride_,
+ CONVERT_TO_BYTEPTR(p_src0 + src0_offset_), src0_stride_,
+ CONVERT_TO_BYTEPTR(p_src1 + src1_offset_), src1_stride_,
+ mask_, h_, w_, bit_depth_);
+ ASM_REGISTER_STATE_CHECK(params_.tst_func(
+ CONVERT_TO_BYTEPTR(dst_tst_ + dst_offset_), dst_stride_,
+ CONVERT_TO_BYTEPTR(p_src0 + src0_offset_), src0_stride_,
+ CONVERT_TO_BYTEPTR(p_src1 + src1_offset_), src1_stride_,
+ mask_, h_, w_, bit_depth_));
}
int bit_depth_;
@@ -359,15 +350,17 @@
INSTANTIATE_TEST_CASE_P(
C, BlendA64Mask1DTestHBD,
::testing::Values(
- make_tuple(highbd_blend_a64_hmask_ref, vpx_highbd_blend_a64_hmask_c),
- make_tuple(highbd_blend_a64_vmask_ref, vpx_highbd_blend_a64_vmask_c)));
+ TestFuncsHBD(highbd_blend_a64_hmask_ref, vpx_highbd_blend_a64_hmask_c),
+ TestFuncsHBD(highbd_blend_a64_vmask_ref, vpx_highbd_blend_a64_vmask_c)));
#if HAVE_SSE4_1
INSTANTIATE_TEST_CASE_P(
SSE4_1, BlendA64Mask1DTestHBD,
::testing::Values(
- make_tuple(highbd_blend_a64_hmask_ref, vpx_highbd_blend_a64_hmask_sse4_1),
- make_tuple(highbd_blend_a64_vmask_ref, vpx_highbd_blend_a64_vmask_sse4_1)));
+ TestFuncsHBD(highbd_blend_a64_hmask_ref,
+ vpx_highbd_blend_a64_hmask_sse4_1),
+ TestFuncsHBD(highbd_blend_a64_vmask_ref,
+ vpx_highbd_blend_a64_vmask_sse4_1)));
#endif // HAVE_SSE4_1
#endif // CONFIG_VP9_HIGHBITDEPTH
diff --git a/test/blend_a64_mask_test.cc b/test/blend_a64_mask_test.cc
index 08ee91d..f6c09bb 100644
--- a/test/blend_a64_mask_test.cc
+++ b/test/blend_a64_mask_test.cc
@@ -23,14 +23,11 @@
#include "./vp10_rtcd.h"
-#include "test/acm_random.h"
#include "vp10/common/enums.h"
#include "vpx_dsp/blend.h"
-using libvpx_test::ACMRandom;
using libvpx_test::FunctionEquivalenceTest;
-using std::tr1::make_tuple;
namespace {
@@ -44,35 +41,33 @@
static const int kMaxMaskWidth = 2 * MAX_SB_SIZE;
static const int kMaxMaskSize = kMaxMaskWidth * kMaxMaskWidth;
- BlendA64MaskTest() : rng_(ACMRandom::DeterministicSeed()) {}
-
virtual ~BlendA64MaskTest() {}
virtual void Execute(const T *p_src0, const T *p_src1) = 0;
void Common() {
- w_ = 1 << rng_(MAX_SB_SIZE_LOG2 + 1);
- h_ = 1 << rng_(MAX_SB_SIZE_LOG2 + 1);
+ w_ = 1 << this->rng_(MAX_SB_SIZE_LOG2 + 1);
+ h_ = 1 << this->rng_(MAX_SB_SIZE_LOG2 + 1);
- subx_ = rng_(2);
- suby_ = rng_(2);
+ subx_ = this->rng_(2);
+ suby_ = this->rng_(2);
- dst_offset_ = rng_(33);
- dst_stride_ = rng_(kMaxWidth + 1 - w_) + w_;
+ dst_offset_ = this->rng_(33);
+ dst_stride_ = this->rng_(kMaxWidth + 1 - w_) + w_;
- src0_offset_ = rng_(33);
- src0_stride_ = rng_(kMaxWidth + 1 - w_) + w_;
+ src0_offset_ = this->rng_(33);
+ src0_stride_ = this->rng_(kMaxWidth + 1 - w_) + w_;
- src1_offset_ = rng_(33);
- src1_stride_ = rng_(kMaxWidth + 1 - w_) + w_;
+ src1_offset_ = this->rng_(33);
+ src1_stride_ = this->rng_(kMaxWidth + 1 - w_) + w_;
- mask_stride_ = rng_(kMaxWidth + 1 - w_ * (subx_ ? 2 : 1))
- + w_ * (subx_ ? 2 : 1);
+ mask_stride_ = this->rng_(kMaxWidth + 1 - w_ * (subx_ ? 2 : 1)) +
+ w_ * (subx_ ? 2 : 1);
T *p_src0;
T *p_src1;
- switch (rng_(3)) {
+ switch (this->rng_(3)) {
case 0: // Separate sources
p_src0 = src0_;
p_src1 = src1_;
@@ -103,8 +98,6 @@
}
}
- ACMRandom rng_;
-
T dst_ref_[kBufSize];
T dst_tst_[kBufSize];
size_t dst_stride_;
@@ -137,21 +130,20 @@
const uint8_t *src1, uint32_t src1_stride,
const uint8_t *mask, uint32_t mask_stride,
int h, int w, int suby, int subx);
+typedef libvpx_test::FuncParam<F8B> TestFuncs;
class BlendA64MaskTest8B : public BlendA64MaskTest<F8B, uint8_t> {
protected:
void Execute(const uint8_t *p_src0, const uint8_t *p_src1) {
- ref_func_(dst_ref_ + dst_offset_, dst_stride_,
- p_src0 + src0_offset_, src0_stride_,
- p_src1 + src1_offset_, src1_stride_,
- mask_, kMaxMaskWidth,
- h_, w_, suby_, subx_);
-
- tst_func_(dst_tst_ + dst_offset_, dst_stride_,
- p_src0 + src0_offset_, src0_stride_,
- p_src1 + src1_offset_, src1_stride_,
- mask_, kMaxMaskWidth,
- h_, w_, suby_, subx_);
+ params_.ref_func(dst_ref_ + dst_offset_, dst_stride_,
+ p_src0 + src0_offset_, src0_stride_,
+ p_src1 + src1_offset_, src1_stride_,
+ mask_, kMaxMaskWidth, h_, w_, suby_, subx_);
+ ASM_REGISTER_STATE_CHECK(
+ params_.tst_func(dst_tst_ + dst_offset_, dst_stride_,
+ p_src0 + src0_offset_, src0_stride_,
+ p_src1 + src1_offset_, src1_stride_,
+ mask_, kMaxMaskWidth, h_, w_, suby_, subx_));
}
};
@@ -191,8 +183,8 @@
#if HAVE_SSE4_1
INSTANTIATE_TEST_CASE_P(
SSE4_1_C_COMPARE, BlendA64MaskTest8B,
- ::testing::Values(make_tuple(vpx_blend_a64_mask_c,
- vpx_blend_a64_mask_sse4_1)));
+ ::testing::Values(
+ TestFuncs(vpx_blend_a64_mask_c, vpx_blend_a64_mask_sse4_1)));
#endif // HAVE_SSE4_1
#if CONFIG_VP9_HIGHBITDEPTH
@@ -205,22 +197,20 @@
const uint8_t *src1, uint32_t src1_stride,
const uint8_t *mask, uint32_t mask_stride,
int h, int w, int suby, int subx, int bd);
+typedef libvpx_test::FuncParam<FHBD> TestFuncsHBD;
class BlendA64MaskTestHBD : public BlendA64MaskTest<FHBD, uint16_t> {
protected:
void Execute(const uint16_t *p_src0, const uint16_t *p_src1) {
- ref_func_(CONVERT_TO_BYTEPTR(dst_ref_ + dst_offset_), dst_stride_,
- CONVERT_TO_BYTEPTR(p_src0 + src0_offset_), src0_stride_,
- CONVERT_TO_BYTEPTR(p_src1 + src1_offset_), src1_stride_,
- mask_, kMaxMaskWidth,
- h_, w_, suby_, subx_, bit_depth_);
-
- ASM_REGISTER_STATE_CHECK(
- tst_func_(CONVERT_TO_BYTEPTR(dst_tst_ + dst_offset_), dst_stride_,
- CONVERT_TO_BYTEPTR(p_src0 + src0_offset_), src0_stride_,
- CONVERT_TO_BYTEPTR(p_src1 + src1_offset_), src1_stride_,
- mask_, kMaxMaskWidth,
- h_, w_, suby_, subx_, bit_depth_));
+ params_.ref_func(CONVERT_TO_BYTEPTR(dst_ref_ + dst_offset_), dst_stride_,
+ CONVERT_TO_BYTEPTR(p_src0 + src0_offset_), src0_stride_,
+ CONVERT_TO_BYTEPTR(p_src1 + src1_offset_), src1_stride_,
+ mask_, kMaxMaskWidth, h_, w_, suby_, subx_, bit_depth_);
+ ASM_REGISTER_STATE_CHECK(params_.tst_func(
+ CONVERT_TO_BYTEPTR(dst_tst_ + dst_offset_), dst_stride_,
+ CONVERT_TO_BYTEPTR(p_src0 + src0_offset_), src0_stride_,
+ CONVERT_TO_BYTEPTR(p_src1 + src1_offset_), src1_stride_,
+ mask_, kMaxMaskWidth, h_, w_, suby_, subx_, bit_depth_));
}
int bit_depth_;
@@ -290,8 +280,9 @@
#if HAVE_SSE4_1
INSTANTIATE_TEST_CASE_P(
SSE4_1_C_COMPARE, BlendA64MaskTestHBD,
- ::testing::Values(make_tuple(vpx_highbd_blend_a64_mask_c,
- vpx_highbd_blend_a64_mask_sse4_1)));
+ ::testing::Values(
+ TestFuncsHBD(vpx_highbd_blend_a64_mask_c,
+ vpx_highbd_blend_a64_mask_sse4_1)));
#endif // HAVE_SSE4_1
#endif // CONFIG_VP9_HIGHBITDEPTH
} // namespace
diff --git a/test/function_equivalence_test.h b/test/function_equivalence_test.h
index 50ad4c5..70f33d1 100644
--- a/test/function_equivalence_test.h
+++ b/test/function_equivalence_test.h
@@ -12,19 +12,44 @@
#define TEST_FUNCTION_EQUIVALENCE_TEST_H_
#include "third_party/googletest/src/include/gtest/gtest.h"
+#include "test/acm_random.h"
#include "test/clear_system_state.h"
#include "test/util.h"
+using libvpx_test::ACMRandom;
+
namespace libvpx_test {
+// Base class for tests that compare 2 implementations of the same function
+// for equivalence. The template parameter should be pointer to a function
+// that is being tested.
+//
+// The test takes a 3-parameters encapsulating struct 'FuncParam', containing:
+// - Pointer to reference function
+// - Pointer to tested function
+// - Integer bit depth (default to 0).
+//
+// These values are then accessible in the tests as member of params_:
+// params_.ref_func, params_.tst_func, and params_.bit_depth.
+//
+
template <typename T>
-class FunctionEquivalenceTest :
- public ::testing::TestWithParam< std::tr1::tuple< T, T > > {
+struct FuncParam {
+ FuncParam(T ref = NULL, T tst = NULL, int bit_depth = 0)
+ : ref_func(ref), tst_func(tst), bit_depth(bit_depth) {}
+ T ref_func;
+ T tst_func;
+ int bit_depth;
+};
+
+template <typename T>
+class FunctionEquivalenceTest : public ::testing::TestWithParam<FuncParam<T> > {
public:
+ FunctionEquivalenceTest() : rng_(ACMRandom::DeterministicSeed()) {}
+
virtual ~FunctionEquivalenceTest() {}
virtual void SetUp() {
- ref_func_ = std::tr1::get<0>(this->GetParam());
- tst_func_ = std::tr1::get<1>(this->GetParam());
+ params_ = this->GetParam();
}
virtual void TearDown() {
@@ -32,8 +57,8 @@
}
protected:
- T ref_func_;
- T tst_func_;
+ ACMRandom rng_;
+ FuncParam<T> params_;
};
} // namespace libvpx_test
diff --git a/test/obmc_sad_test.cc b/test/obmc_sad_test.cc
index 95d56ae..beb7106 100644
--- a/test/obmc_sad_test.cc
+++ b/test/obmc_sad_test.cc
@@ -9,9 +9,9 @@
*/
#include "third_party/googletest/src/include/gtest/gtest.h"
-#include "test/acm_random.h"
#include "test/function_equivalence_test.h"
+#include "test/register_state_check.h"
#include "./vpx_config.h"
#include "./vpx_dsp_rtcd.h"
@@ -19,9 +19,6 @@
#define MAX_SB_SQUARE (MAX_SB_SIZE * MAX_SB_SIZE)
-using std::tr1::make_tuple;
-
-using libvpx_test::ACMRandom;
using libvpx_test::FunctionEquivalenceTest;
namespace {
@@ -31,18 +28,13 @@
typedef unsigned int (*ObmcSadF)(const uint8_t *pre, int pre_stride,
const int32_t *wsrc, const int32_t *mask);
+typedef libvpx_test::FuncParam<ObmcSadF> TestFuncs;
////////////////////////////////////////////////////////////////////////////////
// 8 bit
////////////////////////////////////////////////////////////////////////////////
-class ObmcSadTest : public FunctionEquivalenceTest<ObmcSadF> {
- public:
- ObmcSadTest() : rng_(ACMRandom::DeterministicSeed()) {}
-
- protected:
- ACMRandom rng_;
-};
+class ObmcSadTest : public FunctionEquivalenceTest<ObmcSadF> {};
TEST_P(ObmcSadTest, RandomValues) {
DECLARE_ALIGNED(32, uint8_t, pre[MAX_SB_SQUARE]);
@@ -58,8 +50,10 @@
mask[i] = rng_(kMaskMax * kMaskMax + 1);
}
- const unsigned int ref_res = ref_func_(pre, pre_stride, wsrc, mask);
- const unsigned int tst_res = tst_func_(pre, pre_stride, wsrc, mask);
+ const unsigned int ref_res = params_.ref_func(pre, pre_stride, wsrc, mask);
+ unsigned int tst_res;
+ ASM_REGISTER_STATE_CHECK(tst_res =
+ params_.tst_func(pre, pre_stride, wsrc, mask));
ASSERT_EQ(ref_res, tst_res);
}
@@ -79,8 +73,10 @@
mask[i] = kMaskMax * kMaskMax;
}
- const unsigned int ref_res = ref_func_(pre, pre_stride, wsrc, mask);
- const unsigned int tst_res = tst_func_(pre, pre_stride, wsrc, mask);
+ const unsigned int ref_res = params_.ref_func(pre, pre_stride, wsrc, mask);
+ unsigned int tst_res;
+ ASM_REGISTER_STATE_CHECK(tst_res =
+ params_.tst_func(pre, pre_stride, wsrc, mask));
ASSERT_EQ(ref_res, tst_res);
}
@@ -89,23 +85,23 @@
#if HAVE_SSE4_1
const ObmcSadTest::ParamType sse4_functions[] = {
#if CONFIG_EXT_PARTITION
- make_tuple(vpx_obmc_sad128x128_c, vpx_obmc_sad128x128_sse4_1),
- make_tuple(vpx_obmc_sad128x64_c, vpx_obmc_sad128x64_sse4_1),
- make_tuple(vpx_obmc_sad64x128_c, vpx_obmc_sad64x128_sse4_1),
+ TestFuncs(vpx_obmc_sad128x128_c, vpx_obmc_sad128x128_sse4_1),
+ TestFuncs(vpx_obmc_sad128x64_c, vpx_obmc_sad128x64_sse4_1),
+ TestFuncs(vpx_obmc_sad64x128_c, vpx_obmc_sad64x128_sse4_1),
#endif // CONFIG_EXT_PARTITION
- make_tuple(vpx_obmc_sad64x64_c, vpx_obmc_sad64x64_sse4_1),
- make_tuple(vpx_obmc_sad64x32_c, vpx_obmc_sad64x32_sse4_1),
- make_tuple(vpx_obmc_sad32x64_c, vpx_obmc_sad32x64_sse4_1),
- make_tuple(vpx_obmc_sad32x32_c, vpx_obmc_sad32x32_sse4_1),
- make_tuple(vpx_obmc_sad32x16_c, vpx_obmc_sad32x16_sse4_1),
- make_tuple(vpx_obmc_sad16x32_c, vpx_obmc_sad16x32_sse4_1),
- make_tuple(vpx_obmc_sad16x16_c, vpx_obmc_sad16x16_sse4_1),
- make_tuple(vpx_obmc_sad16x8_c, vpx_obmc_sad16x8_sse4_1),
- make_tuple(vpx_obmc_sad8x16_c, vpx_obmc_sad8x16_sse4_1),
- make_tuple(vpx_obmc_sad8x8_c, vpx_obmc_sad8x8_sse4_1),
- make_tuple(vpx_obmc_sad8x4_c, vpx_obmc_sad8x4_sse4_1),
- make_tuple(vpx_obmc_sad4x8_c, vpx_obmc_sad4x8_sse4_1),
- make_tuple(vpx_obmc_sad4x4_c, vpx_obmc_sad4x4_sse4_1)
+ TestFuncs(vpx_obmc_sad64x64_c, vpx_obmc_sad64x64_sse4_1),
+ TestFuncs(vpx_obmc_sad64x32_c, vpx_obmc_sad64x32_sse4_1),
+ TestFuncs(vpx_obmc_sad32x64_c, vpx_obmc_sad32x64_sse4_1),
+ TestFuncs(vpx_obmc_sad32x32_c, vpx_obmc_sad32x32_sse4_1),
+ TestFuncs(vpx_obmc_sad32x16_c, vpx_obmc_sad32x16_sse4_1),
+ TestFuncs(vpx_obmc_sad16x32_c, vpx_obmc_sad16x32_sse4_1),
+ TestFuncs(vpx_obmc_sad16x16_c, vpx_obmc_sad16x16_sse4_1),
+ TestFuncs(vpx_obmc_sad16x8_c, vpx_obmc_sad16x8_sse4_1),
+ TestFuncs(vpx_obmc_sad8x16_c, vpx_obmc_sad8x16_sse4_1),
+ TestFuncs(vpx_obmc_sad8x8_c, vpx_obmc_sad8x8_sse4_1),
+ TestFuncs(vpx_obmc_sad8x4_c, vpx_obmc_sad8x4_sse4_1),
+ TestFuncs(vpx_obmc_sad4x8_c, vpx_obmc_sad4x8_sse4_1),
+ TestFuncs(vpx_obmc_sad4x4_c, vpx_obmc_sad4x4_sse4_1)
};
INSTANTIATE_TEST_CASE_P(SSE4_1_C_COMPARE, ObmcSadTest,
@@ -117,13 +113,7 @@
////////////////////////////////////////////////////////////////////////////////
#if CONFIG_VP9_HIGHBITDEPTH
-class ObmcSadHBDTest : public FunctionEquivalenceTest<ObmcSadF> {
- public:
- ObmcSadHBDTest() : rng_(ACMRandom::DeterministicSeed()) {}
-
- protected:
- ACMRandom rng_;
-};
+class ObmcSadHBDTest : public FunctionEquivalenceTest<ObmcSadF> {};
TEST_P(ObmcSadHBDTest, RandomValues) {
DECLARE_ALIGNED(32, uint16_t, pre[MAX_SB_SQUARE]);
@@ -139,10 +129,11 @@
mask[i] = rng_(kMaskMax * kMaskMax + 1);
}
- const unsigned int ref_res = ref_func_(CONVERT_TO_BYTEPTR(pre), pre_stride,
- wsrc, mask);
- const unsigned int tst_res = tst_func_(CONVERT_TO_BYTEPTR(pre), pre_stride,
- wsrc, mask);
+ const unsigned int ref_res =
+ params_.ref_func(CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask);
+ unsigned int tst_res;
+ ASM_REGISTER_STATE_CHECK(tst_res =
+ params_.tst_func(CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask));
ASSERT_EQ(ref_res, tst_res);
}
@@ -162,10 +153,11 @@
mask[i] = kMaskMax * kMaskMax;
}
- const unsigned int ref_res = ref_func_(CONVERT_TO_BYTEPTR(pre), pre_stride,
- wsrc, mask);
- const unsigned int tst_res = tst_func_(CONVERT_TO_BYTEPTR(pre), pre_stride,
- wsrc, mask);
+ const unsigned int ref_res =
+ params_.ref_func(CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask);
+ unsigned int tst_res;
+ ASM_REGISTER_STATE_CHECK(tst_res =
+ params_.tst_func(CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask));
ASSERT_EQ(ref_res, tst_res);
}
@@ -174,23 +166,23 @@
#if HAVE_SSE4_1
ObmcSadHBDTest::ParamType sse4_functions_hbd[] = {
#if CONFIG_EXT_PARTITION
- make_tuple(vpx_highbd_obmc_sad128x128_c, vpx_highbd_obmc_sad128x128_sse4_1),
- make_tuple(vpx_highbd_obmc_sad128x64_c, vpx_highbd_obmc_sad128x64_sse4_1),
- make_tuple(vpx_highbd_obmc_sad64x128_c, vpx_highbd_obmc_sad64x128_sse4_1),
+ TestFuncs(vpx_highbd_obmc_sad128x128_c, vpx_highbd_obmc_sad128x128_sse4_1),
+ TestFuncs(vpx_highbd_obmc_sad128x64_c, vpx_highbd_obmc_sad128x64_sse4_1),
+ TestFuncs(vpx_highbd_obmc_sad64x128_c, vpx_highbd_obmc_sad64x128_sse4_1),
#endif // CONFIG_EXT_PARTITION
- make_tuple(vpx_highbd_obmc_sad64x64_c, vpx_highbd_obmc_sad64x64_sse4_1),
- make_tuple(vpx_highbd_obmc_sad64x32_c, vpx_highbd_obmc_sad64x32_sse4_1),
- make_tuple(vpx_highbd_obmc_sad32x64_c, vpx_highbd_obmc_sad32x64_sse4_1),
- make_tuple(vpx_highbd_obmc_sad32x32_c, vpx_highbd_obmc_sad32x32_sse4_1),
- make_tuple(vpx_highbd_obmc_sad32x16_c, vpx_highbd_obmc_sad32x16_sse4_1),
- make_tuple(vpx_highbd_obmc_sad16x32_c, vpx_highbd_obmc_sad16x32_sse4_1),
- make_tuple(vpx_highbd_obmc_sad16x16_c, vpx_highbd_obmc_sad16x16_sse4_1),
- make_tuple(vpx_highbd_obmc_sad16x8_c, vpx_highbd_obmc_sad16x8_sse4_1),
- make_tuple(vpx_highbd_obmc_sad8x16_c, vpx_highbd_obmc_sad8x16_sse4_1),
- make_tuple(vpx_highbd_obmc_sad8x8_c, vpx_highbd_obmc_sad8x8_sse4_1),
- make_tuple(vpx_highbd_obmc_sad8x4_c, vpx_highbd_obmc_sad8x4_sse4_1),
- make_tuple(vpx_highbd_obmc_sad4x8_c, vpx_highbd_obmc_sad4x8_sse4_1),
- make_tuple(vpx_highbd_obmc_sad4x4_c, vpx_highbd_obmc_sad4x4_sse4_1)
+ TestFuncs(vpx_highbd_obmc_sad64x64_c, vpx_highbd_obmc_sad64x64_sse4_1),
+ TestFuncs(vpx_highbd_obmc_sad64x32_c, vpx_highbd_obmc_sad64x32_sse4_1),
+ TestFuncs(vpx_highbd_obmc_sad32x64_c, vpx_highbd_obmc_sad32x64_sse4_1),
+ TestFuncs(vpx_highbd_obmc_sad32x32_c, vpx_highbd_obmc_sad32x32_sse4_1),
+ TestFuncs(vpx_highbd_obmc_sad32x16_c, vpx_highbd_obmc_sad32x16_sse4_1),
+ TestFuncs(vpx_highbd_obmc_sad16x32_c, vpx_highbd_obmc_sad16x32_sse4_1),
+ TestFuncs(vpx_highbd_obmc_sad16x16_c, vpx_highbd_obmc_sad16x16_sse4_1),
+ TestFuncs(vpx_highbd_obmc_sad16x8_c, vpx_highbd_obmc_sad16x8_sse4_1),
+ TestFuncs(vpx_highbd_obmc_sad8x16_c, vpx_highbd_obmc_sad8x16_sse4_1),
+ TestFuncs(vpx_highbd_obmc_sad8x8_c, vpx_highbd_obmc_sad8x8_sse4_1),
+ TestFuncs(vpx_highbd_obmc_sad8x4_c, vpx_highbd_obmc_sad8x4_sse4_1),
+ TestFuncs(vpx_highbd_obmc_sad4x8_c, vpx_highbd_obmc_sad4x8_sse4_1),
+ TestFuncs(vpx_highbd_obmc_sad4x4_c, vpx_highbd_obmc_sad4x4_sse4_1)
};
INSTANTIATE_TEST_CASE_P(SSE4_1_C_COMPARE, ObmcSadHBDTest,
diff --git a/test/sum_squares_test.cc b/test/sum_squares_test.cc
index 5186c85..9adb86e 100644
--- a/test/sum_squares_test.cc
+++ b/test/sum_squares_test.cc
@@ -31,25 +31,21 @@
static const int16_t kInt13Max = (1 << 12) - 1;
-typedef uint64_t (*SSI16Func)(const int16_t *src,
- int stride ,
- int size);
+typedef uint64_t (*SSI16Func)(const int16_t *src, int stride, int size);
+typedef libvpx_test::FuncParam<SSI16Func> TestFuncs;
-typedef std::tr1::tuple<SSI16Func, SSI16Func> SumSquaresParam;
-
-class SumSquaresTest : public ::testing::TestWithParam<SumSquaresParam> {
+class SumSquaresTest :
+ public ::testing::TestWithParam<TestFuncs> {
public:
virtual ~SumSquaresTest() {}
virtual void SetUp() {
- ref_func_ = GET_PARAM(0);
- tst_func_ = GET_PARAM(1);
+ params_ = this->GetParam();
}
virtual void TearDown() { libvpx_test::ClearSystemState(); }
protected:
- SSI16Func ref_func_;
- SSI16Func tst_func_;
+ TestFuncs params_;
};
TEST_P(SumSquaresTest, OperationCheck) {
@@ -74,9 +70,9 @@
}
}
- uint64_t res_ref = ref_func_(src, stride, size);
+ const uint64_t res_ref = params_.ref_func(src, stride, size);
uint64_t res_tst;
- ASM_REGISTER_STATE_CHECK(res_tst = tst_func_(src, stride, size));
+ ASM_REGISTER_STATE_CHECK(res_tst = params_.tst_func(src, stride, size));
if (!failed) {
failed = res_ref != res_tst;
@@ -110,9 +106,9 @@
}
}
- uint64_t res_ref = ref_func_(src, stride, size);
+ const uint64_t res_ref = params_.ref_func(src, stride, size);
uint64_t res_tst;
- ASM_REGISTER_STATE_CHECK(res_tst = tst_func_(src, stride, size));
+ ASM_REGISTER_STATE_CHECK(res_tst = params_.tst_func(src, stride, size));
if (!failed) {
failed = res_ref != res_tst;
@@ -122,16 +118,14 @@
}
}
}
-using std::tr1::make_tuple;
#if HAVE_SSE2
INSTANTIATE_TEST_CASE_P(
SSE2, SumSquaresTest,
::testing::Values(
- make_tuple(&vpx_sum_squares_2d_i16_c, &vpx_sum_squares_2d_i16_sse2)
- )
-);
+ TestFuncs(&vpx_sum_squares_2d_i16_c, &vpx_sum_squares_2d_i16_sse2)));
+
#endif // HAVE_SSE2
//////////////////////////////////////////////////////////////////////////////
@@ -139,15 +133,12 @@
//////////////////////////////////////////////////////////////////////////////
typedef uint64_t (*F1D)(const int16_t *src, uint32_t N);
+typedef libvpx_test::FuncParam<F1D> TestFuncs1D;
class SumSquares1DTest : public FunctionEquivalenceTest<F1D> {
protected:
- SumSquares1DTest() : rng_(ACMRandom::DeterministicSeed()) {}
-
static const int kIterations = 1000;
static const int kMaxSize = 256;
-
- ACMRandom rng_;
};
TEST_P(SumSquares1DTest, RandomValues) {
@@ -160,8 +151,9 @@
const int N = rng_(2) ? rng_(kMaxSize * kMaxSize + 1 - kMaxSize) + kMaxSize
: rng_(kMaxSize) + 1;
- const uint64_t ref_res = ref_func_(src, N);
- const uint64_t tst_res = tst_func_(src, N);
+ const uint64_t ref_res = params_.ref_func(src, N);
+ uint64_t tst_res;
+ ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(src, N));
ASSERT_EQ(ref_res, tst_res);
}
@@ -182,21 +174,19 @@
const int N = rng_(2) ? rng_(kMaxSize * kMaxSize + 1 - kMaxSize) + kMaxSize
: rng_(kMaxSize) + 1;
- const uint64_t ref_res = ref_func_(src, N);
- const uint64_t tst_res = tst_func_(src, N);
+ const uint64_t ref_res = params_.ref_func(src, N);
+ uint64_t tst_res;
+ ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(src, N));
ASSERT_EQ(ref_res, tst_res);
}
}
-using std::tr1::make_tuple;
-
#if HAVE_SSE2
INSTANTIATE_TEST_CASE_P(
SSE2, SumSquares1DTest,
::testing::Values(
- make_tuple(&vpx_sum_squares_i16_c, &vpx_sum_squares_i16_sse2)
- )
-);
+ TestFuncs1D(vpx_sum_squares_i16_c, vpx_sum_squares_i16_sse2)));
+
#endif // HAVE_SSE2
} // namespace
diff --git a/test/vp10_wedge_utils_test.cc b/test/vp10_wedge_utils_test.cc
index 7a541b2..9fa4849 100644
--- a/test/vp10_wedge_utils_test.cc
+++ b/test/vp10_wedge_utils_test.cc
@@ -21,11 +21,11 @@
#include "test/acm_random.h"
#include "test/function_equivalence_test.h"
+#include "test/register_state_check.h"
#define WEDGE_WEIGHT_BITS 6
#define MAX_MASK_VALUE (1 << (WEDGE_WEIGHT_BITS))
-using std::tr1::make_tuple;
using libvpx_test::ACMRandom;
using libvpx_test::FunctionEquivalenceTest;
@@ -154,8 +154,8 @@
for (int i = 0 ; i < N ; i++)
r0[i] = r1[i] + d[i];
- uint64_t ref_res = sse_from_residuals(r0, r1, m, N);
- uint64_t tst_res = vp10_wedge_sse_from_residuals(r1, d, m, N);
+ const uint64_t ref_res = sse_from_residuals(r0, r1, m, N);
+ const uint64_t tst_res = vp10_wedge_sse_from_residuals(r1, d, m, N);
ASSERT_EQ(ref_res, tst_res);
}
@@ -169,14 +169,11 @@
const int16_t *d,
const uint8_t *m,
int N);
+typedef libvpx_test::FuncParam<FSSE> TestFuncsFSSE;
class WedgeUtilsSSEOptTest : public FunctionEquivalenceTest<FSSE> {
protected:
- WedgeUtilsSSEOptTest() : rng_(ACMRandom::DeterministicSeed()) {}
-
static const int kIterations = 10000;
-
- ACMRandom rng_;
};
TEST_P(WedgeUtilsSSEOptTest, RandomValues) {
@@ -193,8 +190,9 @@
const int N = 64 * (rng_(MAX_SB_SQUARE/64) + 1);
- const uint64_t ref_res = ref_func_(r1, d, m, N);
- const uint64_t tst_res = tst_func_(r1, d, m, N);
+ const uint64_t ref_res = params_.ref_func(r1, d, m, N);
+ uint64_t tst_res;
+ ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(r1, d, m, N));
ASSERT_EQ(ref_res, tst_res);
}
@@ -227,8 +225,9 @@
const int N = 64 * (rng_(MAX_SB_SQUARE/64) + 1);
- const uint64_t ref_res = ref_func_(r1, d, m, N);
- const uint64_t tst_res = tst_func_(r1, d, m, N);
+ const uint64_t ref_res = params_.ref_func(r1, d, m, N);
+ uint64_t tst_res;
+ ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(r1, d, m, N));
ASSERT_EQ(ref_res, tst_res);
}
@@ -238,10 +237,9 @@
INSTANTIATE_TEST_CASE_P(
SSE2, WedgeUtilsSSEOptTest,
::testing::Values(
- make_tuple(&vp10_wedge_sse_from_residuals_c,
- &vp10_wedge_sse_from_residuals_sse2)
- )
-);
+ TestFuncsFSSE(vp10_wedge_sse_from_residuals_c,
+ vp10_wedge_sse_from_residuals_sse2)));
+
#endif // HAVE_SSE2
//////////////////////////////////////////////////////////////////////////////
@@ -252,15 +250,12 @@
const uint8_t *m,
int N,
int64_t limit);
+typedef libvpx_test::FuncParam<FSign> TestFuncsFSign;
class WedgeUtilsSignOptTest : public FunctionEquivalenceTest<FSign> {
protected:
- WedgeUtilsSignOptTest() : rng_(ACMRandom::DeterministicSeed()) {}
-
static const int kIterations = 10000;
static const int kMaxSize = 8196; // Size limited by SIMD implementation.
-
- ACMRandom rng_;
};
TEST_P(WedgeUtilsSignOptTest, RandomValues) {
@@ -287,8 +282,9 @@
for (int i = 0 ; i < N ; i++)
ds[i] = clamp(r0[i]*r0[i] - r1[i]*r1[i], INT16_MIN, INT16_MAX);
- const int ref_res = ref_func_(ds, m, N, limit);
- const int tst_res = tst_func_(ds, m, N, limit);
+ const int ref_res = params_.ref_func(ds, m, N, limit);
+ int tst_res;
+ ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(ds, m, N, limit));
ASSERT_EQ(ref_res, tst_res);
}
@@ -342,21 +338,22 @@
for (int i = 0 ; i < N ; i++)
ds[i] = clamp(r0[i]*r0[i] - r1[i]*r1[i], INT16_MIN, INT16_MAX);
- const int ref_res = ref_func_(ds, m, N, limit);
- const int tst_res = tst_func_(ds, m, N, limit);
+ const int ref_res = params_.ref_func(ds, m, N, limit);
+ int tst_res;
+ ASM_REGISTER_STATE_CHECK(tst_res = params_.tst_func(ds, m, N, limit));
ASSERT_EQ(ref_res, tst_res);
}
}
#if HAVE_SSE2
+
INSTANTIATE_TEST_CASE_P(
SSE2, WedgeUtilsSignOptTest,
::testing::Values(
- make_tuple(&vp10_wedge_sign_from_residuals_c,
- &vp10_wedge_sign_from_residuals_sse2)
- )
-);
+ TestFuncsFSign(vp10_wedge_sign_from_residuals_c,
+ vp10_wedge_sign_from_residuals_sse2)));
+
#endif // HAVE_SSE2
//////////////////////////////////////////////////////////////////////////////
@@ -367,14 +364,11 @@
const int16_t *a,
const int16_t *b,
int N);
+typedef libvpx_test::FuncParam<FDS> TestFuncsFDS;
class WedgeUtilsDeltaSquaresOptTest : public FunctionEquivalenceTest<FDS> {
protected:
- WedgeUtilsDeltaSquaresOptTest() : rng_(ACMRandom::DeterministicSeed()) {}
-
static const int kIterations = 10000;
-
- ACMRandom rng_;
};
TEST_P(WedgeUtilsDeltaSquaresOptTest, RandomValues) {
@@ -394,8 +388,8 @@
memset(&d_ref, INT16_MAX, sizeof(d_ref));
memset(&d_tst, INT16_MAX, sizeof(d_tst));
- ref_func_(d_ref, a, b, N);
- tst_func_(d_tst, a, b, N);
+ params_.ref_func(d_ref, a, b, N);
+ ASM_REGISTER_STATE_CHECK(params_.tst_func(d_tst, a, b, N));
for (int i = 0 ; i < MAX_SB_SQUARE ; ++i)
ASSERT_EQ(d_ref[i], d_tst[i]);
@@ -403,13 +397,13 @@
}
#if HAVE_SSE2
+
INSTANTIATE_TEST_CASE_P(
SSE2, WedgeUtilsDeltaSquaresOptTest,
::testing::Values(
- make_tuple(&vp10_wedge_compute_delta_squares_c,
- &vp10_wedge_compute_delta_squares_sse2)
- )
-);
+ TestFuncsFDS(vp10_wedge_compute_delta_squares_c,
+ vp10_wedge_compute_delta_squares_sse2)));
+
#endif // HAVE_SSE2
} // namespace