hybrid_fwd_txfm.c 19.1 KB
Newer Older
Angie Chiang's avatar
Angie Chiang committed
1
/*
Yaowu Xu's avatar
Yaowu Xu committed
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Angie Chiang's avatar
Angie Chiang 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.
Angie Chiang's avatar
Angie Chiang committed
10 11
 */

Yaowu Xu's avatar
Yaowu Xu committed
12 13 14
#include "./av1_rtcd.h"
#include "./aom_config.h"
#include "./aom_dsp_rtcd.h"
Angie Chiang's avatar
Angie Chiang committed
15

16 17
#include "av1/common/idct.h"
#include "av1/encoder/hybrid_fwd_txfm.h"
Angie Chiang's avatar
Angie Chiang committed
18 19 20 21

static INLINE void fdct32x32(int rd_transform, const int16_t *src,
                             tran_low_t *dst, int src_stride) {
  if (rd_transform)
Yaowu Xu's avatar
Yaowu Xu committed
22
    aom_fdct32x32_rd(src, dst, src_stride);
Angie Chiang's avatar
Angie Chiang committed
23
  else
24
    av1_fht32x32(src, dst, src_stride, DCT_DCT);
Angie Chiang's avatar
Angie Chiang committed
25 26
}

27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
#if CONFIG_TX64X64
static INLINE void fdct64x64(const int16_t *src, tran_low_t *dst,
                             int src_stride) {
  av1_fht64x64(src, dst, src_stride, DCT_DCT);
}

static INLINE void fdct64x64_1(const int16_t *src, tran_low_t *dst,
                               int src_stride) {
  int i, j;
  int32_t sum = 0;
  memset(dst, 0, sizeof(*dst) * 4096);
  for (i = 0; i < 64; ++i)
    for (j = 0; j < 64; ++j) sum += src[i * src_stride + j];
  // Note: this scaling makes the transform 2 times unitary
  dst[0] = ROUND_POWER_OF_TWO_SIGNED(sum, 5);
}
#endif  // CONFIG_TX64X64

Jingning Han's avatar
Jingning Han committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
#if CONFIG_CB4X4
static void fwd_txfm_2x2(const int16_t *src_diff, tran_low_t *coeff,
                         int diff_stride, TX_TYPE tx_type, int lossless) {
  tran_high_t a1 = src_diff[0];
  tran_high_t b1 = src_diff[1];
  tran_high_t c1 = src_diff[diff_stride];
  tran_high_t d1 = src_diff[1 + diff_stride];

  tran_high_t a2 = a1 + c1;
  tran_high_t b2 = b1 + d1;
  tran_high_t c2 = a1 - c1;
  tran_high_t d2 = b1 - d1;

  a1 = a2 + b2;
  b1 = a2 - b2;
  c1 = c2 + d2;
  d1 = c2 - d2;

  coeff[0] = (tran_low_t)(4 * a1);
  coeff[1] = (tran_low_t)(4 * b1);
  coeff[2] = (tran_low_t)(4 * c1);
  coeff[3] = (tran_low_t)(4 * d1);

  (void)tx_type;
  (void)lossless;
}
#endif

73 74
static void fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
                         int diff_stride, TX_TYPE tx_type, int lossless) {
Angie Chiang's avatar
Angie Chiang committed
75 76
  if (lossless) {
    assert(tx_type == DCT_DCT);
Yaowu Xu's avatar
Yaowu Xu committed
77
    av1_fwht4x4(src_diff, coeff, diff_stride);
Angie Chiang's avatar
Angie Chiang committed
78 79 80 81 82 83 84
    return;
  }

  switch (tx_type) {
    case DCT_DCT:
    case ADST_DCT:
    case DCT_ADST:
Yaowu Xu's avatar
Yaowu Xu committed
85
    case ADST_ADST: av1_fht4x4(src_diff, coeff, diff_stride, tx_type); break;
Angie Chiang's avatar
Angie Chiang committed
86 87 88 89 90 91
#if CONFIG_EXT_TX
    case FLIPADST_DCT:
    case DCT_FLIPADST:
    case FLIPADST_FLIPADST:
    case ADST_FLIPADST:
    case FLIPADST_ADST:
Jingning Han's avatar
Jingning Han committed
92
    case V_DCT:
93 94 95 96
    case H_DCT:
    case V_ADST:
    case H_ADST:
    case V_FLIPADST:
Yaowu Xu's avatar
Yaowu Xu committed
97 98
    case H_FLIPADST: av1_fht4x4(src_diff, coeff, diff_stride, tx_type); break;
    case IDTX: av1_fwd_idtx_c(src_diff, coeff, diff_stride, 4, tx_type); break;
Angie Chiang's avatar
Angie Chiang committed
99
#endif  // CONFIG_EXT_TX
100
    default: assert(0);
Angie Chiang's avatar
Angie Chiang committed
101 102 103
  }
}

