2016-03-01 03:08:07 +03:00
|
|
|
/*
|
2016-11-29 02:26:06 +03:00
|
|
|
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
2016-03-01 03:08:07 +03:00
|
|
|
*
|
2016-11-29 02:26:06 +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-03-01 03:08:07 +03:00
|
|
|
*/
|
|
|
|
#include <math.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2017-02-08 04:14:05 +03:00
|
|
|
#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
|
2016-03-01 03:08:07 +03:00
|
|
|
#include "test/acm_random.h"
|
|
|
|
#include "test/clear_system_state.h"
|
|
|
|
#include "test/register_state_check.h"
|
|
|
|
#include "test/util.h"
|
|
|
|
|
2016-08-31 00:01:10 +03:00
|
|
|
#include "./aom_config.h"
|
|
|
|
#include "./aom_dsp_rtcd.h"
|
|
|
|
#include "aom/aom_integer.h"
|
2016-03-01 03:08:07 +03:00
|
|
|
|
2016-08-23 02:08:15 +03:00
|
|
|
using libaom_test::ACMRandom;
|
2016-03-01 03:08:07 +03:00
|
|
|
|
|
|
|
namespace {
|
2017-05-23 14:53:08 +03:00
|
|
|
const int number_of_iterations = 200;
|
2016-03-01 03:08:07 +03:00
|
|
|
|
2017-05-16 17:21:50 +03:00
|
|
|
typedef unsigned int (*MaskedSADFunc)(const uint8_t *src, int src_stride,
|
|
|
|
const uint8_t *ref, int ref_stride,
|
|
|
|
const uint8_t *second_pred,
|
|
|
|
const uint8_t *msk, int msk_stride,
|
|
|
|
int invert_mask);
|
2016-03-01 03:08:07 +03:00
|
|
|
typedef std::tr1::tuple<MaskedSADFunc, MaskedSADFunc> MaskedSADParam;
|
|
|
|
|
|
|
|
class MaskedSADTest : public ::testing::TestWithParam<MaskedSADParam> {
|
|
|
|
public:
|
|
|
|
virtual ~MaskedSADTest() {}
|
|
|
|
virtual void SetUp() {
|
2016-08-12 03:46:05 +03:00
|
|
|
maskedSAD_op_ = GET_PARAM(0);
|
2016-03-01 03:08:07 +03:00
|
|
|
ref_maskedSAD_op_ = GET_PARAM(1);
|
|
|
|
}
|
|
|
|
|
2016-08-23 02:08:15 +03:00
|
|
|
virtual void TearDown() { libaom_test::ClearSystemState(); }
|
2016-03-01 03:08:07 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
MaskedSADFunc maskedSAD_op_;
|
|
|
|
MaskedSADFunc ref_maskedSAD_op_;
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(MaskedSADTest, OperationCheck) {
|
|
|
|
unsigned int ref_ret, ret;
|
|
|
|
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
2016-08-12 03:46:05 +03:00
|
|
|
DECLARE_ALIGNED(16, uint8_t, src_ptr[MAX_SB_SIZE * MAX_SB_SIZE]);
|
|
|
|
DECLARE_ALIGNED(16, uint8_t, ref_ptr[MAX_SB_SIZE * MAX_SB_SIZE]);
|
2017-05-16 17:21:50 +03:00
|
|
|
DECLARE_ALIGNED(16, uint8_t, second_pred_ptr[MAX_SB_SIZE * MAX_SB_SIZE]);
|
2016-08-12 03:46:05 +03:00
|
|
|
DECLARE_ALIGNED(16, uint8_t, msk_ptr[MAX_SB_SIZE * MAX_SB_SIZE]);
|
2016-03-01 03:08:07 +03:00
|
|
|
int err_count = 0;
|
|
|
|
int first_failure = -1;
|
2016-03-07 16:46:39 +03:00
|
|
|
int src_stride = MAX_SB_SIZE;
|
|
|
|
int ref_stride = MAX_SB_SIZE;
|
|
|
|
int msk_stride = MAX_SB_SIZE;
|
2016-03-01 03:08:07 +03:00
|
|
|
for (int i = 0; i < number_of_iterations; ++i) {
|
2016-08-12 03:46:05 +03:00
|
|
|
for (int j = 0; j < MAX_SB_SIZE * MAX_SB_SIZE; j++) {
|
2016-03-01 03:08:07 +03:00
|
|
|
src_ptr[j] = rnd.Rand8();
|
|
|
|
ref_ptr[j] = rnd.Rand8();
|
2017-05-16 17:21:50 +03:00
|
|
|
second_pred_ptr[j] = rnd.Rand8();
|
2016-08-12 03:46:05 +03:00
|
|
|
msk_ptr[j] = ((rnd.Rand8() & 0x7f) > 64) ? rnd.Rand8() & 0x3f : 64;
|
2016-03-01 03:08:07 +03:00
|
|
|
assert(msk_ptr[j] <= 64);
|
|
|
|
}
|
|
|
|
|
2017-05-16 17:21:50 +03:00
|
|
|
for (int invert_mask = 0; invert_mask < 2; ++invert_mask) {
|
|
|
|
ref_ret =
|
|
|
|
ref_maskedSAD_op_(src_ptr, src_stride, ref_ptr, ref_stride,
|
|
|
|
second_pred_ptr, msk_ptr, msk_stride, invert_mask);
|
|
|
|
ASM_REGISTER_STATE_CHECK(ret = maskedSAD_op_(src_ptr, src_stride, ref_ptr,
|
|
|
|
ref_stride, second_pred_ptr,
|
|
|
|
msk_ptr, msk_stride,
|
|
|
|
invert_mask));
|
|
|
|
if (ret != ref_ret) {
|
|
|
|
err_count++;
|
|
|
|
if (first_failure == -1) first_failure = i;
|
|
|
|
}
|
2016-03-01 03:08:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPECT_EQ(0, err_count)
|
2016-08-12 03:46:05 +03:00
|
|
|
<< "Error: Masked SAD Test, C output doesn't match SSSE3 output. "
|
|
|
|
<< "First failed at test case " << first_failure;
|
2016-03-01 03:08:07 +03:00
|
|
|
}
|
|
|
|
|
2017-04-12 17:03:28 +03:00
|
|
|
#if CONFIG_HIGHBITDEPTH
|
2017-05-16 17:21:50 +03:00
|
|
|
typedef unsigned int (*HighbdMaskedSADFunc)(const uint8_t *src, int src_stride,
|
|
|
|
const uint8_t *ref, int ref_stride,
|
|
|
|
const uint8_t *second_pred,
|
|
|
|
const uint8_t *msk, int msk_stride,
|
|
|
|
int invert_mask);
|
2016-03-01 03:08:07 +03:00
|
|
|
typedef std::tr1::tuple<HighbdMaskedSADFunc, HighbdMaskedSADFunc>
|
|
|
|
HighbdMaskedSADParam;
|
|
|
|
|
2016-08-12 03:46:05 +03:00
|
|
|
class HighbdMaskedSADTest
|
|
|
|
: public ::testing::TestWithParam<HighbdMaskedSADParam> {
|
2016-03-01 03:08:07 +03:00
|
|
|
public:
|
|
|
|
virtual ~HighbdMaskedSADTest() {}
|
|
|
|
virtual void SetUp() {
|
2016-08-12 03:46:05 +03:00
|
|
|
maskedSAD_op_ = GET_PARAM(0);
|
2016-03-01 03:08:07 +03:00
|
|
|
ref_maskedSAD_op_ = GET_PARAM(1);
|
|
|
|
}
|
|
|
|
|
2016-08-23 02:08:15 +03:00
|
|
|
virtual void TearDown() { libaom_test::ClearSystemState(); }
|
2016-03-01 03:08:07 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
HighbdMaskedSADFunc maskedSAD_op_;
|
|
|
|
HighbdMaskedSADFunc ref_maskedSAD_op_;
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_P(HighbdMaskedSADTest, OperationCheck) {
|
|
|
|
unsigned int ref_ret, ret;
|
|
|
|
ACMRandom rnd(ACMRandom::DeterministicSeed());
|
2016-08-12 03:46:05 +03:00
|
|
|
DECLARE_ALIGNED(16, uint16_t, src_ptr[MAX_SB_SIZE * MAX_SB_SIZE]);
|
|
|
|
DECLARE_ALIGNED(16, uint16_t, ref_ptr[MAX_SB_SIZE * MAX_SB_SIZE]);
|
2017-05-16 17:21:50 +03:00
|
|
|
DECLARE_ALIGNED(16, uint16_t, second_pred_ptr[MAX_SB_SIZE * MAX_SB_SIZE]);
|
2016-08-12 03:46:05 +03:00
|
|
|
DECLARE_ALIGNED(16, uint8_t, msk_ptr[MAX_SB_SIZE * MAX_SB_SIZE]);
|
|
|
|
uint8_t *src8_ptr = CONVERT_TO_BYTEPTR(src_ptr);
|
|
|
|
uint8_t *ref8_ptr = CONVERT_TO_BYTEPTR(ref_ptr);
|
2017-05-16 17:21:50 +03:00
|
|
|
uint8_t *second_pred8_ptr = CONVERT_TO_BYTEPTR(second_pred_ptr);
|
2016-03-01 03:08:07 +03:00
|
|
|
int err_count = 0;
|
|
|
|
int first_failure = -1;
|
2016-03-07 16:46:39 +03:00
|
|
|
int src_stride = MAX_SB_SIZE;
|
|
|
|
int ref_stride = MAX_SB_SIZE;
|
|
|
|
int msk_stride = MAX_SB_SIZE;
|
2016-03-01 03:08:07 +03:00
|
|
|
for (int i = 0; i < number_of_iterations; ++i) {
|
2016-08-12 03:46:05 +03:00
|
|
|
for (int j = 0; j < MAX_SB_SIZE * MAX_SB_SIZE; j++) {
|
|
|
|
src_ptr[j] = rnd.Rand16() & 0xfff;
|
|
|
|
ref_ptr[j] = rnd.Rand16() & 0xfff;
|
2017-05-16 17:21:50 +03:00
|
|
|
second_pred_ptr[j] = rnd.Rand16() & 0xfff;
|
2016-08-12 03:46:05 +03:00
|
|
|
msk_ptr[j] = ((rnd.Rand8() & 0x7f) > 64) ? rnd.Rand8() & 0x3f : 64;
|
2016-03-01 03:08:07 +03:00
|
|
|
}
|
|
|
|
|
2017-05-16 17:21:50 +03:00
|
|
|
for (int invert_mask = 0; invert_mask < 2; ++invert_mask) {
|
|
|
|
ref_ret =
|
|
|
|
ref_maskedSAD_op_(src8_ptr, src_stride, ref8_ptr, ref_stride,
|
|
|
|
second_pred8_ptr, msk_ptr, msk_stride, invert_mask);
|
|
|
|
ASM_REGISTER_STATE_CHECK(ret = maskedSAD_op_(src8_ptr, src_stride,
|
|
|
|
ref8_ptr, ref_stride,
|
|
|
|
second_pred8_ptr, msk_ptr,
|
|
|
|
msk_stride, invert_mask));
|
|
|
|
if (ret != ref_ret) {
|
|
|
|
err_count++;
|
|
|
|
if (first_failure == -1) first_failure = i;
|
|
|
|
}
|
2016-03-01 03:08:07 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPECT_EQ(0, err_count)
|
2016-08-12 03:46:05 +03:00
|
|
|
<< "Error: High BD Masked SAD Test, C output doesn't match SSSE3 output. "
|
|
|
|
<< "First failed at test case " << first_failure;
|
2016-03-01 03:08:07 +03:00
|
|
|
}
|
2017-04-12 17:03:28 +03:00
|
|
|
#endif // CONFIG_HIGHBITDEPTH
|
2016-03-01 03:08:07 +03:00
|
|
|
|
|
|
|
using std::tr1::make_tuple;
|
|
|
|
|
2017-05-23 14:53:08 +03:00
|
|
|
#if HAVE_SSSE3
|
2017-06-03 18:40:49 +03:00
|
|
|
const MaskedSADParam msad_test[] = {
|
2016-03-02 14:12:52 +03:00
|
|
|
#if CONFIG_EXT_PARTITION
|
2017-06-03 18:40:49 +03:00
|
|
|
make_tuple(&aom_masked_sad128x128_ssse3, &aom_masked_sad128x128_c),
|
|
|
|
make_tuple(&aom_masked_sad128x64_ssse3, &aom_masked_sad128x64_c),
|
|
|
|
make_tuple(&aom_masked_sad64x128_ssse3, &aom_masked_sad64x128_c),
|
2016-03-02 14:12:52 +03:00
|
|
|
#endif // CONFIG_EXT_PARTITION
|
2017-06-03 18:40:49 +03:00
|
|
|
make_tuple(&aom_masked_sad64x64_ssse3, &aom_masked_sad64x64_c),
|
|
|
|
make_tuple(&aom_masked_sad64x32_ssse3, &aom_masked_sad64x32_c),
|
|
|
|
make_tuple(&aom_masked_sad32x64_ssse3, &aom_masked_sad32x64_c),
|
|
|
|
make_tuple(&aom_masked_sad32x32_ssse3, &aom_masked_sad32x32_c),
|
|
|
|
make_tuple(&aom_masked_sad32x16_ssse3, &aom_masked_sad32x16_c),
|
|
|
|
make_tuple(&aom_masked_sad16x32_ssse3, &aom_masked_sad16x32_c),
|
|
|
|
make_tuple(&aom_masked_sad16x16_ssse3, &aom_masked_sad16x16_c),
|
|
|
|
make_tuple(&aom_masked_sad16x8_ssse3, &aom_masked_sad16x8_c),
|
|
|
|
make_tuple(&aom_masked_sad8x16_ssse3, &aom_masked_sad8x16_c),
|
|
|
|
make_tuple(&aom_masked_sad8x8_ssse3, &aom_masked_sad8x8_c),
|
|
|
|
make_tuple(&aom_masked_sad8x4_ssse3, &aom_masked_sad8x4_c),
|
|
|
|
make_tuple(&aom_masked_sad4x8_ssse3, &aom_masked_sad4x8_c),
|
|
|
|
make_tuple(&aom_masked_sad4x4_ssse3, &aom_masked_sad4x4_c)
|
|
|
|
};
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(SSSE3_C_COMPARE, MaskedSADTest,
|
|
|
|
::testing::ValuesIn(msad_test));
|
2017-04-12 17:03:28 +03:00
|
|
|
#if CONFIG_HIGHBITDEPTH
|
2017-06-03 18:40:49 +03:00
|
|
|
const HighbdMaskedSADParam hbd_msad_test[] = {
|
2016-03-02 14:12:52 +03:00
|
|
|
#if CONFIG_EXT_PARTITION
|
2017-06-03 18:40:49 +03:00
|
|
|
make_tuple(&aom_highbd_masked_sad128x128_ssse3,
|
|
|
|
&aom_highbd_masked_sad128x128_c),
|
|
|
|
make_tuple(&aom_highbd_masked_sad128x64_ssse3,
|
|
|
|
&aom_highbd_masked_sad128x64_c),
|
|
|
|
make_tuple(&aom_highbd_masked_sad64x128_ssse3,
|
|
|
|
&aom_highbd_masked_sad64x128_c),
|
2016-03-02 14:12:52 +03:00
|
|
|
#endif // CONFIG_EXT_PARTITION
|
2017-06-03 18:40:49 +03:00
|
|
|
make_tuple(&aom_highbd_masked_sad64x64_ssse3, &aom_highbd_masked_sad64x64_c),
|
|
|
|
make_tuple(&aom_highbd_masked_sad64x32_ssse3, &aom_highbd_masked_sad64x32_c),
|
|
|
|
make_tuple(&aom_highbd_masked_sad32x64_ssse3, &aom_highbd_masked_sad32x64_c),
|
|
|
|
make_tuple(&aom_highbd_masked_sad32x32_ssse3, &aom_highbd_masked_sad32x32_c),
|
|
|
|
make_tuple(&aom_highbd_masked_sad32x16_ssse3, &aom_highbd_masked_sad32x16_c),
|
|
|
|
make_tuple(&aom_highbd_masked_sad16x32_ssse3, &aom_highbd_masked_sad16x32_c),
|
|
|
|
make_tuple(&aom_highbd_masked_sad16x16_ssse3, &aom_highbd_masked_sad16x16_c),
|
|
|
|
make_tuple(&aom_highbd_masked_sad16x8_ssse3, &aom_highbd_masked_sad16x8_c),
|
|
|
|
make_tuple(&aom_highbd_masked_sad8x16_ssse3, &aom_highbd_masked_sad8x16_c),
|
|
|
|
make_tuple(&aom_highbd_masked_sad8x8_ssse3, &aom_highbd_masked_sad8x8_c),
|
|
|
|
make_tuple(&aom_highbd_masked_sad8x4_ssse3, &aom_highbd_masked_sad8x4_c),
|
|
|
|
make_tuple(&aom_highbd_masked_sad4x8_ssse3, &aom_highbd_masked_sad4x8_c),
|
|
|
|
make_tuple(&aom_highbd_masked_sad4x4_ssse3, &aom_highbd_masked_sad4x4_c)
|
|
|
|
};
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(SSSE3_C_COMPARE, HighbdMaskedSADTest,
|
|
|
|
::testing::ValuesIn(hbd_msad_test));
|
2017-04-12 17:03:28 +03:00
|
|
|
#endif // CONFIG_HIGHBITDEPTH
|
2017-05-23 14:53:08 +03:00
|
|
|
#endif // HAVE_SSSE3
|
2016-03-01 03:08:07 +03:00
|
|
|
} // namespace
|