idct.c 75.6 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"
22 23 24 25
#if CONFIG_DAALA_DCT4 || CONFIG_DAALA_DCT8 || CONFIG_DAALA_DCT16 || \
    CONFIG_DAALA_DCT32 || CONFIG_DAALA_DCT64
#include "av1/common/daala_tx.h"
#endif
Jingning Han's avatar
Jingning Han committed
26

27
int av1_get_tx_scale(const TX_SIZE tx_size) {
28 29
  const int pels = tx_size_2d[tx_size];
  return (pels > 256) + (pels > 1024) + (pels > 4096);
30 31
}

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

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

static void iidtx8_c(const tran_low_t *input, tran_low_t *output) {
  int i;
49 50 51 52 53 54 55
  for (i = 0; i < 8; ++i) {
#if CONFIG_DAALA_DCT8
    output[i] = input[i];
#else
    output[i] = input[i] * 2;
#endif
  }
Debargha Mukherjee's avatar
Debargha Mukherjee committed
56 57 58 59
}

static void iidtx16_c(const tran_low_t *input, tran_low_t *output) {
  int i;
60 61 62 63
  for (i = 0; i < 16; ++i) {
#if CONFIG_DAALA_DCT16
    output[i] = input[i];
#else
Debargha Mukherjee's avatar
Debargha Mukherjee committed
64
    output[i] = (tran_low_t)dct_const_round_shift(input[i] * 2 * Sqrt2);
65 66
#endif
  }
Debargha Mukherjee's avatar
Debargha Mukherjee committed
67 68 69 70
}

static void iidtx32_c(const tran_low_t *input, tran_low_t *output) {
  int i;
71 72 73 74 75 76 77
  for (i = 0; i < 32; ++i) {
#if CONFIG_DAALA_DCT32
    output[i] = input[i];
#else
    output[i] = input[i] * 4;
#endif
  }
Debargha Mukherjee's avatar
Debargha Mukherjee committed
78
}
79 80 81 82

#if CONFIG_TX64X64
static void iidtx64_c(const tran_low_t *input, tran_low_t *output) {
  int i;
83 84 85 86
  for (i = 0; i < 64; ++i) {
#if CONFIG_DAALA_DCT64
    output[i] = input[i];
#else
87
    output[i] = (tran_low_t)dct_const_round_shift(input[i] * 4 * Sqrt2);
88 89
#endif
  }
90 91
}
#endif  // CONFIG_TX64X64
92
#endif  // CONFIG_EXT_TX
Debargha Mukherjee's avatar
Debargha Mukherjee committed
93

94
// For use in lieu of ADST
95 96 97 98 99 100 101 102 103 104 105 106 107 108
#if CONFIG_DAALA_DCT32
static void ihalfright32_c(const tran_low_t *input, tran_low_t *output) {
  int i;
  tran_low_t inputhalf[16];
  // No scaling within; Daala transforms are all orthonormal
  for (i = 0; i < 16; ++i) {
    inputhalf[i] = input[i];
  }
  for (i = 0; i < 16; ++i) {
    output[i] = input[16 + i];
  }
  aom_idct16_c(inputhalf, output + 16);
}
#else
109 110 111 112 113 114 115
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);
  }
116 117 118
  for (i = 0; i < 16; ++i) {
    output[i] = input[16 + i] * 4;
  }
Luca Barbato's avatar
Luca Barbato committed
119
  aom_idct16_c(inputhalf, output + 16);
120 121
  // Note overall scaling factor is 4 times orthogonal
}
122
#endif
123

124
#if CONFIG_TX64X64
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
#if CONFIG_DAALA_DCT64
static void idct64_col_c(const tran_low_t *input, tran_low_t *output) {
  aom_idct64_c(input, output);
}

static void idct64_row_c(const tran_low_t *input, tran_low_t *output) {
  aom_idct64_c(input, output);
}

