idct.c 49.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include <math.h>

#include "./vp10_rtcd.h"
#include "./vpx_dsp_rtcd.h"
15
#include "vp10/common/blockd.h"
16
#include "vp10/common/enums.h"
17
#include "vp10/common/idct.h"
18 19 20
#include "vpx_dsp/inv_txfm.h"
#include "vpx_ports/mem.h"

21 22
#if CONFIG_EXT_TX
void idst4_c(const tran_low_t *input, tran_low_t *output) {
23 24 25
  // {sin(pi/5), sin(pi*2/5)} * sqrt(2/5) * sqrt(2)
  static const int32_t sinvalue_lookup[] = {
    141124871, 228344838,
26
  };
27 28 29 30 31 32 33 34 35 36 37 38 39
  int64_t sum;
  int64_t s03 = (input[0] + input[3]);
  int64_t d03 = (input[0] - input[3]);
  int64_t s12 = (input[1] + input[2]);
  int64_t d12 = (input[1] - input[2]);
  sum = s03 * sinvalue_lookup[0] + s12 * sinvalue_lookup[1];
  output[0] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = d03 * sinvalue_lookup[1] + d12 * sinvalue_lookup[0];
  output[1] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = s03 * sinvalue_lookup[1] - s12 * sinvalue_lookup[0];
  output[2] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = d03 * sinvalue_lookup[0] - d12 * sinvalue_lookup[1];
  output[3] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
40
}
41

42
void idst8_c(const tran_low_t *input, tran_low_t *output) {
43 44 45
  // {sin(pi/9), sin(pi*2/9), ..., sin(pi*4/9)} * sqrt(2/9) * 2
  static const int32_t sinvalue_lookup[] = {
    86559612, 162678858, 219176632, 249238470
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 73 74 75 76 77
  int64_t sum;
  int64_t s07 = (input[0] + input[7]);
  int64_t d07 = (input[0] - input[7]);
  int64_t s16 = (input[1] + input[6]);
  int64_t d16 = (input[1] - input[6]);
  int64_t s25 = (input[2] + input[5]);
  int64_t d25 = (input[2] - input[5]);
  int64_t s34 = (input[3] + input[4]);
  int64_t d34 = (input[3] - input[4]);
  sum = s07 * sinvalue_lookup[0] + s16 * sinvalue_lookup[1] +
        s25 * sinvalue_lookup[2] + s34 * sinvalue_lookup[3];
  output[0] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = d07 * sinvalue_lookup[1] + d16 * sinvalue_lookup[3] +
        d25 * sinvalue_lookup[2] + d34 * sinvalue_lookup[0];
  output[1] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = (s07 + s16 - s34)* sinvalue_lookup[2];
  output[2] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = d07 * sinvalue_lookup[3] + d16 * sinvalue_lookup[0] -
        d25 * sinvalue_lookup[2] - d34 * sinvalue_lookup[1];
  output[3] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = s07 * sinvalue_lookup[3] - s16 * sinvalue_lookup[0] -
        s25 * sinvalue_lookup[2] + s34 * sinvalue_lookup[1];
  output[4] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = (d07 - d16 + d34)* sinvalue_lookup[2];
  output[5] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = s07 * sinvalue_lookup[1] - s16 * sinvalue_lookup[3] +
        s25 * sinvalue_lookup[2] - s34 * sinvalue_lookup[0];
  output[6] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = d07 * sinvalue_lookup[0] - d16 * sinvalue_lookup[1] +
        d25 * sinvalue_lookup[2] - d34 * sinvalue_lookup[3];
  output[7] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
78
}
79

80
void idst16_c(const tran_low_t *input, tran_low_t *output) {
81 82 83 84
  // {sin(pi/17), sin(pi*2/17, ..., sin(pi*8/17)} * sqrt(2/17) * 2 * sqrt(2)
  static const int32_t sinvalue_lookup[] = {
    47852167, 94074787, 137093803, 175444254,
    207820161, 233119001, 250479254, 259309736
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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
  int64_t sum;
  int64_t s015 = (input[0] + input[15]);
  int64_t d015 = (input[0] - input[15]);
  int64_t s114 = (input[1] + input[14]);
  int64_t d114 = (input[1] - input[14]);
  int64_t s213 = (input[2] + input[13]);
  int64_t d213 = (input[2] - input[13]);
  int64_t s312 = (input[3] + input[12]);
  int64_t d312 = (input[3] - input[12]);
  int64_t s411 = (input[4] + input[11]);
  int64_t d411 = (input[4] - input[11]);
  int64_t s510 = (input[5] + input[10]);
  int64_t d510 = (input[5] - input[10]);
  int64_t s69  = (input[6] + input[9]);
  int64_t d69  = (input[6] - input[9]);
  int64_t s78  = (input[7] + input[8]);
  int64_t d78  = (input[7] - input[8]);
  sum = s015 * sinvalue_lookup[0] + s114 * sinvalue_lookup[1] +
        s213 * sinvalue_lookup[2] + s312 * sinvalue_lookup[3] +
        s411 * sinvalue_lookup[4] + s510 * sinvalue_lookup[5] +
        s69  * sinvalue_lookup[6] + s78  * sinvalue_lookup[7];
  output[0]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = d015 * sinvalue_lookup[1] + d114 * sinvalue_lookup[3] +
        d213 * sinvalue_lookup[5] + d312 * sinvalue_lookup[7] +
        d411 * sinvalue_lookup[6] + d510 * sinvalue_lookup[4] +
        d69  * sinvalue_lookup[2] + d78  * sinvalue_lookup[0];
  output[1]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = s015 * sinvalue_lookup[2] + s114 * sinvalue_lookup[5] +
        s213 * sinvalue_lookup[7] + s312 * sinvalue_lookup[4] +
        s411 * sinvalue_lookup[1] - s510 * sinvalue_lookup[0] -
        s69  * sinvalue_lookup[3] - s78  * sinvalue_lookup[6];
  output[2]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = d015 * sinvalue_lookup[3] + d114 * sinvalue_lookup[7] +
        d213 * sinvalue_lookup[4] + d312 * sinvalue_lookup[0] -
        d411 * sinvalue_lookup[2] - d510 * sinvalue_lookup[6] -
        d69  * sinvalue_lookup[5] - d78  * sinvalue_lookup[1];
  output[3]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = s015 * sinvalue_lookup[4] + s114 * sinvalue_lookup[6] +
        s213 * sinvalue_lookup[1] - s312 * sinvalue_lookup[2] -
        s411 * sinvalue_lookup[7] - s510 * sinvalue_lookup[3] +
        s69  * sinvalue_lookup[0] + s78  * sinvalue_lookup[5];
  output[4]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = d015 * sinvalue_lookup[5] + d114 * sinvalue_lookup[4] -
        d213 * sinvalue_lookup[0] - d312 * sinvalue_lookup[6] -
        d411 * sinvalue_lookup[3] + d510 * sinvalue_lookup[1] +
        d69  * sinvalue_lookup[7] + d78  * sinvalue_lookup[2];
  output[5]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = s015 * sinvalue_lookup[6] + s114 * sinvalue_lookup[2] -
        s213 * sinvalue_lookup[3] - s312 * sinvalue_lookup[5] +
        s411 * sinvalue_lookup[0] + s510 * sinvalue_lookup[7] +
        s69  * sinvalue_lookup[1] - s78  * sinvalue_lookup[4];
  output[6]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = d015 * sinvalue_lookup[7] + d114 * sinvalue_lookup[0] -
        d213 * sinvalue_lookup[6] - d312 * sinvalue_lookup[1] +
        d411 * sinvalue_lookup[5] + d510 * sinvalue_lookup[2] -
        d69  * sinvalue_lookup[4] - d78  * sinvalue_lookup[3];
  output[7]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = s015 * sinvalue_lookup[7] - s114 * sinvalue_lookup[0] -
        s213 * sinvalue_lookup[6] + s312 * sinvalue_lookup[1] +
        s411 * sinvalue_lookup[5] - s510 * sinvalue_lookup[2] -
        s69  * sinvalue_lookup[4] + s78  * sinvalue_lookup[3];
  output[8]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = d015 * sinvalue_lookup[6] - d114 * sinvalue_lookup[2] -
        d213 * sinvalue_lookup[3] + d312 * sinvalue_lookup[5] +
        d411 * sinvalue_lookup[0] - d510 * sinvalue_lookup[7] +
        d69  * sinvalue_lookup[1] + d78  * sinvalue_lookup[4];
  output[9]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = s015 * sinvalue_lookup[5] - s114 * sinvalue_lookup[4] -
        s213 * sinvalue_lookup[0] + s312 * sinvalue_lookup[6] -
        s411 * sinvalue_lookup[3] - s510 * sinvalue_lookup[1] +
        s69  * sinvalue_lookup[7] - s78  * sinvalue_lookup[2];
  output[10] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = d015 * sinvalue_lookup[4] - d114 * sinvalue_lookup[6] +
        d213 * sinvalue_lookup[1] + d312 * sinvalue_lookup[2] -
        d411 * sinvalue_lookup[7] + d510 * sinvalue_lookup[3] +
        d69  * sinvalue_lookup[0] - d78  * sinvalue_lookup[5];
  output[11] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = s015 * sinvalue_lookup[3] - s114 * sinvalue_lookup[7] +
        s213 * sinvalue_lookup[4] - s312 * sinvalue_lookup[0] -
        s411 * sinvalue_lookup[2] + s510 * sinvalue_lookup[6] -
        s69  * sinvalue_lookup[5] + s78  * sinvalue_lookup[1];
  output[12] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = d015 * sinvalue_lookup[2] - d114 * sinvalue_lookup[5] +
        d213 * sinvalue_lookup[7] - d312 * sinvalue_lookup[4] +
        d411 * sinvalue_lookup[1] + d510 * sinvalue_lookup[0] -
        d69  * sinvalue_lookup[3] + d78  * sinvalue_lookup[6];
  output[13] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = s015 * sinvalue_lookup[1] - s114 * sinvalue_lookup[3] +
        s213 * sinvalue_lookup[5] - s312 * sinvalue_lookup[7] +
        s411 * sinvalue_lookup[6] - s510 * sinvalue_lookup[4] +
        s69  * sinvalue_lookup[2] - s78  * sinvalue_lookup[0];
  output[14] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
  sum = d015 * sinvalue_lookup[0] - d114 * sinvalue_lookup[1] +
        d213 * sinvalue_lookup[2] - d312 * sinvalue_lookup[3] +
        d411 * sinvalue_lookup[4] - d510 * sinvalue_lookup[5] +
        d69  * sinvalue_lookup[6] - d78  * sinvalue_lookup[7];
  output[15] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), 8);
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 220 221 222 223 224 225 226 227 228 229 230
static void fliplr(uint8_t *dest, int stride, int l) {
  int i, j;
  for (i = 0; i < l; ++i) {
    for (j = 0; j < l / 2; ++j) {
      const uint8_t tmp = dest[i * stride + j];
      dest[i * stride + j] = dest[i * stride + l - 1 - j];
      dest[i * stride + l - 1 - j] = tmp;
    }
  }
}

static void flipud(uint8_t *dest, int stride, int l) {
  int i, j;
  for (j = 0; j < l; ++j) {
    for (i = 0; i < l / 2; ++i) {
      const uint8_t tmp = dest[i * stride + j];
      dest[i * stride + j] = dest[(l - 1 - i) * stride + j];
      dest[(l - 1 - i) * stride + j] = tmp;
    }
  }
}

static void fliplrud(uint8_t *dest, int stride, int l) {
  int i, j;
  for (i = 0; i < l / 2; ++i) {
    for (j = 0; j < l; ++j) {
      const uint8_t tmp = dest[i * stride + j];
      dest[i * stride + j] = dest[(l - 1 - i) * stride + l - 1 - j];
      dest[(l - 1 - i) * stride + l - 1 - j] = tmp;
    }
  }
}

// Inverse identiy transform and add.
static void inv_idtx_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                           int bs) {
  int r, c;
  const int shift = bs < 32 ? 3 : 2;
  for (r = 0; r < bs; ++r) {
    for (c = 0; c < bs; ++c)
      dest[c] = clip_pixel_add(dest[c], input[c] >> shift);
    dest += stride;
    input += bs;
  }
}

