blob: 78c4ca744b5e2e3ad537857523a47c106c978367 [file] [log] [blame]
Angie Chiang444acd72015-10-27 16:59:02 -07001/*
Yaowu Xubde4ac82016-11-28 15:26:06 -08002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Angie Chiang444acd72015-10-27 16:59:02 -07003 *
Yaowu Xubde4ac82016-11-28 15:26:06 -08004 * 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.
Angie Chiang444acd72015-10-27 16:59:02 -070010 */
11
Yaowu Xuf883b422016-08-30 14:01:10 -070012#include "test/av1_txfm_test.h"
13#include "av1/common/av1_fwd_txfm1d.h"
14#include "av1/common/av1_inv_txfm1d.h"
Angie Chiang444acd72015-10-27 16:59:02 -070015
Yaowu Xuc27fc142016-08-22 16:08:15 -070016using libaom_test::ACMRandom;
17using libaom_test::input_base;
Angie Chiang444acd72015-10-27 16:59:02 -070018
19namespace {
Angie Chiang29a06a12016-03-29 14:27:50 -070020const int txfm_type_num = 2;
21const int txfm_size_num = 5;
Angie Chiang792519b2016-10-18 12:24:20 -070022const int txfm_size_ls[5] = { 4, 8, 16, 32, 64 };
Angie Chiang444acd72015-10-27 16:59:02 -070023
Angie Chiang29a06a12016-03-29 14:27:50 -070024const TxfmFunc fwd_txfm_func_ls[2][5] = {
Angie Chiang792519b2016-10-18 12:24:20 -070025#if CONFIG_TX64X64
26 { av1_fdct4_new, av1_fdct8_new, av1_fdct16_new, av1_fdct32_new,
27 av1_fdct64_new },
28#else
Yaowu Xuf883b422016-08-30 14:01:10 -070029 { av1_fdct4_new, av1_fdct8_new, av1_fdct16_new, av1_fdct32_new, NULL },
Angie Chiang792519b2016-10-18 12:24:20 -070030#endif
Yaowu Xuf883b422016-08-30 14:01:10 -070031 { av1_fadst4_new, av1_fadst8_new, av1_fadst16_new, av1_fadst32_new, NULL }
clang-format3a826f12016-08-11 17:46:05 -070032};
Angie Chiang444acd72015-10-27 16:59:02 -070033
Angie Chiang29a06a12016-03-29 14:27:50 -070034const TxfmFunc inv_txfm_func_ls[2][5] = {
Angie Chiang792519b2016-10-18 12:24:20 -070035#if CONFIG_TX64X64
36 { av1_idct4_new, av1_idct8_new, av1_idct16_new, av1_idct32_new,
37 av1_idct64_new },
38#else
Yaowu Xuf883b422016-08-30 14:01:10 -070039 { av1_idct4_new, av1_idct8_new, av1_idct16_new, av1_idct32_new, NULL },
Angie Chiang792519b2016-10-18 12:24:20 -070040#endif
Yaowu Xuf883b422016-08-30 14:01:10 -070041 { av1_iadst4_new, av1_iadst8_new, av1_iadst16_new, av1_iadst32_new, NULL }
clang-format3a826f12016-08-11 17:46:05 -070042};
Angie Chiang444acd72015-10-27 16:59:02 -070043
44// the maximum stage number of fwd/inv 1d dct/adst txfm is 12
clang-format3a826f12016-08-11 17:46:05 -070045const int8_t cos_bit[12] = { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 };
46const int8_t range_bit[12] = { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 };
Angie Chiang444acd72015-10-27 16:59:02 -070047
Yaowu Xuf883b422016-08-30 14:01:10 -070048TEST(av1_inv_txfm1d, round_trip) {
Angie Chiang444acd72015-10-27 16:59:02 -070049 ACMRandom rnd(ACMRandom::DeterministicSeed());
50 for (int si = 0; si < txfm_size_num; ++si) {
51 int txfm_size = txfm_size_ls[si];
52 int32_t *input = new int32_t[txfm_size];
53 int32_t *output = new int32_t[txfm_size];
54 int32_t *round_trip_output = new int32_t[txfm_size];
55
56 for (int ti = 0; ti < txfm_type_num; ++ti) {
57 TxfmFunc fwd_txfm_func = fwd_txfm_func_ls[ti][si];
58 TxfmFunc inv_txfm_func = inv_txfm_func_ls[ti][si];
59 int max_error = 2;
60
Angie Chianged2514a2016-03-14 12:02:27 -070061 if (fwd_txfm_func != NULL) {
62 const int count_test_block = 5000;
63 for (int ci = 0; ci < count_test_block; ++ci) {
64 for (int ni = 0; ni < txfm_size; ++ni) {
Angie Chiang218dfbd2016-04-19 11:59:00 -070065 input[ni] = rnd.Rand16() % input_base - rnd.Rand16() % input_base;
Angie Chianged2514a2016-03-14 12:02:27 -070066 }
Angie Chiang444acd72015-10-27 16:59:02 -070067
Angie Chianged2514a2016-03-14 12:02:27 -070068 fwd_txfm_func(input, output, cos_bit, range_bit);
69 inv_txfm_func(output, round_trip_output, cos_bit, range_bit);
Angie Chiang444acd72015-10-27 16:59:02 -070070
Angie Chianged2514a2016-03-14 12:02:27 -070071 for (int ni = 0; ni < txfm_size; ++ni) {
72 int node_err =
73 abs(input[ni] - round_shift(round_trip_output[ni],
74 get_max_bit(txfm_size) - 1));
75 EXPECT_LE(node_err, max_error);
76 }
Angie Chiang444acd72015-10-27 16:59:02 -070077 }
78 }
79 }
80 delete[] input;
81 delete[] output;
82 delete[] round_trip_output;
83 }
84}
85
86} // namespace