static void ihalfright64_c(const tran_low_t *input, tran_low_t *output) {
  int i;
  tran_low_t inputhalf[32];
  // No scaling within; Daala transforms are all orthonormal
  for (i = 0; i < 32; ++i) {
    inputhalf[i] = input[i];
  }
  for (i = 0; i < 32; ++i) {
    output[i] = input[32 + i];
  }
  aom_idct32_c(inputhalf, output + 32);
}

#else
148 149 150 151
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];
152
  av1_idct64_new(in, out, inv_cos_bit_col_dct_64, inv_stage_range_col_dct_64);
153 154 155 156 157 158 159
  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];
160
  av1_idct64_new(in, out, inv_cos_bit_row_dct_64, inv_stage_range_row_dct_64);
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
  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
}
178
#endif  // CONFIG_DAALA_DCT64
179 180
#endif  // CONFIG_TX64X64

Jingning Han's avatar
Jingning Han committed
181
// Inverse identity transform and add.
182
#if CONFIG_EXT_TX
183
static void inv_idtx_add_c(const tran_low_t *input, uint8_t *dest, int stride,
Jingning Han's avatar
Jingning Han committed
184
                           int bs, int tx_type) {
185
  int r, c;
186
  const int shift = bs < 32 ? 3 : (bs < 64 ? 2 : 1);
Debargha Mukherjee's avatar
Debargha Mukherjee committed
187
  if (tx_type == IDTX) {
Jingning Han's avatar
Jingning Han committed
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] = clip_pixel_add(dest[c], input[c] >> shift);
      dest += stride;
      input += bs;
Jingning Han's avatar
Jingning Han committed
193
    }
194 195
  }
}
196
#endif  // CONFIG_EXT_TX
197

clang-format's avatar
clang-format committed
198 199 200 201 202
#define FLIPUD_PTR(dest, stride, size)       \
  do {                                       \
    (dest) = (dest) + ((size)-1) * (stride); \
    (stride) = -(stride);                    \
  } while (0)
203

204
#if CONFIG_EXT_TX
clang-format's avatar
clang-format committed
205 206 207
static void maybe_flip_strides(uint8_t **dst, int *dstride, tran_low_t **src,
                               int *sstride, int tx_type, int sizey,
                               int sizex) {
208 209 210 211 212 213 214 215
  // 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
216
    case IDTX:
Jingning Han's avatar
Jingning Han committed
217 218
    case V_DCT:
    case H_DCT:
219
    case V_ADST:
clang-format's avatar
clang-format committed
220
    case H_ADST: break;
221 222
    case FLIPADST_DCT:
    case FLIPADST_ADST:
223
    case V_FLIPADST:
224
      // flip UD
225
      FLIPUD_PTR(*dst, *dstride, sizey);
226 227 228
      break;
    case DCT_FLIPADST:
    case ADST_FLIPADST:
229
    case H_FLIPADST:
230
      // flip LR
231
      FLIPUD_PTR(*src, *sstride, sizex);
232 233 234
      break;
    case FLIPADST_FLIPADST:
      // flip UD
235
      FLIPUD_PTR(*dst, *dstride, sizey);
236
      // flip LR
237
      FLIPUD_PTR(*src, *sstride, sizex);
238
      break;
clang-format's avatar
clang-format committed
239
    default: assert(0); break;
240 241
  }
}
242
#endif  // CONFIG_EXT_TX
243

244
#if CONFIG_HIGHBITDEPTH
245
#if CONFIG_EXT_TX && CONFIG_TX64X64
246
static void highbd_inv_idtx_add_c(const tran_low_t *input, uint8_t *dest8,
247
                                  int stride, int bs, int tx_type, int bd) {
248 249 250
  int r, c;
  const int shift = bs < 32 ? 3 : 2;
  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
251

Debargha Mukherjee's avatar
Debargha Mukherjee committed
252
  if (tx_type == IDTX) {
253 254
    for (r = 0; r < bs; ++r) {
      for (c = 0; c < bs; ++c)
Debargha Mukherjee's avatar
Debargha Mukherjee committed
255 256 257
        dest[c] = highbd_clip_pixel_add(dest[c], input[c] >> shift, bd);
      dest += stride;
      input += bs;
258
    }
259 260
  }
}
261
#endif  // CONFIG_EXT_TX && CONFIG_TX64X64
262
#endif  // CONFIG_HIGHBITDEPTH
263

