idct.c 67.8 KB
Newer Older
Jingning Han's avatar
Jingning Han committed
1
/*
Yaowu Xu's avatar
Yaowu Xu committed
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Jingning Han's avatar
Jingning Han committed
3
 *
Yaowu Xu's avatar
Yaowu Xu committed
4 5 6 7 8 9
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
Jingning Han's avatar
Jingning Han committed
10 11 12 13
 */

#include <math.h>

Yaowu Xu's avatar
Yaowu Xu committed
14
#include "./aom_dsp_rtcd.h"
Geza Lore's avatar
Geza Lore committed
15 16 17
#include "./av1_rtcd.h"
#include "aom_dsp/inv_txfm.h"
#include "aom_ports/mem.h"
18
#include "av1/common/av1_inv_txfm1d_cfg.h"
19 20 21
#include "av1/common/blockd.h"
#include "av1/common/enums.h"
#include "av1/common/idct.h"
Jingning Han's avatar
Jingning Han committed
22

23
int av1_get_tx_scale(const TX_SIZE tx_size) {
24 25 26 27 28 29 30
  if (txsize_sqr_up_map[tx_size] == TX_32X32) return 1;
#if CONFIG_TX64X64
  else if (txsize_sqr_up_map[tx_size] == TX_64X64)
    return 2;
#endif  // CONFIG_TX64X64
  else
    return 0;
31 32
}

33 34 35
// NOTE: The implementation of all inverses need to be aware of the fact
// that input and output could be the same buffer.

36
#if CONFIG_EXT_TX
Debargha Mukherjee's avatar
Debargha Mukherjee committed
37 38 39 40 41 42 43 44
static void iidtx4_c(const tran_low_t *input, tran_low_t *output) {
  int i;
  for (i = 0; i < 4; ++i)
    output[i] = (tran_low_t)dct_const_round_shift(input[i] * Sqrt2);
}

static void iidtx8_c(const tran_low_t *input, tran_low_t *output) {
  int i;
clang-format's avatar
clang-format committed
45
  for (i = 0; i < 8; ++i) output[i] = input[i] * 2;
Debargha Mukherjee's avatar
Debargha Mukherjee committed
46 47 48 49 50 51 52 53 54 55
}

static void iidtx16_c(const tran_low_t *input, tran_low_t *output) {
  int i;
  for (i = 0; i < 16; ++i)
    output[i] = (tran_low_t)dct_const_round_shift(input[i] * 2 * Sqrt2);
}

static void iidtx32_c(const tran_low_t *input, tran_low_t *output) {
  int i;
clang-format's avatar
clang-format committed
56
  for (i = 0; i < 32; ++i) output[i] = input[i] * 4;
Debargha Mukherjee's avatar
Debargha Mukherjee committed
57
}
58 59 60 61 62 63 64 65

#if CONFIG_TX64X64
static void iidtx64_c(const tran_low_t *input, tran_low_t *output) {
  int i;
  for (i = 0; i < 64; ++i)
    output[i] = (tran_low_t)dct_const_round_shift(input[i] * 4 * Sqrt2);
}
#endif  // CONFIG_TX64X64
66
#endif  // CONFIG_EXT_TX
Debargha Mukherjee's avatar
Debargha Mukherjee committed
67

68
// For use in lieu of ADST
69 70 71 72 73 74 75
static void ihalfright32_c(const tran_low_t *input, tran_low_t *output) {
  int i;
  tran_low_t inputhalf[16];
  // Multiply input by sqrt(2)
  for (i = 0; i < 16; ++i) {
    inputhalf[i] = (tran_low_t)dct_const_round_shift(input[i] * Sqrt2);
  }
76 77 78
  for (i = 0; i < 16; ++i) {
    output[i] = input[16 + i] * 4;
  }
Luca Barbato's avatar
Luca Barbato committed
79
  aom_idct16_c(inputhalf, output + 16);
80 81 82
  // Note overall scaling factor is 4 times orthogonal
}

83 84 85 86 87
#if CONFIG_TX64X64
static void idct64_col_c(const tran_low_t *input, tran_low_t *output) {
  int32_t in[64], out[64];
  int i;
  for (i = 0; i < 64; ++i) in[i] = (int32_t)input[i];
88
  av1_idct64_new(in, out, inv_cos_bit_col_dct_64, inv_stage_range_col_dct_64);
89 90 91 92 93 94 95
  for (i = 0; i < 64; ++i) output[i] = (tran_low_t)out[i];
}

static void idct64_row_c(const tran_low_t *input, tran_low_t *output) {
  int32_t in[64], out[64];
  int i;
  for (i = 0; i < 64; ++i) in[i] = (int32_t)input[i];
96
  av1_idct64_new(in, out, inv_cos_bit_row_dct_64, inv_stage_range_row_dct_64);
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
  for (i = 0; i < 64; ++i) output[i] = (tran_low_t)out[i];
}

// For use in lieu of ADST
static void ihalfright64_c(const tran_low_t *input, tran_low_t *output) {
  int i;
  tran_low_t inputhalf[32];
  // Multiply input by sqrt(2)
  for (i = 0; i < 32; ++i) {
    inputhalf[i] = (tran_low_t)dct_const_round_shift(input[i] * Sqrt2);
  }
  for (i = 0; i < 32; ++i) {
    output[i] = (tran_low_t)dct_const_round_shift(input[32 + i] * 4 * Sqrt2);
  }
  aom_idct32_c(inputhalf, output + 32);
  // Note overall scaling factor is 4 * sqrt(2)  times orthogonal
}
#endif  // CONFIG_TX64X64

