1*c0909341SAndroid Build Coastguard Worker /*
2*c0909341SAndroid Build Coastguard Worker * Copyright © 2023, VideoLAN and dav1d authors
3*c0909341SAndroid Build Coastguard Worker * Copyright © 2023, Loongson Technology Corporation Limited
4*c0909341SAndroid Build Coastguard Worker * All rights reserved.
5*c0909341SAndroid Build Coastguard Worker *
6*c0909341SAndroid Build Coastguard Worker * Redistribution and use in source and binary forms, with or without
7*c0909341SAndroid Build Coastguard Worker * modification, are permitted provided that the following conditions are met:
8*c0909341SAndroid Build Coastguard Worker *
9*c0909341SAndroid Build Coastguard Worker * 1. Redistributions of source code must retain the above copyright notice, this
10*c0909341SAndroid Build Coastguard Worker * list of conditions and the following disclaimer.
11*c0909341SAndroid Build Coastguard Worker *
12*c0909341SAndroid Build Coastguard Worker * 2. Redistributions in binary form must reproduce the above copyright notice,
13*c0909341SAndroid Build Coastguard Worker * this list of conditions and the following disclaimer in the documentation
14*c0909341SAndroid Build Coastguard Worker * and/or other materials provided with the distribution.
15*c0909341SAndroid Build Coastguard Worker *
16*c0909341SAndroid Build Coastguard Worker * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17*c0909341SAndroid Build Coastguard Worker * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18*c0909341SAndroid Build Coastguard Worker * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19*c0909341SAndroid Build Coastguard Worker * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20*c0909341SAndroid Build Coastguard Worker * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21*c0909341SAndroid Build Coastguard Worker * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22*c0909341SAndroid Build Coastguard Worker * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23*c0909341SAndroid Build Coastguard Worker * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24*c0909341SAndroid Build Coastguard Worker * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25*c0909341SAndroid Build Coastguard Worker * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*c0909341SAndroid Build Coastguard Worker */
27*c0909341SAndroid Build Coastguard Worker
28*c0909341SAndroid Build Coastguard Worker #ifndef DAV1D_SRC_LOONGARCH_ITX_H
29*c0909341SAndroid Build Coastguard Worker #define DAV1D_SRC_LOONGARCH_ITX_H
30*c0909341SAndroid Build Coastguard Worker
31*c0909341SAndroid Build Coastguard Worker #include "src/cpu.h"
32*c0909341SAndroid Build Coastguard Worker #include "src/itx.h"
33*c0909341SAndroid Build Coastguard Worker
34*c0909341SAndroid Build Coastguard Worker decl_itx17_fns( 4, 4, lsx);
35*c0909341SAndroid Build Coastguard Worker decl_itx16_fns( 4, 8, lsx);
36*c0909341SAndroid Build Coastguard Worker decl_itx16_fns( 4, 16, lsx);
37*c0909341SAndroid Build Coastguard Worker decl_itx16_fns( 8, 4, lsx);
38*c0909341SAndroid Build Coastguard Worker decl_itx16_fns( 8, 8, lsx);
39*c0909341SAndroid Build Coastguard Worker decl_itx16_fns( 8, 16, lsx);
40*c0909341SAndroid Build Coastguard Worker decl_itx2_fns ( 8, 32, lsx);
41*c0909341SAndroid Build Coastguard Worker decl_itx16_fns(16, 8, lsx);
42*c0909341SAndroid Build Coastguard Worker
43*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_dct_dct_16x4, lsx));
44*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_identity_identity_16x4, lsx));
45*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_adst_dct_16x4, lsx));
46*c0909341SAndroid Build Coastguard Worker
47*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_dct_dct_16x16, lsx));
48*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_adst_adst_16x16, lsx));
49*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_adst_dct_16x16, lsx));
50*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_dct_adst_16x16, lsx));
51*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_flipadst_dct_16x16, lsx));
52*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_dct_flipadst_16x16, lsx));
53*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_adst_flipadst_16x16, lsx));
54*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_flipadst_adst_16x16, lsx));
55*c0909341SAndroid Build Coastguard Worker
56*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_dct_dct_16x32, lsx));
57*c0909341SAndroid Build Coastguard Worker
58*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_dct_dct_32x8, lsx));
59*c0909341SAndroid Build Coastguard Worker
60*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_dct_dct_32x16, lsx));
61*c0909341SAndroid Build Coastguard Worker
62*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_dct_dct_32x32, lsx));
63*c0909341SAndroid Build Coastguard Worker
64*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_dct_dct_64x32, lsx));
65*c0909341SAndroid Build Coastguard Worker
66*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_dct_dct_64x64, lsx));
67*c0909341SAndroid Build Coastguard Worker
68*c0909341SAndroid Build Coastguard Worker decl_itx_fn(BF(dav1d_inv_txfm_add_adst_adst_16x16, lasx));
69*c0909341SAndroid Build Coastguard Worker
itx_dsp_init_loongarch(Dav1dInvTxfmDSPContext * const c,int bpc)70*c0909341SAndroid Build Coastguard Worker static ALWAYS_INLINE void itx_dsp_init_loongarch(Dav1dInvTxfmDSPContext *const c, int bpc) {
71*c0909341SAndroid Build Coastguard Worker #if BITDEPTH == 8
72*c0909341SAndroid Build Coastguard Worker const unsigned flags = dav1d_get_cpu_flags();
73*c0909341SAndroid Build Coastguard Worker
74*c0909341SAndroid Build Coastguard Worker if (!(flags & DAV1D_LOONGARCH_CPU_FLAG_LSX)) return;
75*c0909341SAndroid Build Coastguard Worker
76*c0909341SAndroid Build Coastguard Worker if (BITDEPTH != 8 ) return;
77*c0909341SAndroid Build Coastguard Worker
78*c0909341SAndroid Build Coastguard Worker assign_itx17_fn( , 4, 4, lsx);
79*c0909341SAndroid Build Coastguard Worker assign_itx16_fn(R, 4, 8, lsx);
80*c0909341SAndroid Build Coastguard Worker assign_itx16_fn(R, 4, 16, lsx);
81*c0909341SAndroid Build Coastguard Worker assign_itx16_fn(R, 8, 4, lsx);
82*c0909341SAndroid Build Coastguard Worker assign_itx16_fn( , 8, 8, lsx);
83*c0909341SAndroid Build Coastguard Worker assign_itx16_fn(R, 8, 16, lsx);
84*c0909341SAndroid Build Coastguard Worker assign_itx2_fn (R, 8, 32, lsx);
85*c0909341SAndroid Build Coastguard Worker assign_itx16_fn(R, 16, 8, lsx);
86*c0909341SAndroid Build Coastguard Worker assign_itx1_fn (R, 64, 32, lsx);
87*c0909341SAndroid Build Coastguard Worker assign_itx1_fn ( , 64, 64, lsx);
88*c0909341SAndroid Build Coastguard Worker
89*c0909341SAndroid Build Coastguard Worker c->itxfm_add[RTX_16X4][DCT_DCT] = dav1d_inv_txfm_add_dct_dct_16x4_8bpc_lsx;
90*c0909341SAndroid Build Coastguard Worker c->itxfm_add[RTX_16X4][IDTX] = dav1d_inv_txfm_add_identity_identity_16x4_8bpc_lsx;
91*c0909341SAndroid Build Coastguard Worker c->itxfm_add[RTX_16X4][DCT_ADST] = dav1d_inv_txfm_add_adst_dct_16x4_8bpc_lsx;
92*c0909341SAndroid Build Coastguard Worker
93*c0909341SAndroid Build Coastguard Worker c->itxfm_add[TX_16X16][DCT_DCT] = dav1d_inv_txfm_add_dct_dct_16x16_8bpc_lsx;
94*c0909341SAndroid Build Coastguard Worker c->itxfm_add[TX_16X16][ADST_ADST] = dav1d_inv_txfm_add_adst_adst_16x16_8bpc_lsx;
95*c0909341SAndroid Build Coastguard Worker c->itxfm_add[TX_16X16][DCT_ADST] = dav1d_inv_txfm_add_adst_dct_16x16_8bpc_lsx;
96*c0909341SAndroid Build Coastguard Worker c->itxfm_add[TX_16X16][ADST_DCT] = dav1d_inv_txfm_add_dct_adst_16x16_8bpc_lsx;
97*c0909341SAndroid Build Coastguard Worker c->itxfm_add[TX_16X16][DCT_FLIPADST] = dav1d_inv_txfm_add_flipadst_dct_16x16_8bpc_lsx;
98*c0909341SAndroid Build Coastguard Worker c->itxfm_add[TX_16X16][FLIPADST_DCT] = dav1d_inv_txfm_add_dct_flipadst_16x16_8bpc_lsx;
99*c0909341SAndroid Build Coastguard Worker c->itxfm_add[TX_16X16][FLIPADST_ADST] = dav1d_inv_txfm_add_adst_flipadst_16x16_8bpc_lsx;
100*c0909341SAndroid Build Coastguard Worker c->itxfm_add[TX_16X16][ADST_FLIPADST] = dav1d_inv_txfm_add_flipadst_adst_16x16_8bpc_lsx;
101*c0909341SAndroid Build Coastguard Worker
102*c0909341SAndroid Build Coastguard Worker c->itxfm_add[RTX_16X32][DCT_DCT] = dav1d_inv_txfm_add_dct_dct_16x32_8bpc_lsx;
103*c0909341SAndroid Build Coastguard Worker
104*c0909341SAndroid Build Coastguard Worker c->itxfm_add[RTX_32X8][DCT_DCT] = dav1d_inv_txfm_add_dct_dct_32x8_8bpc_lsx;
105*c0909341SAndroid Build Coastguard Worker
106*c0909341SAndroid Build Coastguard Worker c->itxfm_add[RTX_32X16][DCT_DCT] = dav1d_inv_txfm_add_dct_dct_32x16_8bpc_lsx;
107*c0909341SAndroid Build Coastguard Worker
108*c0909341SAndroid Build Coastguard Worker c->itxfm_add[TX_32X32][DCT_DCT] = dav1d_inv_txfm_add_dct_dct_32x32_8bpc_lsx;
109*c0909341SAndroid Build Coastguard Worker
110*c0909341SAndroid Build Coastguard Worker if (!(flags & DAV1D_LOONGARCH_CPU_FLAG_LASX)) return;
111*c0909341SAndroid Build Coastguard Worker
112*c0909341SAndroid Build Coastguard Worker if (BITDEPTH != 8 ) return;
113*c0909341SAndroid Build Coastguard Worker
114*c0909341SAndroid Build Coastguard Worker c->itxfm_add[TX_16X16][ADST_ADST] = dav1d_inv_txfm_add_adst_adst_16x16_8bpc_lasx;
115*c0909341SAndroid Build Coastguard Worker
116*c0909341SAndroid Build Coastguard Worker #endif
117*c0909341SAndroid Build Coastguard Worker }
118*c0909341SAndroid Build Coastguard Worker
119*c0909341SAndroid Build Coastguard Worker #endif /* DAV1D_SRC_LOONGARCH_ITX_H */
120