Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
James Zern | b7c05bd | 2024-06-11 19:15:10 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -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. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
Tom Finegan | 60e653d | 2018-05-22 11:34:58 -0700 | [diff] [blame] | 12 | #include "config/aom_config.h" |
Tom Finegan | 44702c8 | 2018-05-22 13:00:39 -0700 | [diff] [blame] | 13 | #include "config/av1_rtcd.h" |
| 14 | #include "config/aom_dsp_rtcd.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 15 | |
| 16 | #include "av1/common/idct.h" |
Angie Chiang | fd4a8f3 | 2021-03-31 12:18:31 -0700 | [diff] [blame] | 17 | #include "av1/common/blockd.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 18 | #include "av1/encoder/hybrid_fwd_txfm.h" |
| 19 | |
Urvang Joshi | 8207b91 | 2018-05-07 14:37:51 -0700 | [diff] [blame] | 20 | /* 4-point reversible, orthonormal Walsh-Hadamard in 3.5 adds, 0.5 shifts per |
Kyle Siefring | 7bb4c54 | 2022-12-09 10:27:41 -0500 | [diff] [blame] | 21 | pixel. |
| 22 | Shared for both high and low bit depth. |
| 23 | */ |
Urvang Joshi | 8207b91 | 2018-05-07 14:37:51 -0700 | [diff] [blame] | 24 | void av1_fwht4x4_c(const int16_t *input, tran_low_t *output, int stride) { |
| 25 | int i; |
| 26 | tran_high_t a1, b1, c1, d1, e1; |
| 27 | const int16_t *ip_pass0 = input; |
| 28 | const tran_low_t *ip = NULL; |
| 29 | tran_low_t *op = output; |
| 30 | |
| 31 | for (i = 0; i < 4; i++) { |
| 32 | a1 = ip_pass0[0 * stride]; |
| 33 | b1 = ip_pass0[1 * stride]; |
| 34 | c1 = ip_pass0[2 * stride]; |
| 35 | d1 = ip_pass0[3 * stride]; |
| 36 | |
| 37 | a1 += b1; |
| 38 | d1 = d1 - c1; |
| 39 | e1 = (a1 - d1) >> 1; |
| 40 | b1 = e1 - b1; |
| 41 | c1 = e1 - c1; |
| 42 | a1 -= c1; |
| 43 | d1 += b1; |
| 44 | op[0] = (tran_low_t)a1; |
Kyle Siefring | 7bb4c54 | 2022-12-09 10:27:41 -0500 | [diff] [blame] | 45 | op[1] = (tran_low_t)c1; |
| 46 | op[2] = (tran_low_t)d1; |
| 47 | op[3] = (tran_low_t)b1; |
Urvang Joshi | 8207b91 | 2018-05-07 14:37:51 -0700 | [diff] [blame] | 48 | |
| 49 | ip_pass0++; |
Kyle Siefring | 7bb4c54 | 2022-12-09 10:27:41 -0500 | [diff] [blame] | 50 | op += 4; |
Urvang Joshi | 8207b91 | 2018-05-07 14:37:51 -0700 | [diff] [blame] | 51 | } |
| 52 | ip = output; |
| 53 | op = output; |
| 54 | |
| 55 | for (i = 0; i < 4; i++) { |
Kyle Siefring | 7bb4c54 | 2022-12-09 10:27:41 -0500 | [diff] [blame] | 56 | a1 = ip[4 * 0]; |
| 57 | b1 = ip[4 * 1]; |
| 58 | c1 = ip[4 * 2]; |
| 59 | d1 = ip[4 * 3]; |
Urvang Joshi | 8207b91 | 2018-05-07 14:37:51 -0700 | [diff] [blame] | 60 | |
| 61 | a1 += b1; |
| 62 | d1 -= c1; |
| 63 | e1 = (a1 - d1) >> 1; |
| 64 | b1 = e1 - b1; |
| 65 | c1 = e1 - c1; |
| 66 | a1 -= c1; |
| 67 | d1 += b1; |
Kyle Siefring | 7bb4c54 | 2022-12-09 10:27:41 -0500 | [diff] [blame] | 68 | op[4 * 0] = (tran_low_t)(a1 * UNIT_QUANT_FACTOR); |
| 69 | op[4 * 1] = (tran_low_t)(c1 * UNIT_QUANT_FACTOR); |
| 70 | op[4 * 2] = (tran_low_t)(d1 * UNIT_QUANT_FACTOR); |
| 71 | op[4 * 3] = (tran_low_t)(b1 * UNIT_QUANT_FACTOR); |
Urvang Joshi | 8207b91 | 2018-05-07 14:37:51 -0700 | [diff] [blame] | 72 | |
Kyle Siefring | 7bb4c54 | 2022-12-09 10:27:41 -0500 | [diff] [blame] | 73 | ip++; |
| 74 | op++; |
Urvang Joshi | 8207b91 | 2018-05-07 14:37:51 -0700 | [diff] [blame] | 75 | } |
| 76 | } |
| 77 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 78 | static void highbd_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 79 | int diff_stride, TxfmParam *txfm_param) { |
Yi Luo | 0f4195c | 2017-06-27 16:07:28 -0700 | [diff] [blame] | 80 | int32_t *dst_coeff = (int32_t *)coeff; |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 81 | const TX_TYPE tx_type = txfm_param->tx_type; |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 82 | const int bd = txfm_param->bd; |
| 83 | if (txfm_param->lossless) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 84 | assert(tx_type == DCT_DCT); |
Kyle Siefring | 7bb4c54 | 2022-12-09 10:27:41 -0500 | [diff] [blame] | 85 | av1_fwht4x4(src_diff, coeff, diff_stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 86 | return; |
| 87 | } |
Aniket Dhok | 7629c38 | 2018-10-18 13:02:12 +0530 | [diff] [blame] | 88 | av1_fwd_txfm2d_4x4(src_diff, dst_coeff, diff_stride, tx_type, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 89 | } |
| 90 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 91 | static void highbd_fwd_txfm_4x8(const int16_t *src_diff, tran_low_t *coeff, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 92 | int diff_stride, TxfmParam *txfm_param) { |
Yi Luo | 0f4195c | 2017-06-27 16:07:28 -0700 | [diff] [blame] | 93 | int32_t *dst_coeff = (int32_t *)coeff; |
Aniket Dhok | 7629c38 | 2018-10-18 13:02:12 +0530 | [diff] [blame] | 94 | av1_fwd_txfm2d_4x8(src_diff, dst_coeff, diff_stride, txfm_param->tx_type, |
| 95 | txfm_param->bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | static void highbd_fwd_txfm_8x4(const int16_t *src_diff, tran_low_t *coeff, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 99 | int diff_stride, TxfmParam *txfm_param) { |
Yi Luo | 0f4195c | 2017-06-27 16:07:28 -0700 | [diff] [blame] | 100 | int32_t *dst_coeff = (int32_t *)coeff; |
Aniket Dhok | 7629c38 | 2018-10-18 13:02:12 +0530 | [diff] [blame] | 101 | av1_fwd_txfm2d_8x4(src_diff, dst_coeff, diff_stride, txfm_param->tx_type, |
| 102 | txfm_param->bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | static void highbd_fwd_txfm_8x16(const int16_t *src_diff, tran_low_t *coeff, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 106 | int diff_stride, TxfmParam *txfm_param) { |
Yi Luo | 0f4195c | 2017-06-27 16:07:28 -0700 | [diff] [blame] | 107 | int32_t *dst_coeff = (int32_t *)coeff; |
Venkat | d04f6c5 | 2018-09-12 10:42:33 +0530 | [diff] [blame] | 108 | const TX_TYPE tx_type = txfm_param->tx_type; |
| 109 | const int bd = txfm_param->bd; |
Aniket Dhok | 7629c38 | 2018-10-18 13:02:12 +0530 | [diff] [blame] | 110 | av1_fwd_txfm2d_8x16(src_diff, dst_coeff, diff_stride, tx_type, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | static void highbd_fwd_txfm_16x8(const int16_t *src_diff, tran_low_t *coeff, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 114 | int diff_stride, TxfmParam *txfm_param) { |
Yi Luo | 0f4195c | 2017-06-27 16:07:28 -0700 | [diff] [blame] | 115 | int32_t *dst_coeff = (int32_t *)coeff; |
Venkat | d04f6c5 | 2018-09-12 10:42:33 +0530 | [diff] [blame] | 116 | const TX_TYPE tx_type = txfm_param->tx_type; |
| 117 | const int bd = txfm_param->bd; |
Aniket Dhok | 7629c38 | 2018-10-18 13:02:12 +0530 | [diff] [blame] | 118 | av1_fwd_txfm2d_16x8(src_diff, dst_coeff, diff_stride, tx_type, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | static void highbd_fwd_txfm_16x32(const int16_t *src_diff, tran_low_t *coeff, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 122 | int diff_stride, TxfmParam *txfm_param) { |
Yi Luo | 0f4195c | 2017-06-27 16:07:28 -0700 | [diff] [blame] | 123 | int32_t *dst_coeff = (int32_t *)coeff; |
Aniket Dhok | 63adafd | 2018-10-22 17:51:52 +0530 | [diff] [blame] | 124 | av1_fwd_txfm2d_16x32(src_diff, dst_coeff, diff_stride, txfm_param->tx_type, |
| 125 | txfm_param->bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | static void highbd_fwd_txfm_32x16(const int16_t *src_diff, tran_low_t *coeff, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 129 | int diff_stride, TxfmParam *txfm_param) { |
Yi Luo | 0f4195c | 2017-06-27 16:07:28 -0700 | [diff] [blame] | 130 | int32_t *dst_coeff = (int32_t *)coeff; |
Aniket Dhok | 63adafd | 2018-10-22 17:51:52 +0530 | [diff] [blame] | 131 | av1_fwd_txfm2d_32x16(src_diff, dst_coeff, diff_stride, txfm_param->tx_type, |
| 132 | txfm_param->bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 133 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 134 | |
Jerome Jiang | 454d116 | 2021-01-06 20:51:03 -0800 | [diff] [blame] | 135 | #if !CONFIG_REALTIME_ONLY |
Debargha Mukherjee | 845057f | 2017-11-13 07:03:36 -0800 | [diff] [blame] | 136 | static void highbd_fwd_txfm_16x4(const int16_t *src_diff, tran_low_t *coeff, |
| 137 | int diff_stride, TxfmParam *txfm_param) { |
Debargha Mukherjee | 69f914a | 2017-11-15 20:58:23 -0800 | [diff] [blame] | 138 | int32_t *dst_coeff = (int32_t *)coeff; |
Aniket Dhok | 7629c38 | 2018-10-18 13:02:12 +0530 | [diff] [blame] | 139 | av1_fwd_txfm2d_16x4(src_diff, dst_coeff, diff_stride, txfm_param->tx_type, |
| 140 | txfm_param->bd); |
Debargha Mukherjee | 845057f | 2017-11-13 07:03:36 -0800 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | static void highbd_fwd_txfm_4x16(const int16_t *src_diff, tran_low_t *coeff, |
| 144 | int diff_stride, TxfmParam *txfm_param) { |
Debargha Mukherjee | 69f914a | 2017-11-15 20:58:23 -0800 | [diff] [blame] | 145 | int32_t *dst_coeff = (int32_t *)coeff; |
Aniket Dhok | 7629c38 | 2018-10-18 13:02:12 +0530 | [diff] [blame] | 146 | av1_fwd_txfm2d_4x16(src_diff, dst_coeff, diff_stride, txfm_param->tx_type, |
| 147 | txfm_param->bd); |
Debargha Mukherjee | 845057f | 2017-11-13 07:03:36 -0800 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | static void highbd_fwd_txfm_32x8(const int16_t *src_diff, tran_low_t *coeff, |
| 151 | int diff_stride, TxfmParam *txfm_param) { |
Debargha Mukherjee | 69f914a | 2017-11-15 20:58:23 -0800 | [diff] [blame] | 152 | int32_t *dst_coeff = (int32_t *)coeff; |
Aniket Dhok | 63adafd | 2018-10-22 17:51:52 +0530 | [diff] [blame] | 153 | av1_fwd_txfm2d_32x8(src_diff, dst_coeff, diff_stride, txfm_param->tx_type, |
| 154 | txfm_param->bd); |
Debargha Mukherjee | 845057f | 2017-11-13 07:03:36 -0800 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | static void highbd_fwd_txfm_8x32(const int16_t *src_diff, tran_low_t *coeff, |
| 158 | int diff_stride, TxfmParam *txfm_param) { |
Debargha Mukherjee | 69f914a | 2017-11-15 20:58:23 -0800 | [diff] [blame] | 159 | int32_t *dst_coeff = (int32_t *)coeff; |
Aniket Dhok | 63adafd | 2018-10-22 17:51:52 +0530 | [diff] [blame] | 160 | av1_fwd_txfm2d_8x32(src_diff, dst_coeff, diff_stride, txfm_param->tx_type, |
| 161 | txfm_param->bd); |
Debargha Mukherjee | 845057f | 2017-11-13 07:03:36 -0800 | [diff] [blame] | 162 | } |
Jerome Jiang | 454d116 | 2021-01-06 20:51:03 -0800 | [diff] [blame] | 163 | #endif |
Debargha Mukherjee | 845057f | 2017-11-13 07:03:36 -0800 | [diff] [blame] | 164 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 165 | static void highbd_fwd_txfm_8x8(const int16_t *src_diff, tran_low_t *coeff, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 166 | int diff_stride, TxfmParam *txfm_param) { |
Yi Luo | 0f4195c | 2017-06-27 16:07:28 -0700 | [diff] [blame] | 167 | int32_t *dst_coeff = (int32_t *)coeff; |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 168 | const TX_TYPE tx_type = txfm_param->tx_type; |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 169 | const int bd = txfm_param->bd; |
Aniket Dhok | 7629c38 | 2018-10-18 13:02:12 +0530 | [diff] [blame] | 170 | av1_fwd_txfm2d_8x8(src_diff, dst_coeff, diff_stride, tx_type, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | static void highbd_fwd_txfm_16x16(const int16_t *src_diff, tran_low_t *coeff, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 174 | int diff_stride, TxfmParam *txfm_param) { |
Yi Luo | 0f4195c | 2017-06-27 16:07:28 -0700 | [diff] [blame] | 175 | int32_t *dst_coeff = (int32_t *)coeff; |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 176 | const TX_TYPE tx_type = txfm_param->tx_type; |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 177 | const int bd = txfm_param->bd; |
Aniket Dhok | 7629c38 | 2018-10-18 13:02:12 +0530 | [diff] [blame] | 178 | av1_fwd_txfm2d_16x16(src_diff, dst_coeff, diff_stride, tx_type, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 179 | } |
| 180 | |
Angie Chiang | 8fd2d7a | 2017-01-03 15:50:15 -0800 | [diff] [blame] | 181 | static void highbd_fwd_txfm_32x32(const int16_t *src_diff, tran_low_t *coeff, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 182 | int diff_stride, TxfmParam *txfm_param) { |
Yi Luo | 0f4195c | 2017-06-27 16:07:28 -0700 | [diff] [blame] | 183 | int32_t *dst_coeff = (int32_t *)coeff; |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 184 | const TX_TYPE tx_type = txfm_param->tx_type; |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 185 | const int bd = txfm_param->bd; |
Aniket Dhok | 63adafd | 2018-10-22 17:51:52 +0530 | [diff] [blame] | 186 | av1_fwd_txfm2d_32x32(src_diff, dst_coeff, diff_stride, tx_type, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 187 | } |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 188 | |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 189 | static void highbd_fwd_txfm_32x64(const int16_t *src_diff, tran_low_t *coeff, |
| 190 | int diff_stride, TxfmParam *txfm_param) { |
Hui Su | 98626d3 | 2018-04-13 12:08:48 -0700 | [diff] [blame] | 191 | assert(txfm_param->tx_type == DCT_DCT); |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 192 | int32_t *dst_coeff = (int32_t *)coeff; |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 193 | const int bd = txfm_param->bd; |
Satish Kumar Suman | 0252600 | 2018-10-17 17:51:49 +0530 | [diff] [blame] | 194 | av1_fwd_txfm2d_32x64(src_diff, dst_coeff, diff_stride, txfm_param->tx_type, |
| 195 | bd); |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | static void highbd_fwd_txfm_64x32(const int16_t *src_diff, tran_low_t *coeff, |
| 199 | int diff_stride, TxfmParam *txfm_param) { |
Hui Su | 98626d3 | 2018-04-13 12:08:48 -0700 | [diff] [blame] | 200 | assert(txfm_param->tx_type == DCT_DCT); |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 201 | int32_t *dst_coeff = (int32_t *)coeff; |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 202 | const int bd = txfm_param->bd; |
Satish Kumar Suman | 0252600 | 2018-10-17 17:51:49 +0530 | [diff] [blame] | 203 | av1_fwd_txfm2d_64x32(src_diff, dst_coeff, diff_stride, txfm_param->tx_type, |
| 204 | bd); |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 205 | } |
Debargha Mukherjee | 0254fee | 2017-12-02 09:08:52 -0800 | [diff] [blame] | 206 | |
Jerome Jiang | 454d116 | 2021-01-06 20:51:03 -0800 | [diff] [blame] | 207 | #if !CONFIG_REALTIME_ONLY |
Debargha Mukherjee | 0254fee | 2017-12-02 09:08:52 -0800 | [diff] [blame] | 208 | static void highbd_fwd_txfm_16x64(const int16_t *src_diff, tran_low_t *coeff, |
| 209 | int diff_stride, TxfmParam *txfm_param) { |
Hui Su | 98626d3 | 2018-04-13 12:08:48 -0700 | [diff] [blame] | 210 | assert(txfm_param->tx_type == DCT_DCT); |
Debargha Mukherjee | 0254fee | 2017-12-02 09:08:52 -0800 | [diff] [blame] | 211 | int32_t *dst_coeff = (int32_t *)coeff; |
Debargha Mukherjee | 0254fee | 2017-12-02 09:08:52 -0800 | [diff] [blame] | 212 | const int bd = txfm_param->bd; |
Satish Kumar Suman | 0252600 | 2018-10-17 17:51:49 +0530 | [diff] [blame] | 213 | av1_fwd_txfm2d_16x64(src_diff, dst_coeff, diff_stride, DCT_DCT, bd); |
Debargha Mukherjee | 0254fee | 2017-12-02 09:08:52 -0800 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | static void highbd_fwd_txfm_64x16(const int16_t *src_diff, tran_low_t *coeff, |
| 217 | int diff_stride, TxfmParam *txfm_param) { |
Hui Su | 98626d3 | 2018-04-13 12:08:48 -0700 | [diff] [blame] | 218 | assert(txfm_param->tx_type == DCT_DCT); |
Debargha Mukherjee | 0254fee | 2017-12-02 09:08:52 -0800 | [diff] [blame] | 219 | int32_t *dst_coeff = (int32_t *)coeff; |
Debargha Mukherjee | 0254fee | 2017-12-02 09:08:52 -0800 | [diff] [blame] | 220 | const int bd = txfm_param->bd; |
Satish Kumar Suman | 0252600 | 2018-10-17 17:51:49 +0530 | [diff] [blame] | 221 | av1_fwd_txfm2d_64x16(src_diff, dst_coeff, diff_stride, DCT_DCT, bd); |
Debargha Mukherjee | 0254fee | 2017-12-02 09:08:52 -0800 | [diff] [blame] | 222 | } |
Jerome Jiang | 454d116 | 2021-01-06 20:51:03 -0800 | [diff] [blame] | 223 | #endif |
Debargha Mukherjee | 0254fee | 2017-12-02 09:08:52 -0800 | [diff] [blame] | 224 | |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 225 | static void highbd_fwd_txfm_64x64(const int16_t *src_diff, tran_low_t *coeff, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 226 | int diff_stride, TxfmParam *txfm_param) { |
Hui Su | 98626d3 | 2018-04-13 12:08:48 -0700 | [diff] [blame] | 227 | assert(txfm_param->tx_type == DCT_DCT); |
Yi Luo | 0f4195c | 2017-06-27 16:07:28 -0700 | [diff] [blame] | 228 | int32_t *dst_coeff = (int32_t *)coeff; |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 229 | const int bd = txfm_param->bd; |
Hui Su | 98626d3 | 2018-04-13 12:08:48 -0700 | [diff] [blame] | 230 | av1_fwd_txfm2d_64x64(src_diff, dst_coeff, diff_stride, DCT_DCT, bd); |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 231 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 232 | |
hui su | f11fb88 | 2017-03-27 14:56:33 -0700 | [diff] [blame] | 233 | void av1_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff, int diff_stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 234 | TxfmParam *txfm_param) { |
Angie Chiang | 7d8b13e | 2018-02-07 22:55:45 -0800 | [diff] [blame] | 235 | if (txfm_param->bd == 8) |
| 236 | av1_lowbd_fwd_txfm(src_diff, coeff, diff_stride, txfm_param); |
| 237 | else |
| 238 | av1_highbd_fwd_txfm(src_diff, coeff, diff_stride, txfm_param); |
| 239 | } |
| 240 | |
| 241 | void av1_lowbd_fwd_txfm_c(const int16_t *src_diff, tran_low_t *coeff, |
| 242 | int diff_stride, TxfmParam *txfm_param) { |
| 243 | av1_highbd_fwd_txfm(src_diff, coeff, diff_stride, txfm_param); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 244 | } |
| 245 | |
hui su | f11fb88 | 2017-03-27 14:56:33 -0700 | [diff] [blame] | 246 | void av1_highbd_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 247 | int diff_stride, TxfmParam *txfm_param) { |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame] | 248 | assert(av1_ext_tx_used[txfm_param->tx_set_type][txfm_param->tx_type]); |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 249 | const TX_SIZE tx_size = txfm_param->tx_size; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 250 | switch (tx_size) { |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 251 | case TX_64X64: |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 252 | highbd_fwd_txfm_64x64(src_diff, coeff, diff_stride, txfm_param); |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 253 | break; |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 254 | case TX_32X64: |
| 255 | highbd_fwd_txfm_32x64(src_diff, coeff, diff_stride, txfm_param); |
| 256 | break; |
| 257 | case TX_64X32: |
| 258 | highbd_fwd_txfm_64x32(src_diff, coeff, diff_stride, txfm_param); |
| 259 | break; |
Jerome Jiang | 454d116 | 2021-01-06 20:51:03 -0800 | [diff] [blame] | 260 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 261 | case TX_32X32: |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 262 | highbd_fwd_txfm_32x32(src_diff, coeff, diff_stride, txfm_param); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 263 | break; |
| 264 | case TX_16X16: |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 265 | highbd_fwd_txfm_16x16(src_diff, coeff, diff_stride, txfm_param); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 266 | break; |
| 267 | case TX_8X8: |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 268 | highbd_fwd_txfm_8x8(src_diff, coeff, diff_stride, txfm_param); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 269 | break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 270 | case TX_4X8: |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 271 | highbd_fwd_txfm_4x8(src_diff, coeff, diff_stride, txfm_param); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 272 | break; |
| 273 | case TX_8X4: |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 274 | highbd_fwd_txfm_8x4(src_diff, coeff, diff_stride, txfm_param); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 275 | break; |
| 276 | case TX_8X16: |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 277 | highbd_fwd_txfm_8x16(src_diff, coeff, diff_stride, txfm_param); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 278 | break; |
| 279 | case TX_16X8: |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 280 | highbd_fwd_txfm_16x8(src_diff, coeff, diff_stride, txfm_param); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 281 | break; |
| 282 | case TX_16X32: |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 283 | highbd_fwd_txfm_16x32(src_diff, coeff, diff_stride, txfm_param); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 284 | break; |
| 285 | case TX_32X16: |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 286 | highbd_fwd_txfm_32x16(src_diff, coeff, diff_stride, txfm_param); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 287 | break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 288 | case TX_4X4: |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 289 | highbd_fwd_txfm_4x4(src_diff, coeff, diff_stride, txfm_param); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 290 | break; |
Jerome Jiang | 454d116 | 2021-01-06 20:51:03 -0800 | [diff] [blame] | 291 | #if !CONFIG_REALTIME_ONLY |
Debargha Mukherjee | 845057f | 2017-11-13 07:03:36 -0800 | [diff] [blame] | 292 | case TX_4X16: |
| 293 | highbd_fwd_txfm_4x16(src_diff, coeff, diff_stride, txfm_param); |
| 294 | break; |
| 295 | case TX_16X4: |
| 296 | highbd_fwd_txfm_16x4(src_diff, coeff, diff_stride, txfm_param); |
| 297 | break; |
| 298 | case TX_8X32: |
| 299 | highbd_fwd_txfm_8x32(src_diff, coeff, diff_stride, txfm_param); |
| 300 | break; |
| 301 | case TX_32X8: |
| 302 | highbd_fwd_txfm_32x8(src_diff, coeff, diff_stride, txfm_param); |
| 303 | break; |
Jerome Jiang | 454d116 | 2021-01-06 20:51:03 -0800 | [diff] [blame] | 304 | case TX_16X64: |
| 305 | highbd_fwd_txfm_16x64(src_diff, coeff, diff_stride, txfm_param); |
| 306 | break; |
| 307 | case TX_64X16: |
| 308 | highbd_fwd_txfm_64x16(src_diff, coeff, diff_stride, txfm_param); |
| 309 | break; |
| 310 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 311 | default: assert(0); break; |
| 312 | } |
| 313 | } |
Angie Chiang | fd4a8f3 | 2021-03-31 12:18:31 -0700 | [diff] [blame] | 314 | |
Anupam Pandey | 431a11d | 2023-08-24 11:28:45 +0530 | [diff] [blame] | 315 | #if CONFIG_AV1_HIGHBITDEPTH |
Wan-Teh Chang | 12c64e8 | 2024-08-08 16:02:19 -0700 | [diff] [blame] | 316 | static inline void highbd_wht_fwd_txfm(TX_SIZE tx_size, const int16_t *src_diff, |
Anupam Pandey | 431a11d | 2023-08-24 11:28:45 +0530 | [diff] [blame] | 317 | ptrdiff_t src_stride, |
| 318 | tran_low_t *coeff) { |
| 319 | switch (tx_size) { |
| 320 | // As the output transform co-efficients of 4x4 Hadamard transform can be |
| 321 | // represented using 15 bits (for 12-bit clip) use lowbd variant of |
| 322 | // hadamard_4x4. |
| 323 | case TX_4X4: aom_hadamard_4x4(src_diff, src_stride, coeff); break; |
| 324 | case TX_8X8: aom_highbd_hadamard_8x8(src_diff, src_stride, coeff); break; |
| 325 | case TX_16X16: |
| 326 | aom_highbd_hadamard_16x16(src_diff, src_stride, coeff); |
| 327 | break; |
| 328 | case TX_32X32: |
| 329 | aom_highbd_hadamard_32x32(src_diff, src_stride, coeff); |
| 330 | break; |
| 331 | default: assert(0); |
| 332 | } |
| 333 | } |
| 334 | #endif // CONFIG_AV1_HIGHBITDEPTH |
| 335 | |
Wan-Teh Chang | 12c64e8 | 2024-08-08 16:02:19 -0700 | [diff] [blame] | 336 | static inline void wht_fwd_txfm(TX_SIZE tx_size, const int16_t *src_diff, |
Anupam Pandey | 431a11d | 2023-08-24 11:28:45 +0530 | [diff] [blame] | 337 | ptrdiff_t src_stride, tran_low_t *coeff) { |
| 338 | switch (tx_size) { |
| 339 | case TX_4X4: aom_hadamard_4x4(src_diff, src_stride, coeff); break; |
| 340 | case TX_8X8: aom_hadamard_8x8(src_diff, src_stride, coeff); break; |
| 341 | case TX_16X16: aom_hadamard_16x16(src_diff, src_stride, coeff); break; |
| 342 | case TX_32X32: aom_hadamard_32x32(src_diff, src_stride, coeff); break; |
| 343 | default: assert(0); |
| 344 | } |
| 345 | } |
| 346 | |
Angie Chiang | fd4a8f3 | 2021-03-31 12:18:31 -0700 | [diff] [blame] | 347 | void av1_quick_txfm(int use_hadamard, TX_SIZE tx_size, BitDepthInfo bd_info, |
| 348 | const int16_t *src_diff, int src_stride, |
| 349 | tran_low_t *coeff) { |
| 350 | if (use_hadamard) { |
Anupam Pandey | 431a11d | 2023-08-24 11:28:45 +0530 | [diff] [blame] | 351 | #if CONFIG_AV1_HIGHBITDEPTH |
| 352 | if (bd_info.use_highbitdepth_buf) { |
| 353 | highbd_wht_fwd_txfm(tx_size, src_diff, src_stride, coeff); |
| 354 | } else { |
| 355 | wht_fwd_txfm(tx_size, src_diff, src_stride, coeff); |
Angie Chiang | fd4a8f3 | 2021-03-31 12:18:31 -0700 | [diff] [blame] | 356 | } |
Anupam Pandey | 431a11d | 2023-08-24 11:28:45 +0530 | [diff] [blame] | 357 | #else |
| 358 | wht_fwd_txfm(tx_size, src_diff, src_stride, coeff); |
| 359 | #endif // CONFIG_AV1_HIGHBITDEPTH |
Angie Chiang | fd4a8f3 | 2021-03-31 12:18:31 -0700 | [diff] [blame] | 360 | } else { |
| 361 | TxfmParam txfm_param; |
| 362 | txfm_param.tx_type = DCT_DCT; |
| 363 | txfm_param.tx_size = tx_size; |
| 364 | txfm_param.lossless = 0; |
| 365 | txfm_param.bd = bd_info.bit_depth; |
| 366 | txfm_param.is_hbd = bd_info.use_highbitdepth_buf; |
| 367 | txfm_param.tx_set_type = EXT_TX_SET_ALL16; |
| 368 | av1_fwd_txfm(src_diff, coeff, src_stride, &txfm_param); |
| 369 | } |
| 370 | } |