231 232
#if CONFIG_VP9_HIGHBITDEPTH
void highbd_idst4_c(const tran_low_t *input, tran_low_t *output, int bd) {
233 234 235
  // {sin(pi/5), sin(pi*2/5)} * sqrt(2/5) * sqrt(2)
  static const int32_t sinvalue_lookup[] = {
    141124871, 228344838,
236
  };
237 238 239 240 241 242
  int64_t sum;
  int64_t s03 = (input[0] + input[3]);
  int64_t d03 = (input[0] - input[3]);
  int64_t s12 = (input[1] + input[2]);
  int64_t d12 = (input[1] - input[2]);

243 244 245 246
#if !CONFIG_EMULATE_HARDWARE
  (void)bd;
#endif

247 248 249 250 251 252 253 254
  sum = s03 * sinvalue_lookup[0] + s12 * sinvalue_lookup[1];
  output[0] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = d03 * sinvalue_lookup[1] + d12 * sinvalue_lookup[0];
  output[1] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = s03 * sinvalue_lookup[1] - s12 * sinvalue_lookup[0];
  output[2] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = d03 * sinvalue_lookup[0] - d12 * sinvalue_lookup[1];
  output[3] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
255 256
}

257
void highbd_idst8_c(const tran_low_t *input, tran_low_t *output, int bd) {
258 259 260
  // {sin(pi/9), sin(pi*2/9), ..., sin(pi*4/9)} * sqrt(2/9) * 2
  static const int32_t sinvalue_lookup[] = {
    86559612, 162678858, 219176632, 249238470
261
  };
262 263 264 265 266 267 268 269 270 271
  int64_t sum;
  int64_t s07 = (input[0] + input[7]);
  int64_t d07 = (input[0] - input[7]);
  int64_t s16 = (input[1] + input[6]);
  int64_t d16 = (input[1] - input[6]);
  int64_t s25 = (input[2] + input[5]);
  int64_t d25 = (input[2] - input[5]);
  int64_t s34 = (input[3] + input[4]);
  int64_t d34 = (input[3] - input[4]);

272 273 274 275
#if !CONFIG_EMULATE_HARDWARE
  (void)bd;
#endif

276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
  sum = s07 * sinvalue_lookup[0] + s16 * sinvalue_lookup[1] +
        s25 * sinvalue_lookup[2] + s34 * sinvalue_lookup[3];
  output[0] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = d07 * sinvalue_lookup[1] + d16 * sinvalue_lookup[3] +
        d25 * sinvalue_lookup[2] + d34 * sinvalue_lookup[0];
  output[1] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = (s07 + s16 - s34)* sinvalue_lookup[2];
  output[2] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = d07 * sinvalue_lookup[3] + d16 * sinvalue_lookup[0] -
        d25 * sinvalue_lookup[2] - d34 * sinvalue_lookup[1];
  output[3] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = s07 * sinvalue_lookup[3] - s16 * sinvalue_lookup[0] -
        s25 * sinvalue_lookup[2] + s34 * sinvalue_lookup[1];
  output[4] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = (d07 - d16 + d34)* sinvalue_lookup[2];
  output[5] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = s07 * sinvalue_lookup[1] - s16 * sinvalue_lookup[3] +
        s25 * sinvalue_lookup[2] - s34 * sinvalue_lookup[0];
  output[6] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = d07 * sinvalue_lookup[0] - d16 * sinvalue_lookup[1] +
        d25 * sinvalue_lookup[2] - d34 * sinvalue_lookup[3];
  output[7] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
298 299 300
}

