itrans16_dspr2.c 2.95 KB
Newer Older
Jingning Han's avatar
Jingning Han committed
1
/*
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Jingning Han's avatar
Jingning Han committed
3
 *
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 14 15
 */

#include <assert.h>
#include <stdio.h>

#include "./vpx_config.h"
Yaowu Xu's avatar
Yaowu Xu committed
16
#include "./av1_rtcd.h"
Yaowu Xu's avatar
Yaowu Xu committed
17 18 19
#include "av1/common/common.h"
#include "av1/common/blockd.h"
#include "av1/common/idct.h"
Yaowu Xu's avatar
Yaowu Xu committed
20 21 22
#include "aom_dsp/mips/inv_txfm_dspr2.h"
#include "aom_dsp/txfm_common.h"
#include "aom_ports/mem.h"
Jingning Han's avatar
Jingning Han committed
23 24

#if HAVE_DSPR2
clang-format's avatar
clang-format committed
25 26
void vp10_iht16x16_256_add_dspr2(const int16_t *input, uint8_t *dest, int pitch,
                                 int tx_type) {
Jingning Han's avatar
Jingning Han committed
27
  int i, j;
clang-format's avatar
clang-format committed
28
  DECLARE_ALIGNED(32, int16_t, out[16 * 16]);
Jingning Han's avatar
Jingning Han committed
29 30 31 32 33
  int16_t *outptr = out;
  int16_t temp_out[16];
  uint32_t pos = 45;

  /* bit positon for extract from acc */
clang-format's avatar
clang-format committed
34
  __asm__ __volatile__("wrdsp    %[pos],    1    \n\t" : : [pos] "r"(pos));
Jingning Han's avatar
Jingning Han committed
35 36

  switch (tx_type) {
clang-format's avatar
clang-format committed
37
    case DCT_DCT:  // DCT in both horizontal and vertical
Jingning Han's avatar
Jingning Han committed
38 39 40
      idct16_rows_dspr2(input, outptr, 16);
      idct16_cols_add_blk_dspr2(out, dest, pitch);
      break;
clang-format's avatar
clang-format committed
41
    case ADST_DCT:  // ADST in vertical, DCT in horizontal
Jingning Han's avatar
Jingning Han committed
42 43 44 45 46 47 48 49
      idct16_rows_dspr2(input, outptr, 16);

      outptr = out;

      for (i = 0; i < 16; ++i) {
        iadst16_dspr2(outptr, temp_out);

        for (j = 0; j < 16; ++j)
clang-format's avatar
clang-format committed
50 51
          dest[j * pitch + i] = clip_pixel(ROUND_POWER_OF_TWO(temp_out[j], 6) +
                                           dest[j * pitch + i]);
Jingning Han's avatar
Jingning Han committed
52 53 54
        outptr += 16;
      }
      break;
clang-format's avatar
clang-format committed
55
    case DCT_ADST:  // DCT in vertical, ADST in horizontal
Jingning Han's avatar
Jingning Han committed
56 57 58 59 60 61 62 63 64 65 66 67 68
    {
      int16_t temp_in[16 * 16];

      for (i = 0; i < 16; ++i) {
        /* prefetch row */
        prefetch_load((const uint8_t *)(input + 16));

        iadst16_dspr2(input, outptr);
        input += 16;
        outptr += 16;
      }

      for (i = 0; i < 16; ++i)
clang-format's avatar
clang-format committed
69
        for (j = 0; j < 16; ++j) temp_in[j * 16 + i] = out[i * 16 + j];
Jingning Han's avatar
Jingning Han committed
70 71

      idct16_cols_add_blk_dspr2(temp_in, dest, pitch);
clang-format's avatar
clang-format committed
72 73
    } break;
    case ADST_ADST:  // ADST in both directions
Jingning Han's avatar
Jingning Han committed
74 75 76 77 78 79 80 81 82 83 84 85 86
    {
      int16_t temp_in[16];

      for (i = 0; i < 16; ++i) {
        /* prefetch row */
        prefetch_load((const uint8_t *)(input + 16));

        iadst16_dspr2(input, outptr);
        input += 16;
        outptr += 16;
      }

      for (i = 0; i < 16; ++i) {
clang-format's avatar
clang-format committed
87
        for (j = 0; j < 16; ++j) temp_in[j] = out[j * 16 + i];
Jingning Han's avatar
Jingning Han committed
88 89
        iadst16_dspr2(temp_in, temp_out);
        for (j = 0; j < 16; ++j)
clang-format's avatar
clang-format committed
90 91
          dest[j * pitch + i] = clip_pixel(ROUND_POWER_OF_TWO(temp_out[j], 6) +
                                           dest[j * pitch + i]);
Jingning Han's avatar
Jingning Han committed
92
      }
clang-format's avatar
clang-format committed
93 94
    } break;
    default: printf("vp10_short_iht16x16_add_dspr2 : Invalid tx_type\n"); break;
Jingning Han's avatar
Jingning Han committed
95 96 97
  }
}
#endif  // #if HAVE_DSPR2