• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2015 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include "vpx_dsp/mips/inv_txfm_msa.h"
12 
vpx_iwht4x4_16_add_msa(const int16_t * input,uint8_t * dst,int32_t dst_stride)13 void vpx_iwht4x4_16_add_msa(const int16_t *input, uint8_t *dst,
14                             int32_t dst_stride) {
15   v8i16 in0, in1, in2, in3;
16   v4i32 in0_r, in1_r, in2_r, in3_r, in4_r;
17 
18   /* load vector elements of 4x4 block */
19   LD4x4_SH(input, in0, in2, in3, in1);
20   TRANSPOSE4x4_SH_SH(in0, in2, in3, in1, in0, in2, in3, in1);
21   UNPCK_R_SH_SW(in0, in0_r);
22   UNPCK_R_SH_SW(in2, in2_r);
23   UNPCK_R_SH_SW(in3, in3_r);
24   UNPCK_R_SH_SW(in1, in1_r);
25   SRA_4V(in0_r, in1_r, in2_r, in3_r, UNIT_QUANT_SHIFT);
26 
27   in0_r += in2_r;
28   in3_r -= in1_r;
29   in4_r = (in0_r - in3_r) >> 1;
30   in1_r = in4_r - in1_r;
31   in2_r = in4_r - in2_r;
32   in0_r -= in1_r;
33   in3_r += in2_r;
34 
35   TRANSPOSE4x4_SW_SW(in0_r, in1_r, in2_r, in3_r, in0_r, in1_r, in2_r, in3_r);
36 
37   in0_r += in1_r;
38   in2_r -= in3_r;
39   in4_r = (in0_r - in2_r) >> 1;
40   in3_r = in4_r - in3_r;
41   in1_r = in4_r - in1_r;
42   in0_r -= in3_r;
43   in2_r += in1_r;
44 
45   PCKEV_H4_SH(in0_r, in0_r, in1_r, in1_r, in2_r, in2_r, in3_r, in3_r, in0, in1,
46               in2, in3);
47   ADDBLK_ST4x4_UB(in0, in3, in1, in2, dst, dst_stride);
48 }
49 
vpx_iwht4x4_1_add_msa(const int16_t * input,uint8_t * dst,int32_t dst_stride)50 void vpx_iwht4x4_1_add_msa(const int16_t *input, uint8_t *dst,
51                            int32_t dst_stride) {
52   int16_t a1, e1;
53   v8i16 in1, in0 = { 0 };
54 
55   a1 = input[0] >> UNIT_QUANT_SHIFT;
56   e1 = a1 >> 1;
57   a1 -= e1;
58 
59   in0 = __msa_insert_h(in0, 0, a1);
60   in0 = __msa_insert_h(in0, 1, e1);
61   in0 = __msa_insert_h(in0, 2, e1);
62   in0 = __msa_insert_h(in0, 3, e1);
63 
64   in1 = in0 >> 1;
65   in0 -= in1;
66 
67   ADDBLK_ST4x4_UB(in0, in1, in1, in1, dst, dst_stride);
68 }
69 
vpx_idct4x4_16_add_msa(const int16_t * input,uint8_t * dst,int32_t dst_stride)70 void vpx_idct4x4_16_add_msa(const int16_t *input, uint8_t *dst,
71                             int32_t dst_stride) {
72   v8i16 in0, in1, in2, in3;
73 
74   /* load vector elements of 4x4 block */
75   LD4x4_SH(input, in0, in1, in2, in3);
76   /* rows */
77   TRANSPOSE4x4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3);
78   VP9_IDCT4x4(in0, in1, in2, in3, in0, in1, in2, in3);
79   /* columns */
80   TRANSPOSE4x4_SH_SH(in0, in1, in2, in3, in0, in1, in2, in3);
81   VP9_IDCT4x4(in0, in1, in2, in3, in0, in1, in2, in3);
82   /* rounding (add 2^3, divide by 2^4) */
83   SRARI_H4_SH(in0, in1, in2, in3, 4);
84   ADDBLK_ST4x4_UB(in0, in1, in2, in3, dst, dst_stride);
85 }
86 
vpx_idct4x4_1_add_msa(const int16_t * input,uint8_t * dst,int32_t dst_stride)87 void vpx_idct4x4_1_add_msa(const int16_t *input, uint8_t *dst,
88                            int32_t dst_stride) {
89   int16_t out;
90   v8i16 vec;
91 
92   out = ROUND_POWER_OF_TWO((input[0] * cospi_16_64), DCT_CONST_BITS);
93   out = ROUND_POWER_OF_TWO((out * cospi_16_64), DCT_CONST_BITS);
94   out = ROUND_POWER_OF_TWO(out, 4);
95   vec = __msa_fill_h(out);
96 
97   ADDBLK_ST4x4_UB(vec, vec, vec, vec, dst, dst_stride);
98 }
99