Jingning Han's avatar
Jingning Han committed
116
// Inverse identity transform and add.
117
#if CONFIG_EXT_TX
118
static void inv_idtx_add_c(const tran_low_t *input, uint8_t *dest, int stride,
Jingning Han's avatar
Jingning Han committed
119
                           int bs, int tx_type) {
120
  int r, c;
121
  const int shift = bs < 32 ? 3 : (bs < 64 ? 2 : 1);
Debargha Mukherjee's avatar
Debargha Mukherjee committed
122
  if (tx_type == IDTX) {
Jingning Han's avatar
Jingning Han committed
123 124
    for (r = 0; r < bs; ++r) {
      for (c = 0; c < bs; ++c)
Debargha Mukherjee's avatar
Debargha Mukherjee committed
125 126 127
        dest[c] = clip_pixel_add(dest[c], input[c] >> shift);
      dest += stride;
      input += bs;
Jingning Han's avatar
Jingning Han committed
128
    }
129 130
  }
}
131
#endif  // CONFIG_EXT_TX
132

clang-format's avatar
clang-format committed
133 134 135 136 137
#define FLIPUD_PTR(dest, stride, size)       \
  do {                                       \
    (dest) = (dest) + ((size)-1) * (stride); \
    (stride) = -(stride);                    \
  } while (0)
138

139
#if CONFIG_EXT_TX
clang-format's avatar
clang-format committed
140 141 142
static void maybe_flip_strides(uint8_t **dst, int *dstride, tran_low_t **src,
                               int *sstride, int tx_type, int sizey,
                               int sizex) {
143 144 145 146 147 148 149 150
  // Note that the transpose of src will be added to dst. In order to LR
  // flip the addends (in dst coordinates), we UD flip the src. To UD flip
  // the addends, we UD flip the dst.
  switch (tx_type) {
    case DCT_DCT:
    case ADST_DCT:
    case DCT_ADST:
    case ADST_ADST:
Debargha Mukherjee's avatar
Debargha Mukherjee committed
151
    case IDTX:
Jingning Han's avatar
Jingning Han committed
152 153
    case V_DCT:
    case H_DCT:
154
    case V_ADST:
clang-format's avatar
clang-format committed
155
    case H_ADST: break;
156 157
    case FLIPADST_DCT:
    case FLIPADST_ADST:
158
    case V_FLIPADST:
159
      // flip UD
160
      FLIPUD_PTR(*dst, *dstride, sizey);
161 162 163
      break;
    case DCT_FLIPADST:
    case ADST_FLIPADST:
164
    case H_FLIPADST:
165
      // flip LR
166
      FLIPUD_PTR(*src, *sstride, sizex);
167 168 169
      break;
    case FLIPADST_FLIPADST:
      // flip UD
170
      FLIPUD_PTR(*dst, *dstride, sizey);
171
      // flip LR
172
      FLIPUD_PTR(*src, *sstride, sizex);
173
      break;
clang-format's avatar
clang-format committed
174
    default: assert(0); break;
175 176
  }
}
177
#endif  // CONFIG_EXT_TX
178

179
#if CONFIG_HIGHBITDEPTH
180
#if CONFIG_EXT_TX && CONFIG_TX64X64
181
static void highbd_inv_idtx_add_c(const tran_low_t *input, uint8_t *dest8,
182
                                  int stride, int bs, int tx_type, int bd) {
183 184 185
  int r, c;
  const int shift = bs < 32 ? 3 : 2;
  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
186

Debargha Mukherjee's avatar
Debargha Mukherjee committed
187
  if (tx_type == IDTX) {
188 189
    for (r = 0; r < bs; ++r) {
      for (c = 0; c < bs; ++c)
Debargha Mukherjee's avatar
Debargha Mukherjee committed
190 191 192
        dest[c] = highbd_clip_pixel_add(dest[c], input[c] >> shift, bd);
      dest += stride;
      input += bs;
193
    }
194 195
  }
}
196
#endif  // CONFIG_EXT_TX && CONFIG_TX64X64
197
#endif  // CONFIG_HIGHBITDEPTH
198

Yaowu Xu's avatar
Yaowu Xu committed
199 200
void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                         int tx_type) {
201
  static const transform_2d IHT_4[] = {
Luca Barbato's avatar
Luca Barbato committed
202 203 204 205
    { aom_idct4_c, aom_idct4_c },    // DCT_DCT  = 0
    { aom_iadst4_c, aom_idct4_c },   // ADST_DCT = 1
    { aom_idct4_c, aom_iadst4_c },   // DCT_ADST = 2
    { aom_iadst4_c, aom_iadst4_c },  // ADST_ADST = 3
206
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
207 208 209 210 211 212 213 214 215 216 217 218 219
    { aom_iadst4_c, aom_idct4_c },   // FLIPADST_DCT
    { aom_idct4_c, aom_iadst4_c },   // DCT_FLIPADST
    { aom_iadst4_c, aom_iadst4_c },  // FLIPADST_FLIPADST
    { aom_iadst4_c, aom_iadst4_c },  // ADST_FLIPADST
    { aom_iadst4_c, aom_iadst4_c },  // FLIPADST_ADST
    { iidtx4_c, iidtx4_c },          // IDTX
    { aom_idct4_c, iidtx4_c },       // V_DCT
    { iidtx4_c, aom_idct4_c },       // H_DCT
    { aom_iadst4_c, iidtx4_c },      // V_ADST
    { iidtx4_c, aom_iadst4_c },      // H_ADST
    { aom_iadst4_c, iidtx4_c },      // V_FLIPADST
    { iidtx4_c, aom_iadst4_c },      // H_FLIPADST
#endif                               // CONFIG_EXT_TX
220 221 222
  };

  int i, j;
223
  tran_low_t tmp[4][4];
224 225 226
  tran_low_t out[4][4];
  tran_low_t *outp = &out[0][0];
  int outstride = 4;
227 228 229

  // inverse transform row vectors
  for (i = 0; i < 4; ++i) {
230
    IHT_4[tx_type].rows(input, out[i]);
clang-format's avatar
clang-format committed
231
    input += 4;
232 233 234
  }

  // transpose
235 236 237
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      tmp[j][i] = out[i][j];
238
    }
