av1_itrans4_dspr2.c 2.79 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 14
 */

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

Yaowu Xu's avatar
Yaowu Xu committed
15 16
#include "./aom_config.h"
#include "./av1_rtcd.h"
17 18 19 20 21 22
#include "av1/common/common.h"
#include "av1/common/blockd.h"
#include "av1/common/idct.h"
#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
Yaowu Xu's avatar
Yaowu Xu committed
25 26
void av1_iht4x4_16_add_dspr2(const int16_t *input, uint8_t *dest,
                             int dest_stride, int tx_type) {
Jingning Han's avatar
Jingning Han committed
27 28 29 30 31 32 33
  int i, j;
  DECLARE_ALIGNED(32, int16_t, out[4 * 4]);
  int16_t *outptr = out;
  int16_t temp_in[4 * 4], temp_out[4];
  uint32_t pos = 45;

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

  switch (tx_type) {
clang-format's avatar
clang-format committed
39
    case DCT_DCT:  // DCT in both horizontal and vertical
Yaowu Xu's avatar
Yaowu Xu committed
40 41
      aom_idct4_rows_dspr2(input, outptr);
      aom_idct4_columns_add_blk_dspr2(&out[0], dest, dest_stride);
Jingning Han's avatar
Jingning Han committed
42 43
      break;
    case ADST_DCT:  // ADST in vertical, DCT in horizontal
Yaowu Xu's avatar
Yaowu Xu committed
44
      aom_idct4_rows_dspr2(input, outptr);
Jingning Han's avatar
Jingning Han committed
45 46 47 48 49 50 51

      outptr = out;

      for (i = 0; i < 4; ++i) {
        iadst4_dspr2(outptr, temp_out);

        for (j = 0; j < 4; ++j)
clang-format's avatar
clang-format committed
52 53
          dest[j * dest_stride + i] = clip_pixel(
              ROUND_POWER_OF_TWO(temp_out[j], 4) + dest[j * dest_stride + i]);
Jingning Han's avatar
Jingning Han committed
54 55 56 57 58 59 60

        outptr += 4;
      }
      break;
    case DCT_ADST:  // DCT in vertical, ADST in horizontal
      for (i = 0; i < 4; ++i) {
        iadst4_dspr2(input, outptr);
clang-format's avatar
clang-format committed
61
        input += 4;
Jingning Han's avatar
Jingning Han committed
62 63 64 65 66 67 68 69
        outptr += 4;
      }

      for (i = 0; i < 4; ++i) {
        for (j = 0; j < 4; ++j) {
          temp_in[i * 4 + j] = out[j * 4 + i];
        }
      }
Yaowu Xu's avatar
Yaowu Xu committed
70
      aom_idct4_columns_add_blk_dspr2(&temp_in[0], dest, dest_stride);
Jingning Han's avatar
Jingning Han committed
71 72 73 74
      break;
    case ADST_ADST:  // ADST in both directions
      for (i = 0; i < 4; ++i) {
        iadst4_dspr2(input, outptr);
clang-format's avatar
clang-format committed
75
        input += 4;
Jingning Han's avatar
Jingning Han committed
76 77 78 79
        outptr += 4;
      }

      for (i = 0; i < 4; ++i) {
clang-format's avatar
clang-format committed
80
        for (j = 0; j < 4; ++j) temp_in[j] = out[j * 4 + i];
Jingning Han's avatar
Jingning Han committed
81 82 83
        iadst4_dspr2(temp_in, temp_out);

        for (j = 0; j < 4; ++j)
clang-format's avatar
clang-format committed
84 85
          dest[j * dest_stride + i] = clip_pixel(
              ROUND_POWER_OF_TWO(temp_out[j], 4) + dest[j * dest_stride + i]);
Jingning Han's avatar
Jingning Han committed
86 87
      }
      break;
Yaowu Xu's avatar
Yaowu Xu committed
88
    default: printf("av1_short_iht4x4_add_dspr2 : Invalid tx_type\n"); break;
Jingning Han's avatar
Jingning Han committed
89 90 91
  }
}
#endif  // #if HAVE_DSPR2