104
static void fwd_txfm_4x8(const int16_t *src_diff, tran_low_t *coeff,
105 106
                         int diff_stride, TX_TYPE tx_type,
                         FWD_TXFM_OPT fwd_txfm_opt) {
clang-format's avatar
clang-format committed
107
  (void)fwd_txfm_opt;
Yaowu Xu's avatar
Yaowu Xu committed
108
  av1_fht4x8(src_diff, coeff, diff_stride, tx_type);
109 110
}

111
static void fwd_txfm_8x4(const int16_t *src_diff, tran_low_t *coeff,
112 113
                         int diff_stride, TX_TYPE tx_type,
                         FWD_TXFM_OPT fwd_txfm_opt) {
clang-format's avatar
clang-format committed
114
  (void)fwd_txfm_opt;
Yaowu Xu's avatar
Yaowu Xu committed
115
  av1_fht8x4(src_diff, coeff, diff_stride, tx_type);
116 117 118 119 120
}

static void fwd_txfm_8x16(const int16_t *src_diff, tran_low_t *coeff,
                          int diff_stride, TX_TYPE tx_type,
                          FWD_TXFM_OPT fwd_txfm_opt) {
clang-format's avatar
clang-format committed
121
  (void)fwd_txfm_opt;
Yaowu Xu's avatar
Yaowu Xu committed
122
  av1_fht8x16(src_diff, coeff, diff_stride, tx_type);
123 124 125 126 127
}

static void fwd_txfm_16x8(const int16_t *src_diff, tran_low_t *coeff,
                          int diff_stride, TX_TYPE tx_type,
                          FWD_TXFM_OPT fwd_txfm_opt) {
clang-format's avatar
clang-format committed
128
  (void)fwd_txfm_opt;
Yaowu Xu's avatar
Yaowu Xu committed
129
  av1_fht16x8(src_diff, coeff, diff_stride, tx_type);
130 131 132 133 134
}

static void fwd_txfm_16x32(const int16_t *src_diff, tran_low_t *coeff,
                           int diff_stride, TX_TYPE tx_type,
                           FWD_TXFM_OPT fwd_txfm_opt) {
clang-format's avatar
clang-format committed
135
  (void)fwd_txfm_opt;
Yaowu Xu's avatar
Yaowu Xu committed
136
  av1_fht16x32(src_diff, coeff, diff_stride, tx_type);
137 138 139 140 141
}

static void fwd_txfm_32x16(const int16_t *src_diff, tran_low_t *coeff,
                           int diff_stride, TX_TYPE tx_type,
                           FWD_TXFM_OPT fwd_txfm_opt) {
clang-format's avatar
clang-format committed
142
  (void)fwd_txfm_opt;
Yaowu Xu's avatar
Yaowu Xu committed
143
  av1_fht32x16(src_diff, coeff, diff_stride, tx_type);
144 145
}