239 240 241 242
  }

  // inverse transform column vectors
  for (i = 0; i < 4; ++i) {
243
    IHT_4[tx_type].cols(tmp[i], out[i]);
244 245 246
  }

#if CONFIG_EXT_TX
247
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 4, 4);
248 249 250 251
#endif

  // Sum with the destination
  for (i = 0; i < 4; ++i) {
252
    for (j = 0; j < 4; ++j) {
253 254 255
      int d = i * stride + j;
      int s = j * outstride + i;
      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 4));
256 257 258 259
    }
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
260 261
void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                         int tx_type) {
262
  static const transform_2d IHT_4x8[] = {
Luca Barbato's avatar
Luca Barbato committed
263 264 265 266
    { aom_idct8_c, aom_idct4_c },    // DCT_DCT
    { aom_iadst8_c, aom_idct4_c },   // ADST_DCT
    { aom_idct8_c, aom_iadst4_c },   // DCT_ADST
    { aom_iadst8_c, aom_iadst4_c },  // ADST_ADST
267
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
268 269 270 271 272 273 274 275 276 277 278 279
    { aom_iadst8_c, aom_idct4_c },   // FLIPADST_DCT
    { aom_idct8_c, aom_iadst4_c },   // DCT_FLIPADST
    { aom_iadst8_c, aom_iadst4_c },  // FLIPADST_FLIPADST
    { aom_iadst8_c, aom_iadst4_c },  // ADST_FLIPADST
    { aom_iadst8_c, aom_iadst4_c },  // FLIPADST_ADST
    { iidtx8_c, iidtx4_c },          // IDTX
    { aom_idct8_c, iidtx4_c },       // V_DCT
    { iidtx8_c, aom_idct4_c },       // H_DCT
    { aom_iadst8_c, iidtx4_c },      // V_ADST
    { iidtx8_c, aom_iadst4_c },      // H_ADST
    { aom_iadst8_c, iidtx4_c },      // V_FLIPADST
    { iidtx8_c, aom_iadst4_c },      // H_FLIPADST
280
#endif
281 282
  };

283 284
  const int n = 4;
  const int n2 = 8;
285
  int i, j;
286
  tran_low_t out[4][8], tmp[4][8], outtmp[4];
287
  tran_low_t *outp = &out[0][0];
288
  int outstride = n2;
289 290

  // inverse transform row vectors and transpose
291
  for (i = 0; i < n2; ++i) {
292
    IHT_4x8[tx_type].rows(input, outtmp);
293
    for (j = 0; j < n; ++j)
294
      tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
295
    input += n;
296 297 298
  }

  // inverse transform column vectors
299
  for (i = 0; i < n; ++i) {
300
    IHT_4x8[tx_type].cols(tmp[i], out[i]);
301 302
  }

303
#if CONFIG_EXT_TX
304
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n);
305
#endif
306 307

  // Sum with the destination
308 309
  for (i = 0; i < n2; ++i) {
    for (j = 0; j < n; ++j) {
310 311 312 313 314 315 316
      int d = i * stride + j;
      int s = j * outstride + i;
      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5));
    }
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
317 318
void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                         int tx_type) {
319
  static const transform_2d IHT_8x4[] = {
Luca Barbato's avatar
Luca Barbato committed
320 321 322 323
    { aom_idct4_c, aom_idct8_c },    // DCT_DCT
    { aom_iadst4_c, aom_idct8_c },   // ADST_DCT
    { aom_idct4_c, aom_iadst8_c },   // DCT_ADST
    { aom_iadst4_c, aom_iadst8_c },  // ADST_ADST
324
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
325 326 327 328 329 330 331 332 333 334 335 336
    { aom_iadst4_c, aom_idct8_c },   // FLIPADST_DCT
    { aom_idct4_c, aom_iadst8_c },   // DCT_FLIPADST
    { aom_iadst4_c, aom_iadst8_c },  // FLIPADST_FLIPADST
    { aom_iadst4_c, aom_iadst8_c },  // ADST_FLIPADST
    { aom_iadst4_c, aom_iadst8_c },  // FLIPADST_ADST
    { iidtx4_c, iidtx8_c },          // IDTX
    { aom_idct4_c, iidtx8_c },       // V_DCT
    { iidtx4_c, aom_idct8_c },       // H_DCT
    { aom_iadst4_c, iidtx8_c },      // V_ADST
    { iidtx4_c, aom_iadst8_c },      // H_ADST
    { aom_iadst4_c, iidtx8_c },      // V_FLIPADST
    { iidtx4_c, aom_iadst8_c },      // H_FLIPADST
337
#endif
338
  };
339 340
  const int n = 4;
  const int n2 = 8;
341 342

  int i, j;
343
  tran_low_t out[8][4], tmp[8][4], outtmp[8];
344
  tran_low_t *outp = &out[0][0];
345
  int outstride = n;
346 347

  // inverse transform row vectors and transpose
348
  for (i = 0; i < n; ++i) {
349
    IHT_8x4[tx_type].rows(input, outtmp);
350
    for (j = 0; j < n2; ++j)
351
      tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
352
    input += n2;
353 354 355
  }

  // inverse transform column vectors
356
  for (i = 0; i < n2; ++i) {
357
    IHT_8x4[tx_type].cols(tmp[i], out[i]);
358 359
  }

360
#if CONFIG_EXT_TX
361
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2);
362
#endif
363 364

  // Sum with the destination
