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 bf(fn, bd, opt) fn##_##bd##_##opt | ||
36 | #define BF(fn, bpc, opt) fn##_##bpc##bpc_##opt | ||
37 | |||
38 | #define AVG_BPC_PROTOTYPES(bpc, opt) \ | ||
39 | void BF(ff_vvc_avg, bpc, opt)(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
40 | const int16_t *src0, const int16_t *src1, intptr_t width, intptr_t height, intptr_t pixel_max); \ | ||
41 | void BF(ff_vvc_w_avg, bpc, opt)(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
42 | const int16_t *src0, const int16_t *src1, intptr_t width, intptr_t height, \ | ||
43 | intptr_t denom, intptr_t w0, intptr_t w1, intptr_t o0, intptr_t o1, intptr_t pixel_max); | ||
44 | |||
45 | AVG_BPC_PROTOTYPES( 8, avx2) | ||
46 | AVG_BPC_PROTOTYPES(16, avx2) | ||
47 | |||
48 | #define DMVR_PROTOTYPES(bd, opt) \ | ||
49 | void ff_vvc_dmvr_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, \ | ||
50 | int height, intptr_t mx, intptr_t my, int width); \ | ||
51 | void ff_vvc_dmvr_h_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, \ | ||
52 | int height, intptr_t mx, intptr_t my, int width); \ | ||
53 | void ff_vvc_dmvr_v_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, \ | ||
54 | int height, intptr_t mx, intptr_t my, int width); \ | ||
55 | void ff_vvc_dmvr_hv_##bd##_##opt(int16_t *dst, const uint8_t *src, ptrdiff_t src_stride, \ | ||
56 | int height, intptr_t mx, intptr_t my, int width); \ | ||
57 | |||
58 | DMVR_PROTOTYPES( 8, avx2) | ||
59 | DMVR_PROTOTYPES(10, avx2) | ||
60 | DMVR_PROTOTYPES(12, avx2) | ||
61 | |||
62 | #if ARCH_X86_64 && HAVE_AVX2_EXTERNAL | ||
63 | void ff_vvc_apply_bdof_avx2(uint8_t *dst, ptrdiff_t dst_stride, | ||
64 | const int16_t *src0, const int16_t *src1, | ||
65 | int w, int h, int pixel_max); | ||
66 | |||
67 | #define OF_FUNC(bd, opt) \ | ||
68 | static void vvc_apply_bdof_##bd##_##opt(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
69 | const int16_t *src0, const int16_t *src1, int w, int h) \ | ||
70 | { \ | ||
71 | ff_vvc_apply_bdof##_##opt(dst, dst_stride, src0, src1, w, h, (1 << bd) - 1); \ | ||
72 | } \ | ||
73 | |||
74 | 3 | OF_FUNC( 8, avx2) | |
75 | 3 | OF_FUNC(10, avx2) | |
76 | 3 | OF_FUNC(12, avx2) | |
77 | |||
78 | #define OF_INIT(bd) c->inter.apply_bdof = vvc_apply_bdof_##bd##_avx2 | ||
79 | #endif | ||
80 | |||
81 | #define ALF_BPC_PROTOTYPES(bpc, opt) \ | ||
82 | void BF(ff_vvc_alf_filter_luma, bpc, opt)(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
83 | const uint8_t *src, ptrdiff_t src_stride, ptrdiff_t width, ptrdiff_t height, \ | ||
84 | const int16_t *filter, const int16_t *clip, ptrdiff_t stride, ptrdiff_t vb_pos, ptrdiff_t pixel_max); \ | ||
85 | void BF(ff_vvc_alf_filter_chroma, bpc, opt)(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
86 | const uint8_t *src, ptrdiff_t src_stride, ptrdiff_t width, ptrdiff_t height, \ | ||
87 | const int16_t *filter, const int16_t *clip, ptrdiff_t stride, ptrdiff_t vb_pos, ptrdiff_t pixel_max); \ | ||
88 | void BF(ff_vvc_alf_classify_grad, bpc, opt)(int *gradient_sum, \ | ||
89 | const uint8_t *src, ptrdiff_t src_stride, intptr_t width, intptr_t height, intptr_t vb_pos); \ | ||
90 | void BF(ff_vvc_alf_classify, bpc, opt)(int *class_idx, int *transpose_idx, const int *gradient_sum, \ | ||
91 | intptr_t width, intptr_t height, intptr_t vb_pos, intptr_t bit_depth); \ | ||
92 | |||
93 | ALF_BPC_PROTOTYPES(8, avx2) | ||
94 | ALF_BPC_PROTOTYPES(16, avx2) | ||
95 | |||
96 | #if ARCH_X86_64 | ||
97 | #define FW_PUT(name, depth, opt) \ | ||
98 | static void vvc_put_ ## name ## _ ## depth ## _##opt(int16_t *dst, const uint8_t *src, ptrdiff_t srcstride, \ | ||
99 | int height, const int8_t *hf, const int8_t *vf, int width) \ | ||
100 | { \ | ||
101 | ff_h2656_put_## name ## _ ## depth ## _##opt(dst, 2 * MAX_PB_SIZE, src, srcstride, height, hf, vf, width); \ | ||
102 | } | ||
103 | |||
104 | #if HAVE_SSE4_EXTERNAL | ||
105 | #define FW_PUT_TAP(fname, bitd, opt ) \ | ||
106 | FW_PUT(fname##4, bitd, opt ) \ | ||
107 | FW_PUT(fname##8, bitd, opt ) \ | ||
108 | FW_PUT(fname##16, bitd, opt ) \ | ||
109 | FW_PUT(fname##32, bitd, opt ) \ | ||
110 | FW_PUT(fname##64, bitd, opt ) \ | ||
111 | FW_PUT(fname##128, bitd, opt ) \ | ||
112 | |||
113 | #define FW_PUT_4TAP(fname, bitd, opt) \ | ||
114 | FW_PUT(fname ## 2, bitd, opt) \ | ||
115 | FW_PUT_TAP(fname, bitd, opt) | ||
116 | |||
117 | #define FW_PUT_4TAP_SSE4(bitd) \ | ||
118 | FW_PUT_4TAP(pixels, bitd, sse4) \ | ||
119 | FW_PUT_4TAP(4tap_h, bitd, sse4) \ | ||
120 | FW_PUT_4TAP(4tap_v, bitd, sse4) \ | ||
121 | FW_PUT_4TAP(4tap_hv, bitd, sse4) | ||
122 | |||
123 | #define FW_PUT_8TAP_SSE4(bitd) \ | ||
124 | FW_PUT_TAP(8tap_h, bitd, sse4) \ | ||
125 | FW_PUT_TAP(8tap_v, bitd, sse4) \ | ||
126 | FW_PUT_TAP(8tap_hv, bitd, sse4) | ||
127 | |||
128 | #define FW_PUT_SSE4(bitd) \ | ||
129 | FW_PUT_4TAP_SSE4(bitd) \ | ||
130 | FW_PUT_8TAP_SSE4(bitd) | ||
131 | |||
132 | 914 | FW_PUT_SSE4( 8) | |
133 | 1096 | FW_PUT_SSE4(10) | |
134 | 1096 | FW_PUT_SSE4(12) | |
135 | #endif | ||
136 | |||
137 | #if HAVE_AVX2_EXTERNAL | ||
138 | #define FW_PUT_TAP_AVX2(n, bitd) \ | ||
139 | FW_PUT(n ## tap_h32, bitd, avx2) \ | ||
140 | FW_PUT(n ## tap_h64, bitd, avx2) \ | ||
141 | FW_PUT(n ## tap_h128, bitd, avx2) \ | ||
142 | FW_PUT(n ## tap_v32, bitd, avx2) \ | ||
143 | FW_PUT(n ## tap_v64, bitd, avx2) \ | ||
144 | FW_PUT(n ## tap_v128, bitd, avx2) | ||
145 | |||
146 | #define FW_PUT_AVX2(bitd) \ | ||
147 | FW_PUT(pixels32, bitd, avx2) \ | ||
148 | FW_PUT(pixels64, bitd, avx2) \ | ||
149 | FW_PUT(pixels128, bitd, avx2) \ | ||
150 | FW_PUT_TAP_AVX2(4, bitd) \ | ||
151 | FW_PUT_TAP_AVX2(8, bitd) \ | ||
152 | |||
153 | 234 | FW_PUT_AVX2( 8) | |
154 | 234 | FW_PUT_AVX2(10) | |
155 | 234 | FW_PUT_AVX2(12) | |
156 | |||
157 | #define FW_PUT_TAP_16BPC_AVX2(n, bitd) \ | ||
158 | FW_PUT(n ## tap_h16, bitd, avx2) \ | ||
159 | FW_PUT(n ## tap_v16, bitd, avx2) \ | ||
160 | FW_PUT(n ## tap_hv16, bitd, avx2) \ | ||
161 | FW_PUT(n ## tap_hv32, bitd, avx2) \ | ||
162 | FW_PUT(n ## tap_hv64, bitd, avx2) \ | ||
163 | FW_PUT(n ## tap_hv128, bitd, avx2) | ||
164 | |||
165 | #define FW_PUT_16BPC_AVX2(bitd) \ | ||
166 | FW_PUT(pixels16, bitd, avx2) \ | ||
167 | FW_PUT_TAP_16BPC_AVX2(4, bitd) \ | ||
168 | FW_PUT_TAP_16BPC_AVX2(8, bitd) | ||
169 | |||
170 | 182 | FW_PUT_16BPC_AVX2(10) | |
171 | 182 | FW_PUT_16BPC_AVX2(12) | |
172 | |||
173 | #define AVG_FUNCS(bpc, bd, opt) \ | ||
174 | static void bf(vvc_avg, bd, opt)(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
175 | const int16_t *src0, const int16_t *src1, int width, int height) \ | ||
176 | { \ | ||
177 | BF(ff_vvc_avg, bpc, opt)(dst, dst_stride, src0, src1, width, height, (1 << bd) - 1); \ | ||
178 | } \ | ||
179 | static void bf(vvc_w_avg, bd, opt)(uint8_t *dst, ptrdiff_t dst_stride, \ | ||
180 | const int16_t *src0, const int16_t *src1, int width, int height, \ | ||
181 | int denom, int w0, int w1, int o0, int o1) \ | ||
182 | { \ | ||
183 | BF(ff_vvc_w_avg, bpc, opt)(dst, dst_stride, src0, src1, width, height, \ | ||
184 | denom, w0, w1, o0, o1, (1 << bd) - 1); \ | ||
185 | } | ||
186 | |||
187 | 196 | AVG_FUNCS(8, 8, avx2) | |
188 | 196 | AVG_FUNCS(16, 10, avx2) | |
189 | 196 | AVG_FUNCS(16, 12, avx2) | |
190 | |||
191 | #define ALF_FUNCS(bpc, bd, opt) \ | ||
192 | static void bf(vvc_alf_filter_luma, bd, opt)(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, \ | ||
193 | int width, int height, const int16_t *filter, const int16_t *clip, const int vb_pos) \ | ||
194 | { \ | ||
195 | const int param_stride = (width >> 2) * ALF_NUM_COEFF_LUMA; \ | ||
196 | BF(ff_vvc_alf_filter_luma, bpc, opt)(dst, dst_stride, src, src_stride, width, height, \ | ||
197 | filter, clip, param_stride, vb_pos, (1 << bd) - 1); \ | ||
198 | } \ | ||
199 | static void bf(vvc_alf_filter_chroma, bd, opt)(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *src, ptrdiff_t src_stride, \ | ||
200 | int width, int height, const int16_t *filter, const int16_t *clip, const int vb_pos) \ | ||
201 | { \ | ||
202 | BF(ff_vvc_alf_filter_chroma, bpc, opt)(dst, dst_stride, src, src_stride, width, height, \ | ||
203 | filter, clip, 0, vb_pos,(1 << bd) - 1); \ | ||
204 | } \ | ||
205 | static void bf(vvc_alf_classify, bd, opt)(int *class_idx, int *transpose_idx, \ | ||
206 | const uint8_t *src, ptrdiff_t src_stride, int width, int height, int vb_pos, int *gradient_tmp) \ | ||
207 | { \ | ||
208 | BF(ff_vvc_alf_classify_grad, bpc, opt)(gradient_tmp, src, src_stride, width, height, vb_pos); \ | ||
209 | BF(ff_vvc_alf_classify, bpc, opt)(class_idx, transpose_idx, gradient_tmp, width, height, vb_pos, bd); \ | ||
210 | } \ | ||
211 | |||
212 | 2176 | ALF_FUNCS(8, 8, avx2) | |
213 | 2176 | ALF_FUNCS(16, 10, avx2) | |
214 | 2176 | ALF_FUNCS(16, 12, avx2) | |
215 | |||
216 | #endif | ||
217 | |||
218 | #define SAO_FILTER_FUNC(wd, bitd, opt) \ | ||
219 | void ff_vvc_sao_band_filter_##wd##_##bitd##_##opt(uint8_t *_dst, const uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src, \ | ||
220 | const int16_t *sao_offset_val, int sao_left_class, int width, int height); \ | ||
221 | void ff_vvc_sao_edge_filter_##wd##_##bitd##_##opt(uint8_t *_dst, const uint8_t *_src, ptrdiff_t stride_dst, \ | ||
222 | const int16_t *sao_offset_val, int eo, int width, int height); \ | ||
223 | |||
224 | #define SAO_FILTER_FUNCS(bitd, opt) \ | ||
225 | SAO_FILTER_FUNC(8, bitd, opt) \ | ||
226 | SAO_FILTER_FUNC(16, bitd, opt) \ | ||
227 | SAO_FILTER_FUNC(32, bitd, opt) \ | ||
228 | SAO_FILTER_FUNC(48, bitd, opt) \ | ||
229 | SAO_FILTER_FUNC(64, bitd, opt) \ | ||
230 | SAO_FILTER_FUNC(80, bitd, opt) \ | ||
231 | SAO_FILTER_FUNC(96, bitd, opt) \ | ||
232 | SAO_FILTER_FUNC(112, bitd, opt) \ | ||
233 | SAO_FILTER_FUNC(128, bitd, opt) \ | ||
234 | |||
235 | SAO_FILTER_FUNCS(8, avx2) | ||
236 | SAO_FILTER_FUNCS(10, avx2) | ||
237 | SAO_FILTER_FUNCS(12, avx2) | ||
238 | |||
239 | #define SAO_FILTER_INIT(type, bitd, opt) do { \ | ||
240 | c->sao.type##_filter[0] = ff_vvc_sao_##type##_filter_8_##bitd##_##opt; \ | ||
241 | c->sao.type##_filter[1] = ff_vvc_sao_##type##_filter_16_##bitd##_##opt; \ | ||
242 | c->sao.type##_filter[2] = ff_vvc_sao_##type##_filter_32_##bitd##_##opt; \ | ||
243 | c->sao.type##_filter[3] = ff_vvc_sao_##type##_filter_48_##bitd##_##opt; \ | ||
244 | c->sao.type##_filter[4] = ff_vvc_sao_##type##_filter_64_##bitd##_##opt; \ | ||
245 | c->sao.type##_filter[5] = ff_vvc_sao_##type##_filter_80_##bitd##_##opt; \ | ||
246 | c->sao.type##_filter[6] = ff_vvc_sao_##type##_filter_96_##bitd##_##opt; \ | ||
247 | c->sao.type##_filter[7] = ff_vvc_sao_##type##_filter_112_##bitd##_##opt; \ | ||
248 | c->sao.type##_filter[8] = ff_vvc_sao_##type##_filter_128_##bitd##_##opt; \ | ||
249 | } while (0) | ||
250 | |||
251 | #define SAO_INIT(bitd, opt) do { \ | ||
252 | SAO_FILTER_INIT(band, bitd, opt); \ | ||
253 | SAO_FILTER_INIT(edge, bitd, opt); \ | ||
254 | } while (0) | ||
255 | |||
256 | #define AVG_INIT(bd, opt) do { \ | ||
257 | c->inter.avg = bf(vvc_avg, bd, opt); \ | ||
258 | c->inter.w_avg = bf(vvc_w_avg, bd, opt); \ | ||
259 | } while (0) | ||
260 | |||
261 | #define DMVR_INIT(bd) do { \ | ||
262 | c->inter.dmvr[0][0] = ff_vvc_dmvr_##bd##_avx2; \ | ||
263 | c->inter.dmvr[0][1] = ff_vvc_dmvr_h_##bd##_avx2; \ | ||
264 | c->inter.dmvr[1][0] = ff_vvc_dmvr_v_##bd##_avx2; \ | ||
265 | c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_##bd##_avx2; \ | ||
266 | } while (0) | ||
267 | |||
268 | #define PEL_LINK(dst, C, W, idx1, idx2, name, D, opt) \ | ||
269 | dst[C][W][idx1][idx2] = vvc_put_## name ## _ ## D ## _##opt; \ | ||
270 | dst ## _uni[C][W][idx1][idx2] = ff_h2656_put_uni_ ## name ## _ ## D ## _##opt; \ | ||
271 | |||
272 | #define MC_TAP_LINKS(pointer, C, my, mx, fname, bitd, opt ) \ | ||
273 | PEL_LINK(pointer, C, 1, my , mx , fname##4 , bitd, opt ); \ | ||
274 | PEL_LINK(pointer, C, 2, my , mx , fname##8 , bitd, opt ); \ | ||
275 | PEL_LINK(pointer, C, 3, my , mx , fname##16, bitd, opt ); \ | ||
276 | PEL_LINK(pointer, C, 4, my , mx , fname##32, bitd, opt ); \ | ||
277 | PEL_LINK(pointer, C, 5, my , mx , fname##64, bitd, opt ); \ | ||
278 | PEL_LINK(pointer, C, 6, my , mx , fname##128, bitd, opt ); | ||
279 | |||
280 | #define MC_8TAP_LINKS(pointer, my, mx, fname, bitd, opt) \ | ||
281 | MC_TAP_LINKS(pointer, LUMA, my, mx, fname, bitd, opt) | ||
282 | |||
283 | #define MC_8TAP_LINKS_SSE4(bd) \ | ||
284 | MC_8TAP_LINKS(c->inter.put, 0, 0, pixels, bd, sse4); \ | ||
285 | MC_8TAP_LINKS(c->inter.put, 0, 1, 8tap_h, bd, sse4); \ | ||
286 | MC_8TAP_LINKS(c->inter.put, 1, 0, 8tap_v, bd, sse4); \ | ||
287 | MC_8TAP_LINKS(c->inter.put, 1, 1, 8tap_hv, bd, sse4) | ||
288 | |||
289 | #define MC_4TAP_LINKS(pointer, my, mx, fname, bitd, opt) \ | ||
290 | PEL_LINK(pointer, CHROMA, 0, my , mx , fname##2 , bitd, opt ); \ | ||
291 | MC_TAP_LINKS(pointer, CHROMA, my, mx, fname, bitd, opt) \ | ||
292 | |||
293 | #define MC_4TAP_LINKS_SSE4(bd) \ | ||
294 | MC_4TAP_LINKS(c->inter.put, 0, 0, pixels, bd, sse4); \ | ||
295 | MC_4TAP_LINKS(c->inter.put, 0, 1, 4tap_h, bd, sse4); \ | ||
296 | MC_4TAP_LINKS(c->inter.put, 1, 0, 4tap_v, bd, sse4); \ | ||
297 | MC_4TAP_LINKS(c->inter.put, 1, 1, 4tap_hv, bd, sse4) | ||
298 | |||
299 | #define MC_LINK_SSE4(bd) \ | ||
300 | MC_4TAP_LINKS_SSE4(bd) \ | ||
301 | MC_8TAP_LINKS_SSE4(bd) | ||
302 | |||
303 | #define MC_TAP_LINKS_AVX2(C,tap,bd) do { \ | ||
304 | PEL_LINK(c->inter.put, C, 4, 0, 0, pixels32, bd, avx2) \ | ||
305 | PEL_LINK(c->inter.put, C, 5, 0, 0, pixels64, bd, avx2) \ | ||
306 | PEL_LINK(c->inter.put, C, 6, 0, 0, pixels128, bd, avx2) \ | ||
307 | PEL_LINK(c->inter.put, C, 4, 0, 1, tap##tap_h32, bd, avx2) \ | ||
308 | PEL_LINK(c->inter.put, C, 5, 0, 1, tap##tap_h64, bd, avx2) \ | ||
309 | PEL_LINK(c->inter.put, C, 6, 0, 1, tap##tap_h128, bd, avx2) \ | ||
310 | PEL_LINK(c->inter.put, C, 4, 1, 0, tap##tap_v32, bd, avx2) \ | ||
311 | PEL_LINK(c->inter.put, C, 5, 1, 0, tap##tap_v64, bd, avx2) \ | ||
312 | PEL_LINK(c->inter.put, C, 6, 1, 0, tap##tap_v128, bd, avx2) \ | ||
313 | } while (0) | ||
314 | |||
315 | #define MC_LINKS_AVX2(bd) \ | ||
316 | MC_TAP_LINKS_AVX2(LUMA, 8, bd); \ | ||
317 | MC_TAP_LINKS_AVX2(CHROMA, 4, bd); | ||
318 | |||
319 | #define MC_TAP_LINKS_16BPC_AVX2(C, tap, bd) do { \ | ||
320 | PEL_LINK(c->inter.put, C, 3, 0, 0, pixels16, bd, avx2) \ | ||
321 | PEL_LINK(c->inter.put, C, 3, 0, 1, tap##tap_h16, bd, avx2) \ | ||
322 | PEL_LINK(c->inter.put, C, 3, 1, 0, tap##tap_v16, bd, avx2) \ | ||
323 | PEL_LINK(c->inter.put, C, 3, 1, 1, tap##tap_hv16, bd, avx2) \ | ||
324 | PEL_LINK(c->inter.put, C, 4, 1, 1, tap##tap_hv32, bd, avx2) \ | ||
325 | PEL_LINK(c->inter.put, C, 5, 1, 1, tap##tap_hv64, bd, avx2) \ | ||
326 | PEL_LINK(c->inter.put, C, 6, 1, 1, tap##tap_hv128, bd, avx2) \ | ||
327 | } while (0) | ||
328 | |||
329 | #define MC_LINKS_16BPC_AVX2(bd) \ | ||
330 | MC_TAP_LINKS_16BPC_AVX2(LUMA, 8, bd); \ | ||
331 | MC_TAP_LINKS_16BPC_AVX2(CHROMA, 4, bd); | ||
332 | |||
333 | int ff_vvc_sad_avx2(const int16_t *src0, const int16_t *src1, int dx, int dy, int block_w, int block_h); | ||
334 | #define SAD_INIT() c->inter.sad = ff_vvc_sad_avx2 | ||
335 | |||
336 | #define ALF_INIT(bd) do { \ | ||
337 | c->alf.filter[LUMA] = vvc_alf_filter_luma_##bd##_avx2; \ | ||
338 | c->alf.filter[CHROMA] = vvc_alf_filter_chroma_##bd##_avx2; \ | ||
339 | c->alf.classify = vvc_alf_classify_##bd##_avx2; \ | ||
340 | } while (0) | ||
341 | |||
342 | #endif | ||
343 | |||
344 | |||
345 | #endif // ARCH_X86_64 | ||
346 | |||
347 | 1325 | void ff_vvc_dsp_init_x86(VVCDSPContext *const c, const int bd) | |
348 | { | ||
349 | #if ARCH_X86_64 | ||
350 | 1325 | const int cpu_flags = av_get_cpu_flags(); | |
351 | |||
352 |
3/4✓ Branch 0 taken 152 times.
✓ Branch 1 taken 1056 times.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
|
1325 | switch (bd) { |
353 | 152 | case 8: | |
354 | #if HAVE_SSE4_EXTERNAL | ||
355 |
2/2✓ Branch 0 taken 54 times.
✓ Branch 1 taken 98 times.
|
152 | if (EXTERNAL_SSE4(cpu_flags)) { |
356 | 54 | MC_LINK_SSE4(8); | |
357 | } | ||
358 | #endif | ||
359 | #if HAVE_AVX2_EXTERNAL | ||
360 |
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)) { |
361 | // inter | ||
362 | 9 | AVG_INIT(8, avx2); | |
363 | 9 | DMVR_INIT(8); | |
364 | 9 | MC_LINKS_AVX2(8); | |
365 | 9 | OF_INIT(8); | |
366 | 9 | SAD_INIT(); | |
367 | |||
368 | // filter | ||
369 | 9 | ALF_INIT(8); | |
370 | 9 | SAO_INIT(8, avx2); | |
371 | } | ||
372 | #endif | ||
373 | 152 | break; | |
374 | 1056 | case 10: | |
375 | #if HAVE_SSE4_EXTERNAL | ||
376 |
2/2✓ Branch 0 taken 60 times.
✓ Branch 1 taken 996 times.
|
1056 | if (EXTERNAL_SSE4(cpu_flags)) { |
377 | 60 | MC_LINK_SSE4(10); | |
378 | } | ||
379 | #endif | ||
380 | #if HAVE_AVX2_EXTERNAL | ||
381 |
3/4✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1046 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
|
1056 | if (EXTERNAL_AVX2_FAST(cpu_flags)) { |
382 | // inter | ||
383 | 10 | AVG_INIT(10, avx2); | |
384 | 10 | DMVR_INIT(10); | |
385 | 10 | MC_LINKS_AVX2(10); | |
386 | 10 | MC_LINKS_16BPC_AVX2(10); | |
387 | 10 | OF_INIT(10); | |
388 | 10 | SAD_INIT(); | |
389 | |||
390 | // filter | ||
391 | 10 | ALF_INIT(10); | |
392 | 10 | SAO_INIT(10, avx2); | |
393 | } | ||
394 | #endif | ||
395 | 1056 | break; | |
396 | 117 | case 12: | |
397 | #if HAVE_SSE4_EXTERNAL | ||
398 |
2/2✓ Branch 0 taken 54 times.
✓ Branch 1 taken 63 times.
|
117 | if (EXTERNAL_SSE4(cpu_flags)) { |
399 | 54 | MC_LINK_SSE4(12); | |
400 | } | ||
401 | #endif | ||
402 | #if HAVE_AVX2_EXTERNAL | ||
403 |
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)) { |
404 | // inter | ||
405 | 9 | AVG_INIT(12, avx2); | |
406 | 9 | DMVR_INIT(12); | |
407 | 9 | MC_LINKS_AVX2(12); | |
408 | 9 | MC_LINKS_16BPC_AVX2(12); | |
409 | 9 | OF_INIT(12); | |
410 | 9 | SAD_INIT(); | |
411 | |||
412 | // filter | ||
413 | 9 | ALF_INIT(12); | |
414 | 9 | SAO_INIT(12, avx2); | |
415 | } | ||
416 | #endif | ||
417 | 117 | break; | |
418 | ✗ | default: | |
419 | ✗ | break; | |
420 | } | ||
421 | #endif | ||
422 | 1325 | } | |
423 |