2016-07-05 15:36:25 +03:00
|
|
|
/*
|
2016-09-02 22:04:54 +03:00
|
|
|
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
2016-07-05 15:36:25 +03:00
|
|
|
*
|
2016-09-02 22:04:54 +03:00
|
|
|
* This source code is subject to the terms of the BSD 2 Clause License and
|
|
|
|
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
|
|
|
* was not distributed with this source code in the LICENSE file, you can
|
|
|
|
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
|
|
|
* Media Patent License 1.0 was not distributed with this source code in the
|
|
|
|
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
2016-07-05 15:36:25 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "third_party/googletest/src/include/gtest/gtest.h"
|
|
|
|
|
|
|
|
#include "test/function_equivalence_test.h"
|
2016-07-12 17:26:36 +03:00
|
|
|
#include "test/register_state_check.h"
|
2016-07-05 15:36:25 +03:00
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
#include "./aom_config.h"
|
|
|
|
#include "./aom_dsp_rtcd.h"
|
|
|
|
#include "aom/aom_integer.h"
|
2016-07-05 15:36:25 +03:00
|
|
|
|
|
|
|
#define MAX_SB_SQUARE (MAX_SB_SIZE * MAX_SB_SIZE)
|
|
|
|
|
2016-08-23 02:08:15 +03:00
|
|
|
using libaom_test::FunctionEquivalenceTest;
|
2016-07-05 15:36:25 +03:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
static const int kIterations = 1000;
|
|
|
|
static const int kMaskMax = 64;
|
|
|
|
|
2016-07-12 15:20:04 +03:00
|
|
|
typedef unsigned int (*ObmcSadF)(const uint8_t *pre, int pre_stride,
|
2016-07-05 15:36:25 +03:00
|
|
|
const int32_t *wsrc, const int32_t *mask);
|
2016-08-23 02:08:15 +03:00
|
|
|
typedef libaom_test::FuncParam<ObmcSadF> TestFuncs;
|
2016-07-05 15:36:25 +03:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// 8 bit
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-07-12 17:26:36 +03:00
|
|
|
class ObmcSadTest : public FunctionEquivalenceTest<ObmcSadF> {};
|
2016-07-05 15:36:25 +03:00
|
|
|
|
|
|
|
TEST_P(ObmcSadTest, RandomValues) {
|
2016-07-12 15:20:04 +03:00
|
|
|
DECLARE_ALIGNED(32, uint8_t, pre[MAX_SB_SQUARE]);
|
2016-07-05 15:36:25 +03:00
|
|
|
DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
|
|
|
|
DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
|
|
|
|
|
2016-08-12 03:46:05 +03:00
|
|
|
for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
|
2016-07-12 15:20:04 +03:00
|
|
|
const int pre_stride = rng_(MAX_SB_SIZE + 1);
|
2016-07-05 15:36:25 +03:00
|
|
|
|
2016-08-12 03:46:05 +03:00
|
|
|
for (int i = 0; i < MAX_SB_SQUARE; ++i) {
|
2016-07-12 15:20:04 +03:00
|
|
|
pre[i] = rng_.Rand8();
|
2016-07-05 15:36:25 +03:00
|
|
|
wsrc[i] = rng_.Rand8() * rng_(kMaskMax * kMaskMax + 1);
|
|
|
|
mask[i] = rng_(kMaskMax * kMaskMax + 1);
|
|
|
|
}
|
|
|
|
|
2016-07-12 17:26:36 +03:00
|
|
|
const unsigned int ref_res = params_.ref_func(pre, pre_stride, wsrc, mask);
|
|
|
|
unsigned int tst_res;
|
|
|
|
ASM_REGISTER_STATE_CHECK(tst_res =
|
2016-08-12 03:46:05 +03:00
|
|
|
params_.tst_func(pre, pre_stride, wsrc, mask));
|
2016-07-05 15:36:25 +03:00
|
|
|
|
|
|
|
ASSERT_EQ(ref_res, tst_res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(ObmcSadTest, ExtremeValues) {
|
2016-07-12 15:20:04 +03:00
|
|
|
DECLARE_ALIGNED(32, uint8_t, pre[MAX_SB_SQUARE]);
|
2016-07-05 15:36:25 +03:00
|
|
|
DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
|
|
|
|
DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
|
|
|
|
|
2016-08-12 03:46:05 +03:00
|
|
|
for (int iter = 0; iter < MAX_SB_SIZE && !HasFatalFailure(); ++iter) {
|
2016-07-12 15:20:04 +03:00
|
|
|
const int pre_stride = iter;
|
2016-07-05 15:36:25 +03:00
|
|
|
|
2016-08-12 03:46:05 +03:00
|
|
|
for (int i = 0; i < MAX_SB_SQUARE; ++i) {
|
2016-07-12 15:20:04 +03:00
|
|
|
pre[i] = UINT8_MAX;
|
2016-07-05 15:36:25 +03:00
|
|
|
wsrc[i] = UINT8_MAX * kMaskMax * kMaskMax;
|
|
|
|
mask[i] = kMaskMax * kMaskMax;
|
|
|
|
}
|
|
|
|
|
2016-07-12 17:26:36 +03:00
|
|
|
const unsigned int ref_res = params_.ref_func(pre, pre_stride, wsrc, mask);
|
|
|
|
unsigned int tst_res;
|
|
|
|
ASM_REGISTER_STATE_CHECK(tst_res =
|
2016-08-12 03:46:05 +03:00
|
|
|
params_.tst_func(pre, pre_stride, wsrc, mask));
|
2016-07-05 15:36:25 +03:00
|
|
|
|
|
|
|
ASSERT_EQ(ref_res, tst_res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if HAVE_SSE4_1
|
|
|
|
const ObmcSadTest::ParamType sse4_functions[] = {
|
|
|
|
#if CONFIG_EXT_PARTITION
|
2016-08-31 00:01:10 +03:00
|
|
|
TestFuncs(aom_obmc_sad128x128_c, aom_obmc_sad128x128_sse4_1),
|
|
|
|
TestFuncs(aom_obmc_sad128x64_c, aom_obmc_sad128x64_sse4_1),
|
|
|
|
TestFuncs(aom_obmc_sad64x128_c, aom_obmc_sad64x128_sse4_1),
|
2016-07-05 15:36:25 +03:00
|
|
|
#endif // CONFIG_EXT_PARTITION
|
2016-08-31 00:01:10 +03:00
|
|
|
TestFuncs(aom_obmc_sad64x64_c, aom_obmc_sad64x64_sse4_1),
|
|
|
|
TestFuncs(aom_obmc_sad64x32_c, aom_obmc_sad64x32_sse4_1),
|
|
|
|
TestFuncs(aom_obmc_sad32x64_c, aom_obmc_sad32x64_sse4_1),
|
|
|
|
TestFuncs(aom_obmc_sad32x32_c, aom_obmc_sad32x32_sse4_1),
|
|
|
|
TestFuncs(aom_obmc_sad32x16_c, aom_obmc_sad32x16_sse4_1),
|
|
|
|
TestFuncs(aom_obmc_sad16x32_c, aom_obmc_sad16x32_sse4_1),
|
|
|
|
TestFuncs(aom_obmc_sad16x16_c, aom_obmc_sad16x16_sse4_1),
|
|
|
|
TestFuncs(aom_obmc_sad16x8_c, aom_obmc_sad16x8_sse4_1),
|
|
|
|
TestFuncs(aom_obmc_sad8x16_c, aom_obmc_sad8x16_sse4_1),
|
|
|
|
TestFuncs(aom_obmc_sad8x8_c, aom_obmc_sad8x8_sse4_1),
|
|
|
|
TestFuncs(aom_obmc_sad8x4_c, aom_obmc_sad8x4_sse4_1),
|
|
|
|
TestFuncs(aom_obmc_sad4x8_c, aom_obmc_sad4x8_sse4_1),
|
|
|
|
TestFuncs(aom_obmc_sad4x4_c, aom_obmc_sad4x4_sse4_1)
|
2016-07-05 15:36:25 +03:00
|
|
|
};
|
|
|
|
|
2016-12-07 21:56:39 +03:00
|
|
|
INSTANTIATE_TEST_CASE_P(SSE4_1, ObmcSadTest,
|
2016-07-05 15:36:25 +03:00
|
|
|
::testing::ValuesIn(sse4_functions));
|
|
|
|
#endif // HAVE_SSE4_1
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// High bit-depth
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
#if CONFIG_AOM_HIGHBITDEPTH
|
2016-07-12 17:26:36 +03:00
|
|
|
class ObmcSadHBDTest : public FunctionEquivalenceTest<ObmcSadF> {};
|
2016-07-05 15:36:25 +03:00
|
|
|
|
|
|
|
TEST_P(ObmcSadHBDTest, RandomValues) {
|
2016-07-12 15:20:04 +03:00
|
|
|
DECLARE_ALIGNED(32, uint16_t, pre[MAX_SB_SQUARE]);
|
2016-07-05 15:36:25 +03:00
|
|
|
DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
|
|
|
|
DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
|
|
|
|
|
2016-08-12 03:46:05 +03:00
|
|
|
for (int iter = 0; iter < kIterations && !HasFatalFailure(); ++iter) {
|
2016-07-12 15:20:04 +03:00
|
|
|
const int pre_stride = rng_(MAX_SB_SIZE + 1);
|
2016-07-05 15:36:25 +03:00
|
|
|
|
2016-08-12 03:46:05 +03:00
|
|
|
for (int i = 0; i < MAX_SB_SQUARE; ++i) {
|
|
|
|
pre[i] = rng_(1 << 12);
|
|
|
|
wsrc[i] = rng_(1 << 12) * rng_(kMaskMax * kMaskMax + 1);
|
2016-07-05 15:36:25 +03:00
|
|
|
mask[i] = rng_(kMaskMax * kMaskMax + 1);
|
|
|
|
}
|
|
|
|
|
2016-07-12 17:26:36 +03:00
|
|
|
const unsigned int ref_res =
|
|
|
|
params_.ref_func(CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask);
|
|
|
|
unsigned int tst_res;
|
2016-08-12 03:46:05 +03:00
|
|
|
ASM_REGISTER_STATE_CHECK(
|
|
|
|
tst_res =
|
|
|
|
params_.tst_func(CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask));
|
2016-07-05 15:36:25 +03:00
|
|
|
|
|
|
|
ASSERT_EQ(ref_res, tst_res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_P(ObmcSadHBDTest, ExtremeValues) {
|
2016-07-12 15:20:04 +03:00
|
|
|
DECLARE_ALIGNED(32, uint16_t, pre[MAX_SB_SQUARE]);
|
2016-07-05 15:36:25 +03:00
|
|
|
DECLARE_ALIGNED(32, int32_t, wsrc[MAX_SB_SQUARE]);
|
|
|
|
DECLARE_ALIGNED(32, int32_t, mask[MAX_SB_SQUARE]);
|
|
|
|
|
2016-08-12 03:46:05 +03:00
|
|
|
for (int iter = 0; iter < MAX_SB_SIZE && !HasFatalFailure(); ++iter) {
|
2016-07-12 15:20:04 +03:00
|
|
|
const int pre_stride = iter;
|
2016-07-05 15:36:25 +03:00
|
|
|
|
2016-08-12 03:46:05 +03:00
|
|
|
for (int i = 0; i < MAX_SB_SQUARE; ++i) {
|
2016-07-12 15:20:04 +03:00
|
|
|
pre[i] = (1 << 12) - 1;
|
2016-07-05 15:36:25 +03:00
|
|
|
wsrc[i] = ((1 << 12) - 1) * kMaskMax * kMaskMax;
|
|
|
|
mask[i] = kMaskMax * kMaskMax;
|
|
|
|
}
|
|
|
|
|
2016-07-12 17:26:36 +03:00
|
|
|
const unsigned int ref_res =
|
|
|
|
params_.ref_func(CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask);
|
|
|
|
unsigned int tst_res;
|
2016-08-12 03:46:05 +03:00
|
|
|
ASM_REGISTER_STATE_CHECK(
|
|
|
|
tst_res =
|
|
|
|
params_.tst_func(CONVERT_TO_BYTEPTR(pre), pre_stride, wsrc, mask));
|
2016-07-05 15:36:25 +03:00
|
|
|
|
|
|
|
ASSERT_EQ(ref_res, tst_res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if HAVE_SSE4_1
|
|
|
|
ObmcSadHBDTest::ParamType sse4_functions_hbd[] = {
|
|
|
|
#if CONFIG_EXT_PARTITION
|
2016-08-31 00:01:10 +03:00
|
|
|
TestFuncs(aom_highbd_obmc_sad128x128_c, aom_highbd_obmc_sad128x128_sse4_1),
|
|
|
|
TestFuncs(aom_highbd_obmc_sad128x64_c, aom_highbd_obmc_sad128x64_sse4_1),
|
|
|
|
TestFuncs(aom_highbd_obmc_sad64x128_c, aom_highbd_obmc_sad64x128_sse4_1),
|
2016-07-05 15:36:25 +03:00
|
|
|
#endif // CONFIG_EXT_PARTITION
|
2016-08-31 00:01:10 +03:00
|
|
|
TestFuncs(aom_highbd_obmc_sad64x64_c, aom_highbd_obmc_sad64x64_sse4_1),
|
|
|
|
TestFuncs(aom_highbd_obmc_sad64x32_c, aom_highbd_obmc_sad64x32_sse4_1),
|
|
|
|
TestFuncs(aom_highbd_obmc_sad32x64_c, aom_highbd_obmc_sad32x64_sse4_1),
|
|
|
|
TestFuncs(aom_highbd_obmc_sad32x32_c, aom_highbd_obmc_sad32x32_sse4_1),
|
|
|
|
TestFuncs(aom_highbd_obmc_sad32x16_c, aom_highbd_obmc_sad32x16_sse4_1),
|
|
|
|
TestFuncs(aom_highbd_obmc_sad16x32_c, aom_highbd_obmc_sad16x32_sse4_1),
|
|
|
|
TestFuncs(aom_highbd_obmc_sad16x16_c, aom_highbd_obmc_sad16x16_sse4_1),
|
|
|
|
TestFuncs(aom_highbd_obmc_sad16x8_c, aom_highbd_obmc_sad16x8_sse4_1),
|
|
|
|
TestFuncs(aom_highbd_obmc_sad8x16_c, aom_highbd_obmc_sad8x16_sse4_1),
|
|
|
|
TestFuncs(aom_highbd_obmc_sad8x8_c, aom_highbd_obmc_sad8x8_sse4_1),
|
|
|
|
TestFuncs(aom_highbd_obmc_sad8x4_c, aom_highbd_obmc_sad8x4_sse4_1),
|
|
|
|
TestFuncs(aom_highbd_obmc_sad4x8_c, aom_highbd_obmc_sad4x8_sse4_1),
|
|
|
|
TestFuncs(aom_highbd_obmc_sad4x4_c, aom_highbd_obmc_sad4x4_sse4_1)
|
2016-07-05 15:36:25 +03:00
|
|
|
};
|
|
|
|
|
2016-12-07 21:56:39 +03:00
|
|
|
INSTANTIATE_TEST_CASE_P(SSE4_1, ObmcSadHBDTest,
|
2016-07-05 15:36:25 +03:00
|
|
|
::testing::ValuesIn(sse4_functions_hbd));
|
|
|
|
#endif // HAVE_SSE4_1
|
2016-08-31 00:01:10 +03:00
|
|
|
#endif // CONFIG_AOM_HIGHBITDEPTH
|
2016-07-05 15:36:25 +03:00
|
|
|
} // namespace
|