void highbd_idst16_c(const tran_low_t *input, tran_low_t *output, int bd) {
301 302 303 304
  // {sin(pi/17), sin(pi*2/17, ..., sin(pi*8/17)} * sqrt(2/17) * 2 * sqrt(2)
  static const int32_t sinvalue_lookup[] = {
    47852167, 94074787, 137093803, 175444254,
    207820161, 233119001, 250479254, 259309736
305
  };
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
  int64_t sum;
  int64_t s015 = (input[0] + input[15]);
  int64_t d015 = (input[0] - input[15]);
  int64_t s114 = (input[1] + input[14]);
  int64_t d114 = (input[1] - input[14]);
  int64_t s213 = (input[2] + input[13]);
  int64_t d213 = (input[2] - input[13]);
  int64_t s312 = (input[3] + input[12]);
  int64_t d312 = (input[3] - input[12]);
  int64_t s411 = (input[4] + input[11]);
  int64_t d411 = (input[4] - input[11]);
  int64_t s510 = (input[5] + input[10]);
  int64_t d510 = (input[5] - input[10]);
  int64_t s69  = (input[6] + input[9]);
  int64_t d69  = (input[6] - input[9]);
  int64_t s78  = (input[7] + input[8]);
  int64_t d78  = (input[7] - input[8]);
323 324 325 326 327

#if !CONFIG_EMULATE_HARDWARE
  (void)bd;
#endif

328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
  sum = s015 * sinvalue_lookup[0] + s114 * sinvalue_lookup[1] +
        s213 * sinvalue_lookup[2] + s312 * sinvalue_lookup[3] +
        s411 * sinvalue_lookup[4] + s510 * sinvalue_lookup[5] +
        s69  * sinvalue_lookup[6] + s78  * sinvalue_lookup[7];
  output[0]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = d015 * sinvalue_lookup[1] + d114 * sinvalue_lookup[3] +
        d213 * sinvalue_lookup[5] + d312 * sinvalue_lookup[7] +
        d411 * sinvalue_lookup[6] + d510 * sinvalue_lookup[4] +
        d69  * sinvalue_lookup[2] + d78  * sinvalue_lookup[0];
  output[1]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = s015 * sinvalue_lookup[2] + s114 * sinvalue_lookup[5] +
        s213 * sinvalue_lookup[7] + s312 * sinvalue_lookup[4] +
        s411 * sinvalue_lookup[1] - s510 * sinvalue_lookup[0] -
        s69  * sinvalue_lookup[3] - s78  * sinvalue_lookup[6];
  output[2]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = d015 * sinvalue_lookup[3] + d114 * sinvalue_lookup[7] +
        d213 * sinvalue_lookup[4] + d312 * sinvalue_lookup[0] -
        d411 * sinvalue_lookup[2] - d510 * sinvalue_lookup[6] -
        d69  * sinvalue_lookup[5] - d78  * sinvalue_lookup[1];
  output[3]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = s015 * sinvalue_lookup[4] + s114 * sinvalue_lookup[6] +
        s213 * sinvalue_lookup[1] - s312 * sinvalue_lookup[2] -
        s411 * sinvalue_lookup[7] - s510 * sinvalue_lookup[3] +
        s69  * sinvalue_lookup[0] + s78  * sinvalue_lookup[5];
  output[4]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = d015 * sinvalue_lookup[5] + d114 * sinvalue_lookup[4] -
        d213 * sinvalue_lookup[0] - d312 * sinvalue_lookup[6] -
        d411 * sinvalue_lookup[3] + d510 * sinvalue_lookup[1] +
        d69  * sinvalue_lookup[7] + d78  * sinvalue_lookup[2];
  output[5]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = s015 * sinvalue_lookup[6] + s114 * sinvalue_lookup[2] -
        s213 * sinvalue_lookup[3] - s312 * sinvalue_lookup[5] +
        s411 * sinvalue_lookup[0] + s510 * sinvalue_lookup[7] +
        s69  * sinvalue_lookup[1] - s78  * sinvalue_lookup[4];
  output[6]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = d015 * sinvalue_lookup[7] + d114 * sinvalue_lookup[0] -
        d213 * sinvalue_lookup[6] - d312 * sinvalue_lookup[1] +
        d411 * sinvalue_lookup[5] + d510 * sinvalue_lookup[2] -
        d69  * sinvalue_lookup[4] - d78  * sinvalue_lookup[3];
  output[7]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = s015 * sinvalue_lookup[7] - s114 * sinvalue_lookup[0] -
        s213 * sinvalue_lookup[6] + s312 * sinvalue_lookup[1] +
        s411 * sinvalue_lookup[5] - s510 * sinvalue_lookup[2] -
        s69  * sinvalue_lookup[4] + s78  * sinvalue_lookup[3];
  output[8]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = d015 * sinvalue_lookup[6] - d114 * sinvalue_lookup[2] -
        d213 * sinvalue_lookup[3] + d312 * sinvalue_lookup[5] +
        d411 * sinvalue_lookup[0] - d510 * sinvalue_lookup[7] +
        d69  * sinvalue_lookup[1] + d78  * sinvalue_lookup[4];
  output[9]  = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = s015 * sinvalue_lookup[5] - s114 * sinvalue_lookup[4] -
        s213 * sinvalue_lookup[0] + s312 * sinvalue_lookup[6] -
        s411 * sinvalue_lookup[3] - s510 * sinvalue_lookup[1] +
        s69  * sinvalue_lookup[7] - s78  * sinvalue_lookup[2];
  output[10] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = d015 * sinvalue_lookup[4] - d114 * sinvalue_lookup[6] +
        d213 * sinvalue_lookup[1] + d312 * sinvalue_lookup[2] -
        d411 * sinvalue_lookup[7] + d510 * sinvalue_lookup[3] +
        d69  * sinvalue_lookup[0] - d78  * sinvalue_lookup[5];
  output[11] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = s015 * sinvalue_lookup[3] - s114 * sinvalue_lookup[7] +
        s213 * sinvalue_lookup[4] - s312 * sinvalue_lookup[0] -
        s411 * sinvalue_lookup[2] + s510 * sinvalue_lookup[6] -
        s69  * sinvalue_lookup[5] + s78  * sinvalue_lookup[1];
  output[12] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = d015 * sinvalue_lookup[2] - d114 * sinvalue_lookup[5] +
        d213 * sinvalue_lookup[7] - d312 * sinvalue_lookup[4] +
        d411 * sinvalue_lookup[1] + d510 * sinvalue_lookup[0] -
        d69  * sinvalue_lookup[3] + d78  * sinvalue_lookup[6];
  output[13] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = s015 * sinvalue_lookup[1] - s114 * sinvalue_lookup[3] +
        s213 * sinvalue_lookup[5] - s312 * sinvalue_lookup[7] +
        s411 * sinvalue_lookup[6] - s510 * sinvalue_lookup[4] +
        s69  * sinvalue_lookup[2] - s78  * sinvalue_lookup[0];
  output[14] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
  sum = d015 * sinvalue_lookup[0] - d114 * sinvalue_lookup[1] +
        d213 * sinvalue_lookup[2] - d312 * sinvalue_lookup[3] +
        d411 * sinvalue_lookup[4] - d510 * sinvalue_lookup[5] +
        d69  * sinvalue_lookup[6] - d78  * sinvalue_lookup[7];
  output[15] = WRAPLOW(ROUND_POWER_OF_TWO(sum, (2 * DCT_CONST_BITS)), bd);
408
}
409

