xref: /aosp_15_r20/external/libvpx/vpx_dsp/loongarch/txfm_macros_lsx.h (revision fb1b10ab9aebc7c7068eedab379b749d7e3900be)
1 /*
2  *  Copyright (c) 2022 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 #ifndef VPX_VPX_DSP_LOONGARCH_TXFM_MACROS_LSX_H_
12 #define VPX_VPX_DSP_LOONGARCH_TXFM_MACROS_LSX_H_
13 
14 #include "vpx_util/loongson_intrinsics.h"
15 
16 #define DOTP_CONST_PAIR(reg0, reg1, cnst0, cnst1, out0, out1)         \
17   do {                                                                \
18     __m128i s0_m, s1_m, s2_m, s3_m, s4_m, s5_m;                       \
19     __m128i k0_m, k1_m, k2_m, k3_m;                                   \
20                                                                       \
21     k0_m = __lsx_vreplgr2vr_h(cnst0);                                 \
22     k1_m = __lsx_vreplgr2vr_h(cnst1);                                 \
23     k2_m = __lsx_vpackev_h(k1_m, k0_m);                               \
24                                                                       \
25     DUP2_ARG2(__lsx_vilvl_h, reg1, reg0, reg0, reg1, s5_m, s3_m);     \
26     DUP2_ARG2(__lsx_vilvh_h, reg1, reg0, reg0, reg1, s4_m, s2_m);     \
27                                                                       \
28     DUP2_ARG2(__lsx_vmulwev_w_h, s5_m, k0_m, s4_m, k0_m, s1_m, s0_m); \
29     k3_m = __lsx_vmulwod_w_h(s5_m, k1_m);                             \
30     s1_m = __lsx_vsub_w(s1_m, k3_m);                                  \
31     k3_m = __lsx_vmulwod_w_h(s4_m, k1_m);                             \
32     s0_m = __lsx_vsub_w(s0_m, k3_m);                                  \
33                                                                       \
34     out0 = __lsx_vssrarni_h_w(s0_m, s1_m, DCT_CONST_BITS);            \
35                                                                       \
36     DUP2_ARG2(__lsx_vdp2_w_h, s3_m, k2_m, s2_m, k2_m, s1_m, s0_m);    \
37     out1 = __lsx_vssrarni_h_w(s0_m, s1_m, DCT_CONST_BITS);            \
38   } while (0)
39 
40 #define DOT_SHIFT_RIGHT_PCK_H(in0, in1, in2, in3)                \
41   do {                                                           \
42     __m128i tp0_m, tp1_m;                                        \
43                                                                  \
44     DUP2_ARG2(__lsx_vdp2_w_h, in0, in2, in1, in2, tp1_m, tp0_m); \
45     in3 = __lsx_vssrarni_h_w(tp1_m, tp0_m, DCT_CONST_BITS);      \
46   } while (0)
47 
48 #endif  // VPX_VPX_DSP_LOONGARCH_TXFM_MACROS_LSX_H_
49