#include <algorithm>
#include <ostream>
#include "gtest/gtest.h"
#include "config/aom_dsp_rtcd.h"
#include "test/acm_random.h"
#include "test/register_state_check.h"
#include "test/util.h"
namespace {
ACMRandom;
HadamardFunc;
HadamardLPFunc;
HadamardLP8x8DualFunc;
template <typename OutputType>
void Hadamard4x4(const OutputType *a, OutputType *out) { … }
template <typename OutputType>
void ReferenceHadamard4x4(const int16_t *a, int a_stride, OutputType *b) { … }
template <typename OutputType>
void HadamardLoop(const OutputType *a, OutputType *out) { … }
template <typename OutputType>
void ReferenceHadamard8x8(const int16_t *a, int a_stride, OutputType *b) { … }
template <typename OutputType>
void ReferenceHadamard8x8Dual(const int16_t *a, int a_stride, OutputType *b) { … }
template <typename OutputType>
void ReferenceHadamard16x16(const int16_t *a, int a_stride, OutputType *b,
bool shift) { … }
template <typename OutputType>
void ReferenceHadamard32x32(const int16_t *a, int a_stride, OutputType *b,
bool shift) { … }
template <typename OutputType>
void ReferenceHadamard(const int16_t *a, int a_stride, OutputType *b, int bw,
int bh, bool shift) { … }
template <typename HadamardFuncType>
struct FuncWithSize { … };
HadamardFuncWithSize;
HadamardLPFuncWithSize;
HadamardLP8x8DualFuncWithSize;
template <typename OutputType, typename HadamardFuncType>
class HadamardTestBase
: public ::testing::TestWithParam<FuncWithSize<HadamardFuncType>> { … };
class HadamardLowbdTest : public HadamardTestBase<tran_low_t, HadamardFunc> { … };
TEST_P(HadamardLowbdTest, CompareReferenceRandom) { … }
TEST_P(HadamardLowbdTest, CompareReferenceExtreme) { … }
TEST_P(HadamardLowbdTest, VaryStride) { … }
TEST_P(HadamardLowbdTest, DISABLED_SpeedTest) { … }
INSTANTIATE_TEST_SUITE_P(…);
#if HAVE_SSE2
INSTANTIATE_TEST_SUITE_P(…);
#endif
#if HAVE_AVX2
INSTANTIATE_TEST_SUITE_P(…);
#endif
#if HAVE_NEON
INSTANTIATE_TEST_SUITE_P(
NEON, HadamardLowbdTest,
::testing::Values(HadamardFuncWithSize(&aom_hadamard_4x4_neon, 4, 4),
HadamardFuncWithSize(&aom_hadamard_8x8_neon, 8, 8),
HadamardFuncWithSize(&aom_hadamard_16x16_neon, 16, 16),
HadamardFuncWithSize(&aom_hadamard_32x32_neon, 32, 32)));
#endif
#if CONFIG_AV1_HIGHBITDEPTH
class HadamardHighbdTest : public HadamardTestBase<tran_low_t, HadamardFunc> {
protected:
HadamardHighbdTest() : HadamardTestBase(GetParam(), true) {}
int16_t Rand() override {
int16_t src = rnd_.Rand12();
int16_t pred = rnd_.Rand12();
return src - pred;
}
};
TEST_P(HadamardHighbdTest, CompareReferenceRandom) { CompareReferenceRandom(); }
TEST_P(HadamardHighbdTest, VaryStride) { VaryStride(); }
TEST_P(HadamardHighbdTest, DISABLED_Speed) {
SpeedTest(10);
SpeedTest(10000);
SpeedTest(10000000);
}
INSTANTIATE_TEST_SUITE_P(
C, HadamardHighbdTest,
::testing::Values(
HadamardFuncWithSize(&aom_highbd_hadamard_8x8_c, 8, 8),
HadamardFuncWithSize(&aom_highbd_hadamard_16x16_c, 16, 16),
HadamardFuncWithSize(&aom_highbd_hadamard_32x32_c, 32, 32)));
#if HAVE_AVX2
INSTANTIATE_TEST_SUITE_P(
AVX2, HadamardHighbdTest,
::testing::Values(
HadamardFuncWithSize(&aom_highbd_hadamard_8x8_avx2, 8, 8),
HadamardFuncWithSize(&aom_highbd_hadamard_16x16_avx2, 16, 16),
HadamardFuncWithSize(&aom_highbd_hadamard_32x32_avx2, 32, 32)));
#endif
#if HAVE_NEON
INSTANTIATE_TEST_SUITE_P(
NEON, HadamardHighbdTest,
::testing::Values(
HadamardFuncWithSize(&aom_highbd_hadamard_8x8_neon, 8, 8),
HadamardFuncWithSize(&aom_highbd_hadamard_16x16_neon, 16, 16),
HadamardFuncWithSize(&aom_highbd_hadamard_32x32_neon, 32, 32)));
#endif
#endif
class HadamardLowbdLPTest : public HadamardTestBase<int16_t, HadamardLPFunc> { … };
TEST_P(HadamardLowbdLPTest, CompareReferenceRandom) { … }
TEST_P(HadamardLowbdLPTest, VaryStride) { … }
TEST_P(HadamardLowbdLPTest, DISABLED_SpeedTest) { … }
INSTANTIATE_TEST_SUITE_P(…);
#if HAVE_SSE2
INSTANTIATE_TEST_SUITE_P(…);
#endif
#if HAVE_AVX2
INSTANTIATE_TEST_SUITE_P(…);
#endif
#if HAVE_NEON
INSTANTIATE_TEST_SUITE_P(
NEON, HadamardLowbdLPTest,
::testing::Values(HadamardLPFuncWithSize(&aom_hadamard_lp_8x8_neon, 8, 8),
HadamardLPFuncWithSize(&aom_hadamard_lp_16x16_neon, 16,
16)));
#endif
class HadamardLowbdLP8x8DualTest
: public HadamardTestBase<int16_t, HadamardLP8x8DualFunc> { … };
TEST_P(HadamardLowbdLP8x8DualTest, CompareReferenceRandom) { … }
TEST_P(HadamardLowbdLP8x8DualTest, VaryStride) { … }
TEST_P(HadamardLowbdLP8x8DualTest, DISABLED_SpeedTest) { … }
INSTANTIATE_TEST_SUITE_P(…);
#if HAVE_SSE2
INSTANTIATE_TEST_SUITE_P(…);
#endif
#if HAVE_AVX2
INSTANTIATE_TEST_SUITE_P(…);
#endif
#if HAVE_NEON
INSTANTIATE_TEST_SUITE_P(NEON, HadamardLowbdLP8x8DualTest,
::testing::Values(HadamardLP8x8DualFuncWithSize(
&aom_hadamard_lp_8x8_dual_neon, 8, 16)));
#endif
}