Angie Chiang's avatar
Angie Chiang committed
146 147 148 149 150 151 152 153 154
static void fwd_txfm_8x8(const int16_t *src_diff, tran_low_t *coeff,
                         int diff_stride, TX_TYPE tx_type,
                         FWD_TXFM_OPT fwd_txfm_opt) {
  switch (tx_type) {
    case DCT_DCT:
    case ADST_DCT:
    case DCT_ADST:
    case ADST_ADST:
      if (fwd_txfm_opt == FWD_TXFM_OPT_NORMAL)
Yaowu Xu's avatar
Yaowu Xu committed
155
        av1_fht8x8(src_diff, coeff, diff_stride, tx_type);
Angie Chiang's avatar
Angie Chiang committed
156
      else  // FWD_TXFM_OPT_DC
Yaowu Xu's avatar
Yaowu Xu committed
157
        aom_fdct8x8_1(src_diff, coeff, diff_stride);
Angie Chiang's avatar
Angie Chiang committed
158 159 160 161 162 163 164
      break;
#if CONFIG_EXT_TX
    case FLIPADST_DCT:
    case DCT_FLIPADST:
    case FLIPADST_FLIPADST:
    case ADST_FLIPADST:
    case FLIPADST_ADST:
Jingning Han's avatar
Jingning Han committed
165
    case V_DCT:
166 167 168 169
    case H_DCT:
    case V_ADST:
    case H_ADST:
    case V_FLIPADST:
Yaowu Xu's avatar
Yaowu Xu committed
170 171
    case H_FLIPADST: av1_fht8x8(src_diff, coeff, diff_stride, tx_type); break;
    case IDTX: av1_fwd_idtx_c(src_diff, coeff, diff_stride, 8, tx_type); break;
Angie Chiang's avatar
Angie Chiang committed
172
#endif  // CONFIG_EXT_TX
173
    default: assert(0);
Angie Chiang's avatar
Angie Chiang committed
174 175 176 177 178 179 180 181 182 183 184 185
  }
}

static void fwd_txfm_16x16(const int16_t *src_diff, tran_low_t *coeff,
                           int diff_stride, TX_TYPE tx_type,
                           FWD_TXFM_OPT fwd_txfm_opt) {
  switch (tx_type) {
    case DCT_DCT:
    case ADST_DCT:
    case DCT_ADST:
    case ADST_ADST:
      if (fwd_txfm_opt == FWD_TXFM_OPT_NORMAL)
Yaowu Xu's avatar
Yaowu Xu committed
186
        av1_fht16x16(src_diff, coeff, diff_stride, tx_type);
Angie Chiang's avatar
Angie Chiang committed
187
      else  // FWD_TXFM_OPT_DC
Yaowu Xu's avatar
Yaowu Xu committed
188
        aom_fdct16x16_1(src_diff, coeff, diff_stride);
Angie Chiang's avatar
Angie Chiang committed
189 190 191 192 193 194 195
      break;
#if CONFIG_EXT_TX
    case FLIPADST_DCT:
    case DCT_FLIPADST:
    case FLIPADST_FLIPADST:
    case ADST_FLIPADST:
    case FLIPADST_ADST:
Jingning Han's avatar
Jingning Han committed
196
    case V_DCT:
197 198 199 200
    case H_DCT:
    case V_ADST:
    case H_ADST:
    case V_FLIPADST:
Yaowu Xu's avatar
Yaowu Xu committed
201 202
    case H_FLIPADST: av1_fht16x16(src_diff, coeff, diff_stride, tx_type); break;
    case IDTX: av1_fwd_idtx_c(src_diff, coeff, diff_stride, 16, tx_type); break;
Angie Chiang's avatar
Angie Chiang committed
203
#endif  // CONFIG_EXT_TX
204
    default: assert(0);
Angie Chiang's avatar
Angie Chiang committed
205 206 207 208 209 210 211 212 213 214 215
  }
}