410
static void fliplr16(uint16_t *dest, int stride, int l) {
411 412 413
  int i, j;
  for (i = 0; i < l; ++i) {
    for (j = 0; j < l / 2; ++j) {
414
      const uint16_t tmp = dest[i * stride + j];
415 416 417 418 419 420
      dest[i * stride + j] = dest[i * stride + l - 1 - j];
      dest[i * stride + l - 1 - j] = tmp;
    }
  }
}

421
static void flipud16(uint16_t *dest, int stride, int l) {
422 423 424
  int i, j;
  for (j = 0; j < l; ++j) {
    for (i = 0; i < l / 2; ++i) {
425
      const uint16_t tmp = dest[i * stride + j];
426 427 428 429 430 431
      dest[i * stride + j] = dest[(l - 1 - i) * stride + j];
      dest[(l - 1 - i) * stride + j] = tmp;
    }
  }
}

432
static void fliplrud16(uint16_t *dest, int stride, int l) {
433 434 435
  int i, j;
  for (i = 0; i < l / 2; ++i) {
    for (j = 0; j < l; ++j) {
436
      const uint16_t tmp = dest[i * stride + j];
437 438 439 440 441 442
      dest[i * stride + j] = dest[(l - 1 - i) * stride + l - 1 - j];
      dest[(l - 1 - i) * stride + l - 1 - j] = tmp;
    }
  }
}

443 444 445 446 447
static void highbd_inv_idtx_add_c(const tran_low_t *input, uint8_t *dest8,
                                  int stride, int bs, int bd) {
  int r, c;
  const int shift = bs < 32 ? 3 : 2;
  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
448

449 450 451 452 453
  for (r = 0; r < bs; ++r) {
    for (c = 0; c < bs; ++c)
      dest[c] = highbd_clip_pixel_add(dest[c], input[c] >> shift, bd);
    dest += stride;
    input += bs;
454 455
  }
}
456
#endif  // CONFIG_VP9_HIGHBITDEPTH
457 458
#endif  // CONFIG_EXT_TX

459
void vp10_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest, int stride,
460
                          int tx_type) {
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505
  const transform_2d IHT_4[] = {
    { idct4_c, idct4_c  },   // DCT_DCT  = 0
    { iadst4_c, idct4_c  },  // ADST_DCT = 1
    { idct4_c, iadst4_c },   // DCT_ADST = 2
    { iadst4_c, iadst4_c },  // ADST_ADST = 3
#if CONFIG_EXT_TX
    { iadst4_c, idct4_c },   // FLIPADST_DCT = 4
    { idct4_c,  iadst4_c },  // DCT_FLIPADST = 5
    { iadst4_c, iadst4_c },  // FLIPADST_FLIPADST = 6
    { iadst4_c, iadst4_c },  // ADST_FLIPADST = 7
    { iadst4_c, iadst4_c },  // FLIPADST_ADST = 8
    { idst4_c,  idst4_c },   // DST_DST = 9
    { idst4_c,  idct4_c  },  // DST_DCT = 10
    { idct4_c,  idst4_c  },  // DCT_DST = 11
    { idst4_c,  iadst4_c },  // DST_ADST = 12
    { iadst4_c, idst4_c  },  // ADST_DST = 13
    { idst4_c,  iadst4_c },  // DST_FLIPADST = 14
    { iadst4_c, idst4_c  },  // FLIPADST_DST = 15
#endif  // CONFIG_EXT_TX
  };

  int i, j;
  tran_low_t out[4 * 4];
  tran_low_t *outptr = out;
  tran_low_t temp_in[4], temp_out[4];

  // inverse transform row vectors
  for (i = 0; i < 4; ++i) {
    IHT_4[tx_type].rows(input, outptr);
    input  += 4;
    outptr += 4;
  }

  // inverse transform column vectors
  for (i = 0; i < 4; ++i) {
    for (j = 0; j < 4; ++j)
      temp_in[j] = out[j * 4 + i];
    IHT_4[tx_type].cols(temp_in, temp_out);
    for (j = 0; j < 4; ++j) {
      dest[j * stride + i] = clip_pixel_add(dest[j * stride + i],
                                            ROUND_POWER_OF_TWO(temp_out[j], 4));
    }
  }
}

506 507
void vp10_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                         int tx_type) {
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528
  static const transform_2d IHT_8[] = {
    { idct8_c,  idct8_c  },  // DCT_DCT  = 0
    { iadst8_c, idct8_c  },  // ADST_DCT = 1
    { idct8_c,  iadst8_c },  // DCT_ADST = 2
    { iadst8_c, iadst8_c },  // ADST_ADST = 3
#if CONFIG_EXT_TX
    { iadst8_c, idct8_c },   // FLIPADST_DCT = 4
    { idct8_c,  iadst8_c },  // DCT_FLIPADST = 5
    { iadst8_c, iadst8_c },  // FLIPADST_FLIPADST = 6
    { iadst8_c, iadst8_c },  // ADST_FLIPADST = 7
    { iadst8_c, iadst8_c },  // FLIPADST_ADST = 8
    { idst8_c,  idst8_c },   // DST_DST = 9
    { idst8_c,  idct8_c  },  // DST_DCT = 10
    { idct8_c,  idst8_c  },  // DCT_DST = 11
    { idst8_c,  iadst8_c },  // DST_ADST = 12
    { iadst8_c, idst8_c  },  // ADST_DST = 13
    { idst8_c,  iadst8_c },  // DST_FLIPADST = 14
    { iadst8_c, idst8_c  },  // FLIPADST_DST = 15
#endif  // CONFIG_EXT_TX
  };

529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555
  int i, j;
  tran_low_t out[8 * 8];
  tran_low_t *outptr = out;
  tran_low_t temp_in[8], temp_out[8];
  const transform_2d ht = IHT_8[tx_type];

  // inverse transform row vectors
  for (i = 0; i < 8; ++i) {
    ht.rows(input, outptr);
    input += 8;
    outptr += 8;
  }

  // inverse transform column vectors
  for (i = 0; i < 8; ++i) {
    for (j = 0; j < 8; ++j)
      temp_in[j] = out[j * 8 + i];
    ht.cols(temp_in, temp_out);
    for (j = 0; j < 8; ++j) {
      dest[j * stride + i] = clip_pixel_add(dest[j * stride + i],
                                            ROUND_POWER_OF_TWO(temp_out[j], 5));
    }
  }
}

void vp10_iht16x16_256_add_c(const tran_low_t *input, uint8_t *dest, int stride,
                            int tx_type) {
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576
  static const transform_2d IHT_16[] = {
    { idct16_c,  idct16_c  },  // DCT_DCT  = 0
    { iadst16_c, idct16_c  },  // ADST_DCT = 1
    { idct16_c,  iadst16_c },  // DCT_ADST = 2
    { iadst16_c, iadst16_c },  // ADST_ADST = 3
#if CONFIG_EXT_TX
    { iadst16_c, idct16_c  },  // FLIPADST_DCT = 4
    { idct16_c,  iadst16_c },  // DCT_FLIPADST = 5
    { iadst16_c, iadst16_c },  // FLIPADST_FLIPADST = 6
    { iadst16_c, iadst16_c },  // ADST_FLIPADST = 7
    { iadst16_c, iadst16_c },  // FLIPADST_ADST = 8
    { idst16_c,  idst16_c  },  // DST_DST = 9
    { idst16_c,  idct16_c  },  // DST_DCT = 10
    { idct16_c,  idst16_c  },  // DCT_DST = 11
    { idst16_c,  iadst16_c },  // DST_ADST = 12
    { iadst16_c, idst16_c  },  // ADST_DST = 13
    { idst16_c,  iadst16_c },  // DST_FLIPADST = 14
    { iadst16_c, idst16_c  },  // FLIPADST_DST = 15
#endif  // CONFIG_EXT_TX
  };

577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661
  int i, j;
  tran_low_t out[16 * 16];
  tran_low_t *outptr = out;
  tran_low_t temp_in[16], temp_out[16];
  const transform_2d ht = IHT_16[tx_type];

  // Rows
  for (i = 0; i < 16; ++i) {
    ht.rows(input, outptr);
    input += 16;
    outptr += 16;
  }

  // Columns
  for (i = 0; i < 16; ++i) {
    for (j = 0; j < 16; ++j)
      temp_in[j] = out[j * 16 + i];
    ht.cols(temp_in, temp_out);
    for (j = 0; j < 16; ++j) {
      dest[j * stride + i] = clip_pixel_add(dest[j * stride + i],
                                            ROUND_POWER_OF_TWO(temp_out[j], 6));
    }
  }
}

