avcodec/mips: [loongson] mmi optimizations for VP9 put and avg functions
[ffmpeg.git] / libavcodec / mips / vp9dsp_mips.h
1 /*
2  * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com)
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20
21 #ifndef AVCODEC_MIPS_VP9DSP_MIPS_H
22 #define AVCODEC_MIPS_VP9DSP_MIPS_H
23
24 #define VP9_8TAP_MIPS_MSA_FUNC(SIZE, type, type_idx)                         \
25 void ff_put_8tap_##type##_##SIZE##h_msa(uint8_t *dst, ptrdiff_t dststride,   \
26                                         const uint8_t *src,                  \
27                                         ptrdiff_t srcstride,                 \
28                                         int h, int mx, int my);              \
29                                                                              \
30 void ff_put_8tap_##type##_##SIZE##v_msa(uint8_t *dst, ptrdiff_t dststride,   \
31                                         const uint8_t *src,                  \
32                                         ptrdiff_t srcstride,                 \
33                                         int h, int mx, int my);              \
34                                                                              \
35 void ff_put_8tap_##type##_##SIZE##hv_msa(uint8_t *dst, ptrdiff_t dststride,  \
36                                          const uint8_t *src,                 \
37                                          ptrdiff_t srcstride,                \
38                                          int h, int mx, int my);             \
39                                                                              \
40 void ff_avg_8tap_##type##_##SIZE##h_msa(uint8_t *dst, ptrdiff_t dststride,   \
41                                         const uint8_t *src,                  \
42                                         ptrdiff_t srcstride,                 \
43                                         int h, int mx, int my);              \
44                                                                              \
45 void ff_avg_8tap_##type##_##SIZE##v_msa(uint8_t *dst, ptrdiff_t dststride,   \
46                                         const uint8_t *src,                  \
47                                         ptrdiff_t srcstride,                 \
48                                         int h, int mx, int my);              \
49                                                                              \
50 void ff_avg_8tap_##type##_##SIZE##hv_msa(uint8_t *dst, ptrdiff_t dststride,  \
51                                          const uint8_t *src,                 \
52                                          ptrdiff_t srcstride,                \
53                                          int h, int mx, int my);
54
55 #define VP9_BILINEAR_MIPS_MSA_FUNC(SIZE)                                   \
56 void ff_put_bilin_##SIZE##h_msa(uint8_t *dst, ptrdiff_t dststride,         \
57                                 const uint8_t *src, ptrdiff_t srcstride,   \
58                                 int h, int mx, int my);                    \
59                                                                            \
60 void ff_put_bilin_##SIZE##v_msa(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_put_bilin_##SIZE##hv_msa(uint8_t *dst, ptrdiff_t dststride,        \
65                                  const uint8_t *src, ptrdiff_t srcstride,  \
66                                  int h, int mx, int my);                   \
67                                                                            \
68 void ff_avg_bilin_##SIZE##h_msa(uint8_t *dst, ptrdiff_t dststride,         \
69                                 const uint8_t *src, ptrdiff_t srcstride,   \
70                                 int h, int mx, int my);                    \
71                                                                            \
72 void ff_avg_bilin_##SIZE##v_msa(uint8_t *dst, ptrdiff_t dststride,         \
73                                 const uint8_t *src, ptrdiff_t srcstride,   \
74                                 int h, int mx, int my);                    \
75                                                                            \
76 void ff_avg_bilin_##SIZE##hv_msa(uint8_t *dst, ptrdiff_t dststride,        \
77                                  const uint8_t *src, ptrdiff_t srcstride,  \
78                                  int h, int mx, int my);
79
80 #define VP9_COPY_AVG_MIPS_MSA_FUNC(SIZE)                           \
81 void ff_copy##SIZE##_msa(uint8_t *dst, ptrdiff_t dststride,        \
82                          const uint8_t *src, ptrdiff_t srcstride,  \
83                          int h, int mx, int my);                   \
84                                                                    \
85 void ff_avg##SIZE##_msa(uint8_t *dst, ptrdiff_t dststride,         \
86                         const uint8_t *src, ptrdiff_t srcstride,   \
87                         int h, int mx, int my);
88
89 VP9_8TAP_MIPS_MSA_FUNC(64, regular, FILTER_8TAP_REGULAR);
90 VP9_8TAP_MIPS_MSA_FUNC(32, regular, FILTER_8TAP_REGULAR);
91 VP9_8TAP_MIPS_MSA_FUNC(16, regular, FILTER_8TAP_REGULAR);
92 VP9_8TAP_MIPS_MSA_FUNC(8, regular, FILTER_8TAP_REGULAR);
93 VP9_8TAP_MIPS_MSA_FUNC(4, regular, FILTER_8TAP_REGULAR);
94
95 VP9_8TAP_MIPS_MSA_FUNC(64, sharp, FILTER_8TAP_SHARP);
96 VP9_8TAP_MIPS_MSA_FUNC(32, sharp, FILTER_8TAP_SHARP);
97 VP9_8TAP_MIPS_MSA_FUNC(16, sharp, FILTER_8TAP_SHARP);
98 VP9_8TAP_MIPS_MSA_FUNC(8, sharp, FILTER_8TAP_SHARP);
99 VP9_8TAP_MIPS_MSA_FUNC(4, sharp, FILTER_8TAP_SHARP);
100
101 VP9_8TAP_MIPS_MSA_FUNC(64, smooth, FILTER_8TAP_SMOOTH);
102 VP9_8TAP_MIPS_MSA_FUNC(32, smooth, FILTER_8TAP_SMOOTH);
103 VP9_8TAP_MIPS_MSA_FUNC(16, smooth, FILTER_8TAP_SMOOTH);
104 VP9_8TAP_MIPS_MSA_FUNC(8, smooth, FILTER_8TAP_SMOOTH);
105 VP9_8TAP_MIPS_MSA_FUNC(4, smooth, FILTER_8TAP_SMOOTH);
106
107 VP9_BILINEAR_MIPS_MSA_FUNC(64);
108 VP9_BILINEAR_MIPS_MSA_FUNC(32);
109 VP9_BILINEAR_MIPS_MSA_FUNC(16);
110 VP9_BILINEAR_MIPS_MSA_FUNC(8);
111 VP9_BILINEAR_MIPS_MSA_FUNC(4);
112
113 VP9_COPY_AVG_MIPS_MSA_FUNC(64);
114 VP9_COPY_AVG_MIPS_MSA_FUNC(32);
115 VP9_COPY_AVG_MIPS_MSA_FUNC(16);
116 VP9_COPY_AVG_MIPS_MSA_FUNC(8);
117 VP9_COPY_AVG_MIPS_MSA_FUNC(4);
118
119 #undef VP9_8TAP_MIPS_MSA_FUNC
120 #undef VP9_BILINEAR_MIPS_MSA_FUNC
121 #undef VP9_COPY_AVG_MIPS_MSA_FUNC
122
123 void ff_loop_filter_h_4_8_msa(uint8_t *dst, ptrdiff_t stride, int32_t e,
124                               int32_t i, int32_t h);
125 void ff_loop_filter_h_8_8_msa(uint8_t *dst, ptrdiff_t stride, int32_t e,
126                               int32_t i, int32_t h);
127 void ff_loop_filter_h_16_8_msa(uint8_t *dst, ptrdiff_t stride, int32_t e,
128                                int32_t i, int32_t h);
129 void ff_loop_filter_v_4_8_msa(uint8_t *dst, ptrdiff_t stride, int32_t e,
130                               int32_t i, int32_t h);
131 void ff_loop_filter_v_8_8_msa(uint8_t *dst, ptrdiff_t stride, int32_t e,
132                               int32_t i, int32_t h);
133 void ff_loop_filter_v_16_8_msa(uint8_t *dst, ptrdiff_t stride, int32_t e,
134                                int32_t i, int32_t h);
135 void ff_loop_filter_h_44_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e,
136                                 int32_t i, int32_t h);
137 void ff_loop_filter_h_88_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e,
138                                 int32_t i, int32_t h);
139 void ff_loop_filter_h_16_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e,
140                                 int32_t i, int32_t h);
141 void ff_loop_filter_v_44_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e,
142                                 int32_t i, int32_t h);
143 void ff_loop_filter_v_88_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e,
144                                 int32_t i, int32_t h);
145 void ff_loop_filter_v_16_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e,
146                                 int32_t i, int32_t h);
147 void ff_loop_filter_h_48_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e,
148                                 int32_t i, int32_t h);
149 void ff_loop_filter_h_84_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e,
150                                 int32_t i, int32_t h);
151 void ff_loop_filter_v_48_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e,
152                                 int32_t i, int32_t h);
153 void ff_loop_filter_v_84_16_msa(uint8_t *dst, ptrdiff_t stride, int32_t e,
154                                 int32_t i, int32_t h);
155 void ff_idct_idct_4x4_add_msa(uint8_t *dst, ptrdiff_t stride,
156                               int16_t *block, int eob);
157 void ff_idct_idct_8x8_add_msa(uint8_t *dst, ptrdiff_t stride,
158                               int16_t *block, int eob);
159 void ff_idct_idct_16x16_add_msa(uint8_t *dst, ptrdiff_t stride,
160                                 int16_t *block, int eob);
161 void ff_idct_idct_32x32_add_msa(uint8_t *dst, ptrdiff_t stride,
162                                 int16_t *block, int eob);
163 void ff_iadst_iadst_4x4_add_msa(uint8_t *dst, ptrdiff_t stride,
164                                 int16_t *block, int eob);
165 void ff_iadst_iadst_8x8_add_msa(uint8_t *dst, ptrdiff_t stride,
166                                 int16_t *block, int eob);
167 void ff_iadst_iadst_16x16_add_msa(uint8_t *dst, ptrdiff_t stride,
168                                   int16_t *block, int eob);
169 void ff_iadst_idct_4x4_add_msa(uint8_t *dst, ptrdiff_t stride,
170                                int16_t *block, int eob);
171 void ff_iadst_idct_8x8_add_msa(uint8_t *dst, ptrdiff_t stride,
172                                int16_t *block, int eob);
173 void ff_iadst_idct_16x16_add_msa(uint8_t *dst, ptrdiff_t stride,
174                                  int16_t *block, int eob);
175 void ff_idct_iadst_4x4_add_msa(uint8_t *pu8Dest, ptrdiff_t stride,
176                                int16_t *block, int eob);
177 void ff_idct_iadst_8x8_add_msa(uint8_t *pu8Dest, ptrdiff_t stride,
178                                int16_t *block, int eob);
179 void ff_idct_iadst_16x16_add_msa(uint8_t *pu8Dest, ptrdiff_t stride,
180                                  int16_t *block, int eob);
181 void ff_iwht_iwht_4x4_add_msa(uint8_t *dst, ptrdiff_t stride,
182                               int16_t *block, int eob);
183
184 void ff_vert_16x16_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
185                        const uint8_t *top);
186 void ff_vert_32x32_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
187                        const uint8_t *top);
188 void ff_hor_16x16_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
189                       const uint8_t *top);
190 void ff_hor_32x32_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
191                       const uint8_t *top);
192 void ff_dc_4x4_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
193                    const uint8_t *top);
194 void ff_dc_8x8_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
195                    const uint8_t *top);
196 void ff_dc_16x16_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
197                      const uint8_t *top);
198 void ff_dc_32x32_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
199                      const uint8_t *top);
200 void ff_dc_left_4x4_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
201                         const uint8_t *top);
202 void ff_dc_left_8x8_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
203                         const uint8_t *top);
204 void ff_dc_left_16x16_msa(uint8_t *dst, ptrdiff_t stride,
205                           const uint8_t *left, const uint8_t *top);
206 void ff_dc_left_32x32_msa(uint8_t *dst, ptrdiff_t stride,
207                           const uint8_t *left, const uint8_t *top);
208 void ff_dc_top_4x4_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
209                        const uint8_t *top);
210 void ff_dc_top_8x8_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
211                        const uint8_t *top);
212 void ff_dc_top_16x16_msa(uint8_t *dst, ptrdiff_t stride,
213                          const uint8_t *left, const uint8_t *top);
214 void ff_dc_top_32x32_msa(uint8_t *dst, ptrdiff_t stride,
215                          const uint8_t *left, const uint8_t *top);
216 void ff_dc_128_16x16_msa(uint8_t *dst, ptrdiff_t stride,
217                          const uint8_t *left, const uint8_t *top);
218 void ff_dc_128_32x32_msa(uint8_t *dst, ptrdiff_t stride,
219                          const uint8_t *left, const uint8_t *top);
220 void ff_dc_127_16x16_msa(uint8_t *dst, ptrdiff_t stride,
221                          const uint8_t *left, const uint8_t *top);
222 void ff_dc_127_32x32_msa(uint8_t *dst, ptrdiff_t stride,
223                          const uint8_t *left, const uint8_t *top);
224 void ff_dc_129_16x16_msa(uint8_t *dst, ptrdiff_t stride,
225                          const uint8_t *left, const uint8_t *top);
226 void ff_dc_129_32x32_msa(uint8_t *dst, ptrdiff_t stride,
227                          const uint8_t *left, const uint8_t *top);
228 void ff_tm_4x4_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
229                    const uint8_t *top);
230 void ff_tm_8x8_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
231                    const uint8_t *top);
232 void ff_tm_16x16_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
233                      const uint8_t *top);
234 void ff_tm_32x32_msa(uint8_t *dst, ptrdiff_t stride, const uint8_t *left,
235                      const uint8_t *top);
236
237 #define VP9_8TAP_MIPS_MMI_FUNC(SIZE, type, type_idx)                         \
238 void ff_put_8tap_##type##_##SIZE##h_mmi(uint8_t *dst, ptrdiff_t dststride,   \
239                                         const uint8_t *src,                  \
240                                         ptrdiff_t srcstride,                 \
241                                         int h, int mx, int my);              \
242                                                                              \
243 void ff_put_8tap_##type##_##SIZE##v_mmi(uint8_t *dst, ptrdiff_t dststride,   \
244                                         const uint8_t *src,                  \
245                                         ptrdiff_t srcstride,                 \
246                                         int h, int mx, int my);              \
247                                                                              \
248 void ff_put_8tap_##type##_##SIZE##hv_mmi(uint8_t *dst, ptrdiff_t dststride,  \
249                                          const uint8_t *src,                 \
250                                          ptrdiff_t srcstride,                \
251                                          int h, int mx, int my);             \
252                                                                              \
253 void ff_avg_8tap_##type##_##SIZE##h_mmi(uint8_t *dst, ptrdiff_t dststride,   \
254                                         const uint8_t *src,                  \
255                                         ptrdiff_t srcstride,                 \
256                                         int h, int mx, int my);              \
257                                                                              \
258 void ff_avg_8tap_##type##_##SIZE##v_mmi(uint8_t *dst, ptrdiff_t dststride,   \
259                                         const uint8_t *src,                  \
260                                         ptrdiff_t srcstride,                 \
261                                         int h, int mx, int my);              \
262                                                                              \
263 void ff_avg_8tap_##type##_##SIZE##hv_mmi(uint8_t *dst, ptrdiff_t dststride,  \
264                                          const uint8_t *src,                 \
265                                          ptrdiff_t srcstride,                \
266                                          int h, int mx, int my);
267
268 VP9_8TAP_MIPS_MMI_FUNC(64, regular, FILTER_8TAP_REGULAR);
269 VP9_8TAP_MIPS_MMI_FUNC(32, regular, FILTER_8TAP_REGULAR);
270 VP9_8TAP_MIPS_MMI_FUNC(16, regular, FILTER_8TAP_REGULAR);
271 VP9_8TAP_MIPS_MMI_FUNC(8, regular, FILTER_8TAP_REGULAR);
272 VP9_8TAP_MIPS_MMI_FUNC(4, regular, FILTER_8TAP_REGULAR);
273
274 VP9_8TAP_MIPS_MMI_FUNC(64, sharp, FILTER_8TAP_SHARP);
275 VP9_8TAP_MIPS_MMI_FUNC(32, sharp, FILTER_8TAP_SHARP);
276 VP9_8TAP_MIPS_MMI_FUNC(16, sharp, FILTER_8TAP_SHARP);
277 VP9_8TAP_MIPS_MMI_FUNC(8, sharp, FILTER_8TAP_SHARP);
278 VP9_8TAP_MIPS_MMI_FUNC(4, sharp, FILTER_8TAP_SHARP);
279
280 VP9_8TAP_MIPS_MMI_FUNC(64, smooth, FILTER_8TAP_SMOOTH);
281 VP9_8TAP_MIPS_MMI_FUNC(32, smooth, FILTER_8TAP_SMOOTH);
282 VP9_8TAP_MIPS_MMI_FUNC(16, smooth, FILTER_8TAP_SMOOTH);
283 VP9_8TAP_MIPS_MMI_FUNC(8, smooth, FILTER_8TAP_SMOOTH);
284 VP9_8TAP_MIPS_MMI_FUNC(4, smooth, FILTER_8TAP_SMOOTH);
285 #undef VP9_8TAP_MIPS_MMI_FUNC
286
287 #endif  // #ifndef AVCODEC_MIPS_VP9DSP_MIPS_H