inv_txfm_msa.h 28.9 KB
Newer Older
1
/*
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
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.
10 11
 */

Adrian Grange's avatar
Adrian Grange committed
12 13
#ifndef AOM_DSP_MIPS_INV_TXFM_MSA_H_
#define AOM_DSP_MIPS_INV_TXFM_MSA_H_
14

Yaowu Xu's avatar
Yaowu Xu committed
15 16 17
#include "aom_dsp/mips/macros_msa.h"
#include "aom_dsp/mips/txfm_macros_msa.h"
#include "aom_dsp/txfm_common.h"
18

Adrian Grange's avatar
Adrian Grange committed
19
#define AV1_ADST8(in0, in1, in2, in3, in4, in5, in6, in7, out0, out1, out2,  \
clang-format's avatar
clang-format committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 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 73 74 75 76 77 78 79 80 81
                  out3, out4, out5, out6, out7)                              \
  {                                                                          \
    v8i16 cnst0_m, cnst1_m, cnst2_m, cnst3_m, cnst4_m;                       \
    v8i16 vec0_m, vec1_m, vec2_m, vec3_m, s0_m, s1_m;                        \
    v8i16 coeff0_m = { cospi_2_64,  cospi_6_64,  cospi_10_64, cospi_14_64,   \
                       cospi_18_64, cospi_22_64, cospi_26_64, cospi_30_64 }; \
    v8i16 coeff1_m = { cospi_8_64,  -cospi_8_64,  cospi_16_64, -cospi_16_64, \
                       cospi_24_64, -cospi_24_64, 0,           0 };          \
                                                                             \
    SPLATI_H2_SH(coeff0_m, 0, 7, cnst0_m, cnst1_m);                          \
    cnst2_m = -cnst0_m;                                                      \
    ILVEV_H2_SH(cnst0_m, cnst1_m, cnst1_m, cnst2_m, cnst0_m, cnst1_m);       \
    SPLATI_H2_SH(coeff0_m, 4, 3, cnst2_m, cnst3_m);                          \
    cnst4_m = -cnst2_m;                                                      \
    ILVEV_H2_SH(cnst2_m, cnst3_m, cnst3_m, cnst4_m, cnst2_m, cnst3_m);       \
                                                                             \
    ILVRL_H2_SH(in0, in7, vec1_m, vec0_m);                                   \
    ILVRL_H2_SH(in4, in3, vec3_m, vec2_m);                                   \
    DOT_ADD_SUB_SRARI_PCK(vec0_m, vec1_m, vec2_m, vec3_m, cnst0_m, cnst1_m,  \
                          cnst2_m, cnst3_m, in7, in0, in4, in3);             \
                                                                             \
    SPLATI_H2_SH(coeff0_m, 2, 5, cnst0_m, cnst1_m);                          \
    cnst2_m = -cnst0_m;                                                      \
    ILVEV_H2_SH(cnst0_m, cnst1_m, cnst1_m, cnst2_m, cnst0_m, cnst1_m);       \
    SPLATI_H2_SH(coeff0_m, 6, 1, cnst2_m, cnst3_m);                          \
    cnst4_m = -cnst2_m;                                                      \
    ILVEV_H2_SH(cnst2_m, cnst3_m, cnst3_m, cnst4_m, cnst2_m, cnst3_m);       \
                                                                             \
    ILVRL_H2_SH(in2, in5, vec1_m, vec0_m);                                   \
    ILVRL_H2_SH(in6, in1, vec3_m, vec2_m);                                   \
                                                                             \
    DOT_ADD_SUB_SRARI_PCK(vec0_m, vec1_m, vec2_m, vec3_m, cnst0_m, cnst1_m,  \
                          cnst2_m, cnst3_m, in5, in2, in6, in1);             \
    BUTTERFLY_4(in7, in0, in2, in5, s1_m, s0_m, in2, in5);                   \
    out7 = -s0_m;                                                            \
    out0 = s1_m;                                                             \
                                                                             \
    SPLATI_H4_SH(coeff1_m, 0, 4, 1, 5, cnst0_m, cnst1_m, cnst2_m, cnst3_m);  \
                                                                             \
    ILVEV_H2_SH(cnst3_m, cnst0_m, cnst1_m, cnst2_m, cnst3_m, cnst2_m);       \
    cnst0_m = __msa_ilvev_h(cnst1_m, cnst0_m);                               \
    cnst1_m = cnst0_m;                                                       \
                                                                             \
    ILVRL_H2_SH(in4, in3, vec1_m, vec0_m);                                   \
    ILVRL_H2_SH(in6, in1, vec3_m, vec2_m);                                   \
    DOT_ADD_SUB_SRARI_PCK(vec0_m, vec1_m, vec2_m, vec3_m, cnst0_m, cnst2_m,  \
                          cnst3_m, cnst1_m, out1, out6, s0_m, s1_m);         \
                                                                             \
    SPLATI_H2_SH(coeff1_m, 2, 3, cnst0_m, cnst1_m);                          \
    cnst1_m = __msa_ilvev_h(cnst1_m, cnst0_m);                               \
                                                                             \
    ILVRL_H2_SH(in2, in5, vec1_m, vec0_m);                                   \
    ILVRL_H2_SH(s0_m, s1_m, vec3_m, vec2_m);                                 \
    out3 = DOT_SHIFT_RIGHT_PCK_H(vec0_m, vec1_m, cnst0_m);                   \
    out4 = DOT_SHIFT_RIGHT_PCK_H(vec0_m, vec1_m, cnst1_m);                   \
    out2 = DOT_SHIFT_RIGHT_PCK_H(vec2_m, vec3_m, cnst0_m);                   \
    out5 = DOT_SHIFT_RIGHT_PCK_H(vec2_m, vec3_m, cnst1_m);                   \
                                                                             \
    out1 = -out1;                                                            \
    out3 = -out3;                                                            \
    out5 = -out5;                                                            \
  }