Lester Lu's avatar
Lester Lu committed
264 265 266
#if CONFIG_LGT
void ilgt4(const tran_low_t *input, tran_low_t *output,
           const tran_high_t *lgtmtx) {
Lester Lu's avatar
Lester Lu committed
267 268
  if (!lgtmtx) assert(0);
  // evaluate s[j] = sum of all lgtmtx[j]*input[i] over i=1,...,4
Lester Lu's avatar
Lester Lu committed
269 270 271 272 273 274 275 276 277
  tran_high_t s[4] = { 0 };
  for (int i = 0; i < 4; ++i)
    for (int j = 0; j < 4; ++j) s[j] += lgtmtx[i * 4 + j] * input[i];

  for (int i = 0; i < 4; ++i) output[i] = WRAPLOW(dct_const_round_shift(s[i]));
}

void ilgt8(const tran_low_t *input, tran_low_t *output,
           const tran_high_t *lgtmtx) {
Lester Lu's avatar
Lester Lu committed
278 279
  if (!lgtmtx) assert(0);
  // evaluate s[j] = sum of all lgtmtx[j]*input[i] over i=1,...,8
Lester Lu's avatar
Lester Lu committed
280 281 282 283 284 285 286
  tran_high_t s[8] = { 0 };
  for (int i = 0; i < 8; ++i)
    for (int j = 0; j < 8; ++j) s[j] += lgtmtx[i * 8 + j] * input[i];

  for (int i = 0; i < 8; ++i) output[i] = WRAPLOW(dct_const_round_shift(s[i]));
}

Lester Lu's avatar
Lester Lu committed
287 288 289 290 291 292 293 294 295 296 297
// get_lgt4 and get_lgt8 return 1 and pick a lgt matrix if LGT is chosen to
// apply. Otherwise they return 0
int get_lgt4(const TxfmParam *txfm_param, int is_col,
             const tran_high_t **lgtmtx) {
  if (is_col && (vtx_tab[txfm_param->tx_type] == ADST_1D ||
                 vtx_tab[txfm_param->tx_type] == FLIPADST_1D)) {
    lgtmtx[0] = txfm_param->is_inter ? &lgt4_170[0][0] : &lgt4_140[0][0];
    return 1;
  } else if (!is_col && (htx_tab[txfm_param->tx_type] == ADST_1D ||
                         htx_tab[txfm_param->tx_type] == FLIPADST_1D)) {
    lgtmtx[0] = txfm_param->is_inter ? &lgt4_170[0][0] : &lgt4_140[0][0];
Lester Lu's avatar
Lester Lu committed
298 299
    return 1;
  }
Lester Lu's avatar
Lester Lu committed
300
  lgtmtx[0] = NULL;
Lester Lu's avatar
Lester Lu committed
301 302 303
  return 0;
}

Lester Lu's avatar
Lester Lu committed
304 305 306 307 308 309 310 311 312
int get_lgt8(const TxfmParam *txfm_param, int is_col,
             const tran_high_t **lgtmtx) {
  if (is_col && (vtx_tab[txfm_param->tx_type] == ADST_1D ||
                 vtx_tab[txfm_param->tx_type] == FLIPADST_1D)) {
    lgtmtx[0] = txfm_param->is_inter ? &lgt8_170[0][0] : &lgt8_150[0][0];
    return 1;
  } else if (!is_col && (htx_tab[txfm_param->tx_type] == ADST_1D ||
                         htx_tab[txfm_param->tx_type] == FLIPADST_1D)) {
    lgtmtx[0] = txfm_param->is_inter ? &lgt8_170[0][0] : &lgt8_150[0][0];
Lester Lu's avatar
Lester Lu committed
313 314
    return 1;
  }
Lester Lu's avatar
Lester Lu committed
315
  lgtmtx[0] = NULL;
Lester Lu's avatar
Lester Lu committed
316 317 318 319
  return 0;
}
#endif  // CONFIG_LGT

