1/*
2 * Copyright (c) 2021 Loongson Technology Corporation Limited
3 * Contributed by Hao Chen <chenhao@loongson.cn>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef AVCODEC_LOONGARCH_VP9DSP_LOONGARCH_H
23#define AVCODEC_LOONGARCH_VP9DSP_LOONGARCH_H
24
25#define VP9_8TAP_LOONGARCH_LSX_FUNC(SIZE, type, type_idx)                    \
26void ff_put_8tap_##type##_##SIZE##h_lsx(uint8_t *dst, ptrdiff_t dststride,   \
27                                        const uint8_t *src,                  \
28                                        ptrdiff_t srcstride,                 \
29                                        int h, int mx, int my);              \
30                                                                             \
31void ff_put_8tap_##type##_##SIZE##v_lsx(uint8_t *dst, ptrdiff_t dststride,   \
32                                        const uint8_t *src,                  \
33                                        ptrdiff_t srcstride,                 \
34                                        int h, int mx, int my);              \
35                                                                             \
36void ff_put_8tap_##type##_##SIZE##hv_lsx(uint8_t *dst, ptrdiff_t dststride,  \
37                                         const uint8_t *src,                 \
38                                         ptrdiff_t srcstride,                \
39                                         int h, int mx, int my);             \
40                                                                             \
41void ff_avg_8tap_##type##_##SIZE##h_lsx(uint8_t *dst, ptrdiff_t dststride,   \
42                                        const uint8_t *src,                  \
43                                        ptrdiff_t srcstride,                 \
44                                        int h, int mx, int my);              \
45                                                                             \
46void ff_avg_8tap_##type##_##SIZE##v_lsx(uint8_t *dst, ptrdiff_t dststride,   \
47                                        const uint8_t *src,                  \
48                                        ptrdiff_t srcstride,                 \
49                                        int h, int mx, int my);              \
50                                                                             \
51void ff_avg_8tap_##type##_##SIZE##hv_lsx(uint8_t *dst, ptrdiff_t dststride,  \
52                                         const uint8_t *src,                 \
53                                         ptrdiff_t srcstride,                \
54                                         int h, int mx, int my);
55
56#define VP9_COPY_LOONGARCH_LSX_FUNC(SIZE)                          \
57void ff_copy##SIZE##_lsx(uint8_t *dst, ptrdiff_t dststride,        \
58                         const uint8_t *src, ptrdiff_t srcstride,  \
59                         int h, int mx, int my);                   \
60                                                                   \
61void ff_avg##SIZE##_lsx(uint8_t *dst, ptrdiff_t dststride,         \
62                        const uint8_t *src, ptrdiff_t srcstride,   \
63                        int h, int mx, int my);
64
65VP9_8TAP_LOONGARCH_LSX_FUNC(64, regular, FILTER_8TAP_REGULAR);
66VP9_8TAP_LOONGARCH_LSX_FUNC(32, regular, FILTER_8TAP_REGULAR);
67VP9_8TAP_LOONGARCH_LSX_FUNC(16, regular, FILTER_8TAP_REGULAR);
68VP9_8TAP_LOONGARCH_LSX_FUNC(8, regular, FILTER_8TAP_REGULAR);
69VP9_8TAP_LOONGARCH_LSX_FUNC(4, regular, FILTER_8TAP_REGULAR);
70
71VP9_8TAP_LOONGARCH_LSX_FUNC(64, sharp, FILTER_8TAP_SHARP);
72VP9_8TAP_LOONGARCH_LSX_FUNC(32, sharp, FILTER_8TAP_SHARP);
73VP9_8TAP_LOONGARCH_LSX_FUNC(16, sharp, FILTER_8TAP_SHARP);
74VP9_8TAP_LOONGARCH_LSX_FUNC(8, sharp, FILTER_8TAP_SHARP);
75VP9_8TAP_LOONGARCH_LSX_FUNC(4, sharp, FILTER_8TAP_SHARP);
76
77VP9_8TAP_LOONGARCH_LSX_FUNC(64, smooth, FILTER_8TAP_SMOOTH);
78VP9_8TAP_LOONGARCH_LSX_FUNC(32, smooth, FILTER_8TAP_SMOOTH);
79VP9_8TAP_LOONGARCH_LSX_FUNC(16, smooth, FILTER_8TAP_SMOOTH);
80VP9_8TAP_LOONGARCH_LSX_FUNC(8, smooth, FILTER_8TAP_SMOOTH);
81VP9_8TAP_LOONGARCH_LSX_FUNC(4, smooth, FILTER_8TAP_SMOOTH);
82
83VP9_COPY_LOONGARCH_LSX_FUNC(64);
84VP9_COPY_LOONGARCH_LSX_FUNC(32);
85VP9_COPY_LOONGARCH_LSX_FUNC(16);
86VP9_COPY_LOONGARCH_LSX_FUNC(8);
87
88#undef VP9_8TAP_LOONGARCH_LSX_FUNC
89#undef VP9_COPY_LOONGARCH_LSX_FUNC
90
91void ff_vert_16x16_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
92                       const uint8_t *top);
93void ff_vert_32x32_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
94                       const uint8_t *top);
95void ff_hor_16x16_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
96                      const uint8_t *top);
97void ff_hor_32x32_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
98                      const uint8_t *top);
99void ff_dc_4x4_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
100                   const uint8_t *top);
101void ff_dc_8x8_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
102                   const uint8_t *top);
103void ff_dc_16x16_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
104                     const uint8_t *top);
105void ff_dc_32x32_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
106                     const uint8_t *top);
107void ff_dc_left_4x4_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
108                        const uint8_t *top);
109void ff_dc_left_8x8_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
110                        const uint8_t *top);
111void ff_dc_left_16x16_lsx(uint8_t *dst, ptrdiff_t stride,
112                          const uint8_t *left, const uint8_t *top);
113void ff_dc_left_32x32_lsx(uint8_t *dst, ptrdiff_t stride,
114                          const uint8_t *left, const uint8_t *top);
115void ff_dc_top_4x4_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
116                       const uint8_t *top);
117void ff_dc_top_8x8_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
118                       const uint8_t *top);
119void ff_dc_top_16x16_lsx(uint8_t *dst, ptrdiff_t stride,
120                         const uint8_t *left, const uint8_t *top);
121void ff_dc_top_32x32_lsx(uint8_t *dst, ptrdiff_t stride,
122                         const uint8_t *left, const uint8_t *top);
123void ff_dc_128_16x16_lsx(uint8_t *dst, ptrdiff_t stride,
124                         const uint8_t *left, const uint8_t *top);
125void ff_dc_128_32x32_lsx(uint8_t *dst, ptrdiff_t stride,
126                         const uint8_t *left, const uint8_t *top);
127void ff_dc_127_16x16_lsx(uint8_t *dst, ptrdiff_t stride,
128                         const uint8_t *left, const uint8_t *top);
129void ff_dc_127_32x32_lsx(uint8_t *dst, ptrdiff_t stride,
130                         const uint8_t *left, const uint8_t *top);
131void ff_dc_129_16x16_lsx(uint8_t *dst, ptrdiff_t stride,
132                         const uint8_t *left, const uint8_t *top);
133void ff_dc_129_32x32_lsx(uint8_t *dst, ptrdiff_t stride,
134                         const uint8_t *left, const uint8_t *top);
135void ff_tm_4x4_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
136                   const uint8_t *top);
137void ff_tm_8x8_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
138                   const uint8_t *top);
139void ff_tm_16x16_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
140                     const uint8_t *top);
141void ff_tm_32x32_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
142                     const uint8_t *top);
143void ff_loop_filter_h_16_8_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
144                               int32_t i, int32_t h);
145void ff_loop_filter_v_16_8_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
146                               int32_t i, int32_t h);
147void ff_loop_filter_h_4_8_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
148                              int32_t i, int32_t h);
149void ff_loop_filter_v_4_8_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
150                              int32_t i, int32_t h);
151void ff_loop_filter_h_44_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
152                                int32_t i, int32_t h);
153void ff_loop_filter_v_44_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
154                                int32_t i, int32_t h);
155void ff_loop_filter_h_8_8_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
156                              int32_t i, int32_t h);
157void ff_loop_filter_v_8_8_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
158                              int32_t i, int32_t h);
159void ff_loop_filter_h_88_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
160                                int32_t i, int32_t h);
161void ff_loop_filter_v_88_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
162                                int32_t i, int32_t h);
163void ff_loop_filter_h_84_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
164                                int32_t i, int32_t h);
165void ff_loop_filter_v_84_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
166                                int32_t i, int32_t h);
167void ff_loop_filter_h_48_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
168                                int32_t i, int32_t h);
169void ff_loop_filter_v_48_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
170                                int32_t i, int32_t h);
171void ff_loop_filter_h_16_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
172                                int32_t i, int32_t h);
173void ff_loop_filter_v_16_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
174                                int32_t i, int32_t h);
175void ff_idct_idct_8x8_add_lsx(uint8_t *dst, ptrdiff_t stride,
176                              int16_t *block, int eob);
177void ff_idct_idct_16x16_add_lsx(uint8_t *dst, ptrdiff_t stride,
178                                int16_t *block, int eob);
179void ff_idct_idct_32x32_add_lsx(uint8_t *dst, ptrdiff_t stride,
180                                int16_t *block, int eob);
181
182#endif /* AVCODEC_LOONGARCH_VP9DSP_LOONGARCH_H */
183