1 /*
2 * Copyright (c) 2015 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 // Test and time VPX intra-predictor functions
11
12 #include <stdio.h>
13 #include <string.h>
14
15 #include "gtest/gtest.h"
16
17 #include "./vpx_config.h"
18 #include "./vpx_dsp_rtcd.h"
19 #include "test/acm_random.h"
20 #include "test/clear_system_state.h"
21 #include "test/init_vpx_test.h"
22 #include "test/md5_helper.h"
23 #include "vpx/vpx_integer.h"
24 #include "vpx_ports/mem.h"
25 #include "vpx_ports/vpx_timer.h"
26
27 // -----------------------------------------------------------------------------
28
29 namespace {
30
31 typedef void (*VpxPredFunc)(uint8_t *dst, ptrdiff_t y_stride,
32 const uint8_t *above, const uint8_t *left);
33
34 const int kBPS = 32;
35 const int kTotalPixels = 32 * kBPS;
36 const int kNumVp9IntraPredFuncs = 13;
37 const char *kVp9IntraPredNames[kNumVp9IntraPredFuncs] = {
38 "DC_PRED", "DC_LEFT_PRED", "DC_TOP_PRED", "DC_128_PRED", "V_PRED",
39 "H_PRED", "D45_PRED", "D135_PRED", "D117_PRED", "D153_PRED",
40 "D207_PRED", "D63_PRED", "TM_PRED"
41 };
42
43 template <typename Pixel>
44 struct IntraPredTestMem {
Init__anonf82f82e50111::IntraPredTestMem45 void Init(int block_size, int bd) {
46 libvpx_test::ACMRandom rnd(libvpx_test::ACMRandom::DeterministicSeed());
47 Pixel *const above = above_mem + 16;
48 const int mask = (1 << bd) - 1;
49 for (int i = 0; i < kTotalPixels; ++i) ref_src[i] = rnd.Rand16() & mask;
50 for (int i = 0; i < kBPS; ++i) left[i] = rnd.Rand16() & mask;
51 for (int i = -1; i < kBPS; ++i) above[i] = rnd.Rand16() & mask;
52
53 // d45/d63 require the top row to be extended.
54 ASSERT_LE(block_size, kBPS);
55 for (int i = block_size; i < 2 * block_size; ++i) {
56 above[i] = above[block_size - 1];
57 }
58 }
59
60 DECLARE_ALIGNED(16, Pixel, src[kTotalPixels]);
61 DECLARE_ALIGNED(16, Pixel, ref_src[kTotalPixels]);
62 DECLARE_ALIGNED(16, Pixel, left[kBPS]);
63 DECLARE_ALIGNED(16, Pixel, above_mem[2 * kBPS + 16]);
64 };
65
66 typedef IntraPredTestMem<uint8_t> Vp9IntraPredTestMem;
67
CheckMd5Signature(const char name[],const char * const signatures[],const void * data,size_t data_size,int elapsed_time,int idx)68 void CheckMd5Signature(const char name[], const char *const signatures[],
69 const void *data, size_t data_size, int elapsed_time,
70 int idx) {
71 libvpx_test::MD5 md5;
72 md5.Add(reinterpret_cast<const uint8_t *>(data), data_size);
73 printf("Mode %s[%12s]: %5d ms MD5: %s\n", name, kVp9IntraPredNames[idx],
74 elapsed_time, md5.Get());
75 EXPECT_STREQ(signatures[idx], md5.Get());
76 }
77
TestIntraPred(const char name[],VpxPredFunc const * pred_funcs,const char * const signatures[],int block_size)78 void TestIntraPred(const char name[], VpxPredFunc const *pred_funcs,
79 const char *const signatures[], int block_size) {
80 const int kNumTests = static_cast<int>(
81 2.e10 / (block_size * block_size * kNumVp9IntraPredFuncs));
82 Vp9IntraPredTestMem intra_pred_test_mem;
83 const uint8_t *const above = intra_pred_test_mem.above_mem + 16;
84
85 intra_pred_test_mem.Init(block_size, 8);
86
87 for (int k = 0; k < kNumVp9IntraPredFuncs; ++k) {
88 if (pred_funcs[k] == nullptr) continue;
89 memcpy(intra_pred_test_mem.src, intra_pred_test_mem.ref_src,
90 sizeof(intra_pred_test_mem.src));
91 vpx_usec_timer timer;
92 vpx_usec_timer_start(&timer);
93 for (int num_tests = 0; num_tests < kNumTests; ++num_tests) {
94 pred_funcs[k](intra_pred_test_mem.src, kBPS, above,
95 intra_pred_test_mem.left);
96 }
97 libvpx_test::ClearSystemState();
98 vpx_usec_timer_mark(&timer);
99 const int elapsed_time =
100 static_cast<int>(vpx_usec_timer_elapsed(&timer) / 1000);
101 CheckMd5Signature(name, signatures, intra_pred_test_mem.src,
102 sizeof(intra_pred_test_mem.src), elapsed_time, k);
103 }
104 }
105
TestIntraPred4(VpxPredFunc const * pred_funcs)106 void TestIntraPred4(VpxPredFunc const *pred_funcs) {
107 static const char *const kSignatures[kNumVp9IntraPredFuncs] = {
108 "e7ed7353c3383fff942e500e9bfe82fe", "2a4a26fcc6ce005eadc08354d196c8a9",
109 "269d92eff86f315d9c38fe7640d85b15", "ae2960eea9f71ee3dabe08b282ec1773",
110 "6c1abcc44e90148998b51acd11144e9c", "f7bb3186e1ef8a2b326037ff898cad8e",
111 "364c1f3fb2f445f935aec2a70a67eaa4", "141624072a4a56773f68fadbdd07c4a7",
112 "7be49b08687a5f24df3a2c612fca3876", "459bb5d9fd5b238348179c9a22108cd6",
113 "73edb8831bf1bdfce21ae8eaa43b1234", "2e2457f2009c701a355a8b25eb74fcda",
114 "52ae4e8bdbe41494c1f43051d4dd7f0b"
115 };
116 TestIntraPred("Intra4", pred_funcs, kSignatures, 4);
117 }
118
TestIntraPred8(VpxPredFunc const * pred_funcs)119 void TestIntraPred8(VpxPredFunc const *pred_funcs) {
120 static const char *const kSignatures[kNumVp9IntraPredFuncs] = {
121 "d8bbae5d6547cfc17e4f5f44c8730e88", "373bab6d931868d41a601d9d88ce9ac3",
122 "6fdd5ff4ff79656c14747598ca9e3706", "d9661c2811d6a73674f40ffb2b841847",
123 "7c722d10b19ccff0b8c171868e747385", "f81dd986eb2b50f750d3a7da716b7e27",
124 "d500f2c8fc78f46a4c74e4dcf51f14fb", "0e3523f9cab2142dd37fd07ec0760bce",
125 "79ac4efe907f0a0f1885d43066cfedee", "19ecf2432ac305057de3b6578474eec6",
126 "4f985b61acc6dd5d2d2585fa89ea2e2d", "f1bb25a9060dd262f405f15a38f5f674",
127 "209ea00801584829e9a0f7be7d4a74ba"
128 };
129 TestIntraPred("Intra8", pred_funcs, kSignatures, 8);
130 }
131
TestIntraPred16(VpxPredFunc const * pred_funcs)132 void TestIntraPred16(VpxPredFunc const *pred_funcs) {
133 static const char *const kSignatures[kNumVp9IntraPredFuncs] = {
134 "50971c07ce26977d30298538fffec619", "527a6b9e0dc5b21b98cf276305432bef",
135 "7eff2868f80ebc2c43a4f367281d80f7", "67cd60512b54964ef6aff1bd4816d922",
136 "48371c87dc95c08a33b2048f89cf6468", "b0acf2872ee411d7530af6d2625a7084",
137 "f32aafed4d8d3776ed58bcb6188756d5", "dae208f3dca583529cff49b73f7c4183",
138 "7af66a2f4c8e0b4908e40f047e60c47c", "125e3ab6ab9bc961f183ec366a7afa88",
139 "6b90f25b23983c35386b9fd704427622", "f8d6b11d710edc136a7c62c917435f93",
140 "ed308f18614a362917f411c218aee532"
141 };
142 TestIntraPred("Intra16", pred_funcs, kSignatures, 16);
143 }
144
TestIntraPred32(VpxPredFunc const * pred_funcs)145 void TestIntraPred32(VpxPredFunc const *pred_funcs) {
146 static const char *const kSignatures[kNumVp9IntraPredFuncs] = {
147 "a0a618c900e65ae521ccc8af789729f2", "985aaa7c72b4a6c2fb431d32100cf13a",
148 "10662d09febc3ca13ee4e700120daeb5", "b3b01379ba08916ef6b1b35f7d9ad51c",
149 "9f4261755795af97e34679c333ec7004", "bc2c9da91ad97ef0d1610fb0a9041657",
150 "75c79b1362ad18abfcdb1aa0aacfc21d", "4039bb7da0f6860090d3c57b5c85468f",
151 "b29fff7b61804e68383e3a609b33da58", "e1aa5e49067fd8dba66c2eb8d07b7a89",
152 "4e042822909c1c06d3b10a88281df1eb", "72eb9d9e0e67c93f4c66b70348e9fef7",
153 "a22d102bcb51ca798aac12ca4ae8f2e8"
154 };
155 TestIntraPred("Intra32", pred_funcs, kSignatures, 32);
156 }
157
158 } // namespace
159
160 // Defines a test case for |arch| (e.g., C, SSE2, ...) passing the predictors
161 // to |test_func|. The test name is 'arch.test_func', e.g., C.TestIntraPred4.
162 #define INTRA_PRED_TEST(arch, test_func, dc, dc_left, dc_top, dc_128, v, h, \
163 d45, d135, d117, d153, d207, d63, tm) \
164 TEST(arch, test_func) { \
165 static const VpxPredFunc vpx_intra_pred[] = { \
166 dc, dc_left, dc_top, dc_128, v, h, d45, d135, d117, d153, d207, d63, tm \
167 }; \
168 test_func(vpx_intra_pred); \
169 }
170
171 // -----------------------------------------------------------------------------
172
173 INTRA_PRED_TEST(C, TestIntraPred4, vpx_dc_predictor_4x4_c,
174 vpx_dc_left_predictor_4x4_c, vpx_dc_top_predictor_4x4_c,
175 vpx_dc_128_predictor_4x4_c, vpx_v_predictor_4x4_c,
176 vpx_h_predictor_4x4_c, vpx_d45_predictor_4x4_c,
177 vpx_d135_predictor_4x4_c, vpx_d117_predictor_4x4_c,
178 vpx_d153_predictor_4x4_c, vpx_d207_predictor_4x4_c,
179 vpx_d63_predictor_4x4_c, vpx_tm_predictor_4x4_c)
180
181 INTRA_PRED_TEST(C, TestIntraPred8, vpx_dc_predictor_8x8_c,
182 vpx_dc_left_predictor_8x8_c, vpx_dc_top_predictor_8x8_c,
183 vpx_dc_128_predictor_8x8_c, vpx_v_predictor_8x8_c,
184 vpx_h_predictor_8x8_c, vpx_d45_predictor_8x8_c,
185 vpx_d135_predictor_8x8_c, vpx_d117_predictor_8x8_c,
186 vpx_d153_predictor_8x8_c, vpx_d207_predictor_8x8_c,
187 vpx_d63_predictor_8x8_c, vpx_tm_predictor_8x8_c)
188
189 INTRA_PRED_TEST(C, TestIntraPred16, vpx_dc_predictor_16x16_c,
190 vpx_dc_left_predictor_16x16_c, vpx_dc_top_predictor_16x16_c,
191 vpx_dc_128_predictor_16x16_c, vpx_v_predictor_16x16_c,
192 vpx_h_predictor_16x16_c, vpx_d45_predictor_16x16_c,
193 vpx_d135_predictor_16x16_c, vpx_d117_predictor_16x16_c,
194 vpx_d153_predictor_16x16_c, vpx_d207_predictor_16x16_c,
195 vpx_d63_predictor_16x16_c, vpx_tm_predictor_16x16_c)
196
197 INTRA_PRED_TEST(C, TestIntraPred32, vpx_dc_predictor_32x32_c,
198 vpx_dc_left_predictor_32x32_c, vpx_dc_top_predictor_32x32_c,
199 vpx_dc_128_predictor_32x32_c, vpx_v_predictor_32x32_c,
200 vpx_h_predictor_32x32_c, vpx_d45_predictor_32x32_c,
201 vpx_d135_predictor_32x32_c, vpx_d117_predictor_32x32_c,
202 vpx_d153_predictor_32x32_c, vpx_d207_predictor_32x32_c,
203 vpx_d63_predictor_32x32_c, vpx_tm_predictor_32x32_c)
204
205 #if HAVE_SSE2
206 INTRA_PRED_TEST(SSE2, TestIntraPred4, vpx_dc_predictor_4x4_sse2,
207 vpx_dc_left_predictor_4x4_sse2, vpx_dc_top_predictor_4x4_sse2,
208 vpx_dc_128_predictor_4x4_sse2, vpx_v_predictor_4x4_sse2,
209 vpx_h_predictor_4x4_sse2, vpx_d45_predictor_4x4_sse2, nullptr,
210 nullptr, nullptr, vpx_d207_predictor_4x4_sse2, nullptr,
211 vpx_tm_predictor_4x4_sse2)
212
213 INTRA_PRED_TEST(SSE2, TestIntraPred8, vpx_dc_predictor_8x8_sse2,
214 vpx_dc_left_predictor_8x8_sse2, vpx_dc_top_predictor_8x8_sse2,
215 vpx_dc_128_predictor_8x8_sse2, vpx_v_predictor_8x8_sse2,
216 vpx_h_predictor_8x8_sse2, vpx_d45_predictor_8x8_sse2, nullptr,
217 nullptr, nullptr, nullptr, nullptr, vpx_tm_predictor_8x8_sse2)
218
219 INTRA_PRED_TEST(SSE2, TestIntraPred16, vpx_dc_predictor_16x16_sse2,
220 vpx_dc_left_predictor_16x16_sse2,
221 vpx_dc_top_predictor_16x16_sse2,
222 vpx_dc_128_predictor_16x16_sse2, vpx_v_predictor_16x16_sse2,
223 vpx_h_predictor_16x16_sse2, nullptr, nullptr, nullptr, nullptr,
224 nullptr, nullptr, vpx_tm_predictor_16x16_sse2)
225
226 INTRA_PRED_TEST(SSE2, TestIntraPred32, vpx_dc_predictor_32x32_sse2,
227 vpx_dc_left_predictor_32x32_sse2,
228 vpx_dc_top_predictor_32x32_sse2,
229 vpx_dc_128_predictor_32x32_sse2, vpx_v_predictor_32x32_sse2,
230 vpx_h_predictor_32x32_sse2, nullptr, nullptr, nullptr, nullptr,
231 nullptr, nullptr, vpx_tm_predictor_32x32_sse2)
232 #endif // HAVE_SSE2
233
234 #if HAVE_SSSE3
235 INTRA_PRED_TEST(SSSE3, TestIntraPred4, nullptr, nullptr, nullptr, nullptr,
236 nullptr, nullptr, nullptr, nullptr, nullptr,
237 vpx_d153_predictor_4x4_ssse3, nullptr,
238 vpx_d63_predictor_4x4_ssse3, nullptr)
239 INTRA_PRED_TEST(SSSE3, TestIntraPred8, nullptr, nullptr, nullptr, nullptr,
240 nullptr, nullptr, nullptr, nullptr, nullptr,
241 vpx_d153_predictor_8x8_ssse3, vpx_d207_predictor_8x8_ssse3,
242 vpx_d63_predictor_8x8_ssse3, nullptr)
243 INTRA_PRED_TEST(SSSE3, TestIntraPred16, nullptr, nullptr, nullptr, nullptr,
244 nullptr, nullptr, vpx_d45_predictor_16x16_ssse3, nullptr,
245 nullptr, vpx_d153_predictor_16x16_ssse3,
246 vpx_d207_predictor_16x16_ssse3, vpx_d63_predictor_16x16_ssse3,
247 nullptr)
248 INTRA_PRED_TEST(SSSE3, TestIntraPred32, nullptr, nullptr, nullptr, nullptr,
249 nullptr, nullptr, vpx_d45_predictor_32x32_ssse3, nullptr,
250 nullptr, vpx_d153_predictor_32x32_ssse3,
251 vpx_d207_predictor_32x32_ssse3, vpx_d63_predictor_32x32_ssse3,
252 nullptr)
253 #endif // HAVE_SSSE3
254
255 #if HAVE_DSPR2
256 INTRA_PRED_TEST(DSPR2, TestIntraPred4, vpx_dc_predictor_4x4_dspr2, nullptr,
257 nullptr, nullptr, nullptr, vpx_h_predictor_4x4_dspr2, nullptr,
258 nullptr, nullptr, nullptr, nullptr, nullptr,
259 vpx_tm_predictor_4x4_dspr2)
260 INTRA_PRED_TEST(DSPR2, TestIntraPred8, vpx_dc_predictor_8x8_dspr2, nullptr,
261 nullptr, nullptr, nullptr, vpx_h_predictor_8x8_dspr2, nullptr,
262 nullptr, nullptr, nullptr, nullptr, nullptr,
263 vpx_tm_predictor_8x8_c)
264 INTRA_PRED_TEST(DSPR2, TestIntraPred16, vpx_dc_predictor_16x16_dspr2, nullptr,
265 nullptr, nullptr, nullptr, vpx_h_predictor_16x16_dspr2, nullptr,
266 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr)
267 #endif // HAVE_DSPR2
268
269 #if HAVE_NEON
270 INTRA_PRED_TEST(NEON, TestIntraPred4, vpx_dc_predictor_4x4_neon,
271 vpx_dc_left_predictor_4x4_neon, vpx_dc_top_predictor_4x4_neon,
272 vpx_dc_128_predictor_4x4_neon, vpx_v_predictor_4x4_neon,
273 vpx_h_predictor_4x4_neon, vpx_d45_predictor_4x4_neon,
274 vpx_d135_predictor_4x4_neon, vpx_d117_predictor_4x4_neon,
275 vpx_d153_predictor_4x4_neon, vpx_d207_predictor_4x4_neon,
276 vpx_d63_predictor_4x4_neon, vpx_tm_predictor_4x4_neon)
277 INTRA_PRED_TEST(NEON, TestIntraPred8, vpx_dc_predictor_8x8_neon,
278 vpx_dc_left_predictor_8x8_neon, vpx_dc_top_predictor_8x8_neon,
279 vpx_dc_128_predictor_8x8_neon, vpx_v_predictor_8x8_neon,
280 vpx_h_predictor_8x8_neon, vpx_d45_predictor_8x8_neon,
281 vpx_d135_predictor_8x8_neon, vpx_d117_predictor_8x8_neon,
282 vpx_d153_predictor_8x8_neon, vpx_d207_predictor_8x8_neon,
283 vpx_d63_predictor_8x8_neon, vpx_tm_predictor_8x8_neon)
284 INTRA_PRED_TEST(NEON, TestIntraPred16, vpx_dc_predictor_16x16_neon,
285 vpx_dc_left_predictor_16x16_neon,
286 vpx_dc_top_predictor_16x16_neon,
287 vpx_dc_128_predictor_16x16_neon, vpx_v_predictor_16x16_neon,
288 vpx_h_predictor_16x16_neon, vpx_d45_predictor_16x16_neon,
289 vpx_d135_predictor_16x16_neon, vpx_d117_predictor_16x16_neon,
290 vpx_d153_predictor_16x16_neon, vpx_d207_predictor_16x16_neon,
291 vpx_d63_predictor_16x16_neon, vpx_tm_predictor_16x16_neon)
292 INTRA_PRED_TEST(NEON, TestIntraPred32, vpx_dc_predictor_32x32_neon,
293 vpx_dc_left_predictor_32x32_neon,
294 vpx_dc_top_predictor_32x32_neon,
295 vpx_dc_128_predictor_32x32_neon, vpx_v_predictor_32x32_neon,
296 vpx_h_predictor_32x32_neon, vpx_d45_predictor_32x32_neon,
297 vpx_d135_predictor_32x32_neon, vpx_d117_predictor_32x32_neon,
298 vpx_d153_predictor_32x32_neon, vpx_d207_predictor_32x32_neon,
299 vpx_d63_predictor_32x32_neon, vpx_tm_predictor_32x32_neon)
300 #endif // HAVE_NEON
301
302 #if HAVE_MSA
303 INTRA_PRED_TEST(MSA, TestIntraPred4, vpx_dc_predictor_4x4_msa,
304 vpx_dc_left_predictor_4x4_msa, vpx_dc_top_predictor_4x4_msa,
305 vpx_dc_128_predictor_4x4_msa, vpx_v_predictor_4x4_msa,
306 vpx_h_predictor_4x4_msa, nullptr, nullptr, nullptr, nullptr,
307 nullptr, nullptr, vpx_tm_predictor_4x4_msa)
308 INTRA_PRED_TEST(MSA, TestIntraPred8, vpx_dc_predictor_8x8_msa,
309 vpx_dc_left_predictor_8x8_msa, vpx_dc_top_predictor_8x8_msa,
310 vpx_dc_128_predictor_8x8_msa, vpx_v_predictor_8x8_msa,
311 vpx_h_predictor_8x8_msa, nullptr, nullptr, nullptr, nullptr,
312 nullptr, nullptr, vpx_tm_predictor_8x8_msa)
313 INTRA_PRED_TEST(MSA, TestIntraPred16, vpx_dc_predictor_16x16_msa,
314 vpx_dc_left_predictor_16x16_msa, vpx_dc_top_predictor_16x16_msa,
315 vpx_dc_128_predictor_16x16_msa, vpx_v_predictor_16x16_msa,
316 vpx_h_predictor_16x16_msa, nullptr, nullptr, nullptr, nullptr,
317 nullptr, nullptr, vpx_tm_predictor_16x16_msa)
318 INTRA_PRED_TEST(MSA, TestIntraPred32, vpx_dc_predictor_32x32_msa,
319 vpx_dc_left_predictor_32x32_msa, vpx_dc_top_predictor_32x32_msa,
320 vpx_dc_128_predictor_32x32_msa, vpx_v_predictor_32x32_msa,
321 vpx_h_predictor_32x32_msa, nullptr, nullptr, nullptr, nullptr,
322 nullptr, nullptr, vpx_tm_predictor_32x32_msa)
323 #endif // HAVE_MSA
324
325 #if HAVE_VSX
326 // TODO(crbug.com/webm/1522): Fix test failures.
327 #if 0
328 INTRA_PRED_TEST(VSX, TestIntraPred4, nullptr, nullptr, nullptr, nullptr,
329 nullptr, vpx_h_predictor_4x4_vsx, nullptr, nullptr, nullptr,
330 nullptr, nullptr, nullptr, vpx_tm_predictor_4x4_vsx)
331
332 INTRA_PRED_TEST(VSX, TestIntraPred8, vpx_dc_predictor_8x8_vsx, nullptr, nullptr,
333 nullptr, nullptr, vpx_h_predictor_8x8_vsx,
334 vpx_d45_predictor_8x8_vsx, nullptr, nullptr, nullptr, nullptr,
335 vpx_d63_predictor_8x8_vsx, vpx_tm_predictor_8x8_vsx)
336 #endif
337
338 INTRA_PRED_TEST(VSX, TestIntraPred16, vpx_dc_predictor_16x16_vsx,
339 vpx_dc_left_predictor_16x16_vsx, vpx_dc_top_predictor_16x16_vsx,
340 vpx_dc_128_predictor_16x16_vsx, vpx_v_predictor_16x16_vsx,
341 vpx_h_predictor_16x16_vsx, vpx_d45_predictor_16x16_vsx, nullptr,
342 nullptr, nullptr, nullptr, vpx_d63_predictor_16x16_vsx,
343 vpx_tm_predictor_16x16_vsx)
344
345 INTRA_PRED_TEST(VSX, TestIntraPred32, vpx_dc_predictor_32x32_vsx,
346 vpx_dc_left_predictor_32x32_vsx, vpx_dc_top_predictor_32x32_vsx,
347 vpx_dc_128_predictor_32x32_vsx, vpx_v_predictor_32x32_vsx,
348 vpx_h_predictor_32x32_vsx, vpx_d45_predictor_32x32_vsx, nullptr,
349 nullptr, nullptr, nullptr, vpx_d63_predictor_32x32_vsx,
350 vpx_tm_predictor_32x32_vsx)
351 #endif // HAVE_VSX
352
353 #if HAVE_LSX
354 INTRA_PRED_TEST(LSX, TestIntraPred8, vpx_dc_predictor_8x8_lsx, nullptr, nullptr,
355 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
356 nullptr, nullptr, nullptr)
357 INTRA_PRED_TEST(LSX, TestIntraPred16, vpx_dc_predictor_16x16_lsx, nullptr,
358 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
359 nullptr, nullptr, nullptr, nullptr)
360 #endif // HAVE_LSX
361
362 // -----------------------------------------------------------------------------
363
364 #if CONFIG_VP9_HIGHBITDEPTH
365 namespace {
366
367 typedef void (*VpxHighbdPredFunc)(uint16_t *dst, ptrdiff_t y_stride,
368 const uint16_t *above, const uint16_t *left,
369 int bd);
370
371 typedef IntraPredTestMem<uint16_t> Vp9HighbdIntraPredTestMem;
372
TestHighbdIntraPred(const char name[],VpxHighbdPredFunc const * pred_funcs,const char * const signatures[],int block_size)373 void TestHighbdIntraPred(const char name[], VpxHighbdPredFunc const *pred_funcs,
374 const char *const signatures[], int block_size) {
375 const int kNumTests = static_cast<int>(
376 2.e10 / (block_size * block_size * kNumVp9IntraPredFuncs));
377 Vp9HighbdIntraPredTestMem intra_pred_test_mem;
378 const uint16_t *const above = intra_pred_test_mem.above_mem + 16;
379
380 intra_pred_test_mem.Init(block_size, 12);
381
382 for (int k = 0; k < kNumVp9IntraPredFuncs; ++k) {
383 if (pred_funcs[k] == nullptr) continue;
384 memcpy(intra_pred_test_mem.src, intra_pred_test_mem.ref_src,
385 sizeof(intra_pred_test_mem.src));
386 vpx_usec_timer timer;
387 vpx_usec_timer_start(&timer);
388 for (int num_tests = 0; num_tests < kNumTests; ++num_tests) {
389 pred_funcs[k](intra_pred_test_mem.src, kBPS, above,
390 intra_pred_test_mem.left, 12);
391 }
392 libvpx_test::ClearSystemState();
393 vpx_usec_timer_mark(&timer);
394 const int elapsed_time =
395 static_cast<int>(vpx_usec_timer_elapsed(&timer) / 1000);
396 CheckMd5Signature(name, signatures, intra_pred_test_mem.src,
397 sizeof(intra_pred_test_mem.src), elapsed_time, k);
398 }
399 }
400
TestHighbdIntraPred4(VpxHighbdPredFunc const * pred_funcs)401 void TestHighbdIntraPred4(VpxHighbdPredFunc const *pred_funcs) {
402 static const char *const kSignatures[kNumVp9IntraPredFuncs] = {
403 "11f74af6c5737df472f3275cbde062fa", "51bea056b6447c93f6eb8f6b7e8f6f71",
404 "27e97f946766331795886f4de04c5594", "53ab15974b049111fb596c5168ec7e3f",
405 "f0b640bb176fbe4584cf3d32a9b0320a", "729783ca909e03afd4b47111c80d967b",
406 "fbf1c30793d9f32812e4d9f905d53530", "293fc903254a33754133314c6cdba81f",
407 "f8074d704233e73dfd35b458c6092374", "aa6363d08544a1ec4da33d7a0be5640d",
408 "462abcfdfa3d087bb33c9a88f2aec491", "863eab65d22550dd44a2397277c1ec71",
409 "23d61df1574d0fa308f9731811047c4b"
410 };
411 TestHighbdIntraPred("Intra4", pred_funcs, kSignatures, 4);
412 }
413
TestHighbdIntraPred8(VpxHighbdPredFunc const * pred_funcs)414 void TestHighbdIntraPred8(VpxHighbdPredFunc const *pred_funcs) {
415 static const char *const kSignatures[kNumVp9IntraPredFuncs] = {
416 "03da8829fe94663047fd108c5fcaa71d", "ecdb37b8120a2d3a4c706b016bd1bfd7",
417 "1d4543ed8d2b9368cb96898095fe8a75", "f791c9a67b913cbd82d9da8ecede30e2",
418 "065c70646f4dbaff913282f55a45a441", "51f87123616662ef7c35691497dfd0ba",
419 "2a5b0131ef4716f098ee65e6df01e3dd", "9ffe186a6bc7db95275f1bbddd6f7aba",
420 "a3258a2eae2e2bd55cb8f71351b22998", "8d909f0a2066e39b3216092c6289ece4",
421 "d183abb30b9f24c886a0517e991b22c7", "702a42fe4c7d665dc561b2aeeb60f311",
422 "7b5dbbbe7ae3a4ac2948731600bde5d6"
423 };
424 TestHighbdIntraPred("Intra8", pred_funcs, kSignatures, 8);
425 }
426
TestHighbdIntraPred16(VpxHighbdPredFunc const * pred_funcs)427 void TestHighbdIntraPred16(VpxHighbdPredFunc const *pred_funcs) {
428 static const char *const kSignatures[kNumVp9IntraPredFuncs] = {
429 "e33cb3f56a878e2fddb1b2fc51cdd275", "c7bff6f04b6052c8ab335d726dbbd52d",
430 "d0b0b47b654a9bcc5c6008110a44589b", "78f5da7b10b2b9ab39f114a33b6254e9",
431 "c78e31d23831abb40d6271a318fdd6f3", "90d1347f4ec9198a0320daecb6ff90b8",
432 "d2c623746cbb64a0c9e29c10f2c57041", "cf28bd387b81ad3e5f1a1c779a4b70a0",
433 "24c304330431ddeaf630f6ce94af2eac", "91a329798036bf64e8e00a87b131b8b1",
434 "d39111f22885307f920796a42084c872", "e2e702f7250ece98dd8f3f2854c31eeb",
435 "e2fb05b01eb8b88549e85641d8ce5b59"
436 };
437 TestHighbdIntraPred("Intra16", pred_funcs, kSignatures, 16);
438 }
439
TestHighbdIntraPred32(VpxHighbdPredFunc const * pred_funcs)440 void TestHighbdIntraPred32(VpxHighbdPredFunc const *pred_funcs) {
441 static const char *const kSignatures[kNumVp9IntraPredFuncs] = {
442 "a3e8056ba7e36628cce4917cd956fedd", "cc7d3024fe8748b512407edee045377e",
443 "2aab0a0f330a1d3e19b8ecb8f06387a3", "a547bc3fb7b06910bf3973122a426661",
444 "26f712514da95042f93d6e8dc8e431dc", "bb08c6e16177081daa3d936538dbc2e3",
445 "8f031af3e2650e89620d8d2c3a843d8b", "42867c8553285e94ee8e4df7abafbda8",
446 "6496bdee96100667833f546e1be3d640", "2ebfa25bf981377e682e580208504300",
447 "3e8ae52fd1f607f348aa4cb436c71ab7", "3d4efe797ca82193613696753ea624c4",
448 "cb8aab6d372278f3131e8d99efde02d9"
449 };
450 TestHighbdIntraPred("Intra32", pred_funcs, kSignatures, 32);
451 }
452
453 } // namespace
454
455 // Defines a test case for |arch| (e.g., C, SSE2, ...) passing the predictors
456 // to |test_func|. The test name is 'arch.test_func', e.g., C.TestIntraPred4.
457 #define HIGHBD_INTRA_PRED_TEST(arch, test_func, dc, dc_left, dc_top, dc_128, \
458 v, h, d45, d135, d117, d153, d207, d63, tm) \
459 TEST(arch, test_func) { \
460 static const VpxHighbdPredFunc vpx_intra_pred[] = { \
461 dc, dc_left, dc_top, dc_128, v, h, d45, d135, d117, d153, d207, d63, tm \
462 }; \
463 test_func(vpx_intra_pred); \
464 }
465
466 // -----------------------------------------------------------------------------
467
HIGHBD_INTRA_PRED_TEST(C,TestHighbdIntraPred4,vpx_highbd_dc_predictor_4x4_c,vpx_highbd_dc_left_predictor_4x4_c,vpx_highbd_dc_top_predictor_4x4_c,vpx_highbd_dc_128_predictor_4x4_c,vpx_highbd_v_predictor_4x4_c,vpx_highbd_h_predictor_4x4_c,vpx_highbd_d45_predictor_4x4_c,vpx_highbd_d135_predictor_4x4_c,vpx_highbd_d117_predictor_4x4_c,vpx_highbd_d153_predictor_4x4_c,vpx_highbd_d207_predictor_4x4_c,vpx_highbd_d63_predictor_4x4_c,vpx_highbd_tm_predictor_4x4_c)468 HIGHBD_INTRA_PRED_TEST(
469 C, TestHighbdIntraPred4, vpx_highbd_dc_predictor_4x4_c,
470 vpx_highbd_dc_left_predictor_4x4_c, vpx_highbd_dc_top_predictor_4x4_c,
471 vpx_highbd_dc_128_predictor_4x4_c, vpx_highbd_v_predictor_4x4_c,
472 vpx_highbd_h_predictor_4x4_c, vpx_highbd_d45_predictor_4x4_c,
473 vpx_highbd_d135_predictor_4x4_c, vpx_highbd_d117_predictor_4x4_c,
474 vpx_highbd_d153_predictor_4x4_c, vpx_highbd_d207_predictor_4x4_c,
475 vpx_highbd_d63_predictor_4x4_c, vpx_highbd_tm_predictor_4x4_c)
476
477 HIGHBD_INTRA_PRED_TEST(
478 C, TestHighbdIntraPred8, vpx_highbd_dc_predictor_8x8_c,
479 vpx_highbd_dc_left_predictor_8x8_c, vpx_highbd_dc_top_predictor_8x8_c,
480 vpx_highbd_dc_128_predictor_8x8_c, vpx_highbd_v_predictor_8x8_c,
481 vpx_highbd_h_predictor_8x8_c, vpx_highbd_d45_predictor_8x8_c,
482 vpx_highbd_d135_predictor_8x8_c, vpx_highbd_d117_predictor_8x8_c,
483 vpx_highbd_d153_predictor_8x8_c, vpx_highbd_d207_predictor_8x8_c,
484 vpx_highbd_d63_predictor_8x8_c, vpx_highbd_tm_predictor_8x8_c)
485
486 HIGHBD_INTRA_PRED_TEST(
487 C, TestHighbdIntraPred16, vpx_highbd_dc_predictor_16x16_c,
488 vpx_highbd_dc_left_predictor_16x16_c, vpx_highbd_dc_top_predictor_16x16_c,
489 vpx_highbd_dc_128_predictor_16x16_c, vpx_highbd_v_predictor_16x16_c,
490 vpx_highbd_h_predictor_16x16_c, vpx_highbd_d45_predictor_16x16_c,
491 vpx_highbd_d135_predictor_16x16_c, vpx_highbd_d117_predictor_16x16_c,
492 vpx_highbd_d153_predictor_16x16_c, vpx_highbd_d207_predictor_16x16_c,
493 vpx_highbd_d63_predictor_16x16_c, vpx_highbd_tm_predictor_16x16_c)
494
495 HIGHBD_INTRA_PRED_TEST(
496 C, TestHighbdIntraPred32, vpx_highbd_dc_predictor_32x32_c,
497 vpx_highbd_dc_left_predictor_32x32_c, vpx_highbd_dc_top_predictor_32x32_c,
498 vpx_highbd_dc_128_predictor_32x32_c, vpx_highbd_v_predictor_32x32_c,
499 vpx_highbd_h_predictor_32x32_c, vpx_highbd_d45_predictor_32x32_c,
500 vpx_highbd_d135_predictor_32x32_c, vpx_highbd_d117_predictor_32x32_c,
501 vpx_highbd_d153_predictor_32x32_c, vpx_highbd_d207_predictor_32x32_c,
502 vpx_highbd_d63_predictor_32x32_c, vpx_highbd_tm_predictor_32x32_c)
503
504 #if HAVE_SSE2
505 HIGHBD_INTRA_PRED_TEST(
506 SSE2, TestHighbdIntraPred4, vpx_highbd_dc_predictor_4x4_sse2,
507 vpx_highbd_dc_left_predictor_4x4_sse2, vpx_highbd_dc_top_predictor_4x4_sse2,
508 vpx_highbd_dc_128_predictor_4x4_sse2, vpx_highbd_v_predictor_4x4_sse2,
509 vpx_highbd_h_predictor_4x4_sse2, nullptr,
510 vpx_highbd_d135_predictor_4x4_sse2, vpx_highbd_d117_predictor_4x4_sse2,
511 vpx_highbd_d153_predictor_4x4_sse2, vpx_highbd_d207_predictor_4x4_sse2,
512 vpx_highbd_d63_predictor_4x4_sse2, vpx_highbd_tm_predictor_4x4_c)
513
514 HIGHBD_INTRA_PRED_TEST(
515 SSE2, TestHighbdIntraPred8, vpx_highbd_dc_predictor_8x8_sse2,
516 vpx_highbd_dc_left_predictor_8x8_sse2, vpx_highbd_dc_top_predictor_8x8_sse2,
517 vpx_highbd_dc_128_predictor_8x8_sse2, vpx_highbd_v_predictor_8x8_sse2,
518 vpx_highbd_h_predictor_8x8_sse2, nullptr, nullptr, nullptr, nullptr,
519 nullptr, nullptr, vpx_highbd_tm_predictor_8x8_sse2)
520
521 HIGHBD_INTRA_PRED_TEST(SSE2, TestHighbdIntraPred16,
522 vpx_highbd_dc_predictor_16x16_sse2,
523 vpx_highbd_dc_left_predictor_16x16_sse2,
524 vpx_highbd_dc_top_predictor_16x16_sse2,
525 vpx_highbd_dc_128_predictor_16x16_sse2,
526 vpx_highbd_v_predictor_16x16_sse2,
527 vpx_highbd_h_predictor_16x16_sse2, nullptr, nullptr,
528 nullptr, nullptr, nullptr, nullptr,
529 vpx_highbd_tm_predictor_16x16_sse2)
530
531 HIGHBD_INTRA_PRED_TEST(SSE2, TestHighbdIntraPred32,
532 vpx_highbd_dc_predictor_32x32_sse2,
533 vpx_highbd_dc_left_predictor_32x32_sse2,
534 vpx_highbd_dc_top_predictor_32x32_sse2,
535 vpx_highbd_dc_128_predictor_32x32_sse2,
536 vpx_highbd_v_predictor_32x32_sse2,
537 vpx_highbd_h_predictor_32x32_sse2, nullptr, nullptr,
538 nullptr, nullptr, nullptr, nullptr,
539 vpx_highbd_tm_predictor_32x32_sse2)
540 #endif // HAVE_SSE2
541
542 #if HAVE_SSSE3
543 HIGHBD_INTRA_PRED_TEST(SSSE3, TestHighbdIntraPred4, nullptr, nullptr, nullptr,
544 nullptr, nullptr, nullptr,
545 vpx_highbd_d45_predictor_4x4_ssse3, nullptr, nullptr,
546 nullptr, nullptr, nullptr, nullptr)
547 HIGHBD_INTRA_PRED_TEST(SSSE3, TestHighbdIntraPred8, nullptr, nullptr, nullptr,
548 nullptr, nullptr, nullptr,
549 vpx_highbd_d45_predictor_8x8_ssse3,
550 vpx_highbd_d135_predictor_8x8_ssse3,
551 vpx_highbd_d117_predictor_8x8_ssse3,
552 vpx_highbd_d153_predictor_8x8_ssse3,
553 vpx_highbd_d207_predictor_8x8_ssse3,
554 vpx_highbd_d63_predictor_8x8_ssse3, nullptr)
555 HIGHBD_INTRA_PRED_TEST(SSSE3, TestHighbdIntraPred16, nullptr, nullptr, nullptr,
556 nullptr, nullptr, nullptr,
557 vpx_highbd_d45_predictor_16x16_ssse3,
558 vpx_highbd_d135_predictor_16x16_ssse3,
559 vpx_highbd_d117_predictor_16x16_ssse3,
560 vpx_highbd_d153_predictor_16x16_ssse3,
561 vpx_highbd_d207_predictor_16x16_ssse3,
562 vpx_highbd_d63_predictor_16x16_ssse3, nullptr)
563 HIGHBD_INTRA_PRED_TEST(SSSE3, TestHighbdIntraPred32, nullptr, nullptr, nullptr,
564 nullptr, nullptr, nullptr,
565 vpx_highbd_d45_predictor_32x32_ssse3,
566 vpx_highbd_d135_predictor_32x32_ssse3,
567 vpx_highbd_d117_predictor_32x32_ssse3,
568 vpx_highbd_d153_predictor_32x32_ssse3,
569 vpx_highbd_d207_predictor_32x32_ssse3,
570 vpx_highbd_d63_predictor_32x32_ssse3, nullptr)
571 #endif // HAVE_SSSE3
572
573 #if HAVE_NEON
574 HIGHBD_INTRA_PRED_TEST(
575 NEON, TestHighbdIntraPred4, vpx_highbd_dc_predictor_4x4_neon,
576 vpx_highbd_dc_left_predictor_4x4_neon, vpx_highbd_dc_top_predictor_4x4_neon,
577 vpx_highbd_dc_128_predictor_4x4_neon, vpx_highbd_v_predictor_4x4_neon,
578 vpx_highbd_h_predictor_4x4_neon, vpx_highbd_d45_predictor_4x4_neon,
579 vpx_highbd_d135_predictor_4x4_neon, vpx_highbd_d117_predictor_4x4_neon,
580 vpx_highbd_d153_predictor_4x4_neon, vpx_highbd_d207_predictor_4x4_neon,
581 vpx_highbd_d63_predictor_4x4_neon, vpx_highbd_tm_predictor_4x4_neon)
582 HIGHBD_INTRA_PRED_TEST(
583 NEON, TestHighbdIntraPred8, vpx_highbd_dc_predictor_8x8_neon,
584 vpx_highbd_dc_left_predictor_8x8_neon, vpx_highbd_dc_top_predictor_8x8_neon,
585 vpx_highbd_dc_128_predictor_8x8_neon, vpx_highbd_v_predictor_8x8_neon,
586 vpx_highbd_h_predictor_8x8_neon, vpx_highbd_d45_predictor_8x8_neon,
587 vpx_highbd_d135_predictor_8x8_neon, vpx_highbd_d117_predictor_8x8_neon,
588 vpx_highbd_d153_predictor_8x8_neon, vpx_highbd_d207_predictor_8x8_neon,
589 vpx_highbd_d63_predictor_8x8_neon, vpx_highbd_tm_predictor_8x8_neon)
590 HIGHBD_INTRA_PRED_TEST(
591 NEON, TestHighbdIntraPred16, vpx_highbd_dc_predictor_16x16_neon,
592 vpx_highbd_dc_left_predictor_16x16_neon,
593 vpx_highbd_dc_top_predictor_16x16_neon,
594 vpx_highbd_dc_128_predictor_16x16_neon, vpx_highbd_v_predictor_16x16_neon,
595 vpx_highbd_h_predictor_16x16_neon, vpx_highbd_d45_predictor_16x16_neon,
596 vpx_highbd_d135_predictor_16x16_neon, vpx_highbd_d117_predictor_16x16_neon,
597 vpx_highbd_d153_predictor_16x16_neon, vpx_highbd_d207_predictor_16x16_neon,
598 vpx_highbd_d63_predictor_16x16_neon, vpx_highbd_tm_predictor_16x16_neon)
599 HIGHBD_INTRA_PRED_TEST(
600 NEON, TestHighbdIntraPred32, vpx_highbd_dc_predictor_32x32_neon,
601 vpx_highbd_dc_left_predictor_32x32_neon,
602 vpx_highbd_dc_top_predictor_32x32_neon,
603 vpx_highbd_dc_128_predictor_32x32_neon, vpx_highbd_v_predictor_32x32_neon,
604 vpx_highbd_h_predictor_32x32_neon, vpx_highbd_d45_predictor_32x32_neon,
605 vpx_highbd_d135_predictor_32x32_neon, vpx_highbd_d117_predictor_32x32_neon,
606 vpx_highbd_d153_predictor_32x32_neon, vpx_highbd_d207_predictor_32x32_neon,
607 vpx_highbd_d63_predictor_32x32_neon, vpx_highbd_tm_predictor_32x32_neon)
608 #endif // HAVE_NEON
609
610 #endif // CONFIG_VP9_HIGHBITDEPTH
611
612 int main(int argc, char **argv) {
613 ::testing::InitGoogleTest(&argc, argv);
614 ::libvpx_test::init_vpx_test();
615 return RUN_ALL_TESTS();
616 }
617