Yaowu Xu's avatar
Yaowu Xu committed
320
void av1_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int stride,
321 322
                         const TxfmParam *txfm_param) {
  int tx_type = txfm_param->tx_type;
Sarah Parker's avatar
Sarah Parker committed
323 324 325
#if CONFIG_MRC_TX
  assert(tx_type != MRC_DCT && "Invalid tx type for tx size");
#endif  // CONFIG_MRC_TX
326
#if !CONFIG_DAALA_DCT4
327 328 329 330
  if (tx_type == DCT_DCT) {
    aom_idct4x4_16_add(input, dest, stride);
    return;
  }
331
#endif
332
  static const transform_2d IHT_4[] = {
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
#if CONFIG_DAALA_DCT4
    { daala_idct4, daala_idct4 },    // DCT_DCT  = 0
    { aom_iadst4_c, daala_idct4 },   // ADST_DCT = 1
    { daala_idct4, aom_iadst4_c },   // DCT_ADST = 2
    { aom_iadst4_c, aom_iadst4_c },  // ADST_ADST = 3
#if CONFIG_EXT_TX
    { aom_iadst4_c, daala_idct4 },   // FLIPADST_DCT
    { daala_idct4, 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
    { daala_idct4, iidtx4_c },       // V_DCT
    { iidtx4_c, daala_idct4 },       // 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
#else
Luca Barbato's avatar
Luca Barbato committed
353 354 355 356
    { 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
357
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
358 359 360 361 362 363 364 365 366 367 368 369
    { 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
370
#endif
371
#endif
372 373 374
  };

  int i, j;
375
  tran_low_t tmp[4][4];
376 377 378
  tran_low_t out[4][4];
  tran_low_t *outp = &out[0][0];
  int outstride = 4;
379

380 381 382 383
#if CONFIG_DCT_ONLY
  assert(tx_type == DCT_DCT);
#endif

Lester Lu's avatar
Lester Lu committed
384
#if CONFIG_LGT
Lester Lu's avatar
Lester Lu committed
385 386 387 388
  const tran_high_t *lgtmtx_col[1];
  const tran_high_t *lgtmtx_row[1];
  int use_lgt_col = get_lgt4(txfm_param, 1, lgtmtx_col);
  int use_lgt_row = get_lgt4(txfm_param, 0, lgtmtx_row);
Lester Lu's avatar
Lester Lu committed
389 390
#endif

391 392
  // inverse transform row vectors
  for (i = 0; i < 4; ++i) {
393 394
#if CONFIG_DAALA_DCT4
    tran_low_t temp_in[4];
395
    for (j = 0; j < 4; j++) temp_in[j] = input[j] * 2;
396 397
    IHT_4[tx_type].rows(temp_in, out[i]);
#else
Lester Lu's avatar
Lester Lu committed
398 399
#if CONFIG_LGT
    if (use_lgt_row)
Lester Lu's avatar
Lester Lu committed
400
      ilgt4(input, out[i], lgtmtx_row[0]);
Lester Lu's avatar
Lester Lu committed
401 402 403
    else
#endif
      IHT_4[tx_type].rows(input, out[i]);
404
#endif
clang-format's avatar
clang-format committed
405
    input += 4;
406 407 408
  }

  // transpose
409 410 411
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      tmp[j][i] = out[i][j];
412
    }
413 414 415 416
  }

  // inverse transform column vectors
  for (i = 0; i < 4; ++i) {
Lester Lu's avatar
Lester Lu committed
417 418
#if CONFIG_LGT
    if (use_lgt_col)
Lester Lu's avatar
Lester Lu committed
419
      ilgt4(tmp[i], out[i], lgtmtx_col[0]);
Lester Lu's avatar
Lester Lu committed
420 421 422
    else
#endif
      IHT_4[tx_type].cols(tmp[i], out[i]);
423 424 425
  }

#if CONFIG_EXT_TX
426
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, 4, 4);
427 428 429 430
#endif

  // Sum with the destination
  for (i = 0; i < 4; ++i) {
431
    for (j = 0; j < 4; ++j) {
432 433
      int d = i * stride + j;
      int s = j * outstride + i;
434
#if CONFIG_DAALA_DCT4
435
      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 4));
436 437 438
#else
      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 4));
