History

x86/vvcdec: sao, add avx2 support

This is a part of Google Summer of Code 2023

Shaun Loo committed 1 year ago

Commit bed17691 parent 69f63c65 files · +233 −4Browse files

Unified · Split

5 files
  1. libavcodec/x86/h26x/h2656_sao.asm +4 −4
  2. libavcodec/x86/vvc/Makefile +2 −0
  3. libavcodec/x86/vvc/dsp_init.c +41 −0
  4. libavcodec/x86/vvc/sao.asm +73 −0
  5. libavcodec/x86/vvc/sao_10bit.asm +113 −0
libavcodec/x86/h26x/h2656_sao.asm+4−4
@@ -147,7 +147,7 @@ align 16 · 146 unmodified lines
147%assign i i+mmsize147%assign i i+mmsize
148%endrep148%endrep
149 149
150%if %2 == 48150%if %2 == 48 || %2 == 80 || %2 == 112
151INIT_XMM cpuname151INIT_XMM cpuname
152 152
153 mova m13, [srcq + i]153 mova m13, [srcq + i]
@@ -160,7 +160,7 @@ INIT_XMM cpuname · 6 unmodified lines
160%if cpuflag(avx2)160%if cpuflag(avx2)
161INIT_YMM cpuname161INIT_YMM cpuname
162%endif162%endif
163%endif ; %2 == 48163%endif ; %2 == 48 || %2 == 80 || %2 == 112
164 164
165 add dstq, dststrideq ; dst += dststride165 add dstq, dststrideq ; dst += dststride
166 add srcq, srcstrideq ; src += srcstride166 add srcq, srcstrideq ; src += srcstride
@@ -280,7 +280,7 @@ align 16 · 113 unmodified lines
280%assign i i+mmsize280%assign i i+mmsize
281%endrep281%endrep
282 282
283%if %2 == 48283%if %2 == 48 || %2 == 80 || %2 == 112
284INIT_XMM cpuname284INIT_XMM cpuname
285 285
286 mova m1, [srcq + i]286 mova m1, [srcq + i]
@@ -291,7 +291,7 @@ INIT_XMM cpuname · 4 unmodified lines
291%if cpuflag(avx2)291%if cpuflag(avx2)
292INIT_YMM cpuname292INIT_YMM cpuname
293%endif293%endif
294%endif294%endif ; %2 == 48 || %2 == 80 || %2 == 112
295 295
296 add dstq, dststrideq296 add dstq, dststrideq
297 add srcq, EDGE_SRCSTRIDE297 add srcq, EDGE_SRCSTRIDE
libavcodec/x86/vvc/Makefile+2−0
@@ -8,4 +8,6 @@ X86ASM-OBJS-$(CONFIG_VVC_DECODER) += x86/vvc/alf.o \ · 7 unmodified lines
8 x86/vvc/mc.o \8 x86/vvc/mc.o \
9 x86/vvc/of.o \9 x86/vvc/of.o \
10 x86/vvc/sad.o \10 x86/vvc/sad.o \
11 x86/vvc/sao.o \
12 x86/vvc/sao_10bit.o \
11 x86/h26x/h2656_inter.o13 x86/h26x/h2656_inter.o
libavcodec/x86/vvc/dsp_init.c+41−0
@@ -215,6 +215,44 @@ ALF_FUNCS(16, 12, avx2) · 214 unmodified lines
215 215
216#endif216#endif
217 217
218#define SAO_FILTER_FUNC(wd, bitd, opt) \
219void 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); \
221void 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
235SAO_FILTER_FUNCS(8, avx2)
236SAO_FILTER_FUNCS(10, avx2)
237SAO_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
218#define AVG_INIT(bd, opt) do { \256#define AVG_INIT(bd, opt) do { \
219 c->inter.avg = bf(vvc_avg, bd, opt); \257 c->inter.avg = bf(vvc_avg, bd, opt); \
220 c->inter.w_avg = bf(vvc_w_avg, bd, opt); \258 c->inter.w_avg = bf(vvc_w_avg, bd, opt); \
@@ -329,6 +367,7 @@ void ff_vvc_dsp_init_x86(VVCDSPContext *const c, const int bd) · 108 unmodified lines
329 367
330 // filter368 // filter
331 ALF_INIT(8);369 ALF_INIT(8);
370 SAO_INIT(8, avx2);
332 }371 }
333#endif372#endif
334 break;373 break;
@@ -350,6 +389,7 @@ void ff_vvc_dsp_init_x86(VVCDSPContext *const c, const int bd) · 15 unmodified lines
350 389
351 // filter390 // filter
352 ALF_INIT(10);391 ALF_INIT(10);
392 SAO_INIT(10, avx2);
353 }393 }
354#endif394#endif
355 break;395 break;
@@ -371,6 +411,7 @@ void ff_vvc_dsp_init_x86(VVCDSPContext *const c, const int bd) · 15 unmodified lines
371 411
372 // filter412 // filter
373 ALF_INIT(12);413 ALF_INIT(12);
414 SAO_INIT(12, avx2);
374 }415 }
375#endif416#endif
376 break;417 break;
libavcodec/x86/vvc/sao.asm+73−0
@@ -0,0 +1,73 @@
1;******************************************************************************
2;* SIMD optimized SAO functions for VVC 8bit decoding
3;*
4;* Copyright (c) 2024 Shaun Loo
5;* Copyright (c) 2024 Nuo Mi
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%define MAX_PB_SIZE 128
25%include "libavcodec/x86/h26x/h2656_sao.asm"
26
27%macro VVC_SAO_BAND_FILTER 2
28 H2656_SAO_BAND_FILTER vvc, %1, %2
29%endmacro
30
31%macro VVC_SAO_BAND_FILTER_FUNCS 0
32VVC_SAO_BAND_FILTER 8, 0
33VVC_SAO_BAND_FILTER 16, 1
34VVC_SAO_BAND_FILTER 32, 2
35VVC_SAO_BAND_FILTER 48, 2
36VVC_SAO_BAND_FILTER 64, 4
37VVC_SAO_BAND_FILTER 80, 4
38VVC_SAO_BAND_FILTER 96, 6
39VVC_SAO_BAND_FILTER 112, 6
40VVC_SAO_BAND_FILTER 128, 8
41%endmacro
42
43%if HAVE_AVX2_EXTERNAL
44INIT_XMM avx2
45VVC_SAO_BAND_FILTER 8, 0
46VVC_SAO_BAND_FILTER 16, 1
47INIT_YMM avx2
48VVC_SAO_BAND_FILTER 32, 1
49VVC_SAO_BAND_FILTER 48, 1
50VVC_SAO_BAND_FILTER 64, 2
51VVC_SAO_BAND_FILTER 80, 2
52VVC_SAO_BAND_FILTER 96, 3
53VVC_SAO_BAND_FILTER 112, 3
54VVC_SAO_BAND_FILTER 128, 4
55%endif
56
57%macro VVC_SAO_EDGE_FILTER 2-3
58 H2656_SAO_EDGE_FILTER vvc, %{1:-1}
59%endmacro
60
61%if HAVE_AVX2_EXTERNAL
62INIT_XMM avx2
63VVC_SAO_EDGE_FILTER 8, 0
64VVC_SAO_EDGE_FILTER 16, 1, a
65INIT_YMM avx2
66VVC_SAO_EDGE_FILTER 32, 1, a
67VVC_SAO_EDGE_FILTER 48, 1, u
68VVC_SAO_EDGE_FILTER 64, 2, a
69VVC_SAO_EDGE_FILTER 80, 2, u
70VVC_SAO_EDGE_FILTER 96, 3, a
71VVC_SAO_EDGE_FILTER 112, 3, u
72VVC_SAO_EDGE_FILTER 128, 4, a
73%endif
libavcodec/x86/vvc/sao_10bit.asm+113−0
@@ -0,0 +1,113 @@
1;******************************************************************************
2;* SIMD optimized SAO functions for VVC 10/12bit decoding
3;*
4;* Copyright (c) 2024 Shaun Loo
5;* Copyright (c) 2024 Nuo Mi
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%define MAX_PB_SIZE 128
25%include "libavcodec/x86/h26x/h2656_sao_10bit.asm"
26
27%macro VVC_SAO_BAND_FILTER 3
28 H2656_SAO_BAND_FILTER vvc, %1, %2, %3
29%endmacro
30
31%macro VVC_SAO_BAND_FILTER_FUNCS 1
32 VVC_SAO_BAND_FILTER %1, 8, 1
33 VVC_SAO_BAND_FILTER %1, 16, 2
34 VVC_SAO_BAND_FILTER %1, 32, 4
35 VVC_SAO_BAND_FILTER %1, 48, 6
36 VVC_SAO_BAND_FILTER %1, 64, 8
37 VVC_SAO_BAND_FILTER %1, 80, 10
38 VVC_SAO_BAND_FILTER %1, 96, 12
39 VVC_SAO_BAND_FILTER %1, 112, 14
40 VVC_SAO_BAND_FILTER %1, 128, 16
41%endmacro
42
43%macro VVC_SAO_BAND_FILTER_FUNCS 0
44 VVC_SAO_BAND_FILTER_FUNCS 10
45 VVC_SAO_BAND_FILTER_FUNCS 12
46%endmacro
47
48INIT_XMM sse2
49VVC_SAO_BAND_FILTER_FUNCS
50INIT_XMM avx
51VVC_SAO_BAND_FILTER_FUNCS
52
53%if HAVE_AVX2_EXTERNAL
54
55%macro VVC_SAO_BAND_FILTER_FUNCS_AVX2 1
56 INIT_XMM avx2
57 VVC_SAO_BAND_FILTER %1, 8, 1
58 INIT_YMM avx2
59 VVC_SAO_BAND_FILTER %1, 16, 1
60 VVC_SAO_BAND_FILTER %1, 32, 2
61 VVC_SAO_BAND_FILTER %1, 48, 3
62 VVC_SAO_BAND_FILTER %1, 64, 4
63 VVC_SAO_BAND_FILTER %1, 80, 5
64 VVC_SAO_BAND_FILTER %1, 96, 6
65 VVC_SAO_BAND_FILTER %1, 112, 7
66 VVC_SAO_BAND_FILTER %1, 128, 8
67%endmacro
68
69VVC_SAO_BAND_FILTER_FUNCS_AVX2 10
70VVC_SAO_BAND_FILTER_FUNCS_AVX2 12
71
72%endif ; HAVE_AVX2_EXTERNAL
73
74%macro VVC_SAO_EDGE_FILTER 3
75 H2656_SAO_EDGE_FILTER vvc, %1, %2, %3
76%endmacro
77
78%macro VVC_SAO_EDGE_FILTER_FUNCS 1
79 VVC_SAO_EDGE_FILTER %1, 8, 1
80 VVC_SAO_EDGE_FILTER %1, 16, 2
81 VVC_SAO_EDGE_FILTER %1, 32, 4
82 VVC_SAO_EDGE_FILTER %1, 48, 6
83 VVC_SAO_EDGE_FILTER %1, 64, 8
84 VVC_SAO_EDGE_FILTER %1, 80, 10
85 VVC_SAO_EDGE_FILTER %1, 96, 12
86 VVC_SAO_EDGE_FILTER %1, 112, 14
87 VVC_SAO_EDGE_FILTER %1, 128, 16
88%endmacro
89
90INIT_XMM sse2
91VVC_SAO_EDGE_FILTER_FUNCS 10
92VVC_SAO_EDGE_FILTER_FUNCS 12
93
94%if HAVE_AVX2_EXTERNAL
95
96%macro VVC_SAO_EDGE_FILTER_FUNCS_AVX2 1
97 INIT_XMM avx2
98 VVC_SAO_EDGE_FILTER %1, 8, 1
99 INIT_YMM avx2
100 VVC_SAO_EDGE_FILTER %1, 16, 1
101 VVC_SAO_EDGE_FILTER %1, 32, 2
102 VVC_SAO_EDGE_FILTER %1, 48, 3
103 VVC_SAO_EDGE_FILTER %1, 64, 4
104 VVC_SAO_EDGE_FILTER %1, 80, 5
105 VVC_SAO_EDGE_FILTER %1, 96, 6
106 VVC_SAO_EDGE_FILTER %1, 112, 7
107 VVC_SAO_EDGE_FILTER %1, 128, 8
108%endmacro
109
110VVC_SAO_EDGE_FILTER_FUNCS_AVX2 10
111VVC_SAO_EDGE_FILTER_FUNCS_AVX2 12
112
113%endif ; HAVE_AVX2_EXTERNAL

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t