1 /*
2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3 *
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.
10 */
11
12 #include <math.h>
13 #include <stdlib.h>
14 #include <string.h>
15
16 #include "third_party/googletest/src/googletest/include/gtest/gtest.h"
17
18 #include "config/av1_rtcd.h"
19 #include "config/aom_dsp_rtcd.h"
20 #include "test/acm_random.h"
21 #include "test/clear_system_state.h"
22 #include "test/register_state_check.h"
23 #include "test/transform_test_base.h"
24 #include "test/util.h"
25 #include "av1/common/entropy.h"
26 #include "aom/aom_codec.h"
27 #include "aom/aom_integer.h"
28 #include "aom_ports/mem.h"
29
30 using libaom_test::ACMRandom;
31
32 namespace {
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);
35
36 using libaom_test::FhtFunc;
37
38 typedef ::testing::tuple<FdctFunc, IdctFunc, TX_TYPE, aom_bit_depth_t, int>
39 Dct4x4Param;
40
fwht4x4_ref(const int16_t * in,tran_low_t * out,int stride,TxfmParam *)41 void fwht4x4_ref(const int16_t *in, tran_low_t *out, int stride,
42 TxfmParam * /*txfm_param*/) {
43 av1_fwht4x4_c(in, out, stride);
44 }
45
iwht4x4_10(const tran_low_t * in,uint8_t * out,int stride)46 void iwht4x4_10(const tran_low_t *in, uint8_t *out, int stride) {
47 av1_highbd_iwht4x4_16_add_c(in, out, stride, 10);
48 }
49
iwht4x4_12(const tran_low_t * in,uint8_t * out,int stride)50 void iwht4x4_12(const tran_low_t *in, uint8_t *out, int stride) {
51 av1_highbd_iwht4x4_16_add_c(in, out, stride, 12);
52 }
53
54 class Trans4x4WHT : public libaom_test::TransformTestBase,
55 public ::testing::TestWithParam<Dct4x4Param> {
56 public:
~Trans4x4WHT()57 virtual ~Trans4x4WHT() {}
58
SetUp()59 virtual void SetUp() {
60 fwd_txfm_ = GET_PARAM(0);
61 inv_txfm_ = GET_PARAM(1);
62 pitch_ = 4;
63 height_ = 4;
64 fwd_txfm_ref = fwht4x4_ref;
65 bit_depth_ = GET_PARAM(3);
66 mask_ = (1 << bit_depth_) - 1;
67 num_coeffs_ = GET_PARAM(4);
68 }
TearDown()69 virtual void TearDown() { libaom_test::ClearSystemState(); }
70
71 protected:
RunFwdTxfm(const int16_t * in,tran_low_t * out,int stride)72 void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
73 fwd_txfm_(in, out, stride);
74 }
RunInvTxfm(const tran_low_t * out,uint8_t * dst,int stride)75 void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
76 inv_txfm_(out, dst, stride);
77 }
78
79 FdctFunc fwd_txfm_;
80 IdctFunc inv_txfm_;
81 };
82
TEST_P(Trans4x4WHT,AccuracyCheck)83 TEST_P(Trans4x4WHT, AccuracyCheck) { RunAccuracyCheck(0, 0.00001); }
84
TEST_P(Trans4x4WHT,CoeffCheck)85 TEST_P(Trans4x4WHT, CoeffCheck) { RunCoeffCheck(); }
86
TEST_P(Trans4x4WHT,MemCheck)87 TEST_P(Trans4x4WHT, MemCheck) { RunMemCheck(); }
88
TEST_P(Trans4x4WHT,InvAccuracyCheck)89 TEST_P(Trans4x4WHT, InvAccuracyCheck) { RunInvAccuracyCheck(0); }
90 using ::testing::make_tuple;
91
92 INSTANTIATE_TEST_CASE_P(
93 C, Trans4x4WHT,
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 } // namespace
99