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
147147 %assign i i+mmsize
148148 %endrep
149149
150−%if %2 == 48
150+%if %2 == 48 || %2 == 80 || %2 == 112
151151 INIT_XMM cpuname
152152
153153 mova m13, [srcq + i]
@@ -160,7 +160,7 @@ INIT_XMM cpuname · 6 unmodified lines
160160 %if cpuflag(avx2)
161161 INIT_YMM cpuname
162162 %endif
163−%endif ; %2 == 48
163+%endif ; %2 == 48 || %2 == 80 || %2 == 112
164164
165165 add dstq, dststrideq ; dst += dststride
166166 add srcq, srcstrideq ; src += srcstride
@@ -280,7 +280,7 @@ align 16 · 113 unmodified lines
280280 %assign i i+mmsize
281281 %endrep
282282
283−%if %2 == 48
283+%if %2 == 48 || %2 == 80 || %2 == 112
284284 INIT_XMM cpuname
285285
286286 mova m1, [srcq + i]
@@ -291,7 +291,7 @@ INIT_XMM cpuname · 4 unmodified lines
291291 %if cpuflag(avx2)
292292 INIT_YMM cpuname
293293 %endif
294−%endif
294+%endif ; %2 == 48 || %2 == 80 || %2 == 112
295295
296296 add dstq, dststrideq
297297 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
88 x86/vvc/mc.o \
99 x86/vvc/of.o \
1010 x86/vvc/sad.o \
11+ x86/vvc/sao.o \
12+ x86/vvc/sao_10bit.o \
1113 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
215215
216216 #endif
217217
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+
218256 #define AVG_INIT(bd, opt) do { \
219257 c->inter.avg = bf(vvc_avg, bd, opt); \
220258 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
329367
330368 // filter
331369 ALF_INIT(8);
370+ SAO_INIT(8, avx2);
332371 }
333372 #endif
334373 break;
@@ -350,6 +389,7 @@ void ff_vvc_dsp_init_x86(VVCDSPContext *const c, const int bd) · 15 unmodified lines
350389
351390 // filter
352391 ALF_INIT(10);
392+ SAO_INIT(10, avx2);
353393 }
354394 #endif
355395 break;
@@ -371,6 +411,7 @@ void ff_vvc_dsp_init_x86(VVCDSPContext *const c, const int bd) · 15 unmodified lines
371411
372412 // filter
373413 ALF_INIT(12);
414+ SAO_INIT(12, avx2);
374415 }
375416 #endif
376417 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
32+VVC_SAO_BAND_FILTER 8, 0
33+VVC_SAO_BAND_FILTER 16, 1
34+VVC_SAO_BAND_FILTER 32, 2
35+VVC_SAO_BAND_FILTER 48, 2
36+VVC_SAO_BAND_FILTER 64, 4
37+VVC_SAO_BAND_FILTER 80, 4
38+VVC_SAO_BAND_FILTER 96, 6
39+VVC_SAO_BAND_FILTER 112, 6
40+VVC_SAO_BAND_FILTER 128, 8
41+%endmacro
42+
43+%if HAVE_AVX2_EXTERNAL
44+INIT_XMM avx2
45+VVC_SAO_BAND_FILTER 8, 0
46+VVC_SAO_BAND_FILTER 16, 1
47+INIT_YMM avx2
48+VVC_SAO_BAND_FILTER 32, 1
49+VVC_SAO_BAND_FILTER 48, 1
50+VVC_SAO_BAND_FILTER 64, 2
51+VVC_SAO_BAND_FILTER 80, 2
52+VVC_SAO_BAND_FILTER 96, 3
53+VVC_SAO_BAND_FILTER 112, 3
54+VVC_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
62+INIT_XMM avx2
63+VVC_SAO_EDGE_FILTER 8, 0
64+VVC_SAO_EDGE_FILTER 16, 1, a
65+INIT_YMM avx2
66+VVC_SAO_EDGE_FILTER 32, 1, a
67+VVC_SAO_EDGE_FILTER 48, 1, u
68+VVC_SAO_EDGE_FILTER 64, 2, a
69+VVC_SAO_EDGE_FILTER 80, 2, u
70+VVC_SAO_EDGE_FILTER 96, 3, a
71+VVC_SAO_EDGE_FILTER 112, 3, u
72+VVC_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+
48+INIT_XMM sse2
49+VVC_SAO_BAND_FILTER_FUNCS
50+INIT_XMM avx
51+VVC_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+
69+VVC_SAO_BAND_FILTER_FUNCS_AVX2 10
70+VVC_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+
90+INIT_XMM sse2
91+VVC_SAO_EDGE_FILTER_FUNCS 10
92+VVC_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+
110+VVC_SAO_EDGE_FILTER_FUNCS_AVX2 10
111+VVC_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