365 366
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n2; ++j) {
367 368 369 370 371 372 373
      int d = i * stride + j;
      int s = j * outstride + i;
      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5));
    }
  }
}

374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                          int tx_type) {
  static const transform_2d IHT_4x16[] = {
    { aom_idct16_c, aom_idct4_c },    // DCT_DCT
    { aom_iadst16_c, aom_idct4_c },   // ADST_DCT
    { aom_idct16_c, aom_iadst4_c },   // DCT_ADST
    { aom_iadst16_c, aom_iadst4_c },  // ADST_ADST
#if CONFIG_EXT_TX
    { aom_iadst16_c, aom_idct4_c },   // FLIPADST_DCT
    { aom_idct16_c, aom_iadst4_c },   // DCT_FLIPADST
    { aom_iadst16_c, aom_iadst4_c },  // FLIPADST_FLIPADST
    { aom_iadst16_c, aom_iadst4_c },  // ADST_FLIPADST
    { aom_iadst16_c, aom_iadst4_c },  // FLIPADST_ADST
    { iidtx16_c, iidtx4_c },          // IDTX
    { aom_idct16_c, iidtx4_c },       // V_DCT
    { iidtx16_c, aom_idct4_c },       // H_DCT
    { aom_iadst16_c, iidtx4_c },      // V_ADST
    { iidtx16_c, aom_iadst4_c },      // H_ADST
    { aom_iadst16_c, iidtx4_c },      // V_FLIPADST
    { iidtx16_c, aom_iadst4_c },      // H_FLIPADST
#endif
  };

  const int n = 4;
  const int n4 = 16;
  int i, j;
400
  tran_low_t out[4][16], tmp[4][16], outtmp[4];
401 402 403 404 405 406
  tran_low_t *outp = &out[0][0];
  int outstride = n4;

  // inverse transform row vectors and transpose
  for (i = 0; i < n4; ++i) {
    IHT_4x16[tx_type].rows(input, outtmp);
407
    for (j = 0; j < n; ++j) tmp[j][i] = outtmp[j];
408 409 410 411
    input += n;
  }

  // inverse transform column vectors
412
  for (i = 0; i < n; ++i) IHT_4x16[tx_type].cols(tmp[i], out[i]);
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453

#if CONFIG_EXT_TX
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n4, n);
#endif

  // Sum with the destination
  for (i = 0; i < n4; ++i) {
    for (j = 0; j < n; ++j) {
      int d = i * stride + j;
      int s = j * outstride + i;
      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5));
    }
  }
}

