Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -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 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -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. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 12 | #include "./av1_rtcd.h" |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 13 | #include "aom_dsp/inv_txfm.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 14 | #include "av1/common/enums.h" |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 15 | #include "av1/common/av1_txfm.h" |
| 16 | #include "av1/common/av1_inv_txfm1d.h" |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 17 | #include "av1/common/av1_inv_txfm1d_cfg.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 18 | |
| 19 | static INLINE TxfmFunc inv_txfm_type_to_func(TXFM_TYPE txfm_type) { |
| 20 | switch (txfm_type) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 21 | case TXFM_TYPE_DCT4: return av1_idct4_new; |
| 22 | case TXFM_TYPE_DCT8: return av1_idct8_new; |
| 23 | case TXFM_TYPE_DCT16: return av1_idct16_new; |
| 24 | case TXFM_TYPE_DCT32: return av1_idct32_new; |
Urvang Joshi | 900643b | 2017-08-08 13:09:51 -0700 | [diff] [blame^] | 25 | #if CONFIG_TX64X64 |
| 26 | case TXFM_TYPE_DCT64: return av1_idct64_new; |
| 27 | #endif // CONFIG_TX64X64 |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 28 | case TXFM_TYPE_ADST4: return av1_iadst4_new; |
| 29 | case TXFM_TYPE_ADST8: return av1_iadst8_new; |
| 30 | case TXFM_TYPE_ADST16: return av1_iadst16_new; |
| 31 | case TXFM_TYPE_ADST32: return av1_iadst32_new; |
Sarah Parker | 3eed417 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 32 | #if CONFIG_EXT_TX |
| 33 | case TXFM_TYPE_IDENTITY4: return av1_iidentity4_c; |
| 34 | case TXFM_TYPE_IDENTITY8: return av1_iidentity8_c; |
| 35 | case TXFM_TYPE_IDENTITY16: return av1_iidentity16_c; |
| 36 | case TXFM_TYPE_IDENTITY32: return av1_iidentity32_c; |
| 37 | #endif // CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 38 | default: assert(0); return NULL; |
| 39 | } |
| 40 | } |
| 41 | |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 42 | static const TXFM_1D_CFG *inv_txfm_col_cfg_ls[TX_TYPES_1D][TX_SIZES] = { |
| 43 | // DCT |
Frank Galligan | 0b73f3e | 2017-05-03 22:43:22 +0000 | [diff] [blame] | 44 | { |
Timothy B. Terriberry | fe67ed6 | 2017-04-26 16:53:47 -0700 | [diff] [blame] | 45 | #if CONFIG_CHROMA_2X2 |
Frank Galligan | 0b73f3e | 2017-05-03 22:43:22 +0000 | [diff] [blame] | 46 | NULL, |
| 47 | #endif |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 48 | &inv_txfm_1d_col_cfg_dct_4, &inv_txfm_1d_col_cfg_dct_8, |
| 49 | &inv_txfm_1d_col_cfg_dct_16, &inv_txfm_1d_col_cfg_dct_32 }, |
| 50 | // ADST |
Frank Galligan | 0b73f3e | 2017-05-03 22:43:22 +0000 | [diff] [blame] | 51 | { |
Timothy B. Terriberry | fe67ed6 | 2017-04-26 16:53:47 -0700 | [diff] [blame] | 52 | #if CONFIG_CHROMA_2X2 |
Frank Galligan | 0b73f3e | 2017-05-03 22:43:22 +0000 | [diff] [blame] | 53 | NULL, |
| 54 | #endif |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 55 | &inv_txfm_1d_col_cfg_adst_4, &inv_txfm_1d_col_cfg_adst_8, |
| 56 | &inv_txfm_1d_col_cfg_adst_16, &inv_txfm_1d_col_cfg_adst_32 }, |
Fred BARBIER | b72ab8f | 2017-05-08 20:01:07 +0200 | [diff] [blame] | 57 | #if CONFIG_EXT_TX |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 58 | // FLIPADST |
Fred BARBIER | b72ab8f | 2017-05-08 20:01:07 +0200 | [diff] [blame] | 59 | { |
Timothy B. Terriberry | fe67ed6 | 2017-04-26 16:53:47 -0700 | [diff] [blame] | 60 | #if CONFIG_CHROMA_2X2 |
Fred BARBIER | b72ab8f | 2017-05-08 20:01:07 +0200 | [diff] [blame] | 61 | NULL, |
Frank Galligan | 0b73f3e | 2017-05-03 22:43:22 +0000 | [diff] [blame] | 62 | #endif |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 63 | &inv_txfm_1d_col_cfg_adst_4, &inv_txfm_1d_col_cfg_adst_8, |
| 64 | &inv_txfm_1d_col_cfg_adst_16, &inv_txfm_1d_col_cfg_adst_32 }, |
Sarah Parker | 3eed417 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 65 | // IDENTITY |
Fred BARBIER | b72ab8f | 2017-05-08 20:01:07 +0200 | [diff] [blame] | 66 | { |
Timothy B. Terriberry | fe67ed6 | 2017-04-26 16:53:47 -0700 | [diff] [blame] | 67 | #if CONFIG_CHROMA_2X2 |
Fred BARBIER | b72ab8f | 2017-05-08 20:01:07 +0200 | [diff] [blame] | 68 | NULL, |
| 69 | #endif |
Sarah Parker | 3eed417 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 70 | &inv_txfm_1d_cfg_identity_4, &inv_txfm_1d_cfg_identity_8, |
| 71 | &inv_txfm_1d_cfg_identity_16, &inv_txfm_1d_cfg_identity_32 }, |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 72 | #endif // CONFIG_EXT_TX |
| 73 | }; |
| 74 | |
| 75 | static const TXFM_1D_CFG *inv_txfm_row_cfg_ls[TX_TYPES_1D][TX_SIZES] = { |
| 76 | // DCT |
Fred BARBIER | b72ab8f | 2017-05-08 20:01:07 +0200 | [diff] [blame] | 77 | { |
Timothy B. Terriberry | fe67ed6 | 2017-04-26 16:53:47 -0700 | [diff] [blame] | 78 | #if CONFIG_CHROMA_2X2 |
Fred BARBIER | b72ab8f | 2017-05-08 20:01:07 +0200 | [diff] [blame] | 79 | NULL, |
| 80 | #endif |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 81 | &inv_txfm_1d_row_cfg_dct_4, &inv_txfm_1d_row_cfg_dct_8, |
| 82 | &inv_txfm_1d_row_cfg_dct_16, &inv_txfm_1d_row_cfg_dct_32 }, |
| 83 | // ADST |
Fred BARBIER | b72ab8f | 2017-05-08 20:01:07 +0200 | [diff] [blame] | 84 | { |
Timothy B. Terriberry | fe67ed6 | 2017-04-26 16:53:47 -0700 | [diff] [blame] | 85 | #if CONFIG_CHROMA_2X2 |
Fred BARBIER | b72ab8f | 2017-05-08 20:01:07 +0200 | [diff] [blame] | 86 | NULL, |
| 87 | #endif |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 88 | &inv_txfm_1d_row_cfg_adst_4, &inv_txfm_1d_row_cfg_adst_8, |
| 89 | &inv_txfm_1d_row_cfg_adst_16, &inv_txfm_1d_row_cfg_adst_32 }, |
| 90 | #if CONFIG_EXT_TX |
| 91 | // FLIPADST |
Fred BARBIER | b72ab8f | 2017-05-08 20:01:07 +0200 | [diff] [blame] | 92 | { |
Timothy B. Terriberry | fe67ed6 | 2017-04-26 16:53:47 -0700 | [diff] [blame] | 93 | #if CONFIG_CHROMA_2X2 |
Fred BARBIER | b72ab8f | 2017-05-08 20:01:07 +0200 | [diff] [blame] | 94 | NULL, |
| 95 | #endif |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 96 | &inv_txfm_1d_row_cfg_adst_4, &inv_txfm_1d_row_cfg_adst_8, |
| 97 | &inv_txfm_1d_row_cfg_adst_16, &inv_txfm_1d_row_cfg_adst_32 }, |
Sarah Parker | 3eed417 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 98 | // IDENTITY |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 99 | { |
Timothy B. Terriberry | fe67ed6 | 2017-04-26 16:53:47 -0700 | [diff] [blame] | 100 | #if CONFIG_CHROMA_2X2 |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 101 | NULL, |
| 102 | #endif |
Sarah Parker | 3eed417 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 103 | &inv_txfm_1d_cfg_identity_4, &inv_txfm_1d_cfg_identity_8, |
| 104 | &inv_txfm_1d_cfg_identity_16, &inv_txfm_1d_cfg_identity_32 }, |
Fred BARBIER | b72ab8f | 2017-05-08 20:01:07 +0200 | [diff] [blame] | 105 | #endif // CONFIG_EXT_TX |
| 106 | }; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 107 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 108 | TXFM_2D_FLIP_CFG av1_get_inv_txfm_cfg(int tx_type, int tx_size) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 109 | TXFM_2D_FLIP_CFG cfg; |
| 110 | set_flip_cfg(tx_type, &cfg); |
Sarah Parker | 30dfa88 | 2017-06-12 14:02:33 -0700 | [diff] [blame] | 111 | const int tx_type_col = vtx_tab[tx_type]; |
| 112 | const int tx_type_row = htx_tab[tx_type]; |
| 113 | const int tx_size_col = txsize_vert_map[tx_size]; |
| 114 | const int tx_size_row = txsize_horz_map[tx_size]; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 115 | cfg.col_cfg = inv_txfm_col_cfg_ls[tx_type_col][tx_size_col]; |
| 116 | cfg.row_cfg = inv_txfm_row_cfg_ls[tx_type_row][tx_size_row]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 117 | return cfg; |
| 118 | } |
| 119 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 120 | TXFM_2D_FLIP_CFG av1_get_inv_txfm_64x64_cfg(int tx_type) { |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 121 | TXFM_2D_FLIP_CFG cfg = { 0, 0, NULL, NULL }; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 122 | switch (tx_type) { |
| 123 | case DCT_DCT: |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 124 | cfg.col_cfg = &inv_txfm_1d_col_cfg_dct_64; |
| 125 | cfg.row_cfg = &inv_txfm_1d_row_cfg_dct_64; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 126 | set_flip_cfg(tx_type, &cfg); |
| 127 | break; |
| 128 | default: assert(0); |
| 129 | } |
| 130 | return cfg; |
| 131 | } |
| 132 | |
Angie Chiang | ce3ad28 | 2017-08-08 09:51:54 -0700 | [diff] [blame] | 133 | void av1_gen_inv_stage_range(int8_t *stage_range_col, int8_t *stage_range_row, |
| 134 | const TXFM_2D_FLIP_CFG *cfg, int8_t fwd_shift, |
| 135 | int bd) { |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 136 | // Note when assigning txfm_size_col, we use the txfm_size from the |
| 137 | // row configuration and vice versa. This is intentionally done to |
| 138 | // accurately perform rectangular transforms. When the transform is |
| 139 | // rectangular, the number of columns will be the same as the |
| 140 | // txfm_size stored in the row cfg struct. It will make no difference |
| 141 | // for square transforms. |
| 142 | const int txfm_size_col = cfg->row_cfg->txfm_size; |
| 143 | const int txfm_size_row = cfg->col_cfg->txfm_size; |
| 144 | // Take the shift from the larger dimension in the rectangular case. |
Sarah Parker | 30dfa88 | 2017-06-12 14:02:33 -0700 | [diff] [blame] | 145 | const int8_t *shift = (txfm_size_col > txfm_size_row) ? cfg->row_cfg->shift |
| 146 | : cfg->col_cfg->shift; |
Angie Chiang | ce3ad28 | 2017-08-08 09:51:54 -0700 | [diff] [blame] | 147 | // i < MAX_TXFM_STAGE_NUM will mute above array bounds warning |
| 148 | for (int i = 0; i < cfg->row_cfg->stage_num && i < MAX_TXFM_STAGE_NUM; ++i) { |
| 149 | stage_range_row[i] = cfg->row_cfg->stage_range[i] + fwd_shift + bd + 1; |
| 150 | } |
| 151 | // i < MAX_TXFM_STAGE_NUM will mute above array bounds warning |
| 152 | for (int i = 0; i < cfg->col_cfg->stage_num && i < MAX_TXFM_STAGE_NUM; ++i) { |
| 153 | stage_range_col[i] = |
| 154 | cfg->col_cfg->stage_range[i] + fwd_shift + shift[0] + bd + 1; |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | static INLINE void inv_txfm2d_add_c(const int32_t *input, uint16_t *output, |
| 159 | int stride, TXFM_2D_FLIP_CFG *cfg, |
| 160 | int32_t *txfm_buf, int8_t fwd_shift, |
| 161 | int bd) { |
| 162 | // Note when assigning txfm_size_col, we use the txfm_size from the |
| 163 | // row configuration and vice versa. This is intentionally done to |
| 164 | // accurately perform rectangular transforms. When the transform is |
| 165 | // rectangular, the number of columns will be the same as the |
| 166 | // txfm_size stored in the row cfg struct. It will make no difference |
| 167 | // for square transforms. |
| 168 | const int txfm_size_col = cfg->row_cfg->txfm_size; |
| 169 | const int txfm_size_row = cfg->col_cfg->txfm_size; |
| 170 | // Take the shift from the larger dimension in the rectangular case. |
| 171 | const int8_t *shift = (txfm_size_col > txfm_size_row) ? cfg->row_cfg->shift |
| 172 | : cfg->col_cfg->shift; |
| 173 | int8_t stage_range_row[MAX_TXFM_STAGE_NUM]; |
| 174 | int8_t stage_range_col[MAX_TXFM_STAGE_NUM]; |
| 175 | assert(cfg->row_cfg->stage_num <= MAX_TXFM_STAGE_NUM); |
| 176 | assert(cfg->col_cfg->stage_num <= MAX_TXFM_STAGE_NUM); |
| 177 | av1_gen_inv_stage_range(stage_range_col, stage_range_row, cfg, fwd_shift, bd); |
| 178 | |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 179 | const int8_t *cos_bit_col = cfg->col_cfg->cos_bit; |
| 180 | const int8_t *cos_bit_row = cfg->row_cfg->cos_bit; |
| 181 | const TxfmFunc txfm_func_col = inv_txfm_type_to_func(cfg->col_cfg->txfm_type); |
| 182 | const TxfmFunc txfm_func_row = inv_txfm_type_to_func(cfg->row_cfg->txfm_type); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 183 | |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 184 | // txfm_buf's length is txfm_size_row * txfm_size_col + 2 * txfm_size_row |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 185 | // it is used for intermediate data buffering |
| 186 | int32_t *temp_in = txfm_buf; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 187 | int32_t *temp_out = temp_in + txfm_size_row; |
| 188 | int32_t *buf = temp_out + txfm_size_row; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 189 | int32_t *buf_ptr = buf; |
| 190 | int c, r; |
| 191 | |
| 192 | // Rows |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 193 | for (r = 0; r < txfm_size_row; ++r) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 194 | txfm_func_row(input, buf_ptr, cos_bit_row, stage_range_row); |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 195 | round_shift_array(buf_ptr, txfm_size_col, -shift[0]); |
| 196 | // Multiply everything by Sqrt2 if the transform is rectangular |
| 197 | if (txfm_size_row != txfm_size_col) { |
| 198 | for (c = 0; c < txfm_size_col; ++c) |
| 199 | buf_ptr[c] = (int32_t)dct_const_round_shift(buf_ptr[c] * Sqrt2); |
| 200 | } |
| 201 | input += txfm_size_col; |
| 202 | buf_ptr += txfm_size_col; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | // Columns |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 206 | for (c = 0; c < txfm_size_col; ++c) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 207 | if (cfg->lr_flip == 0) { |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 208 | for (r = 0; r < txfm_size_row; ++r) |
| 209 | temp_in[r] = buf[r * txfm_size_col + c]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 210 | } else { |
| 211 | // flip left right |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 212 | for (r = 0; r < txfm_size_row; ++r) |
| 213 | temp_in[r] = buf[r * txfm_size_col + (txfm_size_col - c - 1)]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 214 | } |
| 215 | txfm_func_col(temp_in, temp_out, cos_bit_col, stage_range_col); |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 216 | round_shift_array(temp_out, txfm_size_row, -shift[1]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 217 | if (cfg->ud_flip == 0) { |
Jonathan Matthews | 284f9d0 | 2017-06-08 15:49:08 +0100 | [diff] [blame] | 218 | for (r = 0; r < txfm_size_row; ++r) { |
| 219 | output[r * stride + c] = |
| 220 | highbd_clip_pixel_add(output[r * stride + c], temp_out[r], bd); |
| 221 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 222 | } else { |
| 223 | // flip upside down |
Jonathan Matthews | 284f9d0 | 2017-06-08 15:49:08 +0100 | [diff] [blame] | 224 | for (r = 0; r < txfm_size_row; ++r) { |
| 225 | output[r * stride + c] = highbd_clip_pixel_add( |
| 226 | output[r * stride + c], temp_out[txfm_size_row - r - 1], bd); |
| 227 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 228 | } |
| 229 | } |
| 230 | } |
| 231 | |
Frederic Barbier | c53753f | 2017-04-25 11:05:01 +0200 | [diff] [blame] | 232 | static INLINE void inv_txfm2d_add_facade(const int32_t *input, uint16_t *output, |
| 233 | int stride, int32_t *txfm_buf, |
| 234 | int tx_type, int tx_size, int bd) { |
Frederic Barbier | c53753f | 2017-04-25 11:05:01 +0200 | [diff] [blame] | 235 | TXFM_2D_FLIP_CFG cfg = av1_get_inv_txfm_cfg(tx_type, tx_size); |
Angie Chiang | ce3ad28 | 2017-08-08 09:51:54 -0700 | [diff] [blame] | 236 | int tx_size_sqr = txsize_sqr_map[tx_size]; |
| 237 | inv_txfm2d_add_c(input, output, stride, &cfg, txfm_buf, |
| 238 | fwd_shift_sum[tx_size_sqr], bd); |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | void av1_inv_txfm2d_add_4x8_c(const int32_t *input, uint16_t *output, |
| 242 | int stride, int tx_type, int bd) { |
| 243 | int txfm_buf[4 * 8 + 8 + 8]; |
| 244 | inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_4X8, bd); |
| 245 | } |
| 246 | |
| 247 | void av1_inv_txfm2d_add_8x4_c(const int32_t *input, uint16_t *output, |
| 248 | int stride, int tx_type, int bd) { |
Angie Chiang | 155bf9a | 2017-08-06 19:52:57 -0700 | [diff] [blame] | 249 | #if CONFIG_TXMG |
| 250 | int txfm_buf[8 * 4 + 8 + 8]; |
| 251 | int32_t rinput[8 * 4]; |
| 252 | uint16_t routput[8 * 4]; |
| 253 | int tx_size = TX_8X4; |
| 254 | int rtx_size = av1_rotate_tx_size(tx_size); |
| 255 | int rtx_type = av1_rotate_tx_type(tx_type); |
| 256 | int w = tx_size_wide[tx_size]; |
| 257 | int h = tx_size_high[tx_size]; |
| 258 | int rw = h; |
| 259 | int rh = w; |
| 260 | transpose_int32(rinput, rw, input, w, w, h); |
| 261 | transpose_uint16(routput, rw, output, stride, w, h); |
| 262 | inv_txfm2d_add_facade(rinput, routput, rw, txfm_buf, rtx_type, rtx_size, bd); |
| 263 | transpose_uint16(output, stride, routput, rw, rw, rh); |
| 264 | #else |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 265 | int txfm_buf[8 * 4 + 4 + 4]; |
| 266 | inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_8X4, bd); |
Angie Chiang | 155bf9a | 2017-08-06 19:52:57 -0700 | [diff] [blame] | 267 | #endif |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | void av1_inv_txfm2d_add_8x16_c(const int32_t *input, uint16_t *output, |
| 271 | int stride, int tx_type, int bd) { |
| 272 | int txfm_buf[8 * 16 + 16 + 16]; |
| 273 | inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_8X16, bd); |
| 274 | } |
| 275 | |
| 276 | void av1_inv_txfm2d_add_16x8_c(const int32_t *input, uint16_t *output, |
| 277 | int stride, int tx_type, int bd) { |
Angie Chiang | 155bf9a | 2017-08-06 19:52:57 -0700 | [diff] [blame] | 278 | #if CONFIG_TXMG |
| 279 | int txfm_buf[16 * 8 + 16 + 16]; |
| 280 | int32_t rinput[16 * 8]; |
| 281 | uint16_t routput[16 * 8]; |
| 282 | int tx_size = TX_16X8; |
| 283 | int rtx_size = av1_rotate_tx_size(tx_size); |
| 284 | int rtx_type = av1_rotate_tx_type(tx_type); |
| 285 | int w = tx_size_wide[tx_size]; |
| 286 | int h = tx_size_high[tx_size]; |
| 287 | int rw = h; |
| 288 | int rh = w; |
| 289 | transpose_int32(rinput, rw, input, w, w, h); |
| 290 | transpose_uint16(routput, rw, output, stride, w, h); |
| 291 | inv_txfm2d_add_facade(rinput, routput, rw, txfm_buf, rtx_type, rtx_size, bd); |
| 292 | transpose_uint16(output, stride, routput, rw, rw, rh); |
| 293 | #else |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 294 | int txfm_buf[16 * 8 + 8 + 8]; |
| 295 | inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_16X8, bd); |
Angie Chiang | 155bf9a | 2017-08-06 19:52:57 -0700 | [diff] [blame] | 296 | #endif |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | void av1_inv_txfm2d_add_16x32_c(const int32_t *input, uint16_t *output, |
| 300 | int stride, int tx_type, int bd) { |
| 301 | int txfm_buf[16 * 32 + 32 + 32]; |
| 302 | inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_16X32, bd); |
| 303 | } |
| 304 | |
| 305 | void av1_inv_txfm2d_add_32x16_c(const int32_t *input, uint16_t *output, |
| 306 | int stride, int tx_type, int bd) { |
Angie Chiang | 155bf9a | 2017-08-06 19:52:57 -0700 | [diff] [blame] | 307 | #if CONFIG_TXMG |
| 308 | int txfm_buf[32 * 16 + 32 + 32]; |
| 309 | int32_t rinput[32 * 16]; |
| 310 | uint16_t routput[32 * 16]; |
| 311 | int tx_size = TX_32X16; |
| 312 | int rtx_size = av1_rotate_tx_size(tx_size); |
| 313 | int rtx_type = av1_rotate_tx_type(tx_type); |
| 314 | int w = tx_size_wide[tx_size]; |
| 315 | int h = tx_size_high[tx_size]; |
| 316 | int rw = h; |
| 317 | int rh = w; |
| 318 | transpose_int32(rinput, rw, input, w, w, h); |
| 319 | transpose_uint16(routput, rw, output, stride, w, h); |
| 320 | inv_txfm2d_add_facade(rinput, routput, rw, txfm_buf, rtx_type, rtx_size, bd); |
| 321 | transpose_uint16(output, stride, routput, rw, rw, rh); |
| 322 | #else |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 323 | int txfm_buf[32 * 16 + 16 + 16]; |
| 324 | inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_32X16, bd); |
Angie Chiang | 155bf9a | 2017-08-06 19:52:57 -0700 | [diff] [blame] | 325 | #endif |
Frederic Barbier | c53753f | 2017-04-25 11:05:01 +0200 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | void av1_inv_txfm2d_add_4x4_c(const int32_t *input, uint16_t *output, |
| 329 | int stride, int tx_type, int bd) { |
| 330 | int txfm_buf[4 * 4 + 4 + 4]; |
| 331 | inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_4X4, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 332 | } |
| 333 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 334 | void av1_inv_txfm2d_add_8x8_c(const int32_t *input, uint16_t *output, |
| 335 | int stride, int tx_type, int bd) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 336 | int txfm_buf[8 * 8 + 8 + 8]; |
Frederic Barbier | c53753f | 2017-04-25 11:05:01 +0200 | [diff] [blame] | 337 | inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_8X8, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 338 | } |
| 339 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 340 | void av1_inv_txfm2d_add_16x16_c(const int32_t *input, uint16_t *output, |
| 341 | int stride, int tx_type, int bd) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 342 | int txfm_buf[16 * 16 + 16 + 16]; |
Frederic Barbier | c53753f | 2017-04-25 11:05:01 +0200 | [diff] [blame] | 343 | inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_16X16, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 344 | } |
| 345 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 346 | void av1_inv_txfm2d_add_32x32_c(const int32_t *input, uint16_t *output, |
| 347 | int stride, int tx_type, int bd) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 348 | int txfm_buf[32 * 32 + 32 + 32]; |
Frederic Barbier | c53753f | 2017-04-25 11:05:01 +0200 | [diff] [blame] | 349 | inv_txfm2d_add_facade(input, output, stride, txfm_buf, tx_type, TX_32X32, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 350 | } |
| 351 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 352 | void av1_inv_txfm2d_add_64x64_c(const int32_t *input, uint16_t *output, |
| 353 | int stride, int tx_type, int bd) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 354 | int txfm_buf[64 * 64 + 64 + 64]; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 355 | TXFM_2D_FLIP_CFG cfg = av1_get_inv_txfm_64x64_cfg(tx_type); |
Angie Chiang | ce3ad28 | 2017-08-08 09:51:54 -0700 | [diff] [blame] | 356 | inv_txfm2d_add_c(input, output, stride, &cfg, txfm_buf, -4, bd); |
| 357 | #if CONFIG_TX64X64 |
| 358 | assert(fwd_shift_sum[TX_64X64] == -4); |
| 359 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 360 | } |