static void fwd_txfm_32x32(int rd_transform, const int16_t *src_diff,
                           tran_low_t *coeff, int diff_stride, TX_TYPE tx_type,
                           FWD_TXFM_OPT fwd_txfm_opt) {
  switch (tx_type) {
    case DCT_DCT:
      if (fwd_txfm_opt == FWD_TXFM_OPT_NORMAL)
        fdct32x32(rd_transform, src_diff, coeff, diff_stride);
      else  // FWD_TXFM_OPT_DC
Yaowu Xu's avatar
Yaowu Xu committed
216
        aom_fdct32x32_1(src_diff, coeff, diff_stride);
Angie Chiang's avatar
Angie Chiang committed
217 218 219 220 221
      break;
#if CONFIG_EXT_TX
    case ADST_DCT:
    case DCT_ADST:
    case ADST_ADST:
222 223 224 225 226
    case FLIPADST_DCT:
    case DCT_FLIPADST:
    case FLIPADST_FLIPADST:
    case ADST_FLIPADST:
    case FLIPADST_ADST:
227
      av1_fht32x32(src_diff, coeff, diff_stride, tx_type);
Angie Chiang's avatar
Angie Chiang committed
228
      break;
Jingning Han's avatar
Jingning Han committed
229
    case V_DCT:
230 231 232 233
    case H_DCT:
    case V_ADST:
    case H_ADST:
    case V_FLIPADST:
234
    case H_FLIPADST: av1_fht32x32(src_diff, coeff, diff_stride, tx_type); break;
Yaowu Xu's avatar
Yaowu Xu committed
235
    case IDTX: av1_fwd_idtx_c(src_diff, coeff, diff_stride, 32, tx_type); break;
236
#endif  // CONFIG_EXT_TX
237
    default: assert(0); break;
Angie Chiang's avatar
Angie Chiang committed
238 239 240
  }
}

241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
#if CONFIG_TX64X64
static void fwd_txfm_64x64(const int16_t *src_diff, tran_low_t *coeff,
                           int diff_stride, TX_TYPE tx_type,
                           FWD_TXFM_OPT fwd_txfm_opt) {
  switch (tx_type) {
    case DCT_DCT:
      if (fwd_txfm_opt == FWD_TXFM_OPT_NORMAL)
        fdct64x64(src_diff, coeff, diff_stride);
      else  // FWD_TXFM_OPT_DC
        fdct64x64_1(src_diff, coeff, diff_stride);
      break;
#if CONFIG_EXT_TX
    case ADST_DCT:
    case DCT_ADST:
    case ADST_ADST:
    case FLIPADST_DCT:
    case DCT_FLIPADST:
    case FLIPADST_FLIPADST:
    case ADST_FLIPADST:
    case FLIPADST_ADST:
      av1_fht64x64(src_diff, coeff, diff_stride, tx_type);
      break;
    case V_DCT:
    case H_DCT:
    case V_ADST:
    case H_ADST:
    case V_FLIPADST:
    case H_FLIPADST: av1_fht32x32(src_diff, coeff, diff_stride, tx_type); break;
    case IDTX: av1_fwd_idtx_c(src_diff, coeff, diff_stride, 64, tx_type); break;
#endif  // CONFIG_EXT_TX
    default: assert(0); break;
  }
}
#endif  // CONFIG_TX64X64

Yaowu Xu's avatar
Yaowu Xu committed
276
#if CONFIG_AOM_HIGHBITDEPTH
277 278 279
static void highbd_fwd_txfm_4x4(const int16_t *src_diff, tran_low_t *coeff,
                                int diff_stride, TX_TYPE tx_type, int lossless,
                                const int bd) {
Angie Chiang's avatar
Angie Chiang committed
280 281
  if (lossless) {
    assert(tx_type == DCT_DCT);
Yaowu Xu's avatar
Yaowu Xu committed
282
    av1_highbd_fwht4x4(src_diff, coeff, diff_stride);
Angie Chiang's avatar
Angie Chiang committed
283 284 285 286 287 288 289 290
    return;
  }

  switch (tx_type) {
    case DCT_DCT:
    case ADST_DCT:
    case DCT_ADST:
    case ADST_ADST:
Yaowu Xu's avatar
Yaowu Xu committed
291
      av1_fwd_txfm2d_4x4(src_diff, coeff, diff_stride, tx_type, bd);
Angie Chiang's avatar
Angie Chiang committed
292 293 294 295 296 297 298
      break;
#if CONFIG_EXT_TX
    case FLIPADST_DCT:
    case DCT_FLIPADST:
    case FLIPADST_FLIPADST:
    case ADST_FLIPADST:
    case FLIPADST_ADST:
Yaowu Xu's avatar
Yaowu Xu committed
299
      av1_fwd_txfm2d_4x4(src_diff, coeff, diff_stride, tx_type, bd);
Angie Chiang's avatar
Angie Chiang committed
300
      break;
301
    case V_DCT:
302 303 304 305 306
    case H_DCT:
    case V_ADST:
    case H_ADST:
    case V_FLIPADST:
    case H_FLIPADST:
Yaowu Xu's avatar
Yaowu Xu committed
307
      av1_highbd_fht4x4_c(src_diff, coeff, diff_stride, tx_type);
Debargha Mukherjee's avatar
Debargha Mukherjee committed
308
      break;
Yaowu Xu's avatar
Yaowu Xu committed
309
    case IDTX: av1_fwd_idtx_c(src_diff, coeff, diff_stride, 4, tx_type); break;
Angie Chiang's avatar
Angie Chiang committed
310
#endif  // CONFIG_EXT_TX
311
    default: assert(0);
Angie Chiang's avatar
Angie Chiang committed
312 313 314
  }
}

