idct.c 76.1 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 18
#include "./av1_rtcd.h"
#include "aom_dsp/inv_txfm.h"
#include "aom_ports/mem.h"
#include "av1/common/av1_inv_txfm2d_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 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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
#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];
  av1_idct64_new(in, out, inv_cos_bit_col_dct_dct_64,
                 inv_stage_range_col_dct_dct_64);
  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];
  av1_idct64_new(in, out, inv_cos_bit_row_dct_dct_64,
                 inv_stage_range_row_dct_dct_64);
  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

Yaowu Xu's avatar
Yaowu Xu committed
118
#if CONFIG_AOM_HIGHBITDEPTH
119
#if CONFIG_EXT_TX
Debargha Mukherjee's avatar
Debargha Mukherjee committed
120 121 122 123
static void highbd_iidtx4_c(const tran_low_t *input, tran_low_t *output,
                            int bd) {
  int i;
  for (i = 0; i < 4; ++i)
clang-format's avatar
clang-format committed
124 125
    output[i] =
        HIGHBD_WRAPLOW(highbd_dct_const_round_shift(input[i] * Sqrt2), bd);
Debargha Mukherjee's avatar
Debargha Mukherjee committed
126 127 128 129 130
}

static void highbd_iidtx8_c(const tran_low_t *input, tran_low_t *output,
                            int bd) {
  int i;
clang-format's avatar
clang-format committed
131 132
  (void)bd;
  for (i = 0; i < 8; ++i) output[i] = input[i] * 2;
Debargha Mukherjee's avatar
Debargha Mukherjee committed
133 134 135
}

static void highbd_iidtx16_c(const tran_low_t *input, tran_low_t *output,
clang-format's avatar
clang-format committed
136
                             int bd) {
Debargha Mukherjee's avatar
Debargha Mukherjee committed
137 138
  int i;
  for (i = 0; i < 16; ++i)
clang-format's avatar
clang-format committed
139 140
    output[i] =
        HIGHBD_WRAPLOW(highbd_dct_const_round_shift(input[i] * 2 * Sqrt2), bd);
Debargha Mukherjee's avatar
Debargha Mukherjee committed
141 142 143 144 145
}

static void highbd_iidtx32_c(const tran_low_t *input, tran_low_t *output,
                             int bd) {
  int i;
clang-format's avatar
clang-format committed
146 147
  (void)bd;
  for (i = 0; i < 32; ++i) output[i] = input[i] * 4;
Debargha Mukherjee's avatar
Debargha Mukherjee committed
148
}
149
#endif  // CONFIG_EXT_TX
Debargha Mukherjee's avatar
Debargha Mukherjee committed
150

151 152 153 154 155 156
static void highbd_ihalfright32_c(const tran_low_t *input, tran_low_t *output,
                                  int bd) {
  int i;
  tran_low_t inputhalf[16];
  // Multiply input by sqrt(2)
  for (i = 0; i < 16; ++i) {
clang-format's avatar
clang-format committed
157 158
    inputhalf[i] =
        HIGHBD_WRAPLOW(highbd_dct_const_round_shift(input[i] * Sqrt2), bd);
159
  }
160 161 162
  for (i = 0; i < 16; ++i) {
    output[i] = input[16 + i] * 4;
  }
Yaowu Xu's avatar
Yaowu Xu committed
163
  aom_highbd_idct16_c(inputhalf, output + 16, bd);
164 165
  // Note overall scaling factor is 4 times orthogonal
}
166

167
#if CONFIG_EXT_TX
168 169 170 171 172 173 174 175
#if CONFIG_TX64X64
static void highbd_iidtx64_c(const tran_low_t *input, tran_low_t *output,
                             int bd) {
  int i;
  for (i = 0; i < 64; ++i)
    output[i] =
        HIGHBD_WRAPLOW(highbd_dct_const_round_shift(input[i] * 4 * Sqrt2), bd);
}
176 177
#endif  // CONFIG_TX64X64
#endif  // CONFIG_EXT_TX
178

