Imported Upstream version 6.1
[platform/upstream/ffmpeg.git] / libavcodec / loongarch / vp9dsp_loongarch.h
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 #include <stddef.h>
26 #include <stdint.h>
27
28 #define VP9_8TAP_LOONGARCH_LSX_FUNC(SIZE, type, type_idx)                    \
29 void ff_put_8tap_##type##_##SIZE##h_lsx(uint8_t *dst, ptrdiff_t dststride,   \
30                                         const uint8_t *src,                  \
31                                         ptrdiff_t srcstride,                 \
32                                         int h, int mx, int my);              \
33                                                                              \
34 void ff_put_8tap_##type##_##SIZE##v_lsx(uint8_t *dst, ptrdiff_t dststride,   \
35                                         const uint8_t *src,                  \
36                                         ptrdiff_t srcstride,                 \
37                                         int h, int mx, int my);              \
38                                                                              \
39 void ff_put_8tap_##type##_##SIZE##hv_lsx(uint8_t *dst, ptrdiff_t dststride,  \
40                                          const uint8_t *src,                 \
41                                          ptrdiff_t srcstride,                \
42                                          int h, int mx, int my);             \
43                                                                              \
44 void ff_avg_8tap_##type##_##SIZE##h_lsx(uint8_t *dst, ptrdiff_t dststride,   \
45                                         const uint8_t *src,                  \
46                                         ptrdiff_t srcstride,                 \
47                                         int h, int mx, int my);              \
48                                                                              \
49 void ff_avg_8tap_##type##_##SIZE##v_lsx(uint8_t *dst, ptrdiff_t dststride,   \
50                                         const uint8_t *src,                  \
51                                         ptrdiff_t srcstride,                 \
52                                         int h, int mx, int my);              \
53                                                                              \
54 void ff_avg_8tap_##type##_##SIZE##hv_lsx(uint8_t *dst, ptrdiff_t dststride,  \
55                                          const uint8_t *src,                 \
56                                          ptrdiff_t srcstride,                \
57                                          int h, int mx, int my);
58
59 #define VP9_COPY_LOONGARCH_LSX_FUNC(SIZE)                          \
60 void ff_copy##SIZE##_lsx(uint8_t *dst, ptrdiff_t dststride,        \
61                          const uint8_t *src, ptrdiff_t srcstride,  \
62                          int h, int mx, int my);                   \
63                                                                    \
64 void ff_avg##SIZE##_lsx(uint8_t *dst, ptrdiff_t dststride,         \
65                         const uint8_t *src, ptrdiff_t srcstride,   \
66                         int h, int mx, int my);
67
68 VP9_8TAP_LOONGARCH_LSX_FUNC(64, regular, FILTER_8TAP_REGULAR);
69 VP9_8TAP_LOONGARCH_LSX_FUNC(32, regular, FILTER_8TAP_REGULAR);
70 VP9_8TAP_LOONGARCH_LSX_FUNC(16, regular, FILTER_8TAP_REGULAR);
71 VP9_8TAP_LOONGARCH_LSX_FUNC(8, regular, FILTER_8TAP_REGULAR);
72 VP9_8TAP_LOONGARCH_LSX_FUNC(4, regular, FILTER_8TAP_REGULAR);
73
74 VP9_8TAP_LOONGARCH_LSX_FUNC(64, sharp, FILTER_8TAP_SHARP);
75 VP9_8TAP_LOONGARCH_LSX_FUNC(32, sharp, FILTER_8TAP_SHARP);
76 VP9_8TAP_LOONGARCH_LSX_FUNC(16, sharp, FILTER_8TAP_SHARP);
77 VP9_8TAP_LOONGARCH_LSX_FUNC(8, sharp, FILTER_8TAP_SHARP);
78 VP9_8TAP_LOONGARCH_LSX_FUNC(4, sharp, FILTER_8TAP_SHARP);
79
80 VP9_8TAP_LOONGARCH_LSX_FUNC(64, smooth, FILTER_8TAP_SMOOTH);
81 VP9_8TAP_LOONGARCH_LSX_FUNC(32, smooth, FILTER_8TAP_SMOOTH);
82 VP9_8TAP_LOONGARCH_LSX_FUNC(16, smooth, FILTER_8TAP_SMOOTH);
83 VP9_8TAP_LOONGARCH_LSX_FUNC(8, smooth, FILTER_8TAP_SMOOTH);
84 VP9_8TAP_LOONGARCH_LSX_FUNC(4, smooth, FILTER_8TAP_SMOOTH);
85
86 VP9_COPY_LOONGARCH_LSX_FUNC(64);
87 VP9_COPY_LOONGARCH_LSX_FUNC(32);
88 VP9_COPY_LOONGARCH_LSX_FUNC(16);
89 VP9_COPY_LOONGARCH_LSX_FUNC(8);
90
91 #undef VP9_8TAP_LOONGARCH_LSX_FUNC
92 #undef VP9_COPY_LOONGARCH_LSX_FUNC
93
94 void ff_vert_16x16_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
95                        const uint8_t *top);
96 void ff_vert_32x32_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
97                        const uint8_t *top);
98 void ff_hor_16x16_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
99                       const uint8_t *top);
100 void ff_hor_32x32_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
101                       const uint8_t *top);
102 void ff_dc_4x4_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
103                    const uint8_t *top);
104 void ff_dc_8x8_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
105                    const uint8_t *top);
106 void ff_dc_16x16_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
107                      const uint8_t *top);
108 void ff_dc_32x32_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
109                      const uint8_t *top);
110 void ff_dc_left_4x4_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
111                         const uint8_t *top);
112 void ff_dc_left_8x8_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
113                         const uint8_t *top);
114 void ff_dc_left_16x16_lsx(uint8_t *dst, ptrdiff_t stride,
115                           const uint8_t *left, const uint8_t *top);
116 void ff_dc_left_32x32_lsx(uint8_t *dst, ptrdiff_t stride,
117                           const uint8_t *left, const uint8_t *top);
118 void ff_dc_top_4x4_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
119                        const uint8_t *top);
120 void ff_dc_top_8x8_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
121                        const uint8_t *top);
122 void ff_dc_top_16x16_lsx(uint8_t *dst, ptrdiff_t stride,
123                          const uint8_t *left, const uint8_t *top);
124 void ff_dc_top_32x32_lsx(uint8_t *dst, ptrdiff_t stride,
125                          const uint8_t *left, const uint8_t *top);
126 void ff_dc_128_16x16_lsx(uint8_t *dst, ptrdiff_t stride,
127                          const uint8_t *left, const uint8_t *top);
128 void ff_dc_128_32x32_lsx(uint8_t *dst, ptrdiff_t stride,
129                          const uint8_t *left, const uint8_t *top);
130 void ff_dc_127_16x16_lsx(uint8_t *dst, ptrdiff_t stride,
131                          const uint8_t *left, const uint8_t *top);
132 void ff_dc_127_32x32_lsx(uint8_t *dst, ptrdiff_t stride,
133                          const uint8_t *left, const uint8_t *top);
134 void ff_dc_129_16x16_lsx(uint8_t *dst, ptrdiff_t stride,
135                          const uint8_t *left, const uint8_t *top);
136 void ff_dc_129_32x32_lsx(uint8_t *dst, ptrdiff_t stride,
137                          const uint8_t *left, const uint8_t *top);
138 void ff_tm_4x4_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
139                    const uint8_t *top);
140 void ff_tm_8x8_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
141                    const uint8_t *top);
142 void ff_tm_16x16_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
143                      const uint8_t *top);
144 void ff_tm_32x32_lsx(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
145                      const uint8_t *top);
146 void ff_loop_filter_h_16_8_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
147                                int32_t i, int32_t h);
148 void ff_loop_filter_v_16_8_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
149                                int32_t i, int32_t h);
150 void ff_loop_filter_h_4_8_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
151                               int32_t i, int32_t h);
152 void ff_loop_filter_v_4_8_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
153                               int32_t i, int32_t h);
154 void ff_loop_filter_h_44_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
155                                 int32_t i, int32_t h);
156 void ff_loop_filter_v_44_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
157                                 int32_t i, int32_t h);
158 void ff_loop_filter_h_8_8_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
159                               int32_t i, int32_t h);
160 void ff_loop_filter_v_8_8_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
161                               int32_t i, int32_t h);
162 void ff_loop_filter_h_88_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
163                                 int32_t i, int32_t h);
164 void ff_loop_filter_v_88_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
165                                 int32_t i, int32_t h);
166 void ff_loop_filter_h_84_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
167                                 int32_t i, int32_t h);
168 void ff_loop_filter_v_84_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
169                                 int32_t i, int32_t h);
170 void ff_loop_filter_h_48_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
171                                 int32_t i, int32_t h);
172 void ff_loop_filter_v_48_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
173                                 int32_t i, int32_t h);
174 void ff_loop_filter_h_16_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
175                                 int32_t i, int32_t h);
176 void ff_loop_filter_v_16_16_lsx(uint8_t *dst, ptrdiff_t stride, int32_t e,
177                                 int32_t i, int32_t h);
178 void ff_idct_idct_8x8_add_lsx(uint8_t *dst, ptrdiff_t stride,
179                               int16_t *block, int eob);
180 void ff_idct_idct_16x16_add_lsx(uint8_t *dst, ptrdiff_t stride,
181                                 int16_t *block, int eob);
182 void ff_idct_idct_32x32_add_lsx(uint8_t *dst, ptrdiff_t stride,
183                                 int16_t *block, int eob);
184
185 #endif /* AVCODEC_LOONGARCH_VP9DSP_LOONGARCH_H */