blob: 85f4b7d9b5759d7732ed4b0f4773148a5d4f19c1 [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu2ab7ff02016-09-02 12:04:54 -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
Yaowu Xuf883b422016-08-30 14:01:10 -070012#include "./av1_rtcd.h"
13#include "./aom_config.h"
14#include "./aom_dsp_rtcd.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070015
16#include "av1/common/idct.h"
17#include "av1/encoder/hybrid_fwd_txfm.h"
18
Timothy B. Terriberryfe67ed62017-04-26 16:53:47 -070019#if CONFIG_CHROMA_2X2
Jingning Han12402222016-11-29 15:43:32 -080020static void fwd_txfm_2x2(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -070021 int diff_stride, TxfmParam *txfm_param) {
Jingning Han12402222016-11-29 15:43:32 -080022 tran_high_t a1 = src_diff[0];
23 tran_high_t b1 = src_diff[1];
24 tran_high_t c1 = src_diff[diff_stride];
25 tran_high_t d1 = src_diff[1 + diff_stride];
26
27 tran_high_t a2 = a1 + c1;
28 tran_high_t b2 = b1 + d1;
29 tran_high_t c2 = a1 - c1;
30 tran_high_t d2 = b1 - d1;
31
32 a1 = a2 + b2;
33 b1 = a2 - b2;
34 c1 = c2 + d2;
35 d1 = c2 - d2;
36
37 coeff[0] = (tran_low_t)(4 * a1);
38 coeff[1] = (tran_low_t)(4 * b1);
39 coeff[2] = (tran_low_t)(4 * c1);
40 coeff[3] = (tran_low_t)(4 * d1);
41
Lester Lu27319b62017-07-10 16:57:15 -070042 (void)txfm_param;
Jingning Han12402222016-11-29 15:43:32 -080043}
44#endif
45
Yaowu Xuc27fc142016-08-22 16:08:15 -070046static void fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -070047 int diff_stride, TxfmParam *txfm_param) {
48 if (txfm_param->lossless) {
49 assert(txfm_param->tx_type == DCT_DCT);
Yaowu Xuf883b422016-08-30 14:01:10 -070050 av1_fwht4x4(src_diff, coeff, diff_stride);
Yaowu Xuc27fc142016-08-22 16:08:15 -070051 return;
52 }
53
Lester Luad8290b2017-06-12 18:26:18 -070054#if CONFIG_LGT
55 // only C version has LGTs
Lester Lu27319b62017-07-10 16:57:15 -070056 av1_fht4x4_c(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -070057#else
Lester Lu27319b62017-07-10 16:57:15 -070058 av1_fht4x4(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -070059#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -070060}
61
Yaowu Xuc27fc142016-08-22 16:08:15 -070062static void fwd_txfm_4x8(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -070063 int diff_stride, TxfmParam *txfm_param) {
Lester Luad8290b2017-06-12 18:26:18 -070064#if CONFIG_LGT
Lester Lu27319b62017-07-10 16:57:15 -070065 av1_fht4x8_c(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -070066#else
Lester Lu27319b62017-07-10 16:57:15 -070067 av1_fht4x8(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -070068#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -070069}
70
71static void fwd_txfm_8x4(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -070072 int diff_stride, TxfmParam *txfm_param) {
Lester Luad8290b2017-06-12 18:26:18 -070073#if CONFIG_LGT
Lester Lu27319b62017-07-10 16:57:15 -070074 av1_fht8x4_c(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -070075#else
Lester Lu27319b62017-07-10 16:57:15 -070076 av1_fht8x4(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -070077#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -070078}
79
80static void fwd_txfm_8x16(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -070081 int diff_stride, TxfmParam *txfm_param) {
Lester Luad8290b2017-06-12 18:26:18 -070082#if CONFIG_LGT
Lester Lu27319b62017-07-10 16:57:15 -070083 av1_fht8x16_c(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -070084#else
Lester Lu27319b62017-07-10 16:57:15 -070085 av1_fht8x16(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -070086#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -070087}
88
89static void fwd_txfm_16x8(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -070090 int diff_stride, TxfmParam *txfm_param) {
Lester Luad8290b2017-06-12 18:26:18 -070091#if CONFIG_LGT
Lester Lu27319b62017-07-10 16:57:15 -070092 av1_fht16x8_c(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -070093#else
Lester Lu27319b62017-07-10 16:57:15 -070094 av1_fht16x8(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -070095#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -070096}
97
98static void fwd_txfm_16x32(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -070099 int diff_stride, TxfmParam *txfm_param) {
100 av1_fht16x32(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700101}
102
103static void fwd_txfm_32x16(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700104 int diff_stride, TxfmParam *txfm_param) {
105 av1_fht32x16(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700106}
Yaowu Xuc27fc142016-08-22 16:08:15 -0700107
108static void fwd_txfm_8x8(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700109 int diff_stride, TxfmParam *txfm_param) {
Lester Luad8290b2017-06-12 18:26:18 -0700110#if CONFIG_LGT
Lester Lu27319b62017-07-10 16:57:15 -0700111 av1_fht8x8_c(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -0700112#else
Lester Lu27319b62017-07-10 16:57:15 -0700113 av1_fht8x8(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -0700114#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -0700115}
116
117static void fwd_txfm_16x16(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700118 int diff_stride, TxfmParam *txfm_param) {
119 av1_fht16x16(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700120}
121
Angie Chiang8fd2d7a2017-01-03 15:50:15 -0800122static void fwd_txfm_32x32(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700123 int diff_stride, TxfmParam *txfm_param) {
Sarah Parker53f93db2017-07-11 17:20:04 -0700124#if CONFIG_MRC_TX
125 // MRC_DCT currently only has a C implementation
126 if (txfm_param->tx_type == MRC_DCT) {
127 av1_fht32x32_c(src_diff, coeff, diff_stride, txfm_param);
128 return;
129 }
130#endif // CONFIG_MRC_TX
Lester Lu27319b62017-07-10 16:57:15 -0700131 av1_fht32x32(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700132}
133
Debargha Mukherjee6a47cff2016-11-02 14:57:42 -0700134#if CONFIG_TX64X64
135static void fwd_txfm_64x64(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700136 int diff_stride, TxfmParam *txfm_param) {
Debargha Mukherjee6a47cff2016-11-02 14:57:42 -0700137#if CONFIG_EXT_TX
Lester Lu27319b62017-07-10 16:57:15 -0700138 if (txfm_param->tx_type == IDTX)
139 av1_fwd_idtx_c(src_diff, coeff, diff_stride, 64, txfm_param->tx_type);
Angie Chiang2cc057c2017-01-03 18:31:47 -0800140 else
141#endif
Lester Lu27319b62017-07-10 16:57:15 -0700142 av1_fht64x64(src_diff, coeff, diff_stride, txfm_param);
Debargha Mukherjee6a47cff2016-11-02 14:57:42 -0700143}
144#endif // CONFIG_TX64X64
145
Yue Chend6bdd462017-07-19 16:05:43 -0700146#if CONFIG_RECT_TX_EXT && (CONFIG_EXT_TX || CONFIG_VAR_TX)
Yue Chen56e226e2017-05-02 16:21:40 -0700147static void fwd_txfm_16x4(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700148 int diff_stride, TxfmParam *txfm_param) {
Lester Luad8290b2017-06-12 18:26:18 -0700149#if CONFIG_LGT
Lester Lu27319b62017-07-10 16:57:15 -0700150 av1_fht16x4_c(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -0700151#else
Lester Lu27319b62017-07-10 16:57:15 -0700152 av1_fht16x4(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -0700153#endif
Yue Chen56e226e2017-05-02 16:21:40 -0700154}
155
156static void fwd_txfm_4x16(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700157 int diff_stride, TxfmParam *txfm_param) {
Lester Luad8290b2017-06-12 18:26:18 -0700158#if CONFIG_LGT
Lester Lu27319b62017-07-10 16:57:15 -0700159 av1_fht4x16_c(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -0700160#else
Lester Lu27319b62017-07-10 16:57:15 -0700161 av1_fht4x16(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -0700162#endif
Yue Chen56e226e2017-05-02 16:21:40 -0700163}
164
165static void fwd_txfm_32x8(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700166 int diff_stride, TxfmParam *txfm_param) {
Lester Luad8290b2017-06-12 18:26:18 -0700167#if CONFIG_LGT
Lester Lu27319b62017-07-10 16:57:15 -0700168 av1_fht32x8_c(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -0700169#else
Lester Lu27319b62017-07-10 16:57:15 -0700170 av1_fht32x8(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -0700171#endif
Yue Chen56e226e2017-05-02 16:21:40 -0700172}
173
174static void fwd_txfm_8x32(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700175 int diff_stride, TxfmParam *txfm_param) {
Lester Luad8290b2017-06-12 18:26:18 -0700176#if CONFIG_LGT
Lester Lu27319b62017-07-10 16:57:15 -0700177 av1_fht8x32_c(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -0700178#else
Lester Lu27319b62017-07-10 16:57:15 -0700179 av1_fht8x32(src_diff, coeff, diff_stride, txfm_param);
Lester Luad8290b2017-06-12 18:26:18 -0700180#endif
Yue Chen56e226e2017-05-02 16:21:40 -0700181}
Yue Chend6bdd462017-07-19 16:05:43 -0700182#endif
Yue Chen56e226e2017-05-02 16:21:40 -0700183
Timothy B. Terriberryfe67ed62017-04-26 16:53:47 -0700184#if CONFIG_CHROMA_2X2
Jingning Hanb1ed8d72016-12-19 10:21:14 -0800185static void highbd_fwd_txfm_2x2(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700186 int diff_stride, TxfmParam *txfm_param) {
Jingning Hanb1ed8d72016-12-19 10:21:14 -0800187 tran_high_t a1 = src_diff[0];
188 tran_high_t b1 = src_diff[1];
189 tran_high_t c1 = src_diff[diff_stride];
190 tran_high_t d1 = src_diff[1 + diff_stride];
191
192 tran_high_t a2 = a1 + c1;
193 tran_high_t b2 = b1 + d1;
194 tran_high_t c2 = a1 - c1;
195 tran_high_t d2 = b1 - d1;
196
197 a1 = a2 + b2;
198 b1 = a2 - b2;
199 c1 = c2 + d2;
200 d1 = c2 - d2;
201
202 coeff[0] = (tran_low_t)(4 * a1);
203 coeff[1] = (tran_low_t)(4 * b1);
204 coeff[2] = (tran_low_t)(4 * c1);
205 coeff[3] = (tran_low_t)(4 * d1);
206
Lester Lu27319b62017-07-10 16:57:15 -0700207 (void)txfm_param;
Jingning Hanb1ed8d72016-12-19 10:21:14 -0800208}
209#endif
210
Yaowu Xuc27fc142016-08-22 16:08:15 -0700211static void highbd_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700212 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700213 int32_t *dst_coeff = (int32_t *)coeff;
Lester Lu27319b62017-07-10 16:57:15 -0700214 const int tx_type = txfm_param->tx_type;
215 const int bd = txfm_param->bd;
216 if (txfm_param->lossless) {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700217 assert(tx_type == DCT_DCT);
Yaowu Xuf883b422016-08-30 14:01:10 -0700218 av1_highbd_fwht4x4(src_diff, coeff, diff_stride);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700219 return;
220 }
Yaowu Xuc27fc142016-08-22 16:08:15 -0700221 switch (tx_type) {
222 case DCT_DCT:
223 case ADST_DCT:
224 case DCT_ADST:
225 case ADST_ADST:
Sarah Parker31c66502017-05-19 16:51:07 -0700226 // fallthrough intended
Yi Luo0f4195c2017-06-27 16:07:28 -0700227 av1_fwd_txfm2d_4x4(src_diff, dst_coeff, diff_stride, tx_type, bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700228 break;
229#if CONFIG_EXT_TX
230 case FLIPADST_DCT:
231 case DCT_FLIPADST:
232 case FLIPADST_FLIPADST:
233 case ADST_FLIPADST:
234 case FLIPADST_ADST:
Sarah Parker31c66502017-05-19 16:51:07 -0700235 // fallthrough intended
Yi Luo0f4195c2017-06-27 16:07:28 -0700236 av1_fwd_txfm2d_4x4(src_diff, dst_coeff, diff_stride, tx_type, bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700237 break;
Sarah Parker31c66502017-05-19 16:51:07 -0700238 // use the c version for anything including identity for now
Yaowu Xuc27fc142016-08-22 16:08:15 -0700239 case V_DCT:
240 case H_DCT:
241 case V_ADST:
242 case H_ADST:
243 case V_FLIPADST:
244 case H_FLIPADST:
Sarah Parker31c66502017-05-19 16:51:07 -0700245 case IDTX:
246 // fallthrough intended
Yi Luo0f4195c2017-06-27 16:07:28 -0700247 av1_fwd_txfm2d_4x4_c(src_diff, dst_coeff, diff_stride, tx_type, bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700248 break;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700249#endif // CONFIG_EXT_TX
250 default: assert(0);
251 }
252}
253
Yaowu Xuc27fc142016-08-22 16:08:15 -0700254static void highbd_fwd_txfm_4x8(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700255 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700256 int32_t *dst_coeff = (int32_t *)coeff;
Lester Lu27319b62017-07-10 16:57:15 -0700257 av1_fwd_txfm2d_4x8_c(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
258 txfm_param->bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700259}
260
261static void highbd_fwd_txfm_8x4(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700262 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700263 int32_t *dst_coeff = (int32_t *)coeff;
Lester Lu27319b62017-07-10 16:57:15 -0700264 av1_fwd_txfm2d_8x4_c(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
265 txfm_param->bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700266}
267
268static void highbd_fwd_txfm_8x16(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700269 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700270 int32_t *dst_coeff = (int32_t *)coeff;
Lester Lu27319b62017-07-10 16:57:15 -0700271 av1_fwd_txfm2d_8x16_c(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
272 txfm_param->bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700273}
274
275static void highbd_fwd_txfm_16x8(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700276 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700277 int32_t *dst_coeff = (int32_t *)coeff;
Lester Lu27319b62017-07-10 16:57:15 -0700278 av1_fwd_txfm2d_16x8_c(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
279 txfm_param->bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700280}
281
282static void highbd_fwd_txfm_16x32(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700283 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700284 int32_t *dst_coeff = (int32_t *)coeff;
Lester Lu27319b62017-07-10 16:57:15 -0700285 av1_fwd_txfm2d_16x32_c(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
286 txfm_param->bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700287}
288
289static void highbd_fwd_txfm_32x16(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700290 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700291 int32_t *dst_coeff = (int32_t *)coeff;
Lester Lu27319b62017-07-10 16:57:15 -0700292 av1_fwd_txfm2d_32x16_c(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
293 txfm_param->bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700294}
Yaowu Xuc27fc142016-08-22 16:08:15 -0700295
296static void highbd_fwd_txfm_8x8(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700297 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700298 int32_t *dst_coeff = (int32_t *)coeff;
Lester Lu27319b62017-07-10 16:57:15 -0700299 const int tx_type = txfm_param->tx_type;
300 const int bd = txfm_param->bd;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700301 switch (tx_type) {
302 case DCT_DCT:
303 case ADST_DCT:
304 case DCT_ADST:
305 case ADST_ADST:
Sarah Parker31c66502017-05-19 16:51:07 -0700306 // fallthrough intended
Yi Luo0f4195c2017-06-27 16:07:28 -0700307 av1_fwd_txfm2d_8x8(src_diff, dst_coeff, diff_stride, tx_type, bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700308 break;
309#if CONFIG_EXT_TX
310 case FLIPADST_DCT:
311 case DCT_FLIPADST:
312 case FLIPADST_FLIPADST:
313 case ADST_FLIPADST:
314 case FLIPADST_ADST:
Sarah Parker31c66502017-05-19 16:51:07 -0700315 // fallthrough intended
Yi Luo0f4195c2017-06-27 16:07:28 -0700316 av1_fwd_txfm2d_8x8(src_diff, dst_coeff, diff_stride, tx_type, bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700317 break;
Sarah Parker31c66502017-05-19 16:51:07 -0700318 // use the c version for anything including identity for now
Yaowu Xuc27fc142016-08-22 16:08:15 -0700319 case V_DCT:
320 case H_DCT:
321 case V_ADST:
322 case H_ADST:
323 case V_FLIPADST:
324 case H_FLIPADST:
Sarah Parker31c66502017-05-19 16:51:07 -0700325 case IDTX:
326 // fallthrough intended
Yi Luo0f4195c2017-06-27 16:07:28 -0700327 av1_fwd_txfm2d_8x8_c(src_diff, dst_coeff, diff_stride, tx_type, bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700328 break;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700329#endif // CONFIG_EXT_TX
330 default: assert(0);
331 }
332}
333
334static void highbd_fwd_txfm_16x16(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700335 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700336 int32_t *dst_coeff = (int32_t *)coeff;
Lester Lu27319b62017-07-10 16:57:15 -0700337 const int tx_type = txfm_param->tx_type;
338 const int bd = txfm_param->bd;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700339 switch (tx_type) {
340 case DCT_DCT:
341 case ADST_DCT:
342 case DCT_ADST:
343 case ADST_ADST:
Sarah Parker31c66502017-05-19 16:51:07 -0700344 // fallthrough intended
Yi Luo0f4195c2017-06-27 16:07:28 -0700345 av1_fwd_txfm2d_16x16(src_diff, dst_coeff, diff_stride, tx_type, bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700346 break;
347#if CONFIG_EXT_TX
348 case FLIPADST_DCT:
349 case DCT_FLIPADST:
350 case FLIPADST_FLIPADST:
351 case ADST_FLIPADST:
352 case FLIPADST_ADST:
Sarah Parker31c66502017-05-19 16:51:07 -0700353 // fallthrough intended
Yi Luo0f4195c2017-06-27 16:07:28 -0700354 av1_fwd_txfm2d_16x16(src_diff, dst_coeff, diff_stride, tx_type, bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700355 break;
Sarah Parker31c66502017-05-19 16:51:07 -0700356 // use the c version for anything including identity for now
Yaowu Xuc27fc142016-08-22 16:08:15 -0700357 case V_DCT:
358 case H_DCT:
359 case V_ADST:
360 case H_ADST:
361 case V_FLIPADST:
362 case H_FLIPADST:
Sarah Parker31c66502017-05-19 16:51:07 -0700363 case IDTX:
364 // fallthrough intended
Yi Luo0f4195c2017-06-27 16:07:28 -0700365 av1_fwd_txfm2d_16x16_c(src_diff, dst_coeff, diff_stride, tx_type, bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700366 break;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700367#endif // CONFIG_EXT_TX
368 default: assert(0);
369 }
370}
371
Angie Chiang8fd2d7a2017-01-03 15:50:15 -0800372static void highbd_fwd_txfm_32x32(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700373 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700374 int32_t *dst_coeff = (int32_t *)coeff;
Lester Lu27319b62017-07-10 16:57:15 -0700375 const int tx_type = txfm_param->tx_type;
376 const int bd = txfm_param->bd;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700377 switch (tx_type) {
378 case DCT_DCT:
Yaowu Xuc27fc142016-08-22 16:08:15 -0700379 case ADST_DCT:
380 case DCT_ADST:
381 case ADST_ADST:
Sarah Parker31c66502017-05-19 16:51:07 -0700382 // fallthrough intended
Yi Luo0f4195c2017-06-27 16:07:28 -0700383 av1_fwd_txfm2d_32x32(src_diff, dst_coeff, diff_stride, tx_type, bd);
Sarah Parker31c66502017-05-19 16:51:07 -0700384 break;
385#if CONFIG_EXT_TX
Yaowu Xuc27fc142016-08-22 16:08:15 -0700386 case FLIPADST_DCT:
387 case DCT_FLIPADST:
388 case FLIPADST_FLIPADST:
389 case ADST_FLIPADST:
390 case FLIPADST_ADST:
Sarah Parker31c66502017-05-19 16:51:07 -0700391 // fallthrough intended
Yi Luo0f4195c2017-06-27 16:07:28 -0700392 av1_fwd_txfm2d_32x32(src_diff, dst_coeff, diff_stride, tx_type, bd);
Sarah Parker31c66502017-05-19 16:51:07 -0700393 break;
394 // use the c version for anything including identity for now
Yaowu Xuc27fc142016-08-22 16:08:15 -0700395 case V_DCT:
396 case H_DCT:
397 case V_ADST:
398 case H_ADST:
399 case V_FLIPADST:
400 case H_FLIPADST:
Sarah Parker31c66502017-05-19 16:51:07 -0700401 case IDTX:
402 // fallthrough intended
Yi Luo0f4195c2017-06-27 16:07:28 -0700403 av1_fwd_txfm2d_32x32_c(src_diff, dst_coeff, diff_stride, tx_type, bd);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700404 break;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700405#endif // CONFIG_EXT_TX
Sarah Parker31c66502017-05-19 16:51:07 -0700406 default: assert(0);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700407 }
408}
Debargha Mukherjee6a47cff2016-11-02 14:57:42 -0700409
410#if CONFIG_TX64X64
411static void highbd_fwd_txfm_64x64(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700412 int diff_stride, TxfmParam *txfm_param) {
Yi Luo0f4195c2017-06-27 16:07:28 -0700413 int32_t *dst_coeff = (int32_t *)coeff;
Lester Lu27319b62017-07-10 16:57:15 -0700414 const int tx_type = txfm_param->tx_type;
415 const int bd = txfm_param->bd;
Debargha Mukherjee6a47cff2016-11-02 14:57:42 -0700416 switch (tx_type) {
417 case DCT_DCT:
Yi Luo0f4195c2017-06-27 16:07:28 -0700418 av1_fwd_txfm2d_64x64(src_diff, dst_coeff, diff_stride, tx_type, bd);
Debargha Mukherjee6a47cff2016-11-02 14:57:42 -0700419 break;
420#if CONFIG_EXT_TX
421 case ADST_DCT:
422 case DCT_ADST:
423 case ADST_ADST:
424 case FLIPADST_DCT:
425 case DCT_FLIPADST:
426 case FLIPADST_FLIPADST:
427 case ADST_FLIPADST:
428 case FLIPADST_ADST:
429 case V_DCT:
430 case H_DCT:
431 case V_ADST:
432 case H_ADST:
433 case V_FLIPADST:
434 case H_FLIPADST:
Sarah Parker31c66502017-05-19 16:51:07 -0700435 // TODO(sarahparker)
436 // I've deleted the 64x64 implementations that existed in lieu
437 // of adst, flipadst and identity for simplicity but will bring back
438 // in a later change. This shouldn't impact performance since
439 // DCT_DCT is the only extended type currently allowed for 64x64,
440 // as dictated by get_ext_tx_set_type in blockd.h.
Yi Luo0f4195c2017-06-27 16:07:28 -0700441 av1_fwd_txfm2d_64x64_c(src_diff, dst_coeff, diff_stride, DCT_DCT, bd);
Debargha Mukherjee6a47cff2016-11-02 14:57:42 -0700442 break;
Lester Lud8b1ddc2017-07-06 16:13:29 -0700443 case IDTX:
444 av1_fwd_idtx_c(src_diff, dst_coeff, diff_stride, 64, tx_type);
445 break;
Debargha Mukherjee6a47cff2016-11-02 14:57:42 -0700446#endif // CONFIG_EXT_TX
447 default: assert(0); break;
448 }
449}
450#endif // CONFIG_TX64X64
Yaowu Xuc27fc142016-08-22 16:08:15 -0700451
hui suf11fb882017-03-27 14:56:33 -0700452void av1_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff, int diff_stride,
Lester Lu27319b62017-07-10 16:57:15 -0700453 TxfmParam *txfm_param) {
454 const TX_SIZE tx_size = txfm_param->tx_size;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700455 switch (tx_size) {
Debargha Mukherjee6a47cff2016-11-02 14:57:42 -0700456#if CONFIG_TX64X64
457 case TX_64X64:
Lester Lu27319b62017-07-10 16:57:15 -0700458 fwd_txfm_64x64(src_diff, coeff, diff_stride, txfm_param);
Debargha Mukherjee6a47cff2016-11-02 14:57:42 -0700459 break;
460#endif // CONFIG_TX64X64
Yaowu Xuc27fc142016-08-22 16:08:15 -0700461 case TX_32X32:
Lester Lu27319b62017-07-10 16:57:15 -0700462 fwd_txfm_32x32(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700463 break;
464 case TX_16X16:
Lester Lu27319b62017-07-10 16:57:15 -0700465 fwd_txfm_16x16(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700466 break;
Lester Lu27319b62017-07-10 16:57:15 -0700467 case TX_8X8: fwd_txfm_8x8(src_diff, coeff, diff_stride, txfm_param); break;
468 case TX_4X8: fwd_txfm_4x8(src_diff, coeff, diff_stride, txfm_param); break;
469 case TX_8X4: fwd_txfm_8x4(src_diff, coeff, diff_stride, txfm_param); break;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700470 case TX_8X16:
Lester Lu27319b62017-07-10 16:57:15 -0700471 fwd_txfm_8x16(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700472 break;
473 case TX_16X8:
Lester Lu27319b62017-07-10 16:57:15 -0700474 fwd_txfm_16x8(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700475 break;
476 case TX_16X32:
Lester Lu27319b62017-07-10 16:57:15 -0700477 fwd_txfm_16x32(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700478 break;
479 case TX_32X16:
Lester Lu27319b62017-07-10 16:57:15 -0700480 fwd_txfm_32x16(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700481 break;
Lester Lu27319b62017-07-10 16:57:15 -0700482 case TX_4X4: fwd_txfm_4x4(src_diff, coeff, diff_stride, txfm_param); break;
Timothy B. Terriberryfe67ed62017-04-26 16:53:47 -0700483#if CONFIG_CHROMA_2X2
Lester Lu27319b62017-07-10 16:57:15 -0700484 case TX_2X2: fwd_txfm_2x2(src_diff, coeff, diff_stride, txfm_param); break;
Jingning Han12402222016-11-29 15:43:32 -0800485#endif
Yue Chend6bdd462017-07-19 16:05:43 -0700486#if CONFIG_RECT_TX_EXT && (CONFIG_EXT_TX || CONFIG_VAR_TX)
Yue Chen56e226e2017-05-02 16:21:40 -0700487 case TX_4X16:
Lester Lu27319b62017-07-10 16:57:15 -0700488 fwd_txfm_4x16(src_diff, coeff, diff_stride, txfm_param);
Yue Chen56e226e2017-05-02 16:21:40 -0700489 break;
490 case TX_16X4:
Lester Lu27319b62017-07-10 16:57:15 -0700491 fwd_txfm_16x4(src_diff, coeff, diff_stride, txfm_param);
Yue Chen56e226e2017-05-02 16:21:40 -0700492 break;
493 case TX_8X32:
Lester Lu27319b62017-07-10 16:57:15 -0700494 fwd_txfm_8x32(src_diff, coeff, diff_stride, txfm_param);
Yue Chen56e226e2017-05-02 16:21:40 -0700495 break;
496 case TX_32X8:
Lester Lu27319b62017-07-10 16:57:15 -0700497 fwd_txfm_32x8(src_diff, coeff, diff_stride, txfm_param);
Yue Chen56e226e2017-05-02 16:21:40 -0700498 break;
Yue Chend6bdd462017-07-19 16:05:43 -0700499#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -0700500 default: assert(0); break;
501 }
502}
503
hui suf11fb882017-03-27 14:56:33 -0700504void av1_highbd_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff,
Lester Lu27319b62017-07-10 16:57:15 -0700505 int diff_stride, TxfmParam *txfm_param) {
506 const TX_SIZE tx_size = txfm_param->tx_size;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700507 switch (tx_size) {
Debargha Mukherjee6a47cff2016-11-02 14:57:42 -0700508#if CONFIG_TX64X64
509 case TX_64X64:
Lester Lu27319b62017-07-10 16:57:15 -0700510 highbd_fwd_txfm_64x64(src_diff, coeff, diff_stride, txfm_param);
Debargha Mukherjee6a47cff2016-11-02 14:57:42 -0700511 break;
512#endif // CONFIG_TX64X64
Yaowu Xuc27fc142016-08-22 16:08:15 -0700513 case TX_32X32:
Lester Lu27319b62017-07-10 16:57:15 -0700514 highbd_fwd_txfm_32x32(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700515 break;
516 case TX_16X16:
Lester Lu27319b62017-07-10 16:57:15 -0700517 highbd_fwd_txfm_16x16(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700518 break;
519 case TX_8X8:
Lester Lu27319b62017-07-10 16:57:15 -0700520 highbd_fwd_txfm_8x8(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700521 break;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700522 case TX_4X8:
Lester Lu27319b62017-07-10 16:57:15 -0700523 highbd_fwd_txfm_4x8(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700524 break;
525 case TX_8X4:
Lester Lu27319b62017-07-10 16:57:15 -0700526 highbd_fwd_txfm_8x4(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700527 break;
528 case TX_8X16:
Lester Lu27319b62017-07-10 16:57:15 -0700529 highbd_fwd_txfm_8x16(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700530 break;
531 case TX_16X8:
Lester Lu27319b62017-07-10 16:57:15 -0700532 highbd_fwd_txfm_16x8(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700533 break;
534 case TX_16X32:
Lester Lu27319b62017-07-10 16:57:15 -0700535 highbd_fwd_txfm_16x32(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700536 break;
537 case TX_32X16:
Lester Lu27319b62017-07-10 16:57:15 -0700538 highbd_fwd_txfm_32x16(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700539 break;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700540 case TX_4X4:
Lester Lu27319b62017-07-10 16:57:15 -0700541 highbd_fwd_txfm_4x4(src_diff, coeff, diff_stride, txfm_param);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700542 break;
Timothy B. Terriberryfe67ed62017-04-26 16:53:47 -0700543#if CONFIG_CHROMA_2X2
Jingning Hanb1ed8d72016-12-19 10:21:14 -0800544 case TX_2X2:
Lester Lu27319b62017-07-10 16:57:15 -0700545 highbd_fwd_txfm_2x2(src_diff, coeff, diff_stride, txfm_param);
Jingning Hanb1ed8d72016-12-19 10:21:14 -0800546 break;
547#endif
Yaowu Xuc27fc142016-08-22 16:08:15 -0700548 default: assert(0); break;
549 }
550}