179
#if CONFIG_TX64X64
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
// For use in lieu of ADST
static void highbd_ihalfright64_c(const tran_low_t *input, tran_low_t *output,
                                  int bd) {
  int i;
  tran_low_t inputhalf[32];
  // Multiply input by sqrt(2)
  for (i = 0; i < 32; ++i) {
    inputhalf[i] =
        HIGHBD_WRAPLOW(highbd_dct_const_round_shift(input[i] * Sqrt2), bd);
  }
  for (i = 0; i < 32; ++i) {
    output[i] = HIGHBD_WRAPLOW(
        highbd_dct_const_round_shift(input[32 + i] * 4 * Sqrt2), bd);
  }
  aom_highbd_idct32_c(inputhalf, output + 32, bd);
  // Note overall scaling factor is 4 * sqrt(2)  times orthogonal
}

static void highbd_idct64_col_c(const tran_low_t *input, tran_low_t *output,
                                int bd) {
  int32_t in[64], out[64];
  int i;
  (void)bd;
  for (i = 0; i < 64; ++i) in[i] = (int32_t)input[i];
  av1_idct64_new(in, out, inv_cos_bit_col_dct_dct_64,
                 inv_stage_range_col_dct_dct_64);
  for (i = 0; i < 64; ++i) output[i] = (tran_low_t)out[i];
}

static void highbd_idct64_row_c(const tran_low_t *input, tran_low_t *output,
                                int bd) {
  int32_t in[64], out[64];
  int i;
  (void)bd;
  for (i = 0; i < 64; ++i) in[i] = (int32_t)input[i];
  av1_idct64_new(in, out, inv_cos_bit_row_dct_dct_64,
                 inv_stage_range_row_dct_dct_64);
  for (i = 0; i < 64; ++i) output[i] = (tran_low_t)out[i];
}
#endif  // CONFIG_TX64X64
Yaowu Xu's avatar
Yaowu Xu committed
220
#endif  // CONFIG_AOM_HIGHBITDEPTH
221

Jingning Han's avatar
Jingning Han committed
222
// Inverse identity transform and add.
223
#if CONFIG_EXT_TX
224
static void inv_idtx_add_c(const tran_low_t *input, uint8_t *dest, int stride,
Jingning Han's avatar
Jingning Han committed
225
                           int bs, int tx_type) {
226
  int r, c;
227
  const int shift = bs < 32 ? 3 : (bs < 64 ? 2 : 1);
Debargha Mukherjee's avatar
Debargha Mukherjee committed
228
  if (tx_type == IDTX) {
Jingning Han's avatar
Jingning Han committed
229 230
    for (r = 0; r < bs; ++r) {
      for (c = 0; c < bs; ++c)
Debargha Mukherjee's avatar
Debargha Mukherjee committed
231 232 233
        dest[c] = clip_pixel_add(dest[c], input[c] >> shift);
      dest += stride;
      input += bs;
Jingning Han's avatar
Jingning Han committed
234
    }
235 236
  }
}
237
#endif  // CONFIG_EXT_TX
238

clang-format's avatar
clang-format committed
239 240 241 242 243
#define FLIPUD_PTR(dest, stride, size)       \
  do {                                       \
    (dest) = (dest) + ((size)-1) * (stride); \
    (stride) = -(stride);                    \
  } while (0)
244

245
#if CONFIG_EXT_TX
clang-format's avatar
clang-format committed
246 247 248
static void maybe_flip_strides(uint8_t **dst, int *dstride, tran_low_t **src,
                               int *sstride, int tx_type, int sizey,
                               int sizex) {
249 250 251 252 253 254 255 256
  // 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
257
    case IDTX:
Jingning Han's avatar
Jingning Han committed
258 259
    case V_DCT:
    case H_DCT:
260
    case V_ADST:
clang-format's avatar
clang-format committed
261
    case H_ADST: break;
262 263
    case FLIPADST_DCT:
    case FLIPADST_ADST:
264
    case V_FLIPADST:
265
      // flip UD
266
      FLIPUD_PTR(*dst, *dstride, sizey);
267 268 269
      break;
    case DCT_FLIPADST:
    case ADST_FLIPADST:
270
    case H_FLIPADST:
271
      // flip LR
272
      FLIPUD_PTR(*src, *sstride, sizex);
273 274 275
      break;
    case FLIPADST_FLIPADST:
      // flip UD
276
      FLIPUD_PTR(*dst, *dstride, sizey);
277
      // flip LR
278
      FLIPUD_PTR(*src, *sstride, sizex);
279
      break;
clang-format's avatar
clang-format committed
280
    default: assert(0); break;
281 282
  }
}
283
#endif  // CONFIG_EXT_TX
284