315
static void highbd_fwd_txfm_4x8(const int16_t *src_diff, tran_low_t *coeff,
316 317
                                int diff_stride, TX_TYPE tx_type,
                                FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
clang-format's avatar
clang-format committed
318 319
  (void)fwd_txfm_opt;
  (void)bd;
Yaowu Xu's avatar
Yaowu Xu committed
320
  av1_highbd_fht4x8(src_diff, coeff, diff_stride, tx_type);
321 322
}

323
static void highbd_fwd_txfm_8x4(const int16_t *src_diff, tran_low_t *coeff,
324 325
                                int diff_stride, TX_TYPE tx_type,
                                FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
clang-format's avatar
clang-format committed
326 327
  (void)fwd_txfm_opt;
  (void)bd;
Yaowu Xu's avatar
Yaowu Xu committed
328
  av1_highbd_fht8x4(src_diff, coeff, diff_stride, tx_type);
329 330 331 332 333
}

static void highbd_fwd_txfm_8x16(const int16_t *src_diff, tran_low_t *coeff,
                                 int diff_stride, TX_TYPE tx_type,
                                 FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
clang-format's avatar
clang-format committed
334 335
  (void)fwd_txfm_opt;
  (void)bd;
Yaowu Xu's avatar
Yaowu Xu committed
336
  av1_highbd_fht8x16(src_diff, coeff, diff_stride, tx_type);
337 338 339 340 341
}

static void highbd_fwd_txfm_16x8(const int16_t *src_diff, tran_low_t *coeff,
                                 int diff_stride, TX_TYPE tx_type,
                                 FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
clang-format's avatar
clang-format committed
342 343
  (void)fwd_txfm_opt;
  (void)bd;
Yaowu Xu's avatar
Yaowu Xu committed
344
  av1_highbd_fht16x8(src_diff, coeff, diff_stride, tx_type);
345 346 347 348 349
}

static void highbd_fwd_txfm_16x32(const int16_t *src_diff, tran_low_t *coeff,
                                  int diff_stride, TX_TYPE tx_type,
                                  FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
clang-format's avatar
clang-format committed
350 351
  (void)fwd_txfm_opt;
  (void)bd;
Yaowu Xu's avatar
Yaowu Xu committed
352
  av1_highbd_fht16x32(src_diff, coeff, diff_stride, tx_type);
353 354 355 356 357
}

static void highbd_fwd_txfm_32x16(const int16_t *src_diff, tran_low_t *coeff,
                                  int diff_stride, TX_TYPE tx_type,
                                  FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
clang-format's avatar
clang-format committed
358 359
  (void)fwd_txfm_opt;
  (void)bd;
Yaowu Xu's avatar
Yaowu Xu committed
360
  av1_highbd_fht32x16(src_diff, coeff, diff_stride, tx_type);
361 362
}

