2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
12 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
14 #include "config/av1_rtcd.h"
16 #include "test/acm_random.h"
17 #include "test/clear_system_state.h"
18 #include "test/register_state_check.h"
19 #include "test/util.h"
20 #include "av1/common/enums.h"
24 using ::testing::tuple
;
25 using libaom_test::ACMRandom
;
27 typedef void (*Predictor
)(uint8_t *dst
, ptrdiff_t stride
, TX_SIZE tx_size
,
28 const uint8_t *above
, const uint8_t *left
, int mode
);
31 // Test parameter list:
32 // Reference predictor, optimized predictor, prediction mode, tx size
34 typedef tuple
<Predictor
, Predictor
, int> PredFuncMode
;
35 typedef tuple
<PredFuncMode
, TX_SIZE
> PredParams
;
37 const int MaxTxSize
= 32;
39 const int MaxTestNum
= 100;
41 class AV1FilterIntraPredTest
: public ::testing::TestWithParam
<PredParams
> {
43 virtual ~AV1FilterIntraPredTest() {}
44 virtual void SetUp() {
45 PredFuncMode funcMode
= GET_PARAM(0);
46 predFuncRef_
= ::testing::get
<0>(funcMode
);
47 predFunc_
= ::testing::get
<1>(funcMode
);
48 mode_
= ::testing::get
<2>(funcMode
);
49 txSize_
= GET_PARAM(1);
51 alloc_
= new uint8_t[2 * MaxTxSize
+ 1];
52 predRef_
= new uint8_t[MaxTxSize
* MaxTxSize
];
53 pred_
= new uint8_t[MaxTxSize
* MaxTxSize
];
56 virtual void TearDown() {
60 libaom_test::ClearSystemState();
64 void RunTest() const {
66 int stride
= tx_size_wide
[txSize_
];
67 uint8_t *left
= alloc_
;
68 uint8_t *above
= alloc_
+ MaxTxSize
;
69 while (tstIndex
< MaxTestNum
) {
71 predFuncRef_(predRef_
, stride
, txSize_
, &above
[1], left
, mode_
);
72 ASM_REGISTER_STATE_CHECK(
73 predFunc_(pred_
, stride
, txSize_
, &above
[1], left
, mode_
));
80 void PrepareBuffer() const {
81 ACMRandom
rnd(ACMRandom::DeterministicSeed());
83 while (i
< (2 * MaxTxSize
+ 1)) {
84 alloc_
[i
] = rnd
.Rand8();
89 void DiffPred(int testNum
) const {
91 while (i
< tx_size_wide
[txSize_
] * tx_size_high
[txSize_
]) {
92 EXPECT_EQ(predRef_
[i
], pred_
[i
]) << "Error at position: " << i
<< " "
93 << "Tx size: " << tx_size_wide
[txSize_
]
94 << "x" << tx_size_high
[txSize_
] << " "
95 << "Test number: " << testNum
;
101 Predictor predFuncRef_
;
109 TEST_P(AV1FilterIntraPredTest
, BitExactCheck
) { RunTest(); }
111 using ::testing::make_tuple
;
113 const PredFuncMode kPredFuncMdArray
[] = {
114 make_tuple(&av1_filter_intra_predictor_c
, &av1_filter_intra_predictor_sse4_1
,
116 make_tuple(&av1_filter_intra_predictor_c
, &av1_filter_intra_predictor_sse4_1
,
118 make_tuple(&av1_filter_intra_predictor_c
, &av1_filter_intra_predictor_sse4_1
,
120 make_tuple(&av1_filter_intra_predictor_c
, &av1_filter_intra_predictor_sse4_1
,
122 make_tuple(&av1_filter_intra_predictor_c
, &av1_filter_intra_predictor_sse4_1
,
126 const TX_SIZE kTxSize
[] = { TX_4X4
, TX_8X8
, TX_16X16
, TX_32X32
, TX_4X8
,
127 TX_8X4
, TX_8X16
, TX_16X8
, TX_16X32
, TX_32X16
,
128 TX_4X16
, TX_16X4
, TX_8X32
, TX_32X8
};
130 INSTANTIATE_TEST_CASE_P(
131 SSE4_1
, AV1FilterIntraPredTest
,
132 ::testing::Combine(::testing::ValuesIn(kPredFuncMdArray
),
133 ::testing::ValuesIn(kTxSize
)));