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