// idct
void vp10_idct4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
                     int eob) {
  if (eob > 1)
    vpx_idct4x4_16_add(input, dest, stride);
  else
    vpx_idct4x4_1_add(input, dest, stride);
}


void vp10_iwht4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
                     int eob) {
  if (eob > 1)
    vpx_iwht4x4_16_add(input, dest, stride);
  else
    vpx_iwht4x4_1_add(input, dest, stride);
}

void vp10_idct8x8_add(const tran_low_t *input, uint8_t *dest, int stride,
                     int eob) {
  // If dc is 1, then input[0] is the reconstructed value, do not need
  // dequantization. Also, when dc is 1, dc is counted in eobs, namely eobs >=1.

  // The calculation can be simplified if there are not many non-zero dct
  // coefficients. Use eobs to decide what to do.
  // TODO(yunqingwang): "eobs = 1" case is also handled in vp10_short_idct8x8_c.
  // Combine that with code here.
  if (eob == 1)
    // DC only DCT coefficient
    vpx_idct8x8_1_add(input, dest, stride);
  else if (eob <= 12)
    vpx_idct8x8_12_add(input, dest, stride);
  else
    vpx_idct8x8_64_add(input, dest, stride);
}

void vp10_idct16x16_add(const tran_low_t *input, uint8_t *dest, int stride,
                       int eob) {
  /* The calculation can be simplified if there are not many non-zero dct
   * coefficients. Use eobs to separate different cases. */
  if (eob == 1)
    /* DC only DCT coefficient. */
    vpx_idct16x16_1_add(input, dest, stride);
  else if (eob <= 10)
    vpx_idct16x16_10_add(input, dest, stride);
  else
    vpx_idct16x16_256_add(input, dest, stride);
}

void vp10_idct32x32_add(const tran_low_t *input, uint8_t *dest, int stride,
                       int eob) {
  if (eob == 1)
    vpx_idct32x32_1_add(input, dest, stride);
  else if (eob <= 34)
    // non-zero coeff only in upper-left 8x8
    vpx_idct32x32_34_add(input, dest, stride);
  else
    vpx_idct32x32_1024_add(input, dest, stride);
}

662 663 664 665 666 667 668 669 670 671 672 673 674 675 676
void vp10_inv_txfm_add_4x4(const tran_low_t *input, uint8_t *dest,
                           int stride, int eob, TX_TYPE tx_type, int lossless) {
  if (lossless) {
    assert(tx_type == DCT_DCT);
    vp10_iwht4x4_add(input, dest, stride, eob);
  } else {
    switch (tx_type) {
      case DCT_DCT:
        vp10_idct4x4_add(input, dest, stride, eob);
        break;
      case ADST_DCT:
      case DCT_ADST:
      case ADST_ADST:
        vp10_iht4x4_16_add(input, dest, stride, tx_type);
        break;
677 678 679 680 681
#if CONFIG_EXT_TX
    case FLIPADST_DCT:
      flipud(dest, stride, 4);
      vp10_iht4x4_16_add(input, dest, stride, ADST_DCT);
      flipud(dest, stride, 4);
682
        break;
683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702
    case DCT_FLIPADST:
      fliplr(dest, stride, 4);
      vp10_iht4x4_16_add(input, dest, stride, DCT_ADST);
      fliplr(dest, stride, 4);
      break;
    case FLIPADST_FLIPADST:
      fliplrud(dest, stride, 4);
      vp10_iht4x4_16_add(input, dest, stride, ADST_ADST);
      fliplrud(dest, stride, 4);
      break;
    case ADST_FLIPADST:
      fliplr(dest, stride, 4);
      vp10_iht4x4_16_add(input, dest, stride, ADST_ADST);
      fliplr(dest, stride, 4);
      break;
    case FLIPADST_ADST:
      flipud(dest, stride, 4);
      vp10_iht4x4_16_add(input, dest, stride, ADST_ADST);
      flipud(dest, stride, 4);
      break;
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720
    case DST_DST:
    case DST_DCT:
    case DCT_DST:
    case DST_ADST:
    case ADST_DST:
      // Use C version since DST only exists in C code
      vp10_iht4x4_16_add_c(input, dest, stride, tx_type);
      break;
    case FLIPADST_DST:
      flipud(dest, stride, 4);
      vp10_iht4x4_16_add_c(input, dest, stride, ADST_DST);
      flipud(dest, stride, 4);
      break;
    case DST_FLIPADST:
      fliplr(dest, stride, 4);
      vp10_iht4x4_16_add_c(input, dest, stride, DST_ADST);
      fliplr(dest, stride, 4);
      break;
721 722 723
    case IDTX:
      inv_idtx_add_c(input, dest, stride, 4);
      break;
724
#endif  // CONFIG_EXT_TX
725 726 727 728
      default:
        assert(0);
        break;
    }
hui su's avatar
hui su committed
729
  }
730 731
}

hui su's avatar
hui su committed
732 733 734 735 736 737 738 739 740 741 742
void vp10_inv_txfm_add_8x8(const tran_low_t *input, uint8_t *dest,
                           int stride, int eob, TX_TYPE tx_type) {
  switch (tx_type) {
    case DCT_DCT:
      vp10_idct8x8_add(input, dest, stride, eob);
      break;
    case ADST_DCT:
    case DCT_ADST:
    case ADST_ADST:
      vp10_iht8x8_64_add(input, dest, stride, tx_type);
      break;
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768
#if CONFIG_EXT_TX
    case FLIPADST_DCT:
      flipud(dest, stride, 8);
      vp10_iht8x8_64_add(input, dest, stride, ADST_DCT);
      flipud(dest, stride, 8);
      break;
    case DCT_FLIPADST:
      fliplr(dest, stride, 8);
      vp10_iht8x8_64_add(input, dest, stride, DCT_ADST);
      fliplr(dest, stride, 8);
      break;
    case FLIPADST_FLIPADST:
      fliplrud(dest, stride, 8);
      vp10_iht8x8_64_add(input, dest, stride, ADST_ADST);
      fliplrud(dest, stride, 8);
      break;
    case ADST_FLIPADST:
      fliplr(dest, stride, 8);
      vp10_iht8x8_64_add(input, dest, stride, ADST_ADST);
      fliplr(dest, stride, 8);
      break;
    case FLIPADST_ADST:
      flipud(dest, stride, 8);
      vp10_iht8x8_64_add(input, dest, stride, ADST_ADST);
      flipud(dest, stride, 8);
      break;
769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786
    case DST_DST:
    case DST_DCT:
    case DCT_DST:
    case DST_ADST:
    case ADST_DST:
      // Use C version since DST only exists in C code
      vp10_iht8x8_64_add_c(input, dest, stride, tx_type);
      break;
    case FLIPADST_DST:
      flipud(dest, stride, 8);
      vp10_iht8x8_64_add_c(input, dest, stride, ADST_DST);
      flipud(dest, stride, 8);
      break;
    case DST_FLIPADST:
      fliplr(dest, stride, 8);
      vp10_iht8x8_64_add_c(input, dest, stride, DST_ADST);
      fliplr(dest, stride, 8);
      break;
787 788 789
    case IDTX:
      inv_idtx_add_c(input, dest, stride, 8);
      break;
790
#endif  // CONFIG_EXT_TX
hui su's avatar
hui su committed
791 792 793
    default:
      assert(0);
      break;
794 795 796
  }
}