82

Adrian Grange's avatar
Adrian Grange committed
83
#define AOM_SET_COSPI_PAIR(c0_h, c1_h)  \
clang-format's avatar
clang-format committed
84 85 86 87 88 89 90 91 92
  ({                                    \
    v8i16 out0_m, r0_m, r1_m;           \
                                        \
    r0_m = __msa_fill_h(c0_h);          \
    r1_m = __msa_fill_h(c1_h);          \
    out0_m = __msa_ilvev_h(r1_m, r0_m); \
                                        \
    out0_m;                             \
  })
93

Adrian Grange's avatar
Adrian Grange committed
94
#define AOM_ADDBLK_ST8x4_UB(dst, dst_stride, in0, in1, in2, in3)               \
clang-format's avatar
clang-format committed
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
  {                                                                            \
    uint8_t *dst_m = (uint8_t *)(dst);                                         \
    v16u8 dst0_m, dst1_m, dst2_m, dst3_m;                                      \
    v16i8 tmp0_m, tmp1_m;                                                      \
    v16i8 zero_m = { 0 };                                                      \
    v8i16 res0_m, res1_m, res2_m, res3_m;                                      \
                                                                               \
    LD_UB4(dst_m, dst_stride, dst0_m, dst1_m, dst2_m, dst3_m);                 \
    ILVR_B4_SH(zero_m, dst0_m, zero_m, dst1_m, zero_m, dst2_m, zero_m, dst3_m, \
               res0_m, res1_m, res2_m, res3_m);                                \
    ADD4(res0_m, in0, res1_m, in1, res2_m, in2, res3_m, in3, res0_m, res1_m,   \
         res2_m, res3_m);                                                      \
    CLIP_SH4_0_255(res0_m, res1_m, res2_m, res3_m);                            \
    PCKEV_B2_SB(res1_m, res0_m, res3_m, res2_m, tmp0_m, tmp1_m);               \
    ST8x4_UB(tmp0_m, tmp1_m, dst_m, dst_stride);                               \
  }
111

Adrian Grange's avatar
Adrian Grange committed
112
#define AOM_IDCT4x4(in0, in1, in2, in3, out0, out1, out2, out3)             \
clang-format's avatar
clang-format committed
113 114 115 116 117
  {                                                                         \
    v8i16 c0_m, c1_m, c2_m, c3_m;                                           \
    v8i16 step0_m, step1_m;                                                 \
    v4i32 tmp0_m, tmp1_m, tmp2_m, tmp3_m;                                   \
                                                                            \
Adrian Grange's avatar
Adrian Grange committed
118 119
    c0_m = AOM_SET_COSPI_PAIR(cospi_16_64, cospi_16_64);                    \
    c1_m = AOM_SET_COSPI_PAIR(cospi_16_64, -cospi_16_64);                   \
clang-format's avatar
clang-format committed
120 121 122
    step0_m = __msa_ilvr_h(in2, in0);                                       \
    DOTP_SH2_SW(step0_m, step0_m, c0_m, c1_m, tmp0_m, tmp1_m);              \
                                                                            \
Adrian Grange's avatar
Adrian Grange committed
123 124
    c2_m = AOM_SET_COSPI_PAIR(cospi_24_64, -cospi_8_64);                    \
    c3_m = AOM_SET_COSPI_PAIR(cospi_8_64, cospi_24_64);                     \
clang-format's avatar
clang-format committed
125 126 127 128 129 130 131 132 133
    step1_m = __msa_ilvr_h(in3, in1);                                       \
    DOTP_SH2_SW(step1_m, step1_m, c2_m, c3_m, tmp2_m, tmp3_m);              \
    SRARI_W4_SW(tmp0_m, tmp1_m, tmp2_m, tmp3_m, DCT_CONST_BITS);            \
                                                                            \
    PCKEV_H2_SW(tmp1_m, tmp0_m, tmp3_m, tmp2_m, tmp0_m, tmp2_m);            \
    SLDI_B2_0_SW(tmp0_m, tmp2_m, tmp1_m, tmp3_m, 8);                        \
    BUTTERFLY_4((v8i16)tmp0_m, (v8i16)tmp1_m, (v8i16)tmp2_m, (v8i16)tmp3_m, \
                out0, out1, out2, out3);                                    \
  }
