blob: 40884f342ad92a27330d6836e0b27b7c1b4088dc [file] [log] [blame]
Yi Luo50a164a2016-03-08 14:10:24 -08001/*
2 * Copyright (c) 2016 The WebM project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "third_party/googletest/src/include/gtest/gtest.h"
12
13#include "./vp10_rtcd.h"
14#include "./vpx_dsp_rtcd.h"
15
16#include "test/acm_random.h"
17#include "test/clear_system_state.h"
18#include "test/register_state_check.h"
19#include "test/transform_test_base.h"
20#include "test/util.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070021#include "aom_ports/mem.h"
Yi Luo50a164a2016-03-08 14:10:24 -080022
Yaowu Xuc27fc142016-08-22 16:08:15 -070023using libaom_test::ACMRandom;
Yi Luo50a164a2016-03-08 14:10:24 -080024
25namespace {
26typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
27 int tx_type);
Yi Luo412ad222016-05-09 10:36:40 -070028using std::tr1::tuple;
Yaowu Xuc27fc142016-08-22 16:08:15 -070029using libaom_test::FhtFunc;
Yi Luo412ad222016-05-09 10:36:40 -070030typedef tuple<FhtFunc, IhtFunc, int, vpx_bit_depth_t, int> Ht16x16Param;
Yi Luo50a164a2016-03-08 14:10:24 -080031
clang-format3a826f12016-08-11 17:46:05 -070032void fht16x16_ref(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
Yi Luo50a164a2016-03-08 14:10:24 -080033 vp10_fht16x16_c(in, out, stride, tx_type);
34}
35
Yi Luo412ad222016-05-09 10:36:40 -070036#if CONFIG_VP9_HIGHBITDEPTH
37typedef void (*IHbdHtFunc)(const tran_low_t *in, uint8_t *out, int stride,
38 int tx_type, int bd);
39typedef void (*HbdHtFunc)(const int16_t *input, int32_t *output, int stride,
40 int tx_type, int bd);
41
42// Target optimized function, tx_type, bit depth
43typedef tuple<HbdHtFunc, int, int> HighbdHt16x16Param;
44
45void highbd_fht16x16_ref(const int16_t *in, int32_t *out, int stride,
46 int tx_type, int bd) {
47 vp10_fwd_txfm2d_16x16_c(in, out, stride, tx_type, bd);
48}
49#endif // CONFIG_VP9_HIGHBITDEPTH
50
Yaowu Xuc27fc142016-08-22 16:08:15 -070051class VP10Trans16x16HT : public libaom_test::TransformTestBase,
clang-format3a826f12016-08-11 17:46:05 -070052 public ::testing::TestWithParam<Ht16x16Param> {
Yi Luo50a164a2016-03-08 14:10:24 -080053 public:
54 virtual ~VP10Trans16x16HT() {}
55
56 virtual void SetUp() {
57 fwd_txfm_ = GET_PARAM(0);
58 inv_txfm_ = GET_PARAM(1);
clang-format3a826f12016-08-11 17:46:05 -070059 tx_type_ = GET_PARAM(2);
60 pitch_ = 16;
Yi Luo50a164a2016-03-08 14:10:24 -080061 fwd_txfm_ref = fht16x16_ref;
62 bit_depth_ = GET_PARAM(3);
63 mask_ = (1 << bit_depth_) - 1;
64 num_coeffs_ = GET_PARAM(4);
65 }
Yaowu Xuc27fc142016-08-22 16:08:15 -070066 virtual void TearDown() { libaom_test::ClearSystemState(); }
Yi Luo50a164a2016-03-08 14:10:24 -080067
68 protected:
69 void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
70 fwd_txfm_(in, out, stride, tx_type_);
71 }
72
73 void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
74 inv_txfm_(out, dst, stride, tx_type_);
75 }
76
77 FhtFunc fwd_txfm_;
78 IhtFunc inv_txfm_;
79};
80
clang-format3a826f12016-08-11 17:46:05 -070081TEST_P(VP10Trans16x16HT, CoeffCheck) { RunCoeffCheck(); }
Yi Luo50a164a2016-03-08 14:10:24 -080082
Yi Luo412ad222016-05-09 10:36:40 -070083#if CONFIG_VP9_HIGHBITDEPTH
84class VP10HighbdTrans16x16HT
85 : public ::testing::TestWithParam<HighbdHt16x16Param> {
86 public:
87 virtual ~VP10HighbdTrans16x16HT() {}
Yi Luo770bf712016-03-25 16:48:19 -070088
Yi Luo412ad222016-05-09 10:36:40 -070089 virtual void SetUp() {
90 fwd_txfm_ = GET_PARAM(0);
91 fwd_txfm_ref_ = highbd_fht16x16_ref;
clang-format3a826f12016-08-11 17:46:05 -070092 tx_type_ = GET_PARAM(1);
Yi Luo412ad222016-05-09 10:36:40 -070093 bit_depth_ = GET_PARAM(2);
94 mask_ = (1 << bit_depth_) - 1;
95 num_coeffs_ = 256;
96
97 input_ = reinterpret_cast<int16_t *>(
98 vpx_memalign(16, sizeof(int16_t) * num_coeffs_));
99 output_ = reinterpret_cast<int32_t *>(
100 vpx_memalign(16, sizeof(int32_t) * num_coeffs_));
101 output_ref_ = reinterpret_cast<int32_t *>(
102 vpx_memalign(16, sizeof(int32_t) * num_coeffs_));
103 }
104
105 virtual void TearDown() {
106 vpx_free(input_);
107 vpx_free(output_);
108 vpx_free(output_ref_);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700109 libaom_test::ClearSystemState();
Yi Luo412ad222016-05-09 10:36:40 -0700110 }
111
112 protected:
113 void RunBitexactCheck();
114
115 private:
116 HbdHtFunc fwd_txfm_;
117 HbdHtFunc fwd_txfm_ref_;
118 int tx_type_;
119 int bit_depth_;
120 int mask_;
121 int num_coeffs_;
122 int16_t *input_;
123 int32_t *output_;
124 int32_t *output_ref_;
125};
126
127void VP10HighbdTrans16x16HT::RunBitexactCheck() {
128 ACMRandom rnd(ACMRandom::DeterministicSeed());
129 int i, j;
130 const int stride = 16;
Angie Chiang6f285812016-05-13 15:11:18 -0700131 const int num_tests = 1000;
Yi Luo412ad222016-05-09 10:36:40 -0700132
133 for (i = 0; i < num_tests; ++i) {
134 for (j = 0; j < num_coeffs_; ++j) {
135 input_[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_);
Yi Luo770bf712016-03-25 16:48:19 -0700136 }
137
Yi Luo412ad222016-05-09 10:36:40 -0700138 fwd_txfm_ref_(input_, output_ref_, stride, tx_type_, bit_depth_);
clang-format3a826f12016-08-11 17:46:05 -0700139 ASM_REGISTER_STATE_CHECK(
140 fwd_txfm_(input_, output_, stride, tx_type_, bit_depth_));
Yi Luo770bf712016-03-25 16:48:19 -0700141
Yi Luo412ad222016-05-09 10:36:40 -0700142 for (j = 0; j < num_coeffs_; ++j) {
143 EXPECT_EQ(output_ref_[j], output_[j])
clang-format3a826f12016-08-11 17:46:05 -0700144 << "Not bit-exact result at index: " << j << " at test block: " << i;
Yi Luo770bf712016-03-25 16:48:19 -0700145 }
Yi Luo412ad222016-05-09 10:36:40 -0700146 }
Yi Luo770bf712016-03-25 16:48:19 -0700147}
Yi Luo412ad222016-05-09 10:36:40 -0700148
clang-format3a826f12016-08-11 17:46:05 -0700149TEST_P(VP10HighbdTrans16x16HT, HighbdCoeffCheck) { RunBitexactCheck(); }
Yi Luo412ad222016-05-09 10:36:40 -0700150#endif // CONFIG_VP9_HIGHBITDEPTH
Yi Luo770bf712016-03-25 16:48:19 -0700151
Yi Luo50a164a2016-03-08 14:10:24 -0800152using std::tr1::make_tuple;
153
154#if HAVE_SSE2
Alex Converse2e520f22016-04-27 12:52:25 -0700155const Ht16x16Param kArrayHt16x16Param_sse2[] = {
clang-format3a826f12016-08-11 17:46:05 -0700156 make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 0, VPX_BITS_8,
157 256),
158 make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 1, VPX_BITS_8,
159 256),
160 make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 2, VPX_BITS_8,
161 256),
162 make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 3, VPX_BITS_8,
163 256),
Alex Converse2e520f22016-04-27 12:52:25 -0700164#if CONFIG_EXT_TX
clang-format3a826f12016-08-11 17:46:05 -0700165 make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 4, VPX_BITS_8,
166 256),
167 make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 5, VPX_BITS_8,
168 256),
169 make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 6, VPX_BITS_8,
170 256),
171 make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 7, VPX_BITS_8,
172 256),
173 make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 8, VPX_BITS_8,
174 256),
175 make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 10, VPX_BITS_8,
176 256),
177 make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 11, VPX_BITS_8,
178 256),
179 make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 12, VPX_BITS_8,
180 256),
181 make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 13, VPX_BITS_8,
182 256),
183 make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 14, VPX_BITS_8,
184 256),
185 make_tuple(&vp10_fht16x16_sse2, &vp10_iht16x16_256_add_sse2, 15, VPX_BITS_8,
186 256)
Alex Converse2e520f22016-04-27 12:52:25 -0700187#endif // CONFIG_EXT_TX
188};
clang-format3a826f12016-08-11 17:46:05 -0700189INSTANTIATE_TEST_CASE_P(SSE2, VP10Trans16x16HT,
190 ::testing::ValuesIn(kArrayHt16x16Param_sse2));
Yi Luo50a164a2016-03-08 14:10:24 -0800191#endif // HAVE_SSE2
192
Yi Luo412ad222016-05-09 10:36:40 -0700193#if HAVE_SSE4_1 && CONFIG_VP9_HIGHBITDEPTH
194const HighbdHt16x16Param kArrayHBDHt16x16Param_sse4_1[] = {
clang-format3a826f12016-08-11 17:46:05 -0700195 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 0, 10),
196 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 0, 12),
197 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 1, 10),
198 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 1, 12),
199 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 2, 10),
200 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 2, 12),
201 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 3, 10),
202 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 3, 12),
Angie Chiang6f285812016-05-13 15:11:18 -0700203#if CONFIG_EXT_TX
clang-format3a826f12016-08-11 17:46:05 -0700204 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 4, 10),
205 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 4, 12),
206 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 5, 10),
207 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 5, 12),
208 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 6, 10),
209 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 6, 12),
210 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 7, 10),
211 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 7, 12),
212 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 8, 10),
213 make_tuple(&vp10_fwd_txfm2d_16x16_sse4_1, 8, 12),
Yi Luo1d307362016-05-17 16:41:02 -0700214#endif // CONFIG_EXT_TX
Yi Luo412ad222016-05-09 10:36:40 -0700215};
clang-format3a826f12016-08-11 17:46:05 -0700216INSTANTIATE_TEST_CASE_P(SSE4_1, VP10HighbdTrans16x16HT,
217 ::testing::ValuesIn(kArrayHBDHt16x16Param_sse4_1));
Yi Luo412ad222016-05-09 10:36:40 -0700218#endif // HAVE_SSE4_1 && CONFIG_VP9_HIGHBITDEPTH
219
Yi Luo50a164a2016-03-08 14:10:24 -0800220} // namespace