hui su's avatar
hui su committed
797 798 799 800 801 802 803 804 805 806 807
void vp10_inv_txfm_add_16x16(const tran_low_t *input, uint8_t *dest,
                             int stride, int eob, TX_TYPE tx_type) {
  switch (tx_type) {
    case DCT_DCT:
      vp10_idct16x16_add(input, dest, stride, eob);
      break;
    case ADST_DCT:
    case DCT_ADST:
    case ADST_ADST:
      vp10_iht16x16_256_add(input, dest, stride, tx_type);
      break;
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833
#if CONFIG_EXT_TX
    case FLIPADST_DCT:
      flipud(dest, stride, 16);
      vp10_iht16x16_256_add(input, dest, stride, ADST_DCT);
      flipud(dest, stride, 16);
      break;
    case DCT_FLIPADST:
      fliplr(dest, stride, 16);
      vp10_iht16x16_256_add(input, dest, stride, DCT_ADST);
      fliplr(dest, stride, 16);
      break;
    case FLIPADST_FLIPADST:
      fliplrud(dest, stride, 16);
      vp10_iht16x16_256_add(input, dest, stride, ADST_ADST);
      fliplrud(dest, stride, 16);
      break;
    case ADST_FLIPADST:
      fliplr(dest, stride, 16);
      vp10_iht16x16_256_add(input, dest, stride, ADST_ADST);
      fliplr(dest, stride, 16);
      break;
    case FLIPADST_ADST:
      flipud(dest, stride, 16);
      vp10_iht16x16_256_add(input, dest, stride, ADST_ADST);
      flipud(dest, stride, 16);
      break;
834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851
    case DST_DST:
    case DST_DCT:
    case DCT_DST:
    case DST_ADST:
    case ADST_DST:
      // Use C version since DST only exists in C code
      vp10_iht16x16_256_add_c(input, dest, stride, tx_type);
      break;
    case FLIPADST_DST:
      flipud(dest, stride, 16);
      vp10_iht16x16_256_add_c(input, dest, stride, ADST_DST);
      flipud(dest, stride, 16);
      break;
    case DST_FLIPADST:
      fliplr(dest, stride, 16);
      vp10_iht16x16_256_add_c(input, dest, stride, DST_ADST);
      fliplr(dest, stride, 16);
      break;
852 853 854
    case IDTX:
      inv_idtx_add_c(input, dest, stride, 16);
      break;
855
#endif  // CONFIG_EXT_TX
hui su's avatar
hui su committed
856 857 858 859 860 861 862 863 864 865 866 867
    default:
      assert(0);
      break;
  }
}

void vp10_inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest,
                             int stride, int eob, TX_TYPE tx_type) {
  switch (tx_type) {
    case DCT_DCT:
      vp10_idct32x32_add(input, dest, stride, eob);
      break;
868 869 870 871 872
#if CONFIG_EXT_TX
    case IDTX:
      inv_idtx_add_c(input, dest, stride, 32);
      break;
#endif  // CONFIG_EXT_TX
hui su's avatar
hui su committed
873 874 875 876 877 878 879 880
    case ADST_DCT:
    case DCT_ADST:
    case ADST_ADST:
      assert(0);
      break;
    default:
      assert(0);
      break;
881 882 883 884 885 886 887
  }
}

#if CONFIG_VP9_HIGHBITDEPTH
void vp10_highbd_iht4x4_16_add_c(const tran_low_t *input, uint8_t *dest8,
                                int stride, int tx_type, int bd) {
  const highbd_transform_2d IHT_4[] = {
888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905
    { vpx_highbd_idct4_c,  vpx_highbd_idct4_c  },  // DCT_DCT  = 0
    { vpx_highbd_iadst4_c, vpx_highbd_idct4_c  },  // ADST_DCT = 1
    { vpx_highbd_idct4_c,  vpx_highbd_iadst4_c },  // DCT_ADST = 2
    { vpx_highbd_iadst4_c, vpx_highbd_iadst4_c },  // ADST_ADST = 3
#if CONFIG_EXT_TX
    { vpx_highbd_iadst4_c, vpx_highbd_idct4_c  },  // FLIPADST_DCT = 4
    { vpx_highbd_idct4_c,  vpx_highbd_iadst4_c },  // DCT_FLIPADST = 5
    { vpx_highbd_iadst4_c, vpx_highbd_iadst4_c },  // FLIPADST_FLIPADST = 6
    { vpx_highbd_iadst4_c, vpx_highbd_iadst4_c },  // ADST_FLIPADST = 7
    { vpx_highbd_iadst4_c, vpx_highbd_iadst4_c },  // FLIPADST_ADST = 8
    { highbd_idst4_c,      highbd_idst4_c      },  // DST_DST = 9
    { highbd_idst4_c,      vpx_highbd_idct4_c  },  // DST_DCT = 10
    { vpx_highbd_idct4_c,  highbd_idst4_c      },  // DCT_DST = 11
    { highbd_idst4_c,      vpx_highbd_iadst4_c },  // DST_ADST = 12
    { vpx_highbd_iadst4_c, highbd_idst4_c      },  // ADST_DST = 13
    { highbd_idst4_c,      vpx_highbd_iadst4_c },  // DST_FLIPADST = 14
    { vpx_highbd_iadst4_c, highbd_idst4_c      },  // FLIPADST_DST = 15
#endif  // CONFIG_EXT_TX
906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934
  };
  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);

  int i, j;
  tran_low_t out[4 * 4];
  tran_low_t *outptr = out;
  tran_low_t temp_in[4], temp_out[4];

  // Inverse transform row vectors.
  for (i = 0; i < 4; ++i) {
    IHT_4[tx_type].rows(input, outptr, bd);
    input  += 4;
    outptr += 4;
  }

  // Inverse transform column vectors.
  for (i = 0; i < 4; ++i) {
    for (j = 0; j < 4; ++j)
      temp_in[j] = out[j * 4 + i];
    IHT_4[tx_type].cols(temp_in, temp_out, bd);
    for (j = 0; j < 4; ++j) {
      dest[j * stride + i] = highbd_clip_pixel_add(
          dest[j * stride + i], ROUND_POWER_OF_TWO(temp_out[j], 4), bd);
    }
  }
}

void vp10_highbd_iht8x8_64_add_c(const tran_low_t *input, uint8_t *dest8,
                                int stride, int tx_type, int bd) {
935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955
  static const highbd_transform_2d HIGH_IHT_8[] = {
    { vpx_highbd_idct8_c,  vpx_highbd_idct8_c  },  // DCT_DCT  = 0
    { vpx_highbd_iadst8_c, vpx_highbd_idct8_c  },  // ADST_DCT = 1
    { vpx_highbd_idct8_c,  vpx_highbd_iadst8_c },  // DCT_ADST = 2
    { vpx_highbd_iadst8_c, vpx_highbd_iadst8_c },  // ADST_ADST = 3
#if CONFIG_EXT_TX
    { vpx_highbd_iadst8_c, vpx_highbd_idct8_c  },  // FLIPADST_DCT = 4
    { vpx_highbd_idct8_c,  vpx_highbd_iadst8_c },  // DCT_FLIPADST = 5
    { vpx_highbd_iadst8_c, vpx_highbd_iadst8_c },  // FLIPADST_FLIPADST = 6
    { vpx_highbd_iadst8_c, vpx_highbd_iadst8_c },  // ADST_FLIPADST = 7
    { vpx_highbd_iadst8_c, vpx_highbd_iadst8_c },  // FLIPADST_ADST = 8
    { highbd_idst8_c,      highbd_idst8_c      },  // DST_DST = 9
    { highbd_idst8_c,      vpx_highbd_idct8_c  },  // DST_DCT = 10
    { vpx_highbd_idct8_c,  highbd_idst8_c      },  // DCT_DST = 11
    { highbd_idst8_c,      vpx_highbd_iadst8_c },  // DST_ADST = 12
    { vpx_highbd_iadst8_c, highbd_idst8_c      },  // ADST_DST = 13
    { highbd_idst8_c,      vpx_highbd_iadst8_c },  // DST_FLIPADST = 14
    { vpx_highbd_iadst8_c, highbd_idst8_c      },  // FLIPADST_DST = 15
#endif  // CONFIG_EXT_TX
  };

956 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
  int i, j;
  tran_low_t out[8 * 8];
  tran_low_t *outptr = out;
  tran_low_t temp_in[8], temp_out[8];
  const highbd_transform_2d ht = HIGH_IHT_8[tx_type];
  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);

  // Inverse transform row vectors.
  for (i = 0; i < 8; ++i) {
    ht.rows(input, outptr, bd);
    input += 8;
    outptr += 8;
  }

  // Inverse transform column vectors.
  for (i = 0; i < 8; ++i) {
    for (j = 0; j < 8; ++j)
      temp_in[j] = out[j * 8 + i];
    ht.cols(temp_in, temp_out, bd);
    for (j = 0; j < 8; ++j) {
      dest[j * stride + i] = highbd_clip_pixel_add(
          dest[j * stride + i], ROUND_POWER_OF_TWO(temp_out[j], 5), bd);
    }
  }
}