134

Adrian Grange's avatar
Adrian Grange committed
135
#define AOM_IADST4x4(in0, in1, in2, in3, out0, out1, out2, out3)       \
clang-format's avatar
clang-format committed
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 183
  {                                                                    \
    v8i16 res0_m, res1_m, c0_m, c1_m;                                  \
    v8i16 k1_m, k2_m, k3_m, k4_m;                                      \
    v8i16 zero_m = { 0 };                                              \
    v4i32 tmp0_m, tmp1_m, tmp2_m, tmp3_m;                              \
    v4i32 int0_m, int1_m, int2_m, int3_m;                              \
    v8i16 mask_m = { sinpi_1_9,  sinpi_2_9,  sinpi_3_9,  sinpi_4_9,    \
                     -sinpi_1_9, -sinpi_2_9, -sinpi_3_9, -sinpi_4_9 }; \
                                                                       \
    SPLATI_H4_SH(mask_m, 3, 0, 1, 2, c0_m, c1_m, k1_m, k2_m);          \
    ILVEV_H2_SH(c0_m, c1_m, k1_m, k2_m, c0_m, c1_m);                   \
    ILVR_H2_SH(in0, in2, in1, in3, res0_m, res1_m);                    \
    DOTP_SH2_SW(res0_m, res1_m, c0_m, c1_m, tmp2_m, tmp1_m);           \
    int0_m = tmp2_m + tmp1_m;                                          \
                                                                       \
    SPLATI_H2_SH(mask_m, 4, 7, k4_m, k3_m);                            \
    ILVEV_H2_SH(k4_m, k1_m, k3_m, k2_m, c0_m, c1_m);                   \
    DOTP_SH2_SW(res0_m, res1_m, c0_m, c1_m, tmp0_m, tmp1_m);           \
    int1_m = tmp0_m + tmp1_m;                                          \
                                                                       \
    c0_m = __msa_splati_h(mask_m, 6);                                  \
    ILVL_H2_SH(k2_m, c0_m, zero_m, k2_m, c0_m, c1_m);                  \
    ILVR_H2_SH(in0, in2, in1, in3, res0_m, res1_m);                    \
    DOTP_SH2_SW(res0_m, res1_m, c0_m, c1_m, tmp0_m, tmp1_m);           \
    int2_m = tmp0_m + tmp1_m;                                          \
                                                                       \
    c0_m = __msa_splati_h(mask_m, 6);                                  \
    c0_m = __msa_ilvev_h(c0_m, k1_m);                                  \
                                                                       \
    res0_m = __msa_ilvr_h((in1), (in3));                               \
    tmp0_m = __msa_dotp_s_w(res0_m, c0_m);                             \
    int3_m = tmp2_m + tmp0_m;                                          \
                                                                       \
    res0_m = __msa_ilvr_h((in2), (in3));                               \
    c1_m = __msa_ilvev_h(k4_m, k3_m);                                  \
                                                                       \
    tmp2_m = __msa_dotp_s_w(res0_m, c1_m);                             \
    res1_m = __msa_ilvr_h((in0), (in2));                               \
    c1_m = __msa_ilvev_h(k1_m, zero_m);                                \
                                                                       \
    tmp3_m = __msa_dotp_s_w(res1_m, c1_m);                             \
    int3_m += tmp2_m;                                                  \
    int3_m += tmp3_m;                                                  \
                                                                       \
    SRARI_W4_SW(int0_m, int1_m, int2_m, int3_m, DCT_CONST_BITS);       \
    PCKEV_H2_SH(int0_m, int0_m, int1_m, int1_m, out0, out1);           \
    PCKEV_H2_SH(int2_m, int2_m, int3_m, int3_m, out2, out3);           \
  }
184

