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" |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 22 | #if CONFIG_DAALA_TX4 || CONFIG_DAALA_TX8 || CONFIG_DAALA_TX16 || \ |
| 23 | CONFIG_DAALA_TX32 || CONFIG_DAALA_TX64 |
Nathan E. Egge | 5e6bda8 | 2017-09-16 10:13:51 -0400 | [diff] [blame] | 24 | #include "av1/common/daala_tx.h" |
| 25 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 26 | |
Jingning Han | ff70545 | 2017-04-27 11:32:15 -0700 | [diff] [blame] | 27 | int av1_get_tx_scale(const TX_SIZE tx_size) { |
Yue Chen | aa0d90f | 2017-08-24 17:56:24 -0700 | [diff] [blame] | 28 | const int pels = tx_size_2d[tx_size]; |
| 29 | return (pels > 256) + (pels > 1024) + (pels > 4096); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 30 | } |
| 31 | |
Debargha Mukherjee | e52816b | 2016-10-12 10:49:29 -0700 | [diff] [blame] | 32 | // NOTE: The implementation of all inverses need to be aware of the fact |
| 33 | // that input and output could be the same buffer. |
| 34 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 35 | #if CONFIG_EXT_TX |
| 36 | static void iidtx4_c(const tran_low_t *input, tran_low_t *output) { |
| 37 | int i; |
Monty Montgomery | 02078a3 | 2017-07-11 21:22:29 -0400 | [diff] [blame] | 38 | for (i = 0; i < 4; ++i) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 39 | output[i] = (tran_low_t)dct_const_round_shift(input[i] * Sqrt2); |
Monty Montgomery | 02078a3 | 2017-07-11 21:22:29 -0400 | [diff] [blame] | 40 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | static void iidtx8_c(const tran_low_t *input, tran_low_t *output) { |
| 44 | int i; |
Monty Montgomery | cf18fe4 | 2017-07-11 21:33:25 -0400 | [diff] [blame] | 45 | for (i = 0; i < 8; ++i) { |
Monty Montgomery | cf18fe4 | 2017-07-11 21:33:25 -0400 | [diff] [blame] | 46 | output[i] = input[i] * 2; |
Monty Montgomery | cf18fe4 | 2017-07-11 21:33:25 -0400 | [diff] [blame] | 47 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | static void iidtx16_c(const tran_low_t *input, tran_low_t *output) { |
| 51 | int i; |
Monty Montgomery | cb9c1c5 | 2017-07-17 18:15:30 -0400 | [diff] [blame] | 52 | for (i = 0; i < 16; ++i) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 53 | output[i] = (tran_low_t)dct_const_round_shift(input[i] * 2 * Sqrt2); |
Monty Montgomery | cb9c1c5 | 2017-07-17 18:15:30 -0400 | [diff] [blame] | 54 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | static void iidtx32_c(const tran_low_t *input, tran_low_t *output) { |
| 58 | int i; |
Monty Montgomery | 2cb52ba | 2017-07-17 18:27:27 -0400 | [diff] [blame] | 59 | for (i = 0; i < 32; ++i) { |
Monty Montgomery | 2cb52ba | 2017-07-17 18:27:27 -0400 | [diff] [blame] | 60 | output[i] = input[i] * 4; |
Monty Montgomery | 2cb52ba | 2017-07-17 18:27:27 -0400 | [diff] [blame] | 61 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 62 | } |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 63 | |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 64 | #if CONFIG_TX64X64 && !CONFIG_DAALA_TX64 |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 65 | static void iidtx64_c(const tran_low_t *input, tran_low_t *output) { |
| 66 | int i; |
Monty Montgomery | a4e245a | 2017-07-22 00:48:31 -0400 | [diff] [blame] | 67 | for (i = 0; i < 64; ++i) { |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 68 | output[i] = (tran_low_t)dct_const_round_shift(input[i] * 4 * Sqrt2); |
Monty Montgomery | a4e245a | 2017-07-22 00:48:31 -0400 | [diff] [blame] | 69 | } |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 70 | } |
| 71 | #endif // CONFIG_TX64X64 |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 72 | #endif // CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 73 | |
Debargha Mukherjee | e52816b | 2016-10-12 10:49:29 -0700 | [diff] [blame] | 74 | // For use in lieu of ADST |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 75 | static void ihalfright32_c(const tran_low_t *input, tran_low_t *output) { |
| 76 | int i; |
| 77 | tran_low_t inputhalf[16]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 78 | // Multiply input by sqrt(2) |
| 79 | for (i = 0; i < 16; ++i) { |
| 80 | inputhalf[i] = (tran_low_t)dct_const_round_shift(input[i] * Sqrt2); |
| 81 | } |
Debargha Mukherjee | e52816b | 2016-10-12 10:49:29 -0700 | [diff] [blame] | 82 | for (i = 0; i < 16; ++i) { |
| 83 | output[i] = input[16 + i] * 4; |
| 84 | } |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 85 | aom_idct16_c(inputhalf, output + 16); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 86 | // Note overall scaling factor is 4 times orthogonal |
| 87 | } |
| 88 | |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 89 | #if CONFIG_TX64X64 && !CONFIG_DAALA_TX64 |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 90 | static void idct64_col_c(const tran_low_t *input, tran_low_t *output) { |
| 91 | int32_t in[64], out[64]; |
| 92 | int i; |
| 93 | for (i = 0; i < 64; ++i) in[i] = (int32_t)input[i]; |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 94 | 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] | 95 | for (i = 0; i < 64; ++i) output[i] = (tran_low_t)out[i]; |
| 96 | } |
| 97 | |
| 98 | static void idct64_row_c(const tran_low_t *input, tran_low_t *output) { |
| 99 | int32_t in[64], out[64]; |
| 100 | int i; |
| 101 | for (i = 0; i < 64; ++i) in[i] = (int32_t)input[i]; |
Sarah Parker | eec47e6 | 2017-05-15 20:49:22 -0700 | [diff] [blame] | 102 | 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] | 103 | for (i = 0; i < 64; ++i) output[i] = (tran_low_t)out[i]; |
| 104 | } |
| 105 | |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 106 | // For use in lieu of ADST |
| 107 | static void ihalfright64_c(const tran_low_t *input, tran_low_t *output) { |
| 108 | int i; |
| 109 | tran_low_t inputhalf[32]; |
| 110 | // Multiply input by sqrt(2) |
| 111 | for (i = 0; i < 32; ++i) { |
| 112 | inputhalf[i] = (tran_low_t)dct_const_round_shift(input[i] * Sqrt2); |
| 113 | } |
| 114 | for (i = 0; i < 32; ++i) { |
| 115 | output[i] = (tran_low_t)dct_const_round_shift(input[32 + i] * 4 * Sqrt2); |
| 116 | } |
| 117 | aom_idct32_c(inputhalf, output + 32); |
| 118 | // Note overall scaling factor is 4 * sqrt(2) times orthogonal |
| 119 | } |
| 120 | #endif // CONFIG_TX64X64 |
| 121 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 122 | // Inverse identity transform and add. |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 123 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 124 | static void inv_idtx_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 125 | int bsx, int bsy, TX_TYPE tx_type) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 126 | int r, c; |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 127 | const int pels = bsx * bsy; |
| 128 | const int shift = 3 - ((pels > 256) + (pels > 1024)); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 129 | if (tx_type == IDTX) { |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 130 | for (r = 0; r < bsy; ++r) { |
| 131 | for (c = 0; c < bsx; ++c) |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 132 | dest[c] = clip_pixel_add(dest[c], input[c] >> shift); |
| 133 | dest += stride; |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 134 | input += bsx; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 135 | } |
| 136 | } |
| 137 | } |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 138 | #endif // CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 139 | |
| 140 | #define FLIPUD_PTR(dest, stride, size) \ |
| 141 | do { \ |
| 142 | (dest) = (dest) + ((size)-1) * (stride); \ |
| 143 | (stride) = -(stride); \ |
| 144 | } while (0) |
| 145 | |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 146 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 147 | static void maybe_flip_strides(uint8_t **dst, int *dstride, tran_low_t **src, |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 148 | int *sstride, TX_TYPE tx_type, int sizey, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 149 | int sizex) { |
| 150 | // Note that the transpose of src will be added to dst. In order to LR |
| 151 | // flip the addends (in dst coordinates), we UD flip the src. To UD flip |
| 152 | // the addends, we UD flip the dst. |
| 153 | switch (tx_type) { |
| 154 | case DCT_DCT: |
| 155 | case ADST_DCT: |
| 156 | case DCT_ADST: |
| 157 | case ADST_ADST: |
| 158 | case IDTX: |
| 159 | case V_DCT: |
| 160 | case H_DCT: |
| 161 | case V_ADST: |
| 162 | case H_ADST: break; |
| 163 | case FLIPADST_DCT: |
| 164 | case FLIPADST_ADST: |
| 165 | case V_FLIPADST: |
| 166 | // flip UD |
| 167 | FLIPUD_PTR(*dst, *dstride, sizey); |
| 168 | break; |
| 169 | case DCT_FLIPADST: |
| 170 | case ADST_FLIPADST: |
| 171 | case H_FLIPADST: |
| 172 | // flip LR |
| 173 | FLIPUD_PTR(*src, *sstride, sizex); |
| 174 | break; |
| 175 | case FLIPADST_FLIPADST: |
| 176 | // flip UD |
| 177 | FLIPUD_PTR(*dst, *dstride, sizey); |
| 178 | // flip LR |
| 179 | FLIPUD_PTR(*src, *sstride, sizex); |
| 180 | break; |
| 181 | default: assert(0); break; |
| 182 | } |
| 183 | } |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 184 | #endif // CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 185 | |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 186 | #if CONFIG_HIGHBITDEPTH |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 187 | #if CONFIG_EXT_TX && CONFIG_TX64X64 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 188 | static void highbd_inv_idtx_add_c(const tran_low_t *input, uint8_t *dest8, |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 189 | int stride, int bsx, int bsy, TX_TYPE tx_type, |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 190 | int bd) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 191 | int r, c; |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 192 | const int pels = bsx * bsy; |
| 193 | const int shift = 3 - ((pels > 256) + (pels > 1024)); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 194 | uint16_t *dest = CONVERT_TO_SHORTPTR(dest8); |
| 195 | |
| 196 | if (tx_type == IDTX) { |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 197 | for (r = 0; r < bsy; ++r) { |
| 198 | for (c = 0; c < bsx; ++c) |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 199 | dest[c] = highbd_clip_pixel_add(dest[c], input[c] >> shift, bd); |
| 200 | dest += stride; |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 201 | input += bsx; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 202 | } |
| 203 | } |
| 204 | } |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 205 | #endif // CONFIG_EXT_TX && CONFIG_TX64X64 |
Sebastien Alaiwan | 71e8784 | 2017-04-12 16:03:28 +0200 | [diff] [blame] | 206 | #endif // CONFIG_HIGHBITDEPTH |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 207 | |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 208 | #if CONFIG_LGT || CONFIG_LGT_FROM_PRED |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 209 | void ilgt4(const tran_low_t *input, tran_low_t *output, |
| 210 | const tran_high_t *lgtmtx) { |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 211 | if (!lgtmtx) assert(0); |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 212 | #if CONFIG_LGT_FROM_PRED |
| 213 | // For DCT/ADST, use butterfly implementations |
| 214 | if (lgtmtx[0] == DCT4) { |
| 215 | aom_idct4_c(input, output); |
| 216 | return; |
| 217 | } else if (lgtmtx[0] == ADST4) { |
| 218 | aom_iadst4_c(input, output); |
| 219 | return; |
| 220 | } |
| 221 | #endif // CONFIG_LGT_FROM_PRED |
| 222 | |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 223 | // evaluate s[j] = sum of all lgtmtx[j]*input[i] over i=1,...,4 |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 224 | tran_high_t s[4] = { 0 }; |
| 225 | for (int i = 0; i < 4; ++i) |
| 226 | for (int j = 0; j < 4; ++j) s[j] += lgtmtx[i * 4 + j] * input[i]; |
| 227 | |
| 228 | for (int i = 0; i < 4; ++i) output[i] = WRAPLOW(dct_const_round_shift(s[i])); |
| 229 | } |
| 230 | |
| 231 | void ilgt8(const tran_low_t *input, tran_low_t *output, |
| 232 | const tran_high_t *lgtmtx) { |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 233 | if (!lgtmtx) assert(0); |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 234 | #if CONFIG_LGT_FROM_PRED |
| 235 | // For DCT/ADST, use butterfly implementations |
| 236 | if (lgtmtx[0] == DCT8) { |
| 237 | aom_idct8_c(input, output); |
| 238 | return; |
| 239 | } else if (lgtmtx[0] == ADST8) { |
| 240 | aom_iadst8_c(input, output); |
| 241 | return; |
| 242 | } |
| 243 | #endif // CONFIG_LGT_FROM_PRED |
| 244 | |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 245 | // evaluate s[j] = sum of all lgtmtx[j]*input[i] over i=1,...,8 |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 246 | tran_high_t s[8] = { 0 }; |
| 247 | for (int i = 0; i < 8; ++i) |
| 248 | for (int j = 0; j < 8; ++j) s[j] += lgtmtx[i * 8 + j] * input[i]; |
| 249 | |
| 250 | for (int i = 0; i < 8; ++i) output[i] = WRAPLOW(dct_const_round_shift(s[i])); |
| 251 | } |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 252 | #endif // CONFIG_LGT || CONFIG_LGT_FROM_PRED |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 253 | |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 254 | #if CONFIG_LGT |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 255 | // get_lgt4 and get_lgt8 return 1 and pick a lgt matrix if LGT is chosen to |
| 256 | // apply. Otherwise they return 0 |
| 257 | int get_lgt4(const TxfmParam *txfm_param, int is_col, |
| 258 | const tran_high_t **lgtmtx) { |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 259 | #if CONFIG_EXT_TX |
| 260 | assert(av1_ext_tx_used[txfm_param->tx_set_type][txfm_param->tx_type]); |
| 261 | #endif // CONFIG_EXT_TX |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 262 | if (is_col && (vtx_tab[txfm_param->tx_type] == ADST_1D || |
| 263 | vtx_tab[txfm_param->tx_type] == FLIPADST_1D)) { |
| 264 | lgtmtx[0] = txfm_param->is_inter ? &lgt4_170[0][0] : &lgt4_140[0][0]; |
| 265 | return 1; |
| 266 | } else if (!is_col && (htx_tab[txfm_param->tx_type] == ADST_1D || |
| 267 | htx_tab[txfm_param->tx_type] == FLIPADST_1D)) { |
| 268 | lgtmtx[0] = txfm_param->is_inter ? &lgt4_170[0][0] : &lgt4_140[0][0]; |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 269 | return 1; |
| 270 | } |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 271 | lgtmtx[0] = NULL; |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 272 | return 0; |
| 273 | } |
| 274 | |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 275 | int get_lgt8(const TxfmParam *txfm_param, int is_col, |
| 276 | const tran_high_t **lgtmtx) { |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 277 | #if CONFIG_EXT_TX |
| 278 | assert(av1_ext_tx_used[txfm_param->tx_set_type][txfm_param->tx_type]); |
| 279 | #endif // CONFIG_EXT_TX |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 280 | if (is_col && (vtx_tab[txfm_param->tx_type] == ADST_1D || |
| 281 | vtx_tab[txfm_param->tx_type] == FLIPADST_1D)) { |
| 282 | lgtmtx[0] = txfm_param->is_inter ? &lgt8_170[0][0] : &lgt8_150[0][0]; |
| 283 | return 1; |
| 284 | } else if (!is_col && (htx_tab[txfm_param->tx_type] == ADST_1D || |
| 285 | htx_tab[txfm_param->tx_type] == FLIPADST_1D)) { |
| 286 | lgtmtx[0] = txfm_param->is_inter ? &lgt8_170[0][0] : &lgt8_150[0][0]; |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 287 | return 1; |
| 288 | } |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 289 | lgtmtx[0] = NULL; |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 290 | return 0; |
| 291 | } |
| 292 | #endif // CONFIG_LGT |
| 293 | |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 294 | #if CONFIG_LGT_FROM_PRED |
| 295 | void ilgt16up(const tran_low_t *input, tran_low_t *output, |
| 296 | const tran_high_t *lgtmtx) { |
| 297 | if (lgtmtx[0] == DCT16) { |
| 298 | aom_idct16_c(input, output); |
| 299 | return; |
| 300 | } else if (lgtmtx[0] == ADST16) { |
| 301 | aom_iadst16_c(input, output); |
| 302 | return; |
| 303 | } else if (lgtmtx[0] == DCT32) { |
| 304 | aom_idct32_c(input, output); |
| 305 | return; |
| 306 | } else if (lgtmtx[0] == ADST32) { |
| 307 | ihalfright32_c(input, output); |
| 308 | return; |
| 309 | } else { |
| 310 | assert(0); |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | void get_discontinuity_1d(uint8_t *arr, int n, int *idx_max_diff) { |
| 315 | *idx_max_diff = -1; |
| 316 | |
| 317 | int temp = 0, max_diff = 0, min_diff = INT_MAX; |
| 318 | for (int i = 1; i < n; ++i) { |
| 319 | temp = abs(arr[i] - arr[i - 1]); |
| 320 | if (temp > max_diff) { |
| 321 | max_diff = temp; |
| 322 | *idx_max_diff = i; |
| 323 | } |
| 324 | if (temp < min_diff) min_diff = temp; |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | void get_discontinuity_2d(uint8_t *dst, int stride, int n, int is_col, |
| 329 | int *idx_max_diff, int ntx) { |
| 330 | *idx_max_diff = -1; |
| 331 | |
| 332 | int diff = 0, temp = 0, max_diff = 0, min_diff = INT_MAX; |
| 333 | for (int i = 1; i < n; ++i) { |
| 334 | temp = 0; |
| 335 | for (int j = 0; j < ntx; ++j) { |
| 336 | if (is_col) // vertical diff |
| 337 | diff = dst[i * stride + j] - dst[(i - 1) * stride + j]; |
| 338 | else // horizontal diff |
| 339 | diff = dst[j * stride + i] - dst[j * stride + i - 1]; |
| 340 | temp += diff * diff; |
| 341 | } |
| 342 | // temp/w is the i-th avg square diff |
| 343 | if (temp > max_diff) { |
| 344 | max_diff = temp; |
| 345 | *idx_max_diff = i; |
| 346 | } |
| 347 | if (temp < min_diff) min_diff = temp; |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | int idx_selfloop_wrt_mode(PREDICTION_MODE mode, int is_col) { |
| 352 | // 0: no self-loop |
| 353 | // 1: small self-loop |
| 354 | // 2: medium self-loop |
| 355 | // 3: large self-loop |
| 356 | switch (mode) { |
| 357 | case DC_PRED: |
| 358 | case SMOOTH_PRED: |
| 359 | // predition is good for both directions: large SLs for row and col |
| 360 | return 3; |
Urvang Joshi | 96d1c0a | 2017-10-10 13:15:32 -0700 | [diff] [blame] | 361 | case PAETH_PRED: return 0; |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 362 | #if CONFIG_SMOOTH_HV |
| 363 | case SMOOTH_H_PRED: |
| 364 | #endif |
| 365 | case H_PRED: |
| 366 | // prediction is good for H direction: large SL for row only |
| 367 | return is_col ? 0 : 3; |
| 368 | #if CONFIG_SMOOTH_HV |
| 369 | case SMOOTH_V_PRED: |
| 370 | #endif |
| 371 | case V_PRED: |
| 372 | // prediction is good for V direction: large SL for col only |
| 373 | return is_col ? 3 : 0; |
| 374 | #if LGT_SL_INTRA |
| 375 | // directional mode: choose SL based on the direction |
| 376 | case D45_PRED: return is_col ? 2 : 0; |
| 377 | case D63_PRED: return is_col ? 3 : 0; |
| 378 | case D117_PRED: return is_col ? 3 : 1; |
| 379 | case D135_PRED: return 2; |
| 380 | case D153_PRED: return is_col ? 1 : 3; |
| 381 | case D207_PRED: return is_col ? 0 : 3; |
| 382 | #else |
| 383 | case D45_PRED: |
| 384 | case D63_PRED: |
| 385 | case D117_PRED: return is_col ? 3 : 0; |
| 386 | case D135_PRED: |
| 387 | case D153_PRED: |
| 388 | case D207_PRED: return is_col ? 0 : 3; |
| 389 | #endif |
| 390 | // inter: no SL |
| 391 | default: return 0; |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | void get_lgt4_from_pred(const TxfmParam *txfm_param, int is_col, |
| 396 | const tran_high_t **lgtmtx, int ntx) { |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 397 | #if CONFIG_EXT_TX |
| 398 | assert(av1_ext_tx_used[txfm_param->tx_set_type][txfm_param->tx_type]); |
| 399 | #endif // CONFIG_EXT_TX |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 400 | PREDICTION_MODE mode = txfm_param->mode; |
| 401 | int stride = txfm_param->stride; |
| 402 | uint8_t *dst = txfm_param->dst; |
| 403 | int bp = -1; |
| 404 | uint8_t arr[4]; |
| 405 | |
| 406 | // Each lgt4mtx_arr[k][i] corresponds to a line graph with a self-loop on |
| 407 | // the first node, and possibly a weak edge within the line graph. i is |
| 408 | // the index of the weak edge (between the i-th and (i+1)-th pixels, i=0 |
| 409 | // means no weak edge). k corresponds to the first self-loop's weight |
| 410 | const tran_high_t *lgt4mtx_arr[4][4] = { |
| 411 | { &lgt4_000[0][0], &lgt4_000w1[0][0], &lgt4_000w2[0][0], |
| 412 | &lgt4_000w3[0][0] }, |
| 413 | { &lgt4_060[0][0], &lgt4_060_000w1[0][0], &lgt4_060_000w2[0][0], |
| 414 | &lgt4_060_000w3[0][0] }, |
| 415 | { &lgt4_100[0][0], &lgt4_100_000w1[0][0], &lgt4_100_000w2[0][0], |
| 416 | &lgt4_100_000w3[0][0] }, |
| 417 | { &lgt4_150[0][0], &lgt4_150_000w1[0][0], &lgt4_150_000w2[0][0], |
| 418 | &lgt4_150_000w3[0][0] }, |
| 419 | }; |
| 420 | |
| 421 | // initialize to DCT or some LGTs, and then change later if necessary |
| 422 | int idx_sl = idx_selfloop_wrt_mode(mode, is_col); |
| 423 | lgtmtx[0] = lgt4mtx_arr[idx_sl][0]; |
| 424 | |
| 425 | // find the break point and replace the line graph by the one with a |
| 426 | // break point |
| 427 | if (mode == DC_PRED || mode == SMOOTH_PRED) { |
| 428 | // Do not use break point, since 1) is_left_available and is_top_available |
| 429 | // in DC_PRED are not known by txfm_param for now, so accessing |
| 430 | // both boundaries anyway may cause a mismatch 2) DC prediciton |
| 431 | // typically yields very smooth residues so having the break point |
| 432 | // does not usually improve the RD result. |
| 433 | return; |
Urvang Joshi | 96d1c0a | 2017-10-10 13:15:32 -0700 | [diff] [blame] | 434 | } else if (mode == PAETH_PRED) { |
| 435 | // PAETH_PRED: use both 1D top boundary and 1D left boundary |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 436 | if (is_col) |
| 437 | for (int i = 0; i < 4; ++i) arr[i] = dst[i * stride]; |
| 438 | else |
| 439 | for (int i = 0; i < 4; ++i) arr[i] = dst[i]; |
| 440 | get_discontinuity_1d(&arr[0], 4, &bp); |
| 441 | } else if (mode == V_PRED) { |
| 442 | // V_PRED: use 1D top boundary only |
| 443 | if (is_col) return; |
| 444 | for (int i = 0; i < 4; ++i) arr[i] = dst[i]; |
| 445 | get_discontinuity_1d(&arr[0], 4, &bp); |
| 446 | } else if (mode == H_PRED) { |
| 447 | // H_PRED: use 1D left boundary only |
| 448 | if (!is_col) return; |
| 449 | for (int i = 0; i < 4; ++i) arr[i] = dst[i * stride]; |
| 450 | get_discontinuity_1d(&arr[0], 4, &bp); |
| 451 | #if CONFIG_SMOOTH_HV |
| 452 | } else if (mode == SMOOTH_V_PRED) { |
| 453 | if (is_col) return; |
| 454 | for (int i = 0; i < 4; ++i) arr[i] = dst[-stride + i]; |
| 455 | get_discontinuity_1d(&arr[0], 4, &bp); |
| 456 | } else if (mode == SMOOTH_H_PRED) { |
| 457 | if (!is_col) return; |
| 458 | for (int i = 0; i < 4; ++i) arr[i] = dst[i * stride - 1]; |
| 459 | get_discontinuity_1d(&arr[0], 4, &bp); |
| 460 | #endif |
| 461 | } else if (mode == D45_PRED || mode == D63_PRED || mode == D117_PRED) { |
| 462 | // directional modes closer to vertical (maybe include D135 later) |
| 463 | if (!is_col) get_discontinuity_2d(dst, stride, 4, 0, &bp, ntx); |
| 464 | } else if (mode == D135_PRED || mode == D153_PRED || mode == D207_PRED) { |
| 465 | // directional modes closer to horizontal |
| 466 | if (is_col) get_discontinuity_2d(dst, stride, 4, 1, &bp, ntx); |
Urvang Joshi | 96d1c0a | 2017-10-10 13:15:32 -0700 | [diff] [blame] | 467 | } else if (mode > PAETH_PRED) { |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 468 | // inter |
| 469 | get_discontinuity_2d(dst, stride, 4, is_col, &bp, ntx); |
| 470 | } |
| 471 | |
| 472 | #if LGT_SL_INTRA |
| 473 | if (bp != -1) lgtmtx[0] = lgt4mtx_arr[idx_sl][bp]; |
| 474 | #else |
| 475 | if (bp != -1) lgtmtx[0] = lgt4mtx_arr[0][bp]; |
| 476 | #endif |
| 477 | } |
| 478 | |
| 479 | void get_lgt8_from_pred(const TxfmParam *txfm_param, int is_col, |
| 480 | const tran_high_t **lgtmtx, int ntx) { |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 481 | #if CONFIG_EXT_TX |
| 482 | assert(av1_ext_tx_used[txfm_param->tx_set_type][txfm_param->tx_type]); |
| 483 | #endif // CONFIG_EXT_TX |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 484 | PREDICTION_MODE mode = txfm_param->mode; |
| 485 | int stride = txfm_param->stride; |
| 486 | uint8_t *dst = txfm_param->dst; |
| 487 | int bp = -1; |
| 488 | uint8_t arr[8]; |
| 489 | |
| 490 | const tran_high_t *lgt8mtx_arr[4][8] = { |
| 491 | { &lgt8_000[0][0], &lgt8_000w1[0][0], &lgt8_000w2[0][0], &lgt8_000w3[0][0], |
| 492 | &lgt8_000w4[0][0], &lgt8_000w5[0][0], &lgt8_000w6[0][0], |
| 493 | &lgt8_000w7[0][0] }, |
| 494 | { &lgt8_060[0][0], &lgt8_060_000w1[0][0], &lgt8_060_000w2[0][0], |
| 495 | &lgt8_060_000w3[0][0], &lgt8_060_000w4[0][0], &lgt8_060_000w5[0][0], |
| 496 | &lgt8_060_000w6[0][0], &lgt8_060_000w7[0][0] }, |
| 497 | { &lgt8_100[0][0], &lgt8_100_000w1[0][0], &lgt8_100_000w2[0][0], |
| 498 | &lgt8_100_000w3[0][0], &lgt8_100_000w4[0][0], &lgt8_100_000w5[0][0], |
| 499 | &lgt8_100_000w6[0][0], &lgt8_100_000w7[0][0] }, |
| 500 | { &lgt8_150[0][0], &lgt8_150_000w1[0][0], &lgt8_150_000w2[0][0], |
| 501 | &lgt8_150_000w3[0][0], &lgt8_150_000w4[0][0], &lgt8_150_000w5[0][0], |
| 502 | &lgt8_150_000w6[0][0], &lgt8_150_000w7[0][0] }, |
| 503 | }; |
| 504 | |
| 505 | int idx_sl = idx_selfloop_wrt_mode(mode, is_col); |
| 506 | lgtmtx[0] = lgt8mtx_arr[idx_sl][0]; |
| 507 | |
| 508 | if (mode == DC_PRED || mode == SMOOTH_PRED) { |
| 509 | return; |
Urvang Joshi | 96d1c0a | 2017-10-10 13:15:32 -0700 | [diff] [blame] | 510 | } else if (mode == PAETH_PRED) { |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 511 | if (is_col) |
| 512 | for (int i = 0; i < 8; ++i) arr[i] = dst[i * stride]; |
| 513 | else |
| 514 | for (int i = 0; i < 8; ++i) arr[i] = dst[i]; |
| 515 | get_discontinuity_1d(&arr[0], 8, &bp); |
| 516 | } else if (mode == V_PRED) { |
| 517 | if (is_col) return; |
| 518 | for (int i = 0; i < 8; ++i) arr[i] = dst[i]; |
| 519 | get_discontinuity_1d(&arr[0], 8, &bp); |
| 520 | } else if (mode == H_PRED) { |
| 521 | if (!is_col) return; |
| 522 | for (int i = 0; i < 8; ++i) arr[i] = dst[i * stride]; |
| 523 | get_discontinuity_1d(&arr[0], 8, &bp); |
| 524 | #if CONFIG_SMOOTH_HV |
| 525 | } else if (mode == SMOOTH_V_PRED) { |
| 526 | if (is_col) return; |
| 527 | for (int i = 0; i < 8; ++i) arr[i] = dst[-stride + i]; |
| 528 | get_discontinuity_1d(&arr[0], 8, &bp); |
| 529 | } else if (mode == SMOOTH_H_PRED) { |
| 530 | if (!is_col) return; |
| 531 | for (int i = 0; i < 8; ++i) arr[i] = dst[i * stride - 1]; |
| 532 | get_discontinuity_1d(&arr[0], 8, &bp); |
| 533 | #endif |
| 534 | } else if (mode == D45_PRED || mode == D63_PRED || mode == D117_PRED) { |
| 535 | if (!is_col) get_discontinuity_2d(dst, stride, 8, 0, &bp, ntx); |
| 536 | } else if (mode == D135_PRED || mode == D153_PRED || mode == D207_PRED) { |
| 537 | if (is_col) get_discontinuity_2d(dst, stride, 8, 1, &bp, ntx); |
Urvang Joshi | 96d1c0a | 2017-10-10 13:15:32 -0700 | [diff] [blame] | 538 | } else if (mode > PAETH_PRED) { |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 539 | get_discontinuity_2d(dst, stride, 8, is_col, &bp, ntx); |
| 540 | } |
| 541 | |
| 542 | #if LGT_SL_INTRA |
| 543 | if (bp != -1) lgtmtx[0] = lgt8mtx_arr[idx_sl][bp]; |
| 544 | #else |
| 545 | if (bp != -1) lgtmtx[0] = lgt8mtx_arr[0][bp]; |
| 546 | #endif |
| 547 | } |
| 548 | |
| 549 | // Since LGTs with length >8 are not implemented now, the following function |
| 550 | // will just call DCT or ADST |
| 551 | void get_lgt16up_from_pred(const TxfmParam *txfm_param, int is_col, |
| 552 | const tran_high_t **lgtmtx, int ntx) { |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 553 | #if CONFIG_EXT_TX |
| 554 | assert(av1_ext_tx_used[txfm_param->tx_set_type][txfm_param->tx_type]); |
| 555 | #endif // CONFIG_EXT_TX |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 556 | int tx_length = is_col ? tx_size_high[txfm_param->tx_size] |
| 557 | : tx_size_wide[txfm_param->tx_size]; |
| 558 | assert(tx_length == 16 || tx_length == 32); |
| 559 | PREDICTION_MODE mode = txfm_param->mode; |
| 560 | |
| 561 | (void)ntx; |
| 562 | const tran_high_t *dctmtx = |
| 563 | tx_length == 16 ? &lgt16_000[0][0] : &lgt32_000[0][0]; |
| 564 | const tran_high_t *adstmtx = |
| 565 | tx_length == 16 ? &lgt16_200[0][0] : &lgt32_200[0][0]; |
| 566 | |
| 567 | switch (mode) { |
| 568 | case DC_PRED: |
Urvang Joshi | 96d1c0a | 2017-10-10 13:15:32 -0700 | [diff] [blame] | 569 | case PAETH_PRED: |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 570 | case SMOOTH_PRED: |
| 571 | // prediction from both top and left -> ADST |
| 572 | lgtmtx[0] = adstmtx; |
| 573 | break; |
| 574 | case V_PRED: |
| 575 | case D45_PRED: |
| 576 | case D63_PRED: |
| 577 | case D117_PRED: |
| 578 | #if CONFIG_SMOOTH_HV |
| 579 | case SMOOTH_V_PRED: |
| 580 | #endif |
| 581 | // prediction from the top more than from the left -> ADST |
| 582 | lgtmtx[0] = is_col ? adstmtx : dctmtx; |
| 583 | break; |
| 584 | case H_PRED: |
| 585 | case D135_PRED: |
| 586 | case D153_PRED: |
| 587 | case D207_PRED: |
| 588 | #if CONFIG_SMOOTH_HV |
| 589 | case SMOOTH_H_PRED: |
| 590 | #endif |
| 591 | // prediction from the left more than from the top -> DCT |
| 592 | lgtmtx[0] = is_col ? dctmtx : adstmtx; |
| 593 | break; |
| 594 | default: lgtmtx[0] = dctmtx; break; |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | typedef void (*IlgtFunc)(const tran_low_t *input, tran_low_t *output, |
| 599 | const tran_high_t *lgtmtx); |
| 600 | |
| 601 | static IlgtFunc ilgt_func[4] = { ilgt4, ilgt8, ilgt16up, ilgt16up }; |
| 602 | |
| 603 | typedef void (*GetLgtFunc)(const TxfmParam *txfm_param, int is_col, |
| 604 | const tran_high_t **lgtmtx, int ntx); |
| 605 | |
| 606 | static GetLgtFunc get_lgt_func[4] = { get_lgt4_from_pred, get_lgt8_from_pred, |
| 607 | get_lgt16up_from_pred, |
| 608 | get_lgt16up_from_pred }; |
| 609 | |
| 610 | // this inline function corresponds to the up scaling before the transpose |
| 611 | // operation in the av1_iht* functions |
| 612 | static INLINE tran_low_t inv_upscale_wrt_txsize(const tran_high_t val, |
| 613 | const TX_SIZE tx_size) { |
| 614 | switch (tx_size) { |
| 615 | case TX_4X4: |
| 616 | case TX_8X8: |
| 617 | case TX_4X16: |
| 618 | case TX_16X4: |
| 619 | case TX_8X32: |
| 620 | case TX_32X8: return (tran_low_t)val; |
| 621 | case TX_4X8: |
| 622 | case TX_8X4: |
| 623 | case TX_8X16: |
| 624 | case TX_16X8: return (tran_low_t)dct_const_round_shift(val * Sqrt2); |
| 625 | default: assert(0); break; |
| 626 | } |
| 627 | return 0; |
| 628 | } |
| 629 | |
| 630 | // This inline function corresponds to the bit shift before summing with the |
| 631 | // destination in the av1_iht* functions |
| 632 | static INLINE tran_low_t inv_downscale_wrt_txsize(const tran_low_t val, |
| 633 | const TX_SIZE tx_size) { |
| 634 | switch (tx_size) { |
| 635 | case TX_4X4: return ROUND_POWER_OF_TWO(val, 4); |
| 636 | case TX_4X8: |
| 637 | case TX_8X4: |
| 638 | case TX_8X8: |
| 639 | case TX_4X16: |
| 640 | case TX_16X4: return ROUND_POWER_OF_TWO(val, 5); |
| 641 | case TX_8X16: |
| 642 | case TX_16X8: |
| 643 | case TX_8X32: |
| 644 | case TX_32X8: return ROUND_POWER_OF_TWO(val, 6); |
| 645 | default: assert(0); break; |
| 646 | } |
| 647 | return 0; |
| 648 | } |
| 649 | |
| 650 | void ilgt2d_from_pred_add(const tran_low_t *input, uint8_t *dest, int stride, |
| 651 | const TxfmParam *txfm_param) { |
| 652 | const TX_SIZE tx_size = txfm_param->tx_size; |
| 653 | const int w = tx_size_wide[tx_size]; |
| 654 | const int h = tx_size_high[tx_size]; |
| 655 | const int wlog2 = tx_size_wide_log2[tx_size]; |
| 656 | const int hlog2 = tx_size_high_log2[tx_size]; |
| 657 | assert(w <= 8 || h <= 8); |
| 658 | |
| 659 | int i, j; |
| 660 | // largest 1D size allowed for LGT: 32 |
| 661 | // largest 2D size allowed for LGT: 8x32=256 |
| 662 | tran_low_t tmp[256], out[256], temp1d[32]; |
| 663 | const tran_high_t *lgtmtx_col[1]; |
| 664 | const tran_high_t *lgtmtx_row[1]; |
| 665 | get_lgt_func[hlog2 - 2](txfm_param, 1, lgtmtx_col, w); |
| 666 | get_lgt_func[wlog2 - 2](txfm_param, 0, lgtmtx_row, h); |
| 667 | |
| 668 | // for inverse transform, to be consistent with av1_iht functions, we always |
| 669 | // apply row transforms first and column transforms second, but both |
| 670 | // row-first and column-first versions are implemented here for future |
| 671 | // tests (use different lgtmtx_col[i], and choose row or column tx first |
| 672 | // depending on transforms). |
| 673 | #if 1 |
| 674 | // inverse column transforms |
| 675 | for (i = 0; i < w; ++i) { |
| 676 | // transpose |
| 677 | for (j = 0; j < h; ++j) tmp[i * h + j] = input[j * w + i]; |
| 678 | ilgt_func[hlog2 - 2](&tmp[i * h], temp1d, lgtmtx_col[0]); |
| 679 | // upscale, and store in place |
| 680 | for (j = 0; j < h; ++j) |
| 681 | tmp[i * h + j] = inv_upscale_wrt_txsize(temp1d[j], tx_size); |
| 682 | } |
| 683 | // inverse row transforms |
| 684 | for (i = 0; i < h; ++i) { |
| 685 | for (j = 0; j < w; ++j) temp1d[j] = tmp[j * h + i]; |
| 686 | ilgt_func[wlog2 - 2](temp1d, &out[i * w], lgtmtx_row[0]); |
| 687 | } |
| 688 | // downscale + sum with the destination |
| 689 | for (i = 0; i < h; ++i) { |
| 690 | for (j = 0; j < w; ++j) { |
| 691 | int d = i * stride + j; |
| 692 | int s = i * w + j; |
| 693 | dest[d] = |
| 694 | clip_pixel_add(dest[d], inv_downscale_wrt_txsize(out[s], tx_size)); |
| 695 | } |
| 696 | } |
| 697 | #else |
| 698 | // inverse row transforms |
| 699 | for (i = 0; i < h; ++i) { |
| 700 | ilgt_func[wlog2 - 2](input, temp1d, lgtmtx_row[0]); |
| 701 | // upscale and transpose (tmp[j*h+i] <--> tmp[j][i]) |
| 702 | for (j = 0; j < w; ++j) |
| 703 | tmp[j * h + i] = inv_upscale_wrt_txsize(temp1d[j], tx_size); |
| 704 | input += w; |
| 705 | } |
| 706 | // inverse column transforms |
| 707 | for (i = 0; i < w; ++i) |
| 708 | ilgt_func[hlog2 - 2](&tmp[i * h], &out[i * h], lgtmtx_col[0]); |
| 709 | // here, out[] is the transpose of 2D block of transform coefficients |
| 710 | |
| 711 | // downscale + transform + sum with dest |
| 712 | for (i = 0; i < h; ++i) { |
| 713 | for (j = 0; j < w; ++j) { |
| 714 | int d = i * stride + j; |
| 715 | int s = j * h + i; |
| 716 | dest[d] = |
| 717 | clip_pixel_add(dest[d], inv_downscale_wrt_txsize(out[s], tx_size)); |
| 718 | } |
| 719 | } |
| 720 | #endif |
| 721 | } |
| 722 | #endif // CONFIG_LGT_FROM_PRED |
| 723 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 724 | void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 725 | const TxfmParam *txfm_param) { |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 726 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sarah Parker | 53f93db | 2017-07-11 17:20:04 -0700 | [diff] [blame] | 727 | #if CONFIG_MRC_TX |
| 728 | assert(tx_type != MRC_DCT && "Invalid tx type for tx size"); |
| 729 | #endif // CONFIG_MRC_TX |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 730 | #if !CONFIG_DAALA_TX4 |
Monty Montgomery | 554d2c3 | 2017-07-11 21:01:07 -0400 | [diff] [blame] | 731 | if (tx_type == DCT_DCT) { |
| 732 | aom_idct4x4_16_add(input, dest, stride); |
| 733 | return; |
| 734 | } |
Monty Montgomery | 02078a3 | 2017-07-11 21:22:29 -0400 | [diff] [blame] | 735 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 736 | static const transform_2d IHT_4[] = { |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 737 | #if CONFIG_DAALA_TX4 |
Nathan E. Egge | 1aefb5e | 2017-09-16 11:28:41 -0400 | [diff] [blame] | 738 | { daala_idct4, daala_idct4 }, // DCT_DCT = 0 |
| 739 | { daala_idst4, daala_idct4 }, // ADST_DCT = 1 |
| 740 | { daala_idct4, daala_idst4 }, // DCT_ADST = 2 |
| 741 | { daala_idst4, daala_idst4 }, // ADST_ADST = 3 |
Nathan E. Egge | 5e6bda8 | 2017-09-16 10:13:51 -0400 | [diff] [blame] | 742 | #if CONFIG_EXT_TX |
Nathan E. Egge | 1aefb5e | 2017-09-16 11:28:41 -0400 | [diff] [blame] | 743 | { daala_idst4, daala_idct4 }, // FLIPADST_DCT |
| 744 | { daala_idct4, daala_idst4 }, // DCT_FLIPADST |
| 745 | { daala_idst4, daala_idst4 }, // FLIPADST_FLIPADST |
| 746 | { daala_idst4, daala_idst4 }, // ADST_FLIPADST |
| 747 | { daala_idst4, daala_idst4 }, // FLIPADST_ADST |
Nathan E. Egge | 31f24ee | 2017-09-18 11:25:26 -0400 | [diff] [blame] | 748 | { daala_idtx4, daala_idtx4 }, // IDTX |
| 749 | { daala_idct4, daala_idtx4 }, // V_DCT |
| 750 | { daala_idtx4, daala_idct4 }, // H_DCT |
| 751 | { daala_idst4, daala_idtx4 }, // V_ADST |
| 752 | { daala_idtx4, daala_idst4 }, // H_ADST |
| 753 | { daala_idst4, daala_idtx4 }, // V_FLIPADST |
| 754 | { daala_idtx4, daala_idst4 }, // H_FLIPADST |
Nathan E. Egge | 5e6bda8 | 2017-09-16 10:13:51 -0400 | [diff] [blame] | 755 | #endif |
| 756 | #else |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 757 | { aom_idct4_c, aom_idct4_c }, // DCT_DCT = 0 |
| 758 | { aom_iadst4_c, aom_idct4_c }, // ADST_DCT = 1 |
| 759 | { aom_idct4_c, aom_iadst4_c }, // DCT_ADST = 2 |
| 760 | { aom_iadst4_c, aom_iadst4_c }, // ADST_ADST = 3 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 761 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 762 | { aom_iadst4_c, aom_idct4_c }, // FLIPADST_DCT |
| 763 | { aom_idct4_c, aom_iadst4_c }, // DCT_FLIPADST |
| 764 | { aom_iadst4_c, aom_iadst4_c }, // FLIPADST_FLIPADST |
| 765 | { aom_iadst4_c, aom_iadst4_c }, // ADST_FLIPADST |
| 766 | { aom_iadst4_c, aom_iadst4_c }, // FLIPADST_ADST |
| 767 | { iidtx4_c, iidtx4_c }, // IDTX |
| 768 | { aom_idct4_c, iidtx4_c }, // V_DCT |
| 769 | { iidtx4_c, aom_idct4_c }, // H_DCT |
| 770 | { aom_iadst4_c, iidtx4_c }, // V_ADST |
| 771 | { iidtx4_c, aom_iadst4_c }, // H_ADST |
| 772 | { aom_iadst4_c, iidtx4_c }, // V_FLIPADST |
| 773 | { iidtx4_c, aom_iadst4_c }, // H_FLIPADST |
Lester Lu | d8b1ddc | 2017-07-06 16:13:29 -0700 | [diff] [blame] | 774 | #endif |
Nathan E. Egge | 5e6bda8 | 2017-09-16 10:13:51 -0400 | [diff] [blame] | 775 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 776 | }; |
| 777 | |
| 778 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 779 | tran_low_t tmp[4][4]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 780 | tran_low_t out[4][4]; |
| 781 | tran_low_t *outp = &out[0][0]; |
| 782 | int outstride = 4; |
| 783 | |
Monty Montgomery | cb55dad | 2017-07-11 16:59:52 -0400 | [diff] [blame] | 784 | #if CONFIG_DCT_ONLY |
| 785 | assert(tx_type == DCT_DCT); |
| 786 | #endif |
| 787 | |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 788 | #if CONFIG_LGT |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 789 | const tran_high_t *lgtmtx_col[1]; |
| 790 | const tran_high_t *lgtmtx_row[1]; |
| 791 | int use_lgt_col = get_lgt4(txfm_param, 1, lgtmtx_col); |
| 792 | int use_lgt_row = get_lgt4(txfm_param, 0, lgtmtx_row); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 793 | #endif |
| 794 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 795 | // inverse transform row vectors |
| 796 | for (i = 0; i < 4; ++i) { |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 797 | #if CONFIG_DAALA_TX4 |
Monty Montgomery | 02078a3 | 2017-07-11 21:22:29 -0400 | [diff] [blame] | 798 | tran_low_t temp_in[4]; |
Sebastien Alaiwan | 7732326 | 2017-08-21 11:34:56 +0200 | [diff] [blame] | 799 | for (j = 0; j < 4; j++) temp_in[j] = input[j] * 2; |
Monty Montgomery | 02078a3 | 2017-07-11 21:22:29 -0400 | [diff] [blame] | 800 | IHT_4[tx_type].rows(temp_in, out[i]); |
| 801 | #else |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 802 | #if CONFIG_LGT |
| 803 | if (use_lgt_row) |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 804 | ilgt4(input, out[i], lgtmtx_row[0]); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 805 | else |
| 806 | #endif |
| 807 | IHT_4[tx_type].rows(input, out[i]); |
Monty Montgomery | 02078a3 | 2017-07-11 21:22:29 -0400 | [diff] [blame] | 808 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 809 | input += 4; |
| 810 | } |
| 811 | |
| 812 | // transpose |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 813 | for (i = 0; i < 4; i++) { |
| 814 | for (j = 0; j < 4; j++) { |
| 815 | tmp[j][i] = out[i][j]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 816 | } |
| 817 | } |
| 818 | |
| 819 | // inverse transform column vectors |
| 820 | for (i = 0; i < 4; ++i) { |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 821 | #if CONFIG_LGT |
| 822 | if (use_lgt_col) |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 823 | ilgt4(tmp[i], out[i], lgtmtx_col[0]); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 824 | else |
| 825 | #endif |
| 826 | IHT_4[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 827 | } |
| 828 | |
| 829 | #if CONFIG_EXT_TX |
| 830 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 4, 4); |
| 831 | #endif |
| 832 | |
| 833 | // Sum with the destination |
| 834 | for (i = 0; i < 4; ++i) { |
| 835 | for (j = 0; j < 4; ++j) { |
| 836 | int d = i * stride + j; |
| 837 | int s = j * outstride + i; |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 838 | #if CONFIG_DAALA_TX4 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 839 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 4)); |
Monty Montgomery | 02078a3 | 2017-07-11 21:22:29 -0400 | [diff] [blame] | 840 | #else |
| 841 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 4)); |
| 842 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 843 | } |
| 844 | } |
| 845 | } |
| 846 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 847 | void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 848 | const TxfmParam *txfm_param) { |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 849 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sarah Parker | 53f93db | 2017-07-11 17:20:04 -0700 | [diff] [blame] | 850 | #if CONFIG_MRC_TX |
| 851 | assert(tx_type != MRC_DCT && "Invalid tx type for tx size"); |
| 852 | #endif // CONFIG_MRC_TX |
Monty Montgomery | cb55dad | 2017-07-11 16:59:52 -0400 | [diff] [blame] | 853 | #if CONFIG_DCT_ONLY |
| 854 | assert(tx_type == DCT_DCT); |
| 855 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 856 | static const transform_2d IHT_4x8[] = { |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 857 | #if CONFIG_DAALA_TX4 && CONFIG_DAALA_TX8 |
| 858 | { daala_idct8, daala_idct4 }, // DCT_DCT = 0 |
| 859 | { daala_idst8, daala_idct4 }, // ADST_DCT = 1 |
| 860 | { daala_idct8, daala_idst4 }, // DCT_ADST = 2 |
| 861 | { daala_idst8, daala_idst4 }, // ADST_ADST = 3 |
| 862 | #if CONFIG_EXT_TX |
| 863 | { daala_idst8, daala_idct4 }, // FLIPADST_DCT |
| 864 | { daala_idct8, daala_idst4 }, // DCT_FLIPADST |
| 865 | { daala_idst8, daala_idst4 }, // FLIPADST_FLIPADST |
| 866 | { daala_idst8, daala_idst4 }, // ADST_FLIPADST |
| 867 | { daala_idst8, daala_idst4 }, // FLIPADST_ADST |
| 868 | { daala_idtx8, daala_idtx4 }, // IDTX |
| 869 | { daala_idct8, daala_idtx4 }, // V_DCT |
| 870 | { daala_idtx8, daala_idct4 }, // H_DCT |
| 871 | { daala_idst8, daala_idtx4 }, // V_ADST |
| 872 | { daala_idtx8, daala_idst4 }, // H_ADST |
| 873 | { daala_idst8, daala_idtx4 }, // V_FLIPADST |
| 874 | { daala_idtx8, daala_idst4 }, // H_FLIPADST |
| 875 | #endif |
| 876 | #else |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 877 | { aom_idct8_c, aom_idct4_c }, // DCT_DCT |
| 878 | { aom_iadst8_c, aom_idct4_c }, // ADST_DCT |
| 879 | { aom_idct8_c, aom_iadst4_c }, // DCT_ADST |
| 880 | { aom_iadst8_c, aom_iadst4_c }, // ADST_ADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 881 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 882 | { aom_iadst8_c, aom_idct4_c }, // FLIPADST_DCT |
| 883 | { aom_idct8_c, aom_iadst4_c }, // DCT_FLIPADST |
| 884 | { aom_iadst8_c, aom_iadst4_c }, // FLIPADST_FLIPADST |
| 885 | { aom_iadst8_c, aom_iadst4_c }, // ADST_FLIPADST |
| 886 | { aom_iadst8_c, aom_iadst4_c }, // FLIPADST_ADST |
| 887 | { iidtx8_c, iidtx4_c }, // IDTX |
| 888 | { aom_idct8_c, iidtx4_c }, // V_DCT |
| 889 | { iidtx8_c, aom_idct4_c }, // H_DCT |
| 890 | { aom_iadst8_c, iidtx4_c }, // V_ADST |
| 891 | { iidtx8_c, aom_iadst4_c }, // H_ADST |
| 892 | { aom_iadst8_c, iidtx4_c }, // V_FLIPADST |
| 893 | { iidtx8_c, aom_iadst4_c }, // H_FLIPADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 894 | #endif |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 895 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 896 | }; |
| 897 | |
| 898 | const int n = 4; |
| 899 | const int n2 = 8; |
| 900 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 901 | tran_low_t out[4][8], tmp[4][8], outtmp[4]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 902 | tran_low_t *outp = &out[0][0]; |
| 903 | int outstride = n2; |
| 904 | |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 905 | #if CONFIG_LGT |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 906 | const tran_high_t *lgtmtx_col[1]; |
| 907 | const tran_high_t *lgtmtx_row[1]; |
| 908 | int use_lgt_col = get_lgt8(txfm_param, 1, lgtmtx_col); |
| 909 | int use_lgt_row = get_lgt4(txfm_param, 0, lgtmtx_row); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 910 | #endif |
| 911 | |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 912 | // Multi-way scaling matrix (bits): |
| 913 | // LGT/AV1 row,col input+0, rowTX+.5, mid+.5, colTX+1, out-5 == -3 |
| 914 | // LGT row, Daala col input+0, rowTX+.5, mid+.5, colTX+0, out-4 == -3 |
| 915 | // Daala row, LGT col input+1, rowTX+0, mid+0, colTX+1, out-5 == -3 |
| 916 | // Daala row,col input+1, rowTX+0, mid+0, colTX+0, out-4 == -3 |
| 917 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 918 | // inverse transform row vectors and transpose |
| 919 | for (i = 0; i < n2; ++i) { |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 920 | #if CONFIG_LGT |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 921 | if (use_lgt_row) { |
| 922 | // Scaling cases 1 and 2 above |
| 923 | // No input scaling |
| 924 | // Row transform (LGT; scales up .5 bits) |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 925 | ilgt4(input, outtmp, lgtmtx_row[0]); |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 926 | // Transpose and mid scaling up by .5 bit |
| 927 | for (j = 0; j < n; ++j) |
| 928 | tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2); |
| 929 | } else { |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 930 | #endif |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 931 | #if CONFIG_DAALA_TX4 && CONFIG_DAALA_TX8 |
| 932 | // Daala row transform; Scaling cases 3 and 4 above |
| 933 | tran_low_t temp_in[4]; |
| 934 | // Input scaling up by 1 bit |
| 935 | for (j = 0; j < n; j++) temp_in[j] = input[j] * 2; |
| 936 | // Row transform; Daala does not scale |
| 937 | IHT_4x8[tx_type].rows(temp_in, outtmp); |
| 938 | // Transpose; no mid scaling |
| 939 | for (j = 0; j < n; ++j) tmp[j][i] = outtmp[j]; |
| 940 | #else |
| 941 | // AV1 row transform; Scaling case 1 only |
| 942 | // Row transform (AV1 scales up .5 bits) |
| 943 | IHT_4x8[tx_type].rows(input, outtmp); |
| 944 | // Transpose and mid scaling up by .5 bit |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 945 | for (j = 0; j < n; ++j) |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 946 | tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2); |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 947 | #endif |
| 948 | #if CONFIG_LGT |
| 949 | } |
| 950 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 951 | input += n; |
| 952 | } |
| 953 | |
| 954 | // inverse transform column vectors |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 955 | // AV1/LGT column TX scales up by 1 bit, Daala does not scale |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 956 | for (i = 0; i < n; ++i) { |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 957 | #if CONFIG_LGT |
| 958 | if (use_lgt_col) |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 959 | ilgt8(tmp[i], out[i], lgtmtx_col[0]); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 960 | else |
| 961 | #endif |
| 962 | IHT_4x8[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 963 | } |
| 964 | |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 965 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 966 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n); |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 967 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 968 | |
| 969 | // Sum with the destination |
| 970 | for (i = 0; i < n2; ++i) { |
| 971 | for (j = 0; j < n; ++j) { |
| 972 | int d = i * stride + j; |
| 973 | int s = j * outstride + i; |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 974 | #if CONFIG_DAALA_TX4 && CONFIG_DAALA_TX8 |
| 975 | #if CONFIG_LGT |
| 976 | if (use_lgt_col) |
| 977 | // Output Scaling cases 1, 3 |
| 978 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
| 979 | else |
| 980 | #endif |
| 981 | // Output scaling cases 2, 4 |
| 982 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 4)); |
| 983 | #else |
| 984 | // Output scaling case 1 only |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 985 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 986 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 987 | } |
| 988 | } |
| 989 | } |
| 990 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 991 | void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 992 | const TxfmParam *txfm_param) { |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 993 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sarah Parker | 53f93db | 2017-07-11 17:20:04 -0700 | [diff] [blame] | 994 | #if CONFIG_MRC_TX |
| 995 | assert(tx_type != MRC_DCT && "Invalid tx type for tx size"); |
| 996 | #endif // CONFIG_MRC_TX |
Monty Montgomery | cb55dad | 2017-07-11 16:59:52 -0400 | [diff] [blame] | 997 | #if CONFIG_DCT_ONLY |
| 998 | assert(tx_type == DCT_DCT); |
| 999 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1000 | static const transform_2d IHT_8x4[] = { |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 1001 | #if CONFIG_DAALA_TX4 && CONFIG_DAALA_TX8 |
| 1002 | { daala_idct4, daala_idct8 }, // DCT_DCT = 0 |
| 1003 | { daala_idst4, daala_idct8 }, // ADST_DCT = 1 |
| 1004 | { daala_idct4, daala_idst8 }, // DCT_ADST = 2 |
| 1005 | { daala_idst4, daala_idst8 }, // ADST_ADST = 3 |
| 1006 | #if CONFIG_EXT_TX |
| 1007 | { daala_idst4, daala_idct8 }, // FLIPADST_DCT |
| 1008 | { daala_idct4, daala_idst8 }, // DCT_FLIPADST |
| 1009 | { daala_idst4, daala_idst8 }, // FLIPADST_FLIPADST |
| 1010 | { daala_idst4, daala_idst8 }, // ADST_FLIPADST |
| 1011 | { daala_idst4, daala_idst8 }, // FLIPADST_ADST |
| 1012 | { daala_idtx4, daala_idtx8 }, // IDTX |
| 1013 | { daala_idct4, daala_idtx8 }, // V_DCT |
| 1014 | { daala_idtx4, daala_idct8 }, // H_DCT |
| 1015 | { daala_idst4, daala_idtx8 }, // V_ADST |
| 1016 | { daala_idtx4, daala_idst8 }, // H_ADST |
| 1017 | { daala_idst4, daala_idtx8 }, // V_FLIPADST |
| 1018 | { daala_idtx4, daala_idst8 }, // H_FLIPADST |
| 1019 | #endif |
| 1020 | #else |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 1021 | { aom_idct4_c, aom_idct8_c }, // DCT_DCT |
| 1022 | { aom_iadst4_c, aom_idct8_c }, // ADST_DCT |
| 1023 | { aom_idct4_c, aom_iadst8_c }, // DCT_ADST |
| 1024 | { aom_iadst4_c, aom_iadst8_c }, // ADST_ADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1025 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 1026 | { aom_iadst4_c, aom_idct8_c }, // FLIPADST_DCT |
| 1027 | { aom_idct4_c, aom_iadst8_c }, // DCT_FLIPADST |
| 1028 | { aom_iadst4_c, aom_iadst8_c }, // FLIPADST_FLIPADST |
| 1029 | { aom_iadst4_c, aom_iadst8_c }, // ADST_FLIPADST |
| 1030 | { aom_iadst4_c, aom_iadst8_c }, // FLIPADST_ADST |
| 1031 | { iidtx4_c, iidtx8_c }, // IDTX |
| 1032 | { aom_idct4_c, iidtx8_c }, // V_DCT |
| 1033 | { iidtx4_c, aom_idct8_c }, // H_DCT |
| 1034 | { aom_iadst4_c, iidtx8_c }, // V_ADST |
| 1035 | { iidtx4_c, aom_iadst8_c }, // H_ADST |
| 1036 | { aom_iadst4_c, iidtx8_c }, // V_FLIPADST |
| 1037 | { iidtx4_c, aom_iadst8_c }, // H_FLIPADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1038 | #endif |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 1039 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1040 | }; |
Lester Lu | d8b1ddc | 2017-07-06 16:13:29 -0700 | [diff] [blame] | 1041 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1042 | const int n = 4; |
| 1043 | const int n2 = 8; |
| 1044 | |
| 1045 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1046 | tran_low_t out[8][4], tmp[8][4], outtmp[8]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1047 | tran_low_t *outp = &out[0][0]; |
| 1048 | int outstride = n; |
| 1049 | |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1050 | #if CONFIG_LGT |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1051 | const tran_high_t *lgtmtx_col[1]; |
| 1052 | const tran_high_t *lgtmtx_row[1]; |
| 1053 | int use_lgt_col = get_lgt4(txfm_param, 1, lgtmtx_col); |
| 1054 | int use_lgt_row = get_lgt8(txfm_param, 0, lgtmtx_row); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1055 | #endif |
| 1056 | |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 1057 | // Multi-way scaling matrix (bits): |
| 1058 | // LGT/AV1 row,col input+0, rowTX+1, mid+.5, colTX+.5, out-5 == -3 |
| 1059 | // LGT row, Daala col input+0, rowTX+1, mid+.5, colTX+.5, out-4 == -3 |
| 1060 | // Daala row, LGT col input+1, rowTX+0, mid+0, colTX+1, out-5 == -3 |
| 1061 | // Daala row,col input+1, rowTX+0, mid+0, colTX+0, out-4 == -3 |
| 1062 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1063 | // inverse transform row vectors and transpose |
| 1064 | for (i = 0; i < n; ++i) { |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1065 | #if CONFIG_LGT |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 1066 | if (use_lgt_row) { |
| 1067 | // Scaling cases 1 and 2 above |
| 1068 | // No input scaling |
| 1069 | // Row transform (LGT; scales up 1 bit) |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1070 | ilgt8(input, outtmp, lgtmtx_row[0]); |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 1071 | // Transpose and mid scaling up by .5 bit |
| 1072 | for (j = 0; j < n2; ++j) |
| 1073 | tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2); |
| 1074 | } else { |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1075 | #endif |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 1076 | #if CONFIG_DAALA_TX4 && CONFIG_DAALA_TX8 |
| 1077 | // Daala row transform; Scaling cases 3 and 4 above |
| 1078 | tran_low_t temp_in[8]; |
| 1079 | // Input scaling up by 1 bit |
| 1080 | for (j = 0; j < n2; j++) temp_in[j] = input[j] * 2; |
| 1081 | // Row transform; Daala does not scale |
| 1082 | IHT_8x4[tx_type].rows(temp_in, outtmp); |
| 1083 | // Transpose; no mid scaling |
| 1084 | for (j = 0; j < n2; ++j) tmp[j][i] = outtmp[j]; |
| 1085 | #else |
| 1086 | // AV1 row transform; Scaling case 1 only |
| 1087 | // Row transform (AV1 scales up 1 bit) |
| 1088 | IHT_8x4[tx_type].rows(input, outtmp); |
| 1089 | // Transpose and mid scaling up by .5 bit |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1090 | for (j = 0; j < n2; ++j) |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1091 | tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2); |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 1092 | #endif |
| 1093 | #if CONFIG_LGT |
| 1094 | } |
| 1095 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1096 | input += n2; |
| 1097 | } |
| 1098 | |
| 1099 | // inverse transform column vectors |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 1100 | // AV1 and LGT scale up by .5 bits; Daala does not scale |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1101 | for (i = 0; i < n2; ++i) { |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1102 | #if CONFIG_LGT |
| 1103 | if (use_lgt_col) |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1104 | ilgt4(tmp[i], out[i], lgtmtx_col[0]); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1105 | else |
| 1106 | #endif |
| 1107 | IHT_8x4[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1108 | } |
| 1109 | |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1110 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1111 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2); |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1112 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1113 | |
| 1114 | // Sum with the destination |
| 1115 | for (i = 0; i < n; ++i) { |
| 1116 | for (j = 0; j < n2; ++j) { |
| 1117 | int d = i * stride + j; |
| 1118 | int s = j * outstride + i; |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 1119 | #if CONFIG_DAALA_TX4 && CONFIG_DAALA_TX8 |
| 1120 | #if CONFIG_LGT |
| 1121 | if (use_lgt_col) |
| 1122 | // Output scaling cases 1, 3 |
| 1123 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
| 1124 | else |
| 1125 | #endif |
| 1126 | // Output scaling cases 2, 4 |
| 1127 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 4)); |
| 1128 | #else |
| 1129 | // Output scaling case 1 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1130 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 1131 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1132 | } |
| 1133 | } |
| 1134 | } |
| 1135 | |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1136 | void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 1137 | const TxfmParam *txfm_param) { |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 1138 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sarah Parker | 53f93db | 2017-07-11 17:20:04 -0700 | [diff] [blame] | 1139 | #if CONFIG_MRC_TX |
| 1140 | assert(tx_type != MRC_DCT && "Invalid tx type for tx size"); |
| 1141 | #endif // CONFIG_MRC_TX |
Monty Montgomery | cb55dad | 2017-07-11 16:59:52 -0400 | [diff] [blame] | 1142 | #if CONFIG_DCT_ONLY |
| 1143 | assert(tx_type == DCT_DCT); |
| 1144 | #endif |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1145 | static const transform_2d IHT_4x16[] = { |
| 1146 | { aom_idct16_c, aom_idct4_c }, // DCT_DCT |
| 1147 | { aom_iadst16_c, aom_idct4_c }, // ADST_DCT |
| 1148 | { aom_idct16_c, aom_iadst4_c }, // DCT_ADST |
| 1149 | { aom_iadst16_c, aom_iadst4_c }, // ADST_ADST |
| 1150 | #if CONFIG_EXT_TX |
| 1151 | { aom_iadst16_c, aom_idct4_c }, // FLIPADST_DCT |
| 1152 | { aom_idct16_c, aom_iadst4_c }, // DCT_FLIPADST |
| 1153 | { aom_iadst16_c, aom_iadst4_c }, // FLIPADST_FLIPADST |
| 1154 | { aom_iadst16_c, aom_iadst4_c }, // ADST_FLIPADST |
| 1155 | { aom_iadst16_c, aom_iadst4_c }, // FLIPADST_ADST |
| 1156 | { iidtx16_c, iidtx4_c }, // IDTX |
| 1157 | { aom_idct16_c, iidtx4_c }, // V_DCT |
| 1158 | { iidtx16_c, aom_idct4_c }, // H_DCT |
| 1159 | { aom_iadst16_c, iidtx4_c }, // V_ADST |
| 1160 | { iidtx16_c, aom_iadst4_c }, // H_ADST |
| 1161 | { aom_iadst16_c, iidtx4_c }, // V_FLIPADST |
| 1162 | { iidtx16_c, aom_iadst4_c }, // H_FLIPADST |
| 1163 | #endif |
| 1164 | }; |
| 1165 | |
| 1166 | const int n = 4; |
| 1167 | const int n4 = 16; |
| 1168 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1169 | tran_low_t out[4][16], tmp[4][16], outtmp[4]; |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1170 | tran_low_t *outp = &out[0][0]; |
| 1171 | int outstride = n4; |
| 1172 | |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1173 | #if CONFIG_LGT |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1174 | const tran_high_t *lgtmtx_row[1]; |
| 1175 | int use_lgt_row = get_lgt4(txfm_param, 0, lgtmtx_row); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1176 | #endif |
| 1177 | |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1178 | // inverse transform row vectors and transpose |
| 1179 | for (i = 0; i < n4; ++i) { |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1180 | #if CONFIG_LGT |
| 1181 | if (use_lgt_row) |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1182 | ilgt4(input, outtmp, lgtmtx_row[0]); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1183 | else |
| 1184 | #endif |
| 1185 | IHT_4x16[tx_type].rows(input, outtmp); |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1186 | for (j = 0; j < n; ++j) tmp[j][i] = outtmp[j]; |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1187 | input += n; |
| 1188 | } |
| 1189 | |
| 1190 | // inverse transform column vectors |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1191 | for (i = 0; i < n; ++i) { |
| 1192 | IHT_4x16[tx_type].cols(tmp[i], out[i]); |
| 1193 | } |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1194 | |
| 1195 | #if CONFIG_EXT_TX |
| 1196 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n4, n); |
| 1197 | #endif |
| 1198 | |
| 1199 | // Sum with the destination |
| 1200 | for (i = 0; i < n4; ++i) { |
| 1201 | for (j = 0; j < n; ++j) { |
| 1202 | int d = i * stride + j; |
| 1203 | int s = j * outstride + i; |
| 1204 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
| 1205 | } |
| 1206 | } |
| 1207 | } |
| 1208 | |
| 1209 | void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 1210 | const TxfmParam *txfm_param) { |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 1211 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sarah Parker | 53f93db | 2017-07-11 17:20:04 -0700 | [diff] [blame] | 1212 | #if CONFIG_MRC_TX |
| 1213 | assert(tx_type != MRC_DCT && "Invalid tx type for tx size"); |
| 1214 | #endif // CONFIG_MRC_TX |
Monty Montgomery | cb55dad | 2017-07-11 16:59:52 -0400 | [diff] [blame] | 1215 | #if CONFIG_DCT_ONLY |
| 1216 | assert(tx_type == DCT_DCT); |
| 1217 | #endif |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1218 | static const transform_2d IHT_16x4[] = { |
| 1219 | { aom_idct4_c, aom_idct16_c }, // DCT_DCT |
| 1220 | { aom_iadst4_c, aom_idct16_c }, // ADST_DCT |
| 1221 | { aom_idct4_c, aom_iadst16_c }, // DCT_ADST |
| 1222 | { aom_iadst4_c, aom_iadst16_c }, // ADST_ADST |
| 1223 | #if CONFIG_EXT_TX |
| 1224 | { aom_iadst4_c, aom_idct16_c }, // FLIPADST_DCT |
| 1225 | { aom_idct4_c, aom_iadst16_c }, // DCT_FLIPADST |
| 1226 | { aom_iadst4_c, aom_iadst16_c }, // FLIPADST_FLIPADST |
| 1227 | { aom_iadst4_c, aom_iadst16_c }, // ADST_FLIPADST |
| 1228 | { aom_iadst4_c, aom_iadst16_c }, // FLIPADST_ADST |
| 1229 | { iidtx4_c, iidtx16_c }, // IDTX |
| 1230 | { aom_idct4_c, iidtx16_c }, // V_DCT |
| 1231 | { iidtx4_c, aom_idct16_c }, // H_DCT |
| 1232 | { aom_iadst4_c, iidtx16_c }, // V_ADST |
| 1233 | { iidtx4_c, aom_iadst16_c }, // H_ADST |
| 1234 | { aom_iadst4_c, iidtx16_c }, // V_FLIPADST |
| 1235 | { iidtx4_c, aom_iadst16_c }, // H_FLIPADST |
| 1236 | #endif |
| 1237 | }; |
Lester Lu | d8b1ddc | 2017-07-06 16:13:29 -0700 | [diff] [blame] | 1238 | |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1239 | const int n = 4; |
| 1240 | const int n4 = 16; |
| 1241 | |
| 1242 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1243 | tran_low_t out[16][4], tmp[16][4], outtmp[16]; |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1244 | tran_low_t *outp = &out[0][0]; |
| 1245 | int outstride = n; |
| 1246 | |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1247 | #if CONFIG_LGT |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1248 | const tran_high_t *lgtmtx_col[1]; |
| 1249 | int use_lgt_col = get_lgt4(txfm_param, 1, lgtmtx_col); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1250 | #endif |
| 1251 | |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1252 | // inverse transform row vectors and transpose |
| 1253 | for (i = 0; i < n; ++i) { |
| 1254 | IHT_16x4[tx_type].rows(input, outtmp); |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1255 | for (j = 0; j < n4; ++j) tmp[j][i] = outtmp[j]; |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1256 | input += n4; |
| 1257 | } |
| 1258 | |
| 1259 | // inverse transform column vectors |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1260 | for (i = 0; i < n4; ++i) { |
| 1261 | #if CONFIG_LGT |
| 1262 | if (use_lgt_col) |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1263 | ilgt4(tmp[i], out[i], lgtmtx_col[0]); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1264 | else |
| 1265 | #endif |
| 1266 | IHT_16x4[tx_type].cols(tmp[i], out[i]); |
| 1267 | } |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1268 | |
| 1269 | #if CONFIG_EXT_TX |
| 1270 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n4); |
| 1271 | #endif |
| 1272 | |
| 1273 | // Sum with the destination |
| 1274 | for (i = 0; i < n; ++i) { |
| 1275 | for (j = 0; j < n4; ++j) { |
| 1276 | int d = i * stride + j; |
| 1277 | int s = j * outstride + i; |
| 1278 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
| 1279 | } |
| 1280 | } |
| 1281 | } |
| 1282 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1283 | void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 1284 | const TxfmParam *txfm_param) { |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 1285 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sarah Parker | 53f93db | 2017-07-11 17:20:04 -0700 | [diff] [blame] | 1286 | #if CONFIG_MRC_TX |
| 1287 | assert(tx_type != MRC_DCT && "Invalid tx type for tx size"); |
| 1288 | #endif // CONFIG_MRC_TX |
Monty Montgomery | cb55dad | 2017-07-11 16:59:52 -0400 | [diff] [blame] | 1289 | #if CONFIG_DCT_ONLY |
| 1290 | assert(tx_type == DCT_DCT); |
| 1291 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1292 | static const transform_2d IHT_8x16[] = { |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1293 | #if CONFIG_DAALA_TX8 && CONFIG_DAALA_TX16 |
| 1294 | { daala_idct16, daala_idct8 }, // DCT_DCT = 0 |
| 1295 | { daala_idst16, daala_idct8 }, // ADST_DCT = 1 |
| 1296 | { daala_idct16, daala_idst8 }, // DCT_ADST = 2 |
| 1297 | { daala_idst16, daala_idst8 }, // ADST_ADST = 3 |
| 1298 | #if CONFIG_EXT_TX |
| 1299 | { daala_idst16, daala_idct8 }, // FLIPADST_DCT |
| 1300 | { daala_idct16, daala_idst8 }, // DCT_FLIPADST |
| 1301 | { daala_idst16, daala_idst8 }, // FLIPADST_FLIPADST |
| 1302 | { daala_idst16, daala_idst8 }, // ADST_FLIPADST |
| 1303 | { daala_idst16, daala_idst8 }, // FLIPADST_ADST |
| 1304 | { daala_idtx16, daala_idtx8 }, // IDTX |
| 1305 | { daala_idct16, daala_idtx8 }, // V_DCT |
| 1306 | { daala_idtx16, daala_idct8 }, // H_DCT |
| 1307 | { daala_idst16, daala_idtx8 }, // V_ADST |
| 1308 | { daala_idtx16, daala_idst8 }, // H_ADST |
| 1309 | { daala_idst16, daala_idtx8 }, // V_FLIPADST |
| 1310 | { daala_idtx16, daala_idst8 }, // H_FLIPADST |
| 1311 | #endif |
| 1312 | #else |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 1313 | { aom_idct16_c, aom_idct8_c }, // DCT_DCT |
| 1314 | { aom_iadst16_c, aom_idct8_c }, // ADST_DCT |
| 1315 | { aom_idct16_c, aom_iadst8_c }, // DCT_ADST |
| 1316 | { aom_iadst16_c, aom_iadst8_c }, // ADST_ADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1317 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 1318 | { aom_iadst16_c, aom_idct8_c }, // FLIPADST_DCT |
| 1319 | { aom_idct16_c, aom_iadst8_c }, // DCT_FLIPADST |
| 1320 | { aom_iadst16_c, aom_iadst8_c }, // FLIPADST_FLIPADST |
| 1321 | { aom_iadst16_c, aom_iadst8_c }, // ADST_FLIPADST |
| 1322 | { aom_iadst16_c, aom_iadst8_c }, // FLIPADST_ADST |
| 1323 | { iidtx16_c, iidtx8_c }, // IDTX |
| 1324 | { aom_idct16_c, iidtx8_c }, // V_DCT |
| 1325 | { iidtx16_c, aom_idct8_c }, // H_DCT |
| 1326 | { aom_iadst16_c, iidtx8_c }, // V_ADST |
| 1327 | { iidtx16_c, aom_iadst8_c }, // H_ADST |
| 1328 | { aom_iadst16_c, iidtx8_c }, // V_FLIPADST |
| 1329 | { iidtx16_c, aom_iadst8_c }, // H_FLIPADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1330 | #endif |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1331 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1332 | }; |
| 1333 | |
| 1334 | const int n = 8; |
| 1335 | const int n2 = 16; |
| 1336 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1337 | tran_low_t out[8][16], tmp[8][16], outtmp[8]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1338 | tran_low_t *outp = &out[0][0]; |
| 1339 | int outstride = n2; |
| 1340 | |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1341 | #if CONFIG_LGT |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1342 | const tran_high_t *lgtmtx_row[1]; |
| 1343 | int use_lgt_row = get_lgt8(txfm_param, 0, lgtmtx_row); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1344 | #endif |
| 1345 | |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1346 | // Multi-way scaling matrix (bits): |
| 1347 | // LGT/AV1 row, AV1 col input+0, rowTX+1, mid+.5, colTX+1.5, out-6 == -3 |
| 1348 | // LGT row, Daala col input+0, rowTX+1, mid+0, colTX+0, out-4 == -3 |
| 1349 | // Daala row, LGT col N/A (no 16-point LGT) |
| 1350 | // Daala row,col input+1, rowTX+0, mid+0, colTX+0, out-4 == -3 |
| 1351 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1352 | // inverse transform row vectors and transpose |
| 1353 | for (i = 0; i < n2; ++i) { |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1354 | #if CONFIG_LGT |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1355 | if (use_lgt_row) { |
| 1356 | // Scaling cases 1 and 2 above |
| 1357 | // No input scaling |
| 1358 | // Row transform (LGT; scales up 1 bit) |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1359 | ilgt8(input, outtmp, lgtmtx_row[0]); |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1360 | // Transpose and mid scaling |
| 1361 | for (j = 0; j < n; ++j) { |
| 1362 | #if CONFIG_DAALA_TX8 && CONFIG_DAALA_TX16 |
| 1363 | // Mid scaling case 2 |
| 1364 | tmp[j][i] = outtmp[j]; |
| 1365 | #else |
| 1366 | // Mid scaling case 1 |
| 1367 | tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1368 | #endif |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1369 | } |
| 1370 | } else { |
| 1371 | #endif |
| 1372 | #if CONFIG_DAALA_TX8 && CONFIG_DAALA_TX16 |
| 1373 | tran_low_t temp_in[8]; |
| 1374 | // Input scaling case 4 |
| 1375 | for (j = 0; j < n; j++) temp_in[j] = input[j] * 2; |
| 1376 | // Row transform (Daala does not scale) |
| 1377 | IHT_8x16[tx_type].rows(temp_in, outtmp); |
| 1378 | // Transpose (no mid scaling) |
| 1379 | for (j = 0; j < n; ++j) tmp[j][i] = outtmp[j]; |
| 1380 | #else |
| 1381 | // Case 1; no input scaling |
| 1382 | // Row transform (AV1 scales up 1 bit) |
| 1383 | IHT_8x16[tx_type].rows(input, outtmp); |
| 1384 | // Transpose and mid scaling up .5 bits |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1385 | for (j = 0; j < n; ++j) |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1386 | tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2); |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1387 | #endif |
| 1388 | #if CONFIG_LGT |
| 1389 | } |
| 1390 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1391 | input += n; |
| 1392 | } |
| 1393 | |
| 1394 | // inverse transform column vectors |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1395 | // AV1 column TX scales up by 1.5 bit, Daala does not scale |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1396 | for (i = 0; i < n; ++i) { |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1397 | IHT_8x16[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1398 | } |
| 1399 | |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1400 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1401 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n); |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1402 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1403 | |
| 1404 | // Sum with the destination |
| 1405 | for (i = 0; i < n2; ++i) { |
| 1406 | for (j = 0; j < n; ++j) { |
| 1407 | int d = i * stride + j; |
| 1408 | int s = j * outstride + i; |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1409 | #if CONFIG_DAALA_TX8 && CONFIG_DAALA_TX16 |
| 1410 | // Output scaling cases 2 and 4 |
| 1411 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 4)); |
| 1412 | #else |
| 1413 | // Output scaling case 1 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1414 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6)); |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1415 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1416 | } |
| 1417 | } |
| 1418 | } |
| 1419 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1420 | void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 1421 | const TxfmParam *txfm_param) { |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 1422 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sarah Parker | 53f93db | 2017-07-11 17:20:04 -0700 | [diff] [blame] | 1423 | #if CONFIG_MRC_TX |
| 1424 | assert(tx_type != MRC_DCT && "Invalid tx type for tx size"); |
| 1425 | #endif // CONFIG_MRC_TX |
Monty Montgomery | cb55dad | 2017-07-11 16:59:52 -0400 | [diff] [blame] | 1426 | #if CONFIG_DCT_ONLY |
| 1427 | assert(tx_type == DCT_DCT); |
| 1428 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1429 | static const transform_2d IHT_16x8[] = { |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1430 | #if CONFIG_DAALA_TX8 && CONFIG_DAALA_TX16 |
| 1431 | { daala_idct8, daala_idct16 }, // DCT_DCT = 0 |
| 1432 | { daala_idst8, daala_idct16 }, // ADST_DCT = 1 |
| 1433 | { daala_idct8, daala_idst16 }, // DCT_ADST = 2 |
| 1434 | { daala_idst8, daala_idst16 }, // ADST_ADST = 3 |
| 1435 | #if CONFIG_EXT_TX |
| 1436 | { daala_idst8, daala_idct16 }, // FLIPADST_DCT |
| 1437 | { daala_idct8, daala_idst16 }, // DCT_FLIPADST |
| 1438 | { daala_idst8, daala_idst16 }, // FLIPADST_FLIPADST |
| 1439 | { daala_idst8, daala_idst16 }, // ADST_FLIPADST |
| 1440 | { daala_idst8, daala_idst16 }, // FLIPADST_ADST |
| 1441 | { daala_idtx8, daala_idtx16 }, // IDTX |
| 1442 | { daala_idct8, daala_idtx16 }, // V_DCT |
| 1443 | { daala_idtx8, daala_idct16 }, // H_DCT |
| 1444 | { daala_idst8, daala_idtx16 }, // V_ADST |
| 1445 | { daala_idtx8, daala_idst16 }, // H_ADST |
| 1446 | { daala_idst8, daala_idtx16 }, // V_FLIPADST |
| 1447 | { daala_idtx8, daala_idst16 }, // H_FLIPADST |
| 1448 | #endif |
| 1449 | #else |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 1450 | { aom_idct8_c, aom_idct16_c }, // DCT_DCT |
| 1451 | { aom_iadst8_c, aom_idct16_c }, // ADST_DCT |
| 1452 | { aom_idct8_c, aom_iadst16_c }, // DCT_ADST |
| 1453 | { aom_iadst8_c, aom_iadst16_c }, // ADST_ADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1454 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 1455 | { aom_iadst8_c, aom_idct16_c }, // FLIPADST_DCT |
| 1456 | { aom_idct8_c, aom_iadst16_c }, // DCT_FLIPADST |
| 1457 | { aom_iadst8_c, aom_iadst16_c }, // FLIPADST_FLIPADST |
| 1458 | { aom_iadst8_c, aom_iadst16_c }, // ADST_FLIPADST |
| 1459 | { aom_iadst8_c, aom_iadst16_c }, // FLIPADST_ADST |
| 1460 | { iidtx8_c, iidtx16_c }, // IDTX |
| 1461 | { aom_idct8_c, iidtx16_c }, // V_DCT |
| 1462 | { iidtx8_c, aom_idct16_c }, // H_DCT |
| 1463 | { aom_iadst8_c, iidtx16_c }, // V_ADST |
| 1464 | { iidtx8_c, aom_iadst16_c }, // H_ADST |
| 1465 | { aom_iadst8_c, iidtx16_c }, // V_FLIPADST |
| 1466 | { iidtx8_c, aom_iadst16_c }, // H_FLIPADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1467 | #endif |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1468 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1469 | }; |
Lester Lu | d8b1ddc | 2017-07-06 16:13:29 -0700 | [diff] [blame] | 1470 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1471 | const int n = 8; |
| 1472 | const int n2 = 16; |
| 1473 | |
| 1474 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1475 | tran_low_t out[16][8], tmp[16][8], outtmp[16]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1476 | tran_low_t *outp = &out[0][0]; |
| 1477 | int outstride = n; |
| 1478 | |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1479 | #if CONFIG_LGT |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1480 | const tran_high_t *lgtmtx_col[1]; |
| 1481 | int use_lgt_col = get_lgt8(txfm_param, 1, lgtmtx_col); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1482 | #endif |
| 1483 | |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1484 | // Multi-way scaling matrix (bits): |
| 1485 | // AV1 row, LGT/AV1 col input+0, rowTX+1.5, mid+.5, colTX+1, out-6 == -3 |
| 1486 | // LGT row, Daala col N/A (no 16-point LGT) |
| 1487 | // Daala row, LGT col input+1, rowTX+0, mid+1, colTX+1, out-6 == -3 |
| 1488 | // Daala row, col input+1, rowTX+0, mid+0, colTX+0, out-4 == -3 |
| 1489 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1490 | // inverse transform row vectors and transpose |
| 1491 | for (i = 0; i < n; ++i) { |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1492 | #if CONFIG_DAALA_TX8 && CONFIG_DAALA_TX16 |
| 1493 | tran_low_t temp_in[16]; |
| 1494 | // Input scaling cases 3 and 4 |
| 1495 | for (j = 0; j < n2; j++) temp_in[j] = input[j] * 2; |
| 1496 | // Daala row TX, no scaling |
| 1497 | IHT_16x8[tx_type].rows(temp_in, outtmp); |
| 1498 | // Transpose and mid scaling |
| 1499 | #if CONFIG_LGT |
| 1500 | if (use_lgt_col) |
| 1501 | // Case 3 |
| 1502 | for (j = 0; j < n2; ++j) tmp[j][i] = outtmp[j] * 2; |
| 1503 | else |
| 1504 | #endif |
| 1505 | // Case 4 |
| 1506 | for (j = 0; j < n2; ++j) tmp[j][i] = outtmp[j]; |
| 1507 | #else |
| 1508 | // Case 1 |
| 1509 | // No input scaling |
| 1510 | // Row transform, AV1 scales up by 1.5 bits |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1511 | IHT_16x8[tx_type].rows(input, outtmp); |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1512 | // Transpose and mid scaling up .5 bits |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1513 | for (j = 0; j < n2; ++j) |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1514 | tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2); |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1515 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1516 | input += n2; |
| 1517 | } |
| 1518 | |
| 1519 | // inverse transform column vectors |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1520 | // AV!/LGT scales up by 1 bit, Daala does not scale |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1521 | for (i = 0; i < n2; ++i) { |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1522 | #if CONFIG_LGT |
| 1523 | if (use_lgt_col) |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1524 | ilgt8(tmp[i], out[i], lgtmtx_col[0]); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1525 | else |
| 1526 | #endif |
| 1527 | IHT_16x8[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1528 | } |
| 1529 | |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1530 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1531 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2); |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1532 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1533 | |
| 1534 | // Sum with the destination |
| 1535 | for (i = 0; i < n; ++i) { |
| 1536 | for (j = 0; j < n2; ++j) { |
| 1537 | int d = i * stride + j; |
| 1538 | int s = j * outstride + i; |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1539 | // Output scaling |
| 1540 | #if CONFIG_DAALA_TX8 && CONFIG_DAALA_TX16 |
| 1541 | #if CONFIG_LGT |
| 1542 | if (use_lgt_col) |
| 1543 | // case 3 |
| 1544 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6)); |
| 1545 | else |
| 1546 | #endif |
| 1547 | // case 4 |
| 1548 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 4)); |
| 1549 | #else |
| 1550 | // case 1 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1551 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6)); |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 1552 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1553 | } |
| 1554 | } |
| 1555 | } |
| 1556 | |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1557 | void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 1558 | const TxfmParam *txfm_param) { |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 1559 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sarah Parker | 53f93db | 2017-07-11 17:20:04 -0700 | [diff] [blame] | 1560 | #if CONFIG_MRC_TX |
| 1561 | assert(tx_type != MRC_DCT && "Invalid tx type for tx size"); |
| 1562 | #endif // CONFIG_MRC_TX |
Monty Montgomery | cb55dad | 2017-07-11 16:59:52 -0400 | [diff] [blame] | 1563 | #if CONFIG_DCT_ONLY |
| 1564 | assert(tx_type == DCT_DCT); |
| 1565 | #endif |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1566 | static const transform_2d IHT_8x32[] = { |
| 1567 | { aom_idct32_c, aom_idct8_c }, // DCT_DCT |
| 1568 | { ihalfright32_c, aom_idct8_c }, // ADST_DCT |
| 1569 | { aom_idct32_c, aom_iadst8_c }, // DCT_ADST |
| 1570 | { ihalfright32_c, aom_iadst8_c }, // ADST_ADST |
| 1571 | #if CONFIG_EXT_TX |
| 1572 | { ihalfright32_c, aom_idct8_c }, // FLIPADST_DCT |
| 1573 | { aom_idct32_c, aom_iadst8_c }, // DCT_FLIPADST |
| 1574 | { ihalfright32_c, aom_iadst8_c }, // FLIPADST_FLIPADST |
| 1575 | { ihalfright32_c, aom_iadst8_c }, // ADST_FLIPADST |
| 1576 | { ihalfright32_c, aom_iadst8_c }, // FLIPADST_ADST |
| 1577 | { iidtx32_c, iidtx8_c }, // IDTX |
| 1578 | { aom_idct32_c, iidtx8_c }, // V_DCT |
| 1579 | { iidtx32_c, aom_idct8_c }, // H_DCT |
| 1580 | { ihalfright32_c, iidtx8_c }, // V_ADST |
| 1581 | { iidtx32_c, aom_iadst8_c }, // H_ADST |
| 1582 | { ihalfright32_c, iidtx8_c }, // V_FLIPADST |
| 1583 | { iidtx32_c, aom_iadst8_c }, // H_FLIPADST |
| 1584 | #endif |
| 1585 | }; |
| 1586 | |
| 1587 | const int n = 8; |
| 1588 | const int n4 = 32; |
| 1589 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1590 | tran_low_t out[8][32], tmp[8][32], outtmp[8]; |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1591 | tran_low_t *outp = &out[0][0]; |
| 1592 | int outstride = n4; |
| 1593 | |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1594 | #if CONFIG_LGT |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1595 | const tran_high_t *lgtmtx_row[1]; |
| 1596 | int use_lgt_row = get_lgt8(txfm_param, 0, lgtmtx_row); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1597 | #endif |
| 1598 | |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1599 | // inverse transform row vectors and transpose |
| 1600 | for (i = 0; i < n4; ++i) { |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1601 | #if CONFIG_LGT |
| 1602 | if (use_lgt_row) |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1603 | ilgt8(input, outtmp, lgtmtx_row[0]); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1604 | else |
| 1605 | #endif |
| 1606 | IHT_8x32[tx_type].rows(input, outtmp); |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1607 | for (j = 0; j < n; ++j) tmp[j][i] = outtmp[j]; |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1608 | input += n; |
| 1609 | } |
| 1610 | |
| 1611 | // inverse transform column vectors |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1612 | for (i = 0; i < n; ++i) { |
| 1613 | IHT_8x32[tx_type].cols(tmp[i], out[i]); |
| 1614 | } |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1615 | |
| 1616 | #if CONFIG_EXT_TX |
| 1617 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n4, n); |
| 1618 | #endif |
| 1619 | |
| 1620 | // Sum with the destination |
| 1621 | for (i = 0; i < n4; ++i) { |
| 1622 | for (j = 0; j < n; ++j) { |
| 1623 | int d = i * stride + j; |
| 1624 | int s = j * outstride + i; |
| 1625 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6)); |
| 1626 | } |
| 1627 | } |
| 1628 | } |
| 1629 | |
| 1630 | void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 1631 | const TxfmParam *txfm_param) { |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 1632 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sarah Parker | 53f93db | 2017-07-11 17:20:04 -0700 | [diff] [blame] | 1633 | #if CONFIG_MRC_TX |
| 1634 | assert(tx_type != MRC_DCT && "Invalid tx type for tx size"); |
| 1635 | #endif // CONFIG_MRC_TX |
Monty Montgomery | cb55dad | 2017-07-11 16:59:52 -0400 | [diff] [blame] | 1636 | #if CONFIG_DCT_ONLY |
| 1637 | assert(tx_type == DCT_DCT); |
| 1638 | #endif |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1639 | static const transform_2d IHT_32x8[] = { |
| 1640 | { aom_idct8_c, aom_idct32_c }, // DCT_DCT |
| 1641 | { aom_iadst8_c, aom_idct32_c }, // ADST_DCT |
| 1642 | { aom_idct8_c, ihalfright32_c }, // DCT_ADST |
| 1643 | { aom_iadst8_c, ihalfright32_c }, // ADST_ADST |
| 1644 | #if CONFIG_EXT_TX |
| 1645 | { aom_iadst8_c, aom_idct32_c }, // FLIPADST_DCT |
| 1646 | { aom_idct8_c, ihalfright32_c }, // DCT_FLIPADST |
| 1647 | { aom_iadst8_c, ihalfright32_c }, // FLIPADST_FLIPADST |
| 1648 | { aom_iadst8_c, ihalfright32_c }, // ADST_FLIPADST |
| 1649 | { aom_iadst8_c, ihalfright32_c }, // FLIPADST_ADST |
| 1650 | { iidtx8_c, iidtx32_c }, // IDTX |
| 1651 | { aom_idct8_c, iidtx32_c }, // V_DCT |
| 1652 | { iidtx8_c, aom_idct32_c }, // H_DCT |
| 1653 | { aom_iadst8_c, iidtx32_c }, // V_ADST |
| 1654 | { iidtx8_c, ihalfright32_c }, // H_ADST |
| 1655 | { aom_iadst8_c, iidtx32_c }, // V_FLIPADST |
| 1656 | { iidtx8_c, ihalfright32_c }, // H_FLIPADST |
| 1657 | #endif |
| 1658 | }; |
Lester Lu | d8b1ddc | 2017-07-06 16:13:29 -0700 | [diff] [blame] | 1659 | |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1660 | const int n = 8; |
| 1661 | const int n4 = 32; |
| 1662 | |
| 1663 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1664 | tran_low_t out[32][8], tmp[32][8], outtmp[32]; |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1665 | tran_low_t *outp = &out[0][0]; |
| 1666 | int outstride = n; |
| 1667 | |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1668 | #if CONFIG_LGT |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1669 | const tran_high_t *lgtmtx_col[1]; |
| 1670 | int use_lgt_col = get_lgt4(txfm_param, 1, lgtmtx_col); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1671 | #endif |
| 1672 | |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1673 | // inverse transform row vectors and transpose |
| 1674 | for (i = 0; i < n; ++i) { |
| 1675 | IHT_32x8[tx_type].rows(input, outtmp); |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1676 | for (j = 0; j < n4; ++j) tmp[j][i] = outtmp[j]; |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1677 | input += n4; |
| 1678 | } |
| 1679 | |
| 1680 | // inverse transform column vectors |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1681 | for (i = 0; i < n4; ++i) { |
| 1682 | #if CONFIG_LGT |
| 1683 | if (use_lgt_col) |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1684 | ilgt8(tmp[i], out[i], lgtmtx_col[0]); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1685 | else |
| 1686 | #endif |
| 1687 | IHT_32x8[tx_type].cols(tmp[i], out[i]); |
| 1688 | } |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 1689 | |
| 1690 | #if CONFIG_EXT_TX |
| 1691 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n4); |
| 1692 | #endif |
| 1693 | |
| 1694 | // Sum with the destination |
| 1695 | for (i = 0; i < n; ++i) { |
| 1696 | for (j = 0; j < n4; ++j) { |
| 1697 | int d = i * stride + j; |
| 1698 | int s = j * outstride + i; |
| 1699 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6)); |
| 1700 | } |
| 1701 | } |
| 1702 | } |
| 1703 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1704 | void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 1705 | const TxfmParam *txfm_param) { |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 1706 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sarah Parker | 53f93db | 2017-07-11 17:20:04 -0700 | [diff] [blame] | 1707 | #if CONFIG_MRC_TX |
| 1708 | assert(tx_type != MRC_DCT && "Invalid tx type for tx size"); |
| 1709 | #endif // CONFIG_MRC_TX |
Monty Montgomery | cb55dad | 2017-07-11 16:59:52 -0400 | [diff] [blame] | 1710 | #if CONFIG_DCT_ONLY |
| 1711 | assert(tx_type == DCT_DCT); |
| 1712 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1713 | static const transform_2d IHT_16x32[] = { |
Monty Montgomery | ad39685 | 2017-10-20 03:35:26 -0400 | [diff] [blame] | 1714 | #if CONFIG_DAALA_TX16 && CONFIG_DAALA_TX32 |
| 1715 | { daala_idct32, daala_idct16 }, // DCT_DCT = 0 |
| 1716 | { daala_idst32, daala_idct16 }, // ADST_DCT = 1 |
| 1717 | { daala_idct32, daala_idst16 }, // DCT_ADST = 2 |
| 1718 | { daala_idst32, daala_idst16 }, // ADST_ADST = 3 |
| 1719 | #if CONFIG_EXT_TX |
| 1720 | { daala_idst32, daala_idct16 }, // FLIPADST_DCT |
| 1721 | { daala_idct32, daala_idst16 }, // DCT_FLIPADST |
| 1722 | { daala_idst32, daala_idst16 }, // FLIPADST_FLIPADST |
| 1723 | { daala_idst32, daala_idst16 }, // ADST_FLIPADST |
| 1724 | { daala_idst32, daala_idst16 }, // FLIPADST_ADST |
| 1725 | { daala_idtx32, daala_idtx16 }, // IDTX |
| 1726 | { daala_idct32, daala_idtx16 }, // V_DCT |
| 1727 | { daala_idtx32, daala_idct16 }, // H_DCT |
| 1728 | { daala_idst32, daala_idtx16 }, // V_ADST |
| 1729 | { daala_idtx32, daala_idst16 }, // H_ADST |
| 1730 | { daala_idst32, daala_idtx16 }, // V_FLIPADST |
| 1731 | { daala_idtx32, daala_idst16 }, // H_FLIPADST |
| 1732 | #endif |
| 1733 | #else |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 1734 | { aom_idct32_c, aom_idct16_c }, // DCT_DCT |
| 1735 | { ihalfright32_c, aom_idct16_c }, // ADST_DCT |
| 1736 | { aom_idct32_c, aom_iadst16_c }, // DCT_ADST |
| 1737 | { ihalfright32_c, aom_iadst16_c }, // ADST_ADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1738 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 1739 | { ihalfright32_c, aom_idct16_c }, // FLIPADST_DCT |
| 1740 | { aom_idct32_c, aom_iadst16_c }, // DCT_FLIPADST |
| 1741 | { ihalfright32_c, aom_iadst16_c }, // FLIPADST_FLIPADST |
| 1742 | { ihalfright32_c, aom_iadst16_c }, // ADST_FLIPADST |
| 1743 | { ihalfright32_c, aom_iadst16_c }, // FLIPADST_ADST |
| 1744 | { iidtx32_c, iidtx16_c }, // IDTX |
| 1745 | { aom_idct32_c, iidtx16_c }, // V_DCT |
| 1746 | { iidtx32_c, aom_idct16_c }, // H_DCT |
| 1747 | { ihalfright32_c, iidtx16_c }, // V_ADST |
| 1748 | { iidtx32_c, aom_iadst16_c }, // H_ADST |
| 1749 | { ihalfright32_c, iidtx16_c }, // V_FLIPADST |
| 1750 | { iidtx32_c, aom_iadst16_c }, // H_FLIPADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1751 | #endif |
Monty Montgomery | ad39685 | 2017-10-20 03:35:26 -0400 | [diff] [blame] | 1752 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1753 | }; |
| 1754 | |
| 1755 | const int n = 16; |
| 1756 | const int n2 = 32; |
| 1757 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1758 | tran_low_t out[16][32], tmp[16][32], outtmp[16]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1759 | tran_low_t *outp = &out[0][0]; |
| 1760 | int outstride = n2; |
| 1761 | |
| 1762 | // inverse transform row vectors and transpose |
| 1763 | for (i = 0; i < n2; ++i) { |
Monty Montgomery | ad39685 | 2017-10-20 03:35:26 -0400 | [diff] [blame] | 1764 | #if CONFIG_DAALA_TX16 && CONFIG_DAALA_TX32 |
| 1765 | tran_low_t temp_in[16]; |
| 1766 | for (j = 0; j < n; j++) temp_in[j] = input[j] * 2; |
| 1767 | IHT_16x32[tx_type].rows(temp_in, outtmp); |
| 1768 | for (j = 0; j < n; ++j) tmp[j][i] = outtmp[j] * 4; |
| 1769 | #else |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1770 | IHT_16x32[tx_type].rows(input, outtmp); |
| 1771 | for (j = 0; j < n; ++j) |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1772 | tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2); |
Monty Montgomery | ad39685 | 2017-10-20 03:35:26 -0400 | [diff] [blame] | 1773 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1774 | input += n; |
| 1775 | } |
| 1776 | |
| 1777 | // inverse transform column vectors |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1778 | for (i = 0; i < n; ++i) IHT_16x32[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1779 | |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1780 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1781 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n); |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1782 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1783 | |
| 1784 | // Sum with the destination |
| 1785 | for (i = 0; i < n2; ++i) { |
| 1786 | for (j = 0; j < n; ++j) { |
| 1787 | int d = i * stride + j; |
| 1788 | int s = j * outstride + i; |
Monty Montgomery | ad39685 | 2017-10-20 03:35:26 -0400 | [diff] [blame] | 1789 | #if CONFIG_DAALA_TX16 && CONFIG_DAALA_TX32 |
| 1790 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
| 1791 | #else |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1792 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6)); |
Monty Montgomery | ad39685 | 2017-10-20 03:35:26 -0400 | [diff] [blame] | 1793 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1794 | } |
| 1795 | } |
| 1796 | } |
| 1797 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1798 | void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 1799 | const TxfmParam *txfm_param) { |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 1800 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sarah Parker | 53f93db | 2017-07-11 17:20:04 -0700 | [diff] [blame] | 1801 | #if CONFIG_MRC_TX |
| 1802 | assert(tx_type != MRC_DCT && "Invalid tx type for tx size"); |
| 1803 | #endif // CONFIG_MRC_TX |
Monty Montgomery | cb55dad | 2017-07-11 16:59:52 -0400 | [diff] [blame] | 1804 | #if CONFIG_DCT_ONLY |
| 1805 | assert(tx_type == DCT_DCT); |
| 1806 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1807 | static const transform_2d IHT_32x16[] = { |
Monty Montgomery | ad39685 | 2017-10-20 03:35:26 -0400 | [diff] [blame] | 1808 | #if CONFIG_DAALA_TX16 && CONFIG_DAALA_TX32 |
| 1809 | { daala_idct16, daala_idct32 }, // DCT_DCT = 0 |
| 1810 | { daala_idst16, daala_idct32 }, // ADST_DCT = 1 |
| 1811 | { daala_idct16, daala_idst32 }, // DCT_ADST = 2 |
| 1812 | { daala_idst16, daala_idst32 }, // ADST_ADST = 3 |
| 1813 | #if CONFIG_EXT_TX |
| 1814 | { daala_idst16, daala_idct32 }, // FLIPADST_DCT |
| 1815 | { daala_idct16, daala_idst32 }, // DCT_FLIPADST |
| 1816 | { daala_idst16, daala_idst32 }, // FLIPADST_FLIPADST |
| 1817 | { daala_idst16, daala_idst32 }, // ADST_FLIPADST |
| 1818 | { daala_idst16, daala_idst32 }, // FLIPADST_ADST |
| 1819 | { daala_idtx16, daala_idtx32 }, // IDTX |
| 1820 | { daala_idct16, daala_idtx32 }, // V_DCT |
| 1821 | { daala_idtx16, daala_idct32 }, // H_DCT |
| 1822 | { daala_idst16, daala_idtx32 }, // V_ADST |
| 1823 | { daala_idtx16, daala_idst32 }, // H_ADST |
| 1824 | { daala_idst16, daala_idtx32 }, // V_FLIPADST |
| 1825 | { daala_idtx16, daala_idst32 }, // H_FLIPADST |
| 1826 | #endif |
| 1827 | #else |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 1828 | { aom_idct16_c, aom_idct32_c }, // DCT_DCT |
| 1829 | { aom_iadst16_c, aom_idct32_c }, // ADST_DCT |
| 1830 | { aom_idct16_c, ihalfright32_c }, // DCT_ADST |
| 1831 | { aom_iadst16_c, ihalfright32_c }, // ADST_ADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1832 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 1833 | { aom_iadst16_c, aom_idct32_c }, // FLIPADST_DCT |
| 1834 | { aom_idct16_c, ihalfright32_c }, // DCT_FLIPADST |
| 1835 | { aom_iadst16_c, ihalfright32_c }, // FLIPADST_FLIPADST |
| 1836 | { aom_iadst16_c, ihalfright32_c }, // ADST_FLIPADST |
| 1837 | { aom_iadst16_c, ihalfright32_c }, // FLIPADST_ADST |
| 1838 | { iidtx16_c, iidtx32_c }, // IDTX |
| 1839 | { aom_idct16_c, iidtx32_c }, // V_DCT |
| 1840 | { iidtx16_c, aom_idct32_c }, // H_DCT |
| 1841 | { aom_iadst16_c, iidtx32_c }, // V_ADST |
| 1842 | { iidtx16_c, ihalfright32_c }, // H_ADST |
| 1843 | { aom_iadst16_c, iidtx32_c }, // V_FLIPADST |
| 1844 | { iidtx16_c, ihalfright32_c }, // H_FLIPADST |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1845 | #endif |
Monty Montgomery | ad39685 | 2017-10-20 03:35:26 -0400 | [diff] [blame] | 1846 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1847 | }; |
| 1848 | const int n = 16; |
| 1849 | const int n2 = 32; |
| 1850 | |
| 1851 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1852 | tran_low_t out[32][16], tmp[32][16], outtmp[32]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1853 | tran_low_t *outp = &out[0][0]; |
| 1854 | int outstride = n; |
| 1855 | |
| 1856 | // inverse transform row vectors and transpose |
| 1857 | for (i = 0; i < n; ++i) { |
Monty Montgomery | ad39685 | 2017-10-20 03:35:26 -0400 | [diff] [blame] | 1858 | #if CONFIG_DAALA_TX16 && CONFIG_DAALA_TX32 |
| 1859 | tran_low_t temp_in[32]; |
| 1860 | for (j = 0; j < n2; j++) temp_in[j] = input[j] * 2; |
| 1861 | IHT_32x16[tx_type].rows(temp_in, outtmp); |
| 1862 | for (j = 0; j < n2; ++j) tmp[j][i] = outtmp[j] * 4; |
| 1863 | #else |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1864 | IHT_32x16[tx_type].rows(input, outtmp); |
| 1865 | for (j = 0; j < n2; ++j) |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1866 | tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2); |
Monty Montgomery | ad39685 | 2017-10-20 03:35:26 -0400 | [diff] [blame] | 1867 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1868 | input += n2; |
| 1869 | } |
| 1870 | |
| 1871 | // inverse transform column vectors |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1872 | for (i = 0; i < n2; ++i) IHT_32x16[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1873 | |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1874 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1875 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2); |
Jingning Han | ec419e0 | 2016-11-01 18:19:30 -0700 | [diff] [blame] | 1876 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1877 | |
| 1878 | // Sum with the destination |
| 1879 | for (i = 0; i < n; ++i) { |
| 1880 | for (j = 0; j < n2; ++j) { |
| 1881 | int d = i * stride + j; |
| 1882 | int s = j * outstride + i; |
Monty Montgomery | ad39685 | 2017-10-20 03:35:26 -0400 | [diff] [blame] | 1883 | #if CONFIG_DAALA_TX16 && CONFIG_DAALA_TX32 |
| 1884 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
| 1885 | #else |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1886 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6)); |
Monty Montgomery | ad39685 | 2017-10-20 03:35:26 -0400 | [diff] [blame] | 1887 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1888 | } |
| 1889 | } |
| 1890 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1891 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 1892 | void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 1893 | const TxfmParam *txfm_param) { |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 1894 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sarah Parker | 53f93db | 2017-07-11 17:20:04 -0700 | [diff] [blame] | 1895 | #if CONFIG_MRC_TX |
| 1896 | assert(tx_type != MRC_DCT && "Invalid tx type for tx size"); |
| 1897 | #endif // CONFIG_MRC_TX |
Monty Montgomery | cb55dad | 2017-07-11 16:59:52 -0400 | [diff] [blame] | 1898 | #if CONFIG_DCT_ONLY |
| 1899 | assert(tx_type == DCT_DCT); |
| 1900 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1901 | static const transform_2d IHT_8[] = { |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 1902 | #if CONFIG_DAALA_TX8 |
Nathan E. Egge | 8a873db | 2017-09-16 20:55:20 -0400 | [diff] [blame] | 1903 | { daala_idct8, daala_idct8 }, // DCT_DCT = 0 |
| 1904 | { daala_idst8, daala_idct8 }, // ADST_DCT = 1 |
| 1905 | { daala_idct8, daala_idst8 }, // DCT_ADST = 2 |
| 1906 | { daala_idst8, daala_idst8 }, // ADST_ADST = 3 |
Nathan E. Egge | 75bfeb8 | 2017-09-16 20:41:24 -0400 | [diff] [blame] | 1907 | #if CONFIG_EXT_TX |
Nathan E. Egge | 8a873db | 2017-09-16 20:55:20 -0400 | [diff] [blame] | 1908 | { daala_idst8, daala_idct8 }, // FLIPADST_DCT |
| 1909 | { daala_idct8, daala_idst8 }, // DCT_FLIPADST |
| 1910 | { daala_idst8, daala_idst8 }, // FLIPADST_FLIPADST |
| 1911 | { daala_idst8, daala_idst8 }, // ADST_FLIPADST |
| 1912 | { daala_idst8, daala_idst8 }, // FLIPADST_ADST |
Nathan E. Egge | 3f45fb3 | 2017-09-18 11:34:48 -0400 | [diff] [blame] | 1913 | { daala_idtx8, daala_idtx8 }, // IDTX |
| 1914 | { daala_idct8, daala_idtx8 }, // V_DCT |
| 1915 | { daala_idtx8, daala_idct8 }, // H_DCT |
| 1916 | { daala_idst8, daala_idtx8 }, // V_ADST |
| 1917 | { daala_idtx8, daala_idst8 }, // H_ADST |
| 1918 | { daala_idst8, daala_idtx8 }, // V_FLIPADST |
| 1919 | { daala_idtx8, daala_idst8 }, // H_FLIPADST |
Nathan E. Egge | 75bfeb8 | 2017-09-16 20:41:24 -0400 | [diff] [blame] | 1920 | #endif |
| 1921 | #else |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 1922 | { aom_idct8_c, aom_idct8_c }, // DCT_DCT = 0 |
| 1923 | { aom_iadst8_c, aom_idct8_c }, // ADST_DCT = 1 |
| 1924 | { aom_idct8_c, aom_iadst8_c }, // DCT_ADST = 2 |
| 1925 | { aom_iadst8_c, aom_iadst8_c }, // ADST_ADST = 3 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1926 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 1927 | { aom_iadst8_c, aom_idct8_c }, // FLIPADST_DCT |
| 1928 | { aom_idct8_c, aom_iadst8_c }, // DCT_FLIPADST |
| 1929 | { aom_iadst8_c, aom_iadst8_c }, // FLIPADST_FLIPADST |
| 1930 | { aom_iadst8_c, aom_iadst8_c }, // ADST_FLIPADST |
| 1931 | { aom_iadst8_c, aom_iadst8_c }, // FLIPADST_ADST |
| 1932 | { iidtx8_c, iidtx8_c }, // IDTX |
| 1933 | { aom_idct8_c, iidtx8_c }, // V_DCT |
| 1934 | { iidtx8_c, aom_idct8_c }, // H_DCT |
| 1935 | { aom_iadst8_c, iidtx8_c }, // V_ADST |
| 1936 | { iidtx8_c, aom_iadst8_c }, // H_ADST |
| 1937 | { aom_iadst8_c, iidtx8_c }, // V_FLIPADST |
| 1938 | { iidtx8_c, aom_iadst8_c }, // H_FLIPADST |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1939 | #endif |
Nathan E. Egge | 75bfeb8 | 2017-09-16 20:41:24 -0400 | [diff] [blame] | 1940 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1941 | }; |
| 1942 | |
| 1943 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1944 | tran_low_t tmp[8][8]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1945 | tran_low_t out[8][8]; |
| 1946 | tran_low_t *outp = &out[0][0]; |
| 1947 | int outstride = 8; |
| 1948 | |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1949 | #if CONFIG_LGT |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1950 | const tran_high_t *lgtmtx_col[1]; |
| 1951 | const tran_high_t *lgtmtx_row[1]; |
| 1952 | int use_lgt_col = get_lgt8(txfm_param, 1, lgtmtx_col); |
| 1953 | int use_lgt_row = get_lgt8(txfm_param, 0, lgtmtx_row); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1954 | #endif |
| 1955 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1956 | // inverse transform row vectors |
| 1957 | for (i = 0; i < 8; ++i) { |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 1958 | #if CONFIG_DAALA_TX8 |
Monty Montgomery | cf18fe4 | 2017-07-11 21:33:25 -0400 | [diff] [blame] | 1959 | tran_low_t temp_in[8]; |
| 1960 | for (j = 0; j < 8; j++) temp_in[j] = input[j] * 2; |
| 1961 | IHT_8[tx_type].rows(temp_in, out[i]); |
| 1962 | #else |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1963 | #if CONFIG_LGT |
| 1964 | if (use_lgt_row) |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1965 | ilgt8(input, out[i], lgtmtx_row[0]); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1966 | else |
| 1967 | #endif |
| 1968 | IHT_8[tx_type].rows(input, out[i]); |
Monty Montgomery | cf18fe4 | 2017-07-11 21:33:25 -0400 | [diff] [blame] | 1969 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1970 | input += 8; |
| 1971 | } |
| 1972 | |
| 1973 | // transpose |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 1974 | for (i = 0; i < 8; i++) { |
| 1975 | for (j = 0; j < 8; j++) { |
| 1976 | tmp[j][i] = out[i][j]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1977 | } |
| 1978 | } |
| 1979 | |
| 1980 | // inverse transform column vectors |
| 1981 | for (i = 0; i < 8; ++i) { |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1982 | #if CONFIG_LGT |
| 1983 | if (use_lgt_col) |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 1984 | ilgt8(tmp[i], out[i], lgtmtx_col[0]); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 1985 | else |
| 1986 | #endif |
| 1987 | IHT_8[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1988 | } |
| 1989 | |
| 1990 | #if CONFIG_EXT_TX |
| 1991 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 8, 8); |
| 1992 | #endif |
| 1993 | |
| 1994 | // Sum with the destination |
| 1995 | for (i = 0; i < 8; ++i) { |
| 1996 | for (j = 0; j < 8; ++j) { |
| 1997 | int d = i * stride + j; |
| 1998 | int s = j * outstride + i; |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 1999 | #if CONFIG_DAALA_TX8 |
Monty Montgomery | cf18fe4 | 2017-07-11 21:33:25 -0400 | [diff] [blame] | 2000 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 4)); |
| 2001 | #else |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2002 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
Monty Montgomery | cf18fe4 | 2017-07-11 21:33:25 -0400 | [diff] [blame] | 2003 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2004 | } |
| 2005 | } |
| 2006 | } |
| 2007 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2008 | void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2009 | const TxfmParam *txfm_param) { |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 2010 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sarah Parker | 53f93db | 2017-07-11 17:20:04 -0700 | [diff] [blame] | 2011 | #if CONFIG_MRC_TX |
| 2012 | assert(tx_type != MRC_DCT && "Invalid tx type for tx size"); |
| 2013 | #endif // CONFIG_MRC_TX |
Monty Montgomery | cb55dad | 2017-07-11 16:59:52 -0400 | [diff] [blame] | 2014 | #if CONFIG_DCT_ONLY |
| 2015 | assert(tx_type == DCT_DCT); |
| 2016 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2017 | static const transform_2d IHT_16[] = { |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2018 | #if CONFIG_DAALA_TX16 |
Nathan E. Egge | cbcff06 | 2017-09-16 22:32:19 -0400 | [diff] [blame] | 2019 | { daala_idct16, daala_idct16 }, // DCT_DCT = 0 |
| 2020 | { daala_idst16, daala_idct16 }, // ADST_DCT = 1 |
| 2021 | { daala_idct16, daala_idst16 }, // DCT_ADST = 2 |
| 2022 | { daala_idst16, daala_idst16 }, // ADST_ADST = 3 |
Nathan E. Egge | c5c1e56 | 2017-09-16 22:18:18 -0400 | [diff] [blame] | 2023 | #if CONFIG_EXT_TX |
Nathan E. Egge | cbcff06 | 2017-09-16 22:32:19 -0400 | [diff] [blame] | 2024 | { daala_idst16, daala_idct16 }, // FLIPADST_DCT |
| 2025 | { daala_idct16, daala_idst16 }, // DCT_FLIPADST |
| 2026 | { daala_idst16, daala_idst16 }, // FLIPADST_FLIPADST |
| 2027 | { daala_idst16, daala_idst16 }, // ADST_FLIPADST |
| 2028 | { daala_idst16, daala_idst16 }, // FLIPADST_ADST |
Nathan E. Egge | 74e7fd0 | 2017-09-18 11:40:31 -0400 | [diff] [blame] | 2029 | { daala_idtx16, daala_idtx16 }, // IDTX |
| 2030 | { daala_idct16, daala_idtx16 }, // V_DCT |
| 2031 | { daala_idtx16, daala_idct16 }, // H_DCT |
| 2032 | { daala_idst16, daala_idtx16 }, // V_ADST |
| 2033 | { daala_idtx16, daala_idst16 }, // H_ADST |
| 2034 | { daala_idst16, daala_idtx16 }, // V_FLIPADST |
| 2035 | { daala_idtx16, daala_idst16 }, // H_FLIPADST |
Nathan E. Egge | c5c1e56 | 2017-09-16 22:18:18 -0400 | [diff] [blame] | 2036 | #endif |
| 2037 | #else |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 2038 | { aom_idct16_c, aom_idct16_c }, // DCT_DCT = 0 |
| 2039 | { aom_iadst16_c, aom_idct16_c }, // ADST_DCT = 1 |
| 2040 | { aom_idct16_c, aom_iadst16_c }, // DCT_ADST = 2 |
| 2041 | { aom_iadst16_c, aom_iadst16_c }, // ADST_ADST = 3 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2042 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 2043 | { aom_iadst16_c, aom_idct16_c }, // FLIPADST_DCT |
| 2044 | { aom_idct16_c, aom_iadst16_c }, // DCT_FLIPADST |
| 2045 | { aom_iadst16_c, aom_iadst16_c }, // FLIPADST_FLIPADST |
| 2046 | { aom_iadst16_c, aom_iadst16_c }, // ADST_FLIPADST |
| 2047 | { aom_iadst16_c, aom_iadst16_c }, // FLIPADST_ADST |
| 2048 | { iidtx16_c, iidtx16_c }, // IDTX |
| 2049 | { aom_idct16_c, iidtx16_c }, // V_DCT |
| 2050 | { iidtx16_c, aom_idct16_c }, // H_DCT |
| 2051 | { aom_iadst16_c, iidtx16_c }, // V_ADST |
| 2052 | { iidtx16_c, aom_iadst16_c }, // H_ADST |
| 2053 | { aom_iadst16_c, iidtx16_c }, // V_FLIPADST |
| 2054 | { iidtx16_c, aom_iadst16_c }, // H_FLIPADST |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 2055 | #endif |
Nathan E. Egge | c5c1e56 | 2017-09-16 22:18:18 -0400 | [diff] [blame] | 2056 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2057 | }; |
| 2058 | |
| 2059 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 2060 | tran_low_t tmp[16][16]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2061 | tran_low_t out[16][16]; |
| 2062 | tran_low_t *outp = &out[0][0]; |
| 2063 | int outstride = 16; |
| 2064 | |
| 2065 | // inverse transform row vectors |
| 2066 | for (i = 0; i < 16; ++i) { |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2067 | #if CONFIG_DAALA_TX16 |
Monty Montgomery | cb9c1c5 | 2017-07-17 18:15:30 -0400 | [diff] [blame] | 2068 | tran_low_t temp_in[16]; |
Sebastien Alaiwan | 7732326 | 2017-08-21 11:34:56 +0200 | [diff] [blame] | 2069 | for (j = 0; j < 16; j++) temp_in[j] = input[j] * 2; |
Monty Montgomery | cb9c1c5 | 2017-07-17 18:15:30 -0400 | [diff] [blame] | 2070 | IHT_16[tx_type].rows(temp_in, out[i]); |
| 2071 | #else |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2072 | IHT_16[tx_type].rows(input, out[i]); |
Monty Montgomery | cb9c1c5 | 2017-07-17 18:15:30 -0400 | [diff] [blame] | 2073 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2074 | input += 16; |
| 2075 | } |
| 2076 | |
| 2077 | // transpose |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 2078 | for (i = 0; i < 16; i++) { |
| 2079 | for (j = 0; j < 16; j++) { |
| 2080 | tmp[j][i] = out[i][j]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2081 | } |
| 2082 | } |
| 2083 | |
| 2084 | // inverse transform column vectors |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 2085 | for (i = 0; i < 16; ++i) IHT_16[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2086 | |
| 2087 | #if CONFIG_EXT_TX |
| 2088 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 16, 16); |
| 2089 | #endif |
| 2090 | |
| 2091 | // Sum with the destination |
| 2092 | for (i = 0; i < 16; ++i) { |
| 2093 | for (j = 0; j < 16; ++j) { |
| 2094 | int d = i * stride + j; |
| 2095 | int s = j * outstride + i; |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2096 | #if CONFIG_DAALA_TX16 |
Monty Montgomery | cb9c1c5 | 2017-07-17 18:15:30 -0400 | [diff] [blame] | 2097 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 4)); |
| 2098 | #else |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2099 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6)); |
Monty Montgomery | cb9c1c5 | 2017-07-17 18:15:30 -0400 | [diff] [blame] | 2100 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2101 | } |
| 2102 | } |
| 2103 | } |
| 2104 | |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2105 | #if CONFIG_EXT_TX || CONFIG_DAALA_TX32 |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2106 | void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2107 | const TxfmParam *txfm_param) { |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 2108 | const TX_TYPE tx_type = txfm_param->tx_type; |
Monty Montgomery | cb55dad | 2017-07-11 16:59:52 -0400 | [diff] [blame] | 2109 | #if CONFIG_DCT_ONLY |
| 2110 | assert(tx_type == DCT_DCT); |
| 2111 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2112 | static const transform_2d IHT_32[] = { |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2113 | #if CONFIG_DAALA_TX32 |
Nathan E. Egge | dfd1a92 | 2017-09-16 23:35:30 -0400 | [diff] [blame] | 2114 | { daala_idct32, daala_idct32 }, // DCT_DCT |
| 2115 | #if CONFIG_EXT_TX |
Nathan E. Egge | f6d3ba6 | 2017-09-18 15:40:08 -0400 | [diff] [blame] | 2116 | { daala_idst32, daala_idct32 }, // ADST_DCT |
| 2117 | { daala_idct32, daala_idst32 }, // DCT_ADST |
| 2118 | { daala_idst32, daala_idst32 }, // ADST_ADST |
| 2119 | { daala_idst32, daala_idct32 }, // FLIPADST_DCT |
| 2120 | { daala_idct32, daala_idst32 }, // DCT_FLIPADST |
| 2121 | { daala_idst32, daala_idst32 }, // FLIPADST_FLIPADST |
| 2122 | { daala_idst32, daala_idst32 }, // ADST_FLIPADST |
| 2123 | { daala_idst32, daala_idst32 }, // FLIPADST_ADST |
| 2124 | { daala_idtx32, daala_idtx32 }, // IDTX |
| 2125 | { daala_idct32, daala_idtx32 }, // V_DCT |
| 2126 | { daala_idtx32, daala_idct32 }, // H_DCT |
| 2127 | { daala_idst32, daala_idtx32 }, // V_ADST |
| 2128 | { daala_idtx32, daala_idst32 }, // H_ADST |
| 2129 | { daala_idst32, daala_idtx32 }, // V_FLIPADST |
| 2130 | { daala_idtx32, daala_idst32 }, // H_FLIPADST |
Nathan E. Egge | dfd1a92 | 2017-09-16 23:35:30 -0400 | [diff] [blame] | 2131 | #endif |
| 2132 | #else |
| 2133 | { aom_idct32_c, aom_idct32_c }, // DCT_DCT |
Monty Montgomery | 2cb52ba | 2017-07-17 18:27:27 -0400 | [diff] [blame] | 2134 | #if CONFIG_EXT_TX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 2135 | { ihalfright32_c, aom_idct32_c }, // ADST_DCT |
| 2136 | { aom_idct32_c, ihalfright32_c }, // DCT_ADST |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2137 | { ihalfright32_c, ihalfright32_c }, // ADST_ADST |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 2138 | { ihalfright32_c, aom_idct32_c }, // FLIPADST_DCT |
| 2139 | { aom_idct32_c, ihalfright32_c }, // DCT_FLIPADST |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2140 | { ihalfright32_c, ihalfright32_c }, // FLIPADST_FLIPADST |
| 2141 | { ihalfright32_c, ihalfright32_c }, // ADST_FLIPADST |
| 2142 | { ihalfright32_c, ihalfright32_c }, // FLIPADST_ADST |
| 2143 | { iidtx32_c, iidtx32_c }, // IDTX |
Luca Barbato | f0f9857 | 2016-09-03 12:14:15 +0200 | [diff] [blame] | 2144 | { aom_idct32_c, iidtx32_c }, // V_DCT |
| 2145 | { iidtx32_c, aom_idct32_c }, // H_DCT |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 2146 | { ihalfright32_c, iidtx32_c }, // V_ADST |
| 2147 | { iidtx32_c, ihalfright32_c }, // H_ADST |
| 2148 | { ihalfright32_c, iidtx32_c }, // V_FLIPADST |
| 2149 | { iidtx32_c, ihalfright32_c }, // H_FLIPADST |
Monty Montgomery | 2cb52ba | 2017-07-17 18:27:27 -0400 | [diff] [blame] | 2150 | #endif |
Nathan E. Egge | dfd1a92 | 2017-09-16 23:35:30 -0400 | [diff] [blame] | 2151 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2152 | }; |
| 2153 | |
| 2154 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 2155 | tran_low_t tmp[32][32]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2156 | tran_low_t out[32][32]; |
| 2157 | tran_low_t *outp = &out[0][0]; |
| 2158 | int outstride = 32; |
| 2159 | |
| 2160 | // inverse transform row vectors |
| 2161 | for (i = 0; i < 32; ++i) { |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2162 | #if CONFIG_DAALA_TX32 |
Monty Montgomery | 2cb52ba | 2017-07-17 18:27:27 -0400 | [diff] [blame] | 2163 | tran_low_t temp_in[32]; |
| 2164 | for (j = 0; j < 32; j++) temp_in[j] = input[j] * 2; |
| 2165 | IHT_32[tx_type].rows(temp_in, out[i]); |
| 2166 | #else |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2167 | IHT_32[tx_type].rows(input, out[i]); |
Monty Montgomery | 2cb52ba | 2017-07-17 18:27:27 -0400 | [diff] [blame] | 2168 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2169 | input += 32; |
| 2170 | } |
| 2171 | |
| 2172 | // transpose |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 2173 | for (i = 0; i < 32; i++) { |
| 2174 | for (j = 0; j < 32; j++) { |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2175 | #if CONFIG_DAALA_TX32 |
Monty Montgomery | 2cb52ba | 2017-07-17 18:27:27 -0400 | [diff] [blame] | 2176 | tmp[j][i] = out[i][j] * 4; |
| 2177 | #else |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 2178 | tmp[j][i] = out[i][j]; |
Monty Montgomery | 2cb52ba | 2017-07-17 18:27:27 -0400 | [diff] [blame] | 2179 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2180 | } |
| 2181 | } |
| 2182 | |
| 2183 | // inverse transform column vectors |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 2184 | for (i = 0; i < 32; ++i) IHT_32[tx_type].cols(tmp[i], out[i]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2185 | |
| 2186 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 32, 32); |
| 2187 | |
| 2188 | // Sum with the destination |
| 2189 | for (i = 0; i < 32; ++i) { |
| 2190 | for (j = 0; j < 32; ++j) { |
| 2191 | int d = i * stride + j; |
| 2192 | int s = j * outstride + i; |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2193 | #if CONFIG_DAALA_TX32 |
Monty Montgomery | 2cb52ba | 2017-07-17 18:27:27 -0400 | [diff] [blame] | 2194 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
| 2195 | #else |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2196 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6)); |
Monty Montgomery | 2cb52ba | 2017-07-17 18:27:27 -0400 | [diff] [blame] | 2197 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2198 | } |
| 2199 | } |
| 2200 | } |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2201 | #endif // CONFIG_EXT_TX || CONFIG_DAALA_TX32 |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 2202 | |
| 2203 | #if CONFIG_TX64X64 |
| 2204 | void av1_iht64x64_4096_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2205 | const TxfmParam *txfm_param) { |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 2206 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sarah Parker | 53f93db | 2017-07-11 17:20:04 -0700 | [diff] [blame] | 2207 | #if CONFIG_MRC_TX |
| 2208 | assert(tx_type != MRC_DCT && "Invalid tx type for tx size"); |
| 2209 | #endif // CONFIG_MRC_TX |
Monty Montgomery | cb55dad | 2017-07-11 16:59:52 -0400 | [diff] [blame] | 2210 | #if CONFIG_DCT_ONLY |
| 2211 | assert(tx_type == DCT_DCT); |
| 2212 | #endif |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 2213 | static const transform_2d IHT_64[] = { |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2214 | #if CONFIG_DAALA_TX64 |
Nathan E. Egge | 2496a85 | 2017-09-18 15:59:54 -0400 | [diff] [blame] | 2215 | { daala_idct64, daala_idct64 }, // DCT_DCT |
| 2216 | { daala_idst64, daala_idct64 }, // ADST_DCT |
| 2217 | { daala_idct64, daala_idst64 }, // DCT_ADST |
| 2218 | { daala_idst64, daala_idst64 }, // ADST_ADST |
Nathan E. Egge | d866114 | 2017-09-16 23:57:51 -0400 | [diff] [blame] | 2219 | #if CONFIG_EXT_TX |
Nathan E. Egge | 2496a85 | 2017-09-18 15:59:54 -0400 | [diff] [blame] | 2220 | { daala_idst64, daala_idct64 }, // FLIPADST_DCT |
| 2221 | { daala_idct64, daala_idst64 }, // DCT_FLIPADST |
| 2222 | { daala_idst64, daala_idst64 }, // FLIPADST_FLIPADST |
| 2223 | { daala_idst64, daala_idst64 }, // ADST_FLIPADST |
| 2224 | { daala_idst64, daala_idst64 }, // FLIPADST_ADST |
| 2225 | { daala_idtx64, daala_idtx64 }, // IDTX |
| 2226 | { daala_idct64, daala_idtx64 }, // V_DCT |
| 2227 | { daala_idtx64, daala_idct64 }, // H_DCT |
| 2228 | { daala_idst64, daala_idtx64 }, // V_ADST |
| 2229 | { daala_idtx64, daala_idst64 }, // H_ADST |
| 2230 | { daala_idst64, daala_idtx64 }, // V_FLIPADST |
| 2231 | { daala_idtx64, daala_idst64 }, // H_FLIPADST |
Nathan E. Egge | d866114 | 2017-09-16 23:57:51 -0400 | [diff] [blame] | 2232 | #endif |
| 2233 | #else |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 2234 | { idct64_col_c, idct64_row_c }, // DCT_DCT |
| 2235 | { ihalfright64_c, idct64_row_c }, // ADST_DCT |
| 2236 | { idct64_col_c, ihalfright64_c }, // DCT_ADST |
| 2237 | { ihalfright64_c, ihalfright64_c }, // ADST_ADST |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 2238 | #if CONFIG_EXT_TX |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 2239 | { ihalfright64_c, idct64_row_c }, // FLIPADST_DCT |
| 2240 | { idct64_col_c, ihalfright64_c }, // DCT_FLIPADST |
| 2241 | { ihalfright64_c, ihalfright64_c }, // FLIPADST_FLIPADST |
| 2242 | { ihalfright64_c, ihalfright64_c }, // ADST_FLIPADST |
| 2243 | { ihalfright64_c, ihalfright64_c }, // FLIPADST_ADST |
| 2244 | { iidtx64_c, iidtx64_c }, // IDTX |
| 2245 | { idct64_col_c, iidtx64_c }, // V_DCT |
| 2246 | { iidtx64_c, idct64_row_c }, // H_DCT |
| 2247 | { ihalfright64_c, iidtx64_c }, // V_ADST |
| 2248 | { iidtx64_c, ihalfright64_c }, // H_ADST |
| 2249 | { ihalfright64_c, iidtx64_c }, // V_FLIPADST |
| 2250 | { iidtx64_c, ihalfright64_c }, // H_FLIPADST |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 2251 | #endif |
Nathan E. Egge | d866114 | 2017-09-16 23:57:51 -0400 | [diff] [blame] | 2252 | #endif |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 2253 | }; |
| 2254 | |
| 2255 | int i, j; |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 2256 | tran_low_t tmp[64][64]; |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 2257 | tran_low_t out[64][64]; |
| 2258 | tran_low_t *outp = &out[0][0]; |
| 2259 | int outstride = 64; |
| 2260 | |
| 2261 | // inverse transform row vectors |
| 2262 | for (i = 0; i < 64; ++i) { |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2263 | #if CONFIG_DAALA_TX64 |
Monty Montgomery | a4e245a | 2017-07-22 00:48:31 -0400 | [diff] [blame] | 2264 | tran_low_t temp_in[64]; |
| 2265 | for (j = 0; j < 64; j++) temp_in[j] = input[j] * 2; |
| 2266 | IHT_64[tx_type].rows(temp_in, out[i]); |
| 2267 | // Do not rescale intermediate for Daala |
| 2268 | #else |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 2269 | IHT_64[tx_type].rows(input, out[i]); |
| 2270 | for (j = 0; j < 64; ++j) out[i][j] = ROUND_POWER_OF_TWO(out[i][j], 1); |
Monty Montgomery | a4e245a | 2017-07-22 00:48:31 -0400 | [diff] [blame] | 2271 | #endif |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 2272 | input += 64; |
| 2273 | } |
| 2274 | |
| 2275 | // transpose |
Jonathan Matthews | 362d0c7 | 2017-05-09 14:53:11 +0100 | [diff] [blame] | 2276 | for (i = 0; i < 64; i++) { |
| 2277 | for (j = 0; j < 64; j++) { |
| 2278 | tmp[j][i] = out[i][j]; |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 2279 | } |
| 2280 | } |
| 2281 | |
| 2282 | // inverse transform column vectors |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 2283 | for (i = 0; i < 64; ++i) IHT_64[tx_type].cols(tmp[i], out[i]); |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 2284 | |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 2285 | #if CONFIG_EXT_TX |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 2286 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 64, 64); |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 2287 | #endif // CONFIG_EXT_TX |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 2288 | |
| 2289 | // Sum with the destination |
| 2290 | for (i = 0; i < 64; ++i) { |
| 2291 | for (j = 0; j < 64; ++j) { |
| 2292 | int d = i * stride + j; |
| 2293 | int s = j * outstride + i; |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2294 | #if CONFIG_DAALA_TX64 |
Monty Montgomery | a4e245a | 2017-07-22 00:48:31 -0400 | [diff] [blame] | 2295 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 2)); |
| 2296 | #else |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 2297 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
Monty Montgomery | a4e245a | 2017-07-22 00:48:31 -0400 | [diff] [blame] | 2298 | #endif |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 2299 | } |
| 2300 | } |
| 2301 | } |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 2302 | |
| 2303 | void av1_iht64x32_2048_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 2304 | const TxfmParam *txfm_param) { |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 2305 | const TX_TYPE tx_type = txfm_param->tx_type; |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 2306 | #if CONFIG_MRC_TX |
| 2307 | assert(tx_type != MRC_DCT && "Invalid tx type for tx size"); |
| 2308 | #endif // CONFIG_MRC_TX |
| 2309 | #if CONFIG_DCT_ONLY |
| 2310 | assert(tx_type == DCT_DCT); |
| 2311 | #endif |
| 2312 | static const transform_2d IHT_64x32[] = { |
| 2313 | { aom_idct32_c, idct64_row_c }, // DCT_DCT |
| 2314 | { ihalfright32_c, idct64_row_c }, // ADST_DCT |
| 2315 | { aom_idct32_c, ihalfright64_c }, // DCT_ADST |
| 2316 | { ihalfright32_c, ihalfright64_c }, // ADST_ADST |
| 2317 | #if CONFIG_EXT_TX |
| 2318 | { ihalfright32_c, idct64_row_c }, // FLIPADST_DCT |
| 2319 | { aom_idct32_c, ihalfright64_c }, // DCT_FLIPADST |
| 2320 | { ihalfright32_c, ihalfright64_c }, // FLIPADST_FLIPADST |
| 2321 | { ihalfright32_c, ihalfright64_c }, // ADST_FLIPADST |
| 2322 | { ihalfright32_c, ihalfright64_c }, // FLIPADST_ADST |
| 2323 | { iidtx32_c, iidtx64_c }, // IDTX |
| 2324 | { aom_idct32_c, iidtx64_c }, // V_DCT |
| 2325 | { iidtx32_c, idct64_row_c }, // H_DCT |
| 2326 | { ihalfright32_c, iidtx64_c }, // V_ADST |
| 2327 | { iidtx32_c, ihalfright64_c }, // H_ADST |
| 2328 | { ihalfright32_c, iidtx64_c }, // V_FLIPADST |
| 2329 | { iidtx32_c, ihalfright64_c }, // H_FLIPADST |
| 2330 | #endif |
| 2331 | }; |
| 2332 | const int n = 32; |
| 2333 | const int n2 = 64; |
| 2334 | |
| 2335 | int i, j; |
| 2336 | tran_low_t out[64][32], tmp[64][32], outtmp[64]; |
| 2337 | tran_low_t *outp = &out[0][0]; |
| 2338 | int outstride = n; |
| 2339 | |
| 2340 | // inverse transform row vectors and transpose |
| 2341 | for (i = 0; i < n; ++i) { |
| 2342 | IHT_64x32[tx_type].rows(input, outtmp); |
| 2343 | for (j = 0; j < n2; ++j) |
Debargha Mukherjee | 570423c | 2017-10-01 00:35:20 -0700 | [diff] [blame] | 2344 | tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * InvSqrt2); |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 2345 | input += n2; |
| 2346 | } |
| 2347 | |
| 2348 | // inverse transform column vectors |
| 2349 | for (i = 0; i < n2; ++i) IHT_64x32[tx_type].cols(tmp[i], out[i]); |
| 2350 | |
| 2351 | #if CONFIG_EXT_TX |
| 2352 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2); |
| 2353 | #endif |
| 2354 | |
| 2355 | // Sum with the destination |
| 2356 | for (i = 0; i < n; ++i) { |
| 2357 | for (j = 0; j < n2; ++j) { |
| 2358 | int d = i * stride + j; |
| 2359 | int s = j * outstride + i; |
| 2360 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
| 2361 | } |
| 2362 | } |
| 2363 | } |
| 2364 | |
| 2365 | void av1_iht32x64_2048_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 2366 | const TxfmParam *txfm_param) { |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 2367 | const TX_TYPE tx_type = txfm_param->tx_type; |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 2368 | #if CONFIG_MRC_TX |
| 2369 | assert(tx_type != MRC_DCT && "Invalid tx type for tx size"); |
| 2370 | #endif // CONFIG_MRC_TX |
| 2371 | #if CONFIG_DCT_ONLY |
| 2372 | assert(tx_type == DCT_DCT); |
| 2373 | #endif |
| 2374 | static const transform_2d IHT_32x64[] = { |
| 2375 | { idct64_col_c, aom_idct32_c }, // DCT_DCT |
| 2376 | { ihalfright64_c, aom_idct32_c }, // ADST_DCT |
| 2377 | { idct64_col_c, ihalfright32_c }, // DCT_ADST |
| 2378 | { ihalfright64_c, ihalfright32_c }, // ADST_ADST |
| 2379 | #if CONFIG_EXT_TX |
| 2380 | { ihalfright64_c, aom_idct32_c }, // FLIPADST_DCT |
| 2381 | { idct64_col_c, ihalfright32_c }, // DCT_FLIPADST |
| 2382 | { ihalfright64_c, ihalfright32_c }, // FLIPADST_FLIPADST |
| 2383 | { ihalfright64_c, ihalfright32_c }, // ADST_FLIPADST |
| 2384 | { ihalfright64_c, ihalfright32_c }, // FLIPADST_ADST |
| 2385 | { iidtx64_c, iidtx32_c }, // IDTX |
| 2386 | { idct64_col_c, iidtx32_c }, // V_DCT |
| 2387 | { iidtx64_c, aom_idct32_c }, // H_DCT |
| 2388 | { ihalfright64_c, iidtx32_c }, // V_ADST |
| 2389 | { iidtx64_c, ihalfright32_c }, // H_ADST |
| 2390 | { ihalfright64_c, iidtx32_c }, // V_FLIPADST |
| 2391 | { iidtx64_c, ihalfright32_c }, // H_FLIPADST |
| 2392 | #endif |
| 2393 | }; |
| 2394 | |
| 2395 | const int n = 32; |
| 2396 | const int n2 = 64; |
| 2397 | int i, j; |
| 2398 | tran_low_t out[32][64], tmp[32][64], outtmp[32]; |
| 2399 | tran_low_t *outp = &out[0][0]; |
| 2400 | int outstride = n2; |
| 2401 | |
| 2402 | // inverse transform row vectors and transpose |
| 2403 | for (i = 0; i < n2; ++i) { |
| 2404 | IHT_32x64[tx_type].rows(input, outtmp); |
| 2405 | for (j = 0; j < n; ++j) |
Debargha Mukherjee | 570423c | 2017-10-01 00:35:20 -0700 | [diff] [blame] | 2406 | tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * InvSqrt2); |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 2407 | input += n; |
| 2408 | } |
| 2409 | |
| 2410 | // inverse transform column vectors |
| 2411 | for (i = 0; i < n; ++i) IHT_32x64[tx_type].cols(tmp[i], out[i]); |
| 2412 | |
| 2413 | #if CONFIG_EXT_TX |
| 2414 | maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n); |
| 2415 | #endif |
| 2416 | |
| 2417 | // Sum with the destination |
| 2418 | for (i = 0; i < n2; ++i) { |
| 2419 | for (j = 0; j < n; ++j) { |
| 2420 | int d = i * stride + j; |
| 2421 | int s = j * outstride + i; |
| 2422 | dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5)); |
| 2423 | } |
| 2424 | } |
| 2425 | } |
| 2426 | |
Debargha Mukherjee | 67d1347 | 2016-11-01 14:37:39 -0700 | [diff] [blame] | 2427 | #endif // CONFIG_TX64X64 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2428 | |
| 2429 | // idct |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2430 | void av1_idct4x4_add(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2431 | const TxfmParam *txfm_param) { |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 2432 | #if CONFIG_EXT_TX |
| 2433 | assert(av1_ext_tx_used[txfm_param->tx_set_type][txfm_param->tx_type]); |
| 2434 | #endif // CONFIG_EXT_TX |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2435 | const int eob = txfm_param->eob; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2436 | if (eob > 1) |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2437 | av1_iht4x4_16_add(input, dest, stride, txfm_param); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2438 | else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2439 | aom_idct4x4_1_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2440 | } |
| 2441 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2442 | void av1_iwht4x4_add(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2443 | const TxfmParam *txfm_param) { |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 2444 | #if CONFIG_EXT_TX |
| 2445 | assert(av1_ext_tx_used[txfm_param->tx_set_type][txfm_param->tx_type]); |
| 2446 | #endif // CONFIG_EXT_TX |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2447 | const int eob = txfm_param->eob; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2448 | if (eob > 1) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2449 | aom_iwht4x4_16_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2450 | else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2451 | aom_iwht4x4_1_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2452 | } |
| 2453 | |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2454 | #if !CONFIG_DAALA_TX8 |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2455 | static void idct8x8_add(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2456 | const TxfmParam *txfm_param) { |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 2457 | // If dc is 1, then input[0] is the reconstructed value, do not need |
| 2458 | // 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] | 2459 | |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 2460 | // The calculation can be simplified if there are not many non-zero dct |
| 2461 | // coefficients. Use eobs to decide what to do. |
| 2462 | // TODO(yunqingwang): "eobs = 1" case is also handled in av1_short_idct8x8_c. |
| 2463 | // Combine that with code here. |
| 2464 | #if CONFIG_ADAPT_SCAN |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2465 | const int16_t half = txfm_param->eob_threshold[0]; |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 2466 | #else |
| 2467 | const int16_t half = 12; |
| 2468 | #endif |
| 2469 | |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2470 | const int eob = txfm_param->eob; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2471 | if (eob == 1) |
| 2472 | // DC only DCT coefficient |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2473 | aom_idct8x8_1_add(input, dest, stride); |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 2474 | else if (eob <= half) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2475 | aom_idct8x8_12_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2476 | else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2477 | aom_idct8x8_64_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2478 | } |
Monty Montgomery | cf18fe4 | 2017-07-11 21:33:25 -0400 | [diff] [blame] | 2479 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2480 | |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2481 | #if !CONFIG_DAALA_TX16 |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2482 | static void idct16x16_add(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2483 | const TxfmParam *txfm_param) { |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 2484 | // The calculation can be simplified if there are not many non-zero dct |
| 2485 | // coefficients. Use eobs to separate different cases. |
| 2486 | #if CONFIG_ADAPT_SCAN |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2487 | const int16_t half = txfm_param->eob_threshold[0]; |
| 2488 | const int16_t quarter = txfm_param->eob_threshold[1]; |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 2489 | #else |
| 2490 | const int16_t half = 38; |
| 2491 | const int16_t quarter = 10; |
| 2492 | #endif |
| 2493 | |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2494 | const int eob = txfm_param->eob; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2495 | if (eob == 1) /* DC only DCT coefficient. */ |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2496 | aom_idct16x16_1_add(input, dest, stride); |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 2497 | else if (eob <= quarter) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2498 | aom_idct16x16_10_add(input, dest, stride); |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 2499 | else if (eob <= half) |
Yi Luo | f6176ab | 2017-04-28 15:48:56 -0700 | [diff] [blame] | 2500 | aom_idct16x16_38_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2501 | else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2502 | aom_idct16x16_256_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2503 | } |
Monty Montgomery | cb9c1c5 | 2017-07-17 18:15:30 -0400 | [diff] [blame] | 2504 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2505 | |
Sarah Parker | 5b8e6d2 | 2017-07-24 15:30:53 -0700 | [diff] [blame] | 2506 | #if CONFIG_MRC_TX |
| 2507 | static void imrc32x32_add_c(const tran_low_t *input, uint8_t *dest, int stride, |
| 2508 | const TxfmParam *txfm_param) { |
| 2509 | #if CONFIG_ADAPT_SCAN |
| 2510 | const int16_t half = txfm_param->eob_threshold[0]; |
| 2511 | const int16_t quarter = txfm_param->eob_threshold[1]; |
| 2512 | #else |
| 2513 | const int16_t half = 135; |
| 2514 | const int16_t quarter = 34; |
| 2515 | #endif |
| 2516 | |
| 2517 | const int eob = txfm_param->eob; |
Sarah Parker | 99e7daa | 2017-08-29 10:30:13 -0700 | [diff] [blame] | 2518 | int n_masked_vals = 0; |
| 2519 | uint8_t *mask; |
| 2520 | uint8_t mask_tmp[32 * 32]; |
Sarah Parker | 5b8e6d2 | 2017-07-24 15:30:53 -0700 | [diff] [blame] | 2521 | if (eob == 1) { |
| 2522 | aom_idct32x32_1_add_c(input, dest, stride); |
| 2523 | } else { |
Sarah Parker | 99e7daa | 2017-08-29 10:30:13 -0700 | [diff] [blame] | 2524 | if ((txfm_param->is_inter && SIGNAL_MRC_MASK_INTER) || |
| 2525 | (!txfm_param->is_inter && SIGNAL_MRC_MASK_INTRA)) { |
| 2526 | mask = txfm_param->mask; |
| 2527 | } else { |
| 2528 | n_masked_vals = |
| 2529 | get_mrc_pred_mask(txfm_param->dst, txfm_param->stride, mask_tmp, 32, |
| 2530 | 32, 32, txfm_param->is_inter); |
| 2531 | if (!is_valid_mrc_mask(n_masked_vals, 32, 32)) |
| 2532 | assert(0 && "Invalid MRC mask"); |
| 2533 | mask = mask_tmp; |
| 2534 | } |
Sarah Parker | 5b8e6d2 | 2017-07-24 15:30:53 -0700 | [diff] [blame] | 2535 | if (eob <= quarter) |
| 2536 | // non-zero coeff only in upper-left 8x8 |
| 2537 | aom_imrc32x32_34_add_c(input, dest, stride, mask); |
| 2538 | else if (eob <= half) |
| 2539 | // non-zero coeff only in upper-left 16x16 |
| 2540 | aom_imrc32x32_135_add_c(input, dest, stride, mask); |
| 2541 | else |
| 2542 | aom_imrc32x32_1024_add_c(input, dest, stride, mask); |
| 2543 | } |
| 2544 | } |
| 2545 | #endif // CONFIG_MRC_TX |
| 2546 | |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2547 | #if !CONFIG_DAALA_TX32 |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2548 | static void idct32x32_add(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2549 | const TxfmParam *txfm_param) { |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 2550 | #if CONFIG_ADAPT_SCAN |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2551 | const int16_t half = txfm_param->eob_threshold[0]; |
| 2552 | const int16_t quarter = txfm_param->eob_threshold[1]; |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 2553 | #else |
| 2554 | const int16_t half = 135; |
| 2555 | const int16_t quarter = 34; |
| 2556 | #endif |
| 2557 | |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2558 | const int eob = txfm_param->eob; |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 2559 | if (eob == 1) |
| 2560 | aom_idct32x32_1_add(input, dest, stride); |
| 2561 | else if (eob <= quarter) |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2562 | // non-zero coeff only in upper-left 8x8 |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2563 | aom_idct32x32_34_add(input, dest, stride); |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 2564 | else if (eob <= half) |
Yi Luo | 40f22ef | 2017-05-08 16:29:39 -0700 | [diff] [blame] | 2565 | // non-zero coeff only in upper-left 16x16 |
| 2566 | aom_idct32x32_135_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2567 | else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2568 | aom_idct32x32_1024_add(input, dest, stride); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2569 | } |
Monty Montgomery | 2cb52ba | 2017-07-17 18:27:27 -0400 | [diff] [blame] | 2570 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2571 | |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2572 | #if CONFIG_TX64X64 && !CONFIG_DAALA_TX64 |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2573 | static void idct64x64_add(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2574 | const TxfmParam *txfm_param) { |
| 2575 | (void)txfm_param; |
Urvang Joshi | 9136ab7 | 2017-07-28 14:15:49 -0700 | [diff] [blame] | 2576 | av1_iht64x64_4096_add(input, dest, stride, txfm_param); |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 2577 | } |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2578 | #endif // CONFIG_TX64X64 && !CONFIG_DAALA_TX64 |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 2579 | |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 2580 | static void inv_txfm_add_4x4(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2581 | const TxfmParam *txfm_param) { |
| 2582 | const TX_TYPE tx_type = txfm_param->tx_type; |
| 2583 | if (txfm_param->lossless) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2584 | assert(tx_type == DCT_DCT); |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2585 | av1_iwht4x4_add(input, dest, stride, txfm_param); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2586 | return; |
| 2587 | } |
| 2588 | |
| 2589 | switch (tx_type) { |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2590 | #if !CONFIG_DAALA_TX4 |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2591 | case DCT_DCT: av1_idct4x4_add(input, dest, stride, txfm_param); break; |
Monty Montgomery | 02078a3 | 2017-07-11 21:22:29 -0400 | [diff] [blame] | 2592 | #else |
| 2593 | case DCT_DCT: |
| 2594 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2595 | case ADST_DCT: |
| 2596 | case DCT_ADST: |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2597 | case ADST_ADST: |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2598 | #if CONFIG_LGT || CONFIG_DAALA_TX4 |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2599 | // LGT only exists in C verson |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2600 | av1_iht4x4_16_add_c(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2601 | break; |
| 2602 | #else |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2603 | av1_iht4x4_16_add(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2604 | break; |
| 2605 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2606 | #if CONFIG_EXT_TX |
| 2607 | case FLIPADST_DCT: |
| 2608 | case DCT_FLIPADST: |
| 2609 | case FLIPADST_FLIPADST: |
| 2610 | case ADST_FLIPADST: |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2611 | case FLIPADST_ADST: |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2612 | #if CONFIG_LGT || CONFIG_DAALA_TX4 |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2613 | av1_iht4x4_16_add_c(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2614 | break; |
| 2615 | #else |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2616 | av1_iht4x4_16_add(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2617 | break; |
| 2618 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2619 | case V_DCT: |
| 2620 | case H_DCT: |
| 2621 | case V_ADST: |
| 2622 | case H_ADST: |
| 2623 | case V_FLIPADST: |
| 2624 | case H_FLIPADST: |
| 2625 | // Use C version since DST only exists in C code |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2626 | av1_iht4x4_16_add_c(input, dest, stride, txfm_param); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2627 | break; |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 2628 | case IDTX: inv_idtx_add_c(input, dest, stride, 4, 4, tx_type); break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2629 | #endif // CONFIG_EXT_TX |
| 2630 | default: assert(0); break; |
| 2631 | } |
| 2632 | } |
| 2633 | |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 2634 | static void inv_txfm_add_4x8(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2635 | const TxfmParam *txfm_param) { |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 2636 | #if CONFIG_LGT || (CONFIG_DAALA_TX4 && CONFIG_DAALA_TX8) |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2637 | av1_iht4x8_32_add_c(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2638 | #else |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2639 | av1_iht4x8_32_add(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2640 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2641 | } |
| 2642 | |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 2643 | static void inv_txfm_add_8x4(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2644 | const TxfmParam *txfm_param) { |
Monty Montgomery | abd9451 | 2017-10-14 00:41:42 -0400 | [diff] [blame] | 2645 | #if CONFIG_LGT || (CONFIG_DAALA_TX4 && CONFIG_DAALA_TX8) |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2646 | av1_iht8x4_32_add_c(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2647 | #else |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2648 | av1_iht8x4_32_add(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2649 | #endif |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2650 | } |
| 2651 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2652 | // These will be used by the masked-tx experiment in the future. |
Sebastien Alaiwan | fb83877 | 2017-10-24 12:02:54 +0200 | [diff] [blame] | 2653 | #if CONFIG_RECT_TX_EXT |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2654 | static void inv_txfm_add_4x16(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2655 | int stride, const TxfmParam *txfm_param) { |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2656 | #if CONFIG_LGT |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2657 | av1_iht4x16_64_add_c(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2658 | #else |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2659 | av1_iht4x16_64_add(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2660 | #endif |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 2661 | } |
| 2662 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2663 | static void inv_txfm_add_16x4(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2664 | int stride, const TxfmParam *txfm_param) { |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2665 | #if CONFIG_LGT |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2666 | av1_iht16x4_64_add_c(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2667 | #else |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2668 | av1_iht16x4_64_add(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2669 | #endif |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 2670 | } |
| 2671 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2672 | static void inv_txfm_add_8x32(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2673 | int stride, const TxfmParam *txfm_param) { |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2674 | #if CONFIG_LGT |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2675 | av1_iht8x32_256_add_c(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2676 | #else |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2677 | av1_iht8x32_256_add(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2678 | #endif |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 2679 | } |
| 2680 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2681 | static void inv_txfm_add_32x8(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2682 | int stride, const TxfmParam *txfm_param) { |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2683 | #if CONFIG_LGT |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2684 | av1_iht32x8_256_add_c(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2685 | #else |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2686 | av1_iht32x8_256_add(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2687 | #endif |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 2688 | } |
Yue Chen | d6bdd46 | 2017-07-19 16:05:43 -0700 | [diff] [blame] | 2689 | #endif |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 2690 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2691 | static void inv_txfm_add_8x16(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2692 | int stride, const TxfmParam *txfm_param) { |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 2693 | #if CONFIG_LGT || (CONFIG_DAALA_TX8 && CONFIG_DAALA_TX16) |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2694 | av1_iht8x16_128_add_c(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2695 | #else |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2696 | av1_iht8x16_128_add(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2697 | #endif |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2698 | } |
| 2699 | |
| 2700 | static void inv_txfm_add_16x8(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2701 | int stride, const TxfmParam *txfm_param) { |
Monty Montgomery | 7eb4454 | 2017-10-19 20:47:51 -0400 | [diff] [blame] | 2702 | #if CONFIG_LGT || (CONFIG_DAALA_TX8 && CONFIG_DAALA_TX16) |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2703 | av1_iht16x8_128_add_c(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2704 | #else |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2705 | av1_iht16x8_128_add(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2706 | #endif |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2707 | } |
| 2708 | |
| 2709 | static void inv_txfm_add_16x32(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2710 | int stride, const TxfmParam *txfm_param) { |
Monty Montgomery | ad39685 | 2017-10-20 03:35:26 -0400 | [diff] [blame] | 2711 | #if CONFIG_DAALA_TX16 && CONFIG_DAALA_TX32 |
| 2712 | av1_iht16x32_512_add_c(input, dest, stride, txfm_param); |
| 2713 | #else |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2714 | av1_iht16x32_512_add(input, dest, stride, txfm_param); |
Monty Montgomery | ad39685 | 2017-10-20 03:35:26 -0400 | [diff] [blame] | 2715 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2716 | } |
| 2717 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2718 | static void inv_txfm_add_32x16(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2719 | int stride, const TxfmParam *txfm_param) { |
Monty Montgomery | ad39685 | 2017-10-20 03:35:26 -0400 | [diff] [blame] | 2720 | #if CONFIG_DAALA_TX16 && CONFIG_DAALA_TX32 |
| 2721 | av1_iht32x16_512_add_c(input, dest, stride, txfm_param); |
| 2722 | #else |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2723 | av1_iht32x16_512_add(input, dest, stride, txfm_param); |
Monty Montgomery | ad39685 | 2017-10-20 03:35:26 -0400 | [diff] [blame] | 2724 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2725 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2726 | |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 2727 | #if CONFIG_TX64X64 |
| 2728 | static void inv_txfm_add_32x64(const tran_low_t *input, uint8_t *dest, |
| 2729 | int stride, const TxfmParam *txfm_param) { |
| 2730 | av1_iht32x64_2048_add(input, dest, stride, txfm_param); |
| 2731 | } |
| 2732 | |
| 2733 | static void inv_txfm_add_64x32(const tran_low_t *input, uint8_t *dest, |
| 2734 | int stride, const TxfmParam *txfm_param) { |
| 2735 | av1_iht64x32_2048_add(input, dest, stride, txfm_param); |
| 2736 | } |
| 2737 | #endif // CONFIG_TX64X64 |
| 2738 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2739 | static void inv_txfm_add_8x8(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2740 | const TxfmParam *txfm_param) { |
| 2741 | const TX_TYPE tx_type = txfm_param->tx_type; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2742 | switch (tx_type) { |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2743 | #if !CONFIG_DAALA_TX8 |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2744 | case DCT_DCT: idct8x8_add(input, dest, stride, txfm_param); break; |
Monty Montgomery | cf18fe4 | 2017-07-11 21:33:25 -0400 | [diff] [blame] | 2745 | #else |
| 2746 | case DCT_DCT: |
| 2747 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2748 | case ADST_DCT: |
| 2749 | case DCT_ADST: |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2750 | case ADST_ADST: |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2751 | #if CONFIG_LGT || CONFIG_DAALA_TX8 |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2752 | av1_iht8x8_64_add_c(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2753 | break; |
| 2754 | #else |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2755 | av1_iht8x8_64_add(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2756 | break; |
| 2757 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2758 | #if CONFIG_EXT_TX |
| 2759 | case FLIPADST_DCT: |
| 2760 | case DCT_FLIPADST: |
| 2761 | case FLIPADST_FLIPADST: |
| 2762 | case ADST_FLIPADST: |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2763 | case FLIPADST_ADST: |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2764 | #if CONFIG_LGT || CONFIG_DAALA_TX8 |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2765 | av1_iht8x8_64_add_c(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2766 | break; |
| 2767 | #else |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2768 | av1_iht8x8_64_add(input, dest, stride, txfm_param); |
Lester Lu | ad8290b | 2017-06-12 18:26:18 -0700 | [diff] [blame] | 2769 | break; |
| 2770 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2771 | case V_DCT: |
| 2772 | case H_DCT: |
| 2773 | case V_ADST: |
| 2774 | case H_ADST: |
| 2775 | case V_FLIPADST: |
| 2776 | case H_FLIPADST: |
| 2777 | // Use C version since DST only exists in C code |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2778 | av1_iht8x8_64_add_c(input, dest, stride, txfm_param); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2779 | break; |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 2780 | case IDTX: inv_idtx_add_c(input, dest, stride, 8, 8, tx_type); break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2781 | #endif // CONFIG_EXT_TX |
| 2782 | default: assert(0); break; |
| 2783 | } |
| 2784 | } |
| 2785 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2786 | static void inv_txfm_add_16x16(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2787 | int stride, const TxfmParam *txfm_param) { |
| 2788 | const TX_TYPE tx_type = txfm_param->tx_type; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2789 | switch (tx_type) { |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2790 | #if !CONFIG_DAALA_TX16 |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2791 | case DCT_DCT: idct16x16_add(input, dest, stride, txfm_param); break; |
Monty Montgomery | cb9c1c5 | 2017-07-17 18:15:30 -0400 | [diff] [blame] | 2792 | #else |
| 2793 | case DCT_DCT: |
| 2794 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2795 | case ADST_DCT: |
| 2796 | case DCT_ADST: |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2797 | case ADST_ADST: |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2798 | #if CONFIG_DAALA_TX16 |
Nathan E. Egge | 34e1201 | 2017-09-13 09:02:32 -0400 | [diff] [blame] | 2799 | av1_iht16x16_256_add_c(input, dest, stride, txfm_param); |
| 2800 | #else |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2801 | av1_iht16x16_256_add(input, dest, stride, txfm_param); |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2802 | #endif // CONFIG_DAALA_TX16 |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2803 | break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2804 | #if CONFIG_EXT_TX |
| 2805 | case FLIPADST_DCT: |
| 2806 | case DCT_FLIPADST: |
| 2807 | case FLIPADST_FLIPADST: |
| 2808 | case ADST_FLIPADST: |
| 2809 | case FLIPADST_ADST: |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2810 | case V_DCT: |
| 2811 | case H_DCT: |
| 2812 | case V_ADST: |
| 2813 | case H_ADST: |
| 2814 | case V_FLIPADST: |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2815 | case H_FLIPADST: |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2816 | #if CONFIG_DAALA_TX16 |
Nathan E. Egge | 34e1201 | 2017-09-13 09:02:32 -0400 | [diff] [blame] | 2817 | av1_iht16x16_256_add_c(input, dest, stride, txfm_param); |
| 2818 | #else |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2819 | av1_iht16x16_256_add(input, dest, stride, txfm_param); |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2820 | #endif // CONFIG_DAALA_TX16 |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2821 | break; |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 2822 | case IDTX: inv_idtx_add_c(input, dest, stride, 16, 16, tx_type); break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2823 | #endif // CONFIG_EXT_TX |
Sarah Parker | 53f93db | 2017-07-11 17:20:04 -0700 | [diff] [blame] | 2824 | #if CONFIG_MRC_TX |
| 2825 | case MRC_DCT: assert(0 && "Invalid tx type for tx size"); |
| 2826 | #endif // CONFIG_MRC_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2827 | default: assert(0); break; |
| 2828 | } |
| 2829 | } |
| 2830 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2831 | static void inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2832 | int stride, const TxfmParam *txfm_param) { |
| 2833 | const TX_TYPE tx_type = txfm_param->tx_type; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2834 | switch (tx_type) { |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2835 | #if !CONFIG_DAALA_TX32 |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2836 | case DCT_DCT: idct32x32_add(input, dest, stride, txfm_param); break; |
Monty Montgomery | 2cb52ba | 2017-07-17 18:27:27 -0400 | [diff] [blame] | 2837 | #else |
| 2838 | case DCT_DCT: |
| 2839 | av1_iht32x32_1024_add_c(input, dest, stride, txfm_param); |
| 2840 | break; |
| 2841 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2842 | #if CONFIG_EXT_TX |
| 2843 | case ADST_DCT: |
| 2844 | case DCT_ADST: |
| 2845 | case ADST_ADST: |
| 2846 | case FLIPADST_DCT: |
| 2847 | case DCT_FLIPADST: |
| 2848 | case FLIPADST_FLIPADST: |
| 2849 | case ADST_FLIPADST: |
| 2850 | case FLIPADST_ADST: |
| 2851 | case V_DCT: |
| 2852 | case H_DCT: |
| 2853 | case V_ADST: |
| 2854 | case H_ADST: |
| 2855 | case V_FLIPADST: |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2856 | case H_FLIPADST: |
| 2857 | av1_iht32x32_1024_add_c(input, dest, stride, txfm_param); |
| 2858 | break; |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 2859 | case IDTX: inv_idtx_add_c(input, dest, stride, 32, 32, tx_type); break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2860 | #endif // CONFIG_EXT_TX |
Sarah Parker | 53f93db | 2017-07-11 17:20:04 -0700 | [diff] [blame] | 2861 | #if CONFIG_MRC_TX |
| 2862 | case MRC_DCT: imrc32x32_add_c(input, dest, stride, txfm_param); break; |
| 2863 | #endif // CONFIG_MRC_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2864 | default: assert(0); break; |
| 2865 | } |
| 2866 | } |
| 2867 | |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 2868 | #if CONFIG_TX64X64 |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2869 | static void inv_txfm_add_64x64(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2870 | int stride, const TxfmParam *txfm_param) { |
| 2871 | const TX_TYPE tx_type = txfm_param->tx_type; |
Debargha Mukherjee | 570423c | 2017-10-01 00:35:20 -0700 | [diff] [blame] | 2872 | assert(tx_type == DCT_DCT); |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 2873 | switch (tx_type) { |
Nathan E. Egge | e554f36 | 2017-10-04 14:44:38 -0400 | [diff] [blame] | 2874 | #if !CONFIG_DAALA_TX64 |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2875 | case DCT_DCT: idct64x64_add(input, dest, stride, txfm_param); break; |
Monty Montgomery | a4e245a | 2017-07-22 00:48:31 -0400 | [diff] [blame] | 2876 | #else |
| 2877 | case DCT_DCT: |
| 2878 | #endif |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 2879 | #if CONFIG_EXT_TX |
| 2880 | case ADST_DCT: |
| 2881 | case DCT_ADST: |
| 2882 | case ADST_ADST: |
| 2883 | case FLIPADST_DCT: |
| 2884 | case DCT_FLIPADST: |
| 2885 | case FLIPADST_FLIPADST: |
| 2886 | case ADST_FLIPADST: |
| 2887 | case FLIPADST_ADST: |
| 2888 | case V_DCT: |
| 2889 | case H_DCT: |
| 2890 | case V_ADST: |
| 2891 | case H_ADST: |
| 2892 | case V_FLIPADST: |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2893 | case H_FLIPADST: |
| 2894 | av1_iht64x64_4096_add_c(input, dest, stride, txfm_param); |
| 2895 | break; |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 2896 | case IDTX: inv_idtx_add_c(input, dest, stride, 64, 64, tx_type); break; |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 2897 | #endif // CONFIG_EXT_TX |
Sarah Parker | 53f93db | 2017-07-11 17:20:04 -0700 | [diff] [blame] | 2898 | #if CONFIG_MRC_TX |
| 2899 | case MRC_DCT: assert(0 && "Invalid tx type for tx size"); |
| 2900 | #endif // CONFIG_MRC_TX |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 2901 | default: assert(0); break; |
| 2902 | } |
| 2903 | } |
| 2904 | #endif // CONFIG_TX64X64 |
| 2905 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2906 | void av1_highbd_iwht4x4_add(const tran_low_t *input, uint8_t *dest, int stride, |
| 2907 | int eob, int bd) { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2908 | if (eob > 1) |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2909 | aom_highbd_iwht4x4_16_add(input, dest, stride, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2910 | else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2911 | aom_highbd_iwht4x4_1_add(input, dest, stride, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2912 | } |
| 2913 | |
Sebastien Alaiwan | 62c92e6 | 2017-10-04 15:09:19 +0200 | [diff] [blame] | 2914 | static const int32_t *cast_to_int32(const tran_low_t *input) { |
| 2915 | assert(sizeof(int32_t) == sizeof(tran_low_t)); |
| 2916 | return (const int32_t *)input; |
| 2917 | } |
| 2918 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2919 | void av1_highbd_inv_txfm_add_4x4(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2920 | int stride, const TxfmParam *txfm_param) { |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 2921 | #if CONFIG_EXT_TX |
| 2922 | assert(av1_ext_tx_used[txfm_param->tx_set_type][txfm_param->tx_type]); |
| 2923 | #endif // CONFIG_EXT_TX |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2924 | int eob = txfm_param->eob; |
| 2925 | int bd = txfm_param->bd; |
| 2926 | int lossless = txfm_param->lossless; |
Sebastien Alaiwan | 62c92e6 | 2017-10-04 15:09:19 +0200 | [diff] [blame] | 2927 | const int32_t *src = cast_to_int32(input); |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 2928 | const TX_TYPE tx_type = txfm_param->tx_type; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2929 | if (lossless) { |
| 2930 | assert(tx_type == DCT_DCT); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2931 | av1_highbd_iwht4x4_add(input, dest, stride, eob, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2932 | return; |
| 2933 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2934 | switch (tx_type) { |
| 2935 | case DCT_DCT: |
| 2936 | case ADST_DCT: |
| 2937 | case DCT_ADST: |
| 2938 | case ADST_ADST: |
Yi Luo | 5128109 | 2017-06-26 16:36:15 -0700 | [diff] [blame] | 2939 | av1_inv_txfm2d_add_4x4(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 2940 | bd); |
| 2941 | break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2942 | #if CONFIG_EXT_TX |
| 2943 | case FLIPADST_DCT: |
| 2944 | case DCT_FLIPADST: |
| 2945 | case FLIPADST_FLIPADST: |
| 2946 | case ADST_FLIPADST: |
| 2947 | case FLIPADST_ADST: |
Yi Luo | 5128109 | 2017-06-26 16:36:15 -0700 | [diff] [blame] | 2948 | av1_inv_txfm2d_add_4x4(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2949 | bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2950 | break; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 2951 | // use the c version for anything including identity for now |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2952 | case V_DCT: |
| 2953 | case H_DCT: |
| 2954 | case V_ADST: |
| 2955 | case H_ADST: |
| 2956 | case V_FLIPADST: |
| 2957 | case H_FLIPADST: |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2958 | case IDTX: |
Yi Luo | 5128109 | 2017-06-26 16:36:15 -0700 | [diff] [blame] | 2959 | av1_inv_txfm2d_add_4x4_c(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
| 2960 | bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2961 | break; |
| 2962 | #endif // CONFIG_EXT_TX |
| 2963 | default: assert(0); break; |
| 2964 | } |
| 2965 | } |
| 2966 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2967 | void av1_highbd_inv_txfm_add_4x8(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2968 | int stride, const TxfmParam *txfm_param) { |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 2969 | #if CONFIG_EXT_TX |
| 2970 | assert(av1_ext_tx_used[txfm_param->tx_set_type][txfm_param->tx_type]); |
| 2971 | #endif // CONFIG_EXT_TX |
Sebastien Alaiwan | 62c92e6 | 2017-10-04 15:09:19 +0200 | [diff] [blame] | 2972 | const int32_t *src = cast_to_int32(input); |
Lester Lu | d8b1ddc | 2017-07-06 16:13:29 -0700 | [diff] [blame] | 2973 | av1_inv_txfm2d_add_4x8_c(src, CONVERT_TO_SHORTPTR(dest), stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2974 | txfm_param->tx_type, txfm_param->bd); |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 2975 | } |
| 2976 | |
| 2977 | void av1_highbd_inv_txfm_add_8x4(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2978 | int stride, const TxfmParam *txfm_param) { |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 2979 | #if CONFIG_EXT_TX |
| 2980 | assert(av1_ext_tx_used[txfm_param->tx_set_type][txfm_param->tx_type]); |
| 2981 | #endif // CONFIG_EXT_TX |
Sebastien Alaiwan | 62c92e6 | 2017-10-04 15:09:19 +0200 | [diff] [blame] | 2982 | const int32_t *src = cast_to_int32(input); |
Lester Lu | d8b1ddc | 2017-07-06 16:13:29 -0700 | [diff] [blame] | 2983 | av1_inv_txfm2d_add_8x4_c(src, CONVERT_TO_SHORTPTR(dest), stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2984 | txfm_param->tx_type, txfm_param->bd); |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 2985 | } |
| 2986 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2987 | static void highbd_inv_txfm_add_8x16(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2988 | int stride, const TxfmParam *txfm_param) { |
Sebastien Alaiwan | 62c92e6 | 2017-10-04 15:09:19 +0200 | [diff] [blame] | 2989 | const int32_t *src = cast_to_int32(input); |
Lester Lu | d8b1ddc | 2017-07-06 16:13:29 -0700 | [diff] [blame] | 2990 | av1_inv_txfm2d_add_8x16_c(src, CONVERT_TO_SHORTPTR(dest), stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2991 | txfm_param->tx_type, txfm_param->bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 2992 | } |
| 2993 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 2994 | static void highbd_inv_txfm_add_16x8(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2995 | int stride, const TxfmParam *txfm_param) { |
Sebastien Alaiwan | 62c92e6 | 2017-10-04 15:09:19 +0200 | [diff] [blame] | 2996 | const int32_t *src = cast_to_int32(input); |
Lester Lu | d8b1ddc | 2017-07-06 16:13:29 -0700 | [diff] [blame] | 2997 | av1_inv_txfm2d_add_16x8_c(src, CONVERT_TO_SHORTPTR(dest), stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 2998 | txfm_param->tx_type, txfm_param->bd); |
Debargha Mukherjee | 751de38 | 2016-12-13 02:54:22 -0800 | [diff] [blame] | 2999 | } |
| 3000 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 3001 | static void highbd_inv_txfm_add_16x32(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3002 | int stride, const TxfmParam *txfm_param) { |
Sebastien Alaiwan | 62c92e6 | 2017-10-04 15:09:19 +0200 | [diff] [blame] | 3003 | const int32_t *src = cast_to_int32(input); |
Lester Lu | d8b1ddc | 2017-07-06 16:13:29 -0700 | [diff] [blame] | 3004 | av1_inv_txfm2d_add_16x32_c(src, CONVERT_TO_SHORTPTR(dest), stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3005 | txfm_param->tx_type, txfm_param->bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3006 | } |
| 3007 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 3008 | static void highbd_inv_txfm_add_32x16(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3009 | int stride, const TxfmParam *txfm_param) { |
Sebastien Alaiwan | 62c92e6 | 2017-10-04 15:09:19 +0200 | [diff] [blame] | 3010 | const int32_t *src = cast_to_int32(input); |
Lester Lu | d8b1ddc | 2017-07-06 16:13:29 -0700 | [diff] [blame] | 3011 | av1_inv_txfm2d_add_32x16_c(src, CONVERT_TO_SHORTPTR(dest), stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3012 | txfm_param->tx_type, txfm_param->bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3013 | } |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3014 | |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 3015 | #if CONFIG_TX64X64 |
| 3016 | static void highbd_inv_txfm_add_32x64(const tran_low_t *input, uint8_t *dest, |
| 3017 | int stride, const TxfmParam *txfm_param) { |
Sebastien Alaiwan | 62c92e6 | 2017-10-04 15:09:19 +0200 | [diff] [blame] | 3018 | const int32_t *src = cast_to_int32(input); |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 3019 | av1_inv_txfm2d_add_32x64_c(src, CONVERT_TO_SHORTPTR(dest), stride, |
| 3020 | txfm_param->tx_type, txfm_param->bd); |
| 3021 | } |
| 3022 | |
| 3023 | static void highbd_inv_txfm_add_64x32(const tran_low_t *input, uint8_t *dest, |
| 3024 | int stride, const TxfmParam *txfm_param) { |
Sebastien Alaiwan | 62c92e6 | 2017-10-04 15:09:19 +0200 | [diff] [blame] | 3025 | const int32_t *src = cast_to_int32(input); |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 3026 | av1_inv_txfm2d_add_64x32_c(src, CONVERT_TO_SHORTPTR(dest), stride, |
| 3027 | txfm_param->tx_type, txfm_param->bd); |
| 3028 | } |
| 3029 | #endif // CONFIG_TX64X64 |
| 3030 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 3031 | static void highbd_inv_txfm_add_8x8(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3032 | int stride, const TxfmParam *txfm_param) { |
| 3033 | int bd = txfm_param->bd; |
Urvang Joshi | 2283d37 | 2017-10-02 17:16:45 -0700 | [diff] [blame] | 3034 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sebastien Alaiwan | 62c92e6 | 2017-10-04 15:09:19 +0200 | [diff] [blame] | 3035 | const int32_t *src = cast_to_int32(input); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3036 | switch (tx_type) { |
| 3037 | case DCT_DCT: |
| 3038 | case ADST_DCT: |
| 3039 | case DCT_ADST: |
| 3040 | case ADST_ADST: |
Yi Luo | 5128109 | 2017-06-26 16:36:15 -0700 | [diff] [blame] | 3041 | av1_inv_txfm2d_add_8x8(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 3042 | bd); |
| 3043 | break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3044 | #if CONFIG_EXT_TX |
| 3045 | case FLIPADST_DCT: |
| 3046 | case DCT_FLIPADST: |
| 3047 | case FLIPADST_FLIPADST: |
| 3048 | case ADST_FLIPADST: |
| 3049 | case FLIPADST_ADST: |
Yi Luo | 5128109 | 2017-06-26 16:36:15 -0700 | [diff] [blame] | 3050 | av1_inv_txfm2d_add_8x8(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 3051 | bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3052 | break; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 3053 | // use the c version for anything including identity for now |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3054 | case V_DCT: |
| 3055 | case H_DCT: |
| 3056 | case V_ADST: |
| 3057 | case H_ADST: |
| 3058 | case V_FLIPADST: |
| 3059 | case H_FLIPADST: |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3060 | case IDTX: |
Yi Luo | 5128109 | 2017-06-26 16:36:15 -0700 | [diff] [blame] | 3061 | av1_inv_txfm2d_add_8x8_c(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
| 3062 | bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3063 | break; |
| 3064 | #endif // CONFIG_EXT_TX |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 3065 | default: assert(0); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3066 | } |
| 3067 | } |
| 3068 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 3069 | static void highbd_inv_txfm_add_16x16(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3070 | int stride, const TxfmParam *txfm_param) { |
| 3071 | int bd = txfm_param->bd; |
Urvang Joshi | f8fe2ae | 2017-10-05 12:13:17 -0700 | [diff] [blame] | 3072 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sebastien Alaiwan | 62c92e6 | 2017-10-04 15:09:19 +0200 | [diff] [blame] | 3073 | const int32_t *src = cast_to_int32(input); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3074 | switch (tx_type) { |
| 3075 | case DCT_DCT: |
| 3076 | case ADST_DCT: |
| 3077 | case DCT_ADST: |
| 3078 | case ADST_ADST: |
Yi Luo | 5128109 | 2017-06-26 16:36:15 -0700 | [diff] [blame] | 3079 | av1_inv_txfm2d_add_16x16(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
| 3080 | bd); |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 3081 | break; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3082 | #if CONFIG_EXT_TX |
| 3083 | case FLIPADST_DCT: |
| 3084 | case DCT_FLIPADST: |
| 3085 | case FLIPADST_FLIPADST: |
| 3086 | case ADST_FLIPADST: |
| 3087 | case FLIPADST_ADST: |
Yi Luo | 5128109 | 2017-06-26 16:36:15 -0700 | [diff] [blame] | 3088 | av1_inv_txfm2d_add_16x16(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
| 3089 | bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3090 | break; |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 3091 | // use the c version for anything including identity for now |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3092 | case V_DCT: |
| 3093 | case H_DCT: |
| 3094 | case V_ADST: |
| 3095 | case H_ADST: |
| 3096 | case V_FLIPADST: |
| 3097 | case H_FLIPADST: |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3098 | case IDTX: |
Yi Luo | 5128109 | 2017-06-26 16:36:15 -0700 | [diff] [blame] | 3099 | av1_inv_txfm2d_add_16x16_c(src, CONVERT_TO_SHORTPTR(dest), stride, |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 3100 | tx_type, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3101 | break; |
| 3102 | #endif // CONFIG_EXT_TX |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 3103 | default: assert(0); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3104 | } |
| 3105 | } |
| 3106 | |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 3107 | static void highbd_inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3108 | int stride, const TxfmParam *txfm_param) { |
| 3109 | int bd = txfm_param->bd; |
Urvang Joshi | f8fe2ae | 2017-10-05 12:13:17 -0700 | [diff] [blame] | 3110 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sebastien Alaiwan | 62c92e6 | 2017-10-04 15:09:19 +0200 | [diff] [blame] | 3111 | const int32_t *src = cast_to_int32(input); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3112 | switch (tx_type) { |
| 3113 | case DCT_DCT: |
Yi Luo | 5128109 | 2017-06-26 16:36:15 -0700 | [diff] [blame] | 3114 | av1_inv_txfm2d_add_32x32(src, CONVERT_TO_SHORTPTR(dest), stride, tx_type, |
| 3115 | bd); |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 3116 | break; |
Rupert Swarbrick | f16c3c8 | 2017-08-17 13:24:42 +0100 | [diff] [blame] | 3117 | |
| 3118 | // The optimised version only supports DCT_DCT, so force use of |
| 3119 | // the C version for all other transform types. |
| 3120 | case ADST_DCT: |
| 3121 | case DCT_ADST: |
| 3122 | case ADST_ADST: |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 3123 | #if CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3124 | case FLIPADST_DCT: |
| 3125 | case DCT_FLIPADST: |
| 3126 | case FLIPADST_FLIPADST: |
| 3127 | case ADST_FLIPADST: |
| 3128 | case FLIPADST_ADST: |
Rupert Swarbrick | f16c3c8 | 2017-08-17 13:24:42 +0100 | [diff] [blame] | 3129 | case IDTX: |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3130 | case V_DCT: |
| 3131 | case H_DCT: |
| 3132 | case V_ADST: |
| 3133 | case H_ADST: |
| 3134 | case V_FLIPADST: |
| 3135 | case H_FLIPADST: |
Rupert Swarbrick | f16c3c8 | 2017-08-17 13:24:42 +0100 | [diff] [blame] | 3136 | #endif // CONFIG_EXT_TX |
Yi Luo | 5128109 | 2017-06-26 16:36:15 -0700 | [diff] [blame] | 3137 | av1_inv_txfm2d_add_32x32_c(src, CONVERT_TO_SHORTPTR(dest), stride, |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 3138 | tx_type, bd); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3139 | break; |
Rupert Swarbrick | f16c3c8 | 2017-08-17 13:24:42 +0100 | [diff] [blame] | 3140 | |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 3141 | default: assert(0); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3142 | } |
| 3143 | } |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 3144 | |
| 3145 | #if CONFIG_TX64X64 |
hui su | a531571 | 2017-03-20 11:37:15 -0700 | [diff] [blame] | 3146 | static void highbd_inv_txfm_add_64x64(const tran_low_t *input, uint8_t *dest, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3147 | int stride, const TxfmParam *txfm_param) { |
| 3148 | int bd = txfm_param->bd; |
Urvang Joshi | f8fe2ae | 2017-10-05 12:13:17 -0700 | [diff] [blame] | 3149 | const TX_TYPE tx_type = txfm_param->tx_type; |
Sebastien Alaiwan | 62c92e6 | 2017-10-04 15:09:19 +0200 | [diff] [blame] | 3150 | const int32_t *src = cast_to_int32(input); |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 3151 | switch (tx_type) { |
| 3152 | case DCT_DCT: |
Yi Luo | 5128109 | 2017-06-26 16:36:15 -0700 | [diff] [blame] | 3153 | av1_inv_txfm2d_add_64x64(src, CONVERT_TO_SHORTPTR(dest), stride, DCT_DCT, |
| 3154 | bd); |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 3155 | break; |
| 3156 | #if CONFIG_EXT_TX |
| 3157 | case ADST_DCT: |
| 3158 | case DCT_ADST: |
| 3159 | case ADST_ADST: |
| 3160 | case FLIPADST_DCT: |
| 3161 | case DCT_FLIPADST: |
| 3162 | case FLIPADST_FLIPADST: |
| 3163 | case ADST_FLIPADST: |
| 3164 | case FLIPADST_ADST: |
| 3165 | case V_DCT: |
| 3166 | case H_DCT: |
| 3167 | case V_ADST: |
| 3168 | case H_ADST: |
| 3169 | case V_FLIPADST: |
| 3170 | case H_FLIPADST: |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 3171 | // TODO(sarahparker) |
| 3172 | // I've deleted the 64x64 implementations that existed in lieu |
| 3173 | // of adst, flipadst and identity for simplicity but will bring back |
| 3174 | // in a later change. This shouldn't impact performance since |
| 3175 | // DCT_DCT is the only extended type currently allowed for 64x64, |
| 3176 | // as dictated by get_ext_tx_set_type in blockd.h. |
Yi Luo | 5128109 | 2017-06-26 16:36:15 -0700 | [diff] [blame] | 3177 | av1_inv_txfm2d_add_64x64_c(src, CONVERT_TO_SHORTPTR(dest), stride, |
Sarah Parker | 31c6650 | 2017-05-19 16:51:07 -0700 | [diff] [blame] | 3178 | DCT_DCT, bd); |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 3179 | break; |
| 3180 | case IDTX: |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 3181 | highbd_inv_idtx_add_c(input, dest, stride, 64, 64, tx_type, bd); |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 3182 | break; |
| 3183 | #endif // CONFIG_EXT_TX |
| 3184 | default: assert(0); break; |
| 3185 | } |
| 3186 | } |
| 3187 | #endif // CONFIG_TX64X64 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3188 | |
hui su | bb9c73b | 2017-03-17 15:51:02 -0700 | [diff] [blame] | 3189 | void av1_inv_txfm_add(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3190 | TxfmParam *txfm_param) { |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 3191 | #if CONFIG_EXT_TX |
| 3192 | assert(av1_ext_tx_used[txfm_param->tx_set_type][txfm_param->tx_type]); |
| 3193 | #endif // CONFIG_EXT_TX |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3194 | const TX_SIZE tx_size = txfm_param->tx_size; |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 3195 | #if CONFIG_LGT_FROM_PRED |
| 3196 | if (txfm_param->use_lgt) { |
| 3197 | assert(is_lgt_allowed(txfm_param->mode, tx_size)); |
| 3198 | ilgt2d_from_pred_add(input, dest, stride, txfm_param); |
| 3199 | return; |
| 3200 | } |
| 3201 | #endif // CONFIG_LGT_FROM_PRED |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3202 | switch (tx_size) { |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 3203 | #if CONFIG_TX64X64 |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3204 | case TX_64X64: inv_txfm_add_64x64(input, dest, stride, txfm_param); break; |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 3205 | #endif // CONFIG_TX64X64 |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3206 | case TX_32X32: inv_txfm_add_32x32(input, dest, stride, txfm_param); break; |
| 3207 | case TX_16X16: inv_txfm_add_16x16(input, dest, stride, txfm_param); break; |
| 3208 | case TX_8X8: inv_txfm_add_8x8(input, dest, stride, txfm_param); break; |
| 3209 | case TX_4X8: inv_txfm_add_4x8(input, dest, stride, txfm_param); break; |
| 3210 | case TX_8X4: inv_txfm_add_8x4(input, dest, stride, txfm_param); break; |
| 3211 | case TX_8X16: inv_txfm_add_8x16(input, dest, stride, txfm_param); break; |
| 3212 | case TX_16X8: inv_txfm_add_16x8(input, dest, stride, txfm_param); break; |
| 3213 | case TX_16X32: inv_txfm_add_16x32(input, dest, stride, txfm_param); break; |
| 3214 | case TX_32X16: inv_txfm_add_32x16(input, dest, stride, txfm_param); break; |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 3215 | #if CONFIG_TX64X64 |
| 3216 | case TX_64X32: inv_txfm_add_64x32(input, dest, stride, txfm_param); break; |
| 3217 | case TX_32X64: inv_txfm_add_32x64(input, dest, stride, txfm_param); break; |
| 3218 | #endif // CONFIG_TX64X64 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3219 | case TX_4X4: |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 3220 | // 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] | 3221 | // which is significant (not just an optimization) for the lossless |
| 3222 | // case. |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3223 | inv_txfm_add_4x4(input, dest, stride, txfm_param); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3224 | break; |
Sebastien Alaiwan | fb83877 | 2017-10-24 12:02:54 +0200 | [diff] [blame] | 3225 | #if CONFIG_RECT_TX_EXT |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3226 | case TX_32X8: inv_txfm_add_32x8(input, dest, stride, txfm_param); break; |
| 3227 | case TX_8X32: inv_txfm_add_8x32(input, dest, stride, txfm_param); break; |
| 3228 | case TX_16X4: inv_txfm_add_16x4(input, dest, stride, txfm_param); break; |
| 3229 | case TX_4X16: inv_txfm_add_4x16(input, dest, stride, txfm_param); break; |
Yue Chen | 56e226e | 2017-05-02 16:21:40 -0700 | [diff] [blame] | 3230 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3231 | default: assert(0 && "Invalid transform size"); break; |
| 3232 | } |
| 3233 | } |
| 3234 | |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 3235 | static void init_txfm_param(const MACROBLOCKD *xd, |
| 3236 | #if CONFIG_EXT_TX |
| 3237 | int plane, |
| 3238 | #endif // CONFIG_EXT_TX |
| 3239 | TX_SIZE tx_size, TX_TYPE tx_type, int eob, |
| 3240 | TxfmParam *txfm_param) { |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3241 | txfm_param->tx_type = tx_type; |
| 3242 | txfm_param->tx_size = tx_size; |
| 3243 | txfm_param->eob = eob; |
| 3244 | txfm_param->lossless = xd->lossless[xd->mi[0]->mbmi.segment_id]; |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3245 | txfm_param->bd = xd->bd; |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 3246 | #if CONFIG_EXT_TX |
| 3247 | const struct macroblockd_plane *const pd = &xd->plane[plane]; |
| 3248 | const BLOCK_SIZE plane_bsize = |
| 3249 | get_plane_block_size(xd->mi[0]->mbmi.sb_type, pd); |
| 3250 | // TODO(sarahparker) This assumes reduced_tx_set_used == 0. I will do a |
| 3251 | // follow up refactor to make the actual value of reduced_tx_set_used |
| 3252 | // within this function. |
| 3253 | txfm_param->tx_set_type = get_ext_tx_set_type( |
| 3254 | txfm_param->tx_size, plane_bsize, is_inter_block(&xd->mi[0]->mbmi), 0); |
| 3255 | #endif // CONFIG_EXT_TX |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 3256 | #if CONFIG_LGT |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3257 | txfm_param->is_inter = is_inter_block(&xd->mi[0]->mbmi); |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 3258 | #endif |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 3259 | #if CONFIG_LGT_FROM_PRED |
| 3260 | txfm_param->use_lgt = xd->mi[0]->mbmi.use_lgt; |
| 3261 | #endif |
Yi Luo | f8e87b4 | 2017-04-14 17:20:27 -0700 | [diff] [blame] | 3262 | #if CONFIG_ADAPT_SCAN |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3263 | txfm_param->eob_threshold = |
Yi Luo | 2ab63cb | 2017-05-11 16:44:22 -0700 | [diff] [blame] | 3264 | (const int16_t *)&xd->eob_threshold_md[tx_size][tx_type][0]; |
Yi Luo | f8e87b4 | 2017-04-14 17:20:27 -0700 | [diff] [blame] | 3265 | #endif |
| 3266 | } |
| 3267 | |
Angie Chiang | ad653a3 | 2017-07-31 15:30:58 -0700 | [diff] [blame] | 3268 | #if !CONFIG_TXMG |
Yi Luo | 5128109 | 2017-06-26 16:36:15 -0700 | [diff] [blame] | 3269 | typedef void (*InvTxfmFunc)(const tran_low_t *dqcoeff, uint8_t *dst, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3270 | TxfmParam *txfm_param); |
Yi Luo | 5128109 | 2017-06-26 16:36:15 -0700 | [diff] [blame] | 3271 | |
| 3272 | static InvTxfmFunc inv_txfm_func[2] = { av1_inv_txfm_add, |
| 3273 | av1_highbd_inv_txfm_add }; |
Angie Chiang | ad653a3 | 2017-07-31 15:30:58 -0700 | [diff] [blame] | 3274 | #endif |
Yi Luo | 5128109 | 2017-06-26 16:36:15 -0700 | [diff] [blame] | 3275 | |
Urvang Joshi | 0d1e4ff | 2017-04-27 16:17:25 -0700 | [diff] [blame] | 3276 | void av1_inverse_transform_block(const MACROBLOCKD *xd, |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 3277 | const tran_low_t *dqcoeff, |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 3278 | #if CONFIG_LGT_FROM_PRED |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 3279 | PREDICTION_MODE mode, |
| 3280 | #endif |
Sarah Parker | 99e7daa | 2017-08-29 10:30:13 -0700 | [diff] [blame] | 3281 | #if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK |
| 3282 | uint8_t *mrc_mask, |
| 3283 | #endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 3284 | #if CONFIG_EXT_TX |
| 3285 | int plane, |
| 3286 | #endif // CONFIG_EXT_TX |
Lester Lu | 708c1ec | 2017-06-14 14:54:49 -0700 | [diff] [blame] | 3287 | TX_TYPE tx_type, TX_SIZE tx_size, uint8_t *dst, |
| 3288 | int stride, int eob) { |
Angie Chiang | d92d4bf | 2017-04-02 17:49:18 -0700 | [diff] [blame] | 3289 | if (!eob) return; |
Yushin Cho | d0b77ac | 2017-10-20 17:33:16 -0700 | [diff] [blame] | 3290 | |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3291 | TxfmParam txfm_param; |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 3292 | init_txfm_param(xd, |
| 3293 | #if CONFIG_EXT_TX |
| 3294 | plane, |
| 3295 | #endif // CONFIG_EXT_TX |
| 3296 | tx_size, tx_type, eob, &txfm_param); |
Sarah Parker | 5b8e6d2 | 2017-07-24 15:30:53 -0700 | [diff] [blame] | 3297 | #if CONFIG_LGT || CONFIG_MRC_TX |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 3298 | txfm_param.is_inter = is_inter_block(&xd->mi[0]->mbmi); |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 3299 | #endif // CONFIG_LGT || CONFIG_MRC_TX |
Sarah Parker | 99e7daa | 2017-08-29 10:30:13 -0700 | [diff] [blame] | 3300 | #if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK |
| 3301 | txfm_param.mask = mrc_mask; |
| 3302 | #endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 3303 | #if CONFIG_LGT_FROM_PRED || CONFIG_MRC_TX |
| 3304 | txfm_param.dst = dst; |
| 3305 | txfm_param.stride = stride; |
| 3306 | #if CONFIG_LGT_FROM_PRED |
Sarah Parker | 5b8e6d2 | 2017-07-24 15:30:53 -0700 | [diff] [blame] | 3307 | txfm_param.mode = mode; |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 3308 | #endif // CONFIG_LGT_FROM_PRED |
| 3309 | #endif // CONFIG_LGT_FROM_PRED || CONFIG_MRC_TX |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 3310 | #if CONFIG_EXT_TX |
| 3311 | assert(av1_ext_tx_used[txfm_param.tx_set_type][txfm_param.tx_type]); |
| 3312 | #endif // CONFIG_EXT_TX |
Angie Chiang | d92d4bf | 2017-04-02 17:49:18 -0700 | [diff] [blame] | 3313 | |
Yi Luo | 5128109 | 2017-06-26 16:36:15 -0700 | [diff] [blame] | 3314 | const int is_hbd = get_bitdepth_data_path_index(xd); |
Angie Chiang | e3b604d | 2017-08-06 16:01:24 -0700 | [diff] [blame] | 3315 | #if CONFIG_TXMG |
| 3316 | if (is_hbd) { |
| 3317 | av1_highbd_inv_txfm_add(dqcoeff, dst, stride, &txfm_param); |
| 3318 | } else { |
| 3319 | DECLARE_ALIGNED(16, uint16_t, tmp[MAX_TX_SQUARE]); |
| 3320 | int tmp_stride = MAX_TX_SIZE; |
| 3321 | int w = tx_size_wide[tx_size]; |
| 3322 | int h = tx_size_high[tx_size]; |
| 3323 | for (int r = 0; r < h; ++r) { |
| 3324 | for (int c = 0; c < w; ++c) { |
| 3325 | tmp[r * tmp_stride + c] = dst[r * stride + c]; |
| 3326 | } |
| 3327 | } |
| 3328 | |
| 3329 | av1_highbd_inv_txfm_add(dqcoeff, CONVERT_TO_BYTEPTR(tmp), tmp_stride, |
| 3330 | &txfm_param); |
| 3331 | |
| 3332 | for (int r = 0; r < h; ++r) { |
| 3333 | for (int c = 0; c < w; ++c) { |
Debargha Mukherjee | 5c3b0f8 | 2017-10-08 09:38:15 -0700 | [diff] [blame] | 3334 | dst[r * stride + c] = (uint8_t)tmp[r * tmp_stride + c]; |
Angie Chiang | e3b604d | 2017-08-06 16:01:24 -0700 | [diff] [blame] | 3335 | } |
| 3336 | } |
| 3337 | } |
| 3338 | #else // CONFIG_TXMG |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3339 | inv_txfm_func[is_hbd](dqcoeff, dst, stride, &txfm_param); |
Angie Chiang | ad653a3 | 2017-07-31 15:30:58 -0700 | [diff] [blame] | 3340 | #endif // CONFIG_TXMG |
Angie Chiang | d92d4bf | 2017-04-02 17:49:18 -0700 | [diff] [blame] | 3341 | } |
| 3342 | |
Angie Chiang | bc2288c | 2017-04-09 15:41:17 -0700 | [diff] [blame] | 3343 | void av1_inverse_transform_block_facade(MACROBLOCKD *xd, int plane, int block, |
| 3344 | int blk_row, int blk_col, int eob) { |
| 3345 | struct macroblockd_plane *const pd = &xd->plane[plane]; |
| 3346 | tran_low_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block); |
Sarah Parker | 99e7daa | 2017-08-29 10:30:13 -0700 | [diff] [blame] | 3347 | #if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK |
| 3348 | uint8_t *mrc_mask = BLOCK_OFFSET(xd->mrc_mask, block); |
| 3349 | #endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK |
Angie Chiang | bc2288c | 2017-04-09 15:41:17 -0700 | [diff] [blame] | 3350 | const PLANE_TYPE plane_type = get_plane_type(plane); |
hui su | 0c6244b | 2017-07-12 17:11:43 -0700 | [diff] [blame] | 3351 | const TX_SIZE tx_size = av1_get_tx_size(plane, xd); |
Jingning Han | 19b5c8f | 2017-07-06 15:10:12 -0700 | [diff] [blame] | 3352 | const TX_TYPE tx_type = |
| 3353 | av1_get_tx_type(plane_type, xd, blk_row, blk_col, block, tx_size); |
Angie Chiang | bc2288c | 2017-04-09 15:41:17 -0700 | [diff] [blame] | 3354 | const int dst_stride = pd->dst.stride; |
| 3355 | uint8_t *dst = |
| 3356 | &pd->dst.buf[(blk_row * dst_stride + blk_col) << tx_size_wide_log2[0]]; |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 3357 | av1_inverse_transform_block(xd, dqcoeff, |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 3358 | #if CONFIG_LGT_FROM_PRED |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 3359 | xd->mi[0]->mbmi.mode, |
Lester Lu | 432012f | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 3360 | #endif // CONFIG_LGT_FROM_PRED |
Sarah Parker | 99e7daa | 2017-08-29 10:30:13 -0700 | [diff] [blame] | 3361 | #if CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK |
| 3362 | mrc_mask, |
| 3363 | #endif // CONFIG_MRC_TX && SIGNAL_ANY_MRC_MASK |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 3364 | #if CONFIG_EXT_TX |
| 3365 | plane, |
| 3366 | #endif // CONFIG_EXT_TX |
Lester Lu | 918fe69 | 2017-08-17 14:39:29 -0700 | [diff] [blame] | 3367 | tx_type, tx_size, dst, dst_stride, eob); |
Angie Chiang | bc2288c | 2017-04-09 15:41:17 -0700 | [diff] [blame] | 3368 | } |
| 3369 | |
hui su | bb9c73b | 2017-03-17 15:51:02 -0700 | [diff] [blame] | 3370 | void av1_highbd_inv_txfm_add(const tran_low_t *input, uint8_t *dest, int stride, |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3371 | TxfmParam *txfm_param) { |
| 3372 | const TX_SIZE tx_size = txfm_param->tx_size; |
Sarah Parker | 90024e4 | 2017-10-06 16:50:47 -0700 | [diff] [blame^] | 3373 | #if CONFIG_EXT_TX |
| 3374 | assert(av1_ext_tx_used[txfm_param->tx_set_type][txfm_param->tx_type]); |
| 3375 | #endif // CONFIG_EXT_TX |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3376 | switch (tx_size) { |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 3377 | #if CONFIG_TX64X64 |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3378 | case TX_64X64: |
| 3379 | highbd_inv_txfm_add_64x64(input, dest, stride, txfm_param); |
| 3380 | break; |
Debargha Mukherjee | 6a47cff | 2016-11-02 14:57:42 -0700 | [diff] [blame] | 3381 | #endif // CONFIG_TX64X64 |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3382 | case TX_32X32: |
| 3383 | highbd_inv_txfm_add_32x32(input, dest, stride, txfm_param); |
| 3384 | break; |
| 3385 | case TX_16X16: |
| 3386 | highbd_inv_txfm_add_16x16(input, dest, stride, txfm_param); |
| 3387 | break; |
| 3388 | case TX_8X8: |
| 3389 | highbd_inv_txfm_add_8x8(input, dest, stride, txfm_param); |
| 3390 | break; |
| 3391 | case TX_4X8: |
| 3392 | av1_highbd_inv_txfm_add_4x8(input, dest, stride, txfm_param); |
| 3393 | break; |
| 3394 | case TX_8X4: |
| 3395 | av1_highbd_inv_txfm_add_8x4(input, dest, stride, txfm_param); |
| 3396 | break; |
| 3397 | case TX_8X16: |
| 3398 | highbd_inv_txfm_add_8x16(input, dest, stride, txfm_param); |
| 3399 | break; |
| 3400 | case TX_16X8: |
| 3401 | highbd_inv_txfm_add_16x8(input, dest, stride, txfm_param); |
| 3402 | break; |
| 3403 | case TX_16X32: |
| 3404 | highbd_inv_txfm_add_16x32(input, dest, stride, txfm_param); |
| 3405 | break; |
| 3406 | case TX_32X16: |
| 3407 | highbd_inv_txfm_add_32x16(input, dest, stride, txfm_param); |
| 3408 | break; |
Debargha Mukherjee | 2b43501 | 2017-09-28 08:30:35 -0700 | [diff] [blame] | 3409 | #if CONFIG_TX64X64 |
| 3410 | case TX_64X32: |
| 3411 | highbd_inv_txfm_add_64x32(input, dest, stride, txfm_param); |
| 3412 | break; |
| 3413 | case TX_32X64: |
| 3414 | highbd_inv_txfm_add_32x64(input, dest, stride, txfm_param); |
| 3415 | break; |
| 3416 | #endif // CONFIG_TX64X64 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3417 | case TX_4X4: |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 3418 | // 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] | 3419 | // which is significant (not just an optimization) for the lossless |
| 3420 | // case. |
Lester Lu | 27319b6 | 2017-07-10 16:57:15 -0700 | [diff] [blame] | 3421 | av1_highbd_inv_txfm_add_4x4(input, dest, stride, txfm_param); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3422 | break; |
| 3423 | default: assert(0 && "Invalid transform size"); break; |
| 3424 | } |
| 3425 | } |