2 * Copyright (c) 2017 The WebM project authors. All Rights Reserved.
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.
16 #include "third_party/googletest/src/include/gtest/gtest.h"
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/vpx_codec.h"
27 #include "vpx/vpx_integer.h"
28 #include "vpx_ports/mem.h"
30 using libvpx_test::ACMRandom;
31 using libvpx_test::Buffer;
32 using std::make_tuple;
36 typedef void (*FdctFunc)(const int16_t *in, tran_low_t *out, int stride);
37 typedef void (*IdctFunc)(const tran_low_t *in, uint8_t *out, int stride);
38 typedef void (*FhtFunc)(const int16_t *in, tran_low_t *out, int stride,
40 typedef void (*FhtFuncRef)(const Buffer<int16_t> &in, Buffer<tran_low_t> *out,
41 int size, int tx_type);
42 typedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,
44 typedef void (*IhtWithBdFunc)(const tran_low_t *in, uint8_t *out, int stride,
47 template <FdctFunc fn>
48 void fdct_wrapper(const int16_t *in, tran_low_t *out, int stride, int tx_type) {
53 template <IdctFunc fn>
54 void idct_wrapper(const tran_low_t *in, uint8_t *out, int stride, int tx_type,
62 void iht_wrapper(const tran_low_t *in, uint8_t *out, int stride, int tx_type,
65 fn(in, out, stride, tx_type);
68 #if CONFIG_VP9_HIGHBITDEPTH
69 typedef void (*HighbdIdctFunc)(const tran_low_t *in, uint16_t *out, int stride,
72 typedef void (*HighbdIhtFunc)(const tran_low_t *in, uint16_t *out, int stride,
75 template <HighbdIdctFunc fn>
76 void highbd_idct_wrapper(const tran_low_t *in, uint8_t *out, int stride,
77 int tx_type, int bd) {
79 fn(in, CAST_TO_SHORTPTR(out), stride, bd);
82 template <HighbdIhtFunc fn>
83 void highbd_iht_wrapper(const tran_low_t *in, uint8_t *out, int stride,
84 int tx_type, int bd) {
85 fn(in, CAST_TO_SHORTPTR(out), stride, tx_type, bd);
87 #endif // CONFIG_VP9_HIGHBITDEPTH
91 IhtWithBdFunc it_func;
96 /* forward transform, inverse transform, size, transform type, bit depth */
97 typedef tuple<int, const FuncInfo *, int, vpx_bit_depth_t> DctParam;
99 void fdct_ref(const Buffer<int16_t> &in, Buffer<tran_low_t> *out, int size,
101 const int16_t *i = in.TopLeftPixel();
102 const int i_stride = in.stride();
103 tran_low_t *o = out->TopLeftPixel();
105 vpx_fdct4x4_c(i, o, i_stride);
106 } else if (size == 8) {
107 vpx_fdct8x8_c(i, o, i_stride);
108 } else if (size == 16) {
109 vpx_fdct16x16_c(i, o, i_stride);
110 } else if (size == 32) {
111 vpx_fdct32x32_c(i, o, i_stride);
115 void fht_ref(const Buffer<int16_t> &in, Buffer<tran_low_t> *out, int size,
117 const int16_t *i = in.TopLeftPixel();
118 const int i_stride = in.stride();
119 tran_low_t *o = out->TopLeftPixel();
121 vp9_fht4x4_c(i, o, i_stride, tx_type);
122 } else if (size == 8) {
123 vp9_fht8x8_c(i, o, i_stride, tx_type);
124 } else if (size == 16) {
125 vp9_fht16x16_c(i, o, i_stride, tx_type);
129 void fwht_ref(const Buffer<int16_t> &in, Buffer<tran_low_t> *out, int size,
132 vp9_fwht4x4_c(in.TopLeftPixel(), out->TopLeftPixel(), in.stride());
135 class TransTestBase : public ::testing::TestWithParam<DctParam> {
137 virtual void SetUp() {
138 rnd_.Reset(ACMRandom::DeterministicSeed());
139 const int idx = GET_PARAM(0);
140 const FuncInfo *func_info = &(GET_PARAM(1)[idx]);
141 tx_type_ = GET_PARAM(2);
142 bit_depth_ = GET_PARAM(3);
143 fwd_txfm_ = func_info->ft_func;
144 inv_txfm_ = func_info->it_func;
145 size_ = func_info->size;
146 pixel_size_ = func_info->pixel_size;
147 max_pixel_value_ = (1 << bit_depth_) - 1;
149 // Randomize stride_ to a value less than or equal to 1024
150 stride_ = rnd_(1024) + 1;
151 if (stride_ < size_) {
154 // Align stride_ to 16 if it's bigger than 16.
159 block_size_ = size_ * stride_;
161 src_ = reinterpret_cast<uint8_t *>(
162 vpx_memalign(16, pixel_size_ * block_size_));
163 ASSERT_NE(src_, nullptr);
164 dst_ = reinterpret_cast<uint8_t *>(
165 vpx_memalign(16, pixel_size_ * block_size_));
166 ASSERT_NE(dst_, nullptr);
169 virtual void TearDown() {
174 libvpx_test::ClearSystemState();
178 if (pixel_size_ == 1 && bit_depth_ > VPX_BITS_8) return;
179 if (pixel_size_ == 1) {
180 for (int j = 0; j < block_size_; ++j) {
181 src_[j] = rnd_.Rand16() & max_pixel_value_;
183 for (int j = 0; j < block_size_; ++j) {
184 dst_[j] = rnd_.Rand16() & max_pixel_value_;
187 ASSERT_EQ(pixel_size_, 2);
188 uint16_t *const src = reinterpret_cast<uint16_t *>(src_);
189 uint16_t *const dst = reinterpret_cast<uint16_t *>(dst_);
190 for (int j = 0; j < block_size_; ++j) {
191 src[j] = rnd_.Rand16() & max_pixel_value_;
193 for (int j = 0; j < block_size_; ++j) {
194 dst[j] = rnd_.Rand16() & max_pixel_value_;
199 void RunFwdTxfm(const Buffer<int16_t> &in, Buffer<tran_low_t> *out) {
200 fwd_txfm_(in.TopLeftPixel(), out->TopLeftPixel(), in.stride(), tx_type_);
203 void RunInvTxfm(const Buffer<tran_low_t> &in, uint8_t *out) {
204 inv_txfm_(in.TopLeftPixel(), out, stride_, tx_type_, bit_depth_);
208 void RunAccuracyCheck(int limit) {
209 if (pixel_size_ == 1 && bit_depth_ > VPX_BITS_8) return;
210 ACMRandom rnd(ACMRandom::DeterministicSeed());
211 Buffer<int16_t> test_input_block =
212 Buffer<int16_t>(size_, size_, 8, size_ == 4 ? 0 : 16);
213 ASSERT_TRUE(test_input_block.Init());
214 ASSERT_NE(test_input_block.TopLeftPixel(), nullptr);
215 Buffer<tran_low_t> test_temp_block =
216 Buffer<tran_low_t>(size_, size_, 0, 16);
217 ASSERT_TRUE(test_temp_block.Init());
218 uint32_t max_error = 0;
219 int64_t total_error = 0;
220 const int count_test_block = 10000;
221 for (int i = 0; i < count_test_block; ++i) {
223 for (int h = 0; h < size_; ++h) {
224 for (int w = 0; w < size_; ++w) {
225 if (pixel_size_ == 1) {
226 test_input_block.TopLeftPixel()[h * test_input_block.stride() + w] =
227 src_[h * stride_ + w] - dst_[h * stride_ + w];
229 ASSERT_EQ(pixel_size_, 2);
230 const uint16_t *const src = reinterpret_cast<uint16_t *>(src_);
231 const uint16_t *const dst = reinterpret_cast<uint16_t *>(dst_);
232 test_input_block.TopLeftPixel()[h * test_input_block.stride() + w] =
233 src[h * stride_ + w] - dst[h * stride_ + w];
238 ASM_REGISTER_STATE_CHECK(RunFwdTxfm(test_input_block, &test_temp_block));
239 ASM_REGISTER_STATE_CHECK(RunInvTxfm(test_temp_block, dst_));
241 for (int h = 0; h < size_; ++h) {
242 for (int w = 0; w < size_; ++w) {
244 if (pixel_size_ == 1) {
245 diff = dst_[h * stride_ + w] - src_[h * stride_ + w];
247 ASSERT_EQ(pixel_size_, 2);
248 const uint16_t *const src = reinterpret_cast<uint16_t *>(src_);
249 const uint16_t *const dst = reinterpret_cast<uint16_t *>(dst_);
250 diff = dst[h * stride_ + w] - src[h * stride_ + w];
252 const uint32_t error = diff * diff;
253 if (max_error < error) max_error = error;
254 total_error += error;
259 EXPECT_GE(static_cast<uint32_t>(limit), max_error)
260 << "Error: " << size_ << "x" << size_
261 << " transform/inverse transform has an individual round trip error > "
264 EXPECT_GE(count_test_block * limit, total_error)
265 << "Error: " << size_ << "x" << size_
266 << " transform/inverse transform has average round trip error > "
267 << limit << " per block";
270 void RunCoeffCheck() {
271 if (pixel_size_ == 1 && bit_depth_ > VPX_BITS_8) return;
272 ACMRandom rnd(ACMRandom::DeterministicSeed());
273 const int count_test_block = 5000;
274 Buffer<int16_t> input_block =
275 Buffer<int16_t>(size_, size_, 8, size_ == 4 ? 0 : 16);
276 ASSERT_TRUE(input_block.Init());
277 Buffer<tran_low_t> output_ref_block = Buffer<tran_low_t>(size_, size_, 0);
278 ASSERT_TRUE(output_ref_block.Init());
279 Buffer<tran_low_t> output_block = Buffer<tran_low_t>(size_, size_, 0, 16);
280 ASSERT_TRUE(output_block.Init());
282 for (int i = 0; i < count_test_block; ++i) {
283 // Initialize a test block with input range [-max_pixel_value_,
284 // max_pixel_value_].
285 input_block.Set(&rnd, -max_pixel_value_, max_pixel_value_);
287 fwd_txfm_ref(input_block, &output_ref_block, size_, tx_type_);
288 ASM_REGISTER_STATE_CHECK(RunFwdTxfm(input_block, &output_block));
290 // The minimum quant value is 4.
291 EXPECT_TRUE(output_block.CheckValues(output_ref_block));
292 if (::testing::Test::HasFailure()) {
293 printf("Size: %d Transform type: %d\n", size_, tx_type_);
294 output_block.PrintDifference(output_ref_block);
301 if (pixel_size_ == 1 && bit_depth_ > VPX_BITS_8) return;
302 ACMRandom rnd(ACMRandom::DeterministicSeed());
303 const int count_test_block = 5000;
304 Buffer<int16_t> input_extreme_block =
305 Buffer<int16_t>(size_, size_, 8, size_ == 4 ? 0 : 16);
306 ASSERT_TRUE(input_extreme_block.Init());
307 Buffer<tran_low_t> output_ref_block = Buffer<tran_low_t>(size_, size_, 0);
308 ASSERT_TRUE(output_ref_block.Init());
309 Buffer<tran_low_t> output_block = Buffer<tran_low_t>(size_, size_, 0, 16);
310 ASSERT_TRUE(output_block.Init());
312 for (int i = 0; i < count_test_block; ++i) {
313 // Initialize a test block with -max_pixel_value_ or max_pixel_value_.
315 input_extreme_block.Set(max_pixel_value_);
317 input_extreme_block.Set(-max_pixel_value_);
319 ASSERT_NE(input_extreme_block.TopLeftPixel(), nullptr);
320 for (int h = 0; h < size_; ++h) {
321 for (int w = 0; w < size_; ++w) {
323 .TopLeftPixel()[h * input_extreme_block.stride() + w] =
324 rnd.Rand8() % 2 ? max_pixel_value_ : -max_pixel_value_;
329 fwd_txfm_ref(input_extreme_block, &output_ref_block, size_, tx_type_);
330 ASM_REGISTER_STATE_CHECK(RunFwdTxfm(input_extreme_block, &output_block));
332 // The minimum quant value is 4.
333 EXPECT_TRUE(output_block.CheckValues(output_ref_block));
334 ASSERT_NE(output_block.TopLeftPixel(), nullptr);
335 for (int h = 0; h < size_; ++h) {
336 for (int w = 0; w < size_; ++w) {
338 4 * DCT_MAX_VALUE << (bit_depth_ - 8),
339 abs(output_block.TopLeftPixel()[h * output_block.stride() + w]))
340 << "Error: " << size_ << "x" << size_
341 << " transform has coefficient larger than 4*DCT_MAX_VALUE"
342 << " at " << w << "," << h;
343 if (::testing::Test::HasFailure()) {
344 printf("Size: %d Transform type: %d\n", size_, tx_type_);
345 output_block.DumpBuffer();
353 void RunInvAccuracyCheck(int limit) {
354 if (pixel_size_ == 1 && bit_depth_ > VPX_BITS_8) return;
355 ACMRandom rnd(ACMRandom::DeterministicSeed());
356 const int count_test_block = 1000;
357 Buffer<int16_t> in = Buffer<int16_t>(size_, size_, 4);
358 ASSERT_TRUE(in.Init());
359 Buffer<tran_low_t> coeff = Buffer<tran_low_t>(size_, size_, 0, 16);
360 ASSERT_TRUE(coeff.Init());
361 Buffer<uint8_t> dst = Buffer<uint8_t>(size_, size_, 0, 16);
362 ASSERT_TRUE(dst.Init());
363 Buffer<uint8_t> src = Buffer<uint8_t>(size_, size_, 0);
364 ASSERT_TRUE(src.Init());
365 Buffer<uint16_t> dst16 = Buffer<uint16_t>(size_, size_, 0, 16);
366 ASSERT_TRUE(dst16.Init());
367 Buffer<uint16_t> src16 = Buffer<uint16_t>(size_, size_, 0);
368 ASSERT_TRUE(src16.Init());
370 for (int i = 0; i < count_test_block; ++i) {
372 ASSERT_NE(in.TopLeftPixel(), nullptr);
373 // Initialize a test block with input range [-max_pixel_value_,
374 // max_pixel_value_].
375 for (int h = 0; h < size_; ++h) {
376 for (int w = 0; w < size_; ++w) {
377 if (pixel_size_ == 1) {
378 in.TopLeftPixel()[h * in.stride() + w] =
379 src_[h * stride_ + w] - dst_[h * stride_ + w];
381 ASSERT_EQ(pixel_size_, 2);
382 const uint16_t *const src = reinterpret_cast<uint16_t *>(src_);
383 const uint16_t *const dst = reinterpret_cast<uint16_t *>(dst_);
384 in.TopLeftPixel()[h * in.stride() + w] =
385 src[h * stride_ + w] - dst[h * stride_ + w];
390 fwd_txfm_ref(in, &coeff, size_, tx_type_);
392 ASM_REGISTER_STATE_CHECK(RunInvTxfm(coeff, dst_));
394 for (int h = 0; h < size_; ++h) {
395 for (int w = 0; w < size_; ++w) {
397 if (pixel_size_ == 1) {
398 diff = dst_[h * stride_ + w] - src_[h * stride_ + w];
400 ASSERT_EQ(pixel_size_, 2);
401 const uint16_t *const src = reinterpret_cast<uint16_t *>(src_);
402 const uint16_t *const dst = reinterpret_cast<uint16_t *>(dst_);
403 diff = dst[h * stride_ + w] - src[h * stride_ + w];
405 const uint32_t error = diff * diff;
406 EXPECT_GE(static_cast<uint32_t>(limit), error)
407 << "Error: " << size_ << "x" << size_
408 << " inverse transform has error " << error << " at " << w << ","
410 if (::testing::Test::HasFailure()) {
411 printf("Size: %d Transform type: %d\n", size_, tx_type_);
420 FhtFuncRef fwd_txfm_ref;
421 IhtWithBdFunc inv_txfm_;
425 vpx_bit_depth_t bit_depth_;
427 int max_pixel_value_;
434 /* -------------------------------------------------------------------------- */
436 class TransDCT : public TransTestBase {
438 TransDCT() { fwd_txfm_ref = fdct_ref; }
441 TEST_P(TransDCT, AccuracyCheck) {
443 if (size_ == 16 && bit_depth_ > 10 && pixel_size_ == 2) {
445 } else if (size_ == 32 && bit_depth_ > 10 && pixel_size_ == 2) {
451 TEST_P(TransDCT, CoeffCheck) { RunCoeffCheck(); }
453 TEST_P(TransDCT, MemCheck) { RunMemCheck(); }
455 TEST_P(TransDCT, InvAccuracyCheck) { RunInvAccuracyCheck(1); }
457 static const FuncInfo dct_c_func_info[] = {
458 #if CONFIG_VP9_HIGHBITDEPTH
459 { &fdct_wrapper<vpx_highbd_fdct4x4_c>,
460 &highbd_idct_wrapper<vpx_highbd_idct4x4_16_add_c>, 4, 2 },
461 { &fdct_wrapper<vpx_highbd_fdct8x8_c>,
462 &highbd_idct_wrapper<vpx_highbd_idct8x8_64_add_c>, 8, 2 },
463 { &fdct_wrapper<vpx_highbd_fdct16x16_c>,
464 &highbd_idct_wrapper<vpx_highbd_idct16x16_256_add_c>, 16, 2 },
465 { &fdct_wrapper<vpx_highbd_fdct32x32_c>,
466 &highbd_idct_wrapper<vpx_highbd_idct32x32_1024_add_c>, 32, 2 },
468 { &fdct_wrapper<vpx_fdct4x4_c>, &idct_wrapper<vpx_idct4x4_16_add_c>, 4, 1 },
469 { &fdct_wrapper<vpx_fdct8x8_c>, &idct_wrapper<vpx_idct8x8_64_add_c>, 8, 1 },
470 { &fdct_wrapper<vpx_fdct16x16_c>, &idct_wrapper<vpx_idct16x16_256_add_c>, 16,
472 { &fdct_wrapper<vpx_fdct32x32_c>, &idct_wrapper<vpx_idct32x32_1024_add_c>, 32,
476 INSTANTIATE_TEST_SUITE_P(
479 ::testing::Range(0, static_cast<int>(sizeof(dct_c_func_info) /
480 sizeof(dct_c_func_info[0]))),
481 ::testing::Values(dct_c_func_info), ::testing::Values(0),
482 ::testing::Values(VPX_BITS_8, VPX_BITS_10, VPX_BITS_12)));
484 #if !CONFIG_EMULATE_HARDWARE
487 static const FuncInfo dct_sse2_func_info[] = {
488 #if CONFIG_VP9_HIGHBITDEPTH
489 { &fdct_wrapper<vpx_highbd_fdct4x4_sse2>,
490 &highbd_idct_wrapper<vpx_highbd_idct4x4_16_add_sse2>, 4, 2 },
491 { &fdct_wrapper<vpx_highbd_fdct8x8_sse2>,
492 &highbd_idct_wrapper<vpx_highbd_idct8x8_64_add_sse2>, 8, 2 },
493 { &fdct_wrapper<vpx_highbd_fdct16x16_sse2>,
494 &highbd_idct_wrapper<vpx_highbd_idct16x16_256_add_sse2>, 16, 2 },
495 { &fdct_wrapper<vpx_highbd_fdct32x32_sse2>,
496 &highbd_idct_wrapper<vpx_highbd_idct32x32_1024_add_sse2>, 32, 2 },
498 { &fdct_wrapper<vpx_fdct4x4_sse2>, &idct_wrapper<vpx_idct4x4_16_add_sse2>, 4,
500 { &fdct_wrapper<vpx_fdct8x8_sse2>, &idct_wrapper<vpx_idct8x8_64_add_sse2>, 8,
502 { &fdct_wrapper<vpx_fdct16x16_sse2>,
503 &idct_wrapper<vpx_idct16x16_256_add_sse2>, 16, 1 },
504 { &fdct_wrapper<vpx_fdct32x32_sse2>,
505 &idct_wrapper<vpx_idct32x32_1024_add_sse2>, 32, 1 }
508 INSTANTIATE_TEST_SUITE_P(
511 ::testing::Range(0, static_cast<int>(sizeof(dct_sse2_func_info) /
512 sizeof(dct_sse2_func_info[0]))),
513 ::testing::Values(dct_sse2_func_info), ::testing::Values(0),
514 ::testing::Values(VPX_BITS_8, VPX_BITS_10, VPX_BITS_12)));
517 #if HAVE_SSSE3 && !CONFIG_VP9_HIGHBITDEPTH && VPX_ARCH_X86_64
518 // vpx_fdct8x8_ssse3 is only available in 64 bit builds.
519 static const FuncInfo dct_ssse3_func_info = {
520 &fdct_wrapper<vpx_fdct8x8_ssse3>, &idct_wrapper<vpx_idct8x8_64_add_sse2>, 8, 1
523 // TODO(johannkoenig): high bit depth fdct8x8.
524 INSTANTIATE_TEST_SUITE_P(SSSE3, TransDCT,
525 ::testing::Values(make_tuple(0, &dct_ssse3_func_info,
527 #endif // HAVE_SSSE3 && !CONFIG_VP9_HIGHBITDEPTH && VPX_ARCH_X86_64
529 #if HAVE_AVX2 && !CONFIG_VP9_HIGHBITDEPTH
530 static const FuncInfo dct_avx2_func_info = {
531 &fdct_wrapper<vpx_fdct32x32_avx2>, &idct_wrapper<vpx_idct32x32_1024_add_sse2>,
535 // TODO(johannkoenig): high bit depth fdct32x32.
536 INSTANTIATE_TEST_SUITE_P(AVX2, TransDCT,
537 ::testing::Values(make_tuple(0, &dct_avx2_func_info, 0,
539 #endif // HAVE_AVX2 && !CONFIG_VP9_HIGHBITDEPTH
542 static const FuncInfo dct_neon_func_info[4] = {
543 { &fdct_wrapper<vpx_fdct4x4_neon>, &idct_wrapper<vpx_idct4x4_16_add_neon>, 4,
545 { &fdct_wrapper<vpx_fdct8x8_neon>, &idct_wrapper<vpx_idct8x8_64_add_neon>, 8,
547 { &fdct_wrapper<vpx_fdct16x16_neon>,
548 &idct_wrapper<vpx_idct16x16_256_add_neon>, 16, 1 },
549 { &fdct_wrapper<vpx_fdct32x32_neon>,
550 &idct_wrapper<vpx_idct32x32_1024_add_neon>, 32, 1 }
553 INSTANTIATE_TEST_SUITE_P(
555 ::testing::Combine(::testing::Range(0, 4),
556 ::testing::Values(dct_neon_func_info),
557 ::testing::Values(0), ::testing::Values(VPX_BITS_8)));
560 #if HAVE_MSA && !CONFIG_VP9_HIGHBITDEPTH
561 static const FuncInfo dct_msa_func_info[4] = {
562 { &fdct_wrapper<vpx_fdct4x4_msa>, &idct_wrapper<vpx_idct4x4_16_add_msa>, 4,
564 { &fdct_wrapper<vpx_fdct8x8_msa>, &idct_wrapper<vpx_idct8x8_64_add_msa>, 8,
566 { &fdct_wrapper<vpx_fdct16x16_msa>, &idct_wrapper<vpx_idct16x16_256_add_msa>,
568 { &fdct_wrapper<vpx_fdct32x32_msa>, &idct_wrapper<vpx_idct32x32_1024_add_msa>,
572 INSTANTIATE_TEST_SUITE_P(
574 ::testing::Combine(::testing::Range(0, 4),
575 ::testing::Values(dct_msa_func_info),
576 ::testing::Values(0), ::testing::Values(VPX_BITS_8)));
577 #endif // HAVE_MSA && !CONFIG_VP9_HIGHBITDEPTH
579 #if HAVE_VSX && !CONFIG_VP9_HIGHBITDEPTH
580 static const FuncInfo dct_vsx_func_info = {
581 &fdct_wrapper<vpx_fdct4x4_c>, &idct_wrapper<vpx_idct4x4_16_add_vsx>, 4, 1
584 INSTANTIATE_TEST_SUITE_P(VSX, TransDCT,
585 ::testing::Values(make_tuple(0, &dct_vsx_func_info, 0,
587 #endif // HAVE_VSX && !CONFIG_VP9_HIGHBITDEPTH &&
589 #endif // !CONFIG_EMULATE_HARDWARE
591 /* -------------------------------------------------------------------------- */
593 class TransHT : public TransTestBase {
595 TransHT() { fwd_txfm_ref = fht_ref; }
598 TEST_P(TransHT, AccuracyCheck) {
599 RunAccuracyCheck(size_ == 16 && bit_depth_ > 10 && pixel_size_ == 2 ? 2 : 1);
602 TEST_P(TransHT, CoeffCheck) { RunCoeffCheck(); }
604 TEST_P(TransHT, MemCheck) { RunMemCheck(); }
606 TEST_P(TransHT, InvAccuracyCheck) { RunInvAccuracyCheck(1); }
608 static const FuncInfo ht_c_func_info[] = {
609 #if CONFIG_VP9_HIGHBITDEPTH
610 { &vp9_highbd_fht4x4_c, &highbd_iht_wrapper<vp9_highbd_iht4x4_16_add_c>, 4,
612 { &vp9_highbd_fht8x8_c, &highbd_iht_wrapper<vp9_highbd_iht8x8_64_add_c>, 8,
614 { &vp9_highbd_fht16x16_c, &highbd_iht_wrapper<vp9_highbd_iht16x16_256_add_c>,
617 { &vp9_fht4x4_c, &iht_wrapper<vp9_iht4x4_16_add_c>, 4, 1 },
618 { &vp9_fht8x8_c, &iht_wrapper<vp9_iht8x8_64_add_c>, 8, 1 },
619 { &vp9_fht16x16_c, &iht_wrapper<vp9_iht16x16_256_add_c>, 16, 1 }
622 INSTANTIATE_TEST_SUITE_P(
625 ::testing::Range(0, static_cast<int>(sizeof(ht_c_func_info) /
626 sizeof(ht_c_func_info[0]))),
627 ::testing::Values(ht_c_func_info), ::testing::Range(0, 4),
628 ::testing::Values(VPX_BITS_8, VPX_BITS_10, VPX_BITS_12)));
630 #if !CONFIG_EMULATE_HARDWARE
634 static const FuncInfo ht_neon_func_info[] = {
635 #if CONFIG_VP9_HIGHBITDEPTH
636 { &vp9_highbd_fht4x4_c, &highbd_iht_wrapper<vp9_highbd_iht4x4_16_add_neon>, 4,
638 { &vp9_highbd_fht8x8_c, &highbd_iht_wrapper<vp9_highbd_iht8x8_64_add_neon>, 8,
640 { &vp9_highbd_fht16x16_c,
641 &highbd_iht_wrapper<vp9_highbd_iht16x16_256_add_neon>, 16, 2 },
643 { &vp9_fht4x4_c, &iht_wrapper<vp9_iht4x4_16_add_neon>, 4, 1 },
644 { &vp9_fht8x8_c, &iht_wrapper<vp9_iht8x8_64_add_neon>, 8, 1 },
645 { &vp9_fht16x16_c, &iht_wrapper<vp9_iht16x16_256_add_neon>, 16, 1 }
648 INSTANTIATE_TEST_SUITE_P(
651 ::testing::Range(0, static_cast<int>(sizeof(ht_neon_func_info) /
652 sizeof(ht_neon_func_info[0]))),
653 ::testing::Values(ht_neon_func_info), ::testing::Range(0, 4),
654 ::testing::Values(VPX_BITS_8, VPX_BITS_10, VPX_BITS_12)));
659 static const FuncInfo ht_sse2_func_info[3] = {
660 { &vp9_fht4x4_sse2, &iht_wrapper<vp9_iht4x4_16_add_sse2>, 4, 1 },
661 { &vp9_fht8x8_sse2, &iht_wrapper<vp9_iht8x8_64_add_sse2>, 8, 1 },
662 { &vp9_fht16x16_sse2, &iht_wrapper<vp9_iht16x16_256_add_sse2>, 16, 1 }
665 INSTANTIATE_TEST_SUITE_P(
667 ::testing::Combine(::testing::Range(0, 3),
668 ::testing::Values(ht_sse2_func_info),
669 ::testing::Range(0, 4), ::testing::Values(VPX_BITS_8)));
672 #if HAVE_SSE4_1 && CONFIG_VP9_HIGHBITDEPTH
673 static const FuncInfo ht_sse4_1_func_info[3] = {
674 { &vp9_highbd_fht4x4_c, &highbd_iht_wrapper<vp9_highbd_iht4x4_16_add_sse4_1>,
676 { vp9_highbd_fht8x8_c, &highbd_iht_wrapper<vp9_highbd_iht8x8_64_add_sse4_1>,
678 { &vp9_highbd_fht16x16_c,
679 &highbd_iht_wrapper<vp9_highbd_iht16x16_256_add_sse4_1>, 16, 2 }
682 INSTANTIATE_TEST_SUITE_P(
684 ::testing::Combine(::testing::Range(0, 3),
685 ::testing::Values(ht_sse4_1_func_info),
686 ::testing::Range(0, 4),
687 ::testing::Values(VPX_BITS_8, VPX_BITS_10,
689 #endif // HAVE_SSE4_1 && CONFIG_VP9_HIGHBITDEPTH
691 #if HAVE_VSX && !CONFIG_EMULATE_HARDWARE && !CONFIG_VP9_HIGHBITDEPTH
692 static const FuncInfo ht_vsx_func_info[3] = {
693 { &vp9_fht4x4_c, &iht_wrapper<vp9_iht4x4_16_add_vsx>, 4, 1 },
694 { &vp9_fht8x8_c, &iht_wrapper<vp9_iht8x8_64_add_vsx>, 8, 1 },
695 { &vp9_fht16x16_c, &iht_wrapper<vp9_iht16x16_256_add_vsx>, 16, 1 }
698 INSTANTIATE_TEST_SUITE_P(VSX, TransHT,
699 ::testing::Combine(::testing::Range(0, 3),
700 ::testing::Values(ht_vsx_func_info),
701 ::testing::Range(0, 4),
702 ::testing::Values(VPX_BITS_8)));
704 #endif // !CONFIG_EMULATE_HARDWARE
706 /* -------------------------------------------------------------------------- */
708 class TransWHT : public TransTestBase {
710 TransWHT() { fwd_txfm_ref = fwht_ref; }
713 TEST_P(TransWHT, AccuracyCheck) { RunAccuracyCheck(0); }
715 TEST_P(TransWHT, CoeffCheck) { RunCoeffCheck(); }
717 TEST_P(TransWHT, MemCheck) { RunMemCheck(); }
719 TEST_P(TransWHT, InvAccuracyCheck) { RunInvAccuracyCheck(0); }
721 static const FuncInfo wht_c_func_info[] = {
722 #if CONFIG_VP9_HIGHBITDEPTH
723 { &fdct_wrapper<vp9_highbd_fwht4x4_c>,
724 &highbd_idct_wrapper<vpx_highbd_iwht4x4_16_add_c>, 4, 2 },
726 { &fdct_wrapper<vp9_fwht4x4_c>, &idct_wrapper<vpx_iwht4x4_16_add_c>, 4, 1 }
729 INSTANTIATE_TEST_SUITE_P(
732 ::testing::Range(0, static_cast<int>(sizeof(wht_c_func_info) /
733 sizeof(wht_c_func_info[0]))),
734 ::testing::Values(wht_c_func_info), ::testing::Values(0),
735 ::testing::Values(VPX_BITS_8, VPX_BITS_10, VPX_BITS_12)));
737 #if HAVE_SSE2 && !CONFIG_EMULATE_HARDWARE
738 static const FuncInfo wht_sse2_func_info = {
739 &fdct_wrapper<vp9_fwht4x4_sse2>, &idct_wrapper<vpx_iwht4x4_16_add_sse2>, 4, 1
742 INSTANTIATE_TEST_SUITE_P(SSE2, TransWHT,
743 ::testing::Values(make_tuple(0, &wht_sse2_func_info, 0,
745 #endif // HAVE_SSE2 && !CONFIG_EMULATE_HARDWARE
747 #if HAVE_VSX && !CONFIG_EMULATE_HARDWARE && !CONFIG_VP9_HIGHBITDEPTH
748 static const FuncInfo wht_vsx_func_info = {
749 &fdct_wrapper<vp9_fwht4x4_c>, &idct_wrapper<vpx_iwht4x4_16_add_vsx>, 4, 1
752 INSTANTIATE_TEST_SUITE_P(VSX, TransWHT,
753 ::testing::Values(make_tuple(0, &wht_vsx_func_info, 0,
755 #endif // HAVE_VSX && !CONFIG_EMULATE_HARDWARE