Adrian Grange's avatar
Adrian Grange committed
185
#define AV1_SET_CONST_PAIR(mask_h, idx1_h, idx2_h)    \
clang-format's avatar
clang-format committed
186 187 188 189 190 191 192 193
  ({                                                  \
    v8i16 c0_m, c1_m;                                 \
                                                      \
    SPLATI_H2_SH(mask_h, idx1_h, idx2_h, c0_m, c1_m); \
    c0_m = __msa_ilvev_h(c1_m, c0_m);                 \
                                                      \
    c0_m;                                             \
  })
194 195

/* multiply and add macro */
Adrian Grange's avatar
Adrian Grange committed
196
#define AV1_MADD(inp0, inp1, inp2, inp3, cst0, cst1, cst2, cst3, out0, out1,  \
clang-format's avatar
clang-format committed
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
                 out2, out3)                                                  \
  {                                                                           \
    v8i16 madd_s0_m, madd_s1_m, madd_s2_m, madd_s3_m;                         \
    v4i32 tmp0_m, tmp1_m, tmp2_m, tmp3_m;                                     \
                                                                              \
    ILVRL_H2_SH(inp1, inp0, madd_s1_m, madd_s0_m);                            \
    ILVRL_H2_SH(inp3, inp2, madd_s3_m, madd_s2_m);                            \
    DOTP_SH4_SW(madd_s1_m, madd_s0_m, madd_s1_m, madd_s0_m, cst0, cst0, cst1, \
                cst1, tmp0_m, tmp1_m, tmp2_m, tmp3_m);                        \
    SRARI_W4_SW(tmp0_m, tmp1_m, tmp2_m, tmp3_m, DCT_CONST_BITS);              \
    PCKEV_H2_SH(tmp1_m, tmp0_m, tmp3_m, tmp2_m, out0, out1);                  \
    DOTP_SH4_SW(madd_s3_m, madd_s2_m, madd_s3_m, madd_s2_m, cst2, cst2, cst3, \
                cst3, tmp0_m, tmp1_m, tmp2_m, tmp3_m);                        \
    SRARI_W4_SW(tmp0_m, tmp1_m, tmp2_m, tmp3_m, DCT_CONST_BITS);              \
    PCKEV_H2_SH(tmp1_m, tmp0_m, tmp3_m, tmp2_m, out2, out3);                  \
  }
213 214

/* idct 8x8 macro */
Adrian Grange's avatar
Adrian Grange committed
215
#define AOM_IDCT8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, out0, out1,    \
clang-format's avatar
clang-format committed
216 217 218 219 220 221 222 223
                       out2, out3, out4, out5, out6, out7)                    \
  {                                                                           \
    v8i16 tp0_m, tp1_m, tp2_m, tp3_m, tp4_m, tp5_m, tp6_m, tp7_m;             \
    v8i16 k0_m, k1_m, k2_m, k3_m, res0_m, res1_m, res2_m, res3_m;             \
    v4i32 tmp0_m, tmp1_m, tmp2_m, tmp3_m;                                     \
    v8i16 mask_m = { cospi_28_64, cospi_4_64,  cospi_20_64,  cospi_12_64,     \
                     cospi_16_64, -cospi_4_64, -cospi_20_64, -cospi_16_64 };  \
                                                                              \
Adrian Grange's avatar
Adrian Grange committed
224 225 226 227 228
    k0_m = AV1_SET_CONST_PAIR(mask_m, 0, 5);                                  \
    k1_m = AV1_SET_CONST_PAIR(mask_m, 1, 0);                                  \
    k2_m = AV1_SET_CONST_PAIR(mask_m, 6, 3);                                  \
    k3_m = AV1_SET_CONST_PAIR(mask_m, 3, 2);                                  \
    AV1_MADD(in1, in7, in3, in5, k0_m, k1_m, k2_m, k3_m, in1, in7, in3, in5); \
clang-format's avatar
clang-format committed
229
    SUB2(in1, in3, in7, in5, res0_m, res1_m);                                 \
Adrian Grange's avatar
Adrian Grange committed
230
    k0_m = AV1_SET_CONST_PAIR(mask_m, 4, 7);                                  \
clang-format's avatar
clang-format committed
231 232 233 234 235 236 237 238 239
    k1_m = __msa_splati_h(mask_m, 4);                                         \
                                                                              \
    ILVRL_H2_SH(res0_m, res1_m, res2_m, res3_m);                              \
    DOTP_SH4_SW(res2_m, res3_m, res2_m, res3_m, k0_m, k0_m, k1_m, k1_m,       \
                tmp0_m, tmp1_m, tmp2_m, tmp3_m);                              \
    SRARI_W4_SW(tmp0_m, tmp1_m, tmp2_m, tmp3_m, DCT_CONST_BITS);              \
    tp4_m = in1 + in3;                                                        \
    PCKEV_H2_SH(tmp1_m, tmp0_m, tmp3_m, tmp2_m, tp5_m, tp6_m);                \
    tp7_m = in7 + in5;                                                        \
Adrian Grange's avatar
Adrian Grange committed
240 241
    k2_m = AOM_SET_COSPI_PAIR(cospi_24_64, -cospi_8_64);                      \
    k3_m = AOM_SET_COSPI_PAIR(cospi_8_64, cospi_24_64);                       \
Adrian Grange's avatar
Adrian Grange committed
242
    AV1_MADD(in0, in4, in2, in6, k1_m, k0_m, k2_m, k3_m, in0, in4, in2, in6); \
clang-format's avatar
clang-format committed
243 244 245 246
    BUTTERFLY_4(in0, in4, in2, in6, tp0_m, tp1_m, tp2_m, tp3_m);              \
    BUTTERFLY_8(tp0_m, tp1_m, tp2_m, tp3_m, tp4_m, tp5_m, tp6_m, tp7_m, out0, \
                out1, out2, out3, out4, out5, out6, out7);                    \
  }