Angie Chiang's avatar
Angie Chiang committed
363 364
static void highbd_fwd_txfm_8x8(const int16_t *src_diff, tran_low_t *coeff,
                                int diff_stride, TX_TYPE tx_type,
365
                                FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
Angie Chiang's avatar
Angie Chiang committed
366 367 368 369 370 371
  (void)fwd_txfm_opt;
  switch (tx_type) {
    case DCT_DCT:
    case ADST_DCT:
    case DCT_ADST:
    case ADST_ADST:
Yaowu Xu's avatar
Yaowu Xu committed
372
      av1_fwd_txfm2d_8x8(src_diff, coeff, diff_stride, tx_type, bd);
Angie Chiang's avatar
Angie Chiang committed
373 374 375 376 377 378 379
      break;
#if CONFIG_EXT_TX
    case FLIPADST_DCT:
    case DCT_FLIPADST:
    case FLIPADST_FLIPADST:
    case ADST_FLIPADST:
    case FLIPADST_ADST:
Yaowu Xu's avatar
Yaowu Xu committed
380
      av1_fwd_txfm2d_8x8(src_diff, coeff, diff_stride, tx_type, bd);
Angie Chiang's avatar
Angie Chiang committed
381
      break;
Debargha Mukherjee's avatar
Debargha Mukherjee committed
382
    case V_DCT:
383 384 385 386 387
    case H_DCT:
    case V_ADST:
    case H_ADST:
    case V_FLIPADST:
    case H_FLIPADST:
Angie Chiang's avatar
Angie Chiang committed
388
      // Use C version since DST exists only in C
Yaowu Xu's avatar
Yaowu Xu committed
389
      av1_highbd_fht8x8_c(src_diff, coeff, diff_stride, tx_type);
Angie Chiang's avatar
Angie Chiang committed
390
      break;
Yaowu Xu's avatar
Yaowu Xu committed
391
    case IDTX: av1_fwd_idtx_c(src_diff, coeff, diff_stride, 8, tx_type); break;
Angie Chiang's avatar
Angie Chiang committed
392
#endif  // CONFIG_EXT_TX
393
    default: assert(0);
Angie Chiang's avatar
Angie Chiang committed
394 395 396 397 398
  }
}

static void highbd_fwd_txfm_16x16(const int16_t *src_diff, tran_low_t *coeff,
                                  int diff_stride, TX_TYPE tx_type,
399
                                  FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
Angie Chiang's avatar
Angie Chiang committed
400 401 402 403 404 405
  (void)fwd_txfm_opt;
  switch (tx_type) {
    case DCT_DCT:
    case ADST_DCT:
    case DCT_ADST:
    case ADST_ADST:
Yaowu Xu's avatar
Yaowu Xu committed
406
      av1_fwd_txfm2d_16x16(src_diff, coeff, diff_stride, tx_type, bd);
Angie Chiang's avatar
Angie Chiang committed
407 408 409 410 411 412 413
      break;
#if CONFIG_EXT_TX
    case FLIPADST_DCT:
    case DCT_FLIPADST:
    case FLIPADST_FLIPADST:
    case ADST_FLIPADST:
    case FLIPADST_ADST:
Yaowu Xu's avatar
Yaowu Xu committed
414
      av1_fwd_txfm2d_16x16(src_diff, coeff, diff_stride, tx_type, bd);
Angie Chiang's avatar
Angie Chiang committed
415
      break;
Debargha Mukherjee's avatar
Debargha Mukherjee committed
416
    case V_DCT:
417 418 419 420 421
    case H_DCT:
    case V_ADST:
    case H_ADST:
    case V_FLIPADST:
    case H_FLIPADST:
Angie Chiang's avatar
Angie Chiang committed
422
      // Use C version since DST exists only in C
Yaowu Xu's avatar
Yaowu Xu committed
423
      av1_highbd_fht16x16_c(src_diff, coeff, diff_stride, tx_type);
Angie Chiang's avatar
Angie Chiang committed
424
      break;
Yaowu Xu's avatar
Yaowu Xu committed
425
    case IDTX: av1_fwd_idtx_c(src_diff, coeff, diff_stride, 16, tx_type); break;
Angie Chiang's avatar
Angie Chiang committed
426
#endif  // CONFIG_EXT_TX
427
    default: assert(0);
Angie Chiang's avatar
Angie Chiang committed
428 429 430 431 432
  }
}