#endif
439 440 441 442
    }
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
443
void av1_iht4x8_32_add_c(const tran_low_t *input, uint8_t *dest, int stride,
444 445
                         const TxfmParam *txfm_param) {
  int tx_type = txfm_param->tx_type;
Sarah Parker's avatar
Sarah Parker committed
446 447 448
#if CONFIG_MRC_TX
  assert(tx_type != MRC_DCT && "Invalid tx type for tx size");
#endif  // CONFIG_MRC_TX
449 450 451
#if CONFIG_DCT_ONLY
  assert(tx_type == DCT_DCT);
#endif
452
  static const transform_2d IHT_4x8[] = {
Luca Barbato's avatar
Luca Barbato committed
453 454 455 456
    { 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
457
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
458 459 460 461 462 463 464 465 466 467 468 469
    { 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
470
#endif
471 472
  };

473 474
  const int n = 4;
  const int n2 = 8;
475
  int i, j;
476
  tran_low_t out[4][8], tmp[4][8], outtmp[4];
477
  tran_low_t *outp = &out[0][0];
478
  int outstride = n2;
479

Lester Lu's avatar
Lester Lu committed
480
#if CONFIG_LGT
Lester Lu's avatar
Lester Lu committed
481 482 483 484
  const tran_high_t *lgtmtx_col[1];
  const tran_high_t *lgtmtx_row[1];
  int use_lgt_col = get_lgt8(txfm_param, 1, lgtmtx_col);
  int use_lgt_row = get_lgt4(txfm_param, 0, lgtmtx_row);
Lester Lu's avatar
Lester Lu committed
485 486
#endif

487
  // inverse transform row vectors and transpose
488
  for (i = 0; i < n2; ++i) {
Lester Lu's avatar
Lester Lu committed
489 490
#if CONFIG_LGT
    if (use_lgt_row)
Lester Lu's avatar
Lester Lu committed
491
      ilgt4(input, outtmp, lgtmtx_row[0]);
Lester Lu's avatar
Lester Lu committed
492 493 494
    else
#endif
      IHT_4x8[tx_type].rows(input, outtmp);
495
    for (j = 0; j < n; ++j)
496
      tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
497
    input += n;
498 499 500
  }

  // inverse transform column vectors
501
  for (i = 0; i < n; ++i) {
Lester Lu's avatar
Lester Lu committed
502 503
#if CONFIG_LGT
    if (use_lgt_col)
Lester Lu's avatar
Lester Lu committed
504
      ilgt8(tmp[i], out[i], lgtmtx_col[0]);
Lester Lu's avatar
Lester Lu committed
505 506 507
    else
#endif
      IHT_4x8[tx_type].cols(tmp[i], out[i]);
508 509
  }

510
#if CONFIG_EXT_TX
511
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n);
512
#endif
513 514

  // Sum with the destination
515 516
  for (i = 0; i < n2; ++i) {
    for (j = 0; j < n; ++j) {
517 518 519 520 521 522 523
      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
524
void av1_iht8x4_32_add_c(const tran_low_t *input, uint8_t *dest, int stride,
525 526
                         const TxfmParam *txfm_param) {
  int tx_type = txfm_param->tx_type;
Sarah Parker's avatar
Sarah Parker committed
527 528 529
#if CONFIG_MRC_TX
  assert(tx_type != MRC_DCT && "Invalid tx type for tx size");
#endif  // CONFIG_MRC_TX
530 531 532
#if CONFIG_DCT_ONLY
  assert(tx_type == DCT_DCT);
#endif
533
  static const transform_2d IHT_8x4[] = {
Luca Barbato's avatar
Luca Barbato committed
534 535 536 537
    { 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
538
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
539 540 541 542 543 544 545 546 547 548 549 550
    { 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
551
#endif
552
  };
553

554 555
  const int n = 4;
  const int n2 = 8;
556 557

  int i, j;
558
  tran_low_t out[8][4], tmp[8][4], outtmp[8];
559
  tran_low_t *outp = &out[0][0];
560
  int outstride = n;
561

Lester Lu's avatar
Lester Lu committed
562
#if CONFIG_LGT
Lester Lu's avatar
Lester Lu committed
563 564 565 566
  const tran_high_t *lgtmtx_col[1];
  const tran_high_t *lgtmtx_row[1];
  int use_lgt_col = get_lgt4(txfm_param, 1, lgtmtx_col);
  int use_lgt_row = get_lgt8(txfm_param, 0, lgtmtx_row);
Lester Lu's avatar
Lester Lu committed
567 568
#endif

569
  // inverse transform row vectors and transpose
570
  for (i = 0; i < n; ++i) {
Lester Lu's avatar
Lester Lu committed
571 572
#if CONFIG_LGT
    if (use_lgt_row)
Lester Lu's avatar
Lester Lu committed
573
      ilgt8(input, outtmp, lgtmtx_row[0]);
Lester Lu's avatar
Lester Lu committed
574 575 576
    else
#endif
      IHT_8x4[tx_type].rows(input, outtmp);
577
    for (j = 0; j < n2; ++j)
578
      tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
579
    input += n2;
580 581 582
  }

  // inverse transform column vectors
583
  for (i = 0; i < n2; ++i) {
Lester Lu's avatar
Lester Lu committed
584 585
#if CONFIG_LGT
    if (use_lgt_col)
Lester Lu's avatar
Lester Lu committed
586
      ilgt4(tmp[i], out[i], lgtmtx_col[0]);
Lester Lu's avatar
Lester Lu committed
587 588 589
    else
#endif
      IHT_8x4[tx_type].cols(tmp[i], out[i]);
590 591
  }

592
#if CONFIG_EXT_TX
593
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2);
594
#endif
595 596

  // Sum with the destination
597 598
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n2; ++j) {
599 600 601 602 603 604 605
      int d = i * stride + j;
      int s = j * outstride + i;
      dest[d] = clip_pixel_add(dest[d], ROUND_POWER_OF_TWO(outp[s], 5));
    }
  }
}

606
void av1_iht4x16_64_add_c(const tran_low_t *input, uint8_t *dest, int stride,
607 608
                          const TxfmParam *txfm_param) {
  int tx_type = txfm_param->tx_type;
Sarah Parker's avatar
Sarah Parker committed
609 610 611
#if CONFIG_MRC_TX
  assert(tx_type != MRC_DCT && "Invalid tx type for tx size");
#endif  // CONFIG_MRC_TX
612 613 614
#if CONFIG_DCT_ONLY
  assert(tx_type == DCT_DCT);
#endif
615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638
  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;
639
  tran_low_t out[4][16], tmp[4][16], outtmp[4];
640 641 642
  tran_low_t *outp = &out[0][0];
  int outstride = n4;

Lester Lu's avatar
Lester Lu committed
643
#if CONFIG_LGT
Lester Lu's avatar
Lester Lu committed
644 645
  const tran_high_t *lgtmtx_row[1];
  int use_lgt_row = get_lgt4(txfm_param, 0, lgtmtx_row);
Lester Lu's avatar
Lester Lu committed
646 647
#endif

648 649
  // inverse transform row vectors and transpose
  for (i = 0; i < n4; ++i) {
Lester Lu's avatar
Lester Lu committed
650 651
#if CONFIG_LGT
    if (use_lgt_row)
Lester Lu's avatar
Lester Lu committed
652
      ilgt4(input, outtmp, lgtmtx_row[0]);
Lester Lu's avatar
Lester Lu committed
653 654 655
    else
#endif
      IHT_4x16[tx_type].rows(input, outtmp);
656
    for (j = 0; j < n; ++j) tmp[j][i] = outtmp[j];
657 658 659 660
    input += n;
  }

  // inverse transform column vectors
Lester Lu's avatar
Lester Lu committed
661 662 663
  for (i = 0; i < n; ++i) {
    IHT_4x16[tx_type].cols(tmp[i], out[i]);
  }
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679

#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,
680 681
                          const TxfmParam *txfm_param) {
  int tx_type = txfm_param->tx_type;
Sarah Parker's avatar
Sarah Parker committed
682 683 684
#if CONFIG_MRC_TX
  assert(tx_type != MRC_DCT && "Invalid tx type for tx size");
#endif  // CONFIG_MRC_TX
685 686 687
#if CONFIG_DCT_ONLY
  assert(tx_type == DCT_DCT);
#endif
688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707
  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
  };
708

709 710 711 712
  const int n = 4;
  const int n4 = 16;

  int i, j;
713
  tran_low_t out[16][4], tmp[16][4], outtmp[16];
714 715 716
  tran_low_t *outp = &out[0][0];
  int outstride = n;

Lester Lu's avatar
Lester Lu committed
717
#if CONFIG_LGT
Lester Lu's avatar
Lester Lu committed
718 719
  const tran_high_t *lgtmtx_col[1];
  int use_lgt_col = get_lgt4(txfm_param, 1, lgtmtx_col);
Lester Lu's avatar
Lester Lu committed
720 721
#endif

722 723 724
  // inverse transform row vectors and transpose
  for (i = 0; i < n; ++i) {
    IHT_16x4[tx_type].rows(input, outtmp);
725
    for (j = 0; j < n4; ++j) tmp[j][i] = outtmp[j];
726 727 728 729
    input += n4;
  }

  // inverse transform column vectors
Lester Lu's avatar
Lester Lu committed
730 731 732
  for (i = 0; i < n4; ++i) {
#if CONFIG_LGT
    if (use_lgt_col)
Lester Lu's avatar
Lester Lu committed
733
      ilgt4(tmp[i], out[i], lgtmtx_col[0]);
Lester Lu's avatar
Lester Lu committed
734 735 736 737
    else
#endif
      IHT_16x4[tx_type].cols(tmp[i], out[i]);
  }
738 739 740 741 742 743 744 745 746 747 748 749 750 751 752

#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
753
void av1_iht8x16_128_add_c(const tran_low_t *input, uint8_t *dest, int stride,
754 755
                           const TxfmParam *txfm_param) {
  int tx_type = txfm_param->tx_type;
Sarah Parker's avatar
Sarah Parker committed
756 757 758
#if CONFIG_MRC_TX
  assert(tx_type != MRC_DCT && "Invalid tx type for tx size");
#endif  // CONFIG_MRC_TX
759 760 761
#if CONFIG_DCT_ONLY
  assert(tx_type == DCT_DCT);
#endif
762
  static const transform_2d IHT_8x16[] = {
Luca Barbato's avatar
Luca Barbato committed
763 764 765 766
    { 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
767
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
768 769 770 771 772 773 774 775 776 777 778 779
    { 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
780
#endif
781 782 783 784 785
  };

  const int n = 8;
  const int n2 = 16;
  int i, j;
786
  tran_low_t out[8][16], tmp[8][16], outtmp[8];
787 788 789
  tran_low_t *outp = &out[0][0];
  int outstride = n2;

Lester Lu's avatar
Lester Lu committed
790
#if CONFIG_LGT
Lester Lu's avatar
Lester Lu committed
791 792
  const tran_high_t *lgtmtx_row[1];
  int use_lgt_row = get_lgt8(txfm_param, 0, lgtmtx_row);
Lester Lu's avatar
Lester Lu committed
793 794
#endif

795 796
  // inverse transform row vectors and transpose
  for (i = 0; i < n2; ++i) {
Lester Lu's avatar
Lester Lu committed
797 798
#if CONFIG_LGT
    if (use_lgt_row)
Lester Lu's avatar
Lester Lu committed
799
      ilgt8(input, outtmp, lgtmtx_row[0]);
Lester Lu's avatar
Lester Lu committed
800 801 802
    else
#endif
      IHT_8x16[tx_type].rows(input, outtmp);
803
    for (j = 0; j < n; ++j)
804
      tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
clang-format's avatar
clang-format committed
805
    input += n;
806 807 808 809
  }

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

813
#if CONFIG_EXT_TX
814
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n2, n);
815
#endif
816 817 818 819 820 821 822 823 824 825 826

  // 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
827
void av1_iht16x8_128_add_c(const tran_low_t *input, uint8_t *dest, int stride,
828 829
                           const TxfmParam *txfm_param) {
  int tx_type = txfm_param->tx_type;
Sarah Parker's avatar
Sarah Parker committed
830 831 832
#if CONFIG_MRC_TX
  assert(tx_type != MRC_DCT && "Invalid tx type for tx size");
#endif  // CONFIG_MRC_TX
833 834 835
#if CONFIG_DCT_ONLY
  assert(tx_type == DCT_DCT);
#endif
836
  static const transform_2d IHT_16x8[] = {
Luca Barbato's avatar
Luca Barbato committed
837 838 839 840
    { 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
841
#if CONFIG_EXT_TX
Luca Barbato's avatar
Luca Barbato committed
842 843 844 845 846 847 848 849 850 851 852 853
    { 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
854
#endif
855
  };
856

857 858 859 860
  const int n = 8;
  const int n2 = 16;

  int i, j;
861
  tran_low_t out[16][8], tmp[16][8], outtmp[16];
862 863 864
  tran_low_t *outp = &out[0][0];
  int outstride = n;

Lester Lu's avatar
Lester Lu committed
865
#if CONFIG_LGT
Lester Lu's avatar
Lester Lu committed
866 867
  const tran_high_t *lgtmtx_col[1];
  int use_lgt_col = get_lgt8(txfm_param, 1, lgtmtx_col);
Lester Lu's avatar
Lester Lu committed
868 869
#endif

870 871 872 873
  // 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)
874
      tmp[j][i] = (tran_low_t)dct_const_round_shift(outtmp[j] * Sqrt2);
clang-format's avatar
clang-format committed
875
    input += n2;
876 877 878 879
  }

  // inverse transform column vectors
  for (i = 0; i < n2; ++i) {
Lester Lu's avatar
Lester Lu committed
880 881
#if CONFIG_LGT
    if (use_lgt_col)
Lester Lu's avatar
Lester Lu committed
882
      ilgt8(tmp[i], out[i], lgtmtx_col[0]);
Lester Lu's avatar
Lester Lu committed
883 884 885
    else
#endif
      IHT_16x8[tx_type].cols(tmp[i], out[i]);
886 887
  }

888
#if CONFIG_EXT_TX
889
  maybe_flip_strides(&dest, &stride, &outp, &outstride, tx_type, n, n2);
890
#endif
891 892 893 894 895 896 897 898 899 900 901

  // 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));
    }
  }
}

902
void av1_iht8x32_256_add_c(const tran_low_t *input, uint8_t *dest, int stride,
903 904
                           const TxfmParam *txfm_param) {
  int tx_type = txfm_param->tx_type;
Sarah Parker's avatar
Sarah Parker committed
905 906 907
#if CONFIG_MRC_TX
  assert(tx_type != MRC_DCT && "Invalid tx type for tx size");
#endif  // CONFIG_MRC_TX
908 909 910
#if CONFIG_DCT_ONLY
  assert(tx_type == DCT_DCT);
#endif
911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934
  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;
935
  tran_low_t out[8][32], tmp[8][32], outtmp[8];
936 937 938
  tran_low_t *outp = &out[0][0];
  int outstride = n4;

Lester Lu's avatar
Lester Lu committed
939
#if CONFIG_LGT
Lester Lu's avatar
Lester Lu committed
940 941
  const tran_high_t *lgtmtx_row[1];
  int use_lgt_row = get_lgt8(txfm_param, 0, lgtmtx_row);
Lester Lu's avatar
Lester Lu committed
942 943
#endif

944 945
  // inverse transform row vectors and transpose
  for (i = 0; i < n4; ++i) {