Daniel Kang | 58156f1 | 2012-06-26 18:11:33 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Daniel Kang | 58156f1 | 2012-06-26 18:11:33 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 4 | * This source code is subject to the terms of the BSD 2 Clause License and |
| 5 | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
| 6 | * was not distributed with this source code in the LICENSE file, you can |
| 7 | * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
| 8 | * Media Patent License 1.0 was not distributed with this source code in the |
| 9 | * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
Johann | 123e8a6 | 2017-12-28 14:40:49 -0800 | [diff] [blame] | 10 | */ |
Daniel Kang | 58156f1 | 2012-06-26 18:11:33 -0700 | [diff] [blame] | 11 | |
| 12 | #include <math.h> |
| 13 | #include <stdlib.h> |
| 14 | #include <string.h> |
| 15 | |
Tom Finegan | 7a07ece | 2017-02-07 17:14:05 -0800 | [diff] [blame] | 16 | #include "third_party/googletest/src/googletest/include/gtest/gtest.h" |
Jingning Han | 097d59c | 2015-07-29 14:51:36 -0700 | [diff] [blame] | 17 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 18 | #include "./av1_rtcd.h" |
| 19 | #include "./aom_dsp_rtcd.h" |
Jingning Han | 30d4c5e | 2013-11-12 12:47:32 -0800 | [diff] [blame] | 20 | #include "test/acm_random.h" |
| 21 | #include "test/clear_system_state.h" |
| 22 | #include "test/register_state_check.h" |
Yi Luo | 267f73a | 2016-02-29 09:53:42 -0800 | [diff] [blame] | 23 | #include "test/transform_test_base.h" |
Jingning Han | 30d4c5e | 2013-11-12 12:47:32 -0800 | [diff] [blame] | 24 | #include "test/util.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 25 | #include "av1/common/entropy.h" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 26 | #include "aom/aom_codec.h" |
| 27 | #include "aom/aom_integer.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 28 | #include "aom_ports/mem.h" |
James Zern | 002ad40 | 2014-01-18 13:03:31 -0800 | [diff] [blame] | 29 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 30 | using libaom_test::ACMRandom; |
Daniel Kang | 26641c7 | 2012-06-28 16:26:31 -0700 | [diff] [blame] | 31 | |
Daniel Kang | 58156f1 | 2012-06-26 18:11:33 -0700 | [diff] [blame] | 32 | namespace { |
Deb Mukherjee | 10783d4 | 2014-09-02 16:34:09 -0700 | [diff] [blame] | 33 | typedef void (*FdctFunc)(const int16_t *in, tran_low_t *out, int stride); |
| 34 | typedef void (*IdctFunc)(const tran_low_t *in, uint8_t *out, int stride); |
Sebastien Alaiwan | 98392b2 | 2018-03-21 12:16:51 +0100 | [diff] [blame] | 35 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 36 | using libaom_test::FhtFunc; |
Jingning Han | 30d4c5e | 2013-11-12 12:47:32 -0800 | [diff] [blame] | 37 | |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 38 | typedef std::tr1::tuple<FdctFunc, IdctFunc, TX_TYPE, aom_bit_depth_t, int> |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 39 | Dct4x4Param; |
Joshua Litt | 51490e5 | 2013-11-18 17:07:55 -0800 | [diff] [blame] | 40 | |
Deb Mukherjee | 10783d4 | 2014-09-02 16:34:09 -0700 | [diff] [blame] | 41 | void fwht4x4_ref(const int16_t *in, tran_low_t *out, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 42 | TxfmParam * /*txfm_param*/) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 43 | av1_fwht4x4_c(in, out, stride); |
Alex Converse | 9f9f87c | 2014-05-05 13:50:12 -0700 | [diff] [blame] | 44 | } |
| 45 | |
Deb Mukherjee | 10783d4 | 2014-09-02 16:34:09 -0700 | [diff] [blame] | 46 | void iwht4x4_10(const tran_low_t *in, uint8_t *out, int stride) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 47 | aom_highbd_iwht4x4_16_add_c(in, out, stride, 10); |
Deb Mukherjee | 10783d4 | 2014-09-02 16:34:09 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | void iwht4x4_12(const tran_low_t *in, uint8_t *out, int stride) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 51 | aom_highbd_iwht4x4_16_add_c(in, out, stride, 12); |
Deb Mukherjee | 10783d4 | 2014-09-02 16:34:09 -0700 | [diff] [blame] | 52 | } |
Deb Mukherjee | 10783d4 | 2014-09-02 16:34:09 -0700 | [diff] [blame] | 53 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 54 | class Trans4x4WHT : public libaom_test::TransformTestBase, |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 55 | public ::testing::TestWithParam<Dct4x4Param> { |
Alex Converse | 9f9f87c | 2014-05-05 13:50:12 -0700 | [diff] [blame] | 56 | public: |
| 57 | virtual ~Trans4x4WHT() {} |
| 58 | |
| 59 | virtual void SetUp() { |
| 60 | fwd_txfm_ = GET_PARAM(0); |
| 61 | inv_txfm_ = GET_PARAM(1); |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 62 | pitch_ = 4; |
David Barker | 7825022 | 2016-10-13 15:10:14 +0100 | [diff] [blame] | 63 | height_ = 4; |
Alex Converse | 9f9f87c | 2014-05-05 13:50:12 -0700 | [diff] [blame] | 64 | fwd_txfm_ref = fwht4x4_ref; |
Deb Mukherjee | 10783d4 | 2014-09-02 16:34:09 -0700 | [diff] [blame] | 65 | bit_depth_ = GET_PARAM(3); |
| 66 | mask_ = (1 << bit_depth_) - 1; |
Yi Luo | 267f73a | 2016-02-29 09:53:42 -0800 | [diff] [blame] | 67 | num_coeffs_ = GET_PARAM(4); |
Alex Converse | 9f9f87c | 2014-05-05 13:50:12 -0700 | [diff] [blame] | 68 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 69 | virtual void TearDown() { libaom_test::ClearSystemState(); } |
Alex Converse | 9f9f87c | 2014-05-05 13:50:12 -0700 | [diff] [blame] | 70 | |
| 71 | protected: |
Deb Mukherjee | 10783d4 | 2014-09-02 16:34:09 -0700 | [diff] [blame] | 72 | void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) { |
Alex Converse | 9f9f87c | 2014-05-05 13:50:12 -0700 | [diff] [blame] | 73 | fwd_txfm_(in, out, stride); |
| 74 | } |
Deb Mukherjee | 10783d4 | 2014-09-02 16:34:09 -0700 | [diff] [blame] | 75 | void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) { |
Alex Converse | 9f9f87c | 2014-05-05 13:50:12 -0700 | [diff] [blame] | 76 | inv_txfm_(out, dst, stride); |
| 77 | } |
| 78 | |
James Zern | b8b3dd9 | 2014-07-16 18:55:40 -0700 | [diff] [blame] | 79 | FdctFunc fwd_txfm_; |
| 80 | IdctFunc inv_txfm_; |
Alex Converse | 9f9f87c | 2014-05-05 13:50:12 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
Angie Chiang | e6aece8 | 2017-01-09 17:27:56 -0800 | [diff] [blame] | 83 | TEST_P(Trans4x4WHT, AccuracyCheck) { RunAccuracyCheck(0, 0.00001); } |
Alex Converse | 9f9f87c | 2014-05-05 13:50:12 -0700 | [diff] [blame] | 84 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 85 | TEST_P(Trans4x4WHT, CoeffCheck) { RunCoeffCheck(); } |
Alex Converse | 9f9f87c | 2014-05-05 13:50:12 -0700 | [diff] [blame] | 86 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 87 | TEST_P(Trans4x4WHT, MemCheck) { RunMemCheck(); } |
Alex Converse | 9f9f87c | 2014-05-05 13:50:12 -0700 | [diff] [blame] | 88 | |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 89 | TEST_P(Trans4x4WHT, InvAccuracyCheck) { RunInvAccuracyCheck(0); } |
Jingning Han | 30d4c5e | 2013-11-12 12:47:32 -0800 | [diff] [blame] | 90 | using std::tr1::make_tuple; |
| 91 | |
Alex Converse | 9f9f87c | 2014-05-05 13:50:12 -0700 | [diff] [blame] | 92 | INSTANTIATE_TEST_CASE_P( |
| 93 | C, Trans4x4WHT, |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 94 | ::testing::Values(make_tuple(&av1_highbd_fwht4x4_c, &iwht4x4_10, DCT_DCT, |
| 95 | AOM_BITS_10, 16), |
| 96 | make_tuple(&av1_highbd_fwht4x4_c, &iwht4x4_12, DCT_DCT, |
| 97 | AOM_BITS_12, 16), |
| 98 | make_tuple(&av1_fwht4x4_c, &aom_iwht4x4_16_add_c, DCT_DCT, |
| 99 | AOM_BITS_8, 16))); |
James Zern | 08c3180 | 2014-02-25 23:11:49 -0800 | [diff] [blame] | 100 | |
Sebastien Alaiwan | 5859636 | 2018-01-26 10:11:35 +0100 | [diff] [blame] | 101 | #if HAVE_SSE2 |
Alex Converse | d8426d6 | 2015-07-13 11:12:45 -0700 | [diff] [blame] | 102 | INSTANTIATE_TEST_CASE_P( |
| 103 | SSE2, Trans4x4WHT, |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 104 | ::testing::Values(make_tuple(&av1_fwht4x4_c, &aom_iwht4x4_16_add_c, DCT_DCT, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 105 | AOM_BITS_8, 16), |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 106 | make_tuple(&av1_fwht4x4_c, &aom_iwht4x4_16_add_sse2, |
| 107 | DCT_DCT, AOM_BITS_8, 16))); |
Alex Converse | d8426d6 | 2015-07-13 11:12:45 -0700 | [diff] [blame] | 108 | #endif |
| 109 | |
Daniel Kang | 58156f1 | 2012-06-26 18:11:33 -0700 | [diff] [blame] | 110 | } // namespace |