Angie Chiang | 444acd7 | 2015-10-27 16:59:02 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | bde4ac8 | 2016-11-28 15:26:06 -0800 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Angie Chiang | 444acd7 | 2015-10-27 16:59:02 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | bde4ac8 | 2016-11-28 15:26:06 -0800 | [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. |
Angie Chiang | 444acd7 | 2015-10-27 16:59:02 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 12 | #include "test/av1_txfm_test.h" |
| 13 | #include "av1/common/av1_fwd_txfm1d.h" |
| 14 | #include "av1/common/av1_inv_txfm1d.h" |
Angie Chiang | 444acd7 | 2015-10-27 16:59:02 -0700 | [diff] [blame] | 15 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 16 | using libaom_test::ACMRandom; |
| 17 | using libaom_test::input_base; |
Angie Chiang | 444acd7 | 2015-10-27 16:59:02 -0700 | [diff] [blame] | 18 | |
| 19 | namespace { |
Angie Chiang | 29a06a1 | 2016-03-29 14:27:50 -0700 | [diff] [blame] | 20 | const int txfm_type_num = 2; |
| 21 | const int txfm_size_num = 5; |
Angie Chiang | 792519b | 2016-10-18 12:24:20 -0700 | [diff] [blame] | 22 | const int txfm_size_ls[5] = { 4, 8, 16, 32, 64 }; |
Angie Chiang | 444acd7 | 2015-10-27 16:59:02 -0700 | [diff] [blame] | 23 | |
Angie Chiang | 29a06a1 | 2016-03-29 14:27:50 -0700 | [diff] [blame] | 24 | const TxfmFunc fwd_txfm_func_ls[2][5] = { |
Angie Chiang | 792519b | 2016-10-18 12:24:20 -0700 | [diff] [blame] | 25 | #if CONFIG_TX64X64 |
| 26 | { av1_fdct4_new, av1_fdct8_new, av1_fdct16_new, av1_fdct32_new, |
| 27 | av1_fdct64_new }, |
| 28 | #else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 29 | { av1_fdct4_new, av1_fdct8_new, av1_fdct16_new, av1_fdct32_new, NULL }, |
Angie Chiang | 792519b | 2016-10-18 12:24:20 -0700 | [diff] [blame] | 30 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 31 | { av1_fadst4_new, av1_fadst8_new, av1_fadst16_new, av1_fadst32_new, NULL } |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 32 | }; |
Angie Chiang | 444acd7 | 2015-10-27 16:59:02 -0700 | [diff] [blame] | 33 | |
Angie Chiang | 29a06a1 | 2016-03-29 14:27:50 -0700 | [diff] [blame] | 34 | const TxfmFunc inv_txfm_func_ls[2][5] = { |
Angie Chiang | 792519b | 2016-10-18 12:24:20 -0700 | [diff] [blame] | 35 | #if CONFIG_TX64X64 |
| 36 | { av1_idct4_new, av1_idct8_new, av1_idct16_new, av1_idct32_new, |
| 37 | av1_idct64_new }, |
| 38 | #else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 39 | { av1_idct4_new, av1_idct8_new, av1_idct16_new, av1_idct32_new, NULL }, |
Angie Chiang | 792519b | 2016-10-18 12:24:20 -0700 | [diff] [blame] | 40 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 41 | { av1_iadst4_new, av1_iadst8_new, av1_iadst16_new, av1_iadst32_new, NULL } |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 42 | }; |
Angie Chiang | 444acd7 | 2015-10-27 16:59:02 -0700 | [diff] [blame] | 43 | |
| 44 | // the maximum stage number of fwd/inv 1d dct/adst txfm is 12 |
clang-format | 3a826f1 | 2016-08-11 17:46:05 -0700 | [diff] [blame] | 45 | const int8_t cos_bit[12] = { 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14 }; |
| 46 | const int8_t range_bit[12] = { 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32 }; |
Angie Chiang | 444acd7 | 2015-10-27 16:59:02 -0700 | [diff] [blame] | 47 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 48 | TEST(av1_inv_txfm1d, round_trip) { |
Angie Chiang | 444acd7 | 2015-10-27 16:59:02 -0700 | [diff] [blame] | 49 | 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 Chiang | ed2514a | 2016-03-14 12:02:27 -0700 | [diff] [blame] | 61 | 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 Chiang | 218dfbd | 2016-04-19 11:59:00 -0700 | [diff] [blame] | 65 | input[ni] = rnd.Rand16() % input_base - rnd.Rand16() % input_base; |
Angie Chiang | ed2514a | 2016-03-14 12:02:27 -0700 | [diff] [blame] | 66 | } |
Angie Chiang | 444acd7 | 2015-10-27 16:59:02 -0700 | [diff] [blame] | 67 | |
Angie Chiang | ed2514a | 2016-03-14 12:02:27 -0700 | [diff] [blame] | 68 | fwd_txfm_func(input, output, cos_bit, range_bit); |
| 69 | inv_txfm_func(output, round_trip_output, cos_bit, range_bit); |
Angie Chiang | 444acd7 | 2015-10-27 16:59:02 -0700 | [diff] [blame] | 70 | |
Angie Chiang | ed2514a | 2016-03-14 12:02:27 -0700 | [diff] [blame] | 71 | 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 Chiang | 444acd7 | 2015-10-27 16:59:02 -0700 | [diff] [blame] | 77 | } |
| 78 | } |
| 79 | } |
| 80 | delete[] input; |
| 81 | delete[] output; |
| 82 | delete[] round_trip_output; |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | } // namespace |