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