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)                                               \
29void ff_hevc_put_hevc_##PEL##_##DIR##WIDTH##_8_lsx(int16_t *dst,          \
30                                                   uint8_t *src,          \
31                                                   ptrdiff_t src_stride,  \
32                                                   int height,            \
33                                                   intptr_t mx,           \
34                                                   intptr_t my,           \
35                                                   int width)
36
37MC(pel, pixels, 4);
38MC(pel, pixels, 6);
39MC(pel, pixels, 8);
40MC(pel, pixels, 12);
41MC(pel, pixels, 16);
42MC(pel, pixels, 24);
43MC(pel, pixels, 32);
44MC(pel, pixels, 48);
45MC(pel, pixels, 64);
46
47MC(qpel, h, 4);
48MC(qpel, h, 8);
49MC(qpel, h, 12);
50MC(qpel, h, 16);
51MC(qpel, h, 24);
52MC(qpel, h, 32);
53MC(qpel, h, 48);
54MC(qpel, h, 64);
55
56MC(qpel, v, 4);
57MC(qpel, v, 8);
58MC(qpel, v, 12);
59MC(qpel, v, 16);
60MC(qpel, v, 24);
61MC(qpel, v, 32);
62MC(qpel, v, 48);
63MC(qpel, v, 64);
64
65MC(qpel, hv, 4);
66MC(qpel, hv, 8);
67MC(qpel, hv, 12);
68MC(qpel, hv, 16);
69MC(qpel, hv, 24);
70MC(qpel, hv, 32);
71MC(qpel, hv, 48);
72MC(qpel, hv, 64);
73
74MC(epel, h, 32);
75
76MC(epel, v, 16);
77MC(epel, v, 24);
78MC(epel, v, 32);
79
80MC(epel, hv, 8);
81MC(epel, hv, 12);
82MC(epel, hv, 16);
83MC(epel, hv, 24);
84MC(epel, hv, 32);
85
86#undef MC
87
88#define BI_MC(PEL, DIR, WIDTH)                                               \
89void ff_hevc_put_hevc_bi_##PEL##_##DIR##WIDTH##_8_lsx(uint8_t *dst,          \
90                                                      ptrdiff_t dst_stride,  \
91                                                      uint8_t *src,          \
92                                                      ptrdiff_t src_stride,  \
93                                                      int16_t *src_16bit,    \
94                                                      int height,            \
95                                                      intptr_t mx,           \
96                                                      intptr_t my,           \
97                                                      int width)
98
99BI_MC(pel, pixels, 4);
100BI_MC(pel, pixels, 6);
101BI_MC(pel, pixels, 8);
102BI_MC(pel, pixels, 12);
103BI_MC(pel, pixels, 16);
104BI_MC(pel, pixels, 24);
105BI_MC(pel, pixels, 32);
106BI_MC(pel, pixels, 48);
107BI_MC(pel, pixels, 64);
108
109BI_MC(qpel, h, 16);
110BI_MC(qpel, h, 24);
111BI_MC(qpel, h, 32);
112BI_MC(qpel, h, 48);
113BI_MC(qpel, h, 64);
114
115BI_MC(qpel, v, 8);
116BI_MC(qpel, v, 16);
117BI_MC(qpel, v, 24);
118BI_MC(qpel, v, 32);
119BI_MC(qpel, v, 48);
120BI_MC(qpel, v, 64);
121
122BI_MC(qpel, hv, 8);
123BI_MC(qpel, hv, 16);
124BI_MC(qpel, hv, 24);
125BI_MC(qpel, hv, 32);
126BI_MC(qpel, hv, 48);
127BI_MC(qpel, hv, 64);
128
129BI_MC(epel, h, 24);
130BI_MC(epel, h, 32);
131
132BI_MC(epel, v, 12);
133BI_MC(epel, v, 16);
134BI_MC(epel, v, 24);
135BI_MC(epel, v, 32);
136
137BI_MC(epel, hv, 6);
138BI_MC(epel, hv, 8);
139BI_MC(epel, hv, 16);
140BI_MC(epel, hv, 24);
141BI_MC(epel, hv, 32);
142
143#undef BI_MC
144
145#define UNI_MC(PEL, DIR, WIDTH)                                              \
146void ff_hevc_put_hevc_uni_##PEL##_##DIR##WIDTH##_8_lsx(uint8_t *dst,         \
147                                                       ptrdiff_t dst_stride, \
148                                                       uint8_t *src,         \
149                                                       ptrdiff_t src_stride, \
150                                                       int height,           \
151                                                       intptr_t mx,          \
152                                                       intptr_t my,          \
153                                                       int width)
154
155UNI_MC(qpel, h, 64);
156
157UNI_MC(qpel, v, 24);
158UNI_MC(qpel, v, 32);
159UNI_MC(qpel, v, 48);
160UNI_MC(qpel, v, 64);
161
162UNI_MC(qpel, hv, 8);
163UNI_MC(qpel, hv, 16);
164UNI_MC(qpel, hv, 24);
165UNI_MC(qpel, hv, 32);
166UNI_MC(qpel, hv, 48);
167UNI_MC(qpel, hv, 64);
168
169UNI_MC(epel, v, 24);
170UNI_MC(epel, v, 32);
171
172UNI_MC(epel, hv, 8);
173UNI_MC(epel, hv, 12);
174UNI_MC(epel, hv, 16);
175UNI_MC(epel, hv, 24);
176UNI_MC(epel, hv, 32);
177
178#undef UNI_MC
179
180#define UNI_W_MC(PEL, DIR, WIDTH)                                       \
181void ff_hevc_put_hevc_uni_w_##PEL##_##DIR##WIDTH##_8_lsx(uint8_t *dst,  \
182                                                         ptrdiff_t      \
183                                                         dst_stride,    \
184                                                         uint8_t *src,  \
185                                                         ptrdiff_t      \
186                                                         src_stride,    \
187                                                         int height,    \
188                                                         int denom,     \
189                                                         int weight,    \
190                                                         int offset,    \
191                                                         intptr_t mx,   \
192                                                         intptr_t my,   \
193                                                         int width)
194
195UNI_W_MC(qpel, hv, 8);
196UNI_W_MC(qpel, hv, 16);
197UNI_W_MC(qpel, hv, 24);
198UNI_W_MC(qpel, hv, 32);
199UNI_W_MC(qpel, hv, 48);
200UNI_W_MC(qpel, hv, 64);
201
202#undef UNI_W_MC
203
204void ff_hevc_loop_filter_luma_h_8_lsx(uint8_t *src, ptrdiff_t stride,
205                                      int32_t beta, int32_t *tc,
206                                      uint8_t *p_is_pcm, uint8_t *q_is_pcm);
207
208void ff_hevc_loop_filter_luma_v_8_lsx(uint8_t *src, ptrdiff_t stride,
209                                      int32_t beta, int32_t *tc,
210                                      uint8_t *p_is_pcm, uint8_t *q_is_pcm);
211
212void ff_hevc_loop_filter_chroma_h_8_lsx(uint8_t *src, ptrdiff_t stride,
213                                        int32_t *tc, uint8_t *p_is_pcm,
214                                        uint8_t *q_is_pcm);
215
216void ff_hevc_loop_filter_chroma_v_8_lsx(uint8_t *src, ptrdiff_t stride,
217                                        int32_t *tc, uint8_t *p_is_pcm,
218                                        uint8_t *q_is_pcm);
219
220void ff_hevc_sao_edge_filter_8_lsx(uint8_t *dst, uint8_t *src,
221                                   ptrdiff_t stride_dst,
222                                   int16_t *sao_offset_val,
223                                   int eo, int width, int height);
224
225void ff_hevc_idct_4x4_lsx(int16_t *coeffs, int col_limit);
226void ff_hevc_idct_8x8_lsx(int16_t *coeffs, int col_limit);
227void ff_hevc_idct_16x16_lsx(int16_t *coeffs, int col_limit);
228void ff_hevc_idct_32x32_lsx(int16_t *coeffs, int col_limit);
229
230#endif  // #ifndef AVCODEC_LOONGARCH_HEVCDSP_LSX_H
231