blob: 4b7fec5b2762e70483649396b9e41fc0472c98f4 [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
James Zernb7c05bd2024-06-11 19:15:10 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
Yaowu Xuc27fc142016-08-22 16:08:15 -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.
Yaowu Xuc27fc142016-08-22 16:08:15 -070010 */
11
Tom Finegan60e653d2018-05-22 11:34:58 -070012#include "config/aom_config.h"
Tom Finegan44702c82018-05-22 13:00:39 -070013#include "config/av1_rtcd.h"
14#include "config/aom_dsp_rtcd.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070015
16#include "av1/common/idct.h"
Angie Chiangfd4a8f32021-03-31 12:18:31 -070017#include "av1/common/blockd.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070018#include "av1/encoder/hybrid_fwd_txfm.h"
19
Urvang Joshi8207b912018-05-07 14:37:51 -070020/* 4-point reversible, orthonormal Walsh-Hadamard in 3.5 adds, 0.5 shifts per
Kyle Siefring7bb4c542022-12-09 10:27:41 -050021 pixel.
22 Shared for both high and low bit depth.
23 */
Urvang Joshi8207b912018-05-07 14:37:51 -070024void 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 Siefring7bb4c542022-12-09 10:27:41 -050045 op[1] = (tran_low_t)c1;
46 op[2] = (tran_low_t)d1;
47 op[3] = (tran_low_t)b1;
Urvang Joshi8207b912018-05-07 14:37:51 -070048
49 ip_pass0++;
Kyle Siefring7bb4c542022-12-09 10:27:41 -050050 op += 4;
Urvang Joshi8207b912018-05-07 14:37:51 -070051 }
52 ip = output;
53 op = output;
54
55 for (i = 0; i < 4; i++) {
Kyle Siefring7bb4c542022-12-09 10:27:41 -050056 a1 = ip[4 * 0];
57 b1 = ip[4 * 1];
58 c1 = ip[4 * 2];
59 d1 = ip[4 * 3];
Urvang Joshi8207b912018-05-07 14:37:51 -070060
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 Siefring7bb4c542022-12-09 10:27:41 -050068 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 Joshi8207b912018-05-07 14:37:51 -070072
Kyle Siefring7bb4c542022-12-09 10:27:41 -050073 ip++;
74 op++;
Urvang Joshi8207b912018-05-07 14:37:51 -070075 }
76}
77
Yaowu Xuc27fc142016-08-22 16:08:15 -070078static void highbd_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -070079 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -070080 int32_t *dst_coeff = (int32_t *)coeff;
Urvang Joshi2283d372017-10-02 17:16:45 -070081 const TX_TYPE tx_type = txfm_param->tx_type;
Lester Lu27319b62017-07-10 16:57:15 -070082 const int bd = txfm_param->bd;
83 if (txfm_param->lossless) {
Yaowu Xuc27fc142016-08-22 16:08:15 -070084 assert(tx_type == DCT_DCT);
Kyle Siefring7bb4c542022-12-09 10:27:41 -050085 av1_fwht4x4(src_diff, coeff, diff_stride);
Yaowu Xuc27fc142016-08-22 16:08:15 -070086 return;
87 }
Aniket Dhok7629c382018-10-18 13:02:12 +053088 av1_fwd_txfm2d_4x4(src_diff, dst_coeff, diff_stride, tx_type, bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -070089}
90
Yaowu Xuc27fc142016-08-22 16:08:15 -070091static void highbd_fwd_txfm_4x8(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -070092 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -070093 int32_t *dst_coeff = (int32_t *)coeff;
Aniket Dhok7629c382018-10-18 13:02:12 +053094 av1_fwd_txfm2d_4x8(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
95 txfm_param->bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -070096}
97
98static void highbd_fwd_txfm_8x4(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -070099 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700100 int32_t *dst_coeff = (int32_t *)coeff;
Aniket Dhok7629c382018-10-18 13:02:12 +0530101 av1_fwd_txfm2d_8x4(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
102 txfm_param->bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700103}
104
105static void highbd_fwd_txfm_8x16(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700106 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700107 int32_t *dst_coeff = (int32_t *)coeff;
Venkatd04f6c52018-09-12 10:42:33 +0530108 const TX_TYPE tx_type = txfm_param->tx_type;
109 const int bd = txfm_param->bd;
Aniket Dhok7629c382018-10-18 13:02:12 +0530110 av1_fwd_txfm2d_8x16(src_diff, dst_coeff, diff_stride, tx_type, bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700111}
112
113static void highbd_fwd_txfm_16x8(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700114 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700115 int32_t *dst_coeff = (int32_t *)coeff;
Venkatd04f6c52018-09-12 10:42:33 +0530116 const TX_TYPE tx_type = txfm_param->tx_type;
117 const int bd = txfm_param->bd;
Aniket Dhok7629c382018-10-18 13:02:12 +0530118 av1_fwd_txfm2d_16x8(src_diff, dst_coeff, diff_stride, tx_type, bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700119}
120
121static void highbd_fwd_txfm_16x32(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700122 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700123 int32_t *dst_coeff = (int32_t *)coeff;
Aniket Dhok63adafd2018-10-22 17:51:52 +0530124 av1_fwd_txfm2d_16x32(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
125 txfm_param->bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700126}
127
128static void highbd_fwd_txfm_32x16(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700129 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700130 int32_t *dst_coeff = (int32_t *)coeff;
Aniket Dhok63adafd2018-10-22 17:51:52 +0530131 av1_fwd_txfm2d_32x16(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
132 txfm_param->bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700133}
Yaowu Xuc27fc142016-08-22 16:08:15 -0700134
Jerome Jiang454d1162021-01-06 20:51:03 -0800135#if !CONFIG_REALTIME_ONLY
Debargha Mukherjee845057f2017-11-13 07:03:36 -0800136static void highbd_fwd_txfm_16x4(const int16_t *src_diff, tran_low_t *coeff,
137 int diff_stride, TxfmParam *txfm_param) {
Debargha Mukherjee69f914a2017-11-15 20:58:23 -0800138 int32_t *dst_coeff = (int32_t *)coeff;
Aniket Dhok7629c382018-10-18 13:02:12 +0530139 av1_fwd_txfm2d_16x4(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
140 txfm_param->bd);
Debargha Mukherjee845057f2017-11-13 07:03:36 -0800141}
142
143static void highbd_fwd_txfm_4x16(const int16_t *src_diff, tran_low_t *coeff,
144 int diff_stride, TxfmParam *txfm_param) {
Debargha Mukherjee69f914a2017-11-15 20:58:23 -0800145 int32_t *dst_coeff = (int32_t *)coeff;
Aniket Dhok7629c382018-10-18 13:02:12 +0530146 av1_fwd_txfm2d_4x16(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
147 txfm_param->bd);
Debargha Mukherjee845057f2017-11-13 07:03:36 -0800148}
149
150static void highbd_fwd_txfm_32x8(const int16_t *src_diff, tran_low_t *coeff,
151 int diff_stride, TxfmParam *txfm_param) {
Debargha Mukherjee69f914a2017-11-15 20:58:23 -0800152 int32_t *dst_coeff = (int32_t *)coeff;
Aniket Dhok63adafd2018-10-22 17:51:52 +0530153 av1_fwd_txfm2d_32x8(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
154 txfm_param->bd);
Debargha Mukherjee845057f2017-11-13 07:03:36 -0800155}
156
157static void highbd_fwd_txfm_8x32(const int16_t *src_diff, tran_low_t *coeff,
158 int diff_stride, TxfmParam *txfm_param) {
Debargha Mukherjee69f914a2017-11-15 20:58:23 -0800159 int32_t *dst_coeff = (int32_t *)coeff;
Aniket Dhok63adafd2018-10-22 17:51:52 +0530160 av1_fwd_txfm2d_8x32(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
161 txfm_param->bd);
Debargha Mukherjee845057f2017-11-13 07:03:36 -0800162}
Jerome Jiang454d1162021-01-06 20:51:03 -0800163#endif
Debargha Mukherjee845057f2017-11-13 07:03:36 -0800164
Yaowu Xuc27fc142016-08-22 16:08:15 -0700165static void highbd_fwd_txfm_8x8(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700166 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700167 int32_t *dst_coeff = (int32_t *)coeff;
Urvang Joshi2283d372017-10-02 17:16:45 -0700168 const TX_TYPE tx_type = txfm_param->tx_type;
Lester Lu27319b62017-07-10 16:57:15 -0700169 const int bd = txfm_param->bd;
Aniket Dhok7629c382018-10-18 13:02:12 +0530170 av1_fwd_txfm2d_8x8(src_diff, dst_coeff, diff_stride, tx_type, bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700171}
172
173static void highbd_fwd_txfm_16x16(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700174 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700175 int32_t *dst_coeff = (int32_t *)coeff;
Urvang Joshi2283d372017-10-02 17:16:45 -0700176 const TX_TYPE tx_type = txfm_param->tx_type;
Lester Lu27319b62017-07-10 16:57:15 -0700177 const int bd = txfm_param->bd;
Aniket Dhok7629c382018-10-18 13:02:12 +0530178 av1_fwd_txfm2d_16x16(src_diff, dst_coeff, diff_stride, tx_type, bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700179}
180
Angie Chiang8fd2d7a2017-01-03 15:50:15 -0800181static void highbd_fwd_txfm_32x32(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700182 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700183 int32_t *dst_coeff = (int32_t *)coeff;
Urvang Joshi2283d372017-10-02 17:16:45 -0700184 const TX_TYPE tx_type = txfm_param->tx_type;
Lester Lu27319b62017-07-10 16:57:15 -0700185 const int bd = txfm_param->bd;
Aniket Dhok63adafd2018-10-22 17:51:52 +0530186 av1_fwd_txfm2d_32x32(src_diff, dst_coeff, diff_stride, tx_type, bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700187}
Debargha Mukherjee6a47cff2016-11-02 14:57:42 -0700188
Debargha Mukherjee2b435012017-09-28 08:30:35 -0700189static void highbd_fwd_txfm_32x64(const int16_t *src_diff, tran_low_t *coeff,
190 int diff_stride, TxfmParam *txfm_param) {
Hui Su98626d32018-04-13 12:08:48 -0700191 assert(txfm_param->tx_type == DCT_DCT);
Debargha Mukherjee2b435012017-09-28 08:30:35 -0700192 int32_t *dst_coeff = (int32_t *)coeff;
Debargha Mukherjee2b435012017-09-28 08:30:35 -0700193 const int bd = txfm_param->bd;
Satish Kumar Suman02526002018-10-17 17:51:49 +0530194 av1_fwd_txfm2d_32x64(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
195 bd);
Debargha Mukherjee2b435012017-09-28 08:30:35 -0700196}
197
198static void highbd_fwd_txfm_64x32(const int16_t *src_diff, tran_low_t *coeff,
199 int diff_stride, TxfmParam *txfm_param) {
Hui Su98626d32018-04-13 12:08:48 -0700200 assert(txfm_param->tx_type == DCT_DCT);
Debargha Mukherjee2b435012017-09-28 08:30:35 -0700201 int32_t *dst_coeff = (int32_t *)coeff;
Debargha Mukherjee2b435012017-09-28 08:30:35 -0700202 const int bd = txfm_param->bd;
Satish Kumar Suman02526002018-10-17 17:51:49 +0530203 av1_fwd_txfm2d_64x32(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
204 bd);
Debargha Mukherjee2b435012017-09-28 08:30:35 -0700205}
Debargha Mukherjee0254fee2017-12-02 09:08:52 -0800206
Jerome Jiang454d1162021-01-06 20:51:03 -0800207#if !CONFIG_REALTIME_ONLY
Debargha Mukherjee0254fee2017-12-02 09:08:52 -0800208static void highbd_fwd_txfm_16x64(const int16_t *src_diff, tran_low_t *coeff,
209 int diff_stride, TxfmParam *txfm_param) {
Hui Su98626d32018-04-13 12:08:48 -0700210 assert(txfm_param->tx_type == DCT_DCT);
Debargha Mukherjee0254fee2017-12-02 09:08:52 -0800211 int32_t *dst_coeff = (int32_t *)coeff;
Debargha Mukherjee0254fee2017-12-02 09:08:52 -0800212 const int bd = txfm_param->bd;
Satish Kumar Suman02526002018-10-17 17:51:49 +0530213 av1_fwd_txfm2d_16x64(src_diff, dst_coeff, diff_stride, DCT_DCT, bd);
Debargha Mukherjee0254fee2017-12-02 09:08:52 -0800214}
215
216static void highbd_fwd_txfm_64x16(const int16_t *src_diff, tran_low_t *coeff,
217 int diff_stride, TxfmParam *txfm_param) {
Hui Su98626d32018-04-13 12:08:48 -0700218 assert(txfm_param->tx_type == DCT_DCT);
Debargha Mukherjee0254fee2017-12-02 09:08:52 -0800219 int32_t *dst_coeff = (int32_t *)coeff;
Debargha Mukherjee0254fee2017-12-02 09:08:52 -0800220 const int bd = txfm_param->bd;
Satish Kumar Suman02526002018-10-17 17:51:49 +0530221 av1_fwd_txfm2d_64x16(src_diff, dst_coeff, diff_stride, DCT_DCT, bd);
Debargha Mukherjee0254fee2017-12-02 09:08:52 -0800222}
Jerome Jiang454d1162021-01-06 20:51:03 -0800223#endif
Debargha Mukherjee0254fee2017-12-02 09:08:52 -0800224
Debargha Mukherjee6a47cff2016-11-02 14:57:42 -0700225static void highbd_fwd_txfm_64x64(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700226 int diff_stride, TxfmParam *txfm_param) {
Hui Su98626d32018-04-13 12:08:48 -0700227 assert(txfm_param->tx_type == DCT_DCT);
Yi Luo0f4195c2017-06-27 16:07:28 -0700228 int32_t *dst_coeff = (int32_t *)coeff;
Lester Lu27319b62017-07-10 16:57:15 -0700229 const int bd = txfm_param->bd;
Hui Su98626d32018-04-13 12:08:48 -0700230 av1_fwd_txfm2d_64x64(src_diff, dst_coeff, diff_stride, DCT_DCT, bd);
Debargha Mukherjee6a47cff2016-11-02 14:57:42 -0700231}
Yaowu Xuc27fc142016-08-22 16:08:15 -0700232
hui suf11fb882017-03-27 14:56:33 -0700233void av1_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff, int diff_stride,
Lester Lu27319b62017-07-10 16:57:15 -0700234 TxfmParam *txfm_param) {
Angie Chiang7d8b13e2018-02-07 22:55:45 -0800235 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
241void 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 Xuc27fc142016-08-22 16:08:15 -0700244}
245
hui suf11fb882017-03-27 14:56:33 -0700246void av1_highbd_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700247 int diff_stride, TxfmParam *txfm_param) {
Sarah Parker90024e42017-10-06 16:50:47 -0700248 assert(av1_ext_tx_used[txfm_param->tx_set_type][txfm_param->tx_type]);
Lester Lu27319b62017-07-10 16:57:15 -0700249 const TX_SIZE tx_size = txfm_param->tx_size;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700250 switch (tx_size) {
Debargha Mukherjee6a47cff2016-11-02 14:57:42 -0700251 case TX_64X64:
Lester Lu27319b62017-07-10 16:57:15 -0700252 highbd_fwd_txfm_64x64(src_diff, coeff, diff_stride, txfm_param);
Debargha Mukherjee6a47cff2016-11-02 14:57:42 -0700253 break;
Debargha Mukherjee2b435012017-09-28 08:30:35 -0700254 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 Jiang454d1162021-01-06 20:51:03 -0800260
Yaowu Xuc27fc142016-08-22 16:08:15 -0700261 case TX_32X32:
Lester Lu27319b62017-07-10 16:57:15 -0700262 highbd_fwd_txfm_32x32(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700263 break;
264 case TX_16X16:
Lester Lu27319b62017-07-10 16:57:15 -0700265 highbd_fwd_txfm_16x16(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700266 break;
267 case TX_8X8:
Lester Lu27319b62017-07-10 16:57:15 -0700268 highbd_fwd_txfm_8x8(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700269 break;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700270 case TX_4X8:
Lester Lu27319b62017-07-10 16:57:15 -0700271 highbd_fwd_txfm_4x8(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700272 break;
273 case TX_8X4:
Lester Lu27319b62017-07-10 16:57:15 -0700274 highbd_fwd_txfm_8x4(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700275 break;
276 case TX_8X16:
Lester Lu27319b62017-07-10 16:57:15 -0700277 highbd_fwd_txfm_8x16(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700278 break;
279 case TX_16X8:
Lester Lu27319b62017-07-10 16:57:15 -0700280 highbd_fwd_txfm_16x8(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700281 break;
282 case TX_16X32:
Lester Lu27319b62017-07-10 16:57:15 -0700283 highbd_fwd_txfm_16x32(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700284 break;
285 case TX_32X16:
Lester Lu27319b62017-07-10 16:57:15 -0700286 highbd_fwd_txfm_32x16(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700287 break;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700288 case TX_4X4:
Lester Lu27319b62017-07-10 16:57:15 -0700289 highbd_fwd_txfm_4x4(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700290 break;
Jerome Jiang454d1162021-01-06 20:51:03 -0800291#if !CONFIG_REALTIME_ONLY
Debargha Mukherjee845057f2017-11-13 07:03:36 -0800292 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 Jiang454d1162021-01-06 20:51:03 -0800304 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 Xuc27fc142016-08-22 16:08:15 -0700311 default: assert(0); break;
312 }
313}
Angie Chiangfd4a8f32021-03-31 12:18:31 -0700314
Anupam Pandey431a11d2023-08-24 11:28:45 +0530315#if CONFIG_AV1_HIGHBITDEPTH
Wan-Teh Chang12c64e82024-08-08 16:02:19 -0700316static inline void highbd_wht_fwd_txfm(TX_SIZE tx_size, const int16_t *src_diff,
Anupam Pandey431a11d2023-08-24 11:28:45 +0530317 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 Chang12c64e82024-08-08 16:02:19 -0700336static inline void wht_fwd_txfm(TX_SIZE tx_size, const int16_t *src_diff,
Anupam Pandey431a11d2023-08-24 11:28:45 +0530337 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 Chiangfd4a8f32021-03-31 12:18:31 -0700347void 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 Pandey431a11d2023-08-24 11:28:45 +0530351#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 Chiangfd4a8f32021-03-31 12:18:31 -0700356 }
Anupam Pandey431a11d2023-08-24 11:28:45 +0530357#else
358 wht_fwd_txfm(tx_size, src_diff, src_stride, coeff);
359#endif // CONFIG_AV1_HIGHBITDEPTH
Angie Chiangfd4a8f32021-03-31 12:18:31 -0700360 } 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}