blob: f03b1e19b1e00f554df554db56c023c8881c6ab8 [file] [log] [blame]
Daniel Kang58156f12012-06-26 18:11:33 -07001/*
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Daniel Kang58156f12012-06-26 18:11:33 -07003 *
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07004 * 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.
Johann123e8a62017-12-28 14:40:49 -080010 */
Daniel Kang58156f12012-06-26 18:11:33 -070011
12#include <math.h>
13#include <stdlib.h>
14#include <string.h>
15
Tom Finegan7a07ece2017-02-07 17:14:05 -080016#include "third_party/googletest/src/googletest/include/gtest/gtest.h"
Jingning Han097d59c2015-07-29 14:51:36 -070017
Yaowu Xuf883b422016-08-30 14:01:10 -070018#include "./av1_rtcd.h"
19#include "./aom_dsp_rtcd.h"
Jingning Han30d4c5e2013-11-12 12:47:32 -080020#include "test/acm_random.h"
21#include "test/clear_system_state.h"
22#include "test/register_state_check.h"
Yi Luo267f73a2016-02-29 09:53:42 -080023#include "test/transform_test_base.h"
Jingning Han30d4c5e2013-11-12 12:47:32 -080024#include "test/util.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070025#include "av1/common/entropy.h"
Yaowu Xuf883b422016-08-30 14:01:10 -070026#include "aom/aom_codec.h"
27#include "aom/aom_integer.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070028#include "aom_ports/mem.h"
James Zern002ad402014-01-18 13:03:31 -080029
Yaowu Xuc27fc142016-08-22 16:08:15 -070030using libaom_test::ACMRandom;
Daniel Kang26641c72012-06-28 16:26:31 -070031
Daniel Kang58156f12012-06-26 18:11:33 -070032namespace {
Deb Mukherjee10783d42014-09-02 16:34:09 -070033typedef void (*FdctFunc)(const int16_t *in, tran_low_t *out, int stride);
34typedef void (*IdctFunc)(const tran_low_t *in, uint8_t *out, int stride);
Sebastien Alaiwan98392b22018-03-21 12:16:51 +010035
Yaowu Xuc27fc142016-08-22 16:08:15 -070036using libaom_test::FhtFunc;
Jingning Han30d4c5e2013-11-12 12:47:32 -080037
Urvang Joshi2283d372017-10-02 17:16:45 -070038typedef std::tr1::tuple<FdctFunc, IdctFunc, TX_TYPE, aom_bit_depth_t, int>
clang-format3a826f12016-08-11 17:46:05 -070039 Dct4x4Param;
Joshua Litt51490e52013-11-18 17:07:55 -080040
Deb Mukherjee10783d42014-09-02 16:34:09 -070041void fwht4x4_ref(const int16_t *in, tran_low_t *out, int stride,
Lester Lu27319b62017-07-10 16:57:15 -070042 TxfmParam * /*txfm_param*/) {
Yaowu Xuf883b422016-08-30 14:01:10 -070043 av1_fwht4x4_c(in, out, stride);
Alex Converse9f9f87c2014-05-05 13:50:12 -070044}
45
Deb Mukherjee10783d42014-09-02 16:34:09 -070046void iwht4x4_10(const tran_low_t *in, uint8_t *out, int stride) {
Yaowu Xuf883b422016-08-30 14:01:10 -070047 aom_highbd_iwht4x4_16_add_c(in, out, stride, 10);
Deb Mukherjee10783d42014-09-02 16:34:09 -070048}
49
50void iwht4x4_12(const tran_low_t *in, uint8_t *out, int stride) {
Yaowu Xuf883b422016-08-30 14:01:10 -070051 aom_highbd_iwht4x4_16_add_c(in, out, stride, 12);
Deb Mukherjee10783d42014-09-02 16:34:09 -070052}
Deb Mukherjee10783d42014-09-02 16:34:09 -070053
Yaowu Xuc27fc142016-08-22 16:08:15 -070054class Trans4x4WHT : public libaom_test::TransformTestBase,
clang-format3a826f12016-08-11 17:46:05 -070055 public ::testing::TestWithParam<Dct4x4Param> {
Alex Converse9f9f87c2014-05-05 13:50:12 -070056 public:
57 virtual ~Trans4x4WHT() {}
58
59 virtual void SetUp() {
60 fwd_txfm_ = GET_PARAM(0);
61 inv_txfm_ = GET_PARAM(1);
clang-format3a826f12016-08-11 17:46:05 -070062 pitch_ = 4;
David Barker78250222016-10-13 15:10:14 +010063 height_ = 4;
Alex Converse9f9f87c2014-05-05 13:50:12 -070064 fwd_txfm_ref = fwht4x4_ref;
Deb Mukherjee10783d42014-09-02 16:34:09 -070065 bit_depth_ = GET_PARAM(3);
66 mask_ = (1 << bit_depth_) - 1;
Yi Luo267f73a2016-02-29 09:53:42 -080067 num_coeffs_ = GET_PARAM(4);
Alex Converse9f9f87c2014-05-05 13:50:12 -070068 }
Yaowu Xuc27fc142016-08-22 16:08:15 -070069 virtual void TearDown() { libaom_test::ClearSystemState(); }
Alex Converse9f9f87c2014-05-05 13:50:12 -070070
71 protected:
Deb Mukherjee10783d42014-09-02 16:34:09 -070072 void RunFwdTxfm(const int16_t *in, tran_low_t *out, int stride) {
Alex Converse9f9f87c2014-05-05 13:50:12 -070073 fwd_txfm_(in, out, stride);
74 }
Deb Mukherjee10783d42014-09-02 16:34:09 -070075 void RunInvTxfm(const tran_low_t *out, uint8_t *dst, int stride) {
Alex Converse9f9f87c2014-05-05 13:50:12 -070076 inv_txfm_(out, dst, stride);
77 }
78
James Zernb8b3dd92014-07-16 18:55:40 -070079 FdctFunc fwd_txfm_;
80 IdctFunc inv_txfm_;
Alex Converse9f9f87c2014-05-05 13:50:12 -070081};
82
Angie Chiange6aece82017-01-09 17:27:56 -080083TEST_P(Trans4x4WHT, AccuracyCheck) { RunAccuracyCheck(0, 0.00001); }
Alex Converse9f9f87c2014-05-05 13:50:12 -070084
clang-format3a826f12016-08-11 17:46:05 -070085TEST_P(Trans4x4WHT, CoeffCheck) { RunCoeffCheck(); }
Alex Converse9f9f87c2014-05-05 13:50:12 -070086
clang-format3a826f12016-08-11 17:46:05 -070087TEST_P(Trans4x4WHT, MemCheck) { RunMemCheck(); }
Alex Converse9f9f87c2014-05-05 13:50:12 -070088
clang-format3a826f12016-08-11 17:46:05 -070089TEST_P(Trans4x4WHT, InvAccuracyCheck) { RunInvAccuracyCheck(0); }
Jingning Han30d4c5e2013-11-12 12:47:32 -080090using std::tr1::make_tuple;
91
Alex Converse9f9f87c2014-05-05 13:50:12 -070092INSTANTIATE_TEST_CASE_P(
93 C, Trans4x4WHT,
Urvang Joshi2283d372017-10-02 17:16:45 -070094 ::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 Zern08c31802014-02-25 23:11:49 -0800100
Sebastien Alaiwan58596362018-01-26 10:11:35 +0100101#if HAVE_SSE2
Alex Conversed8426d62015-07-13 11:12:45 -0700102INSTANTIATE_TEST_CASE_P(
103 SSE2, Trans4x4WHT,
Urvang Joshi2283d372017-10-02 17:16:45 -0700104 ::testing::Values(make_tuple(&av1_fwht4x4_c, &aom_iwht4x4_16_add_c, DCT_DCT,
Yaowu Xuf883b422016-08-30 14:01:10 -0700105 AOM_BITS_8, 16),
Urvang Joshi2283d372017-10-02 17:16:45 -0700106 make_tuple(&av1_fwht4x4_c, &aom_iwht4x4_16_add_sse2,
107 DCT_DCT, AOM_BITS_8, 16)));
Alex Conversed8426d62015-07-13 11:12:45 -0700108#endif
109
Daniel Kang58156f12012-06-26 18:11:33 -0700110} // namespace