247

Adrian Grange's avatar
Adrian Grange committed
248
#define AV1_IADST8x8_1D(in0, in1, in2, in3, in4, in5, in6, in7, out0, out1,   \
clang-format's avatar
clang-format committed
249 250 251 252 253 254 255 256 257 258 259 260 261
                        out2, out3, out4, out5, out6, out7)                   \
  {                                                                           \
    v4i32 r0_m, r1_m, r2_m, r3_m, r4_m, r5_m, r6_m, r7_m;                     \
    v4i32 m0_m, m1_m, m2_m, m3_m, t0_m, t1_m;                                 \
    v8i16 res0_m, res1_m, res2_m, res3_m, k0_m, k1_m, in_s0, in_s1;           \
    v8i16 mask1_m = { cospi_2_64,  cospi_30_64,  -cospi_2_64, cospi_10_64,    \
                      cospi_22_64, -cospi_10_64, cospi_18_64, cospi_14_64 };  \
    v8i16 mask2_m = { cospi_14_64,  -cospi_18_64, cospi_26_64, cospi_6_64,    \
                      -cospi_26_64, cospi_8_64,   cospi_24_64, -cospi_8_64 }; \
    v8i16 mask3_m = {                                                         \
      -cospi_24_64, cospi_8_64, cospi_16_64, -cospi_16_64, 0, 0, 0, 0         \
    };                                                                        \
                                                                              \
Adrian Grange's avatar
Adrian Grange committed
262 263
    k0_m = AV1_SET_CONST_PAIR(mask1_m, 0, 1);                                 \
    k1_m = AV1_SET_CONST_PAIR(mask1_m, 1, 2);                                 \
clang-format's avatar
clang-format committed
264 265 266
    ILVRL_H2_SH(in1, in0, in_s1, in_s0);                                      \
    DOTP_SH4_SW(in_s1, in_s0, in_s1, in_s0, k0_m, k0_m, k1_m, k1_m, r0_m,     \
                r1_m, r2_m, r3_m);                                            \
Adrian Grange's avatar
Adrian Grange committed
267 268
    k0_m = AV1_SET_CONST_PAIR(mask1_m, 6, 7);                                 \
    k1_m = AV1_SET_CONST_PAIR(mask2_m, 0, 1);                                 \
clang-format's avatar
clang-format committed
269 270 271 272 273 274 275 276 277 278 279
    ILVRL_H2_SH(in5, in4, in_s1, in_s0);                                      \
    DOTP_SH4_SW(in_s1, in_s0, in_s1, in_s0, k0_m, k0_m, k1_m, k1_m, r4_m,     \
                r5_m, r6_m, r7_m);                                            \
    ADD4(r0_m, r4_m, r1_m, r5_m, r2_m, r6_m, r3_m, r7_m, m0_m, m1_m, m2_m,    \
         m3_m);                                                               \
    SRARI_W4_SW(m0_m, m1_m, m2_m, m3_m, DCT_CONST_BITS);                      \
    PCKEV_H2_SH(m1_m, m0_m, m3_m, m2_m, res0_m, res1_m);                      \
    SUB4(r0_m, r4_m, r1_m, r5_m, r2_m, r6_m, r3_m, r7_m, m0_m, m1_m, m2_m,    \
         m3_m);                                                               \
    SRARI_W4_SW(m0_m, m1_m, m2_m, m3_m, DCT_CONST_BITS);                      \
    PCKEV_H2_SW(m1_m, m0_m, m3_m, m2_m, t0_m, t1_m);                          \
Adrian Grange's avatar
Adrian Grange committed
280 281
    k0_m = AV1_SET_CONST_PAIR(mask1_m, 3, 4);                                 \
    k1_m = AV1_SET_CONST_PAIR(mask1_m, 4, 5);                                 \
clang-format's avatar
clang-format committed
282 283 284
    ILVRL_H2_SH(in3, in2, in_s1, in_s0);                                      \
    DOTP_SH4_SW(in_s1, in_s0, in_s1, in_s0, k0_m, k0_m, k1_m, k1_m, r0_m,     \
                r1_m, r2_m, r3_m);                                            \
Adrian Grange's avatar
Adrian Grange committed
285 286
    k0_m = AV1_SET_CONST_PAIR(mask2_m, 2, 3);                                 \
    k1_m = AV1_SET_CONST_PAIR(mask2_m, 3, 4);                                 \
clang-format's avatar
clang-format committed
287 288 289 290 291 292 293 294 295 296 297 298 299
    ILVRL_H2_SH(in7, in6, in_s1, in_s0);                                      \
    DOTP_SH4_SW(in_s1, in_s0, in_s1, in_s0, k0_m, k0_m, k1_m, k1_m, r4_m,     \
                r5_m, r6_m, r7_m);                                            \
    ADD4(r0_m, r4_m, r1_m, r5_m, r2_m, r6_m, r3_m, r7_m, m0_m, m1_m, m2_m,    \
         m3_m);                                                               \
    SRARI_W4_SW(m0_m, m1_m, m2_m, m3_m, DCT_CONST_BITS);                      \
    PCKEV_H2_SH(m1_m, m0_m, m3_m, m2_m, res2_m, res3_m);                      \
    SUB4(r0_m, r4_m, r1_m, r5_m, r2_m, r6_m, r3_m, r7_m, m0_m, m1_m, m2_m,    \
         m3_m);                                                               \
    SRARI_W4_SW(m0_m, m1_m, m2_m, m3_m, DCT_CONST_BITS);                      \
    PCKEV_H2_SW(m1_m, m0_m, m3_m, m2_m, r2_m, r3_m);                          \
    ILVRL_H2_SW(r3_m, r2_m, m2_m, m3_m);                                      \
    BUTTERFLY_4(res0_m, res1_m, res3_m, res2_m, out0, in7, in4, in3);         \
Adrian Grange's avatar
Adrian Grange committed
300 301
    k0_m = AV1_SET_CONST_PAIR(mask2_m, 5, 6);                                 \
    k1_m = AV1_SET_CONST_PAIR(mask2_m, 6, 7);                                 \
clang-format's avatar
clang-format committed
302 303 304
    ILVRL_H2_SH(t1_m, t0_m, in_s1, in_s0);                                    \
    DOTP_SH4_SW(in_s1, in_s0, in_s1, in_s0, k0_m, k0_m, k1_m, k1_m, r0_m,     \
                r1_m, r2_m, r3_m);                                            \
Adrian Grange's avatar
Adrian Grange committed
305
    k1_m = AV1_SET_CONST_PAIR(mask3_m, 0, 1);                                 \
clang-format's avatar
clang-format committed
306 307 308 309 310 311 312 313 314 315
    DOTP_SH4_SW(m2_m, m3_m, m2_m, m3_m, k0_m, k0_m, k1_m, k1_m, r4_m, r5_m,   \
                r6_m, r7_m);                                                  \
    ADD4(r0_m, r6_m, r1_m, r7_m, r2_m, r4_m, r3_m, r5_m, m0_m, m1_m, m2_m,    \
         m3_m);                                                               \
    SRARI_W4_SW(m0_m, m1_m, m2_m, m3_m, DCT_CONST_BITS);                      \
    PCKEV_H2_SH(m1_m, m0_m, m3_m, m2_m, in1, out6);                           \
    SUB4(r0_m, r6_m, r1_m, r7_m, r2_m, r4_m, r3_m, r5_m, m0_m, m1_m, m2_m,    \
         m3_m);                                                               \
    SRARI_W4_SW(m0_m, m1_m, m2_m, m3_m, DCT_CONST_BITS);                      \
    PCKEV_H2_SH(m1_m, m0_m, m3_m, m2_m, in2, in5);                            \
Adrian Grange's avatar
Adrian Grange committed
316 317
    k0_m = AV1_SET_CONST_PAIR(mask3_m, 2, 2);                                 \
    k1_m = AV1_SET_CONST_PAIR(mask3_m, 2, 3);                                 \
clang-format's avatar
clang-format committed
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
    ILVRL_H2_SH(in4, in3, in_s1, in_s0);                                      \
    DOTP_SH4_SW(in_s1, in_s0, in_s1, in_s0, k0_m, k0_m, k1_m, k1_m, m0_m,     \
                m1_m, m2_m, m3_m);                                            \
    SRARI_W4_SW(m0_m, m1_m, m2_m, m3_m, DCT_CONST_BITS);                      \
    PCKEV_H2_SH(m1_m, m0_m, m3_m, m2_m, in3, out4);                           \
    ILVRL_H2_SW(in5, in2, m2_m, m3_m);                                        \
    DOTP_SH4_SW(m2_m, m3_m, m2_m, m3_m, k0_m, k0_m, k1_m, k1_m, m0_m, m1_m,   \
                m2_m, m3_m);                                                  \
    SRARI_W4_SW(m0_m, m1_m, m2_m, m3_m, DCT_CONST_BITS);                      \
    PCKEV_H2_SH(m1_m, m0_m, m3_m, m2_m, out2, in5);                           \
                                                                              \
    out1 = -in1;                                                              \
    out3 = -in3;                                                              \
    out5 = -in5;                                                              \
    out7 = -in7;                                                              \
  }