void av1_iht16x4_64_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                          int tx_type) {
  static const transform_2d IHT_16x4[] = {
    { aom_idct4_c, aom_idct16_c },    // DCT_DCT
    { aom_iadst4_c, aom_idct16_c },   // ADST_DCT
    { aom_idct4_c, aom_iadst16_c },   // DCT_ADST
    { aom_iadst4_c, aom_iadst16_c },  // ADST_ADST
#if CONFIG_EXT_TX
    { aom_iadst4_c, aom_idct16_c },   // FLIPADST_DCT
    { aom_idct4_c, aom_iadst16_c },   // DCT_FLIPADST
    { aom_iadst4_c, aom_iadst16_c },  // FLIPADST_FLIPADST
    { aom_iadst4_c, aom_iadst16_c },  // ADST_FLIPADST
    { aom_iadst4_c, aom_iadst16_c },  // FLIPADST_ADST
    { iidtx4_c, iidtx16_c },          // IDTX
    { aom_idct4_c, iidtx16_c },       // V_DCT
    { iidtx4_c, aom_idct16_c },       // H_DCT
    { aom_iadst4_c, iidtx16_c },      // V_ADST
    { iidtx4_c, aom_iadst16_c },      // H_ADST
    { aom_iadst4_c, iidtx16_c },      // V_FLIPADST
    { iidtx4_c, aom_iadst16_c },      // H_FLIPADST
#endif
  };
  const int n = 4;
  const int n4 = 16;

  int i, j;
454
  tran_low_t out[16][4], tmp[16][4], outtmp[16];
455 456 457 458 459 460
  tran_low_t *outp = &out[0][0];
  int outstride = n;

  // inverse transform row vectors and transpose
  for (i = 0; i < n; ++i) {
    IHT_16x4[tx_type].rows(input, outtmp);
461
    for (j = 0; j < n4; ++j) tmp[j][i] = outtmp[j];
462 463 464 465
    input += n4;
  }

  // inverse transform column vectors
466
  for (i = 0; i < n4; ++i) IHT_16x4[tx_type].cols(tmp[i], out[i]);
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481

#if CONFIG_EXT_TX
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n4);
#endif

  // Sum with the destination
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n4; ++j) {
      int d = i * stride + j;
      int s = j * outstride + i;
      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5));
    }
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
482 483
void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                           int tx_type) {
484
  static const transform_2d IHT_8x16[] = {
Luca Barbato's avatar
Luca Barbato committed
485 486 487 488
    { aom_idct16_c, aom_idct8_c },    // DCT_DCT
    { aom_iadst16_c, aom_idct8_c },   // ADST_DCT
    { aom_idct16_c, aom_iadst8_c },   // DCT_ADST
    { aom_iadst16_c, aom_iadst8_c },  // ADST_ADST
489
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
490 491 492 493 494 495 496 497 498 499 500 501
    { aom_iadst16_c, aom_idct8_c },   // FLIPADST_DCT
    { aom_idct16_c, aom_iadst8_c },   // DCT_FLIPADST
    { aom_iadst16_c, aom_iadst8_c },  // FLIPADST_FLIPADST
    { aom_iadst16_c, aom_iadst8_c },  // ADST_FLIPADST
    { aom_iadst16_c, aom_iadst8_c },  // FLIPADST_ADST
    { iidtx16_c, iidtx8_c },          // IDTX
    { aom_idct16_c, iidtx8_c },       // V_DCT
    { iidtx16_c, aom_idct8_c },       // H_DCT
    { aom_iadst16_c, iidtx8_c },      // V_ADST
    { iidtx16_c, aom_iadst8_c },      // H_ADST
    { aom_iadst16_c, iidtx8_c },      // V_FLIPADST
    { iidtx16_c, aom_iadst8_c },      // H_FLIPADST
502
#endif
503 504 505 506 507
  };

  const int n = 8;
  const int n2 = 16;
  int i, j;
508
  tran_low_t out[8][16], tmp[8][16], outtmp[8];
509 510 511 512 513 514 515
  tran_low_t *outp = &out[0][0];
  int outstride = n2;

  // inverse transform row vectors and transpose
  for (i = 0; i < n2; ++i) {
    IHT_8x16[tx_type].rows(input, outtmp);
    for (j = 0; j < n; ++j)
516
      tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
clang-format's avatar
clang-format committed
517
    input += n;
518 519 520 521
  }

  // inverse transform column vectors
  for (i = 0; i < n; ++i) {
522
    IHT_8x16[tx_type].cols(tmp[i], out[i]);
523 524
  }

525
#if CONFIG_EXT_TX
526
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n);
527
#endif
528 529 530 531 532 533 534 535 536 537 538

  // Sum with the destination
  for (i = 0; i < n2; ++i) {
    for (j = 0; j < n; ++j) {
      int d = i * stride + j;
      int s = j * outstride + i;
      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6));
    }
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
539 540
void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                           int tx_type) {
541
  static const transform_2d IHT_16x8[] = {
Luca Barbato's avatar
Luca Barbato committed
542 543 544 545
    { aom_idct8_c, aom_idct16_c },    // DCT_DCT
    { aom_iadst8_c, aom_idct16_c },   // ADST_DCT
    { aom_idct8_c, aom_iadst16_c },   // DCT_ADST
    { aom_iadst8_c, aom_iadst16_c },  // ADST_ADST
546
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
547 548 549 550 551 552 553 554 555 556 557 558
    { aom_iadst8_c, aom_idct16_c },   // FLIPADST_DCT
    { aom_idct8_c, aom_iadst16_c },   // DCT_FLIPADST
    { aom_iadst8_c, aom_iadst16_c },  // FLIPADST_FLIPADST
    { aom_iadst8_c, aom_iadst16_c },  // ADST_FLIPADST
    { aom_iadst8_c, aom_iadst16_c },  // FLIPADST_ADST
    { iidtx8_c, iidtx16_c },          // IDTX
    { aom_idct8_c, iidtx16_c },       // V_DCT
    { iidtx8_c, aom_idct16_c },       // H_DCT
    { aom_iadst8_c, iidtx16_c },      // V_ADST
    { iidtx8_c, aom_iadst16_c },      // H_ADST
    { aom_iadst8_c, iidtx16_c },      // V_FLIPADST
    { iidtx8_c, aom_iadst16_c },      // H_FLIPADST
559
#endif
560 561 562 563 564
  };
  const int n = 8;
  const int n2 = 16;

  int i, j;
565
  tran_low_t out[16][8], tmp[16][8], outtmp[16];
566 567 568 569 570 571 572
  tran_low_t *outp = &out[0][0];
  int outstride = n;

  // inverse transform row vectors and transpose
  for (i = 0; i < n; ++i) {
    IHT_16x8[tx_type].rows(input, outtmp);
    for (j = 0; j < n2; ++j)
573
      tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
clang-format's avatar
clang-format committed
574
    input += n2;
575 576 577 578
  }

  // inverse transform column vectors
  for (i = 0; i < n2; ++i) {
579
    IHT_16x8[tx_type].cols(tmp[i], out[i]);
580 581
  }

582
#if CONFIG_EXT_TX
583
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2);
584
#endif
585 586 587 588 589 590 591 592 593 594 595

  // Sum with the destination
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n2; ++j) {
      int d = i * stride + j;
      int s = j * outstride + i;
      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6));
    }
  }
}