static void highbd_fwd_txfm_32x32(int rd_transform, const int16_t *src_diff,
                                  tran_low_t *coeff, int diff_stride,
433 434
                                  TX_TYPE tx_type, FWD_TXFM_OPT fwd_txfm_opt,
                                  const int bd) {
435 436
  (void)rd_transform;
  (void)fwd_txfm_opt;
Angie Chiang's avatar
Angie Chiang committed
437 438
  switch (tx_type) {
    case DCT_DCT:
Yaowu Xu's avatar
Yaowu Xu committed
439
      av1_fwd_txfm2d_32x32(src_diff, coeff, diff_stride, tx_type, bd);
Angie Chiang's avatar
Angie Chiang committed
440 441 442 443 444
      break;
#if CONFIG_EXT_TX
    case ADST_DCT:
    case DCT_ADST:
    case ADST_ADST:
445 446 447 448 449
    case FLIPADST_DCT:
    case DCT_FLIPADST:
    case FLIPADST_FLIPADST:
    case ADST_FLIPADST:
    case FLIPADST_ADST:
450
    case V_DCT:
451 452 453 454 455
    case H_DCT:
    case V_ADST:
    case H_ADST:
    case V_FLIPADST:
    case H_FLIPADST:
Yaowu Xu's avatar
Yaowu Xu committed
456
      av1_highbd_fht32x32_c(src_diff, coeff, diff_stride, tx_type);
457
      break;
Yaowu Xu's avatar
Yaowu Xu committed
458
    case IDTX: av1_fwd_idtx_c(src_diff, coeff, diff_stride, 32, tx_type); break;
459
#endif  // CONFIG_EXT_TX
460
    default: assert(0); break;
Angie Chiang's avatar
Angie Chiang committed
461 462
  }
}
463 464 465 466 467 468 469 470 471

#if CONFIG_TX64X64
static void highbd_fwd_txfm_64x64(const int16_t *src_diff, tran_low_t *coeff,
                                  int diff_stride, TX_TYPE tx_type,
                                  FWD_TXFM_OPT fwd_txfm_opt, const int bd) {
  (void)fwd_txfm_opt;
  (void)bd;
  switch (tx_type) {
    case DCT_DCT:
472
      av1_highbd_fht64x64(src_diff, coeff, diff_stride, tx_type);
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488
      break;
#if CONFIG_EXT_TX
    case ADST_DCT:
    case DCT_ADST:
    case ADST_ADST:
    case FLIPADST_DCT:
    case DCT_FLIPADST:
    case FLIPADST_FLIPADST:
    case ADST_FLIPADST:
    case FLIPADST_ADST:
    case V_DCT:
    case H_DCT:
    case V_ADST:
    case H_ADST:
    case V_FLIPADST:
    case H_FLIPADST:
489
      av1_highbd_fht64x64(src_diff, coeff, diff_stride, tx_type);
490 491 492 493 494 495 496
      break;
    case IDTX: av1_fwd_idtx_c(src_diff, coeff, diff_stride, 64, tx_type); break;
#endif  // CONFIG_EXT_TX
    default: assert(0); break;
  }
}
#endif  // CONFIG_TX64X64
Yaowu Xu's avatar
Yaowu Xu committed
497
#endif  // CONFIG_AOM_HIGHBITDEPTH
Angie Chiang's avatar
Angie Chiang committed
498 499 500 501 502 503 504 505 506