Yaowu Xu's avatar
Yaowu Xu committed
285
#if CONFIG_AOM_HIGHBITDEPTH
286
#if CONFIG_EXT_TX
287
static void highbd_inv_idtx_add_c(const tran_low_t *input, uint8_t *dest8,
288
                                  int stride, int bs, int tx_type, int bd) {
289 290 291
  int r, c;
  const int shift = bs < 32 ? 3 : 2;
  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
292

Debargha Mukherjee's avatar
Debargha Mukherjee committed
293
  if (tx_type == IDTX) {
294 295
    for (r = 0; r < bs; ++r) {
      for (c = 0; c < bs; ++c)
Debargha Mukherjee's avatar
Debargha Mukherjee committed
296 297 298
        dest[c] = highbd_clip_pixel_add(dest[c], input[c] >> shift, bd);
      dest += stride;
      input += bs;
299
    }
300 301
  }
}
302

clang-format's avatar
clang-format committed
303 304 305
static void maybe_flip_strides16(uint16_t **dst, int *dstride, tran_low_t **src,
                                 int *sstride, int tx_type, int sizey,
                                 int sizex) {
306 307 308 309 310 311 312 313
  // 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
314 315 316
    case IDTX:
    case V_DCT:
    case H_DCT:
317
    case V_ADST:
clang-format's avatar
clang-format committed
318
    case H_ADST: break;
319 320
    case FLIPADST_DCT:
    case FLIPADST_ADST:
321
    case V_FLIPADST:
322
      // flip UD
323
      FLIPUD_PTR(*dst, *dstride, sizey);
324 325 326
      break;
    case DCT_FLIPADST:
    case ADST_FLIPADST:
327
    case H_FLIPADST:
328
      // flip LR
329
      FLIPUD_PTR(*src, *sstride, sizex);
330 331 332
      break;
    case FLIPADST_FLIPADST:
      // flip UD
333
      FLIPUD_PTR(*dst, *dstride, sizey);
334
      // flip LR
335
      FLIPUD_PTR(*src, *sstride, sizex);
336
      break;
clang-format's avatar
clang-format committed
337
    default: assert(0); break;
338 339
  }
}
340
#endif  // CONFIG_EXT_TX
341
#endif  // CONFIG_AOM_HIGHBITDEPTH
342

