Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * VVC DSP init for x86 | ||
3 | * | ||
4 | * Copyright (C) 2022-2024 Nuo Mi | ||
5 | * Copyright (c) 2023-2024 Wu Jianhua | ||
6 | * | ||
7 | * This file is part of FFmpeg. | ||
8 | * | ||
9 | * FFmpeg is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU Lesser General Public | ||
11 | * License as published by the Free Software Foundation; either | ||
12 | * version 2.1 of the License, or (at your option) any later version. | ||
13 | * | ||
14 | * FFmpeg is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * Lesser General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public | ||
20 | * License along with FFmpeg; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | */ | ||
23 | |||
24 | #include "config.h" | ||
25 | |||
26 | #include "libavutil/cpu.h" | ||
27 | #include "libavutil/x86/cpu.h" | ||
28 | #include "libavcodec/vvc/dec.h" | ||
29 | #include "libavcodec/vvc/ctu.h" | ||
30 | #include "libavcodec/vvc/dsp.h" | ||
31 | #include "libavcodec/x86/h26x/h2656dsp.h" | ||
32 | |||
33 | #if ARCH_X86_64 | ||
34 | |||
35 | #define PUT_PROTOTYPE(name, depth, opt) \ | ||
36 | void ff_vvc_put_ ## name ## _ ## depth ## _##opt(int16_t *dst, const uint8_t *src, ptrdiff_t srcstride, int height, const int8_t *hf, const int8_t *vf, int width); | ||
37 | |||
38 | #define PUT_PROTOTYPES(name, bitd, opt) \ | ||
39 | PUT_PROTOTYPE(name##2, bitd, opt) \ | ||
40 | PUT_PROTOTYPE(name##4, bitd, opt) \ | ||
41 | PUT_PROTOTYPE(name##8, bitd, opt) \ | ||
42 | PUT_PROTOTYPE(name##12, bitd, opt) \ | ||
43 | PUT_PROTOTYPE(name##16, bitd, opt) \ | ||
44 | PUT_PROTOTYPE(name##24, bitd, opt) \ | ||
45 | PUT_PROTOTYPE(name##32, bitd, opt) \ | ||
46 | PUT_PROTOTYPE(name##48, bitd, opt) \ | ||
47 | PUT_PROTOTYPE(name##64, bitd, opt) \ | ||
48 | PUT_PROTOTYPE(name##128, bitd, opt) | ||
49 | |||
50 | #define PUT_BPC_PROTOTYPES(name, opt) \ | ||
51 | PUT_PROTOTYPES(name, 8, opt) \ | ||
52 | PUT_PROTOTYPES(name, 10, opt) \ | ||
53 | PUT_PROTOTYPES(name, 12, opt) | ||
54 | |||
55 | #define PUT_TAP_PROTOTYPES(n, opt) \ | ||
56 | PUT_BPC_PROTOTYPES(n##tap_h, opt) \ | ||
57 | PUT_BPC_PROTOTYPES(n##tap_v, opt) \ | ||
58 | PUT_BPC_PROTOTYPES(n##tap_hv, opt) | ||
59 | |||
60 | PUT_BPC_PROTOTYPES(pixels, sse4) | ||
61 | PUT_BPC_PROTOTYPES(pixels, avx2) | ||
62 | |||
63 | PUT_TAP_PROTOTYPES(4, sse4) | ||
64 | PUT_TAP_PROTOTYPES(8, sse4) | ||
65 | PUT_TAP_PROTOTYPES(4, avx2) | ||
66 | PUT_TAP_PROTOTYPES(8, avx2) | ||
67 | |||
68 | #define bf(fn, bd, opt) fn##_##bd##_##opt | ||
69 | #define BF(fn, bpc, opt) fn##_##bpc##bpc_##opt | ||
70 | |||
71 | #define AVG_BPC_PROTOTYPES(bpc, opt) \ | ||
72 | void BF(ff_vvc_avg, bpc, opt)(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
73 | const int16_t *src0, const int16_t *src1, intptr_t width, intptr_t height, intptr_t pixel_max); \ | ||
74 | void BF(ff_vvc_w_avg, bpc, opt)(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
75 | const int16_t *src0, const int16_t *src1, intptr_t width, intptr_t height, \ | ||
76 | intptr_t denom, intptr_t w0, intptr_t w1, intptr_t o0, intptr_t o1, intptr_t pixel_max); | ||
77 | |||
78 | #define AVG_PROTOTYPES(bd, opt) \ | ||
79 | void bf(ff_vvc_avg, bd, opt)(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
80 | const int16_t *src0, const int16_t *src1, int width, int height); \ | ||
81 | void bf(ff_vvc_w_avg, bd, opt)(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
82 | const int16_t *src0, const int16_t *src1, int width, int height, \ | ||
83 | int denom, int w0, int w1, int o0, int o1); | ||
84 | |||
85 | AVG_BPC_PROTOTYPES( 8, avx2) | ||
86 | AVG_BPC_PROTOTYPES(16, avx2) | ||
87 | |||
88 | AVG_PROTOTYPES( 8, avx2) | ||
89 | AVG_PROTOTYPES(10, avx2) | ||
90 | AVG_PROTOTYPES(12, avx2) | ||
91 | |||
92 | |||
93 | #define DMVR_PROTOTYPES(bd, opt) \ | ||
94 | void ff_vvc_dmvr_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, \ | ||
95 | int height, intptr_t mx, intptr_t my, int width); \ | ||
96 | void ff_vvc_dmvr_h_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, \ | ||
97 | int height, intptr_t mx, intptr_t my, int width); \ | ||
98 | void ff_vvc_dmvr_v_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, \ | ||
99 | int height, intptr_t mx, intptr_t my, int width); \ | ||
100 | void ff_vvc_dmvr_hv_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, \ | ||
101 | int height, intptr_t mx, intptr_t my, int width); \ | ||
102 | |||
103 | DMVR_PROTOTYPES( 8, avx2) | ||
104 | DMVR_PROTOTYPES(10, avx2) | ||
105 | DMVR_PROTOTYPES(12, avx2) | ||
106 | |||
107 | #define OF_PROTOTYPES(bd, opt) \ | ||
108 | void ff_vvc_apply_bdof_##bd##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
109 | const int16_t *src0, const int16_t *src1, int w, int h); \ | ||
110 | |||
111 | OF_PROTOTYPES( 8, avx2) | ||
112 | OF_PROTOTYPES(10, avx2) | ||
113 | OF_PROTOTYPES(12, avx2) | ||
114 | |||
115 | #if ARCH_X86_64 && HAVE_AVX2_EXTERNAL | ||
116 | void ff_vvc_apply_bdof_avx2(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
117 | const int16_t *src0, const int16_t *src1, int w, int h, int pixel_max); \ | ||
118 | |||
119 | #define OF_FUNC(bd, opt) \ | ||
120 | void ff_vvc_apply_bdof_##bd##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
121 | const int16_t *src0, const int16_t *src1, int w, int h) \ | ||
122 | { \ | ||
123 | ff_vvc_apply_bdof##_##opt(dst, dst_stride, src0, src1, w, h, (1 << bd) - 1); \ | ||
124 | } \ | ||
125 | |||
126 | 3 | OF_FUNC( 8, avx2) | |
127 | 3 | OF_FUNC(10, avx2) | |
128 | 3 | OF_FUNC(12, avx2) | |
129 | #endif | ||
130 | |||
131 | #define ALF_BPC_PROTOTYPES(bpc, opt) \ | ||
132 | void BF(ff_vvc_alf_filter_luma, bpc, opt)(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
133 | const uint8_t *src, ptrdiff_t src_stride, ptrdiff_t width, ptrdiff_t height, \ | ||
134 | const int16_t *filter, const int16_t *clip, ptrdiff_t stride, ptrdiff_t vb_pos, ptrdiff_t pixel_max); \ | ||
135 | void BF(ff_vvc_alf_filter_chroma, bpc, opt)(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
136 | const uint8_t *src, ptrdiff_t src_stride, ptrdiff_t width, ptrdiff_t height, \ | ||
137 | const int16_t *filter, const int16_t *clip, ptrdiff_t stride, ptrdiff_t vb_pos, ptrdiff_t pixel_max); \ | ||
138 | void BF(ff_vvc_alf_classify_grad, bpc, opt)(int *gradient_sum, \ | ||
139 | const uint8_t *src, ptrdiff_t src_stride, intptr_t width, intptr_t height, intptr_t vb_pos); \ | ||
140 | void BF(ff_vvc_alf_classify, bpc, opt)(int *class_idx, int *transpose_idx, const int *gradient_sum, \ | ||
141 | intptr_t width, intptr_t height, intptr_t vb_pos, intptr_t bit_depth); \ | ||
142 | |||
143 | #define ALF_PROTOTYPES(bpc, bd, opt) \ | ||
144 | void bf(ff_vvc_alf_filter_luma, bd, opt)(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, \ | ||
145 | int width, int height, const int16_t *filter, const int16_t *clip, const int vb_pos); \ | ||
146 | void bf(ff_vvc_alf_filter_chroma, bd, opt)(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, \ | ||
147 | int width, int height, const int16_t *filter, const int16_t *clip, const int vb_pos); \ | ||
148 | void bf(ff_vvc_alf_classify, bd, opt)(int *class_idx, int *transpose_idx, \ | ||
149 | const uint8_t *src, ptrdiff_t src_stride, int width, int height, int vb_pos, int *gradient_tmp); \ | ||
150 | |||
151 | ALF_BPC_PROTOTYPES(8, avx2) | ||
152 | ALF_BPC_PROTOTYPES(16, avx2) | ||
153 | |||
154 | ALF_PROTOTYPES(8, 8, avx2) | ||
155 | ALF_PROTOTYPES(16, 10, avx2) | ||
156 | ALF_PROTOTYPES(16, 12, avx2) | ||
157 | |||
158 | #if ARCH_X86_64 | ||
159 | #if HAVE_SSE4_EXTERNAL | ||
160 | #define FW_PUT(name, depth, opt) \ | ||
161 | void ff_vvc_put_ ## name ## _ ## depth ## _##opt(int16_t *dst, const uint8_t *src, ptrdiff_t srcstride, \ | ||
162 | int height, const int8_t *hf, const int8_t *vf, int width) \ | ||
163 | { \ | ||
164 | ff_h2656_put_## name ## _ ## depth ## _##opt(dst, 2 * MAX_PB_SIZE, src, srcstride, height, hf, vf, width); \ | ||
165 | } | ||
166 | |||
167 | #define FW_PUT_TAP(fname, bitd, opt ) \ | ||
168 | FW_PUT(fname##4, bitd, opt ) \ | ||
169 | FW_PUT(fname##8, bitd, opt ) \ | ||
170 | FW_PUT(fname##16, bitd, opt ) \ | ||
171 | FW_PUT(fname##32, bitd, opt ) \ | ||
172 | FW_PUT(fname##64, bitd, opt ) \ | ||
173 | FW_PUT(fname##128, bitd, opt ) \ | ||
174 | |||
175 | #define FW_PUT_4TAP(fname, bitd, opt) \ | ||
176 | FW_PUT(fname ## 2, bitd, opt) \ | ||
177 | FW_PUT_TAP(fname, bitd, opt) | ||
178 | |||
179 | #define FW_PUT_4TAP_SSE4(bitd) \ | ||
180 | FW_PUT_4TAP(pixels, bitd, sse4) \ | ||
181 | FW_PUT_4TAP(4tap_h, bitd, sse4) \ | ||
182 | FW_PUT_4TAP(4tap_v, bitd, sse4) \ | ||
183 | FW_PUT_4TAP(4tap_hv, bitd, sse4) | ||
184 | |||
185 | #define FW_PUT_8TAP_SSE4(bitd) \ | ||
186 | FW_PUT_TAP(8tap_h, bitd, sse4) \ | ||
187 | FW_PUT_TAP(8tap_v, bitd, sse4) \ | ||
188 | FW_PUT_TAP(8tap_hv, bitd, sse4) | ||
189 | |||
190 | #define FW_PUT_SSE4(bitd) \ | ||
191 | FW_PUT_4TAP_SSE4(bitd) \ | ||
192 | FW_PUT_8TAP_SSE4(bitd) | ||
193 | |||
194 | 914 | FW_PUT_SSE4( 8) | |
195 | 1096 | FW_PUT_SSE4(10) | |
196 | 1096 | FW_PUT_SSE4(12) | |
197 | #endif | ||
198 | |||
199 | #if HAVE_AVX2_EXTERNAL | ||
200 | #define FW_PUT_TAP_AVX2(n, bitd) \ | ||
201 | FW_PUT(n ## tap_h32, bitd, avx2) \ | ||
202 | FW_PUT(n ## tap_h64, bitd, avx2) \ | ||
203 | FW_PUT(n ## tap_h128, bitd, avx2) \ | ||
204 | FW_PUT(n ## tap_v32, bitd, avx2) \ | ||
205 | FW_PUT(n ## tap_v64, bitd, avx2) \ | ||
206 | FW_PUT(n ## tap_v128, bitd, avx2) | ||
207 | |||
208 | #define FW_PUT_AVX2(bitd) \ | ||
209 | FW_PUT(pixels32, bitd, avx2) \ | ||
210 | FW_PUT(pixels64, bitd, avx2) \ | ||
211 | FW_PUT(pixels128, bitd, avx2) \ | ||
212 | FW_PUT_TAP_AVX2(4, bitd) \ | ||
213 | FW_PUT_TAP_AVX2(8, bitd) \ | ||
214 | |||
215 | 234 | FW_PUT_AVX2( 8) | |
216 | 234 | FW_PUT_AVX2(10) | |
217 | 234 | FW_PUT_AVX2(12) | |
218 | |||
219 | #define FW_PUT_TAP_16BPC_AVX2(n, bitd) \ | ||
220 | FW_PUT(n ## tap_h16, bitd, avx2) \ | ||
221 | FW_PUT(n ## tap_v16, bitd, avx2) \ | ||
222 | FW_PUT(n ## tap_hv16, bitd, avx2) \ | ||
223 | FW_PUT(n ## tap_hv32, bitd, avx2) \ | ||
224 | FW_PUT(n ## tap_hv64, bitd, avx2) \ | ||
225 | FW_PUT(n ## tap_hv128, bitd, avx2) | ||
226 | |||
227 | #define FW_PUT_16BPC_AVX2(bitd) \ | ||
228 | FW_PUT(pixels16, bitd, avx2) \ | ||
229 | FW_PUT_TAP_16BPC_AVX2(4, bitd) \ | ||
230 | FW_PUT_TAP_16BPC_AVX2(8, bitd) | ||
231 | |||
232 | 182 | FW_PUT_16BPC_AVX2(10) | |
233 | 182 | FW_PUT_16BPC_AVX2(12) | |
234 | |||
235 | #define AVG_FUNCS(bpc, bd, opt) \ | ||
236 | void bf(ff_vvc_avg, bd, opt)(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
237 | const int16_t *src0, const int16_t *src1, int width, int height) \ | ||
238 | { \ | ||
239 | BF(ff_vvc_avg, bpc, opt)(dst, dst_stride, src0, src1, width, height, (1 << bd) - 1); \ | ||
240 | } \ | ||
241 | void bf(ff_vvc_w_avg, bd, opt)(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
242 | const int16_t *src0, const int16_t *src1, int width, int height, \ | ||
243 | int denom, int w0, int w1, int o0, int o1) \ | ||
244 | { \ | ||
245 | BF(ff_vvc_w_avg, bpc, opt)(dst, dst_stride, src0, src1, width, height, \ | ||
246 | denom, w0, w1, o0, o1, (1 << bd) - 1); \ | ||
247 | } | ||
248 | |||
249 | 196 | AVG_FUNCS(8, 8, avx2) | |
250 | 196 | AVG_FUNCS(16, 10, avx2) | |
251 | 196 | AVG_FUNCS(16, 12, avx2) | |
252 | |||
253 | #define ALF_FUNCS(bpc, bd, opt) \ | ||
254 | void bf(ff_vvc_alf_filter_luma, bd, opt)(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, \ | ||
255 | int width, int height, const int16_t *filter, const int16_t *clip, const int vb_pos) \ | ||
256 | { \ | ||
257 | const int param_stride = (width >> 2) * ALF_NUM_COEFF_LUMA; \ | ||
258 | BF(ff_vvc_alf_filter_luma, bpc, opt)(dst, dst_stride, src, src_stride, width, height, \ | ||
259 | filter, clip, param_stride, vb_pos, (1 << bd) - 1); \ | ||
260 | } \ | ||
261 | void bf(ff_vvc_alf_filter_chroma, bd, opt)(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, \ | ||
262 | int width, int height, const int16_t *filter, const int16_t *clip, const int vb_pos) \ | ||
263 | { \ | ||
264 | BF(ff_vvc_alf_filter_chroma, bpc, opt)(dst, dst_stride, src, src_stride, width, height, \ | ||
265 | filter, clip, 0, vb_pos,(1 << bd) - 1); \ | ||
266 | } \ | ||
267 | void bf(ff_vvc_alf_classify, bd, opt)(int *class_idx, int *transpose_idx, \ | ||
268 | const uint8_t *src, ptrdiff_t src_stride, int width, int height, int vb_pos, int *gradient_tmp) \ | ||
269 | { \ | ||
270 | BF(ff_vvc_alf_classify_grad, bpc, opt)(gradient_tmp, src, src_stride, width, height, vb_pos); \ | ||
271 | BF(ff_vvc_alf_classify, bpc, opt)(class_idx, transpose_idx, gradient_tmp, width, height, vb_pos, bd); \ | ||
272 | } \ | ||
273 | |||
274 | 2176 | ALF_FUNCS(8, 8, avx2) | |
275 | 2176 | ALF_FUNCS(16, 10, avx2) | |
276 | 2176 | ALF_FUNCS(16, 12, avx2) | |
277 | |||
278 | #endif | ||
279 | |||
280 | #define PEL_LINK(dst, C, W, idx1, idx2, name, D, opt) \ | ||
281 | dst[C][W][idx1][idx2] = ff_vvc_put_## name ## _ ## D ## _##opt; \ | ||
282 | dst ## _uni[C][W][idx1][idx2] = ff_h2656_put_uni_ ## name ## _ ## D ## _##opt; \ | ||
283 | |||
284 | #define MC_TAP_LINKS(pointer, C, my, mx, fname, bitd, opt ) \ | ||
285 | PEL_LINK(pointer, C, 1, my , mx , fname##4 , bitd, opt ); \ | ||
286 | PEL_LINK(pointer, C, 2, my , mx , fname##8 , bitd, opt ); \ | ||
287 | PEL_LINK(pointer, C, 3, my , mx , fname##16, bitd, opt ); \ | ||
288 | PEL_LINK(pointer, C, 4, my , mx , fname##32, bitd, opt ); \ | ||
289 | PEL_LINK(pointer, C, 5, my , mx , fname##64, bitd, opt ); \ | ||
290 | PEL_LINK(pointer, C, 6, my , mx , fname##128, bitd, opt ); | ||
291 | |||
292 | #define MC_8TAP_LINKS(pointer, my, mx, fname, bitd, opt) \ | ||
293 | MC_TAP_LINKS(pointer, LUMA, my, mx, fname, bitd, opt) | ||
294 | |||
295 | #define MC_8TAP_LINKS_SSE4(bd) \ | ||
296 | MC_8TAP_LINKS(c->inter.put, 0, 0, pixels, bd, sse4); \ | ||
297 | MC_8TAP_LINKS(c->inter.put, 0, 1, 8tap_h, bd, sse4); \ | ||
298 | MC_8TAP_LINKS(c->inter.put, 1, 0, 8tap_v, bd, sse4); \ | ||
299 | MC_8TAP_LINKS(c->inter.put, 1, 1, 8tap_hv, bd, sse4) | ||
300 | |||
301 | #define MC_4TAP_LINKS(pointer, my, mx, fname, bitd, opt) \ | ||
302 | PEL_LINK(pointer, CHROMA, 0, my , mx , fname##2 , bitd, opt ); \ | ||
303 | MC_TAP_LINKS(pointer, CHROMA, my, mx, fname, bitd, opt) \ | ||
304 | |||
305 | #define MC_4TAP_LINKS_SSE4(bd) \ | ||
306 | MC_4TAP_LINKS(c->inter.put, 0, 0, pixels, bd, sse4); \ | ||
307 | MC_4TAP_LINKS(c->inter.put, 0, 1, 4tap_h, bd, sse4); \ | ||
308 | MC_4TAP_LINKS(c->inter.put, 1, 0, 4tap_v, bd, sse4); \ | ||
309 | MC_4TAP_LINKS(c->inter.put, 1, 1, 4tap_hv, bd, sse4) | ||
310 | |||
311 | #define MC_LINK_SSE4(bd) \ | ||
312 | MC_4TAP_LINKS_SSE4(bd) \ | ||
313 | MC_8TAP_LINKS_SSE4(bd) | ||
314 | |||
315 | #define MC_TAP_LINKS_AVX2(C,tap,bd) do { \ | ||
316 | PEL_LINK(c->inter.put, C, 4, 0, 0, pixels32, bd, avx2) \ | ||
317 | PEL_LINK(c->inter.put, C, 5, 0, 0, pixels64, bd, avx2) \ | ||
318 | PEL_LINK(c->inter.put, C, 6, 0, 0, pixels128, bd, avx2) \ | ||
319 | PEL_LINK(c->inter.put, C, 4, 0, 1, tap##tap_h32, bd, avx2) \ | ||
320 | PEL_LINK(c->inter.put, C, 5, 0, 1, tap##tap_h64, bd, avx2) \ | ||
321 | PEL_LINK(c->inter.put, C, 6, 0, 1, tap##tap_h128, bd, avx2) \ | ||
322 | PEL_LINK(c->inter.put, C, 4, 1, 0, tap##tap_v32, bd, avx2) \ | ||
323 | PEL_LINK(c->inter.put, C, 5, 1, 0, tap##tap_v64, bd, avx2) \ | ||
324 | PEL_LINK(c->inter.put, C, 6, 1, 0, tap##tap_v128, bd, avx2) \ | ||
325 | } while (0) | ||
326 | |||
327 | #define MC_LINKS_AVX2(bd) \ | ||
328 | MC_TAP_LINKS_AVX2(LUMA, 8, bd); \ | ||
329 | MC_TAP_LINKS_AVX2(CHROMA, 4, bd); | ||
330 | |||
331 | #define MC_TAP_LINKS_16BPC_AVX2(C, tap, bd) do { \ | ||
332 | PEL_LINK(c->inter.put, C, 3, 0, 0, pixels16, bd, avx2) \ | ||
333 | PEL_LINK(c->inter.put, C, 3, 0, 1, tap##tap_h16, bd, avx2) \ | ||
334 | PEL_LINK(c->inter.put, C, 3, 1, 0, tap##tap_v16, bd, avx2) \ | ||
335 | PEL_LINK(c->inter.put, C, 3, 1, 1, tap##tap_hv16, bd, avx2) \ | ||
336 | PEL_LINK(c->inter.put, C, 4, 1, 1, tap##tap_hv32, bd, avx2) \ | ||
337 | PEL_LINK(c->inter.put, C, 5, 1, 1, tap##tap_hv64, bd, avx2) \ | ||
338 | PEL_LINK(c->inter.put, C, 6, 1, 1, tap##tap_hv128, bd, avx2) \ | ||
339 | } while (0) | ||
340 | |||
341 | #define MC_LINKS_16BPC_AVX2(bd) \ | ||
342 | MC_TAP_LINKS_16BPC_AVX2(LUMA, 8, bd); \ | ||
343 | MC_TAP_LINKS_16BPC_AVX2(CHROMA, 4, bd); | ||
344 | |||
345 | #define AVG_INIT(bd, opt) do { \ | ||
346 | c->inter.avg = bf(ff_vvc_avg, bd, opt); \ | ||
347 | c->inter.w_avg = bf(ff_vvc_w_avg, bd, opt); \ | ||
348 | } while (0) | ||
349 | |||
350 | #define DMVR_INIT(bd) do { \ | ||
351 | c->inter.dmvr[0][0] = ff_vvc_dmvr_##bd##_avx2; \ | ||
352 | c->inter.dmvr[0][1] = ff_vvc_dmvr_h_##bd##_avx2; \ | ||
353 | c->inter.dmvr[1][0] = ff_vvc_dmvr_v_##bd##_avx2; \ | ||
354 | c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_##bd##_avx2; \ | ||
355 | } while (0) | ||
356 | |||
357 | #define OF_INIT(bd) do { \ | ||
358 | c->inter.apply_bdof = ff_vvc_apply_bdof_##bd##_avx2; \ | ||
359 | } while (0) | ||
360 | |||
361 | #define ALF_INIT(bd) do { \ | ||
362 | c->alf.filter[LUMA] = ff_vvc_alf_filter_luma_##bd##_avx2; \ | ||
363 | c->alf.filter[CHROMA] = ff_vvc_alf_filter_chroma_##bd##_avx2; \ | ||
364 | c->alf.classify = ff_vvc_alf_classify_##bd##_avx2; \ | ||
365 | } while (0) | ||
366 | |||
367 | int ff_vvc_sad_avx2(const int16_t *src0, const int16_t *src1, int dx, int dy, int block_w, int block_h); | ||
368 | #define SAD_INIT() c->inter.sad = ff_vvc_sad_avx2 | ||
369 | #endif | ||
370 | |||
371 | |||
372 | #endif // ARCH_X86_64 | ||
373 | |||
374 | 1300 | void ff_vvc_dsp_init_x86(VVCDSPContext *const c, const int bd) | |
375 | { | ||
376 | #if ARCH_X86_64 | ||
377 | 1300 | const int cpu_flags = av_get_cpu_flags(); | |
378 | |||
379 |
3/4✓ Branch 0 taken 152 times.
✓ Branch 1 taken 1031 times.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
|
1300 | switch (bd) { |
380 | 152 | case 8: | |
381 |
2/2✓ Branch 0 taken 54 times.
✓ Branch 1 taken 98 times.
|
152 | if (EXTERNAL_SSE4(cpu_flags)) { |
382 | 54 | MC_LINK_SSE4(8); | |
383 | } | ||
384 |
3/4✓ Branch 0 taken 9 times.
✓ Branch 1 taken 143 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
152 | if (EXTERNAL_AVX2_FAST(cpu_flags)) { |
385 | 9 | ALF_INIT(8); | |
386 | 9 | AVG_INIT(8, avx2); | |
387 | 9 | MC_LINKS_AVX2(8); | |
388 | 9 | OF_INIT(8); | |
389 | 9 | DMVR_INIT(8); | |
390 | 9 | SAD_INIT(); | |
391 | } | ||
392 | 152 | break; | |
393 | 1031 | case 10: | |
394 |
2/2✓ Branch 0 taken 60 times.
✓ Branch 1 taken 971 times.
|
1031 | if (EXTERNAL_SSE4(cpu_flags)) { |
395 | 60 | MC_LINK_SSE4(10); | |
396 | } | ||
397 |
3/4✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1021 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
|
1031 | if (EXTERNAL_AVX2_FAST(cpu_flags)) { |
398 | 10 | ALF_INIT(10); | |
399 | 10 | AVG_INIT(10, avx2); | |
400 | 10 | MC_LINKS_AVX2(10); | |
401 | 10 | MC_LINKS_16BPC_AVX2(10); | |
402 | 10 | OF_INIT(10); | |
403 | 10 | DMVR_INIT(10); | |
404 | 10 | SAD_INIT(); | |
405 | } | ||
406 | 1031 | break; | |
407 | 117 | case 12: | |
408 |
2/2✓ Branch 0 taken 54 times.
✓ Branch 1 taken 63 times.
|
117 | if (EXTERNAL_SSE4(cpu_flags)) { |
409 | 54 | MC_LINK_SSE4(12); | |
410 | } | ||
411 |
3/4✓ Branch 0 taken 9 times.
✓ Branch 1 taken 108 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
|
117 | if (EXTERNAL_AVX2_FAST(cpu_flags)) { |
412 | 9 | ALF_INIT(12); | |
413 | 9 | AVG_INIT(12, avx2); | |
414 | 9 | MC_LINKS_AVX2(12); | |
415 | 9 | MC_LINKS_16BPC_AVX2(12); | |
416 | 9 | OF_INIT(12); | |
417 | 9 | DMVR_INIT(12); | |
418 | 9 | SAD_INIT(); | |
419 | } | ||
420 | 117 | break; | |
421 | ✗ | default: | |
422 | ✗ | break; | |
423 | } | ||
424 | #endif | ||
425 | 1300 | } | |
426 |