void vp10_highbd_iht16x16_256_add_c(const tran_low_t *input, uint8_t *dest8,
                                   int stride, int tx_type, int bd) {
984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004
  static const highbd_transform_2d HIGH_IHT_16[] = {
    { vpx_highbd_idct16_c,  vpx_highbd_idct16_c  },  // DCT_DCT  = 0
    { vpx_highbd_iadst16_c, vpx_highbd_idct16_c  },  // ADST_DCT = 1
    { vpx_highbd_idct16_c,  vpx_highbd_iadst16_c },  // DCT_ADST = 2
    { vpx_highbd_iadst16_c, vpx_highbd_iadst16_c },  // ADST_ADST = 3
#if CONFIG_EXT_TX
    { vpx_highbd_iadst16_c, vpx_highbd_idct16_c  },  // FLIPADST_DCT = 4
    { vpx_highbd_idct16_c,  vpx_highbd_iadst16_c },  // DCT_FLIPADST = 5
    { vpx_highbd_iadst16_c, vpx_highbd_iadst16_c },  // FLIPADST_FLIPADST = 6
    { vpx_highbd_iadst16_c, vpx_highbd_iadst16_c },  // ADST_FLIPADST = 7
    { vpx_highbd_iadst16_c, vpx_highbd_iadst16_c },  // FLIPADST_ADST = 8
    { highbd_idst16_c,      highbd_idst16_c      },  // DST_DST = 9
    { highbd_idst16_c,      vpx_highbd_idct16_c  },  // DST_DCT = 10
    { vpx_highbd_idct16_c,  highbd_idst16_c      },  // DCT_DST = 11
    { highbd_idst16_c,      vpx_highbd_iadst16_c },  // DST_ADST = 12
    { vpx_highbd_iadst16_c, highbd_idst16_c      },  // ADST_DST = 13
    { highbd_idst16_c,      vpx_highbd_iadst16_c },  // DST_FLIPADST = 14
    { vpx_highbd_iadst16_c, highbd_idst16_c      },  // FLIPADST_DST = 15
#endif  // CONFIG_EXT_TX
  };

1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093
  int i, j;
  tran_low_t out[16 * 16];
  tran_low_t *outptr = out;
  tran_low_t temp_in[16], temp_out[16];
  const highbd_transform_2d ht = HIGH_IHT_16[tx_type];
  uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);

  // Rows
  for (i = 0; i < 16; ++i) {
    ht.rows(input, outptr, bd);
    input += 16;
    outptr += 16;
  }

  // Columns
  for (i = 0; i < 16; ++i) {
    for (j = 0; j < 16; ++j)
      temp_in[j] = out[j * 16 + i];
    ht.cols(temp_in, temp_out, bd);
    for (j = 0; j < 16; ++j) {
      dest[j * stride + i] = highbd_clip_pixel_add(
          dest[j * stride + i], ROUND_POWER_OF_TWO(temp_out[j], 6), bd);
    }
  }
}

// idct
void vp10_highbd_idct4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
                            int eob, int bd) {
  if (eob > 1)
    vpx_highbd_idct4x4_16_add(input, dest, stride, bd);
  else
    vpx_highbd_idct4x4_1_add(input, dest, stride, bd);
}


void vp10_highbd_iwht4x4_add(const tran_low_t *input, uint8_t *dest, int stride,
                            int eob, int bd) {
  if (eob > 1)
    vpx_highbd_iwht4x4_16_add(input, dest, stride, bd);
  else
    vpx_highbd_iwht4x4_1_add(input, dest, stride, bd);
}

void vp10_highbd_idct8x8_add(const tran_low_t *input, uint8_t *dest, int stride,
                            int eob, int bd) {
  // If dc is 1, then input[0] is the reconstructed value, do not need
  // dequantization. Also, when dc is 1, dc is counted in eobs, namely eobs >=1.

  // The calculation can be simplified if there are not many non-zero dct
  // coefficients. Use eobs to decide what to do.
  // TODO(yunqingwang): "eobs = 1" case is also handled in vp10_short_idct8x8_c.
  // Combine that with code here.
  // DC only DCT coefficient
  if (eob == 1) {
    vpx_highbd_idct8x8_1_add(input, dest, stride, bd);
  } else if (eob <= 10) {
    vpx_highbd_idct8x8_10_add(input, dest, stride, bd);
  } else {
    vpx_highbd_idct8x8_64_add(input, dest, stride, bd);
  }
}

void vp10_highbd_idct16x16_add(const tran_low_t *input, uint8_t *dest,
                              int stride, int eob, int bd) {
  // The calculation can be simplified if there are not many non-zero dct
  // coefficients. Use eobs to separate different cases.
  // DC only DCT coefficient.
  if (eob == 1) {
    vpx_highbd_idct16x16_1_add(input, dest, stride, bd);
  } else if (eob <= 10) {
    vpx_highbd_idct16x16_10_add(input, dest, stride, bd);
  } else {
    vpx_highbd_idct16x16_256_add(input, dest, stride, bd);
  }
}

void vp10_highbd_idct32x32_add(const tran_low_t *input, uint8_t *dest,
                              int stride, int eob, int bd) {
  // Non-zero coeff only in upper-left 8x8
  if (eob == 1) {
    vpx_highbd_idct32x32_1_add(input, dest, stride, bd);
  } else if (eob <= 34) {
    vpx_highbd_idct32x32_34_add(input, dest, stride, bd);
  } else {
    vpx_highbd_idct32x32_1024_add(input, dest, stride, bd);
  }
}

hui su's avatar
hui su committed
1094 1095
void vp10_highbd_inv_txfm_add_4x4(const tran_low_t *input, uint8_t *dest,
                                  int stride, int eob, int bd, TX_TYPE tx_type,
1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109
                                  int lossless) {
  if (lossless) {
    assert(tx_type == DCT_DCT);
    vp10_highbd_iwht4x4_add(input, dest, stride, eob, bd);
  } else {
    switch (tx_type) {
      case DCT_DCT:
        vp10_highbd_idct4x4_add(input, dest, stride, eob, bd);
        break;
      case ADST_DCT:
      case DCT_ADST:
      case ADST_ADST:
         vp10_highbd_iht4x4_16_add(input, dest, stride, tx_type, bd);
         break;
1110 1111 1112 1113 1114
#if CONFIG_EXT_TX
    case FLIPADST_DCT:
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 4);
      vp10_highbd_iht4x4_16_add(input, dest, stride, ADST_DCT, bd);
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 4);
1115
         break;
1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135
    case DCT_FLIPADST:
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 4);
      vp10_highbd_iht4x4_16_add(input, dest, stride, DCT_ADST, bd);
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 4);
      break;
    case FLIPADST_FLIPADST:
      fliplrud16(CONVERT_TO_SHORTPTR(dest), stride, 4);
      vp10_highbd_iht4x4_16_add(input, dest, stride, ADST_ADST, bd);
      fliplrud16(CONVERT_TO_SHORTPTR(dest), stride, 4);
      break;
    case ADST_FLIPADST:
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 4);
      vp10_highbd_iht4x4_16_add(input, dest, stride, ADST_ADST, bd);
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 4);
      break;
    case FLIPADST_ADST:
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 4);
      vp10_highbd_iht4x4_16_add(input, dest, stride, ADST_ADST, bd);
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 4);
      break;