Yaowu Xu's avatar
Yaowu Xu committed
343 344
void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                         int tx_type) {
345
  static const transform_2d IHT_4[] = {
Luca Barbato's avatar
Luca Barbato committed
346 347 348 349
    { 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
350
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
351 352 353 354 355 356 357 358 359 360 361 362 363
    { 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
364 365 366
  };

  int i, j;
367 368 369 370
  tran_low_t tmp;
  tran_low_t out[4][4];
  tran_low_t *outp = &out[0][0];
  int outstride = 4;
371 372 373

  // inverse transform row vectors
  for (i = 0; i < 4; ++i) {
374
    IHT_4[tx_type].rows(input, out[i]);
clang-format's avatar
clang-format committed
375
    input += 4;
376 377 378
  }

  // transpose
clang-format's avatar
clang-format committed
379
  for (i = 1; i < 4; i++) {
380
    for (j = 0; j < i; j++) {
clang-format's avatar
clang-format committed
381
      tmp = out[i][j];
382 383 384
      out[i][j] = out[j][i];
      out[j][i] = tmp;
    }
385 386 387 388
  }

  // inverse transform column vectors
  for (i = 0; i < 4; ++i) {
389 390 391 392
    IHT_4[tx_type].cols(out[i], out[i]);
  }

#if CONFIG_EXT_TX
393
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 4, 4);
394 395 396 397
#endif

  // Sum with the destination
  for (i = 0; i < 4; ++i) {
398
    for (j = 0; j < 4; ++j) {
399 400 401
      int d = i * stride + j;
      int s = j * outstride + i;
      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 4));
402 403 404 405
    }
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
406 407
void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                         int tx_type) {
408
  static const transform_2d IHT_4x8[] = {
Luca Barbato's avatar
Luca Barbato committed
409 410 411 412
    { 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
413
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
414 415 416 417 418 419 420 421 422 423 424 425
    { 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
426
#endif
427 428
  };

429 430
  const int n = 4;
  const int n2 = 8;
431 432 433
  int i, j;
  tran_low_t out[4][8], outtmp[4];
  tran_low_t *outp = &out[0][0];
434
  int outstride = n2;
435 436

  // inverse transform row vectors and transpose
437
  for (i = 0; i < n2; ++i) {
438
    IHT_4x8[tx_type].rows(input, outtmp);
439
    for (j = 0; j < n; ++j)
440
      out[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
441
    input += n;
442 443 444
  }

  // inverse transform column vectors
445
  for (i = 0; i < n; ++i) {
446 447 448
    IHT_4x8[tx_type].cols(out[i], out[i]);
  }

449
#if CONFIG_EXT_TX
450
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n);
451
#endif
452 453

  // Sum with the destination
454 455
  for (i = 0; i < n2; ++i) {
    for (j = 0; j < n; ++j) {
456 457 458 459 460 461 462
      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
463 464
void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                         int tx_type) {
465
  static const transform_2d IHT_8x4[] = {
Luca Barbato's avatar
Luca Barbato committed
466 467 468 469
    { 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
470
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
471 472 473 474 475 476 477 478 479 480 481 482
    { 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
483
#endif
484
  };
485 486
  const int n = 4;
  const int n2 = 8;
487 488 489 490

  int i, j;
  tran_low_t out[8][4], outtmp[8];
  tran_low_t *outp = &out[0][0];
491
  int outstride = n;
492 493

  // inverse transform row vectors and transpose
494
  for (i = 0; i < n; ++i) {
495
    IHT_8x4[tx_type].rows(input, outtmp);
496
    for (j = 0; j < n2; ++j)
497
      out[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
498
    input += n2;
499 500 501
  }

  // inverse transform column vectors
502
  for (i = 0; i < n2; ++i) {
503 504 505
    IHT_8x4[tx_type].cols(out[i], out[i]);
  }

506
#if CONFIG_EXT_TX
507
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2);
508
#endif
509 510

  // Sum with the destination
511 512
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n2; ++j) {
513 514 515 516 517 518 519
      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
520 521
void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                           int tx_type) {
522
  static const transform_2d IHT_8x16[] = {
Luca Barbato's avatar
Luca Barbato committed
523 524 525 526
    { 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
527
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
528 529 530 531 532 533 534 535 536 537 538 539
    { 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
540
#endif
541 542 543 544 545 546 547 548 549 550 551 552 553 554
  };

  const int n = 8;
  const int n2 = 16;
  int i, j;
  tran_low_t out[8][16], outtmp[8];
  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)
      out[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
clang-format's avatar
clang-format committed
555
    input += n;
556 557 558 559 560 561 562
  }

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

563
#if CONFIG_EXT_TX
564
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n);
565
#endif
566 567 568 569 570 571 572 573 574 575 576

  // 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
577 578
void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                           int tx_type) {
579
  static const transform_2d IHT_16x8[] = {
Luca Barbato's avatar
Luca Barbato committed
580 581 582 583
    { 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
584
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
585 586 587 588 589 590 591 592 593 594 595 596
    { 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
597
#endif
598 599 600 601 602 603 604 605 606 607 608 609 610 611
  };
  const int n = 8;
  const int n2 = 16;

  int i, j;
  tran_low_t out[16][8], outtmp[16];
  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)
      out[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
clang-format's avatar
clang-format committed
612
    input += n2;
613 614 615 616 617 618 619
  }

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

620
#if CONFIG_EXT_TX
621
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2);
622
#endif
623 624 625 626 627 628 629 630 631 632 633

  // 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
634 635
void av1_iht16x32_512_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                            int tx_type) {
636
  static const transform_2d IHT_16x32[] = {
Luca Barbato's avatar
Luca Barbato committed
637 638 639 640
    { 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
641
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
642 643 644 645 646 647 648 649 650 651 652 653
    { 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
654
#endif
655 656 657 658 659 660 661 662 663 664 665 666 667 668
  };

  const int n = 16;
  const int n2 = 32;
  int i, j;
  tran_low_t out[16][32], outtmp[16];
  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)
      out[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
clang-format's avatar
clang-format committed
669
    input += n;
670 671 672 673 674 675 676
  }

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

677
#if CONFIG_EXT_TX
678
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n);
679
#endif
680 681 682 683 684 685 686 687 688 689 690

  // 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
691 692
void av1_iht32x16_512_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                            int tx_type) {
693
  static const transform_2d IHT_32x16[] = {
Luca Barbato's avatar
Luca Barbato committed
694 695 696 697
    { 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
698
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
699 700 701 702 703 704 705 706 707 708 709 710
    { 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
711
#endif
712 713 714 715 716 717 718 719 720 721 722 723 724 725
  };
  const int n = 16;
  const int n2 = 32;

  int i, j;
  tran_low_t out[32][16], outtmp[32];
  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)
      out[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
clang-format's avatar
clang-format committed
726
    input += n2;
727 728 729 730 731 732 733
  }

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

734
#if CONFIG_EXT_TX
735
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2);
736
#endif
737 738 739 740 741 742 743 744 745 746 747

  // 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
748 749
void av1_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                         int tx_type) {
750
  static const transform_2d IHT_8[] = {
Luca Barbato's avatar
Luca Barbato committed
751 752 753 754
    { 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
755
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
756 757 758 759 760 761 762 763 764 765 766 767 768
    { 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
769 770
  };

Jingning Han's avatar
Jingning Han committed
771
  int i, j;
772 773 774 775
  tran_low_t tmp;
  tran_low_t out[8][8];
  tran_low_t *outp = &out[0][0];
  int outstride = 8;
Jingning Han's avatar
Jingning Han committed
776 777 778

  // inverse transform row vectors
  for (i = 0; i < 8; ++i) {
779
    IHT_8[tx_type].rows(input, out[i]);
clang-format's avatar
clang-format committed
780
    input += 8;
781 782 783
  }

  // transpose
clang-format's avatar
clang-format committed
784
  for (i = 1; i < 8; i++) {
785
    for (j = 0; j < i; j++) {
clang-format's avatar
clang-format committed
786
      tmp = out[i][j];
787 788 789
      out[i][j] = out[j][i];
      out[j][i] = tmp;
    }
Jingning Han's avatar
Jingning Han committed
790 791 792 793
  }

  // inverse transform column vectors
  for (i = 0; i < 8; ++i) {
794 795 796 797
    IHT_8[tx_type].cols(out[i], out[i]);
  }

#if CONFIG_EXT_TX
798
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 8, 8);
799 800 801 802
#endif

  // Sum with the destination
  for (i = 0; i < 8; ++i) {
Jingning Han's avatar
Jingning Han committed
803
    for (j = 0; j < 8; ++j) {
804 805 806
      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
807 808 809 810
    }
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
811 812
void av1_iht16x16_256_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                            int tx_type) {
813
  static const transform_2d IHT_16[] = {
Luca Barbato's avatar
Luca Barbato committed
814 815 816 817
    { 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
818
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
819 820 821 822 823 824 825 826 827 828 829 830 831
    { 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
832
  };
833

Jingning Han's avatar
Jingning Han committed
834
  int i, j;
835 836 837 838 839 840 841 842
  tran_low_t tmp;
  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
843
    input += 16;
844 845 846
  }

  // transpose
clang-format's avatar
clang-format committed
847
  for (i = 1; i < 16; i++) {
848
    for (j = 0; j < i; j++) {
clang-format's avatar
clang-format committed
849
      tmp = out[i][j];
850 851 852 853
      out[i][j] = out[j][i];
      out[j][i] = tmp;
    }
  }
Jingning Han's avatar
Jingning Han committed
854

855
  // inverse transform column vectors
Jingning Han's avatar
Jingning Han committed
856
  for (i = 0; i < 16; ++i) {
857
    IHT_16[tx_type].cols(out[i], out[i]);
Jingning Han's avatar
Jingning Han committed
858 859
  }

860
#if CONFIG_EXT_TX
861
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 16, 16);
862 863 864
#endif

  // Sum with the destination
Jingning Han's avatar
Jingning Han committed
865 866
  for (i = 0; i < 16; ++i) {
    for (j = 0; j < 16; ++j) {
867 868 869
      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
870 871 872 873
    }
  }
}

874
#if CONFIG_EXT_TX
Yaowu Xu's avatar
Yaowu Xu committed
875 876
void av1_iht32x32_1024_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                             int tx_type) {
877
  static const transform_2d IHT_32[] = {
Luca Barbato's avatar
Luca Barbato committed
878 879 880
    { 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
881
    { ihalfright32_c, ihalfright32_c },  // ADST_ADST
Luca Barbato's avatar
Luca Barbato committed
882 883
    { ihalfright32_c, aom_idct32_c },    // FLIPADST_DCT
    { aom_idct32_c, ihalfright32_c },    // DCT_FLIPADST
clang-format's avatar
clang-format committed
884 885 886 887
    { 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
888 889
    { aom_idct32_c, iidtx32_c },         // V_DCT
    { iidtx32_c, aom_idct32_c },         // H_DCT
890 891 892 893
    { ihalfright32_c, iidtx32_c },       // V_ADST
    { iidtx32_c, ihalfright32_c },       // H_ADST
    { ihalfright32_c, iidtx32_c },       // V_FLIPADST
    { iidtx32_c, ihalfright32_c },       // H_FLIPADST
894 895 896 897 898 899 900 901 902 903 904
  };

  int i, j;
  tran_low_t tmp;
  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
905
    input += 32;
906 907 908
  }

  // transpose
clang-format's avatar
clang-format committed
909
  for (i = 1; i < 32; i++) {
910
    for (j = 0; j < i; j++) {
clang-format's avatar
clang-format committed
911
      tmp = out[i][j];
912 913 914 915 916 917 918 919 920 921
      out[i][j] = out[j][i];
      out[j][i] = tmp;
    }
  }

  // inverse transform column vectors
  for (i = 0; i < 32; ++i) {
    IHT_32[tx_type].cols(out[i], out[i]);
  }

922
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 32, 32);
923 924 925 926 927 928 929 930 931 932

  // Sum with the destination
  for (i = 0; i < 32; ++i) {
    for (j = 0; j < 32; ++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));
    }
  }
}
933
#endif  // CONFIG_EXT_TX
934 935 936 937 938 939 940 941 942

#if CONFIG_TX64X64
void av1_iht64x64_4096_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                             int tx_type) {
  static const transform_2d IHT_64[] = {
    { idct64_col_c, idct64_row_c },      // DCT_DCT
    { ihalfright64_c, idct64_row_c },    // ADST_DCT
    { idct64_col_c, ihalfright64_c },    // DCT_ADST
    { ihalfright64_c, ihalfright64_c },  // ADST_ADST
943
#if CONFIG_EXT_TX
944 945 946 947 948 949 950 951 952 953 954 955
    { ihalfright64_c, idct64_row_c },    // FLIPADST_DCT
    { idct64_col_c, ihalfright64_c },    // DCT_FLIPADST
    { ihalfright64_c, ihalfright64_c },  // FLIPADST_FLIPADST
    { ihalfright64_c, ihalfright64_c },  // ADST_FLIPADST
    { ihalfright64_c, ihalfright64_c },  // FLIPADST_ADST
    { iidtx64_c, iidtx64_c },            // IDTX
    { idct64_col_c, iidtx64_c },         // V_DCT
    { iidtx64_c, idct64_row_c },         // H_DCT
    { ihalfright64_c, iidtx64_c },       // V_ADST
    { iidtx64_c, ihalfright64_c },       // H_ADST
    { ihalfright64_c, iidtx64_c },       // V_FLIPADST
    { iidtx64_c, ihalfright64_c },       // H_FLIPADST
956
#endif                                   // CONFIG_EXT_TX
957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985
  };

  int i, j;
  tran_low_t tmp;
  tran_low_t out[64][64];
  tran_low_t *outp = &out[0][0];
  int outstride = 64;

  // inverse transform row vectors
  for (i = 0; i < 64; ++i) {
    IHT_64[tx_type].rows(input, out[i]);
    for (j = 0; j < 64; ++j) out[i][j] = ROUND_POWER_OF_TWO(out[i][j], 1);
    input += 64;
  }

  // transpose
  for (i = 1; i < 64; i++) {
    for (j = 0; j < i; j++) {
      tmp = out[i][j];
      out[i][j] = out[j][i];
      out[j][i] = tmp;
    }
  }

  // inverse transform column vectors
  for (i = 0; i < 64; ++i) {
    IHT_64[tx_type].cols(out[i], out[i]);
  }