596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621
void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                           int tx_type) {
  static const transform_2d IHT_8x32[] = {
    { aom_idct32_c, aom_idct8_c },     // DCT_DCT
    { ihalfright32_c, aom_idct8_c },   // ADST_DCT
    { aom_idct32_c, aom_iadst8_c },    // DCT_ADST
    { ihalfright32_c, aom_iadst8_c },  // ADST_ADST
#if CONFIG_EXT_TX
    { ihalfright32_c, aom_idct8_c },   // FLIPADST_DCT
    { aom_idct32_c, aom_iadst8_c },    // DCT_FLIPADST
    { ihalfright32_c, aom_iadst8_c },  // FLIPADST_FLIPADST
    { ihalfright32_c, aom_iadst8_c },  // ADST_FLIPADST
    { ihalfright32_c, aom_iadst8_c },  // FLIPADST_ADST
    { iidtx32_c, iidtx8_c },           // IDTX
    { aom_idct32_c, iidtx8_c },        // V_DCT
    { iidtx32_c, aom_idct8_c },        // H_DCT
    { ihalfright32_c, iidtx8_c },      // V_ADST
    { iidtx32_c, aom_iadst8_c },       // H_ADST
    { ihalfright32_c, iidtx8_c },      // V_FLIPADST
    { iidtx32_c, aom_iadst8_c },       // H_FLIPADST
#endif
  };

  const int n = 8;
  const int n4 = 32;
  int i, j;
622
  tran_low_t out[8][32], tmp[8][32], outtmp[8];
623 624 625 626 627 628
  tran_low_t *outp = &out[0][0];
  int outstride = n4;

  // inverse transform row vectors and transpose
  for (i = 0; i < n4; ++i) {
    IHT_8x32[tx_type].rows(input, outtmp);
629
    for (j = 0; j < n; ++j) tmp[j][i] = outtmp[j];
630 631 632 633
    input += n;
  }

  // inverse transform column vectors
634
  for (i = 0; i < n; ++i) IHT_8x32[tx_type].cols(tmp[i], out[i]);
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675

#if CONFIG_EXT_TX
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n4, n);
#endif

  // Sum with the destination
  for (i = 0; i < n4; ++i) {
    for (j = 0; j < n; ++j) {
      int d = i * stride + j;
      int s = j * outstride + i;
      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6));
    }
  }
}

