]> granicus.if.org Git - libvpx/blob - test/test_intra_pred_speed.cc
Merge "Deduplicate some high bit depth tables"
[libvpx] / test / test_intra_pred_speed.cc
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 kNumVp9IntraPredFuncs = 13;
33 const char *kVp9IntraPredNames[kNumVp9IntraPredFuncs] = {
34   "DC_PRED", "DC_LEFT_PRED", "DC_TOP_PRED", "DC_128_PRED", "V_PRED", "H_PRED",
35   "D45_PRED", "D135_PRED", "D117_PRED", "D153_PRED", "D207_PRED", "D63_PRED",
36   "TM_PRED"
37 };
38
39 void TestIntraPred(const char name[], VpxPredFunc const *pred_funcs,
40                    const char *const pred_func_names[], int num_funcs,
41                    const char *const signatures[], int block_size,
42                    int num_pixels_per_test) {
43   libvpx_test::ACMRandom rnd(libvpx_test::ACMRandom::DeterministicSeed());
44   const int kBPS = 32;
45   const int kTotalPixels = 32 * kBPS;
46   DECLARE_ALIGNED(16, uint8_t, src[kTotalPixels]);
47   DECLARE_ALIGNED(16, uint8_t, ref_src[kTotalPixels]);
48   DECLARE_ALIGNED(16, uint8_t, left[kBPS]);
49   DECLARE_ALIGNED(16, uint8_t, above_mem[2 * kBPS + 16]);
50   uint8_t *const above = above_mem + 16;
51   for (int i = 0; i < kTotalPixels; ++i) ref_src[i] = rnd.Rand8();
52   for (int i = 0; i < kBPS; ++i) left[i] = rnd.Rand8();
53   for (int i = -1; i < kBPS; ++i) above[i] = rnd.Rand8();
54   const int kNumTests = static_cast<int>(2.e10 / num_pixels_per_test);
55
56   // some code assumes the top row has been extended:
57   // d45/d63 C-code, for instance, but not the assembly.
58   // TODO(jzern): this style of extension isn't strictly necessary.
59   ASSERT_LE(block_size, kBPS);
60   memset(above + block_size, above[block_size - 1], 2 * kBPS - block_size);
61
62   for (int k = 0; k < num_funcs; ++k) {
63     if (pred_funcs[k] == NULL) continue;
64     memcpy(src, ref_src, sizeof(src));
65     vpx_usec_timer timer;
66     vpx_usec_timer_start(&timer);
67     for (int num_tests = 0; num_tests < kNumTests; ++num_tests) {
68       pred_funcs[k](src, kBPS, above, left);
69     }
70     libvpx_test::ClearSystemState();
71     vpx_usec_timer_mark(&timer);
72     const int elapsed_time =
73         static_cast<int>(vpx_usec_timer_elapsed(&timer) / 1000);
74     libvpx_test::MD5 md5;
75     md5.Add(src, sizeof(src));
76     printf("Mode %s[%12s]: %5d ms     MD5: %s\n", name, pred_func_names[k],
77            elapsed_time, md5.Get());
78     EXPECT_STREQ(signatures[k], md5.Get());
79   }
80 }
81
82 void TestIntraPred4(VpxPredFunc const *pred_funcs) {
83   static const int kNumVp9IntraFuncs = 13;
84   static const char *const kSignatures[kNumVp9IntraFuncs] = {
85     "4334156168b34ab599d9b5b30f522fe9",
86     "bc4649d5ba47c7ff178d92e475960fb0",
87     "8d316e5933326dcac24e1064794b5d12",
88     "a27270fed024eafd762c95de85f4da51",
89     "c33dff000d4256c2b8f3bf9e9bab14d2",
90     "44d8cddc2ad8f79b8ed3306051722b4f",
91     "eb54839b2bad6699d8946f01ec041cd0",
92     "ecb0d56ae5f677ea45127ce9d5c058e4",
93     "0b7936841f6813da818275944895b574",
94     "9117972ef64f91a58ff73e1731c81db2",
95     "c56d5e8c729e46825f46dd5d3b5d508a",
96     "c0889e2039bcf7bcb5d2f33cdca69adc",
97     "309a618577b27c648f9c5ee45252bc8f",
98   };
99   TestIntraPred("Intra4", pred_funcs, kVp9IntraPredNames, kNumVp9IntraFuncs,
100                 kSignatures, 4, 4 * 4 * kNumVp9IntraFuncs);
101 }
102
103 void TestIntraPred8(VpxPredFunc const *pred_funcs) {
104   static const int kNumVp9IntraFuncs = 13;
105   static const char *const kSignatures[kNumVp9IntraFuncs] = {
106     "7694ddeeefed887faf9d339d18850928",
107     "7d726b1213591b99f736be6dec65065b",
108     "19c5711281357a485591aaf9c96c0a67",
109     "ba6b66877a089e71cd938e3b8c40caac",
110     "802440c93317e0f8ba93fab02ef74265",
111     "9e09a47a15deb0b9d8372824f9805080",
112     "b7c2d8c662268c0c427da412d7b0311d",
113     "78339c1c60bb1d67d248ab8c4da08b7f",
114     "5c97d70f7d47de1882a6cd86c165c8a9",
115     "8182bf60688b42205acd95e59e967157",
116     "08323400005a297f16d7e57e7fe1eaac",
117     "95f7bfc262329a5849eda66d8f7c68ce",
118     "815b75c8e0d91cc1ae766dc5d3e445a3",
119   };
120   TestIntraPred("Intra8", pred_funcs, kVp9IntraPredNames, kNumVp9IntraFuncs,
121                 kSignatures, 8, 8 * 8 * kNumVp9IntraFuncs);
122 }
123
124 void TestIntraPred16(VpxPredFunc const *pred_funcs) {
125   static const int kNumVp9IntraFuncs = 13;
126   static const char *const kSignatures[kNumVp9IntraFuncs] = {
127     "b40dbb555d5d16a043dc361e6694fe53",
128     "fb08118cee3b6405d64c1fd68be878c6",
129     "6c190f341475c837cc38c2e566b64875",
130     "db5c34ccbe2c7f595d9b08b0dc2c698c",
131     "a62cbfd153a1f0b9fed13e62b8408a7a",
132     "143df5b4c89335e281103f610f5052e4",
133     "d87feb124107cdf2cfb147655aa0bb3c",
134     "7841fae7d4d47b519322e6a03eeed9dc",
135     "f6ebed3f71cbcf8d6d0516ce87e11093",
136     "3cc480297dbfeed01a1c2d78dd03d0c5",
137     "b9f69fa6532b372c545397dcb78ef311",
138     "a8fe1c70432f09d0c20c67bdb6432c4d",
139     "b8a41aa968ec108af447af4217cba91b",
140   };
141   TestIntraPred("Intra16", pred_funcs, kVp9IntraPredNames, kNumVp9IntraFuncs,
142                 kSignatures, 16, 16 * 16 * kNumVp9IntraFuncs);
143 }
144
145 void TestIntraPred32(VpxPredFunc const *pred_funcs) {
146   static const int kNumVp9IntraFuncs = 13;
147   static const char *const kSignatures[kNumVp9IntraFuncs] = {
148     "558541656d84f9ae7896db655826febe",
149     "b3587a1f9a01495fa38c8cd3c8e2a1bf",
150     "4c6501e64f25aacc55a2a16c7e8f0255",
151     "b3b01379ba08916ef6b1b35f7d9ad51c",
152     "0f1eb38b6cbddb3d496199ef9f329071",
153     "911c06efb9ed1c3b4c104b232b55812f",
154     "9225beb0ddfa7a1d24eaa1be430a6654",
155     "0a6d584a44f8db9aa7ade2e2fdb9fc9e",
156     "b01c9076525216925f3456f034fb6eee",
157     "d267e20ad9e5cd2915d1a47254d3d149",
158     "ed012a4a5da71f36c2393023184a0e59",
159     "f162b51ed618d28b936974cff4391da5",
160     "9e1370c6d42e08d357d9612c93a71cfc",
161   };
162   TestIntraPred("Intra32", pred_funcs, kVp9IntraPredNames, kNumVp9IntraFuncs,
163                 kSignatures, 32, 32 * 32 * kNumVp9IntraFuncs);
164 }
165
166 }  // namespace
167
168 // Defines a test case for |arch| (e.g., C, SSE2, ...) passing the predictors
169 // to |test_func|. The test name is 'arch.test_func', e.g., C.TestIntraPred4.
170 #define INTRA_PRED_TEST(arch, test_func, dc, dc_left, dc_top, dc_128, v, h, \
171                         d45, d135, d117, d153, d207, d63, tm)               \
172   TEST(arch, test_func) {                                                   \
173     static const VpxPredFunc vpx_intra_pred[] = {                           \
174         dc,   dc_left, dc_top, dc_128, v,   h, d45,                         \
175         d135, d117,    d153,   d207,   d63, tm};                            \
176     test_func(vpx_intra_pred);                                              \
177   }
178
179 // -----------------------------------------------------------------------------
180 // 4x4
181
182 INTRA_PRED_TEST(C, TestIntraPred4, vpx_dc_predictor_4x4_c,
183                 vpx_dc_left_predictor_4x4_c, vpx_dc_top_predictor_4x4_c,
184                 vpx_dc_128_predictor_4x4_c, vpx_v_predictor_4x4_c,
185                 vpx_h_predictor_4x4_c, vpx_d45_predictor_4x4_c,
186                 vpx_d135_predictor_4x4_c, vpx_d117_predictor_4x4_c,
187                 vpx_d153_predictor_4x4_c, vpx_d207_predictor_4x4_c,
188                 vpx_d63_predictor_4x4_c, vpx_tm_predictor_4x4_c)
189
190 #if HAVE_SSE && CONFIG_USE_X86INC
191 INTRA_PRED_TEST(SSE, TestIntraPred4, vpx_dc_predictor_4x4_sse,
192                 vpx_dc_left_predictor_4x4_sse, vpx_dc_top_predictor_4x4_sse,
193                 vpx_dc_128_predictor_4x4_sse, vpx_v_predictor_4x4_sse, NULL,
194                 NULL, NULL, NULL, NULL, NULL, NULL, NULL)
195 #endif  // HAVE_SSE && CONFIG_USE_X86INC
196
197 #if HAVE_SSE2 && CONFIG_USE_X86INC
198 INTRA_PRED_TEST(SSE2, TestIntraPred4, NULL, NULL, NULL, NULL, NULL, NULL,
199                 NULL, NULL, NULL, NULL, NULL, NULL, vpx_tm_predictor_4x4_sse2)
200 #endif  // HAVE_SSE2 && CONFIG_USE_X86INC
201
202 #if HAVE_SSSE3 && CONFIG_USE_X86INC
203 INTRA_PRED_TEST(SSSE3, TestIntraPred4, NULL, NULL, NULL, NULL, NULL,
204                 vpx_h_predictor_4x4_ssse3, vpx_d45_predictor_4x4_ssse3, NULL,
205                 NULL, vpx_d153_predictor_4x4_ssse3,
206                 vpx_d207_predictor_4x4_ssse3, vpx_d63_predictor_4x4_ssse3, NULL)
207 #endif  // HAVE_SSSE3 && CONFIG_USE_X86INC
208
209 #if HAVE_DSPR2
210 INTRA_PRED_TEST(DSPR2, TestIntraPred4, vpx_dc_predictor_4x4_dspr2, NULL, NULL,
211                 NULL, NULL, vpx_h_predictor_4x4_dspr2, NULL, NULL, NULL, NULL,
212                 NULL, NULL, vpx_tm_predictor_4x4_dspr2)
213 #endif  // HAVE_DSPR2
214
215 #if HAVE_NEON
216 INTRA_PRED_TEST(NEON, TestIntraPred4, vpx_dc_predictor_4x4_neon,
217                 vpx_dc_left_predictor_4x4_neon, vpx_dc_top_predictor_4x4_neon,
218                 vpx_dc_128_predictor_4x4_neon, vpx_v_predictor_4x4_neon,
219                 vpx_h_predictor_4x4_neon, vpx_d45_predictor_4x4_neon,
220                 vpx_d135_predictor_4x4_neon, NULL, NULL, NULL, NULL,
221                 vpx_tm_predictor_4x4_neon)
222 #endif  // HAVE_NEON
223
224 #if HAVE_MSA
225 INTRA_PRED_TEST(MSA, TestIntraPred4, vpx_dc_predictor_4x4_msa,
226                 vpx_dc_left_predictor_4x4_msa, vpx_dc_top_predictor_4x4_msa,
227                 vpx_dc_128_predictor_4x4_msa, vpx_v_predictor_4x4_msa,
228                 vpx_h_predictor_4x4_msa, NULL, NULL, NULL, NULL, NULL,
229                 NULL, vpx_tm_predictor_4x4_msa)
230 #endif  // HAVE_MSA
231
232 // -----------------------------------------------------------------------------
233 // 8x8
234
235 INTRA_PRED_TEST(C, TestIntraPred8, vpx_dc_predictor_8x8_c,
236                 vpx_dc_left_predictor_8x8_c, vpx_dc_top_predictor_8x8_c,
237                 vpx_dc_128_predictor_8x8_c, vpx_v_predictor_8x8_c,
238                 vpx_h_predictor_8x8_c, vpx_d45_predictor_8x8_c,
239                 vpx_d135_predictor_8x8_c, vpx_d117_predictor_8x8_c,
240                 vpx_d153_predictor_8x8_c, vpx_d207_predictor_8x8_c,
241                 vpx_d63_predictor_8x8_c, vpx_tm_predictor_8x8_c)
242
243 #if HAVE_SSE && CONFIG_USE_X86INC
244 INTRA_PRED_TEST(SSE, TestIntraPred8, vpx_dc_predictor_8x8_sse,
245                 vpx_dc_left_predictor_8x8_sse, vpx_dc_top_predictor_8x8_sse,
246                 vpx_dc_128_predictor_8x8_sse, vpx_v_predictor_8x8_sse, NULL,
247                 NULL, NULL, NULL, NULL, NULL, NULL, NULL)
248 #endif  // HAVE_SSE && CONFIG_USE_X86INC
249
250 #if HAVE_SSE2 && CONFIG_USE_X86INC
251 INTRA_PRED_TEST(SSE2, TestIntraPred8, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
252                 NULL, NULL, NULL, NULL, NULL, vpx_tm_predictor_8x8_sse2)
253 #endif  // HAVE_SSE2 && CONFIG_USE_X86INC
254
255 #if HAVE_SSSE3 && CONFIG_USE_X86INC
256 INTRA_PRED_TEST(SSSE3, TestIntraPred8, NULL, NULL, NULL, NULL, NULL,
257                 vpx_h_predictor_8x8_ssse3, vpx_d45_predictor_8x8_ssse3, NULL,
258                 NULL, vpx_d153_predictor_8x8_ssse3,
259                 vpx_d207_predictor_8x8_ssse3, vpx_d63_predictor_8x8_ssse3, NULL)
260 #endif  // HAVE_SSSE3 && CONFIG_USE_X86INC
261
262 #if HAVE_DSPR2
263 INTRA_PRED_TEST(DSPR2, TestIntraPred8, vpx_dc_predictor_8x8_dspr2, NULL, NULL,
264                 NULL, NULL, vpx_h_predictor_8x8_dspr2, NULL, NULL, NULL, NULL,
265                 NULL, NULL, vpx_tm_predictor_8x8_c)
266 #endif  // HAVE_DSPR2
267
268 #if HAVE_NEON
269 INTRA_PRED_TEST(NEON, TestIntraPred8, vpx_dc_predictor_8x8_neon,
270                 vpx_dc_left_predictor_8x8_neon, vpx_dc_top_predictor_8x8_neon,
271                 vpx_dc_128_predictor_8x8_neon, vpx_v_predictor_8x8_neon,
272                 vpx_h_predictor_8x8_neon, vpx_d45_predictor_8x8_neon, NULL,
273                 NULL, NULL, NULL, NULL, vpx_tm_predictor_8x8_neon)
274
275 #endif  // HAVE_NEON
276
277 #if HAVE_MSA
278 INTRA_PRED_TEST(MSA, TestIntraPred8, vpx_dc_predictor_8x8_msa,
279                 vpx_dc_left_predictor_8x8_msa, vpx_dc_top_predictor_8x8_msa,
280                 vpx_dc_128_predictor_8x8_msa, vpx_v_predictor_8x8_msa,
281                 vpx_h_predictor_8x8_msa, NULL, NULL, NULL, NULL, NULL,
282                 NULL, vpx_tm_predictor_8x8_msa)
283 #endif  // HAVE_MSA
284
285 // -----------------------------------------------------------------------------
286 // 16x16
287
288 INTRA_PRED_TEST(C, TestIntraPred16, vpx_dc_predictor_16x16_c,
289                 vpx_dc_left_predictor_16x16_c, vpx_dc_top_predictor_16x16_c,
290                 vpx_dc_128_predictor_16x16_c, vpx_v_predictor_16x16_c,
291                 vpx_h_predictor_16x16_c, vpx_d45_predictor_16x16_c,
292                 vpx_d135_predictor_16x16_c, vpx_d117_predictor_16x16_c,
293                 vpx_d153_predictor_16x16_c, vpx_d207_predictor_16x16_c,
294                 vpx_d63_predictor_16x16_c, vpx_tm_predictor_16x16_c)
295
296 #if HAVE_SSE2 && CONFIG_USE_X86INC
297 INTRA_PRED_TEST(SSE2, TestIntraPred16, vpx_dc_predictor_16x16_sse2,
298                 vpx_dc_left_predictor_16x16_sse2,
299                 vpx_dc_top_predictor_16x16_sse2,
300                 vpx_dc_128_predictor_16x16_sse2, vpx_v_predictor_16x16_sse2,
301                 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
302                 vpx_tm_predictor_16x16_sse2)
303 #endif  // HAVE_SSE2 && CONFIG_USE_X86INC
304
305 #if HAVE_SSSE3 && CONFIG_USE_X86INC
306 INTRA_PRED_TEST(SSSE3, TestIntraPred16, NULL, NULL, NULL, NULL, NULL,
307                 vpx_h_predictor_16x16_ssse3, vpx_d45_predictor_16x16_ssse3,
308                 NULL, NULL, vpx_d153_predictor_16x16_ssse3,
309                 vpx_d207_predictor_16x16_ssse3, vpx_d63_predictor_16x16_ssse3,
310                 NULL)
311 #endif  // HAVE_SSSE3 && CONFIG_USE_X86INC
312
313 #if HAVE_DSPR2
314 INTRA_PRED_TEST(DSPR2, TestIntraPred16, vpx_dc_predictor_16x16_dspr2, NULL,
315                 NULL, NULL, NULL, vpx_h_predictor_16x16_dspr2, NULL, NULL, NULL,
316                 NULL, NULL, NULL, NULL)
317 #endif  // HAVE_DSPR2
318
319 #if HAVE_NEON
320 INTRA_PRED_TEST(NEON, TestIntraPred16, vpx_dc_predictor_16x16_neon,
321                 vpx_dc_left_predictor_16x16_neon,
322                 vpx_dc_top_predictor_16x16_neon,
323                 vpx_dc_128_predictor_16x16_neon, vpx_v_predictor_16x16_neon,
324                 vpx_h_predictor_16x16_neon, vpx_d45_predictor_16x16_neon, NULL,
325                 NULL, NULL, NULL, NULL, vpx_tm_predictor_16x16_neon)
326 #endif  // HAVE_NEON
327
328 #if HAVE_MSA
329 INTRA_PRED_TEST(MSA, TestIntraPred16, vpx_dc_predictor_16x16_msa,
330                 vpx_dc_left_predictor_16x16_msa, vpx_dc_top_predictor_16x16_msa,
331                 vpx_dc_128_predictor_16x16_msa, vpx_v_predictor_16x16_msa,
332                 vpx_h_predictor_16x16_msa, NULL, NULL, NULL, NULL, NULL,
333                 NULL, vpx_tm_predictor_16x16_msa)
334 #endif  // HAVE_MSA
335
336 // -----------------------------------------------------------------------------
337 // 32x32
338
339 INTRA_PRED_TEST(C, TestIntraPred32, vpx_dc_predictor_32x32_c,
340                 vpx_dc_left_predictor_32x32_c, vpx_dc_top_predictor_32x32_c,
341                 vpx_dc_128_predictor_32x32_c, vpx_v_predictor_32x32_c,
342                 vpx_h_predictor_32x32_c, vpx_d45_predictor_32x32_c,
343                 vpx_d135_predictor_32x32_c, vpx_d117_predictor_32x32_c,
344                 vpx_d153_predictor_32x32_c, vpx_d207_predictor_32x32_c,
345                 vpx_d63_predictor_32x32_c, vpx_tm_predictor_32x32_c)
346
347 #if HAVE_SSE2 && CONFIG_USE_X86INC
348 #if ARCH_X86_64
349 INTRA_PRED_TEST(SSE2, TestIntraPred32, vpx_dc_predictor_32x32_sse2,
350                 vpx_dc_left_predictor_32x32_sse2,
351                 vpx_dc_top_predictor_32x32_sse2,
352                 vpx_dc_128_predictor_32x32_sse2, vpx_v_predictor_32x32_sse2,
353                 NULL, NULL, NULL, NULL, NULL, NULL, NULL,
354                 vpx_tm_predictor_32x32_sse2)
355 #else
356 INTRA_PRED_TEST(SSE2, TestIntraPred32, vpx_dc_predictor_32x32_sse2,
357                 vpx_dc_left_predictor_32x32_sse2,
358                 vpx_dc_top_predictor_32x32_sse2,
359                 vpx_dc_128_predictor_32x32_sse2, vpx_v_predictor_32x32_sse2,
360                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
361 #endif  // ARCH_X86_64
362 #endif  // HAVE_SSE2 && CONFIG_USE_X86INC
363
364 #if HAVE_SSSE3 && CONFIG_USE_X86INC
365 INTRA_PRED_TEST(SSSE3, TestIntraPred32, NULL, NULL, NULL, NULL, NULL,
366                 vpx_h_predictor_32x32_ssse3, vpx_d45_predictor_32x32_ssse3,
367                 NULL, NULL, vpx_d153_predictor_32x32_ssse3,
368                 vpx_d207_predictor_32x32_ssse3, vpx_d63_predictor_32x32_ssse3,
369                 NULL)
370 #endif  // HAVE_SSSE3 && CONFIG_USE_X86INC
371
372 #if HAVE_NEON
373 INTRA_PRED_TEST(NEON, TestIntraPred32, vpx_dc_predictor_32x32_neon,
374                 vpx_dc_left_predictor_32x32_neon,
375                 vpx_dc_top_predictor_32x32_neon,
376                 vpx_dc_128_predictor_32x32_neon, vpx_v_predictor_32x32_neon,
377                 vpx_h_predictor_32x32_neon, NULL, NULL, NULL, NULL, NULL, NULL,
378                 vpx_tm_predictor_32x32_neon)
379 #endif  // HAVE_NEON
380
381 #if HAVE_MSA
382 INTRA_PRED_TEST(MSA, TestIntraPred32, vpx_dc_predictor_32x32_msa,
383                 vpx_dc_left_predictor_32x32_msa, vpx_dc_top_predictor_32x32_msa,
384                 vpx_dc_128_predictor_32x32_msa, vpx_v_predictor_32x32_msa,
385                 vpx_h_predictor_32x32_msa, NULL, NULL, NULL, NULL, NULL,
386                 NULL, vpx_tm_predictor_32x32_msa)
387 #endif  // HAVE_MSA
388
389 #include "test/test_libvpx.cc"