FFmpeg
hevcdsp_lsx.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 Loongson Technology Corporation Limited
3  * Contributed by Lu Wang <wanglu@loongson.cn>
4  * Hao Chen <chenhao@loongson.cn>
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #ifndef AVCODEC_LOONGARCH_HEVCDSP_LSX_H
24 #define AVCODEC_LOONGARCH_HEVCDSP_LSX_H
25 
26 #include "libavcodec/hevcdsp.h"
27 
28 #define MC(PEL, DIR, WIDTH) \
29 void ff_hevc_put_hevc_##PEL##_##DIR##WIDTH##_8_lsx(int16_t *dst, \
30  const uint8_t *src, \
31  ptrdiff_t src_stride, \
32  int height, \
33  intptr_t mx, \
34  intptr_t my, \
35  int width)
36 
37 MC(pel, pixels, 4);
38 MC(pel, pixels, 6);
39 MC(pel, pixels, 8);
40 MC(pel, pixels, 12);
41 MC(pel, pixels, 16);
42 MC(pel, pixels, 24);
43 MC(pel, pixels, 32);
44 MC(pel, pixels, 48);
45 MC(pel, pixels, 64);
46 
47 MC(qpel, h, 4);
48 MC(qpel, h, 8);
49 MC(qpel, h, 12);
50 MC(qpel, h, 16);
51 MC(qpel, h, 24);
52 MC(qpel, h, 32);
53 MC(qpel, h, 48);
54 MC(qpel, h, 64);
55 
56 MC(qpel, v, 4);
57 MC(qpel, v, 8);
58 MC(qpel, v, 12);
59 MC(qpel, v, 16);
60 MC(qpel, v, 24);
61 MC(qpel, v, 32);
62 MC(qpel, v, 48);
63 MC(qpel, v, 64);
64 
65 MC(qpel, hv, 4);
66 MC(qpel, hv, 8);
67 MC(qpel, hv, 12);
68 MC(qpel, hv, 16);
69 MC(qpel, hv, 24);
70 MC(qpel, hv, 32);
71 MC(qpel, hv, 48);
72 MC(qpel, hv, 64);
73 
74 MC(epel, h, 32);
75 
76 MC(epel, v, 16);
77 MC(epel, v, 24);
78 MC(epel, v, 32);
79 
80 MC(epel, hv, 8);
81 MC(epel, hv, 12);
82 MC(epel, hv, 16);
83 MC(epel, hv, 24);
84 MC(epel, hv, 32);
85 
86 #undef MC
87 
88 #define BI_MC(PEL, DIR, WIDTH) \
89 void ff_hevc_put_hevc_bi_##PEL##_##DIR##WIDTH##_8_lsx(uint8_t *dst, \
90  ptrdiff_t dst_stride, \
91  const uint8_t *src, \
92  ptrdiff_t src_stride, \
93  const int16_t *src_16bit, \
94  int height, \
95  intptr_t mx, \
96  intptr_t my, \
97  int width)
98 
99 BI_MC(pel, pixels, 4);
100 BI_MC(pel, pixels, 6);
101 BI_MC(pel, pixels, 8);
102 BI_MC(pel, pixels, 12);
103 BI_MC(pel, pixels, 16);
104 BI_MC(pel, pixels, 24);
105 BI_MC(pel, pixels, 32);
106 BI_MC(pel, pixels, 48);
107 BI_MC(pel, pixels, 64);
108 
109 BI_MC(qpel, h, 16);
110 BI_MC(qpel, h, 24);
111 BI_MC(qpel, h, 32);
112 BI_MC(qpel, h, 48);
113 BI_MC(qpel, h, 64);
114 
115 BI_MC(qpel, v, 8);
116 BI_MC(qpel, v, 16);
117 BI_MC(qpel, v, 24);
118 BI_MC(qpel, v, 32);
119 BI_MC(qpel, v, 48);
120 BI_MC(qpel, v, 64);
121 
122 BI_MC(qpel, hv, 8);
123 BI_MC(qpel, hv, 16);
124 BI_MC(qpel, hv, 24);
125 BI_MC(qpel, hv, 32);
126 BI_MC(qpel, hv, 48);
127 BI_MC(qpel, hv, 64);
128 
129 BI_MC(epel, h, 4);
130 BI_MC(epel, h, 6);
131 BI_MC(epel, h, 8);
132 BI_MC(epel, h, 12);
133 BI_MC(epel, h, 16);
134 BI_MC(epel, h, 24);
135 BI_MC(epel, h, 32);
136 BI_MC(epel, h, 48);
137 BI_MC(epel, h, 64);
138 
139 BI_MC(epel, v, 12);
140 BI_MC(epel, v, 16);
141 BI_MC(epel, v, 24);
142 BI_MC(epel, v, 32);
143 
144 BI_MC(epel, hv, 6);
145 BI_MC(epel, hv, 8);
146 BI_MC(epel, hv, 16);
147 BI_MC(epel, hv, 24);
148 BI_MC(epel, hv, 32);
149 
150 #undef BI_MC
151 
152 #define UNI_MC(PEL, DIR, WIDTH) \
153 void ff_hevc_put_hevc_uni_##PEL##_##DIR##WIDTH##_8_lsx(uint8_t *dst, \
154  ptrdiff_t dst_stride, \
155  const uint8_t *src, \
156  ptrdiff_t src_stride, \
157  int height, \
158  intptr_t mx, \
159  intptr_t my, \
160  int width)
161 UNI_MC(qpel, h, 4);
162 UNI_MC(qpel, h, 6);
163 UNI_MC(qpel, h, 8);
164 UNI_MC(qpel, h, 12);
165 UNI_MC(qpel, h, 16);
166 UNI_MC(qpel, h, 24);
167 UNI_MC(qpel, h, 32);
168 UNI_MC(qpel, h, 48);
169 UNI_MC(qpel, h, 64);
170 
171 UNI_MC(qpel, v, 24);
172 UNI_MC(qpel, v, 32);
173 UNI_MC(qpel, v, 48);
174 UNI_MC(qpel, v, 64);
175 
176 UNI_MC(qpel, hv, 8);
177 UNI_MC(qpel, hv, 16);
178 UNI_MC(qpel, hv, 24);
179 UNI_MC(qpel, hv, 32);
180 UNI_MC(qpel, hv, 48);
181 UNI_MC(qpel, hv, 64);
182 
183 UNI_MC(epel, v, 24);
184 UNI_MC(epel, v, 32);
185 
186 UNI_MC(epel, hv, 8);
187 UNI_MC(epel, hv, 12);
188 UNI_MC(epel, hv, 16);
189 UNI_MC(epel, hv, 24);
190 UNI_MC(epel, hv, 32);
191 
192 #undef UNI_MC
193 
194 #define UNI_W_MC(PEL, DIR, WIDTH) \
195 void ff_hevc_put_hevc_uni_w_##PEL##_##DIR##WIDTH##_8_lsx(uint8_t *dst, \
196  ptrdiff_t \
197  dst_stride, \
198  const uint8_t *src, \
199  ptrdiff_t \
200  src_stride, \
201  int height, \
202  int denom, \
203  int weight, \
204  int offset, \
205  intptr_t mx, \
206  intptr_t my, \
207  int width)
208 
209 UNI_W_MC(qpel, hv, 8);
210 UNI_W_MC(qpel, hv, 16);
211 UNI_W_MC(qpel, hv, 24);
212 UNI_W_MC(qpel, hv, 32);
213 UNI_W_MC(qpel, hv, 48);
214 UNI_W_MC(qpel, hv, 64);
215 
216 #undef UNI_W_MC
217 
218 void ff_hevc_loop_filter_luma_h_8_lsx(uint8_t *src, ptrdiff_t stride,
219  int32_t beta, const int32_t *tc,
220  const uint8_t *p_is_pcm, const uint8_t *q_is_pcm);
221 
222 void ff_hevc_loop_filter_luma_v_8_lsx(uint8_t *src, ptrdiff_t stride,
223  int32_t beta, const int32_t *tc,
224  const uint8_t *p_is_pcm, const uint8_t *q_is_pcm);
225 
226 void ff_hevc_loop_filter_chroma_h_8_lsx(uint8_t *src, ptrdiff_t stride,
227  const int32_t *tc, const uint8_t *p_is_pcm,
228  const uint8_t *q_is_pcm);
229 
230 void ff_hevc_loop_filter_chroma_v_8_lsx(uint8_t *src, ptrdiff_t stride,
231  const int32_t *tc, const uint8_t *p_is_pcm,
232  const uint8_t *q_is_pcm);
233 
234 void ff_hevc_sao_edge_filter_8_lsx(uint8_t *dst, const uint8_t *src,
235  ptrdiff_t stride_dst,
236  const int16_t *sao_offset_val,
237  int eo, int width, int height);
238 
239 void ff_hevc_idct_4x4_lsx(int16_t *coeffs, int col_limit);
240 void ff_hevc_idct_8x8_lsx(int16_t *coeffs, int col_limit);
241 void ff_hevc_idct_16x16_lsx(int16_t *coeffs, int col_limit);
242 void ff_hevc_idct_32x32_lsx(int16_t *coeffs, int col_limit);
243 
244 void ff_hevc_add_residual4x4_8_lsx(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
245 void ff_hevc_add_residual8x8_8_lsx(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
246 void ff_hevc_add_residual16x16_8_lsx(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
247 void ff_hevc_add_residual32x32_8_lsx(uint8_t *dst, const int16_t *res, ptrdiff_t stride);
248 
249 #define PEL_UNI_W(PEL, DIR, WIDTH) \
250 void ff_hevc_put_hevc_##PEL##_uni_w_##DIR##WIDTH##_8_lsx(uint8_t *dst, \
251  ptrdiff_t \
252  dst_stride, \
253  const uint8_t *src, \
254  ptrdiff_t \
255  src_stride, \
256  int height, \
257  int denom, \
258  int wx, \
259  int ox, \
260  intptr_t mx, \
261  intptr_t my, \
262  int width)
263 
264 PEL_UNI_W(pel, pixels, 4);
265 PEL_UNI_W(pel, pixels, 6);
266 PEL_UNI_W(pel, pixels, 8);
267 PEL_UNI_W(pel, pixels, 12);
268 PEL_UNI_W(pel, pixels, 16);
269 PEL_UNI_W(pel, pixels, 24);
270 PEL_UNI_W(pel, pixels, 32);
271 PEL_UNI_W(pel, pixels, 48);
272 PEL_UNI_W(pel, pixels, 64);
273 
274 PEL_UNI_W(qpel, v, 4);
275 PEL_UNI_W(qpel, v, 6);
276 PEL_UNI_W(qpel, v, 8);
277 PEL_UNI_W(qpel, v, 12);
278 PEL_UNI_W(qpel, v, 16);
279 PEL_UNI_W(qpel, v, 24);
280 PEL_UNI_W(qpel, v, 32);
281 PEL_UNI_W(qpel, v, 48);
282 PEL_UNI_W(qpel, v, 64);
283 
284 PEL_UNI_W(qpel, h, 4);
285 PEL_UNI_W(qpel, h, 6);
286 PEL_UNI_W(qpel, h, 8);
287 PEL_UNI_W(qpel, h, 12);
288 PEL_UNI_W(qpel, h, 16);
289 PEL_UNI_W(qpel, h, 24);
290 PEL_UNI_W(qpel, h, 32);
291 PEL_UNI_W(qpel, h, 48);
292 PEL_UNI_W(qpel, h, 64);
293 
294 PEL_UNI_W(epel, hv, 4);
295 PEL_UNI_W(epel, hv, 6);
296 PEL_UNI_W(epel, hv, 8);
297 PEL_UNI_W(epel, hv, 12);
298 PEL_UNI_W(epel, hv, 16);
299 PEL_UNI_W(epel, hv, 24);
300 PEL_UNI_W(epel, hv, 32);
301 PEL_UNI_W(epel, hv, 48);
302 PEL_UNI_W(epel, hv, 64);
303 
304 PEL_UNI_W(epel, h, 4);
305 PEL_UNI_W(epel, h, 6);
306 PEL_UNI_W(epel, h, 8);
307 PEL_UNI_W(epel, h, 12);
308 PEL_UNI_W(epel, h, 16);
309 PEL_UNI_W(epel, h, 24);
310 PEL_UNI_W(epel, h, 32);
311 PEL_UNI_W(epel, h, 48);
312 PEL_UNI_W(epel, h, 64);
313 
314 PEL_UNI_W(epel, v, 4);
315 PEL_UNI_W(epel, v, 6);
316 PEL_UNI_W(epel, v, 8);
317 PEL_UNI_W(epel, v, 12);
318 PEL_UNI_W(epel, v, 16);
319 PEL_UNI_W(epel, v, 24);
320 PEL_UNI_W(epel, v, 32);
321 PEL_UNI_W(epel, v, 48);
322 PEL_UNI_W(epel, v, 64);
323 
324 #undef PEL_UNI_W
325 
326 #endif // #ifndef AVCODEC_LOONGARCH_HEVCDSP_LSX_H
ff_hevc_loop_filter_chroma_v_8_lsx
void ff_hevc_loop_filter_chroma_v_8_lsx(uint8_t *src, ptrdiff_t stride, const int32_t *tc, const uint8_t *p_is_pcm, const uint8_t *q_is_pcm)
Definition: hevc_lpf_sao_lsx.c:917
ff_hevc_idct_8x8_lsx
void ff_hevc_idct_8x8_lsx(int16_t *coeffs, int col_limit)
Definition: hevc_idct_lsx.c:360
ff_hevc_sao_edge_filter_8_lsx
void ff_hevc_sao_edge_filter_8_lsx(uint8_t *dst, const uint8_t *src, ptrdiff_t stride_dst, const int16_t *sao_offset_val, int eo, int width, int height)
Definition: hevc_lpf_sao_lsx.c:2367
ff_hevc_idct_16x16_lsx
void ff_hevc_idct_16x16_lsx(int16_t *coeffs, int col_limit)
Definition: hevc_idct_lsx.c:386
MC
#define MC(PEL, DIR, WIDTH)
Definition: hevcdsp_lsx.h:28
ff_hevc_add_residual8x8_8_lsx
void ff_hevc_add_residual8x8_8_lsx(uint8_t *dst, const int16_t *res, ptrdiff_t stride)
width
#define width
ff_hevc_add_residual32x32_8_lsx
void ff_hevc_add_residual32x32_8_lsx(uint8_t *dst, const int16_t *res, ptrdiff_t stride)
ff_hevc_add_residual16x16_8_lsx
void ff_hevc_add_residual16x16_8_lsx(uint8_t *dst, const int16_t *res, ptrdiff_t stride)
hevcdsp.h
PEL_UNI_W
#define PEL_UNI_W(PEL, DIR, WIDTH)
Definition: hevcdsp_lsx.h:249
height
#define height
BI_MC
#define BI_MC(PEL, DIR, WIDTH)
Definition: hevcdsp_lsx.h:88
stride
#define stride
Definition: h264pred_template.c:537
ff_hevc_loop_filter_chroma_h_8_lsx
void ff_hevc_loop_filter_chroma_h_8_lsx(uint8_t *src, ptrdiff_t stride, const int32_t *tc, const uint8_t *p_is_pcm, const uint8_t *q_is_pcm)
Definition: hevc_lpf_sao_lsx.c:863
ff_hevc_loop_filter_luma_h_8_lsx
void ff_hevc_loop_filter_luma_h_8_lsx(uint8_t *src, ptrdiff_t stride, int32_t beta, const int32_t *tc, const uint8_t *p_is_pcm, const uint8_t *q_is_pcm)
Definition: hevc_lpf_sao_lsx.c:26
ff_hevc_idct_32x32_lsx
void ff_hevc_idct_32x32_lsx(int16_t *coeffs, int col_limit)
Definition: hevc_idct_lsx.c:811
ff_hevc_idct_4x4_lsx
void ff_hevc_idct_4x4_lsx(int16_t *coeffs, int col_limit)
Definition: hevc_idct_lsx.c:330
tc
#define tc
Definition: regdef.h:69
ff_hevc_loop_filter_luma_v_8_lsx
void ff_hevc_loop_filter_luma_v_8_lsx(uint8_t *src, ptrdiff_t stride, int32_t beta, const int32_t *tc, const uint8_t *p_is_pcm, const uint8_t *q_is_pcm)
Definition: hevc_lpf_sao_lsx.c:438
UNI_MC
#define UNI_MC(PEL, DIR, WIDTH)
Definition: hevcdsp_lsx.h:152
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
UNI_W_MC
#define UNI_W_MC(PEL, DIR, WIDTH)
Definition: hevcdsp_lsx.h:194
int32_t
int32_t
Definition: audioconvert.c:56
h
h
Definition: vp9dsp_template.c:2038
ff_hevc_add_residual4x4_8_lsx
void ff_hevc_add_residual4x4_8_lsx(uint8_t *dst, const int16_t *res, ptrdiff_t stride)