1 /*
2 * Copyright (c) 2017 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 <math.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <tuple>
15
16 #include "gtest/gtest.h"
17
18 #include "./vp9_rtcd.h"
19 #include "./vpx_dsp_rtcd.h"
20 #include "test/acm_random.h"
21 #include "test/buffer.h"
22 #include "test/clear_system_state.h"
23 #include "test/register_state_check.h"
24 #include "test/util.h"
25 #include "vp9/common/vp9_entropy.h"
26 #include "vpx_config.h"
27 #include "vpx/vpx_codec.h"
28 #include "vpx/vpx_integer.h"
29 #include "vpx_ports/mem.h"
30
31 using libvpx_test::ACMRandom;
32 using libvpx_test::Buffer;
33 using std::make_tuple;
34 using std::tuple;
35
36 namespace {
37 typedef void (*FdctFunc)(const int16_t *in, tran_low_t *out, int stride);
38 typedef void (*IdctFunc)(const tran_low_t *in, uint8_t *out, int stride);
39 typedef void (*FhtFunc)(const int16_t *in, tran_low_t *out, int stride,
40 int tx_type);
41 typedef void (*FhtFuncRef)(const Buffer<int16_t> &in, Buffer<tran_low_t> *out,
42 int size, int tx_type);
43 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
44 int tx_type);
45 typedef void (*IhtWithBdFunc)(const tran_low_t *in, uint8_t *out, int stride,
46 int tx_type, int bd);
47
48 template <FdctFunc fn>
fdct_wrapper(const int16_t * in,tran_low_t * out,int stride,int tx_type)49 void fdct_wrapper(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
50 (void)tx_type;
51 fn(in, out, stride);
52 }
53
54 template <IdctFunc fn>
idct_wrapper(const tran_low_t * in,uint8_t * out,int stride,int tx_type,int bd)55 void idct_wrapper(const tran_low_t *in, uint8_t *out, int stride, int tx_type,
56 int bd) {
57 (void)tx_type;
58 (void)bd;
59 fn(in, out, stride);
60 }
61
62 template <IhtFunc fn>
iht_wrapper(const tran_low_t * in,uint8_t * out,int stride,int tx_type,int bd)63 void iht_wrapper(const tran_low_t *in, uint8_t *out, int stride, int tx_type,
64 int bd) {
65 (void)bd;
66 fn(in, out, stride, tx_type);
67 }
68
69 #if CONFIG_VP9_HIGHBITDEPTH
70 typedef void (*HighbdIdctFunc)(const tran_low_t *in, uint16_t *out, int stride,
71 int bd);
72
73 typedef void (*HighbdIhtFunc)(const tran_low_t *in, uint16_t *out, int stride,
74 int tx_type, int bd);
75
76 template <HighbdIdctFunc fn>
highbd_idct_wrapper(const tran_low_t * in,uint8_t * out,int stride,int tx_type,int bd)77 void highbd_idct_wrapper(const tran_low_t *in, uint8_t *out, int stride,
78 int tx_type, int bd) {
79 (void)tx_type;
80 fn(in, CAST_TO_SHORTPTR(out), stride, bd);
81 }
82
83 template <HighbdIhtFunc fn>
highbd_iht_wrapper(const tran_low_t * in,uint8_t * out,int stride,int tx_type,int bd)84 void highbd_iht_wrapper(const tran_low_t *in, uint8_t *out, int stride,
85 int tx_type, int bd) {
86 fn(in, CAST_TO_SHORTPTR(out), stride, tx_type, bd);
87 }
88 #endif // CONFIG_VP9_HIGHBITDEPTH
89
90 struct FuncInfo {
91 FhtFunc ft_func;
92 IhtWithBdFunc it_func;
93 int size;
94 int pixel_size;
95 };
96
97 /* forward transform, inverse transform, size, transform type, bit depth */
98 typedef tuple<int, const FuncInfo *, int, vpx_bit_depth_t> DctParam;
99
fdct_ref(const Buffer<int16_t> & in,Buffer<tran_low_t> * out,int size,int)100 void fdct_ref(const Buffer<int16_t> &in, Buffer<tran_low_t> *out, int size,
101 int /*tx_type*/) {
102 const int16_t *i = in.TopLeftPixel();
103 const int i_stride = in.stride();
104 tran_low_t *o = out->TopLeftPixel();
105 if (size == 4) {
106 vpx_fdct4x4_c(i, o, i_stride);
107 } else if (size == 8) {
108 vpx_fdct8x8_c(i, o, i_stride);
109 } else if (size == 16) {
110 vpx_fdct16x16_c(i, o, i_stride);
111 } else if (size == 32) {
112 vpx_fdct32x32_c(i, o, i_stride);
113 }
114 }
115
fht_ref(const Buffer<int16_t> & in,Buffer<tran_low_t> * out,int size,int tx_type)116 void fht_ref(const Buffer<int16_t> &in, Buffer<tran_low_t> *out, int size,
117 int tx_type) {
118 const int16_t *i = in.TopLeftPixel();
119 const int i_stride = in.stride();
120 tran_low_t *o = out->TopLeftPixel();
121 if (size == 4) {
122 vp9_fht4x4_c(i, o, i_stride, tx_type);
123 } else if (size == 8) {
124 vp9_fht8x8_c(i, o, i_stride, tx_type);
125 } else if (size == 16) {
126 vp9_fht16x16_c(i, o, i_stride, tx_type);
127 }
128 }
129
fwht_ref(const Buffer<int16_t> & in,Buffer<tran_low_t> * out,int size,int)130 void fwht_ref(const Buffer<int16_t> &in, Buffer<tran_low_t> *out, int size,
131 int /*tx_type*/) {
132 ASSERT_EQ(size, 4);
133 vp9_fwht4x4_c(in.TopLeftPixel(), out->TopLeftPixel(), in.stride());
134 }
135
136 class TransTestBase : public ::testing::TestWithParam<DctParam> {
137 public:
SetUp()138 void SetUp() override {
139 rnd_.Reset(ACMRandom::DeterministicSeed());
140 const int idx = GET_PARAM(0);
141 const FuncInfo *func_info = &(GET_PARAM(1)[idx]);
142 tx_type_ = GET_PARAM(2);
143 bit_depth_ = GET_PARAM(3);
144 fwd_txfm_ = func_info->ft_func;
145 inv_txfm_ = func_info->it_func;
146 size_ = func_info->size;
147 pixel_size_ = func_info->pixel_size;
148 max_pixel_value_ = (1 << bit_depth_) - 1;
149
150 // Randomize stride_ to a value less than or equal to 1024
151 stride_ = rnd_(1024) + 1;
152 if (stride_ < size_) {
153 stride_ = size_;
154 }
155 // Align stride_ to 16 if it's bigger than 16.
156 if (stride_ > 16) {
157 stride_ &= ~15;
158 }
159
160 block_size_ = size_ * stride_;
161
162 src_ = reinterpret_cast<uint8_t *>(
163 vpx_memalign(16, pixel_size_ * block_size_));
164 ASSERT_NE(src_, nullptr);
165 dst_ = reinterpret_cast<uint8_t *>(
166 vpx_memalign(16, pixel_size_ * block_size_));
167 ASSERT_NE(dst_, nullptr);
168 }
169
TearDown()170 void TearDown() override {
171 vpx_free(src_);
172 src_ = nullptr;
173 vpx_free(dst_);
174 dst_ = nullptr;
175 libvpx_test::ClearSystemState();
176 }
177
InitMem()178 void InitMem() {
179 if (pixel_size_ == 1 && bit_depth_ > VPX_BITS_8) return;
180 if (pixel_size_ == 1) {
181 for (int j = 0; j < block_size_; ++j) {
182 src_[j] = rnd_.Rand16() & max_pixel_value_;
183 }
184 for (int j = 0; j < block_size_; ++j) {
185 dst_[j] = rnd_.Rand16() & max_pixel_value_;
186 }
187 } else {
188 ASSERT_EQ(pixel_size_, 2);
189 uint16_t *const src = reinterpret_cast<uint16_t *>(src_);
190 uint16_t *const dst = reinterpret_cast<uint16_t *>(dst_);
191 for (int j = 0; j < block_size_; ++j) {
192 src[j] = rnd_.Rand16() & max_pixel_value_;
193 }
194 for (int j = 0; j < block_size_; ++j) {
195 dst[j] = rnd_.Rand16() & max_pixel_value_;
196 }
197 }
198 }
199
RunFwdTxfm(const Buffer<int16_t> & in,Buffer<tran_low_t> * out)200 void RunFwdTxfm(const Buffer<int16_t> &in, Buffer<tran_low_t> *out) {
201 fwd_txfm_(in.TopLeftPixel(), out->TopLeftPixel(), in.stride(), tx_type_);
202 }
203
RunInvTxfm(const Buffer<tran_low_t> & in,uint8_t * out)204 void RunInvTxfm(const Buffer<tran_low_t> &in, uint8_t *out) {
205 inv_txfm_(in.TopLeftPixel(), out, stride_, tx_type_, bit_depth_);
206 }
207
208 protected:
RunAccuracyCheck(int limit)209 void RunAccuracyCheck(int limit) {
210 if (pixel_size_ == 1 && bit_depth_ > VPX_BITS_8) return;
211 ACMRandom rnd(ACMRandom::DeterministicSeed());
212 Buffer<int16_t> test_input_block =
213 Buffer<int16_t>(size_, size_, 8, size_ == 4 ? 0 : 16);
214 ASSERT_TRUE(test_input_block.Init());
215 ASSERT_NE(test_input_block.TopLeftPixel(), nullptr);
216 Buffer<tran_low_t> test_temp_block =
217 Buffer<tran_low_t>(size_, size_, 0, 16);
218 ASSERT_TRUE(test_temp_block.Init());
219 uint32_t max_error = 0;
220 int64_t total_error = 0;
221 const int count_test_block = 10000;
222 for (int i = 0; i < count_test_block; ++i) {
223 InitMem();
224 for (int h = 0; h < size_; ++h) {
225 for (int w = 0; w < size_; ++w) {
226 if (pixel_size_ == 1) {
227 test_input_block.TopLeftPixel()[h * test_input_block.stride() + w] =
228 src_[h * stride_ + w] - dst_[h * stride_ + w];
229 } else {
230 ASSERT_EQ(pixel_size_, 2);
231 const uint16_t *const src = reinterpret_cast<uint16_t *>(src_);
232 const uint16_t *const dst = reinterpret_cast<uint16_t *>(dst_);
233 test_input_block.TopLeftPixel()[h * test_input_block.stride() + w] =
234 src[h * stride_ + w] - dst[h * stride_ + w];
235 }
236 }
237 }
238
239 ASM_REGISTER_STATE_CHECK(RunFwdTxfm(test_input_block, &test_temp_block));
240 ASM_REGISTER_STATE_CHECK(RunInvTxfm(test_temp_block, dst_));
241
242 for (int h = 0; h < size_; ++h) {
243 for (int w = 0; w < size_; ++w) {
244 int diff;
245 if (pixel_size_ == 1) {
246 diff = dst_[h * stride_ + w] - src_[h * stride_ + w];
247 } else {
248 ASSERT_EQ(pixel_size_, 2);
249 const uint16_t *const src = reinterpret_cast<uint16_t *>(src_);
250 const uint16_t *const dst = reinterpret_cast<uint16_t *>(dst_);
251 diff = dst[h * stride_ + w] - src[h * stride_ + w];
252 }
253 const uint32_t error = diff * diff;
254 if (max_error < error) max_error = error;
255 total_error += error;
256 }
257 }
258 }
259
260 EXPECT_GE(static_cast<uint32_t>(limit), max_error)
261 << "Error: " << size_ << "x" << size_
262 << " transform/inverse transform has an individual round trip error > "
263 << limit;
264
265 EXPECT_GE(count_test_block * limit, total_error)
266 << "Error: " << size_ << "x" << size_
267 << " transform/inverse transform has average round trip error > "
268 << limit << " per block";
269 }
270
RunCoeffCheck()271 void RunCoeffCheck() {
272 if (pixel_size_ == 1 && bit_depth_ > VPX_BITS_8) return;
273 ACMRandom rnd(ACMRandom::DeterministicSeed());
274 const int count_test_block = 5000;
275 Buffer<int16_t> input_block =
276 Buffer<int16_t>(size_, size_, 8, size_ == 4 ? 0 : 16);
277 ASSERT_TRUE(input_block.Init());
278 Buffer<tran_low_t> output_ref_block = Buffer<tran_low_t>(size_, size_, 0);
279 ASSERT_TRUE(output_ref_block.Init());
280 Buffer<tran_low_t> output_block = Buffer<tran_low_t>(size_, size_, 0, 16);
281 ASSERT_TRUE(output_block.Init());
282
283 for (int i = 0; i < count_test_block; ++i) {
284 // Initialize a test block with input range [-max_pixel_value_,
285 // max_pixel_value_].
286 input_block.Set(&rnd, -max_pixel_value_, max_pixel_value_);
287
288 fwd_txfm_ref(input_block, &output_ref_block, size_, tx_type_);
289 ASM_REGISTER_STATE_CHECK(RunFwdTxfm(input_block, &output_block));
290
291 // The minimum quant value is 4.
292 EXPECT_TRUE(output_block.CheckValues(output_ref_block));
293 if (::testing::Test::HasFailure()) {
294 printf("Size: %d Transform type: %d\n", size_, tx_type_);
295 output_block.PrintDifference(output_ref_block);
296 return;
297 }
298 }
299 }
300
RunMemCheck()301 void RunMemCheck() {
302 if (pixel_size_ == 1 && bit_depth_ > VPX_BITS_8) return;
303 ACMRandom rnd(ACMRandom::DeterministicSeed());
304 const int count_test_block = 5000;
305 Buffer<int16_t> input_extreme_block =
306 Buffer<int16_t>(size_, size_, 8, size_ == 4 ? 0 : 16);
307 ASSERT_TRUE(input_extreme_block.Init());
308 Buffer<tran_low_t> output_ref_block = Buffer<tran_low_t>(size_, size_, 0);
309 ASSERT_TRUE(output_ref_block.Init());
310 Buffer<tran_low_t> output_block = Buffer<tran_low_t>(size_, size_, 0, 16);
311 ASSERT_TRUE(output_block.Init());
312
313 for (int i = 0; i < count_test_block; ++i) {
314 // Initialize a test block with -max_pixel_value_ or max_pixel_value_.
315 if (i == 0) {
316 input_extreme_block.Set(max_pixel_value_);
317 } else if (i == 1) {
318 input_extreme_block.Set(-max_pixel_value_);
319 } else {
320 ASSERT_NE(input_extreme_block.TopLeftPixel(), nullptr);
321 for (int h = 0; h < size_; ++h) {
322 for (int w = 0; w < size_; ++w) {
323 input_extreme_block
324 .TopLeftPixel()[h * input_extreme_block.stride() + w] =
325 rnd.Rand8() % 2 ? max_pixel_value_ : -max_pixel_value_;
326 }
327 }
328 }
329
330 fwd_txfm_ref(input_extreme_block, &output_ref_block, size_, tx_type_);
331 ASM_REGISTER_STATE_CHECK(RunFwdTxfm(input_extreme_block, &output_block));
332
333 // The minimum quant value is 4.
334 EXPECT_TRUE(output_block.CheckValues(output_ref_block));
335 ASSERT_NE(output_block.TopLeftPixel(), nullptr);
336 for (int h = 0; h < size_; ++h) {
337 for (int w = 0; w < size_; ++w) {
338 EXPECT_GE(
339 4 * DCT_MAX_VALUE << (bit_depth_ - 8),
340 abs(output_block.TopLeftPixel()[h * output_block.stride() + w]))
341 << "Error: " << size_ << "x" << size_
342 << " transform has coefficient larger than 4*DCT_MAX_VALUE"
343 << " at " << w << "," << h;
344 if (::testing::Test::HasFailure()) {
345 printf("Size: %d Transform type: %d\n", size_, tx_type_);
346 output_block.DumpBuffer();
347 return;
348 }
349 }
350 }
351 }
352 }
353
RunInvAccuracyCheck(int limit)354 void RunInvAccuracyCheck(int limit) {
355 if (pixel_size_ == 1 && bit_depth_ > VPX_BITS_8) return;
356 ACMRandom rnd(ACMRandom::DeterministicSeed());
357 const int count_test_block = 1000;
358 Buffer<int16_t> in = Buffer<int16_t>(size_, size_, 4);
359 ASSERT_TRUE(in.Init());
360 Buffer<tran_low_t> coeff = Buffer<tran_low_t>(size_, size_, 0, 16);
361 ASSERT_TRUE(coeff.Init());
362
363 for (int i = 0; i < count_test_block; ++i) {
364 InitMem();
365 ASSERT_NE(in.TopLeftPixel(), nullptr);
366 // Initialize a test block with input range [-max_pixel_value_,
367 // max_pixel_value_].
368 for (int h = 0; h < size_; ++h) {
369 for (int w = 0; w < size_; ++w) {
370 if (pixel_size_ == 1) {
371 in.TopLeftPixel()[h * in.stride() + w] =
372 src_[h * stride_ + w] - dst_[h * stride_ + w];
373 } else {
374 ASSERT_EQ(pixel_size_, 2);
375 const uint16_t *const src = reinterpret_cast<uint16_t *>(src_);
376 const uint16_t *const dst = reinterpret_cast<uint16_t *>(dst_);
377 in.TopLeftPixel()[h * in.stride() + w] =
378 src[h * stride_ + w] - dst[h * stride_ + w];
379 }
380 }
381 }
382
383 fwd_txfm_ref(in, &coeff, size_, tx_type_);
384
385 ASM_REGISTER_STATE_CHECK(RunInvTxfm(coeff, dst_));
386
387 for (int h = 0; h < size_; ++h) {
388 for (int w = 0; w < size_; ++w) {
389 int diff;
390 if (pixel_size_ == 1) {
391 diff = dst_[h * stride_ + w] - src_[h * stride_ + w];
392 } else {
393 ASSERT_EQ(pixel_size_, 2);
394 const uint16_t *const src = reinterpret_cast<uint16_t *>(src_);
395 const uint16_t *const dst = reinterpret_cast<uint16_t *>(dst_);
396 diff = dst[h * stride_ + w] - src[h * stride_ + w];
397 }
398 const uint32_t error = diff * diff;
399 EXPECT_GE(static_cast<uint32_t>(limit), error)
400 << "Error: " << size_ << "x" << size_
401 << " inverse transform has error " << error << " at " << w << ","
402 << h;
403 if (::testing::Test::HasFailure()) {
404 printf("Size: %d Transform type: %d\n", size_, tx_type_);
405 return;
406 }
407 }
408 }
409 }
410 }
411
412 FhtFunc fwd_txfm_;
413 FhtFuncRef fwd_txfm_ref;
414 IhtWithBdFunc inv_txfm_;
415 ACMRandom rnd_;
416 uint8_t *src_;
417 uint8_t *dst_;
418 vpx_bit_depth_t bit_depth_;
419 int tx_type_;
420 int max_pixel_value_;
421 int size_;
422 int stride_;
423 int pixel_size_;
424 int block_size_;
425 };
426
427 /* -------------------------------------------------------------------------- */
428
429 class TransDCT : public TransTestBase {
430 public:
TransDCT()431 TransDCT() { fwd_txfm_ref = fdct_ref; }
432 };
433
TEST_P(TransDCT,AccuracyCheck)434 TEST_P(TransDCT, AccuracyCheck) {
435 int t = 1;
436 if (size_ == 16 && bit_depth_ > 10 && pixel_size_ == 2) {
437 t = 2;
438 } else if (size_ == 32 && bit_depth_ > 10 && pixel_size_ == 2) {
439 t = 7;
440 }
441 RunAccuracyCheck(t);
442 }
443
TEST_P(TransDCT,CoeffCheck)444 TEST_P(TransDCT, CoeffCheck) { RunCoeffCheck(); }
445
TEST_P(TransDCT,MemCheck)446 TEST_P(TransDCT, MemCheck) { RunMemCheck(); }
447
TEST_P(TransDCT,InvAccuracyCheck)448 TEST_P(TransDCT, InvAccuracyCheck) { RunInvAccuracyCheck(1); }
449
450 static const FuncInfo dct_c_func_info[] = {
451 #if CONFIG_VP9_HIGHBITDEPTH
452 { &fdct_wrapper<vpx_highbd_fdct4x4_c>,
453 &highbd_idct_wrapper<vpx_highbd_idct4x4_16_add_c>, 4, 2 },
454 { &fdct_wrapper<vpx_highbd_fdct8x8_c>,
455 &highbd_idct_wrapper<vpx_highbd_idct8x8_64_add_c>, 8, 2 },
456 { &fdct_wrapper<vpx_highbd_fdct16x16_c>,
457 &highbd_idct_wrapper<vpx_highbd_idct16x16_256_add_c>, 16, 2 },
458 { &fdct_wrapper<vpx_highbd_fdct32x32_c>,
459 &highbd_idct_wrapper<vpx_highbd_idct32x32_1024_add_c>, 32, 2 },
460 #endif
461 { &fdct_wrapper<vpx_fdct4x4_c>, &idct_wrapper<vpx_idct4x4_16_add_c>, 4, 1 },
462 { &fdct_wrapper<vpx_fdct8x8_c>, &idct_wrapper<vpx_idct8x8_64_add_c>, 8, 1 },
463 { &fdct_wrapper<vpx_fdct16x16_c>, &idct_wrapper<vpx_idct16x16_256_add_c>, 16,
464 1 },
465 { &fdct_wrapper<vpx_fdct32x32_c>, &idct_wrapper<vpx_idct32x32_1024_add_c>, 32,
466 1 }
467 };
468
469 INSTANTIATE_TEST_SUITE_P(
470 C, TransDCT,
471 ::testing::Combine(
472 ::testing::Range(0, static_cast<int>(sizeof(dct_c_func_info) /
473 sizeof(dct_c_func_info[0]))),
474 ::testing::Values(dct_c_func_info), ::testing::Values(0),
475 ::testing::Values(VPX_BITS_8, VPX_BITS_10, VPX_BITS_12)));
476
477 #if !CONFIG_EMULATE_HARDWARE
478
479 #if HAVE_SSE2
480 static const FuncInfo dct_sse2_func_info[] = {
481 #if CONFIG_VP9_HIGHBITDEPTH
482 { &fdct_wrapper<vpx_highbd_fdct4x4_sse2>,
483 &highbd_idct_wrapper<vpx_highbd_idct4x4_16_add_sse2>, 4, 2 },
484 { &fdct_wrapper<vpx_highbd_fdct8x8_sse2>,
485 &highbd_idct_wrapper<vpx_highbd_idct8x8_64_add_sse2>, 8, 2 },
486 { &fdct_wrapper<vpx_highbd_fdct16x16_sse2>,
487 &highbd_idct_wrapper<vpx_highbd_idct16x16_256_add_sse2>, 16, 2 },
488 { &fdct_wrapper<vpx_highbd_fdct32x32_sse2>,
489 &highbd_idct_wrapper<vpx_highbd_idct32x32_1024_add_sse2>, 32, 2 },
490 #endif
491 { &fdct_wrapper<vpx_fdct4x4_sse2>, &idct_wrapper<vpx_idct4x4_16_add_sse2>, 4,
492 1 },
493 { &fdct_wrapper<vpx_fdct8x8_sse2>, &idct_wrapper<vpx_idct8x8_64_add_sse2>, 8,
494 1 },
495 { &fdct_wrapper<vpx_fdct16x16_sse2>,
496 &idct_wrapper<vpx_idct16x16_256_add_sse2>, 16, 1 },
497 { &fdct_wrapper<vpx_fdct32x32_sse2>,
498 &idct_wrapper<vpx_idct32x32_1024_add_sse2>, 32, 1 }
499 };
500
501 INSTANTIATE_TEST_SUITE_P(
502 SSE2, TransDCT,
503 ::testing::Combine(
504 ::testing::Range(0, static_cast<int>(sizeof(dct_sse2_func_info) /
505 sizeof(dct_sse2_func_info[0]))),
506 ::testing::Values(dct_sse2_func_info), ::testing::Values(0),
507 ::testing::Values(VPX_BITS_8, VPX_BITS_10, VPX_BITS_12)));
508 #endif // HAVE_SSE2
509
510 #if HAVE_SSSE3 && !CONFIG_VP9_HIGHBITDEPTH && VPX_ARCH_X86_64
511 // vpx_fdct8x8_ssse3 is only available in 64 bit builds.
512 static const FuncInfo dct_ssse3_func_info = {
513 &fdct_wrapper<vpx_fdct8x8_ssse3>, &idct_wrapper<vpx_idct8x8_64_add_sse2>, 8, 1
514 };
515
516 // TODO(johannkoenig): high bit depth fdct8x8.
517 INSTANTIATE_TEST_SUITE_P(SSSE3, TransDCT,
518 ::testing::Values(make_tuple(0, &dct_ssse3_func_info,
519 0, VPX_BITS_8)));
520 #endif // HAVE_SSSE3 && !CONFIG_VP9_HIGHBITDEPTH && VPX_ARCH_X86_64
521
522 #if HAVE_AVX2 && !CONFIG_VP9_HIGHBITDEPTH
523 static const FuncInfo dct_avx2_func_info = {
524 &fdct_wrapper<vpx_fdct32x32_avx2>, &idct_wrapper<vpx_idct32x32_1024_add_sse2>,
525 32, 1
526 };
527
528 // TODO(johannkoenig): high bit depth fdct32x32.
529 INSTANTIATE_TEST_SUITE_P(AVX2, TransDCT,
530 ::testing::Values(make_tuple(0, &dct_avx2_func_info, 0,
531 VPX_BITS_8)));
532 #endif // HAVE_AVX2 && !CONFIG_VP9_HIGHBITDEPTH
533
534 #if HAVE_NEON
535 #if CONFIG_VP9_HIGHBITDEPTH
536 static const FuncInfo dct_neon_func_info[] = {
537 { &fdct_wrapper<vpx_highbd_fdct4x4_neon>,
538 &highbd_idct_wrapper<vpx_highbd_idct4x4_16_add_neon>, 4, 2 },
539 { &fdct_wrapper<vpx_highbd_fdct8x8_neon>,
540 &highbd_idct_wrapper<vpx_highbd_idct8x8_64_add_neon>, 8, 2 },
541 { &fdct_wrapper<vpx_highbd_fdct16x16_neon>,
542 &highbd_idct_wrapper<vpx_highbd_idct16x16_256_add_neon>, 16, 2 },
543 /* { &fdct_wrapper<vpx_highbd_fdct32x32_neon>,
544 &highbd_idct_wrapper<vpx_highbd_idct32x32_1024_add_neon>, 32, 2 },*/
545 };
546 #else
547 static const FuncInfo dct_neon_func_info[4] = {
548 { &fdct_wrapper<vpx_fdct4x4_neon>, &idct_wrapper<vpx_idct4x4_16_add_neon>, 4,
549 1 },
550 { &fdct_wrapper<vpx_fdct8x8_neon>, &idct_wrapper<vpx_idct8x8_64_add_neon>, 8,
551 1 },
552 { &fdct_wrapper<vpx_fdct16x16_neon>,
553 &idct_wrapper<vpx_idct16x16_256_add_neon>, 16, 1 },
554 { &fdct_wrapper<vpx_fdct32x32_neon>,
555 &idct_wrapper<vpx_idct32x32_1024_add_neon>, 32, 1 }
556 };
557 #endif // CONFIG_VP9_HIGHBITDEPTH
558
559 INSTANTIATE_TEST_SUITE_P(
560 NEON, TransDCT,
561 ::testing::Combine(
562 ::testing::Range(0, static_cast<int>(sizeof(dct_neon_func_info) /
563 sizeof(dct_neon_func_info[0]))),
564 ::testing::Values(dct_neon_func_info), ::testing::Values(0),
565 ::testing::Values(VPX_BITS_8, VPX_BITS_10, VPX_BITS_12)));
566 #endif // HAVE_NEON
567
568 #if HAVE_MSA && !CONFIG_VP9_HIGHBITDEPTH
569 static const FuncInfo dct_msa_func_info[4] = {
570 { &fdct_wrapper<vpx_fdct4x4_msa>, &idct_wrapper<vpx_idct4x4_16_add_msa>, 4,
571 1 },
572 { &fdct_wrapper<vpx_fdct8x8_msa>, &idct_wrapper<vpx_idct8x8_64_add_msa>, 8,
573 1 },
574 { &fdct_wrapper<vpx_fdct16x16_msa>, &idct_wrapper<vpx_idct16x16_256_add_msa>,
575 16, 1 },
576 { &fdct_wrapper<vpx_fdct32x32_msa>, &idct_wrapper<vpx_idct32x32_1024_add_msa>,
577 32, 1 }
578 };
579
580 INSTANTIATE_TEST_SUITE_P(
581 MSA, TransDCT,
582 ::testing::Combine(::testing::Range(0, 4),
583 ::testing::Values(dct_msa_func_info),
584 ::testing::Values(0), ::testing::Values(VPX_BITS_8)));
585 #endif // HAVE_MSA && !CONFIG_VP9_HIGHBITDEPTH
586
587 #if HAVE_VSX && !CONFIG_VP9_HIGHBITDEPTH
588 static const FuncInfo dct_vsx_func_info = {
589 &fdct_wrapper<vpx_fdct4x4_c>, &idct_wrapper<vpx_idct4x4_16_add_vsx>, 4, 1
590 };
591
592 INSTANTIATE_TEST_SUITE_P(VSX, TransDCT,
593 ::testing::Values(make_tuple(0, &dct_vsx_func_info, 0,
594 VPX_BITS_8)));
595 #endif // HAVE_VSX && !CONFIG_VP9_HIGHBITDEPTH &&
596
597 #if HAVE_LSX && !CONFIG_VP9_HIGHBITDEPTH
598 static const FuncInfo dct_lsx_func_info[4] = {
599 { &fdct_wrapper<vpx_fdct4x4_lsx>, &idct_wrapper<vpx_idct4x4_16_add_c>, 4, 1 },
600 { &fdct_wrapper<vpx_fdct8x8_lsx>, &idct_wrapper<vpx_idct8x8_64_add_c>, 8, 1 },
601 { &fdct_wrapper<vpx_fdct16x16_lsx>, &idct_wrapper<vpx_idct16x16_256_add_c>,
602 16, 1 },
603 { &fdct_wrapper<vpx_fdct32x32_lsx>, &idct_wrapper<vpx_idct32x32_1024_add_lsx>,
604 32, 1 }
605 };
606
607 INSTANTIATE_TEST_SUITE_P(
608 LSX, TransDCT,
609 ::testing::Combine(::testing::Range(0, 4),
610 ::testing::Values(dct_lsx_func_info),
611 ::testing::Values(0), ::testing::Values(VPX_BITS_8)));
612 #endif // HAVE_LSX && !CONFIG_VP9_HIGHBITDEPTH
613
614 #endif // !CONFIG_EMULATE_HARDWARE
615
616 /* -------------------------------------------------------------------------- */
617
618 class TransHT : public TransTestBase {
619 public:
TransHT()620 TransHT() { fwd_txfm_ref = fht_ref; }
621 };
622
TEST_P(TransHT,AccuracyCheck)623 TEST_P(TransHT, AccuracyCheck) {
624 RunAccuracyCheck(size_ == 16 && bit_depth_ > 10 && pixel_size_ == 2 ? 2 : 1);
625 }
626
TEST_P(TransHT,CoeffCheck)627 TEST_P(TransHT, CoeffCheck) { RunCoeffCheck(); }
628
TEST_P(TransHT,MemCheck)629 TEST_P(TransHT, MemCheck) { RunMemCheck(); }
630
TEST_P(TransHT,InvAccuracyCheck)631 TEST_P(TransHT, InvAccuracyCheck) { RunInvAccuracyCheck(1); }
632
633 static const FuncInfo ht_c_func_info[] = {
634 #if CONFIG_VP9_HIGHBITDEPTH
635 { &vp9_highbd_fht4x4_c, &highbd_iht_wrapper<vp9_highbd_iht4x4_16_add_c>, 4,
636 2 },
637 { &vp9_highbd_fht8x8_c, &highbd_iht_wrapper<vp9_highbd_iht8x8_64_add_c>, 8,
638 2 },
639 { &vp9_highbd_fht16x16_c, &highbd_iht_wrapper<vp9_highbd_iht16x16_256_add_c>,
640 16, 2 },
641 #endif
642 { &vp9_fht4x4_c, &iht_wrapper<vp9_iht4x4_16_add_c>, 4, 1 },
643 { &vp9_fht8x8_c, &iht_wrapper<vp9_iht8x8_64_add_c>, 8, 1 },
644 { &vp9_fht16x16_c, &iht_wrapper<vp9_iht16x16_256_add_c>, 16, 1 }
645 };
646
647 INSTANTIATE_TEST_SUITE_P(
648 C, TransHT,
649 ::testing::Combine(
650 ::testing::Range(0, static_cast<int>(sizeof(ht_c_func_info) /
651 sizeof(ht_c_func_info[0]))),
652 ::testing::Values(ht_c_func_info), ::testing::Range(0, 4),
653 ::testing::Values(VPX_BITS_8, VPX_BITS_10, VPX_BITS_12)));
654
655 #if !CONFIG_EMULATE_HARDWARE
656
657 #if HAVE_NEON
658
659 static const FuncInfo ht_neon_func_info[] = {
660 #if CONFIG_VP9_HIGHBITDEPTH
661 { &vp9_highbd_fht4x4_c, &highbd_iht_wrapper<vp9_highbd_iht4x4_16_add_neon>, 4,
662 2 },
663 { &vp9_highbd_fht4x4_neon, &highbd_iht_wrapper<vp9_highbd_iht4x4_16_add_neon>,
664 4, 2 },
665 { &vp9_highbd_fht8x8_c, &highbd_iht_wrapper<vp9_highbd_iht8x8_64_add_neon>, 8,
666 2 },
667 { &vp9_highbd_fht8x8_neon, &highbd_iht_wrapper<vp9_highbd_iht8x8_64_add_neon>,
668 8, 2 },
669 { &vp9_highbd_fht16x16_c,
670 &highbd_iht_wrapper<vp9_highbd_iht16x16_256_add_neon>, 16, 2 },
671 { &vp9_highbd_fht16x16_neon,
672 &highbd_iht_wrapper<vp9_highbd_iht16x16_256_add_neon>, 16, 2 },
673 #endif
674 { &vp9_fht4x4_c, &iht_wrapper<vp9_iht4x4_16_add_neon>, 4, 1 },
675 { &vp9_fht4x4_neon, &iht_wrapper<vp9_iht4x4_16_add_neon>, 4, 1 },
676 { &vp9_fht8x8_c, &iht_wrapper<vp9_iht8x8_64_add_neon>, 8, 1 },
677 { &vp9_fht8x8_neon, &iht_wrapper<vp9_iht8x8_64_add_neon>, 8, 1 },
678 { &vp9_fht16x16_c, &iht_wrapper<vp9_iht16x16_256_add_neon>, 16, 1 },
679 { &vp9_fht16x16_neon, &iht_wrapper<vp9_iht16x16_256_add_neon>, 16, 1 }
680 };
681
682 INSTANTIATE_TEST_SUITE_P(
683 NEON, TransHT,
684 ::testing::Combine(
685 ::testing::Range(0, static_cast<int>(sizeof(ht_neon_func_info) /
686 sizeof(ht_neon_func_info[0]))),
687 ::testing::Values(ht_neon_func_info), ::testing::Range(0, 4),
688 ::testing::Values(VPX_BITS_8, VPX_BITS_10, VPX_BITS_12)));
689 #endif // HAVE_NEON
690
691 #if HAVE_SSE2
692
693 static const FuncInfo ht_sse2_func_info[3] = {
694 { &vp9_fht4x4_sse2, &iht_wrapper<vp9_iht4x4_16_add_sse2>, 4, 1 },
695 { &vp9_fht8x8_sse2, &iht_wrapper<vp9_iht8x8_64_add_sse2>, 8, 1 },
696 { &vp9_fht16x16_sse2, &iht_wrapper<vp9_iht16x16_256_add_sse2>, 16, 1 }
697 };
698
699 INSTANTIATE_TEST_SUITE_P(
700 SSE2, TransHT,
701 ::testing::Combine(::testing::Range(0, 3),
702 ::testing::Values(ht_sse2_func_info),
703 ::testing::Range(0, 4), ::testing::Values(VPX_BITS_8)));
704 #endif // HAVE_SSE2
705
706 #if HAVE_SSE4_1 && CONFIG_VP9_HIGHBITDEPTH
707 static const FuncInfo ht_sse4_1_func_info[3] = {
708 { &vp9_highbd_fht4x4_c, &highbd_iht_wrapper<vp9_highbd_iht4x4_16_add_sse4_1>,
709 4, 2 },
710 { vp9_highbd_fht8x8_c, &highbd_iht_wrapper<vp9_highbd_iht8x8_64_add_sse4_1>,
711 8, 2 },
712 { &vp9_highbd_fht16x16_c,
713 &highbd_iht_wrapper<vp9_highbd_iht16x16_256_add_sse4_1>, 16, 2 }
714 };
715
716 INSTANTIATE_TEST_SUITE_P(
717 SSE4_1, TransHT,
718 ::testing::Combine(::testing::Range(0, 3),
719 ::testing::Values(ht_sse4_1_func_info),
720 ::testing::Range(0, 4),
721 ::testing::Values(VPX_BITS_8, VPX_BITS_10,
722 VPX_BITS_12)));
723 #endif // HAVE_SSE4_1 && CONFIG_VP9_HIGHBITDEPTH
724
725 #if HAVE_VSX && !CONFIG_EMULATE_HARDWARE && !CONFIG_VP9_HIGHBITDEPTH
726 static const FuncInfo ht_vsx_func_info[3] = {
727 { &vp9_fht4x4_c, &iht_wrapper<vp9_iht4x4_16_add_vsx>, 4, 1 },
728 { &vp9_fht8x8_c, &iht_wrapper<vp9_iht8x8_64_add_vsx>, 8, 1 },
729 { &vp9_fht16x16_c, &iht_wrapper<vp9_iht16x16_256_add_vsx>, 16, 1 }
730 };
731
732 INSTANTIATE_TEST_SUITE_P(VSX, TransHT,
733 ::testing::Combine(::testing::Range(0, 3),
734 ::testing::Values(ht_vsx_func_info),
735 ::testing::Range(0, 4),
736 ::testing::Values(VPX_BITS_8)));
737 #endif // HAVE_VSX
738 #endif // !CONFIG_EMULATE_HARDWARE
739
740 /* -------------------------------------------------------------------------- */
741
742 class TransWHT : public TransTestBase {
743 public:
TransWHT()744 TransWHT() { fwd_txfm_ref = fwht_ref; }
745 };
746
TEST_P(TransWHT,AccuracyCheck)747 TEST_P(TransWHT, AccuracyCheck) { RunAccuracyCheck(0); }
748
TEST_P(TransWHT,CoeffCheck)749 TEST_P(TransWHT, CoeffCheck) { RunCoeffCheck(); }
750
TEST_P(TransWHT,MemCheck)751 TEST_P(TransWHT, MemCheck) { RunMemCheck(); }
752
TEST_P(TransWHT,InvAccuracyCheck)753 TEST_P(TransWHT, InvAccuracyCheck) { RunInvAccuracyCheck(0); }
754
755 static const FuncInfo wht_c_func_info[] = {
756 #if CONFIG_VP9_HIGHBITDEPTH
757 { &fdct_wrapper<vp9_highbd_fwht4x4_c>,
758 &highbd_idct_wrapper<vpx_highbd_iwht4x4_16_add_c>, 4, 2 },
759 #endif
760 { &fdct_wrapper<vp9_fwht4x4_c>, &idct_wrapper<vpx_iwht4x4_16_add_c>, 4, 1 }
761 };
762
763 INSTANTIATE_TEST_SUITE_P(
764 C, TransWHT,
765 ::testing::Combine(
766 ::testing::Range(0, static_cast<int>(sizeof(wht_c_func_info) /
767 sizeof(wht_c_func_info[0]))),
768 ::testing::Values(wht_c_func_info), ::testing::Values(0),
769 ::testing::Values(VPX_BITS_8, VPX_BITS_10, VPX_BITS_12)));
770
771 #if HAVE_SSE2 && !CONFIG_EMULATE_HARDWARE
772 static const FuncInfo wht_sse2_func_info = {
773 &fdct_wrapper<vp9_fwht4x4_sse2>, &idct_wrapper<vpx_iwht4x4_16_add_sse2>, 4, 1
774 };
775
776 INSTANTIATE_TEST_SUITE_P(SSE2, TransWHT,
777 ::testing::Values(make_tuple(0, &wht_sse2_func_info, 0,
778 VPX_BITS_8)));
779 #endif // HAVE_SSE2 && !CONFIG_EMULATE_HARDWARE
780
781 #if HAVE_VSX && !CONFIG_EMULATE_HARDWARE && !CONFIG_VP9_HIGHBITDEPTH
782 static const FuncInfo wht_vsx_func_info = {
783 &fdct_wrapper<vp9_fwht4x4_c>, &idct_wrapper<vpx_iwht4x4_16_add_vsx>, 4, 1
784 };
785
786 INSTANTIATE_TEST_SUITE_P(VSX, TransWHT,
787 ::testing::Values(make_tuple(0, &wht_vsx_func_info, 0,
788 VPX_BITS_8)));
789 #endif // HAVE_VSX && !CONFIG_EMULATE_HARDWARE
790
791 } // namespace
792