Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -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 | |
| 12 | #include <math.h> |
| 13 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 14 | #include "./aom_dsp_rtcd.h" |
Geza Lore | a1ddae5 | 2016-09-02 09:51:34 +0100 | [diff] [blame] | 15 | #include "./av1_rtcd.h" |
| 16 | #include "aom_dsp/inv_txfm.h" |
| 17 | #include "aom_ports/mem.h" |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 18 | #include "av1/common/av1_inv_txfm1d_cfg.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 19 | #include "av1/common/blockd.h" |
| 20 | #include "av1/common/enums.h" |
| 21 | #include "av1/common/idct.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 22 | |
Jingning Han | ff70545 | 2017-04-27 11:32:15 -0700 | [diff] [blame] | 23 | int av1_get_tx_scale(const TX_SIZE tx_size) { |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 24 | if (txsize_sqr_up_map[tx_size] == TX_32X32) return 1; |
| 25 | #if CONFIG_TX64X64 |
| 26 | else if (txsize_sqr_up_map[tx_size] == TX_64X64) |
| 27 | return 2; |
| 28 | #endif // CONFIG_TX64X64 |
| 29 | else |
| 30 | return 0; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 31 | } |
| 32 | |
Debargha Mukherjee | e52816b | 2016-10-12 10:49:29 -0700 | [diff] [blame] | 33 | // NOTE: The implementation of all inverses need to be aware of the fact |
| 34 | // that input and output could be the same buffer. |
| 35 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 36 | #if CONFIG_EXT_TX |
| 37 | static void iidtx4_c(const tran_low_t *input, tran_low_t *output) { |
| 38 | int i; |
| 39 | for (i = 0; i < 4; ++i) |
| 40 | output[i] = (tran_low_t)dct_const_round_shift(input[i] * Sqrt2); |
| 41 | } |
| 42 | |
| 43 | static void iidtx8_c(const tran_low_t *input, tran_low_t *output) { |
| 44 | int i; |
| 45 | for (i = 0; i < 8; ++i) output[i] = input[i] * 2; |
| 46 | } |
| 47 | |
| 48 | static void iidtx16_c(const tran_low_t *input, tran_low_t *output) { |
| 49 | int i; |
| 50 | for (i = 0; i < 16; ++i) |
| 51 | output[i] = (tran_low_t)dct_const_round_shift(input[i] * 2 * Sqrt2); |
| 52 | } |
| 53 | |
| 54 | static void iidtx32_c(const tran_low_t *input, tran_low_t *output) { |
| 55 | int i; |
| 56 | for (i = 0; i < 32; ++i) output[i] = input[i] * 4; |
| 57 | } |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 58 | |
| 59 | #if CONFIG_TX64X64 |
| 60 | static void iidtx64_c(const tran_low_t *input, tran_low_t *output) { |
| 61 | int i; |
| 62 | for (i = 0; i < 64; ++i) |
| 63 | output[i] = (tran_low_t)dct_const_round_shift(input[i] * 4 * Sqrt2); |
| 64 | } |
| 65 | #endif // CONFIG_TX64X64 |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 66 | #endif // CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 67 | |
Debargha Mukherjee | e52816b | 2016-10-12 10:49:29 -0700 | [diff] [blame] | 68 | // For use in lieu of ADST |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 69 | static void ihalfright32_c(const tran_low_t *input, tran_low_t *output) { |
| 70 | int i; |
| 71 | tran_low_t inputhalf[16]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 72 | // Multiply input by sqrt(2) |
| 73 | for (i = 0; i < 16; ++i) { |
| 74 | inputhalf[i] = (tran_low_t)dct_const_round_shift(input[i] * Sqrt2); |
| 75 | } |
Debargha Mukherjee | e52816b | 2016-10-12 10:49:29 -0700 | [diff] [blame] | 76 | for (i = 0; i < 16; ++i) { |
| 77 | output[i] = input[16 + i] * 4; |
| 78 | } |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 79 | aom_idct16_c(inputhalf, output + 16); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 80 | // Note overall scaling factor is 4 times orthogonal |
| 81 | } |
| 82 | |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 83 | #if CONFIG_TX64X64 |
| 84 | static void idct64_col_c(const tran_low_t *input, tran_low_t *output) { |
| 85 | int32_t in[64], out[64]; |
| 86 | int i; |
| 87 | for (i = 0; i < 64; ++i) in[i] = (int32_t)input[i]; |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 88 | av1_idct64_new(in, out, inv_cos_bit_col_dct_64, inv_stage_range_col_dct_64); |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 89 | for (i = 0; i < 64; ++i) output[i] = (tran_low_t)out[i]; |
| 90 | } |
| 91 | |
| 92 | static void idct64_row_c(const tran_low_t *input, tran_low_t *output) { |
| 93 | int32_t in[64], out[64]; |
| 94 | int i; |
| 95 | for (i = 0; i < 64; ++i) in[i] = (int32_t)input[i]; |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 96 | av1_idct64_new(in, out, inv_cos_bit_row_dct_64, inv_stage_range_row_dct_64); |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 97 | for (i = 0; i < 64; ++i) output[i] = (tran_low_t)out[i]; |
| 98 | } |
| 99 | |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 100 | // For use in lieu of ADST |
| 101 | static void ihalfright64_c(const tran_low_t *input, tran_low_t *output) { |
| 102 | int i; |
| 103 | tran_low_t inputhalf[32]; |
| 104 | // Multiply input by sqrt(2) |
| 105 | for (i = 0; i < 32; ++i) { |
| 106 | inputhalf[i] = (tran_low_t)dct_const_round_shift(input[i] * Sqrt2); |
| 107 | } |
| 108 | for (i = 0; i < 32; ++i) { |
| 109 | output[i] = (tran_low_t)dct_const_round_shift(input[32 + i] * 4 * Sqrt2); |
| 110 | } |
| 111 | aom_idct32_c(inputhalf, output + 32); |
| 112 | // Note overall scaling factor is 4 * sqrt(2) times orthogonal |
| 113 | } |
| 114 | #endif // CONFIG_TX64X64 |
| 115 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 116 | // Inverse identity transform and add. |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 117 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 118 | static void inv_idtx_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 119 | int bs, int tx_type) { |
| 120 | int r, c; |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 121 | const int shift = bs < 32 ? 3 : (bs < 64 ? 2 : 1); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 122 | if (tx_type == IDTX) { |
| 123 | for (r = 0; r < bs; ++r) { |
| 124 | for (c = 0; c < bs; ++c) |
| 125 | dest[c] = clip_pixel_add(dest[c], input[c] >> shift); |
| 126 | dest += stride; |
| 127 | input += bs; |
| 128 | } |
| 129 | } |
| 130 | } |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 131 | #endif // CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 132 | |
| 133 | #define FLIPUD_PTR(dest, stride, size) \ |
| 134 | do { \ |
| 135 | (dest) = (dest) + ((size)-1) * (stride); \ |
| 136 | (stride) = -(stride); \ |
| 137 | } while (0) |
| 138 | |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 139 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 140 | static void maybe_flip_strides(uint8_t **dst, int *dstride, tran_low_t **src, |
| 141 | int *sstride, int tx_type, int sizey, |
| 142 | int sizex) { |
| 143 | // Note that the transpose of src will be added to dst. In order to LR |
| 144 | // flip the addends (in dst coordinates), we UD flip the src. To UD flip |
| 145 | // the addends, we UD flip the dst. |
| 146 | switch (tx_type) { |
| 147 | case DCT_DCT: |
| 148 | case ADST_DCT: |
| 149 | case DCT_ADST: |
| 150 | case ADST_ADST: |
| 151 | case IDTX: |
| 152 | case V_DCT: |
| 153 | case H_DCT: |
| 154 | case V_ADST: |
| 155 | case H_ADST: break; |
| 156 | case FLIPADST_DCT: |
| 157 | case FLIPADST_ADST: |
| 158 | case V_FLIPADST: |
| 159 | // flip UD |
| 160 | FLIPUD_PTR(*dst, *dstride, sizey); |
| 161 | break; |
| 162 | case DCT_FLIPADST: |
| 163 | case ADST_FLIPADST: |
| 164 | case H_FLIPADST: |
| 165 | // flip LR |
| 166 | FLIPUD_PTR(*src, *sstride, sizex); |
| 167 | break; |
| 168 | case FLIPADST_FLIPADST: |
| 169 | // flip UD |
| 170 | FLIPUD_PTR(*dst, *dstride, sizey); |
| 171 | // flip LR |
| 172 | FLIPUD_PTR(*src, *sstride, sizex); |
| 173 | break; |
| 174 | default: assert(0); break; |
| 175 | } |
| 176 | } |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 177 | #endif // CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 178 | |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 179 | #if CONFIG_HIGHBITDEPTH |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 180 | #if CONFIG_EXT_TX && CONFIG_TX64X64 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 181 | static void highbd_inv_idtx_add_c(const tran_low_t *input, uint8_t *dest8, |
| 182 | int stride, int bs, int tx_type, int bd) { |
| 183 | int r, c; |
| 184 | const int shift = bs < 32 ? 3 : 2; |
| 185 | uint16_t *dest = CONVERT_TO_SHORTPTR(dest8); |
| 186 | |
| 187 | if (tx_type == IDTX) { |
| 188 | for (r = 0; r < bs; ++r) { |
| 189 | for (c = 0; c < bs; ++c) |
| 190 | dest[c] = highbd_clip_pixel_add(dest[c], input[c] >> shift, bd); |
| 191 | dest += stride; |
| 192 | input += bs; |
| 193 | } |
| 194 | } |
| 195 | } |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 196 | #endif // CONFIG_EXT_TX && CONFIG_TX64X64 |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 197 | #endif // CONFIG_HIGHBITDEPTH |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 198 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 199 | void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 200 | int tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 201 | static const transform_2d IHT_4[] = { |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 202 | { aom_idct4_c, aom_idct4_c }, // DCT_DCT = 0 |
| 203 | { aom_iadst4_c, aom_idct4_c }, // ADST_DCT = 1 |
| 204 | { aom_idct4_c, aom_iadst4_c }, // DCT_ADST = 2 |
| 205 | { aom_iadst4_c, aom_iadst4_c }, // ADST_ADST = 3 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 206 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 207 | { aom_iadst4_c, aom_idct4_c }, // FLIPADST_DCT |
| 208 | { aom_idct4_c, aom_iadst4_c }, // DCT_FLIPADST |
| 209 | { aom_iadst4_c, aom_iadst4_c }, // FLIPADST_FLIPADST |
| 210 | { aom_iadst4_c, aom_iadst4_c }, // ADST_FLIPADST |
| 211 | { aom_iadst4_c, aom_iadst4_c }, // FLIPADST_ADST |
| 212 | { iidtx4_c, iidtx4_c }, // IDTX |
| 213 | { aom_idct4_c, iidtx4_c }, // V_DCT |
| 214 | { iidtx4_c, aom_idct4_c }, // H_DCT |
| 215 | { aom_iadst4_c, iidtx4_c }, // V_ADST |
| 216 | { iidtx4_c, aom_iadst4_c }, // H_ADST |
| 217 | { aom_iadst4_c, iidtx4_c }, // V_FLIPADST |
| 218 | { iidtx4_c, aom_iadst4_c }, // H_FLIPADST |
| 219 | #endif // CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 220 | }; |
| 221 | |
| 222 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 223 | tran_low_t tmp[4][4]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 224 | tran_low_t out[4][4]; |
| 225 | tran_low_t *outp = &out[0][0]; |
| 226 | int outstride = 4; |
| 227 | |
| 228 | // inverse transform row vectors |
| 229 | for (i = 0; i < 4; ++i) { |
| 230 | IHT_4[tx_type].rows(input, out[i]); |
| 231 | input += 4; |
| 232 | } |
| 233 | |
| 234 | // transpose |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 235 | for (i = 0; i < 4; i++) { |
| 236 | for (j = 0; j < 4; j++) { |
| 237 | tmp[j][i] = out[i][j]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 238 | } |
| 239 | } |
| 240 | |
| 241 | // inverse transform column vectors |
| 242 | for (i = 0; i < 4; ++i) { |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 243 | IHT_4[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | #if CONFIG_EXT_TX |
| 247 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 4, 4); |
| 248 | #endif |
| 249 | |
| 250 | // Sum with the destination |
| 251 | for (i = 0; i < 4; ++i) { |
| 252 | for (j = 0; j < 4; ++j) { |
| 253 | int d = i * stride + j; |
| 254 | int s = j * outstride + i; |
| 255 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 4)); |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 260 | void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 261 | int tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 262 | static const transform_2d IHT_4x8[] = { |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 263 | { aom_idct8_c, aom_idct4_c }, // DCT_DCT |
| 264 | { aom_iadst8_c, aom_idct4_c }, // ADST_DCT |
| 265 | { aom_idct8_c, aom_iadst4_c }, // DCT_ADST |
| 266 | { aom_iadst8_c, aom_iadst4_c }, // ADST_ADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 267 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 268 | { aom_iadst8_c, aom_idct4_c }, // FLIPADST_DCT |
| 269 | { aom_idct8_c, aom_iadst4_c }, // DCT_FLIPADST |
| 270 | { aom_iadst8_c, aom_iadst4_c }, // FLIPADST_FLIPADST |
| 271 | { aom_iadst8_c, aom_iadst4_c }, // ADST_FLIPADST |
| 272 | { aom_iadst8_c, aom_iadst4_c }, // FLIPADST_ADST |
| 273 | { iidtx8_c, iidtx4_c }, // IDTX |
| 274 | { aom_idct8_c, iidtx4_c }, // V_DCT |
| 275 | { iidtx8_c, aom_idct4_c }, // H_DCT |
| 276 | { aom_iadst8_c, iidtx4_c }, // V_ADST |
| 277 | { iidtx8_c, aom_iadst4_c }, // H_ADST |
| 278 | { aom_iadst8_c, iidtx4_c }, // V_FLIPADST |
| 279 | { iidtx8_c, aom_iadst4_c }, // H_FLIPADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 280 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 281 | }; |
| 282 | |
| 283 | const int n = 4; |
| 284 | const int n2 = 8; |
| 285 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 286 | tran_low_t out[4][8], tmp[4][8], outtmp[4]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 287 | tran_low_t *outp = &out[0][0]; |
| 288 | int outstride = n2; |
| 289 | |
| 290 | // inverse transform row vectors and transpose |
| 291 | for (i = 0; i < n2; ++i) { |
| 292 | IHT_4x8[tx_type].rows(input, outtmp); |
| 293 | for (j = 0; j < n; ++j) |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 294 | tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 295 | input += n; |
| 296 | } |
| 297 | |
| 298 | // inverse transform column vectors |
| 299 | for (i = 0; i < n; ++i) { |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 300 | IHT_4x8[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 301 | } |
| 302 | |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 303 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 304 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n); |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 305 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 306 | |
| 307 | // Sum with the destination |
| 308 | for (i = 0; i < n2; ++i) { |
| 309 | for (j = 0; j < n; ++j) { |
| 310 | int d = i * stride + j; |
| 311 | int s = j * outstride + i; |
| 312 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 317 | void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 318 | int tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 319 | static const transform_2d IHT_8x4[] = { |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 320 | { aom_idct4_c, aom_idct8_c }, // DCT_DCT |
| 321 | { aom_iadst4_c, aom_idct8_c }, // ADST_DCT |
| 322 | { aom_idct4_c, aom_iadst8_c }, // DCT_ADST |
| 323 | { aom_iadst4_c, aom_iadst8_c }, // ADST_ADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 324 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 325 | { aom_iadst4_c, aom_idct8_c }, // FLIPADST_DCT |
| 326 | { aom_idct4_c, aom_iadst8_c }, // DCT_FLIPADST |
| 327 | { aom_iadst4_c, aom_iadst8_c }, // FLIPADST_FLIPADST |
| 328 | { aom_iadst4_c, aom_iadst8_c }, // ADST_FLIPADST |
| 329 | { aom_iadst4_c, aom_iadst8_c }, // FLIPADST_ADST |
| 330 | { iidtx4_c, iidtx8_c }, // IDTX |
| 331 | { aom_idct4_c, iidtx8_c }, // V_DCT |
| 332 | { iidtx4_c, aom_idct8_c }, // H_DCT |
| 333 | { aom_iadst4_c, iidtx8_c }, // V_ADST |
| 334 | { iidtx4_c, aom_iadst8_c }, // H_ADST |
| 335 | { aom_iadst4_c, iidtx8_c }, // V_FLIPADST |
| 336 | { iidtx4_c, aom_iadst8_c }, // H_FLIPADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 337 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 338 | }; |
| 339 | const int n = 4; |
| 340 | const int n2 = 8; |
| 341 | |
| 342 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 343 | tran_low_t out[8][4], tmp[8][4], outtmp[8]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 344 | tran_low_t *outp = &out[0][0]; |
| 345 | int outstride = n; |
| 346 | |
| 347 | // inverse transform row vectors and transpose |
| 348 | for (i = 0; i < n; ++i) { |
| 349 | IHT_8x4[tx_type].rows(input, outtmp); |
| 350 | for (j = 0; j < n2; ++j) |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 351 | tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 352 | input += n2; |
| 353 | } |
| 354 | |
| 355 | // inverse transform column vectors |
| 356 | for (i = 0; i < n2; ++i) { |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 357 | IHT_8x4[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 358 | } |
| 359 | |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 360 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 361 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2); |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 362 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 363 | |
| 364 | // Sum with the destination |
| 365 | for (i = 0; i < n; ++i) { |
| 366 | for (j = 0; j < n2; ++j) { |
| 367 | int d = i * stride + j; |
| 368 | int s = j * outstride + i; |
| 369 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
| 370 | } |
| 371 | } |
| 372 | } |
| 373 | |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 374 | void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 375 | int tx_type) { |
| 376 | static const transform_2d IHT_4x16[] = { |
| 377 | { aom_idct16_c, aom_idct4_c }, // DCT_DCT |
| 378 | { aom_iadst16_c, aom_idct4_c }, // ADST_DCT |
| 379 | { aom_idct16_c, aom_iadst4_c }, // DCT_ADST |
| 380 | { aom_iadst16_c, aom_iadst4_c }, // ADST_ADST |
| 381 | #if CONFIG_EXT_TX |
| 382 | { aom_iadst16_c, aom_idct4_c }, // FLIPADST_DCT |
| 383 | { aom_idct16_c, aom_iadst4_c }, // DCT_FLIPADST |
| 384 | { aom_iadst16_c, aom_iadst4_c }, // FLIPADST_FLIPADST |
| 385 | { aom_iadst16_c, aom_iadst4_c }, // ADST_FLIPADST |
| 386 | { aom_iadst16_c, aom_iadst4_c }, // FLIPADST_ADST |
| 387 | { iidtx16_c, iidtx4_c }, // IDTX |
| 388 | { aom_idct16_c, iidtx4_c }, // V_DCT |
| 389 | { iidtx16_c, aom_idct4_c }, // H_DCT |
| 390 | { aom_iadst16_c, iidtx4_c }, // V_ADST |
| 391 | { iidtx16_c, aom_iadst4_c }, // H_ADST |
| 392 | { aom_iadst16_c, iidtx4_c }, // V_FLIPADST |
| 393 | { iidtx16_c, aom_iadst4_c }, // H_FLIPADST |
| 394 | #endif |
| 395 | }; |
| 396 | |
| 397 | const int n = 4; |
| 398 | const int n4 = 16; |
| 399 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 400 | tran_low_t out[4][16], tmp[4][16], outtmp[4]; |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 401 | tran_low_t *outp = &out[0][0]; |
| 402 | int outstride = n4; |
| 403 | |
| 404 | // inverse transform row vectors and transpose |
| 405 | for (i = 0; i < n4; ++i) { |
| 406 | IHT_4x16[tx_type].rows(input, outtmp); |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 407 | for (j = 0; j < n; ++j) tmp[j][i] = outtmp[j]; |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 408 | input += n; |
| 409 | } |
| 410 | |
| 411 | // inverse transform column vectors |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 412 | for (i = 0; i < n; ++i) IHT_4x16[tx_type].cols(tmp[i], out[i]); |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 413 | |
| 414 | #if CONFIG_EXT_TX |
| 415 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n4, n); |
| 416 | #endif |
| 417 | |
| 418 | // Sum with the destination |
| 419 | for (i = 0; i < n4; ++i) { |
| 420 | for (j = 0; j < n; ++j) { |
| 421 | int d = i * stride + j; |
| 422 | int s = j * outstride + i; |
| 423 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
| 424 | } |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 429 | int tx_type) { |
| 430 | static const transform_2d IHT_16x4[] = { |
| 431 | { aom_idct4_c, aom_idct16_c }, // DCT_DCT |
| 432 | { aom_iadst4_c, aom_idct16_c }, // ADST_DCT |
| 433 | { aom_idct4_c, aom_iadst16_c }, // DCT_ADST |
| 434 | { aom_iadst4_c, aom_iadst16_c }, // ADST_ADST |
| 435 | #if CONFIG_EXT_TX |
| 436 | { aom_iadst4_c, aom_idct16_c }, // FLIPADST_DCT |
| 437 | { aom_idct4_c, aom_iadst16_c }, // DCT_FLIPADST |
| 438 | { aom_iadst4_c, aom_iadst16_c }, // FLIPADST_FLIPADST |
| 439 | { aom_iadst4_c, aom_iadst16_c }, // ADST_FLIPADST |
| 440 | { aom_iadst4_c, aom_iadst16_c }, // FLIPADST_ADST |
| 441 | { iidtx4_c, iidtx16_c }, // IDTX |
| 442 | { aom_idct4_c, iidtx16_c }, // V_DCT |
| 443 | { iidtx4_c, aom_idct16_c }, // H_DCT |
| 444 | { aom_iadst4_c, iidtx16_c }, // V_ADST |
| 445 | { iidtx4_c, aom_iadst16_c }, // H_ADST |
| 446 | { aom_iadst4_c, iidtx16_c }, // V_FLIPADST |
| 447 | { iidtx4_c, aom_iadst16_c }, // H_FLIPADST |
| 448 | #endif |
| 449 | }; |
| 450 | const int n = 4; |
| 451 | const int n4 = 16; |
| 452 | |
| 453 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 454 | tran_low_t out[16][4], tmp[16][4], outtmp[16]; |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 455 | tran_low_t *outp = &out[0][0]; |
| 456 | int outstride = n; |
| 457 | |
| 458 | // inverse transform row vectors and transpose |
| 459 | for (i = 0; i < n; ++i) { |
| 460 | IHT_16x4[tx_type].rows(input, outtmp); |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 461 | for (j = 0; j < n4; ++j) tmp[j][i] = outtmp[j]; |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 462 | input += n4; |
| 463 | } |
| 464 | |
| 465 | // inverse transform column vectors |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 466 | for (i = 0; i < n4; ++i) IHT_16x4[tx_type].cols(tmp[i], out[i]); |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 467 | |
| 468 | #if CONFIG_EXT_TX |
| 469 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n4); |
| 470 | #endif |
| 471 | |
| 472 | // Sum with the destination |
| 473 | for (i = 0; i < n; ++i) { |
| 474 | for (j = 0; j < n4; ++j) { |
| 475 | int d = i * stride + j; |
| 476 | int s = j * outstride + i; |
| 477 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
| 478 | } |
| 479 | } |
| 480 | } |
| 481 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 482 | void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 483 | int tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 484 | static const transform_2d IHT_8x16[] = { |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 485 | { aom_idct16_c, aom_idct8_c }, // DCT_DCT |
| 486 | { aom_iadst16_c, aom_idct8_c }, // ADST_DCT |
| 487 | { aom_idct16_c, aom_iadst8_c }, // DCT_ADST |
| 488 | { aom_iadst16_c, aom_iadst8_c }, // ADST_ADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 489 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 490 | { aom_iadst16_c, aom_idct8_c }, // FLIPADST_DCT |
| 491 | { aom_idct16_c, aom_iadst8_c }, // DCT_FLIPADST |
| 492 | { aom_iadst16_c, aom_iadst8_c }, // FLIPADST_FLIPADST |
| 493 | { aom_iadst16_c, aom_iadst8_c }, // ADST_FLIPADST |
| 494 | { aom_iadst16_c, aom_iadst8_c }, // FLIPADST_ADST |
| 495 | { iidtx16_c, iidtx8_c }, // IDTX |
| 496 | { aom_idct16_c, iidtx8_c }, // V_DCT |
| 497 | { iidtx16_c, aom_idct8_c }, // H_DCT |
| 498 | { aom_iadst16_c, iidtx8_c }, // V_ADST |
| 499 | { iidtx16_c, aom_iadst8_c }, // H_ADST |
| 500 | { aom_iadst16_c, iidtx8_c }, // V_FLIPADST |
| 501 | { iidtx16_c, aom_iadst8_c }, // H_FLIPADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 502 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 503 | }; |
| 504 | |
| 505 | const int n = 8; |
| 506 | const int n2 = 16; |
| 507 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 508 | tran_low_t out[8][16], tmp[8][16], outtmp[8]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 509 | tran_low_t *outp = &out[0][0]; |
| 510 | int outstride = n2; |
| 511 | |
| 512 | // inverse transform row vectors and transpose |
| 513 | for (i = 0; i < n2; ++i) { |
| 514 | IHT_8x16[tx_type].rows(input, outtmp); |
| 515 | for (j = 0; j < n; ++j) |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 516 | tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 517 | input += n; |
| 518 | } |
| 519 | |
| 520 | // inverse transform column vectors |
| 521 | for (i = 0; i < n; ++i) { |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 522 | IHT_8x16[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 523 | } |
| 524 | |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 525 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 526 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n); |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 527 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 528 | |
| 529 | // Sum with the destination |
| 530 | for (i = 0; i < n2; ++i) { |
| 531 | for (j = 0; j < n; ++j) { |
| 532 | int d = i * stride + j; |
| 533 | int s = j * outstride + i; |
| 534 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6)); |
| 535 | } |
| 536 | } |
| 537 | } |
| 538 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 539 | void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 540 | int tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 541 | static const transform_2d IHT_16x8[] = { |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 542 | { aom_idct8_c, aom_idct16_c }, // DCT_DCT |
| 543 | { aom_iadst8_c, aom_idct16_c }, // ADST_DCT |
| 544 | { aom_idct8_c, aom_iadst16_c }, // DCT_ADST |
| 545 | { aom_iadst8_c, aom_iadst16_c }, // ADST_ADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 546 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 547 | { aom_iadst8_c, aom_idct16_c }, // FLIPADST_DCT |
| 548 | { aom_idct8_c, aom_iadst16_c }, // DCT_FLIPADST |
| 549 | { aom_iadst8_c, aom_iadst16_c }, // FLIPADST_FLIPADST |
| 550 | { aom_iadst8_c, aom_iadst16_c }, // ADST_FLIPADST |
| 551 | { aom_iadst8_c, aom_iadst16_c }, // FLIPADST_ADST |
| 552 | { iidtx8_c, iidtx16_c }, // IDTX |
| 553 | { aom_idct8_c, iidtx16_c }, // V_DCT |
| 554 | { iidtx8_c, aom_idct16_c }, // H_DCT |
| 555 | { aom_iadst8_c, iidtx16_c }, // V_ADST |
| 556 | { iidtx8_c, aom_iadst16_c }, // H_ADST |
| 557 | { aom_iadst8_c, iidtx16_c }, // V_FLIPADST |
| 558 | { iidtx8_c, aom_iadst16_c }, // H_FLIPADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 559 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 560 | }; |
| 561 | const int n = 8; |
| 562 | const int n2 = 16; |
| 563 | |
| 564 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 565 | tran_low_t out[16][8], tmp[16][8], outtmp[16]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 566 | tran_low_t *outp = &out[0][0]; |
| 567 | int outstride = n; |
| 568 | |
| 569 | // inverse transform row vectors and transpose |
| 570 | for (i = 0; i < n; ++i) { |
| 571 | IHT_16x8[tx_type].rows(input, outtmp); |
| 572 | for (j = 0; j < n2; ++j) |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 573 | tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 574 | input += n2; |
| 575 | } |
| 576 | |
| 577 | // inverse transform column vectors |
| 578 | for (i = 0; i < n2; ++i) { |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 579 | IHT_16x8[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 580 | } |
| 581 | |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 582 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 583 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2); |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 584 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 585 | |
| 586 | // Sum with the destination |
| 587 | for (i = 0; i < n; ++i) { |
| 588 | for (j = 0; j < n2; ++j) { |
| 589 | int d = i * stride + j; |
| 590 | int s = j * outstride + i; |
| 591 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6)); |
| 592 | } |
| 593 | } |
| 594 | } |
| 595 | |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 596 | void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 597 | int tx_type) { |
| 598 | static const transform_2d IHT_8x32[] = { |
| 599 | { aom_idct32_c, aom_idct8_c }, // DCT_DCT |
| 600 | { ihalfright32_c, aom_idct8_c }, // ADST_DCT |
| 601 | { aom_idct32_c, aom_iadst8_c }, // DCT_ADST |
| 602 | { ihalfright32_c, aom_iadst8_c }, // ADST_ADST |
| 603 | #if CONFIG_EXT_TX |
| 604 | { ihalfright32_c, aom_idct8_c }, // FLIPADST_DCT |
| 605 | { aom_idct32_c, aom_iadst8_c }, // DCT_FLIPADST |
| 606 | { ihalfright32_c, aom_iadst8_c }, // FLIPADST_FLIPADST |
| 607 | { ihalfright32_c, aom_iadst8_c }, // ADST_FLIPADST |
| 608 | { ihalfright32_c, aom_iadst8_c }, // FLIPADST_ADST |
| 609 | { iidtx32_c, iidtx8_c }, // IDTX |
| 610 | { aom_idct32_c, iidtx8_c }, // V_DCT |
| 611 | { iidtx32_c, aom_idct8_c }, // H_DCT |
| 612 | { ihalfright32_c, iidtx8_c }, // V_ADST |
| 613 | { iidtx32_c, aom_iadst8_c }, // H_ADST |
| 614 | { ihalfright32_c, iidtx8_c }, // V_FLIPADST |
| 615 | { iidtx32_c, aom_iadst8_c }, // H_FLIPADST |
| 616 | #endif |
| 617 | }; |
| 618 | |
| 619 | const int n = 8; |
| 620 | const int n4 = 32; |
| 621 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 622 | tran_low_t out[8][32], tmp[8][32], outtmp[8]; |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 623 | tran_low_t *outp = &out[0][0]; |
| 624 | int outstride = n4; |
| 625 | |
| 626 | // inverse transform row vectors and transpose |
| 627 | for (i = 0; i < n4; ++i) { |
| 628 | IHT_8x32[tx_type].rows(input, outtmp); |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 629 | for (j = 0; j < n; ++j) tmp[j][i] = outtmp[j]; |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 630 | input += n; |
| 631 | } |
| 632 | |
| 633 | // inverse transform column vectors |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 634 | for (i = 0; i < n; ++i) IHT_8x32[tx_type].cols(tmp[i], out[i]); |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 635 | |
| 636 | #if CONFIG_EXT_TX |
| 637 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n4, n); |
| 638 | #endif |
| 639 | |
| 640 | // Sum with the destination |
| 641 | for (i = 0; i < n4; ++i) { |
| 642 | for (j = 0; j < n; ++j) { |
| 643 | int d = i * stride + j; |
| 644 | int s = j * outstride + i; |
| 645 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6)); |
| 646 | } |
| 647 | } |
| 648 | } |
| 649 | |
| 650 | void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 651 | int tx_type) { |
| 652 | static const transform_2d IHT_32x8[] = { |
| 653 | { aom_idct8_c, aom_idct32_c }, // DCT_DCT |
| 654 | { aom_iadst8_c, aom_idct32_c }, // ADST_DCT |
| 655 | { aom_idct8_c, ihalfright32_c }, // DCT_ADST |
| 656 | { aom_iadst8_c, ihalfright32_c }, // ADST_ADST |
| 657 | #if CONFIG_EXT_TX |
| 658 | { aom_iadst8_c, aom_idct32_c }, // FLIPADST_DCT |
| 659 | { aom_idct8_c, ihalfright32_c }, // DCT_FLIPADST |
| 660 | { aom_iadst8_c, ihalfright32_c }, // FLIPADST_FLIPADST |
| 661 | { aom_iadst8_c, ihalfright32_c }, // ADST_FLIPADST |
| 662 | { aom_iadst8_c, ihalfright32_c }, // FLIPADST_ADST |
| 663 | { iidtx8_c, iidtx32_c }, // IDTX |
| 664 | { aom_idct8_c, iidtx32_c }, // V_DCT |
| 665 | { iidtx8_c, aom_idct32_c }, // H_DCT |
| 666 | { aom_iadst8_c, iidtx32_c }, // V_ADST |
| 667 | { iidtx8_c, ihalfright32_c }, // H_ADST |
| 668 | { aom_iadst8_c, iidtx32_c }, // V_FLIPADST |
| 669 | { iidtx8_c, ihalfright32_c }, // H_FLIPADST |
| 670 | #endif |
| 671 | }; |
| 672 | const int n = 8; |
| 673 | const int n4 = 32; |
| 674 | |
| 675 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 676 | tran_low_t out[32][8], tmp[32][8], outtmp[32]; |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 677 | tran_low_t *outp = &out[0][0]; |
| 678 | int outstride = n; |
| 679 | |
| 680 | // inverse transform row vectors and transpose |
| 681 | for (i = 0; i < n; ++i) { |
| 682 | IHT_32x8[tx_type].rows(input, outtmp); |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 683 | for (j = 0; j < n4; ++j) tmp[j][i] = outtmp[j]; |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 684 | input += n4; |
| 685 | } |
| 686 | |
| 687 | // inverse transform column vectors |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 688 | for (i = 0; i < n4; ++i) IHT_32x8[tx_type].cols(tmp[i], out[i]); |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 689 | |
| 690 | #if CONFIG_EXT_TX |
| 691 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n4); |
| 692 | #endif |
| 693 | |
| 694 | // Sum with the destination |
| 695 | for (i = 0; i < n; ++i) { |
| 696 | for (j = 0; j < n4; ++j) { |
| 697 | int d = i * stride + j; |
| 698 | int s = j * outstride + i; |
| 699 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6)); |
| 700 | } |
| 701 | } |
| 702 | } |
| 703 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 704 | void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 705 | int tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 706 | static const transform_2d IHT_16x32[] = { |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 707 | { aom_idct32_c, aom_idct16_c }, // DCT_DCT |
| 708 | { ihalfright32_c, aom_idct16_c }, // ADST_DCT |
| 709 | { aom_idct32_c, aom_iadst16_c }, // DCT_ADST |
| 710 | { ihalfright32_c, aom_iadst16_c }, // ADST_ADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 711 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 712 | { ihalfright32_c, aom_idct16_c }, // FLIPADST_DCT |
| 713 | { aom_idct32_c, aom_iadst16_c }, // DCT_FLIPADST |
| 714 | { ihalfright32_c, aom_iadst16_c }, // FLIPADST_FLIPADST |
| 715 | { ihalfright32_c, aom_iadst16_c }, // ADST_FLIPADST |
| 716 | { ihalfright32_c, aom_iadst16_c }, // FLIPADST_ADST |
| 717 | { iidtx32_c, iidtx16_c }, // IDTX |
| 718 | { aom_idct32_c, iidtx16_c }, // V_DCT |
| 719 | { iidtx32_c, aom_idct16_c }, // H_DCT |
| 720 | { ihalfright32_c, iidtx16_c }, // V_ADST |
| 721 | { iidtx32_c, aom_iadst16_c }, // H_ADST |
| 722 | { ihalfright32_c, iidtx16_c }, // V_FLIPADST |
| 723 | { iidtx32_c, aom_iadst16_c }, // H_FLIPADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 724 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 725 | }; |
| 726 | |
| 727 | const int n = 16; |
| 728 | const int n2 = 32; |
| 729 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 730 | tran_low_t out[16][32], tmp[16][32], outtmp[16]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 731 | tran_low_t *outp = &out[0][0]; |
| 732 | int outstride = n2; |
| 733 | |
| 734 | // inverse transform row vectors and transpose |
| 735 | for (i = 0; i < n2; ++i) { |
| 736 | IHT_16x32[tx_type].rows(input, outtmp); |
| 737 | for (j = 0; j < n; ++j) |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 738 | tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 739 | input += n; |
| 740 | } |
| 741 | |
| 742 | // inverse transform column vectors |
| 743 | for (i = 0; i < n; ++i) { |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 744 | IHT_16x32[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 745 | } |
| 746 | |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 747 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 748 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n); |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 749 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 750 | |
| 751 | // Sum with the destination |
| 752 | for (i = 0; i < n2; ++i) { |
| 753 | for (j = 0; j < n; ++j) { |
| 754 | int d = i * stride + j; |
| 755 | int s = j * outstride + i; |
| 756 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6)); |
| 757 | } |
| 758 | } |
| 759 | } |
| 760 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 761 | void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 762 | int tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 763 | static const transform_2d IHT_32x16[] = { |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 764 | { aom_idct16_c, aom_idct32_c }, // DCT_DCT |
| 765 | { aom_iadst16_c, aom_idct32_c }, // ADST_DCT |
| 766 | { aom_idct16_c, ihalfright32_c }, // DCT_ADST |
| 767 | { aom_iadst16_c, ihalfright32_c }, // ADST_ADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 768 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 769 | { aom_iadst16_c, aom_idct32_c }, // FLIPADST_DCT |
| 770 | { aom_idct16_c, ihalfright32_c }, // DCT_FLIPADST |
| 771 | { aom_iadst16_c, ihalfright32_c }, // FLIPADST_FLIPADST |
| 772 | { aom_iadst16_c, ihalfright32_c }, // ADST_FLIPADST |
| 773 | { aom_iadst16_c, ihalfright32_c }, // FLIPADST_ADST |
| 774 | { iidtx16_c, iidtx32_c }, // IDTX |
| 775 | { aom_idct16_c, iidtx32_c }, // V_DCT |
| 776 | { iidtx16_c, aom_idct32_c }, // H_DCT |
| 777 | { aom_iadst16_c, iidtx32_c }, // V_ADST |
| 778 | { iidtx16_c, ihalfright32_c }, // H_ADST |
| 779 | { aom_iadst16_c, iidtx32_c }, // V_FLIPADST |
| 780 | { iidtx16_c, ihalfright32_c }, // H_FLIPADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 781 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 782 | }; |
| 783 | const int n = 16; |
| 784 | const int n2 = 32; |
| 785 | |
| 786 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 787 | tran_low_t out[32][16], tmp[32][16], outtmp[32]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 788 | tran_low_t *outp = &out[0][0]; |
| 789 | int outstride = n; |
| 790 | |
| 791 | // inverse transform row vectors and transpose |
| 792 | for (i = 0; i < n; ++i) { |
| 793 | IHT_32x16[tx_type].rows(input, outtmp); |
| 794 | for (j = 0; j < n2; ++j) |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 795 | tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 796 | input += n2; |
| 797 | } |
| 798 | |
| 799 | // inverse transform column vectors |
| 800 | for (i = 0; i < n2; ++i) { |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 801 | IHT_32x16[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 802 | } |
| 803 | |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 804 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 805 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2); |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 806 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 807 | |
| 808 | // Sum with the destination |
| 809 | for (i = 0; i < n; ++i) { |
| 810 | for (j = 0; j < n2; ++j) { |
| 811 | int d = i * stride + j; |
| 812 | int s = j * outstride + i; |
| 813 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6)); |
| 814 | } |
| 815 | } |
| 816 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 817 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 818 | void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 819 | int tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 820 | static const transform_2d IHT_8[] = { |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 821 | { aom_idct8_c, aom_idct8_c }, // DCT_DCT = 0 |
| 822 | { aom_iadst8_c, aom_idct8_c }, // ADST_DCT = 1 |
| 823 | { aom_idct8_c, aom_iadst8_c }, // DCT_ADST = 2 |
| 824 | { aom_iadst8_c, aom_iadst8_c }, // ADST_ADST = 3 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 825 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 826 | { aom_iadst8_c, aom_idct8_c }, // FLIPADST_DCT |
| 827 | { aom_idct8_c, aom_iadst8_c }, // DCT_FLIPADST |
| 828 | { aom_iadst8_c, aom_iadst8_c }, // FLIPADST_FLIPADST |
| 829 | { aom_iadst8_c, aom_iadst8_c }, // ADST_FLIPADST |
| 830 | { aom_iadst8_c, aom_iadst8_c }, // FLIPADST_ADST |
| 831 | { iidtx8_c, iidtx8_c }, // IDTX |
| 832 | { aom_idct8_c, iidtx8_c }, // V_DCT |
| 833 | { iidtx8_c, aom_idct8_c }, // H_DCT |
| 834 | { aom_iadst8_c, iidtx8_c }, // V_ADST |
| 835 | { iidtx8_c, aom_iadst8_c }, // H_ADST |
| 836 | { aom_iadst8_c, iidtx8_c }, // V_FLIPADST |
| 837 | { iidtx8_c, aom_iadst8_c }, // H_FLIPADST |
| 838 | #endif // CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 839 | }; |
| 840 | |
| 841 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 842 | tran_low_t tmp[8][8]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 843 | tran_low_t out[8][8]; |
| 844 | tran_low_t *outp = &out[0][0]; |
| 845 | int outstride = 8; |
| 846 | |
| 847 | // inverse transform row vectors |
| 848 | for (i = 0; i < 8; ++i) { |
| 849 | IHT_8[tx_type].rows(input, out[i]); |
| 850 | input += 8; |
| 851 | } |
| 852 | |
| 853 | // transpose |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 854 | for (i = 0; i < 8; i++) { |
| 855 | for (j = 0; j < 8; j++) { |
| 856 | tmp[j][i] = out[i][j]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 857 | } |
| 858 | } |
| 859 | |
| 860 | // inverse transform column vectors |
| 861 | for (i = 0; i < 8; ++i) { |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 862 | IHT_8[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 863 | } |
| 864 | |
| 865 | #if CONFIG_EXT_TX |
| 866 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 8, 8); |
| 867 | #endif |
| 868 | |
| 869 | // Sum with the destination |
| 870 | for (i = 0; i < 8; ++i) { |
| 871 | for (j = 0; j < 8; ++j) { |
| 872 | int d = i * stride + j; |
| 873 | int s = j * outstride + i; |
| 874 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
| 875 | } |
| 876 | } |
| 877 | } |
| 878 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 879 | void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 880 | int tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 881 | static const transform_2d IHT_16[] = { |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 882 | { aom_idct16_c, aom_idct16_c }, // DCT_DCT = 0 |
| 883 | { aom_iadst16_c, aom_idct16_c }, // ADST_DCT = 1 |
| 884 | { aom_idct16_c, aom_iadst16_c }, // DCT_ADST = 2 |
| 885 | { aom_iadst16_c, aom_iadst16_c }, // ADST_ADST = 3 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 886 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 887 | { aom_iadst16_c, aom_idct16_c }, // FLIPADST_DCT |
| 888 | { aom_idct16_c, aom_iadst16_c }, // DCT_FLIPADST |
| 889 | { aom_iadst16_c, aom_iadst16_c }, // FLIPADST_FLIPADST |
| 890 | { aom_iadst16_c, aom_iadst16_c }, // ADST_FLIPADST |
| 891 | { aom_iadst16_c, aom_iadst16_c }, // FLIPADST_ADST |
| 892 | { iidtx16_c, iidtx16_c }, // IDTX |
| 893 | { aom_idct16_c, iidtx16_c }, // V_DCT |
| 894 | { iidtx16_c, aom_idct16_c }, // H_DCT |
| 895 | { aom_iadst16_c, iidtx16_c }, // V_ADST |
| 896 | { iidtx16_c, aom_iadst16_c }, // H_ADST |
| 897 | { aom_iadst16_c, iidtx16_c }, // V_FLIPADST |
| 898 | { iidtx16_c, aom_iadst16_c }, // H_FLIPADST |
| 899 | #endif // CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 900 | }; |
| 901 | |
| 902 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 903 | tran_low_t tmp[16][16]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 904 | tran_low_t out[16][16]; |
| 905 | tran_low_t *outp = &out[0][0]; |
| 906 | int outstride = 16; |
| 907 | |
| 908 | // inverse transform row vectors |
| 909 | for (i = 0; i < 16; ++i) { |
| 910 | IHT_16[tx_type].rows(input, out[i]); |
| 911 | input += 16; |
| 912 | } |
| 913 | |
| 914 | // transpose |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 915 | for (i = 0; i < 16; i++) { |
| 916 | for (j = 0; j < 16; j++) { |
| 917 | tmp[j][i] = out[i][j]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 918 | } |
| 919 | } |
| 920 | |
| 921 | // inverse transform column vectors |
| 922 | for (i = 0; i < 16; ++i) { |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 923 | IHT_16[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 924 | } |
| 925 | |
| 926 | #if CONFIG_EXT_TX |
| 927 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 16, 16); |
| 928 | #endif |
| 929 | |
| 930 | // Sum with the destination |
| 931 | for (i = 0; i < 16; ++i) { |
| 932 | for (j = 0; j < 16; ++j) { |
| 933 | int d = i * stride + j; |
| 934 | int s = j * outstride + i; |
| 935 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6)); |
| 936 | } |
| 937 | } |
| 938 | } |
| 939 | |
| 940 | #if CONFIG_EXT_TX |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 941 | void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 942 | int tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 943 | static const transform_2d IHT_32[] = { |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 944 | { aom_idct32_c, aom_idct32_c }, // DCT_DCT |
| 945 | { ihalfright32_c, aom_idct32_c }, // ADST_DCT |
| 946 | { aom_idct32_c, ihalfright32_c }, // DCT_ADST |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 947 | { ihalfright32_c, ihalfright32_c }, // ADST_ADST |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 948 | { ihalfright32_c, aom_idct32_c }, // FLIPADST_DCT |
| 949 | { aom_idct32_c, ihalfright32_c }, // DCT_FLIPADST |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 950 | { ihalfright32_c, ihalfright32_c }, // FLIPADST_FLIPADST |
| 951 | { ihalfright32_c, ihalfright32_c }, // ADST_FLIPADST |
| 952 | { ihalfright32_c, ihalfright32_c }, // FLIPADST_ADST |
| 953 | { iidtx32_c, iidtx32_c }, // IDTX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 954 | { aom_idct32_c, iidtx32_c }, // V_DCT |
| 955 | { iidtx32_c, aom_idct32_c }, // H_DCT |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 956 | { ihalfright32_c, iidtx32_c }, // V_ADST |
| 957 | { iidtx32_c, ihalfright32_c }, // H_ADST |
| 958 | { ihalfright32_c, iidtx32_c }, // V_FLIPADST |
| 959 | { iidtx32_c, ihalfright32_c }, // H_FLIPADST |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 960 | }; |
| 961 | |
| 962 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 963 | tran_low_t tmp[32][32]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 964 | tran_low_t out[32][32]; |
| 965 | tran_low_t *outp = &out[0][0]; |
| 966 | int outstride = 32; |
| 967 | |
| 968 | // inverse transform row vectors |
| 969 | for (i = 0; i < 32; ++i) { |
| 970 | IHT_32[tx_type].rows(input, out[i]); |
| 971 | input += 32; |
| 972 | } |
| 973 | |
| 974 | // transpose |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 975 | for (i = 0; i < 32; i++) { |
| 976 | for (j = 0; j < 32; j++) { |
| 977 | tmp[j][i] = out[i][j]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 978 | } |
| 979 | } |
| 980 | |
| 981 | // inverse transform column vectors |
| 982 | for (i = 0; i < 32; ++i) { |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 983 | IHT_32[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 984 | } |
| 985 | |
| 986 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 32, 32); |
| 987 | |
| 988 | // Sum with the destination |
| 989 | for (i = 0; i < 32; ++i) { |
| 990 | for (j = 0; j < 32; ++j) { |
| 991 | int d = i * stride + j; |
| 992 | int s = j * outstride + i; |
| 993 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6)); |
| 994 | } |
| 995 | } |
| 996 | } |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 997 | #endif // CONFIG_EXT_TX |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 998 | |
| 999 | #if CONFIG_TX64X64 |
| 1000 | void av1_iht64x64_4096_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 1001 | int tx_type) { |
| 1002 | static const transform_2d IHT_64[] = { |
| 1003 | { idct64_col_c, idct64_row_c }, // DCT_DCT |
| 1004 | { ihalfright64_c, idct64_row_c }, // ADST_DCT |
| 1005 | { idct64_col_c, ihalfright64_c }, // DCT_ADST |
| 1006 | { ihalfright64_c, ihalfright64_c }, // ADST_ADST |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 1007 | #if CONFIG_EXT_TX |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 1008 | { ihalfright64_c, idct64_row_c }, // FLIPADST_DCT |
| 1009 | { idct64_col_c, ihalfright64_c }, // DCT_FLIPADST |
| 1010 | { ihalfright64_c, ihalfright64_c }, // FLIPADST_FLIPADST |
| 1011 | { ihalfright64_c, ihalfright64_c }, // ADST_FLIPADST |
| 1012 | { ihalfright64_c, ihalfright64_c }, // FLIPADST_ADST |
| 1013 | { iidtx64_c, iidtx64_c }, // IDTX |
| 1014 | { idct64_col_c, iidtx64_c }, // V_DCT |
| 1015 | { iidtx64_c, idct64_row_c }, // H_DCT |
| 1016 | { ihalfright64_c, iidtx64_c }, // V_ADST |
| 1017 | { iidtx64_c, ihalfright64_c }, // H_ADST |
| 1018 | { ihalfright64_c, iidtx64_c }, // V_FLIPADST |
| 1019 | { iidtx64_c, ihalfright64_c }, // H_FLIPADST |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 1020 | #endif // CONFIG_EXT_TX |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 1021 | }; |
| 1022 | |
| 1023 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1024 | tran_low_t tmp[64][64]; |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 1025 | tran_low_t out[64][64]; |
| 1026 | tran_low_t *outp = &out[0][0]; |
| 1027 | int outstride = 64; |
| 1028 | |
| 1029 | // inverse transform row vectors |
| 1030 | for (i = 0; i < 64; ++i) { |
| 1031 | IHT_64[tx_type].rows(input, out[i]); |
| 1032 | for (j = 0; j < 64; ++j) out[i][j] = ROUND_POWER_OF_TWO(out[i][j], 1); |
| 1033 | input += 64; |
| 1034 | } |
| 1035 | |
| 1036 | // transpose |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1037 | for (i = 0; i < 64; i++) { |
| 1038 | for (j = 0; j < 64; j++) { |
| 1039 | tmp[j][i] = out[i][j]; |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 1040 | } |
| 1041 | } |
| 1042 | |
| 1043 | // inverse transform column vectors |
| 1044 | for (i = 0; i < 64; ++i) { |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1045 | IHT_64[tx_type].cols(tmp[i], out[i]); |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 1046 | } |
| 1047 | |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 1048 | #if CONFIG_EXT_TX |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 1049 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 64, 64); |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 1050 | #endif // CONFIG_EXT_TX |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 1051 | |
| 1052 | // Sum with the destination |
| 1053 | for (i = 0; i < 64; ++i) { |
| 1054 | for (j = 0; j < 64; ++j) { |
| 1055 | int d = i * stride + j; |
| 1056 | int s = j * outstride + i; |
| 1057 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
| 1058 | } |
| 1059 | } |
| 1060 | } |
| 1061 | #endif // CONFIG_TX64X64 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1062 | |
| 1063 | // idct |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1064 | void av1_idct4x4_add(const tran_low_t *input, uint8_t *dest, int stride, |
| 1065 | int eob) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1066 | if (eob > 1) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1067 | aom_idct4x4_16_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1068 | else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1069 | aom_idct4x4_1_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1070 | } |
| 1071 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1072 | void av1_iwht4x4_add(const tran_low_t *input, uint8_t *dest, int stride, |
| 1073 | int eob) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1074 | if (eob > 1) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1075 | aom_iwht4x4_16_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1076 | else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1077 | aom_iwht4x4_1_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1078 | } |
| 1079 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1080 | static void idct8x8_add(const tran_low_t *input, uint8_t *dest, int stride, |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1081 | const INV_TXFM_PARAM *param) { |
| 1082 | // If dc is 1, then input[0] is the reconstructed value, do not need |
| 1083 | // dequantization. Also, when dc is 1, dc is counted in eobs, namely eobs >=1. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1084 | |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1085 | // The calculation can be simplified if there are not many non-zero dct |
| 1086 | // coefficients. Use eobs to decide what to do. |
| 1087 | // TODO(yunqingwang): "eobs = 1" case is also handled in av1_short_idct8x8_c. |
| 1088 | // Combine that with code here. |
| 1089 | #if CONFIG_ADAPT_SCAN |
| 1090 | const int16_t half = param->eob_threshold[0]; |
| 1091 | #else |
| 1092 | const int16_t half = 12; |
| 1093 | #endif |
| 1094 | |
| 1095 | const int eob = param->eob; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1096 | if (eob == 1) |
| 1097 | // DC only DCT coefficient |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1098 | aom_idct8x8_1_add(input, dest, stride); |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1099 | else if (eob <= half) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1100 | aom_idct8x8_12_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1101 | else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1102 | aom_idct8x8_64_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1103 | } |
| 1104 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1105 | static void idct16x16_add(const tran_low_t *input, uint8_t *dest, int stride, |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1106 | const INV_TXFM_PARAM *param) { |
| 1107 | // The calculation can be simplified if there are not many non-zero dct |
| 1108 | // coefficients. Use eobs to separate different cases. |
| 1109 | #if CONFIG_ADAPT_SCAN |
| 1110 | const int16_t half = param->eob_threshold[0]; |
| 1111 | const int16_t quarter = param->eob_threshold[1]; |
| 1112 | #else |
| 1113 | const int16_t half = 38; |
| 1114 | const int16_t quarter = 10; |
| 1115 | #endif |
| 1116 | |
| 1117 | const int eob = param->eob; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1118 | if (eob == 1) /* DC only DCT coefficient. */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1119 | aom_idct16x16_1_add(input, dest, stride); |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1120 | else if (eob <= quarter) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1121 | aom_idct16x16_10_add(input, dest, stride); |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1122 | else if (eob <= half) |
Yi Luo | f6176ab | 2017-04-28 15:48:56 -0700 | [diff] [blame] | 1123 | aom_idct16x16_38_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1124 | else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1125 | aom_idct16x16_256_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1126 | } |
| 1127 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1128 | static void idct32x32_add(const tran_low_t *input, uint8_t *dest, int stride, |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1129 | const INV_TXFM_PARAM *param) { |
| 1130 | #if CONFIG_ADAPT_SCAN |
| 1131 | const int16_t half = param->eob_threshold[0]; |
| 1132 | const int16_t quarter = param->eob_threshold[1]; |
| 1133 | #else |
| 1134 | const int16_t half = 135; |
| 1135 | const int16_t quarter = 34; |
| 1136 | #endif |
| 1137 | |
| 1138 | const int eob = param->eob; |
| 1139 | if (eob == 1) |
| 1140 | aom_idct32x32_1_add(input, dest, stride); |
| 1141 | else if (eob <= quarter) |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1142 | // non-zero coeff only in upper-left 8x8 |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1143 | aom_idct32x32_34_add(input, dest, stride); |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1144 | else if (eob <= half) |
Yi Luo | 40f22ef | 2017-05-08 16:29:39 -0700 | [diff] [blame] | 1145 | // non-zero coeff only in upper-left 16x16 |
| 1146 | aom_idct32x32_135_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1147 | else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1148 | aom_idct32x32_1024_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1149 | } |
| 1150 | |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 1151 | #if CONFIG_TX64X64 |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1152 | static void idct64x64_add(const tran_low_t *input, uint8_t *dest, int stride, |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1153 | const INV_TXFM_PARAM *param) { |
| 1154 | (void)param; |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 1155 | av1_iht64x64_4096_add(input, dest, stride, DCT_DCT); |
| 1156 | } |
| 1157 | #endif // CONFIG_TX64X64 |
| 1158 | |
Timothy B. Terriberry | fe67ed6 | 2017-04-26 16:53:47 -0700 | [diff] [blame] | 1159 | #if CONFIG_CHROMA_2X2 |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1160 | static void inv_txfm_add_2x2(const tran_low_t *input, uint8_t *dest, int stride, |
| 1161 | int eob, TX_TYPE tx_type, int lossless) { |
Jingning Han | d7ec47f | 2016-11-29 16:34:40 -0800 | [diff] [blame] | 1162 | tran_high_t a1 = input[0] >> UNIT_QUANT_SHIFT; |
| 1163 | tran_high_t b1 = input[1] >> UNIT_QUANT_SHIFT; |
| 1164 | tran_high_t c1 = input[2] >> UNIT_QUANT_SHIFT; |
| 1165 | tran_high_t d1 = input[3] >> UNIT_QUANT_SHIFT; |
| 1166 | |
| 1167 | tran_high_t a2 = a1 + c1; |
| 1168 | tran_high_t b2 = b1 + d1; |
| 1169 | tran_high_t c2 = a1 - c1; |
| 1170 | tran_high_t d2 = b1 - d1; |
| 1171 | |
| 1172 | (void)tx_type; |
| 1173 | (void)lossless; |
| 1174 | (void)eob; |
| 1175 | |
Jingning Han | 4629661 | 2016-11-30 09:54:01 -0800 | [diff] [blame] | 1176 | a1 = (a2 + b2) >> 2; |
| 1177 | b1 = (a2 - b2) >> 2; |
| 1178 | c1 = (c2 + d2) >> 2; |
| 1179 | d1 = (c2 - d2) >> 2; |
Jingning Han | d7ec47f | 2016-11-29 16:34:40 -0800 | [diff] [blame] | 1180 | |
| 1181 | dest[0] = clip_pixel_add(dest[0], WRAPLOW(a1)); |
| 1182 | dest[1] = clip_pixel_add(dest[1], WRAPLOW(b1)); |
| 1183 | dest[stride] = clip_pixel_add(dest[stride], WRAPLOW(c1)); |
| 1184 | dest[stride + 1] = clip_pixel_add(dest[stride + 1], WRAPLOW(d1)); |
| 1185 | } |
| 1186 | #endif |
| 1187 | |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1188 | static void inv_txfm_add_4x4(const tran_low_t *input, uint8_t *dest, int stride, |
| 1189 | int eob, TX_TYPE tx_type, int lossless) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1190 | if (lossless) { |
| 1191 | assert(tx_type == DCT_DCT); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1192 | av1_iwht4x4_add(input, dest, stride, eob); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1193 | return; |
| 1194 | } |
| 1195 | |
| 1196 | switch (tx_type) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1197 | case DCT_DCT: av1_idct4x4_add(input, dest, stride, eob); break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1198 | case ADST_DCT: |
| 1199 | case DCT_ADST: |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1200 | case ADST_ADST: |
| 1201 | #if CONFIG_LGT |
| 1202 | // LGT only exists in C verson |
| 1203 | av1_iht4x4_16_add_c(input, dest, stride, tx_type); |
| 1204 | break; |
| 1205 | #else |
| 1206 | av1_iht4x4_16_add(input, dest, stride, tx_type); |
| 1207 | break; |
| 1208 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1209 | #if CONFIG_EXT_TX |
| 1210 | case FLIPADST_DCT: |
| 1211 | case DCT_FLIPADST: |
| 1212 | case FLIPADST_FLIPADST: |
| 1213 | case ADST_FLIPADST: |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1214 | case FLIPADST_ADST: |
| 1215 | #if CONFIG_LGT |
| 1216 | av1_iht4x4_16_add_c(input, dest, stride, tx_type); |
| 1217 | break; |
| 1218 | #else |
| 1219 | av1_iht4x4_16_add(input, dest, stride, tx_type); |
| 1220 | break; |
| 1221 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1222 | case V_DCT: |
| 1223 | case H_DCT: |
| 1224 | case V_ADST: |
| 1225 | case H_ADST: |
| 1226 | case V_FLIPADST: |
| 1227 | case H_FLIPADST: |
| 1228 | // Use C version since DST only exists in C code |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1229 | av1_iht4x4_16_add_c(input, dest, stride, tx_type); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1230 | break; |
| 1231 | case IDTX: inv_idtx_add_c(input, dest, stride, 4, tx_type); break; |
| 1232 | #endif // CONFIG_EXT_TX |
| 1233 | default: assert(0); break; |
| 1234 | } |
| 1235 | } |
| 1236 | |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1237 | static void inv_txfm_add_4x8(const tran_low_t *input, uint8_t *dest, int stride, |
| 1238 | int eob, TX_TYPE tx_type) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1239 | (void)eob; |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1240 | #if CONFIG_LGT |
| 1241 | av1_iht4x8_32_add_c(input, dest, stride, tx_type); |
| 1242 | #else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1243 | av1_iht4x8_32_add(input, dest, stride, tx_type); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1244 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1245 | } |
| 1246 | |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1247 | static void inv_txfm_add_8x4(const tran_low_t *input, uint8_t *dest, int stride, |
| 1248 | int eob, TX_TYPE tx_type) { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1249 | (void)eob; |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1250 | #if CONFIG_LGT |
| 1251 | av1_iht8x4_32_add_c(input, dest, stride, tx_type); |
| 1252 | #else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1253 | av1_iht8x4_32_add(input, dest, stride, tx_type); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1254 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1255 | } |
| 1256 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1257 | // These will be used by the masked-tx experiment in the future. |
Yue Chen | 56e226e | 2017-05-02 16:21:40 -0700 | [diff] [blame] | 1258 | #if CONFIG_RECT_TX && CONFIG_EXT_TX && CONFIG_RECT_TX_EXT |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1259 | static void inv_txfm_add_4x16(const tran_low_t *input, uint8_t *dest, |
| 1260 | int stride, int eob, TX_TYPE tx_type) { |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1261 | (void)eob; |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1262 | #if CONFIG_LGT |
| 1263 | av1_iht4x16_64_add_c(input, dest, stride, tx_type); |
| 1264 | #else |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1265 | av1_iht4x16_64_add(input, dest, stride, tx_type); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1266 | #endif |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1267 | } |
| 1268 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1269 | static void inv_txfm_add_16x4(const tran_low_t *input, uint8_t *dest, |
| 1270 | int stride, int eob, TX_TYPE tx_type) { |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1271 | (void)eob; |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1272 | #if CONFIG_LGT |
| 1273 | av1_iht16x4_64_add_c(input, dest, stride, tx_type); |
| 1274 | #else |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1275 | av1_iht16x4_64_add(input, dest, stride, tx_type); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1276 | #endif |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1277 | } |
| 1278 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1279 | static void inv_txfm_add_8x32(const tran_low_t *input, uint8_t *dest, |
| 1280 | int stride, int eob, TX_TYPE tx_type) { |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1281 | (void)eob; |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1282 | #if CONFIG_LGT |
| 1283 | av1_iht8x32_256_add_c(input, dest, stride, tx_type); |
| 1284 | #else |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1285 | av1_iht8x32_256_add(input, dest, stride, tx_type); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1286 | #endif |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1287 | } |
| 1288 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1289 | static void inv_txfm_add_32x8(const tran_low_t *input, uint8_t *dest, |
| 1290 | int stride, int eob, TX_TYPE tx_type) { |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1291 | (void)eob; |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1292 | #if CONFIG_LGT |
| 1293 | av1_iht32x8_256_add_c(input, dest, stride, tx_type); |
| 1294 | #else |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1295 | av1_iht32x8_256_add(input, dest, stride, tx_type); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1296 | #endif |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1297 | } |
Yue Chen | 56e226e | 2017-05-02 16:21:40 -0700 | [diff] [blame] | 1298 | #endif |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1299 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1300 | static void inv_txfm_add_8x16(const tran_low_t *input, uint8_t *dest, |
| 1301 | int stride, int eob, TX_TYPE tx_type) { |
| 1302 | (void)eob; |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1303 | #if CONFIG_LGT |
| 1304 | av1_iht8x16_128_add_c(input, dest, stride, tx_type); |
| 1305 | #else |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1306 | av1_iht8x16_128_add(input, dest, stride, tx_type); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1307 | #endif |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1308 | } |
| 1309 | |
| 1310 | static void inv_txfm_add_16x8(const tran_low_t *input, uint8_t *dest, |
| 1311 | int stride, int eob, TX_TYPE tx_type) { |
| 1312 | (void)eob; |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1313 | #if CONFIG_LGT |
| 1314 | av1_iht16x8_128_add_c(input, dest, stride, tx_type); |
| 1315 | #else |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1316 | av1_iht16x8_128_add(input, dest, stride, tx_type); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1317 | #endif |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1318 | } |
| 1319 | |
| 1320 | static void inv_txfm_add_16x32(const tran_low_t *input, uint8_t *dest, |
| 1321 | int stride, int eob, TX_TYPE tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1322 | (void)eob; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1323 | av1_iht16x32_512_add(input, dest, stride, tx_type); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1324 | } |
| 1325 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1326 | static void inv_txfm_add_32x16(const tran_low_t *input, uint8_t *dest, |
| 1327 | int stride, int eob, TX_TYPE tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1328 | (void)eob; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1329 | av1_iht32x16_512_add(input, dest, stride, tx_type); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1330 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1331 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1332 | static void inv_txfm_add_8x8(const tran_low_t *input, uint8_t *dest, int stride, |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1333 | const INV_TXFM_PARAM *param) { |
| 1334 | const TX_TYPE tx_type = param->tx_type; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1335 | switch (tx_type) { |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1336 | case DCT_DCT: idct8x8_add(input, dest, stride, param); break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1337 | case ADST_DCT: |
| 1338 | case DCT_ADST: |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1339 | case ADST_ADST: |
| 1340 | #if CONFIG_LGT |
| 1341 | av1_iht8x8_64_add_c(input, dest, stride, tx_type); |
| 1342 | break; |
| 1343 | #else |
| 1344 | av1_iht8x8_64_add(input, dest, stride, tx_type); |
| 1345 | break; |
| 1346 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1347 | #if CONFIG_EXT_TX |
| 1348 | case FLIPADST_DCT: |
| 1349 | case DCT_FLIPADST: |
| 1350 | case FLIPADST_FLIPADST: |
| 1351 | case ADST_FLIPADST: |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame^] | 1352 | case FLIPADST_ADST: |
| 1353 | #if CONFIG_LGT |
| 1354 | av1_iht8x8_64_add_c(input, dest, stride, tx_type); |
| 1355 | break; |
| 1356 | #else |
| 1357 | av1_iht8x8_64_add(input, dest, stride, tx_type); |
| 1358 | break; |
| 1359 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1360 | case V_DCT: |
| 1361 | case H_DCT: |
| 1362 | case V_ADST: |
| 1363 | case H_ADST: |
| 1364 | case V_FLIPADST: |
| 1365 | case H_FLIPADST: |
| 1366 | // Use C version since DST only exists in C code |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1367 | av1_iht8x8_64_add_c(input, dest, stride, tx_type); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1368 | break; |
| 1369 | case IDTX: inv_idtx_add_c(input, dest, stride, 8, tx_type); break; |
| 1370 | #endif // CONFIG_EXT_TX |
| 1371 | default: assert(0); break; |
| 1372 | } |
| 1373 | } |
| 1374 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1375 | static void inv_txfm_add_16x16(const tran_low_t *input, uint8_t *dest, |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1376 | int stride, const INV_TXFM_PARAM *param) { |
| 1377 | const TX_TYPE tx_type = param->tx_type; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1378 | switch (tx_type) { |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1379 | case DCT_DCT: idct16x16_add(input, dest, stride, param); break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1380 | case ADST_DCT: |
| 1381 | case DCT_ADST: |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1382 | case ADST_ADST: av1_iht16x16_256_add(input, dest, stride, tx_type); break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1383 | #if CONFIG_EXT_TX |
| 1384 | case FLIPADST_DCT: |
| 1385 | case DCT_FLIPADST: |
| 1386 | case FLIPADST_FLIPADST: |
| 1387 | case ADST_FLIPADST: |
| 1388 | case FLIPADST_ADST: |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1389 | case V_DCT: |
| 1390 | case H_DCT: |
| 1391 | case V_ADST: |
| 1392 | case H_ADST: |
| 1393 | case V_FLIPADST: |
Yi Luo | 7317200 | 2016-10-28 10:52:04 -0700 | [diff] [blame] | 1394 | case H_FLIPADST: av1_iht16x16_256_add(input, dest, stride, tx_type); break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1395 | case IDTX: inv_idtx_add_c(input, dest, stride, 16, tx_type); break; |
| 1396 | #endif // CONFIG_EXT_TX |
| 1397 | default: assert(0); break; |
| 1398 | } |
| 1399 | } |
| 1400 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1401 | static void inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest, |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1402 | int stride, const INV_TXFM_PARAM *param) { |
| 1403 | const TX_TYPE tx_type = param->tx_type; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1404 | switch (tx_type) { |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1405 | case DCT_DCT: idct32x32_add(input, dest, stride, param); break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1406 | #if CONFIG_EXT_TX |
| 1407 | case ADST_DCT: |
| 1408 | case DCT_ADST: |
| 1409 | case ADST_ADST: |
| 1410 | case FLIPADST_DCT: |
| 1411 | case DCT_FLIPADST: |
| 1412 | case FLIPADST_FLIPADST: |
| 1413 | case ADST_FLIPADST: |
| 1414 | case FLIPADST_ADST: |
| 1415 | case V_DCT: |
| 1416 | case H_DCT: |
| 1417 | case V_ADST: |
| 1418 | case H_ADST: |
| 1419 | case V_FLIPADST: |
| 1420 | case H_FLIPADST: |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1421 | av1_iht32x32_1024_add_c(input, dest, stride, tx_type); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1422 | break; |
| 1423 | case IDTX: inv_idtx_add_c(input, dest, stride, 32, tx_type); break; |
| 1424 | #endif // CONFIG_EXT_TX |
| 1425 | default: assert(0); break; |
| 1426 | } |
| 1427 | } |
| 1428 | |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 1429 | #if CONFIG_TX64X64 |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1430 | static void inv_txfm_add_64x64(const tran_low_t *input, uint8_t *dest, |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1431 | int stride, const INV_TXFM_PARAM *param) { |
| 1432 | const TX_TYPE tx_type = param->tx_type; |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 1433 | switch (tx_type) { |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1434 | case DCT_DCT: idct64x64_add(input, dest, stride, param); break; |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 1435 | #if CONFIG_EXT_TX |
| 1436 | case ADST_DCT: |
| 1437 | case DCT_ADST: |
| 1438 | case ADST_ADST: |
| 1439 | case FLIPADST_DCT: |
| 1440 | case DCT_FLIPADST: |
| 1441 | case FLIPADST_FLIPADST: |
| 1442 | case ADST_FLIPADST: |
| 1443 | case FLIPADST_ADST: |
| 1444 | case V_DCT: |
| 1445 | case H_DCT: |
| 1446 | case V_ADST: |
| 1447 | case H_ADST: |
| 1448 | case V_FLIPADST: |
| 1449 | case H_FLIPADST: |
| 1450 | av1_iht64x64_4096_add_c(input, dest, stride, tx_type); |
| 1451 | break; |
| 1452 | case IDTX: inv_idtx_add_c(input, dest, stride, 64, tx_type); break; |
| 1453 | #endif // CONFIG_EXT_TX |
| 1454 | default: assert(0); break; |
| 1455 | } |
| 1456 | } |
| 1457 | #endif // CONFIG_TX64X64 |
| 1458 | |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 1459 | #if CONFIG_HIGHBITDEPTH |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1460 | // idct |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1461 | void av1_highbd_idct4x4_add(const tran_low_t *input, uint8_t *dest, int stride, |
| 1462 | int eob, int bd) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1463 | if (eob > 1) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1464 | aom_highbd_idct4x4_16_add(input, dest, stride, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1465 | else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1466 | aom_highbd_idct4x4_1_add(input, dest, stride, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1467 | } |
| 1468 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1469 | void av1_highbd_iwht4x4_add(const tran_low_t *input, uint8_t *dest, int stride, |
| 1470 | int eob, int bd) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1471 | if (eob > 1) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1472 | aom_highbd_iwht4x4_16_add(input, dest, stride, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1473 | else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1474 | aom_highbd_iwht4x4_1_add(input, dest, stride, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1475 | } |
| 1476 | |
Timothy B. Terriberry | fe67ed6 | 2017-04-26 16:53:47 -0700 | [diff] [blame] | 1477 | #if CONFIG_CHROMA_2X2 |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1478 | static void highbd_inv_txfm_add_2x2(const tran_low_t *input, uint8_t *dest, |
| 1479 | int stride, int eob, int bd, |
| 1480 | TX_TYPE tx_type, int lossless) { |
Jingning Han | b1ed8d7 | 2016-12-19 10:21:14 -0800 | [diff] [blame] | 1481 | tran_high_t a1 = input[0] >> UNIT_QUANT_SHIFT; |
| 1482 | tran_high_t b1 = input[1] >> UNIT_QUANT_SHIFT; |
| 1483 | tran_high_t c1 = input[2] >> UNIT_QUANT_SHIFT; |
| 1484 | tran_high_t d1 = input[3] >> UNIT_QUANT_SHIFT; |
| 1485 | |
| 1486 | tran_high_t a2 = a1 + c1; |
| 1487 | tran_high_t b2 = b1 + d1; |
| 1488 | tran_high_t c2 = a1 - c1; |
| 1489 | tran_high_t d2 = b1 - d1; |
| 1490 | |
| 1491 | uint16_t *dst = CONVERT_TO_SHORTPTR(dest); |
| 1492 | |
| 1493 | (void)tx_type; |
| 1494 | (void)lossless; |
| 1495 | (void)eob; |
| 1496 | |
| 1497 | a1 = (a2 + b2) >> 2; |
| 1498 | b1 = (a2 - b2) >> 2; |
| 1499 | c1 = (c2 + d2) >> 2; |
| 1500 | d1 = (c2 - d2) >> 2; |
| 1501 | |
| 1502 | dst[0] = highbd_clip_pixel_add(dst[0], a1, bd); |
| 1503 | dst[1] = highbd_clip_pixel_add(dst[1], b1, bd); |
| 1504 | dst[stride] = highbd_clip_pixel_add(dst[stride], c1, bd); |
| 1505 | dst[stride + 1] = highbd_clip_pixel_add(dst[stride + 1], d1, bd); |
| 1506 | } |
| 1507 | #endif |
| 1508 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1509 | void av1_highbd_inv_txfm_add_4x4(const tran_low_t *input, uint8_t *dest, |
| 1510 | int stride, int eob, int bd, TX_TYPE tx_type, |
| 1511 | int lossless) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1512 | if (lossless) { |
| 1513 | assert(tx_type == DCT_DCT); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1514 | av1_highbd_iwht4x4_add(input, dest, stride, eob, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1515 | return; |
| 1516 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1517 | switch (tx_type) { |
| 1518 | case DCT_DCT: |
| 1519 | case ADST_DCT: |
| 1520 | case DCT_ADST: |
| 1521 | case ADST_ADST: |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1522 | av1_inv_txfm2d_add_4x4(input, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
| 1523 | bd); |
| 1524 | break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1525 | #if CONFIG_EXT_TX |
| 1526 | case FLIPADST_DCT: |
| 1527 | case DCT_FLIPADST: |
| 1528 | case FLIPADST_FLIPADST: |
| 1529 | case ADST_FLIPADST: |
| 1530 | case FLIPADST_ADST: |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1531 | av1_inv_txfm2d_add_4x4(input, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
| 1532 | bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1533 | break; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1534 | // use the c version for anything including identity for now |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1535 | case V_DCT: |
| 1536 | case H_DCT: |
| 1537 | case V_ADST: |
| 1538 | case H_ADST: |
| 1539 | case V_FLIPADST: |
| 1540 | case H_FLIPADST: |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1541 | case IDTX: |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1542 | av1_inv_txfm2d_add_4x4_c(input, CONVERT_TO_SHORTPTR(dest), stride, |
| 1543 | tx_type, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1544 | break; |
| 1545 | #endif // CONFIG_EXT_TX |
| 1546 | default: assert(0); break; |
| 1547 | } |
| 1548 | } |
| 1549 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1550 | void av1_highbd_inv_txfm_add_4x8(const tran_low_t *input, uint8_t *dest, |
| 1551 | int stride, int eob, int bd, TX_TYPE tx_type) { |
| 1552 | (void)eob; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1553 | av1_inv_txfm2d_add_4x8_c(input, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
| 1554 | bd); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1555 | } |
| 1556 | |
| 1557 | void av1_highbd_inv_txfm_add_8x4(const tran_low_t *input, uint8_t *dest, |
| 1558 | int stride, int eob, int bd, TX_TYPE tx_type) { |
| 1559 | (void)eob; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1560 | av1_inv_txfm2d_add_8x4_c(input, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
| 1561 | bd); |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1562 | } |
| 1563 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1564 | static void highbd_inv_txfm_add_8x16(const tran_low_t *input, uint8_t *dest, |
| 1565 | int stride, int eob, int bd, |
| 1566 | TX_TYPE tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1567 | (void)eob; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1568 | av1_inv_txfm2d_add_8x16_c(input, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
| 1569 | bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1570 | } |
| 1571 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1572 | static void highbd_inv_txfm_add_16x8(const tran_low_t *input, uint8_t *dest, |
| 1573 | int stride, int eob, int bd, |
| 1574 | TX_TYPE tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1575 | (void)eob; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1576 | av1_inv_txfm2d_add_16x8_c(input, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
| 1577 | bd); |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1578 | } |
| 1579 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1580 | static void highbd_inv_txfm_add_16x32(const tran_low_t *input, uint8_t *dest, |
| 1581 | int stride, int eob, int bd, |
| 1582 | TX_TYPE tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1583 | (void)eob; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1584 | av1_inv_txfm2d_add_16x32_c(input, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
| 1585 | bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1586 | } |
| 1587 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1588 | static void highbd_inv_txfm_add_32x16(const tran_low_t *input, uint8_t *dest, |
| 1589 | int stride, int eob, int bd, |
| 1590 | TX_TYPE tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1591 | (void)eob; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1592 | av1_inv_txfm2d_add_32x16_c(input, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
| 1593 | bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1594 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1595 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1596 | static void highbd_inv_txfm_add_8x8(const tran_low_t *input, uint8_t *dest, |
| 1597 | int stride, int eob, int bd, |
| 1598 | TX_TYPE tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1599 | (void)eob; |
| 1600 | switch (tx_type) { |
| 1601 | case DCT_DCT: |
| 1602 | case ADST_DCT: |
| 1603 | case DCT_ADST: |
| 1604 | case ADST_ADST: |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1605 | av1_inv_txfm2d_add_8x8(input, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
| 1606 | bd); |
| 1607 | break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1608 | #if CONFIG_EXT_TX |
| 1609 | case FLIPADST_DCT: |
| 1610 | case DCT_FLIPADST: |
| 1611 | case FLIPADST_FLIPADST: |
| 1612 | case ADST_FLIPADST: |
| 1613 | case FLIPADST_ADST: |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1614 | av1_inv_txfm2d_add_8x8(input, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
| 1615 | bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1616 | break; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1617 | // use the c version for anything including identity for now |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1618 | case V_DCT: |
| 1619 | case H_DCT: |
| 1620 | case V_ADST: |
| 1621 | case H_ADST: |
| 1622 | case V_FLIPADST: |
| 1623 | case H_FLIPADST: |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1624 | case IDTX: |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1625 | av1_inv_txfm2d_add_8x8_c(input, CONVERT_TO_SHORTPTR(dest), stride, |
| 1626 | tx_type, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1627 | break; |
| 1628 | #endif // CONFIG_EXT_TX |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1629 | default: assert(0); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1630 | } |
| 1631 | } |
| 1632 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1633 | static void highbd_inv_txfm_add_16x16(const tran_low_t *input, uint8_t *dest, |
| 1634 | int stride, int eob, int bd, |
| 1635 | TX_TYPE tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1636 | (void)eob; |
| 1637 | switch (tx_type) { |
| 1638 | case DCT_DCT: |
| 1639 | case ADST_DCT: |
| 1640 | case DCT_ADST: |
| 1641 | case ADST_ADST: |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1642 | av1_inv_txfm2d_add_16x16(input, CONVERT_TO_SHORTPTR(dest), stride, |
| 1643 | tx_type, bd); |
| 1644 | break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1645 | #if CONFIG_EXT_TX |
| 1646 | case FLIPADST_DCT: |
| 1647 | case DCT_FLIPADST: |
| 1648 | case FLIPADST_FLIPADST: |
| 1649 | case ADST_FLIPADST: |
| 1650 | case FLIPADST_ADST: |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1651 | av1_inv_txfm2d_add_16x16(input, CONVERT_TO_SHORTPTR(dest), stride, |
| 1652 | tx_type, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1653 | break; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1654 | // use the c version for anything including identity for now |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1655 | case V_DCT: |
| 1656 | case H_DCT: |
| 1657 | case V_ADST: |
| 1658 | case H_ADST: |
| 1659 | case V_FLIPADST: |
| 1660 | case H_FLIPADST: |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1661 | case IDTX: |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1662 | av1_inv_txfm2d_add_16x16_c(input, CONVERT_TO_SHORTPTR(dest), stride, |
| 1663 | tx_type, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1664 | break; |
| 1665 | #endif // CONFIG_EXT_TX |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1666 | default: assert(0); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1667 | } |
| 1668 | } |
| 1669 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1670 | static void highbd_inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest, |
| 1671 | int stride, int eob, int bd, |
| 1672 | TX_TYPE tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1673 | (void)eob; |
| 1674 | switch (tx_type) { |
| 1675 | case DCT_DCT: |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1676 | case ADST_DCT: |
| 1677 | case DCT_ADST: |
| 1678 | case ADST_ADST: |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1679 | av1_inv_txfm2d_add_32x32(input, CONVERT_TO_SHORTPTR(dest), stride, |
| 1680 | tx_type, bd); |
| 1681 | break; |
| 1682 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1683 | case FLIPADST_DCT: |
| 1684 | case DCT_FLIPADST: |
| 1685 | case FLIPADST_FLIPADST: |
| 1686 | case ADST_FLIPADST: |
| 1687 | case FLIPADST_ADST: |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1688 | av1_inv_txfm2d_add_32x32(input, CONVERT_TO_SHORTPTR(dest), stride, |
| 1689 | tx_type, bd); |
| 1690 | break; |
| 1691 | // use the c version for anything including identity for now |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1692 | case V_DCT: |
| 1693 | case H_DCT: |
| 1694 | case V_ADST: |
| 1695 | case H_ADST: |
| 1696 | case V_FLIPADST: |
| 1697 | case H_FLIPADST: |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1698 | case IDTX: |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1699 | av1_inv_txfm2d_add_32x32_c(input, CONVERT_TO_SHORTPTR(dest), stride, |
| 1700 | tx_type, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1701 | break; |
| 1702 | #endif // CONFIG_EXT_TX |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1703 | default: assert(0); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1704 | } |
| 1705 | } |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 1706 | |
| 1707 | #if CONFIG_TX64X64 |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1708 | static void highbd_inv_txfm_add_64x64(const tran_low_t *input, uint8_t *dest, |
| 1709 | int stride, int eob, int bd, |
| 1710 | TX_TYPE tx_type) { |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 1711 | (void)eob; |
| 1712 | switch (tx_type) { |
| 1713 | case DCT_DCT: |
| 1714 | av1_inv_txfm2d_add_64x64(input, CONVERT_TO_SHORTPTR(dest), stride, |
| 1715 | DCT_DCT, bd); |
| 1716 | break; |
| 1717 | #if CONFIG_EXT_TX |
| 1718 | case ADST_DCT: |
| 1719 | case DCT_ADST: |
| 1720 | case ADST_ADST: |
| 1721 | case FLIPADST_DCT: |
| 1722 | case DCT_FLIPADST: |
| 1723 | case FLIPADST_FLIPADST: |
| 1724 | case ADST_FLIPADST: |
| 1725 | case FLIPADST_ADST: |
| 1726 | case V_DCT: |
| 1727 | case H_DCT: |
| 1728 | case V_ADST: |
| 1729 | case H_ADST: |
| 1730 | case V_FLIPADST: |
| 1731 | case H_FLIPADST: |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1732 | // TODO(sarahparker) |
| 1733 | // I've deleted the 64x64 implementations that existed in lieu |
| 1734 | // of adst, flipadst and identity for simplicity but will bring back |
| 1735 | // in a later change. This shouldn't impact performance since |
| 1736 | // DCT_DCT is the only extended type currently allowed for 64x64, |
| 1737 | // as dictated by get_ext_tx_set_type in blockd.h. |
| 1738 | av1_inv_txfm2d_add_64x64_c(input, CONVERT_TO_SHORTPTR(dest), stride, |
| 1739 | DCT_DCT, bd); |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 1740 | break; |
| 1741 | case IDTX: |
| 1742 | highbd_inv_idtx_add_c(input, dest, stride, 64, tx_type, bd); |
| 1743 | break; |
| 1744 | #endif // CONFIG_EXT_TX |
| 1745 | default: assert(0); break; |
| 1746 | } |
| 1747 | } |
| 1748 | #endif // CONFIG_TX64X64 |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 1749 | #endif // CONFIG_HIGHBITDEPTH |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1750 | |
hui su | bb9c73b | 2017-03-17 15:51:02 -0700 | [diff] [blame] | 1751 | void av1_inv_txfm_add(const tran_low_t *input, uint8_t *dest, int stride, |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1752 | INV_TXFM_PARAM *param) { |
| 1753 | const TX_TYPE tx_type = param->tx_type; |
| 1754 | const TX_SIZE tx_size = param->tx_size; |
| 1755 | const int eob = param->eob; |
| 1756 | const int lossless = param->lossless; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1757 | |
| 1758 | switch (tx_size) { |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 1759 | #if CONFIG_TX64X64 |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1760 | case TX_64X64: inv_txfm_add_64x64(input, dest, stride, param); break; |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 1761 | #endif // CONFIG_TX64X64 |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1762 | case TX_32X32: inv_txfm_add_32x32(input, dest, stride, param); break; |
| 1763 | case TX_16X16: inv_txfm_add_16x16(input, dest, stride, param); break; |
| 1764 | case TX_8X8: inv_txfm_add_8x8(input, dest, stride, param); break; |
| 1765 | case TX_4X8: inv_txfm_add_4x8(input, dest, stride, eob, tx_type); break; |
| 1766 | case TX_8X4: inv_txfm_add_8x4(input, dest, stride, eob, tx_type); break; |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1767 | case TX_8X16: inv_txfm_add_8x16(input, dest, stride, eob, tx_type); break; |
| 1768 | case TX_16X8: inv_txfm_add_16x8(input, dest, stride, eob, tx_type); break; |
| 1769 | case TX_16X32: inv_txfm_add_16x32(input, dest, stride, eob, tx_type); break; |
| 1770 | case TX_32X16: inv_txfm_add_32x16(input, dest, stride, eob, tx_type); break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1771 | case TX_4X4: |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1772 | // this is like av1_short_idct4x4 but has a special case around eob<=1 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1773 | // which is significant (not just an optimization) for the lossless |
| 1774 | // case. |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1775 | inv_txfm_add_4x4(input, dest, stride, eob, tx_type, lossless); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1776 | break; |
Timothy B. Terriberry | fe67ed6 | 2017-04-26 16:53:47 -0700 | [diff] [blame] | 1777 | #if CONFIG_CHROMA_2X2 |
Jingning Han | d7ec47f | 2016-11-29 16:34:40 -0800 | [diff] [blame] | 1778 | case TX_2X2: |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1779 | inv_txfm_add_2x2(input, dest, stride, eob, tx_type, lossless); |
Jingning Han | d7ec47f | 2016-11-29 16:34:40 -0800 | [diff] [blame] | 1780 | break; |
| 1781 | #endif |
Yue Chen | 56e226e | 2017-05-02 16:21:40 -0700 | [diff] [blame] | 1782 | #if CONFIG_EXT_TX && CONFIG_RECT_TX && CONFIG_RECT_TX_EXT |
| 1783 | case TX_32X8: inv_txfm_add_32x8(input, dest, stride, eob, tx_type); break; |
| 1784 | case TX_8X32: inv_txfm_add_8x32(input, dest, stride, eob, tx_type); break; |
| 1785 | case TX_16X4: inv_txfm_add_16x4(input, dest, stride, eob, tx_type); break; |
| 1786 | case TX_4X16: inv_txfm_add_4x16(input, dest, stride, eob, tx_type); break; |
| 1787 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1788 | default: assert(0 && "Invalid transform size"); break; |
| 1789 | } |
| 1790 | } |
| 1791 | |
Yi Luo | f8e87b4 | 2017-04-14 17:20:27 -0700 | [diff] [blame] | 1792 | static void init_inv_txfm_param(const MACROBLOCKD *xd, TX_SIZE tx_size, |
| 1793 | TX_TYPE tx_type, int eob, INV_TXFM_PARAM *inv) { |
| 1794 | inv->tx_type = tx_type; |
| 1795 | inv->tx_size = tx_size; |
| 1796 | inv->eob = eob; |
| 1797 | inv->lossless = xd->lossless[xd->mi[0]->mbmi.segment_id]; |
| 1798 | #if CONFIG_HIGHBITDEPTH |
| 1799 | inv->bd = xd->bd; |
| 1800 | #endif |
| 1801 | #if CONFIG_ADAPT_SCAN |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 1802 | inv->eob_threshold = |
| 1803 | (const int16_t *)&xd->eob_threshold_md[tx_size][tx_type][0]; |
Yi Luo | f8e87b4 | 2017-04-14 17:20:27 -0700 | [diff] [blame] | 1804 | #endif |
| 1805 | } |
| 1806 | |
Urvang Joshi | 0d1e4ff | 2017-04-27 16:17:25 -0700 | [diff] [blame] | 1807 | void av1_inverse_transform_block(const MACROBLOCKD *xd, |
| 1808 | const tran_low_t *dqcoeff, TX_TYPE tx_type, |
| 1809 | TX_SIZE tx_size, uint8_t *dst, int stride, |
| 1810 | int eob) { |
Angie Chiang | d92d4bf | 2017-04-02 17:49:18 -0700 | [diff] [blame] | 1811 | if (!eob) return; |
Angie Chiang | 50910f6 | 2017-04-03 12:31:34 -0700 | [diff] [blame] | 1812 | #if CONFIG_PVQ |
| 1813 | const BLOCK_SIZE tx_bsize = txsize_to_bsize[tx_size]; |
| 1814 | const int txb_width = block_size_wide[tx_bsize]; |
| 1815 | const int txb_height = block_size_high[tx_bsize]; |
| 1816 | int r, c; |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 1817 | #if CONFIG_HIGHBITDEPTH |
Angie Chiang | 50910f6 | 2017-04-03 12:31:34 -0700 | [diff] [blame] | 1818 | if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { |
Angie Chiang | 50910f6 | 2017-04-03 12:31:34 -0700 | [diff] [blame] | 1819 | for (r = 0; r < txb_height; r++) |
| 1820 | for (c = 0; c < txb_width; c++) |
| 1821 | CONVERT_TO_SHORTPTR(dst)[r * stride + c] = 0; |
| 1822 | } else { |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 1823 | #endif // CONFIG_HIGHBITDEPTH |
Angie Chiang | 50910f6 | 2017-04-03 12:31:34 -0700 | [diff] [blame] | 1824 | for (r = 0; r < txb_height; r++) |
| 1825 | for (c = 0; c < txb_width; c++) dst[r * stride + c] = 0; |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 1826 | #if CONFIG_HIGHBITDEPTH |
Angie Chiang | 50910f6 | 2017-04-03 12:31:34 -0700 | [diff] [blame] | 1827 | } |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 1828 | #endif // CONFIG_HIGHBITDEPTH |
Angie Chiang | 50910f6 | 2017-04-03 12:31:34 -0700 | [diff] [blame] | 1829 | #endif // CONFIG_PVQ |
Angie Chiang | d92d4bf | 2017-04-02 17:49:18 -0700 | [diff] [blame] | 1830 | INV_TXFM_PARAM inv_txfm_param; |
Yi Luo | f8e87b4 | 2017-04-14 17:20:27 -0700 | [diff] [blame] | 1831 | init_inv_txfm_param(xd, tx_size, tx_type, eob, &inv_txfm_param); |
Angie Chiang | d92d4bf | 2017-04-02 17:49:18 -0700 | [diff] [blame] | 1832 | |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 1833 | #if CONFIG_HIGHBITDEPTH |
Angie Chiang | d92d4bf | 2017-04-02 17:49:18 -0700 | [diff] [blame] | 1834 | if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { |
Angie Chiang | d92d4bf | 2017-04-02 17:49:18 -0700 | [diff] [blame] | 1835 | av1_highbd_inv_txfm_add(dqcoeff, dst, stride, &inv_txfm_param); |
| 1836 | } else { |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 1837 | #endif // CONFIG_HIGHBITDEPTH |
Angie Chiang | d92d4bf | 2017-04-02 17:49:18 -0700 | [diff] [blame] | 1838 | av1_inv_txfm_add(dqcoeff, dst, stride, &inv_txfm_param); |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 1839 | #if CONFIG_HIGHBITDEPTH |
Angie Chiang | d92d4bf | 2017-04-02 17:49:18 -0700 | [diff] [blame] | 1840 | } |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 1841 | #endif // CONFIG_HIGHBITDEPTH |
Angie Chiang | d92d4bf | 2017-04-02 17:49:18 -0700 | [diff] [blame] | 1842 | } |
| 1843 | |
Angie Chiang | bc2288c | 2017-04-09 15:41:17 -0700 | [diff] [blame] | 1844 | void av1_inverse_transform_block_facade(MACROBLOCKD *xd, int plane, int block, |
| 1845 | int blk_row, int blk_col, int eob) { |
| 1846 | struct macroblockd_plane *const pd = &xd->plane[plane]; |
| 1847 | tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); |
| 1848 | const PLANE_TYPE plane_type = get_plane_type(plane); |
| 1849 | const TX_SIZE tx_size = get_tx_size(plane, xd); |
| 1850 | const TX_TYPE tx_type = get_tx_type(plane_type, xd, block, tx_size); |
| 1851 | const int dst_stride = pd->dst.stride; |
| 1852 | uint8_t *dst = |
| 1853 | &pd->dst.buf[(blk_row * dst_stride + blk_col) << tx_size_wide_log2[0]]; |
| 1854 | av1_inverse_transform_block(xd, dqcoeff, tx_type, tx_size, dst, dst_stride, |
| 1855 | eob); |
| 1856 | } |
| 1857 | |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 1858 | #if CONFIG_HIGHBITDEPTH |
hui su | bb9c73b | 2017-03-17 15:51:02 -0700 | [diff] [blame] | 1859 | void av1_highbd_inv_txfm_add(const tran_low_t *input, uint8_t *dest, int stride, |
| 1860 | INV_TXFM_PARAM *inv_txfm_param) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1861 | const TX_TYPE tx_type = inv_txfm_param->tx_type; |
| 1862 | const TX_SIZE tx_size = inv_txfm_param->tx_size; |
| 1863 | const int eob = inv_txfm_param->eob; |
| 1864 | const int bd = inv_txfm_param->bd; |
| 1865 | const int lossless = inv_txfm_param->lossless; |
| 1866 | |
| 1867 | switch (tx_size) { |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 1868 | #if CONFIG_TX64X64 |
| 1869 | case TX_64X64: |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1870 | highbd_inv_txfm_add_64x64(input, dest, stride, eob, bd, tx_type); |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 1871 | break; |
| 1872 | #endif // CONFIG_TX64X64 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1873 | case TX_32X32: |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1874 | highbd_inv_txfm_add_32x32(input, dest, stride, eob, bd, tx_type); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1875 | break; |
| 1876 | case TX_16X16: |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1877 | highbd_inv_txfm_add_16x16(input, dest, stride, eob, bd, tx_type); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1878 | break; |
| 1879 | case TX_8X8: |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1880 | highbd_inv_txfm_add_8x8(input, dest, stride, eob, bd, tx_type); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1881 | break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1882 | case TX_4X8: |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1883 | av1_highbd_inv_txfm_add_4x8(input, dest, stride, eob, bd, tx_type); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1884 | break; |
| 1885 | case TX_8X4: |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1886 | av1_highbd_inv_txfm_add_8x4(input, dest, stride, eob, bd, tx_type); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1887 | break; |
| 1888 | case TX_8X16: |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1889 | highbd_inv_txfm_add_8x16(input, dest, stride, eob, bd, tx_type); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1890 | break; |
| 1891 | case TX_16X8: |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1892 | highbd_inv_txfm_add_16x8(input, dest, stride, eob, bd, tx_type); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1893 | break; |
| 1894 | case TX_16X32: |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1895 | highbd_inv_txfm_add_16x32(input, dest, stride, eob, bd, tx_type); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1896 | break; |
| 1897 | case TX_32X16: |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1898 | highbd_inv_txfm_add_32x16(input, dest, stride, eob, bd, tx_type); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1899 | break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1900 | case TX_4X4: |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1901 | // this is like av1_short_idct4x4 but has a special case around eob<=1 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1902 | // which is significant (not just an optimization) for the lossless |
| 1903 | // case. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1904 | av1_highbd_inv_txfm_add_4x4(input, dest, stride, eob, bd, tx_type, |
| 1905 | lossless); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1906 | break; |
Timothy B. Terriberry | fe67ed6 | 2017-04-26 16:53:47 -0700 | [diff] [blame] | 1907 | #if CONFIG_CHROMA_2X2 |
Jingning Han | b1ed8d7 | 2016-12-19 10:21:14 -0800 | [diff] [blame] | 1908 | case TX_2X2: |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 1909 | highbd_inv_txfm_add_2x2(input, dest, stride, eob, bd, tx_type, lossless); |
Jingning Han | b1ed8d7 | 2016-12-19 10:21:14 -0800 | [diff] [blame] | 1910 | break; |
Jingning Han | b1ed8d7 | 2016-12-19 10:21:14 -0800 | [diff] [blame] | 1911 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1912 | default: assert(0 && "Invalid transform size"); break; |
| 1913 | } |
| 1914 | } |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 1915 | #endif // CONFIG_HIGHBITDEPTH |
hui su | b8a6fd6 | 2017-05-10 10:57:57 -0700 | [diff] [blame] | 1916 | |
| 1917 | #if CONFIG_DPCM_INTRA |
| 1918 | void av1_dpcm_inv_txfm_add_4_c(const tran_low_t *input, int stride, |
| 1919 | TX_TYPE_1D tx_type, uint8_t *dest) { |
| 1920 | assert(tx_type < TX_TYPES_1D); |
| 1921 | static const transform_1d IHT[] = { aom_idct4_c, aom_iadst4_c, aom_iadst4_c, |
| 1922 | iidtx4_c }; |
| 1923 | const transform_1d inv_tx = IHT[tx_type]; |
| 1924 | tran_low_t out[4]; |
| 1925 | inv_tx(input, out); |
| 1926 | for (int i = 0; i < 4; ++i) { |
| 1927 | out[i] = (tran_low_t)dct_const_round_shift(out[i] * Sqrt2); |
| 1928 | dest[i * stride] = |
| 1929 | clip_pixel_add(dest[i * stride], ROUND_POWER_OF_TWO(out[i], 4)); |
| 1930 | } |
| 1931 | } |
| 1932 | |
| 1933 | void av1_dpcm_inv_txfm_add_8_c(const tran_low_t *input, int stride, |
| 1934 | TX_TYPE_1D tx_type, uint8_t *dest) { |
| 1935 | assert(tx_type < TX_TYPES_1D); |
| 1936 | static const transform_1d IHT[] = { aom_idct8_c, aom_iadst8_c, aom_iadst8_c, |
| 1937 | iidtx8_c }; |
| 1938 | const transform_1d inv_tx = IHT[tx_type]; |
| 1939 | tran_low_t out[8]; |
| 1940 | inv_tx(input, out); |
| 1941 | for (int i = 0; i < 8; ++i) { |
| 1942 | dest[i * stride] = |
| 1943 | clip_pixel_add(dest[i * stride], ROUND_POWER_OF_TWO(out[i], 4)); |
| 1944 | } |
| 1945 | } |
| 1946 | |
| 1947 | void av1_dpcm_inv_txfm_add_16_c(const tran_low_t *input, int stride, |
| 1948 | TX_TYPE_1D tx_type, uint8_t *dest) { |
| 1949 | assert(tx_type < TX_TYPES_1D); |
| 1950 | static const transform_1d IHT[] = { aom_idct16_c, aom_iadst16_c, |
| 1951 | aom_iadst16_c, iidtx16_c }; |
| 1952 | const transform_1d inv_tx = IHT[tx_type]; |
| 1953 | tran_low_t out[16]; |
| 1954 | inv_tx(input, out); |
| 1955 | for (int i = 0; i < 16; ++i) { |
| 1956 | out[i] = (tran_low_t)dct_const_round_shift(out[i] * Sqrt2); |
| 1957 | dest[i * stride] = |
| 1958 | clip_pixel_add(dest[i * stride], ROUND_POWER_OF_TWO(out[i], 5)); |
| 1959 | } |
| 1960 | } |
| 1961 | |
| 1962 | void av1_dpcm_inv_txfm_add_32_c(const tran_low_t *input, int stride, |
| 1963 | TX_TYPE_1D tx_type, uint8_t *dest) { |
| 1964 | assert(tx_type < TX_TYPES_1D); |
| 1965 | static const transform_1d IHT[] = { aom_idct32_c, ihalfright32_c, |
| 1966 | ihalfright32_c, iidtx32_c }; |
| 1967 | const transform_1d inv_tx = IHT[tx_type]; |
| 1968 | tran_low_t out[32]; |
| 1969 | inv_tx(input, out); |
| 1970 | for (int i = 0; i < 32; ++i) { |
| 1971 | dest[i * stride] = |
| 1972 | clip_pixel_add(dest[i * stride], ROUND_POWER_OF_TWO(out[i], 4)); |
| 1973 | } |
| 1974 | } |
| 1975 | |
| 1976 | dpcm_inv_txfm_add_func av1_get_dpcm_inv_txfm_add_func(int tx_length) { |
| 1977 | switch (tx_length) { |
| 1978 | case 4: return av1_dpcm_inv_txfm_add_4_c; |
| 1979 | case 8: return av1_dpcm_inv_txfm_add_8_c; |
| 1980 | case 16: return av1_dpcm_inv_txfm_add_16_c; |
| 1981 | case 32: |
| 1982 | return av1_dpcm_inv_txfm_add_32_c; |
| 1983 | // TODO(huisu): add support for TX_64X64. |
| 1984 | default: assert(0); return NULL; |
| 1985 | } |
| 1986 | } |
| 1987 | |
| 1988 | #if CONFIG_HIGHBITDEPTH |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1989 | // TODO(sarahparker) I am adding a quick workaround for these functions |
| 1990 | // to remove the old hbd transforms. This will be cleaned up in a followup. |
hui su | b8a6fd6 | 2017-05-10 10:57:57 -0700 | [diff] [blame] | 1991 | void av1_hbd_dpcm_inv_txfm_add_4_c(const tran_low_t *input, int stride, |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1992 | TX_TYPE_1D tx_type, int bd, uint16_t *dest, |
| 1993 | int dir) { |
hui su | b8a6fd6 | 2017-05-10 10:57:57 -0700 | [diff] [blame] | 1994 | assert(tx_type < TX_TYPES_1D); |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 1995 | static const TxfmFunc IHT[] = { av1_idct4_new, av1_iadst4_new, av1_iadst4_new, |
| 1996 | av1_iidentity4_c }; |
| 1997 | // In order { horizontal, vertical } |
| 1998 | static const TXFM_1D_CFG *inv_txfm_cfg_ls[TX_TYPES_1D][2] = { |
| 1999 | { &inv_txfm_1d_row_cfg_dct_4, &inv_txfm_1d_col_cfg_dct_4 }, |
| 2000 | { &inv_txfm_1d_row_cfg_adst_4, &inv_txfm_1d_col_cfg_adst_4 }, |
| 2001 | { &inv_txfm_1d_row_cfg_adst_4, &inv_txfm_1d_col_cfg_adst_4 }, |
| 2002 | { &inv_txfm_1d_cfg_identity_4, &inv_txfm_1d_cfg_identity_4 } |
| 2003 | }; |
| 2004 | |
| 2005 | const TXFM_1D_CFG *inv_txfm_cfg = inv_txfm_cfg_ls[tx_type][dir]; |
| 2006 | const TxfmFunc inv_tx = IHT[tx_type]; |
| 2007 | |
hui su | b8a6fd6 | 2017-05-10 10:57:57 -0700 | [diff] [blame] | 2008 | tran_low_t out[4]; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 2009 | inv_tx(input, out, inv_txfm_cfg->cos_bit, inv_txfm_cfg->stage_range); |
hui su | b8a6fd6 | 2017-05-10 10:57:57 -0700 | [diff] [blame] | 2010 | for (int i = 0; i < 4; ++i) { |
| 2011 | out[i] = (tran_low_t)dct_const_round_shift(out[i] * Sqrt2); |
| 2012 | dest[i * stride] = highbd_clip_pixel_add(dest[i * stride], |
| 2013 | ROUND_POWER_OF_TWO(out[i], 4), bd); |
| 2014 | } |
| 2015 | } |
| 2016 | |
| 2017 | void av1_hbd_dpcm_inv_txfm_add_8_c(const tran_low_t *input, int stride, |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 2018 | TX_TYPE_1D tx_type, int bd, uint16_t *dest, |
| 2019 | int dir) { |
hui su | b8a6fd6 | 2017-05-10 10:57:57 -0700 | [diff] [blame] | 2020 | assert(tx_type < TX_TYPES_1D); |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 2021 | static const TxfmFunc IHT[] = { av1_idct4_new, av1_iadst4_new, av1_iadst4_new, |
| 2022 | av1_iidentity4_c }; |
| 2023 | // In order { horizontal, vertical } |
| 2024 | static const TXFM_1D_CFG *inv_txfm_cfg_ls[TX_TYPES_1D][2] = { |
| 2025 | { &inv_txfm_1d_row_cfg_dct_8, &inv_txfm_1d_col_cfg_dct_8 }, |
| 2026 | { &inv_txfm_1d_row_cfg_adst_8, &inv_txfm_1d_col_cfg_adst_8 }, |
| 2027 | { &inv_txfm_1d_row_cfg_adst_8, &inv_txfm_1d_col_cfg_adst_8 }, |
| 2028 | { &inv_txfm_1d_cfg_identity_8, &inv_txfm_1d_cfg_identity_8 } |
| 2029 | }; |
| 2030 | |
| 2031 | const TXFM_1D_CFG *inv_txfm_cfg = inv_txfm_cfg_ls[tx_type][dir]; |
| 2032 | const TxfmFunc inv_tx = IHT[tx_type]; |
| 2033 | |
hui su | b8a6fd6 | 2017-05-10 10:57:57 -0700 | [diff] [blame] | 2034 | tran_low_t out[8]; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 2035 | inv_tx(input, out, inv_txfm_cfg->cos_bit, inv_txfm_cfg->stage_range); |
hui su | b8a6fd6 | 2017-05-10 10:57:57 -0700 | [diff] [blame] | 2036 | for (int i = 0; i < 8; ++i) { |
| 2037 | dest[i * stride] = highbd_clip_pixel_add(dest[i * stride], |
| 2038 | ROUND_POWER_OF_TWO(out[i], 4), bd); |
| 2039 | } |
| 2040 | } |
| 2041 | |
| 2042 | void av1_hbd_dpcm_inv_txfm_add_16_c(const tran_low_t *input, int stride, |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 2043 | TX_TYPE_1D tx_type, int bd, uint16_t *dest, |
| 2044 | int dir) { |
hui su | b8a6fd6 | 2017-05-10 10:57:57 -0700 | [diff] [blame] | 2045 | assert(tx_type < TX_TYPES_1D); |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 2046 | static const TxfmFunc IHT[] = { av1_idct4_new, av1_iadst4_new, av1_iadst4_new, |
| 2047 | av1_iidentity4_c }; |
| 2048 | // In order { horizontal, vertical } |
| 2049 | static const TXFM_1D_CFG *inv_txfm_cfg_ls[TX_TYPES_1D][2] = { |
| 2050 | { &inv_txfm_1d_row_cfg_dct_16, &inv_txfm_1d_col_cfg_dct_16 }, |
| 2051 | { &inv_txfm_1d_row_cfg_adst_16, &inv_txfm_1d_col_cfg_adst_16 }, |
| 2052 | { &inv_txfm_1d_row_cfg_adst_16, &inv_txfm_1d_col_cfg_adst_16 }, |
| 2053 | { &inv_txfm_1d_cfg_identity_16, &inv_txfm_1d_cfg_identity_16 } |
| 2054 | }; |
| 2055 | |
| 2056 | const TXFM_1D_CFG *inv_txfm_cfg = inv_txfm_cfg_ls[tx_type][dir]; |
| 2057 | const TxfmFunc inv_tx = IHT[tx_type]; |
| 2058 | |
hui su | b8a6fd6 | 2017-05-10 10:57:57 -0700 | [diff] [blame] | 2059 | tran_low_t out[16]; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 2060 | inv_tx(input, out, inv_txfm_cfg->cos_bit, inv_txfm_cfg->stage_range); |
hui su | b8a6fd6 | 2017-05-10 10:57:57 -0700 | [diff] [blame] | 2061 | for (int i = 0; i < 16; ++i) { |
| 2062 | out[i] = (tran_low_t)dct_const_round_shift(out[i] * Sqrt2); |
| 2063 | dest[i * stride] = highbd_clip_pixel_add(dest[i * stride], |
| 2064 | ROUND_POWER_OF_TWO(out[i], 5), bd); |
| 2065 | } |
| 2066 | } |
| 2067 | |
| 2068 | void av1_hbd_dpcm_inv_txfm_add_32_c(const tran_low_t *input, int stride, |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 2069 | TX_TYPE_1D tx_type, int bd, uint16_t *dest, |
| 2070 | int dir) { |
hui su | b8a6fd6 | 2017-05-10 10:57:57 -0700 | [diff] [blame] | 2071 | assert(tx_type < TX_TYPES_1D); |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 2072 | static const TxfmFunc IHT[] = { av1_idct4_new, av1_iadst4_new, av1_iadst4_new, |
| 2073 | av1_iidentity4_c }; |
| 2074 | // In order { horizontal, vertical } |
| 2075 | static const TXFM_1D_CFG *inv_txfm_cfg_ls[TX_TYPES_1D][2] = { |
| 2076 | { &inv_txfm_1d_row_cfg_dct_32, &inv_txfm_1d_col_cfg_dct_32 }, |
| 2077 | { &inv_txfm_1d_row_cfg_adst_32, &inv_txfm_1d_col_cfg_adst_32 }, |
| 2078 | { &inv_txfm_1d_row_cfg_adst_32, &inv_txfm_1d_col_cfg_adst_32 }, |
| 2079 | { &inv_txfm_1d_cfg_identity_32, &inv_txfm_1d_cfg_identity_32 } |
| 2080 | }; |
| 2081 | |
| 2082 | const TXFM_1D_CFG *inv_txfm_cfg = inv_txfm_cfg_ls[tx_type][dir]; |
| 2083 | const TxfmFunc inv_tx = IHT[tx_type]; |
| 2084 | |
hui su | b8a6fd6 | 2017-05-10 10:57:57 -0700 | [diff] [blame] | 2085 | tran_low_t out[32]; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 2086 | inv_tx(input, out, inv_txfm_cfg->cos_bit, inv_txfm_cfg->stage_range); |
hui su | b8a6fd6 | 2017-05-10 10:57:57 -0700 | [diff] [blame] | 2087 | for (int i = 0; i < 32; ++i) { |
| 2088 | dest[i * stride] = highbd_clip_pixel_add(dest[i * stride], |
| 2089 | ROUND_POWER_OF_TWO(out[i], 4), bd); |
| 2090 | } |
| 2091 | } |
| 2092 | |
| 2093 | hbd_dpcm_inv_txfm_add_func av1_get_hbd_dpcm_inv_txfm_add_func(int tx_length) { |
| 2094 | switch (tx_length) { |
| 2095 | case 4: return av1_hbd_dpcm_inv_txfm_add_4_c; |
| 2096 | case 8: return av1_hbd_dpcm_inv_txfm_add_8_c; |
| 2097 | case 16: return av1_hbd_dpcm_inv_txfm_add_16_c; |
| 2098 | case 32: |
| 2099 | return av1_hbd_dpcm_inv_txfm_add_32_c; |
| 2100 | // TODO(huisu): add support for TX_64X64. |
| 2101 | default: assert(0); return NULL; |
| 2102 | } |
| 2103 | } |
| 2104 | #endif // CONFIG_HIGHBITDEPTH |
| 2105 | #endif // CONFIG_DPCM_INTRA |