void fwd_txfm(const int16_t *src_diff, tran_low_t *coeff, int diff_stride,
              FWD_TXFM_PARAM *fwd_txfm_param) {
  const int fwd_txfm_opt = fwd_txfm_param->fwd_txfm_opt;
  const TX_TYPE tx_type = fwd_txfm_param->tx_type;
  const TX_SIZE tx_size = fwd_txfm_param->tx_size;
  const int rd_transform = fwd_txfm_param->rd_transform;
  const int lossless = fwd_txfm_param->lossless;
  switch (tx_size) {
507 508 509 510 511
#if CONFIG_TX64X64
    case TX_64X64:
      fwd_txfm_64x64(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
      break;
#endif  // CONFIG_TX64X64
Angie Chiang's avatar
Angie Chiang committed
512 513 514 515 516 517 518 519 520 521
    case TX_32X32:
      fwd_txfm_32x32(rd_transform, src_diff, coeff, diff_stride, tx_type,
                     fwd_txfm_opt);
      break;
    case TX_16X16:
      fwd_txfm_16x16(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
      break;
    case TX_8X8:
      fwd_txfm_8x8(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
      break;
522 523 524 525 526 527
    case TX_4X8:
      fwd_txfm_4x8(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
      break;
    case TX_8X4:
      fwd_txfm_8x4(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
      break;
528 529 530 531 532 533 534 535 536 537 538 539
    case TX_8X16:
      fwd_txfm_8x16(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
      break;
    case TX_16X8:
      fwd_txfm_16x8(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
      break;
    case TX_16X32:
      fwd_txfm_16x32(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
      break;
    case TX_32X16:
      fwd_txfm_32x16(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt);
      break;
Angie Chiang's avatar
Angie Chiang committed
540
    case TX_4X4:
541
      fwd_txfm_4x4(src_diff, coeff, diff_stride, tx_type, lossless);
Angie Chiang's avatar
Angie Chiang committed
542
      break;
Jingning Han's avatar
Jingning Han committed
543 544 545 546 547
#if CONFIG_CB4X4
    case TX_2X2:
      fwd_txfm_2x2(src_diff, coeff, diff_stride, tx_type, lossless);
      break;
#endif
548
    default: assert(0); break;
Angie Chiang's avatar
Angie Chiang committed
549 550 551
  }
}

Yaowu Xu's avatar
Yaowu Xu committed
552
#if CONFIG_AOM_HIGHBITDEPTH
Angie Chiang's avatar
Angie Chiang committed
553 554 555 556 557 558 559
void highbd_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff,
                     int diff_stride, FWD_TXFM_PARAM *fwd_txfm_param) {
  const int fwd_txfm_opt = fwd_txfm_param->fwd_txfm_opt;
  const TX_TYPE tx_type = fwd_txfm_param->tx_type;
  const TX_SIZE tx_size = fwd_txfm_param->tx_size;
  const int rd_transform = fwd_txfm_param->rd_transform;
  const int lossless = fwd_txfm_param->lossless;
560
  const int bd = fwd_txfm_param->bd;
Angie Chiang's avatar
Angie Chiang committed
561
  switch (tx_size) {
562 563 564 565 566 567
#if CONFIG_TX64X64
    case TX_64X64:
      highbd_fwd_txfm_64x64(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
                            bd);
      break;
#endif  // CONFIG_TX64X64
Angie Chiang's avatar
Angie Chiang committed
568 569
    case TX_32X32:
      highbd_fwd_txfm_32x32(rd_transform, src_diff, coeff, diff_stride, tx_type,
570
                            fwd_txfm_opt, bd);
Angie Chiang's avatar
Angie Chiang committed
571 572
      break;
    case TX_16X16:
573 574
      highbd_fwd_txfm_16x16(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
                            bd);
Angie Chiang's avatar
Angie Chiang committed
575 576
      break;
    case TX_8X8:
577 578
      highbd_fwd_txfm_8x8(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
                          bd);
Angie Chiang's avatar
Angie Chiang committed
579
      break;
580
    case TX_4X8:
581 582
      highbd_fwd_txfm_4x8(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
                          bd);
583 584
      break;
    case TX_8X4:
585 586
      highbd_fwd_txfm_8x4(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
                          bd);
587
      break;
588
    case TX_8X16:
clang-format's avatar
clang-format committed
589 590
      highbd_fwd_txfm_8x16(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
                           bd);
591 592
      break;
    case TX_16X8:
clang-format's avatar
clang-format committed
593 594
      highbd_fwd_txfm_16x8(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
                           bd);
595 596
      break;
    case TX_16X32:
clang-format's avatar
clang-format committed
597 598
      highbd_fwd_txfm_16x32(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
                            bd);
599 600
      break;
    case TX_32X16:
clang-format's avatar
clang-format committed
601 602
      highbd_fwd_txfm_32x16(src_diff, coeff, diff_stride, tx_type, fwd_txfm_opt,
                            bd);
603
      break;
Angie Chiang's avatar
Angie Chiang committed
604
    case TX_4X4:
clang-format's avatar
clang-format committed
605
      highbd_fwd_txfm_4x4(src_diff, coeff, diff_stride, tx_type, lossless, bd);
Angie Chiang's avatar
Angie Chiang committed
606
      break;
clang-format's avatar
clang-format committed
607
    default: assert(0); break;
Angie Chiang's avatar
Angie Chiang committed
608 609
  }
}
Yaowu Xu's avatar
Yaowu Xu committed
610
#endif  // CONFIG_AOM_HIGHBITDEPTH