void av1_iht32x8_256_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                           int tx_type) {
  static const transform_2d IHT_32x8[] = {
    { aom_idct8_c, aom_idct32_c },     // DCT_DCT
    { aom_iadst8_c, aom_idct32_c },    // ADST_DCT
    { aom_idct8_c, ihalfright32_c },   // DCT_ADST
    { aom_iadst8_c, ihalfright32_c },  // ADST_ADST
#if CONFIG_EXT_TX
    { aom_iadst8_c, aom_idct32_c },    // FLIPADST_DCT
    { aom_idct8_c, ihalfright32_c },   // DCT_FLIPADST
    { aom_iadst8_c, ihalfright32_c },  // FLIPADST_FLIPADST
    { aom_iadst8_c, ihalfright32_c },  // ADST_FLIPADST
    { aom_iadst8_c, ihalfright32_c },  // FLIPADST_ADST
    { iidtx8_c, iidtx32_c },           // IDTX
    { aom_idct8_c, iidtx32_c },        // V_DCT
    { iidtx8_c, aom_idct32_c },        // H_DCT
    { aom_iadst8_c, iidtx32_c },       // V_ADST
    { iidtx8_c, ihalfright32_c },      // H_ADST
    { aom_iadst8_c, iidtx32_c },       // V_FLIPADST
    { iidtx8_c, ihalfright32_c },      // H_FLIPADST
#endif
  };
  const int n = 8;
  const int n4 = 32;

  int i, j;
676
  tran_low_t out[32][8], tmp[32][8], outtmp[32];
677 678 679 680 681 682
  tran_low_t *outp = &out[0][0];
  int outstride = n;

  // inverse transform row vectors and transpose
  for (i = 0; i < n; ++i) {
    IHT_32x8[tx_type].rows(input, outtmp);
683
    for (j = 0; j < n4; ++j) tmp[j][i] = outtmp[j];
684 685 686 687
    input += n4;
  }

  // inverse transform column vectors
688
  for (i = 0; i < n4; ++i) IHT_32x8[tx_type].cols(tmp[i], out[i]);
689 690 691 692 693 694 695 696 697 698 699 700 701 702 703

#if CONFIG_EXT_TX
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n4);
#endif

  // Sum with the destination
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n4; ++j) {
      int d = i * stride + j;
      int s = j * outstride + i;
      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6));
    }
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
704 705
void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                            int tx_type) {
706
  static const transform_2d IHT_16x32[] = {
Luca Barbato's avatar
Luca Barbato committed
707 708 709 710
    { aom_idct32_c, aom_idct16_c },     // DCT_DCT
    { ihalfright32_c, aom_idct16_c },   // ADST_DCT
    { aom_idct32_c, aom_iadst16_c },    // DCT_ADST
    { ihalfright32_c, aom_iadst16_c },  // ADST_ADST
711
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
712 713 714 715 716 717 718 719 720 721 722 723
    { ihalfright32_c, aom_idct16_c },   // FLIPADST_DCT
    { aom_idct32_c, aom_iadst16_c },    // DCT_FLIPADST
    { ihalfright32_c, aom_iadst16_c },  // FLIPADST_FLIPADST
    { ihalfright32_c, aom_iadst16_c },  // ADST_FLIPADST
    { ihalfright32_c, aom_iadst16_c },  // FLIPADST_ADST
    { iidtx32_c, iidtx16_c },           // IDTX
    { aom_idct32_c, iidtx16_c },        // V_DCT
    { iidtx32_c, aom_idct16_c },        // H_DCT
    { ihalfright32_c, iidtx16_c },      // V_ADST
    { iidtx32_c, aom_iadst16_c },       // H_ADST
    { ihalfright32_c, iidtx16_c },      // V_FLIPADST
    { iidtx32_c, aom_iadst16_c },       // H_FLIPADST
724
#endif
725 726 727 728 729
  };

  const int n = 16;
  const int n2 = 32;
  int i, j;
730
  tran_low_t out[16][32], tmp[16][32], outtmp[16];
731 732 733 734 735 736 737
  tran_low_t *outp = &out[0][0];
  int outstride = n2;

  // inverse transform row vectors and transpose
  for (i = 0; i < n2; ++i) {
    IHT_16x32[tx_type].rows(input, outtmp);
    for (j = 0; j < n; ++j)
738
      tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
clang-format's avatar
clang-format committed
739
    input += n;
740 741 742 743
  }

  // inverse transform column vectors
  for (i = 0; i < n; ++i) {
744
    IHT_16x32[tx_type].cols(tmp[i], out[i]);
745 746
  }

747
#if CONFIG_EXT_TX
748
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n);
749
#endif
750 751 752 753 754 755 756 757 758 759 760

  // Sum with the destination
  for (i = 0; i < n2; ++i) {
    for (j = 0; j < n; ++j) {
      int d = i * stride + j;
      int s = j * outstride + i;
      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6));
    }
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
761 762
void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                            int tx_type) {
763
  static const transform_2d IHT_32x16[] = {
Luca Barbato's avatar
Luca Barbato committed
764 765 766 767
    { aom_idct16_c, aom_idct32_c },     // DCT_DCT
    { aom_iadst16_c, aom_idct32_c },    // ADST_DCT
    { aom_idct16_c, ihalfright32_c },   // DCT_ADST
    { aom_iadst16_c, ihalfright32_c },  // ADST_ADST
768
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
769 770 771 772 773 774 775 776 777 778 779 780
    { aom_iadst16_c, aom_idct32_c },    // FLIPADST_DCT
    { aom_idct16_c, ihalfright32_c },   // DCT_FLIPADST
    { aom_iadst16_c, ihalfright32_c },  // FLIPADST_FLIPADST
    { aom_iadst16_c, ihalfright32_c },  // ADST_FLIPADST
    { aom_iadst16_c, ihalfright32_c },  // FLIPADST_ADST
    { iidtx16_c, iidtx32_c },           // IDTX
    { aom_idct16_c, iidtx32_c },        // V_DCT
    { iidtx16_c, aom_idct32_c },        // H_DCT
    { aom_iadst16_c, iidtx32_c },       // V_ADST
    { iidtx16_c, ihalfright32_c },      // H_ADST
    { aom_iadst16_c, iidtx32_c },       // V_FLIPADST
    { iidtx16_c, ihalfright32_c },      // H_FLIPADST
781
#endif
782 783 784 785 786
  };
  const int n = 16;
  const int n2 = 32;

  int i, j;
787
  tran_low_t out[32][16], tmp[32][16], outtmp[32];
788 789 790 791 792 793 794
  tran_low_t *outp = &out[0][0];
  int outstride = n;

  // inverse transform row vectors and transpose
  for (i = 0; i < n; ++i) {
    IHT_32x16[tx_type].rows(input, outtmp);
    for (j = 0; j < n2; ++j)
795
      tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
clang-format's avatar
clang-format committed
796
    input += n2;
797 798 799 800
  }

  // inverse transform column vectors
  for (i = 0; i < n2; ++i) {
801
    IHT_32x16[tx_type].cols(tmp[i], out[i]);
802 803
  }

804
#if CONFIG_EXT_TX
805
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2);
806
#endif
807 808 809 810 811 812 813 814 815 816 817

  // Sum with the destination
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n2; ++j) {
      int d = i * stride + j;
      int s = j * outstride + i;
      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6));
    }
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
818 819
void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                         int tx_type) {
820
  static const transform_2d IHT_8[] = {
Luca Barbato's avatar
Luca Barbato committed
821 822 823 824
    { aom_idct8_c, aom_idct8_c },    // DCT_DCT  = 0
    { aom_iadst8_c, aom_idct8_c },   // ADST_DCT = 1
    { aom_idct8_c, aom_iadst8_c },   // DCT_ADST = 2
    { aom_iadst8_c, aom_iadst8_c },  // ADST_ADST = 3
825
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
826 827 828 829 830 831 832 833 834 835 836 837 838
    { aom_iadst8_c, aom_idct8_c },   // FLIPADST_DCT
    { aom_idct8_c, aom_iadst8_c },   // DCT_FLIPADST
    { aom_iadst8_c, aom_iadst8_c },  // FLIPADST_FLIPADST
    { aom_iadst8_c, aom_iadst8_c },  // ADST_FLIPADST
    { aom_iadst8_c, aom_iadst8_c },  // FLIPADST_ADST
    { iidtx8_c, iidtx8_c },          // IDTX
    { aom_idct8_c, iidtx8_c },       // V_DCT
    { iidtx8_c, aom_idct8_c },       // H_DCT
    { aom_iadst8_c, iidtx8_c },      // V_ADST
    { iidtx8_c, aom_iadst8_c },      // H_ADST
    { aom_iadst8_c, iidtx8_c },      // V_FLIPADST
    { iidtx8_c, aom_iadst8_c },      // H_FLIPADST
#endif                               // CONFIG_EXT_TX
839 840
  };

Jingning Han's avatar
Jingning Han committed
841
  int i, j;
842
  tran_low_t tmp[8][8];
843 844 845
  tran_low_t out[8][8];
  tran_low_t *outp = &out[0][0];
  int outstride = 8;
Jingning Han's avatar
Jingning Han committed
846 847 848

  // inverse transform row vectors
  for (i = 0; i < 8; ++i) {
849
    IHT_8[tx_type].rows(input, out[i]);
clang-format's avatar
clang-format committed
850
    input += 8;
851 852 853
  }

  // transpose
854 855 856
  for (i = 0; i < 8; i++) {
    for (j = 0; j < 8; j++) {
      tmp[j][i] = out[i][j];
857
    }
Jingning Han's avatar
Jingning Han committed
858 859 860 861
  }

  // inverse transform column vectors
  for (i = 0; i < 8; ++i) {
862
    IHT_8[tx_type].cols(tmp[i], out[i]);
863 864 865
  }

#if CONFIG_EXT_TX
866
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 8, 8);
867 868 869 870
#endif

  // Sum with the destination
  for (i = 0; i < 8; ++i) {
Jingning Han's avatar
Jingning Han committed
871
    for (j = 0; j < 8; ++j) {
872 873 874
      int d = i * stride + j;
      int s = j * outstride + i;
      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5));