1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153
    case DST_DST:
    case DST_DCT:
    case DCT_DST:
    case DST_ADST:
    case ADST_DST:
      // Use C version since DST only exists in C code
      vp10_highbd_iht4x4_16_add_c(input, dest, stride, tx_type, bd);
      break;
    case FLIPADST_DST:
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 4);
      vp10_highbd_iht4x4_16_add_c(input, dest, stride, ADST_DST, bd);
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 4);
      break;
    case DST_FLIPADST:
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 4);
      vp10_highbd_iht4x4_16_add_c(input, dest, stride, DST_ADST, bd);
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 4);
      break;
1154 1155 1156
    case IDTX:
      highbd_inv_idtx_add_c(input, dest, stride, 4, bd);
      break;
1157
#endif  // CONFIG_EXT_TX
1158 1159 1160 1161
      default:
        assert(0);
        break;
    }
hui su's avatar
hui su committed
1162
  }
1163 1164
}

hui su's avatar
hui su committed
1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176
void vp10_highbd_inv_txfm_add_8x8(const tran_low_t *input, uint8_t *dest,
                                  int stride, int eob, int bd,
                                  TX_TYPE tx_type) {
  switch (tx_type) {
    case DCT_DCT:
      vp10_highbd_idct8x8_add(input, dest, stride, eob, bd);
      break;
    case ADST_DCT:
    case DCT_ADST:
    case ADST_ADST:
      vp10_highbd_iht8x8_64_add(input, dest, stride, tx_type, bd);
      break;
1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202
#if CONFIG_EXT_TX
    case FLIPADST_DCT:
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 8);
      vp10_highbd_iht8x8_64_add(input, dest, stride, ADST_DCT, bd);
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 8);
      break;
    case DCT_FLIPADST:
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 8);
      vp10_highbd_iht8x8_64_add(input, dest, stride, DCT_ADST, bd);
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 8);
      break;
    case FLIPADST_FLIPADST:
      fliplrud16(CONVERT_TO_SHORTPTR(dest), stride, 8);
      vp10_highbd_iht8x8_64_add(input, dest, stride, ADST_ADST, bd);
      fliplrud16(CONVERT_TO_SHORTPTR(dest), stride, 8);
      break;
    case ADST_FLIPADST:
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 8);
      vp10_highbd_iht8x8_64_add(input, dest, stride, ADST_ADST, bd);
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 8);
      break;
    case FLIPADST_ADST:
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 8);
      vp10_highbd_iht8x8_64_add(input, dest, stride, ADST_ADST, bd);
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 8);
      break;
1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220
    case DST_DST:
    case DST_DCT:
    case DCT_DST:
    case DST_ADST:
    case ADST_DST:
      // Use C version since DST only exists in C code
      vp10_highbd_iht8x8_64_add_c(input, dest, stride, tx_type, bd);
      break;
    case FLIPADST_DST:
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 8);
      vp10_highbd_iht8x8_64_add_c(input, dest, stride, ADST_DST, bd);
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 8);
      break;
    case DST_FLIPADST:
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 8);
      vp10_highbd_iht8x8_64_add_c(input, dest, stride, DST_ADST, bd);
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 8);
      break;
1221 1222 1223
    case IDTX:
      highbd_inv_idtx_add_c(input, dest, stride, 8, bd);
      break;
1224
#endif  // CONFIG_EXT_TX
hui su's avatar
hui su committed
1225 1226 1227
    default:
      assert(0);
      break;
1228 1229 1230
  }
}

hui su's avatar
hui su committed
1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242
void vp10_highbd_inv_txfm_add_16x16(const tran_low_t *input, uint8_t *dest,
                                    int stride, int eob, int bd,
                                    TX_TYPE tx_type) {
  switch (tx_type) {
    case DCT_DCT:
      vp10_highbd_idct16x16_add(input, dest, stride, eob, bd);
      break;
    case ADST_DCT:
    case DCT_ADST:
    case ADST_ADST:
      vp10_highbd_iht16x16_256_add(input, dest, stride, tx_type, bd);
      break;
1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268
#if CONFIG_EXT_TX
    case FLIPADST_DCT:
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 16);
      vp10_highbd_iht16x16_256_add(input, dest, stride, ADST_DCT, bd);
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 16);
      break;
    case DCT_FLIPADST:
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 16);
      vp10_highbd_iht16x16_256_add(input, dest, stride, DCT_ADST, bd);
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 16);
      break;
    case FLIPADST_FLIPADST:
      fliplrud16(CONVERT_TO_SHORTPTR(dest), stride, 16);
      vp10_highbd_iht16x16_256_add(input, dest, stride, ADST_ADST, bd);
      fliplrud16(CONVERT_TO_SHORTPTR(dest), stride, 16);
      break;
    case ADST_FLIPADST:
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 16);
      vp10_highbd_iht16x16_256_add(input, dest, stride, ADST_ADST, bd);
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 16);
      break;
    case FLIPADST_ADST:
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 16);
      vp10_highbd_iht16x16_256_add(input, dest, stride, ADST_ADST, bd);
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 16);
      break;
1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286
    case DST_DST:
    case DST_DCT:
    case DCT_DST:
    case DST_ADST:
    case ADST_DST:
      // Use C version since DST only exists in C code
      vp10_highbd_iht16x16_256_add_c(input, dest, stride, tx_type, bd);
      break;
    case FLIPADST_DST:
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 16);
      vp10_highbd_iht16x16_256_add_c(input, dest, stride, ADST_DST, bd);
      flipud16(CONVERT_TO_SHORTPTR(dest), stride, 16);
      break;
    case DST_FLIPADST:
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 16);
      vp10_highbd_iht16x16_256_add_c(input, dest, stride, DST_ADST, bd);
      fliplr16(CONVERT_TO_SHORTPTR(dest), stride, 16);
      break;
1287 1288 1289
    case IDTX:
      highbd_inv_idtx_add_c(input, dest, stride, 16, bd);
      break;
1290
#endif  // CONFIG_EXT_TX
hui su's avatar
hui su committed
1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303
    default:
      assert(0);
      break;
  }
}

void vp10_highbd_inv_txfm_add_32x32(const tran_low_t *input, uint8_t *dest,
                                    int stride, int eob, int bd,
                                    TX_TYPE tx_type) {
  switch (tx_type) {
    case DCT_DCT:
      vp10_highbd_idct32x32_add(input, dest, stride, eob, bd);
      break;
1304 1305 1306 1307 1308
#if CONFIG_EXT_TX
    case IDTX:
      highbd_inv_idtx_add_c(input, dest, stride, 32, bd);
      break;
#endif  // CONFIG_EXT_TX
hui su's avatar
hui su committed
1309 1310 1311 1312 1313 1314 1315 1316
    case ADST_DCT:
    case DCT_ADST:
    case ADST_ADST:
      assert(0);
      break;
    default:
      assert(0);
      break;
1317 1318 1319
  }
}
#endif  // CONFIG_VP9_HIGHBITDEPTH