334

Adrian Grange's avatar
Adrian Grange committed
335
#define AOM_IADST8x16_1D(r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11,     \
clang-format's avatar
clang-format committed
336 337 338 339 340 341 342 343 344 345 346
                         r12, r13, r14, r15, out0, out1, out2, out3, out4,     \
                         out5, out6, out7, out8, out9, out10, out11, out12,    \
                         out13, out14, out15)                                  \
  {                                                                            \
    v8i16 g0_m, g1_m, g2_m, g3_m, g4_m, g5_m, g6_m, g7_m;                      \
    v8i16 g8_m, g9_m, g10_m, g11_m, g12_m, g13_m, g14_m, g15_m;                \
    v8i16 h0_m, h1_m, h2_m, h3_m, h4_m, h5_m, h6_m, h7_m;                      \
    v8i16 h8_m, h9_m, h10_m, h11_m;                                            \
    v8i16 k0_m, k1_m, k2_m, k3_m;                                              \
                                                                               \
    /* stage 1 */                                                              \
Adrian Grange's avatar
Adrian Grange committed
347 348 349 350
    k0_m = AOM_SET_COSPI_PAIR(cospi_1_64, cospi_31_64);                        \
    k1_m = AOM_SET_COSPI_PAIR(cospi_31_64, -cospi_1_64);                       \
    k2_m = AOM_SET_COSPI_PAIR(cospi_17_64, cospi_15_64);                       \
    k3_m = AOM_SET_COSPI_PAIR(cospi_15_64, -cospi_17_64);                      \
clang-format's avatar
clang-format committed
351
    MADD_BF(r15, r0, r7, r8, k0_m, k1_m, k2_m, k3_m, g0_m, g1_m, g2_m, g3_m);  \
Adrian Grange's avatar
Adrian Grange committed
352 353 354 355
    k0_m = AOM_SET_COSPI_PAIR(cospi_5_64, cospi_27_64);                        \
    k1_m = AOM_SET_COSPI_PAIR(cospi_27_64, -cospi_5_64);                       \
    k2_m = AOM_SET_COSPI_PAIR(cospi_21_64, cospi_11_64);                       \
    k3_m = AOM_SET_COSPI_PAIR(cospi_11_64, -cospi_21_64);                      \
clang-format's avatar
clang-format committed
356
    MADD_BF(r13, r2, r5, r10, k0_m, k1_m, k2_m, k3_m, g4_m, g5_m, g6_m, g7_m); \
Adrian Grange's avatar
Adrian Grange committed
357 358 359 360
    k0_m = AOM_SET_COSPI_PAIR(cospi_9_64, cospi_23_64);                        \
    k1_m = AOM_SET_COSPI_PAIR(cospi_23_64, -cospi_9_64);                       \
    k2_m = AOM_SET_COSPI_PAIR(cospi_25_64, cospi_7_64);                        \
    k3_m = AOM_SET_COSPI_PAIR(cospi_7_64, -cospi_25_64);                       \
clang-format's avatar
clang-format committed
361 362
    MADD_BF(r11, r4, r3, r12, k0_m, k1_m, k2_m, k3_m, g8_m, g9_m, g10_m,       \
            g11_m);                                                            \
Adrian Grange's avatar
Adrian Grange committed
363 364 365 366
    k0_m = AOM_SET_COSPI_PAIR(cospi_13_64, cospi_19_64);                       \
    k1_m = AOM_SET_COSPI_PAIR(cospi_19_64, -cospi_13_64);                      \
    k2_m = AOM_SET_COSPI_PAIR(cospi_29_64, cospi_3_64);                        \
    k3_m = AOM_SET_COSPI_PAIR(cospi_3_64, -cospi_29_64);                       \
clang-format's avatar
clang-format committed
367 368 369 370
    MADD_BF(r9, r6, r1, r14, k0_m, k1_m, k2_m, k3_m, g12_m, g13_m, g14_m,      \
            g15_m);                                                            \
                                                                               \
    /* stage 2 */                                                              \
Adrian Grange's avatar
Adrian Grange committed
371 372 373
    k0_m = AOM_SET_COSPI_PAIR(cospi_4_64, cospi_28_64);                        \
    k1_m = AOM_SET_COSPI_PAIR(cospi_28_64, -cospi_4_64);                       \
    k2_m = AOM_SET_COSPI_PAIR(-cospi_28_64, cospi_4_64);                       \
clang-format's avatar
clang-format committed
374 375
    MADD_BF(g1_m, g3_m, g9_m, g11_m, k0_m, k1_m, k2_m, k0_m, h0_m, h1_m, h2_m, \
            h3_m);                                                             \
Adrian Grange's avatar
Adrian Grange committed
376 377 378
    k0_m = AOM_SET_COSPI_PAIR(cospi_12_64, cospi_20_64);                       \
    k1_m = AOM_SET_COSPI_PAIR(-cospi_20_64, cospi_12_64);                      \
    k2_m = AOM_SET_COSPI_PAIR(cospi_20_64, -cospi_12_64);                      \
clang-format's avatar
clang-format committed
379 380 381 382 383 384 385 386
    MADD_BF(g7_m, g5_m, g15_m, g13_m, k0_m, k1_m, k2_m, k0_m, h4_m, h5_m,      \
            h6_m, h7_m);                                                       \
    BUTTERFLY_4(h0_m, h2_m, h6_m, h4_m, out8, out9, out11, out10);             \
    BUTTERFLY_8(g0_m, g2_m, g4_m, g6_m, g14_m, g12_m, g10_m, g8_m, h8_m, h9_m, \
                h10_m, h11_m, h6_m, h4_m, h2_m, h0_m);                         \
                                                                               \
    /* stage 3 */                                                              \
    BUTTERFLY_4(h8_m, h9_m, h11_m, h10_m, out0, out1, h11_m, h10_m);           \
Adrian Grange's avatar
Adrian Grange committed
387 388 389
    k0_m = AOM_SET_COSPI_PAIR(cospi_8_64, cospi_24_64);                        \
    k1_m = AOM_SET_COSPI_PAIR(cospi_24_64, -cospi_8_64);                       \
    k2_m = AOM_SET_COSPI_PAIR(-cospi_24_64, cospi_8_64);                       \
clang-format's avatar
clang-format committed
390 391 392 393 394 395
    MADD_BF(h0_m, h2_m, h4_m, h6_m, k0_m, k1_m, k2_m, k0_m, out4, out6, out5,  \
            out7);                                                             \
    MADD_BF(h1_m, h3_m, h5_m, h7_m, k0_m, k1_m, k2_m, k0_m, out12, out14,      \
            out13, out15);                                                     \
                                                                               \
    /* stage 4 */                                                              \
Adrian Grange's avatar
Adrian Grange committed
396 397 398 399
    k0_m = AOM_SET_COSPI_PAIR(cospi_16_64, cospi_16_64);                       \
    k1_m = AOM_SET_COSPI_PAIR(-cospi_16_64, -cospi_16_64);                     \
    k2_m = AOM_SET_COSPI_PAIR(cospi_16_64, -cospi_16_64);                      \
    k3_m = AOM_SET_COSPI_PAIR(-cospi_16_64, cospi_16_64);                      \
clang-format's avatar
clang-format committed
400 401 402 403 404
    MADD_SHORT(h10_m, h11_m, k1_m, k2_m, out2, out3);                          \
    MADD_SHORT(out6, out7, k0_m, k3_m, out6, out7);                            \
    MADD_SHORT(out10, out11, k0_m, k3_m, out10, out11);                        \
    MADD_SHORT(out14, out15, k1_m, k2_m, out14, out15);                        \
  }
405

Adrian Grange's avatar
Adrian Grange committed
406
void aom_idct16_1d_columns_addblk_msa(int16_t *input, uint8_t *dst,
407
                                      int32_t dst_stride);
Adrian Grange's avatar
Adrian Grange committed
408 409
void aom_idct16_1d_rows_msa(const int16_t *input, int16_t *output);
void aom_iadst16_1d_columns_addblk_msa(int16_t *input, uint8_t *dst,
410
                                       int32_t dst_stride);
Adrian Grange's avatar
Adrian Grange committed
411
void aom_iadst16_1d_rows_msa(const int16_t *input, int16_t *output);
Adrian Grange's avatar
Adrian Grange committed
412
#endif  // AOM_DSP_MIPS_INV_TXFM_MSA_H_