Jingning Han's avatar
Jingning Han committed
875 876 877 878
    }
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
879 880
void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                            int tx_type) {
881
  static const transform_2d IHT_16[] = {
Luca Barbato's avatar
Luca Barbato committed
882 883 884 885
    { aom_idct16_c, aom_idct16_c },    // DCT_DCT  = 0
    { aom_iadst16_c, aom_idct16_c },   // ADST_DCT = 1
    { aom_idct16_c, aom_iadst16_c },   // DCT_ADST = 2
    { aom_iadst16_c, aom_iadst16_c },  // ADST_ADST = 3
886
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
887 888 889 890 891 892 893 894 895 896 897 898 899
    { aom_iadst16_c, aom_idct16_c },   // FLIPADST_DCT
    { aom_idct16_c, aom_iadst16_c },   // DCT_FLIPADST
    { aom_iadst16_c, aom_iadst16_c },  // FLIPADST_FLIPADST
    { aom_iadst16_c, aom_iadst16_c },  // ADST_FLIPADST
    { aom_iadst16_c, aom_iadst16_c },  // FLIPADST_ADST
    { iidtx16_c, iidtx16_c },          // IDTX
    { aom_idct16_c, iidtx16_c },       // V_DCT
    { iidtx16_c, aom_idct16_c },       // H_DCT
    { aom_iadst16_c, iidtx16_c },      // V_ADST
    { iidtx16_c, aom_iadst16_c },      // H_ADST
    { aom_iadst16_c, iidtx16_c },      // V_FLIPADST
    { iidtx16_c, aom_iadst16_c },      // H_FLIPADST
#endif                                 // CONFIG_EXT_TX
900
  };
901

Jingning Han's avatar
Jingning Han committed
902
  int i, j;
903
  tran_low_t tmp[16][16];
904 905 906 907 908 909 910
  tran_low_t out[16][16];
  tran_low_t *outp = &out[0][0];
  int outstride = 16;

  // inverse transform row vectors
  for (i = 0; i < 16; ++i) {
    IHT_16[tx_type].rows(input, out[i]);
clang-format's avatar
clang-format committed
911
    input += 16;
912 913 914
  }

  // transpose
915 916 917
  for (i = 0; i < 16; i++) {
    for (j = 0; j < 16; j++) {
      tmp[j][i] = out[i][j];
918 919
    }
  }
Jingning Han's avatar
Jingning Han committed
920

921
  // inverse transform column vectors
Jingning Han's avatar
Jingning Han committed
922
  for (i = 0; i < 16; ++i) {
923
    IHT_16[tx_type].cols(tmp[i], out[i]);
Jingning Han's avatar
Jingning Han committed
924 925
  }

926
#if CONFIG_EXT_TX
927
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 16, 16);
928 929 930
#endif

  // Sum with the destination
Jingning Han's avatar
Jingning Han committed
931 932
  for (i = 0; i < 16; ++i) {
    for (j = 0; j < 16; ++j) {
933 934 935
      int d = i * stride + j;
      int s = j * outstride + i;
      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 6));
Jingning Han's avatar
Jingning Han committed
936 937 938 939
    }
  }
}

940
#if CONFIG_EXT_TX
Yaowu Xu's avatar
Yaowu Xu committed
941 942
void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                             int tx_type) {
943
  static const transform_2d IHT_32[] = {
Luca Barbato's avatar
Luca Barbato committed
944 945 946
    { aom_idct32_c, aom_idct32_c },      // DCT_DCT
    { ihalfright32_c, aom_idct32_c },    // ADST_DCT
    { aom_idct32_c, ihalfright32_c },    // DCT_ADST
clang-format's avatar
clang-format committed
947
    { ihalfright32_c, ihalfright32_c },  // ADST_ADST
Luca Barbato's avatar
Luca Barbato committed
948 949
    { ihalfright32_c, aom_idct32_c },    // FLIPADST_DCT
    { aom_idct32_c, ihalfright32_c },    // DCT_FLIPADST
clang-format's avatar
clang-format committed
950 951 952 953
    { ihalfright32_c, ihalfright32_c },  // FLIPADST_FLIPADST
    { ihalfright32_c, ihalfright32_c },  // ADST_FLIPADST
    { ihalfright32_c, ihalfright32_c },  // FLIPADST_ADST
    { iidtx32_c, iidtx32_c },            // IDTX
Luca Barbato's avatar
Luca Barbato committed
954 955
    { aom_idct32_c, iidtx32_c },         // V_DCT
    { iidtx32_c, aom_idct32_c },         // H_DCT
956 957 958 959
    { ihalfright32_c, iidtx32_c },       // V_ADST
    { iidtx32_c, ihalfright32_c },       // H_ADST
    { ihalfright32_c, iidtx32_c },       // V_FLIPADST
    { iidtx32_c, ihalfright32_c },       // H_FLIPADST
960 961 962
  };

  int i, j;
963
  tran_low_t tmp[32][32];
964 965 966 967 968 969 970
  tran_low_t out[32][32];
  tran_low_t *outp = &out[0][0];
  int outstride = 32;

  // inverse transform row vectors
  for (i = 0; i < 32; ++i) {
    IHT_32[tx_type].rows(input, out[i]);
clang-format's avatar
clang-format committed
971
    input += 32;
972 973 974
  }

  // transpose
975 976 977
  for (i = 0; i < 32; i++) {
    for (j = 0; j < 32; j++) {
      tmp[j][i] = out[i][j];
978 979 980 981 982