ffmpeg-cvslog
Threads by month
- ----- 2026 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
October 2024
- 1 participants
- 424 discussions
ffmpeg | branch: master | Zhao Zhili <zhilizhao(a)tencent.com> | Sun Sep 22 11:39:14 2024 +0800| [240c16bbc6ef723139793fea6e94516dfb058db9] | committer: Nuo Mi
avcodec/vvc: Don't use large array on stack
tmp_array in dmvr_hv takes 33024 bytes on stack, which can be
dangerous.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=240c16bbc6ef72313…
---
libavcodec/vvc/inter_template.c | 33 ++++++++++++++++++---------------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/libavcodec/vvc/inter_template.c b/libavcodec/vvc/inter_template.c
index c073a73e76..aee4994c17 100644
--- a/libavcodec/vvc/inter_template.c
+++ b/libavcodec/vvc/inter_template.c
@@ -472,6 +472,9 @@ static void FUNC(apply_bdof)(uint8_t *_dst, const ptrdiff_t _dst_stride, const i
(filter[0] * src[x] + \
filter[1] * src[x + stride])
+#define DMVR_FILTER2(filter, src0, src1) \
+ (filter[0] * src0 + filter[1] * src1)
+
//8.5.3.2.2 Luma sample bilinear interpolation process
static void FUNC(dmvr)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
const int height, const intptr_t mx, const intptr_t my, const int width)
@@ -541,31 +544,31 @@ static void FUNC(dmvr_v)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src
static void FUNC(dmvr_hv)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
const int height, const intptr_t mx, const intptr_t my, const int width)
{
- int16_t tmp_array[(MAX_PB_SIZE + BILINEAR_EXTRA) * MAX_PB_SIZE];
- int16_t *tmp = tmp_array;
+ int16_t tmp_array[MAX_PB_SIZE * 2];
+ int16_t *tmp0 = tmp_array;
+ int16_t *tmp1 = tmp_array + MAX_PB_SIZE;
const pixel *src = (const pixel*)_src;
const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
- const int8_t *filter = ff_vvc_inter_luma_dmvr_filters[mx];
+ const int8_t *filter_x = ff_vvc_inter_luma_dmvr_filters[mx];
+ const int8_t *filter_y = ff_vvc_inter_luma_dmvr_filters[my];
const int shift1 = BIT_DEPTH - 6;
const int offset1 = 1 << (shift1 - 1);
const int shift2 = 4;
const int offset2 = 1 << (shift2 - 1);
src -= BILINEAR_EXTRA_BEFORE * src_stride;
- for (int y = 0; y < height + BILINEAR_EXTRA; y++) {
- for (int x = 0; x < width; x++)
- tmp[x] = (DMVR_FILTER(src, 1) + offset1) >> shift1;
- src += src_stride;
- tmp += MAX_PB_SIZE;
- }
+ for (int x = 0; x < width; x++)
+ tmp0[x] = (DMVR_FILTER2(filter_x, src[x], src[x + 1]) + offset1) >> shift1;
+ src += src_stride;
- tmp = tmp_array + BILINEAR_EXTRA_BEFORE * MAX_PB_SIZE;
- filter = ff_vvc_inter_luma_dmvr_filters[my];
- for (int y = 0; y < height; y++) {
- for (int x = 0; x < width; x++)
- dst[x] = (DMVR_FILTER(tmp, MAX_PB_SIZE) + offset2) >> shift2;
- tmp += MAX_PB_SIZE;
+ for (int y = 1; y < height + BILINEAR_EXTRA; y++) {
+ for (int x = 0; x < width; x++) {
+ tmp1[x] = (DMVR_FILTER2(filter_x, src[x], src[x + 1]) + offset1) >> shift1;
+ dst[x] = (DMVR_FILTER2(filter_y, tmp0[x], tmp1[x]) + offset2) >> shift2;
+ }
+ src += src_stride;
dst += MAX_PB_SIZE;
+ FFSWAP(int16_t *, tmp0, tmp1);
}
}
1
0
ffmpeg | branch: master | Zhao Zhili <zhilizhao(a)tencent.com> | Sun Sep 29 20:02:48 2024 +0800| [5988a2729bc21ade237a9d0f9bb1112f39870f56] | committer: Nuo Mi
aarch64/vvc: Add dmvr
dmvr_8_12x20_c: 1.5 ( 1.00x)
dmvr_8_12x20_neon: 0.2 ( 6.56x)
dmvr_8_20x12_c: 1.0 ( 1.00x)
dmvr_8_20x12_neon: 0.2 ( 4.33x)
dmvr_8_20x20_c: 1.7 ( 1.00x)
dmvr_8_20x20_neon: 0.5 ( 3.63x)
dmvr_12_12x20_c: 2.2 ( 1.00x)
dmvr_12_12x20_neon: 0.5 ( 4.68x)
dmvr_12_20x12_c: 2.0 ( 1.00x)
dmvr_12_20x12_neon: 0.5 ( 4.16x)
dmvr_12_20x20_c: 3.7 ( 1.00x)
dmvr_12_20x20_neon: 0.7 ( 5.14x)
Signed-off-by: Zhao Zhili <zhilizhao(a)tencent.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5988a2729bc21ade2…
---
libavcodec/aarch64/vvc/dsp_init.c | 4 ++
libavcodec/aarch64/vvc/inter.S | 87 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 90 insertions(+), 1 deletion(-)
diff --git a/libavcodec/aarch64/vvc/dsp_init.c b/libavcodec/aarch64/vvc/dsp_init.c
index b5f6f6da93..e47f1ab4cc 100644
--- a/libavcodec/aarch64/vvc/dsp_init.c
+++ b/libavcodec/aarch64/vvc/dsp_init.c
@@ -90,6 +90,8 @@ W_AVG_FUN(12)
const uint8_t *_src, ptrdiff_t _src_stride, int height, \
intptr_t mx, intptr_t my, int width);
+DMVR_FUN(, 8)
+DMVR_FUN(, 12)
DMVR_FUN(hv_, 8)
DMVR_FUN(hv_, 10)
DMVR_FUN(hv_, 12)
@@ -166,6 +168,7 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd)
c->inter.avg = ff_vvc_avg_8_neon;
c->inter.w_avg = vvc_w_avg_8;
+ c->inter.dmvr[0][0] = ff_vvc_dmvr_8_neon;
c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_8_neon;
for (int i = 0; i < FF_ARRAY_ELEMS(c->sao.band_filter); i++)
@@ -215,6 +218,7 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd)
} else if (bd == 12) {
c->inter.avg = ff_vvc_avg_12_neon;
c->inter.w_avg = vvc_w_avg_12;
+ c->inter.dmvr[0][0] = ff_vvc_dmvr_12_neon;
c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_12_neon;
c->alf.filter[LUMA] = alf_filter_luma_12_neon;
diff --git a/libavcodec/aarch64/vvc/inter.S b/libavcodec/aarch64/vvc/inter.S
index 4fc8def133..b6b079b569 100644
--- a/libavcodec/aarch64/vvc/inter.S
+++ b/libavcodec/aarch64/vvc/inter.S
@@ -235,7 +235,7 @@ vvc_avg w_avg, 12
* x5: intptr_t my
* w6: int width
*/
-function ff_vvc_dmvr_hv_8_neon, export=1
+function ff_vvc_dmvr_8_neon, export=1
dst .req x0
src .req x1
src_stride .req x2
@@ -243,6 +243,91 @@ function ff_vvc_dmvr_hv_8_neon, export=1
mx .req x4
my .req x5
width .req w6
+
+ sxtw x6, w6
+ mov x7, #(VVC_MAX_PB_SIZE * 2 + 8)
+ cmp width, #16
+ sub src_stride, src_stride, x6
+ cset w15, gt // width > 16
+ movi v16.8h, #2 // DMVR_SHIFT
+ sub x7, x7, x6, lsl #1
+1:
+ cbz w15, 2f
+ ldr q0, [src], #16
+ uxtl v1.8h, v0.8b
+ uxtl2 v2.8h, v0.16b
+ ushl v1.8h, v1.8h, v16.8h
+ ushl v2.8h, v2.8h, v16.8h
+ stp q1, q2, [dst], #32
+ b 3f
+2:
+ ldr d0, [src], #8
+ uxtl v1.8h, v0.8b
+ ushl v1.8h, v1.8h, v16.8h
+ str q1, [dst], #16
+3:
+ subs height, height, #1
+ ldr s3, [src], #4
+ uxtl v4.8h, v3.8b
+ ushl v4.4h, v4.4h, v16.4h
+ st1 {v4.4h}, [dst], x7
+
+ add src, src, src_stride
+ b.ne 1b
+
+ ret
+endfunc
+
+function ff_vvc_dmvr_12_neon, export=1
+ sxtw x6, w6
+ mov x7, #(VVC_MAX_PB_SIZE * 2 + 8)
+ cmp width, #16
+ sub src_stride, src_stride, x6, lsl #1
+ cset w15, gt // width > 16
+ movi v16.8h, #2 // offset4
+ sub x7, x7, x6, lsl #1
+1:
+ cbz w15, 2f
+ ldp q0, q1, [src], #32
+ uaddl v2.4s, v0.4h, v16.4h
+ uaddl2 v3.4s, v0.8h, v16.8h
+ uaddl v4.4s, v1.4h, v16.4h
+ uaddl2 v5.4s, v1.8h, v16.8h
+ ushr v2.4s, v2.4s, #2
+ ushr v3.4s, v3.4s, #2
+ ushr v4.4s, v4.4s, #2
+ ushr v5.4s, v5.4s, #2
+ uqxtn v2.4h, v2.4s
+ uqxtn2 v2.8h, v3.4s
+ uqxtn v4.4h, v4.4s
+ uqxtn2 v4.8h, v5.4s
+
+ stp q2, q4, [dst], #32
+ b 3f
+2:
+ ldr q0, [src], #16
+ uaddl v2.4s, v0.4h, v16.4h
+ uaddl2 v3.4s, v0.8h, v16.8h
+ ushr v2.4s, v2.4s, #2
+ ushr v3.4s, v3.4s, #2
+ uqxtn v2.4h, v2.4s
+ uqxtn2 v2.8h, v3.4s
+ str q2, [dst], #16
+3:
+ subs height, height, #1
+ ldr d0, [src], #8
+ uaddl v3.4s, v0.4h, v16.4h
+ ushr v3.4s, v3.4s, #2
+ uqxtn v3.4h, v3.4s
+ st1 {v3.4h}, [dst], x7
+
+ add src, src, src_stride
+ b.ne 1b
+
+ ret
+endfunc
+
+function ff_vvc_dmvr_hv_8_neon, export=1
tmp0 .req x7
tmp1 .req x8
1
0
ffmpeg | branch: master | Zhao Zhili <zhilizhao(a)tencent.com> | Sun Sep 29 20:02:43 2024 +0800| [bcd65ebd8fcdc4bf81db8a36bac0d7e4ddab0449] | committer: Nuo Mi
aarch64/vvc: Add dmvr_hv
dmvr_hv_8_12x20_c: 8.0 ( 1.00x)
dmvr_hv_8_12x20_neon: 1.2 ( 6.62x)
dmvr_hv_8_20x12_c: 8.0 ( 1.00x)
dmvr_hv_8_20x12_neon: 0.9 ( 8.37x)
dmvr_hv_8_20x20_c: 12.9 ( 1.00x)
dmvr_hv_8_20x20_neon: 1.7 ( 7.62x)
dmvr_hv_10_12x20_c: 7.0 ( 1.00x)
dmvr_hv_10_12x20_neon: 1.7 ( 4.09x)
dmvr_hv_10_20x12_c: 7.0 ( 1.00x)
dmvr_hv_10_20x12_neon: 1.7 ( 4.09x)
dmvr_hv_10_20x20_c: 11.2 ( 1.00x)
dmvr_hv_10_20x20_neon: 2.7 ( 4.15x)
dmvr_hv_12_12x20_c: 6.5 ( 1.00x)
dmvr_hv_12_12x20_neon: 1.7 ( 3.79x)
dmvr_hv_12_20x12_c: 6.5 ( 1.00x)
dmvr_hv_12_20x12_neon: 1.7 ( 3.79x)
dmvr_hv_12_20x20_c: 10.2 ( 1.00x)
dmvr_hv_12_20x20_neon: 2.2 ( 4.64x)
Signed-off-by: Zhao Zhili <zhilizhao(a)tencent.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bcd65ebd8fcdc4bf8…
---
libavcodec/aarch64/vvc/dsp_init.c | 12 ++
libavcodec/aarch64/vvc/inter.S | 307 ++++++++++++++++++++++++++++++++++++++
2 files changed, 319 insertions(+)
diff --git a/libavcodec/aarch64/vvc/dsp_init.c b/libavcodec/aarch64/vvc/dsp_init.c
index ebe58a2ba5..b5f6f6da93 100644
--- a/libavcodec/aarch64/vvc/dsp_init.c
+++ b/libavcodec/aarch64/vvc/dsp_init.c
@@ -85,6 +85,15 @@ W_AVG_FUN(8)
W_AVG_FUN(10)
W_AVG_FUN(12)
+#define DMVR_FUN(fn, bd) \
+ void ff_vvc_dmvr_ ## fn ## bd ## _neon(int16_t *dst, \
+ const uint8_t *_src, ptrdiff_t _src_stride, int height, \
+ intptr_t mx, intptr_t my, int width);
+
+DMVR_FUN(hv_, 8)
+DMVR_FUN(hv_, 10)
+DMVR_FUN(hv_, 12)
+
void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd)
{
int cpu_flags = av_get_cpu_flags();
@@ -157,6 +166,7 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd)
c->inter.avg = ff_vvc_avg_8_neon;
c->inter.w_avg = vvc_w_avg_8;
+ c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_8_neon;
for (int i = 0; i < FF_ARRAY_ELEMS(c->sao.band_filter); i++)
c->sao.band_filter[i] = ff_h26x_sao_band_filter_8x8_8_neon;
@@ -198,12 +208,14 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd)
} else if (bd == 10) {
c->inter.avg = ff_vvc_avg_10_neon;
c->inter.w_avg = vvc_w_avg_10;
+ c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_10_neon;
c->alf.filter[LUMA] = alf_filter_luma_10_neon;
c->alf.filter[CHROMA] = alf_filter_chroma_10_neon;
} else if (bd == 12) {
c->inter.avg = ff_vvc_avg_12_neon;
c->inter.w_avg = vvc_w_avg_12;
+ c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_12_neon;
c->alf.filter[LUMA] = alf_filter_luma_12_neon;
c->alf.filter[CHROMA] = alf_filter_chroma_12_neon;
diff --git a/libavcodec/aarch64/vvc/inter.S b/libavcodec/aarch64/vvc/inter.S
index c4c6ab1a72..4fc8def133 100644
--- a/libavcodec/aarch64/vvc/inter.S
+++ b/libavcodec/aarch64/vvc/inter.S
@@ -226,3 +226,310 @@ vvc_avg avg, 12
vvc_avg w_avg, 8
vvc_avg w_avg, 10
vvc_avg w_avg, 12
+
+/* x0: int16_t *dst
+ * x1: const uint8_t *_src
+ * x2: ptrdiff_t _src_stride
+ * w3: int height
+ * x4: intptr_t mx
+ * x5: intptr_t my
+ * w6: int width
+ */
+function ff_vvc_dmvr_hv_8_neon, export=1
+ dst .req x0
+ src .req x1
+ src_stride .req x2
+ height .req w3
+ mx .req x4
+ my .req x5
+ width .req w6
+ tmp0 .req x7
+ tmp1 .req x8
+
+ sub sp, sp, #(VVC_MAX_PB_SIZE * 4)
+
+ movrel x9, X(ff_vvc_inter_luma_dmvr_filters)
+ add x12, x9, mx, lsl #1
+ ldrb w10, [x12]
+ ldrb w11, [x12, #1]
+ mov tmp0, sp
+ add tmp1, tmp0, #(VVC_MAX_PB_SIZE * 2)
+ // We know the value are positive
+ dup v0.8h, w10 // filter_x[0]
+ dup v1.8h, w11 // filter_x[1]
+
+ add x12, x9, my, lsl #1
+ ldrb w10, [x12]
+ ldrb w11, [x12, #1]
+ sxtw x6, w6
+ movi v30.8h, #(1 << (8 - 7)) // offset1
+ movi v31.8h, #8 // offset2
+ dup v2.8h, w10 // filter_y[0]
+ dup v3.8h, w11 // filter_y[1]
+
+ // Valid value for width can only be 8 + 4, 16 + 4
+ cmp width, #16
+ mov w10, #0 // start filter_y or not
+ add height, height, #1
+ sub dst, dst, #(VVC_MAX_PB_SIZE * 2)
+ sub src_stride, src_stride, x6
+ cset w15, gt // width > 16
+1:
+ mov x12, tmp0
+ mov x13, tmp1
+ mov x14, dst
+ cbz w15, 2f
+
+ // width > 16
+ ldur q5, [src, #1]
+ ldr q4, [src], #16
+ uxtl v7.8h, v5.8b
+ uxtl2 v17.8h, v5.16b
+ uxtl v6.8h, v4.8b
+ uxtl2 v16.8h, v4.16b
+ mul v6.8h, v6.8h, v0.8h
+ mul v16.8h, v16.8h, v0.8h
+ mla v6.8h, v7.8h, v1.8h
+ mla v16.8h, v17.8h, v1.8h
+ add v6.8h, v6.8h, v30.8h
+ add v16.8h, v16.8h, v30.8h
+ ushr v6.8h, v6.8h, #(8 - 6)
+ ushr v7.8h, v16.8h, #(8 - 6)
+ stp q6, q7, [x13], #32
+
+ cbz w10, 3f
+
+ ldp q16, q17, [x12], #32
+ mul v16.8h, v16.8h, v2.8h
+ mul v17.8h, v17.8h, v2.8h
+ mla v16.8h, v6.8h, v3.8h
+ mla v17.8h, v7.8h, v3.8h
+ add v16.8h, v16.8h, v31.8h
+ add v17.8h, v17.8h, v31.8h
+ ushr v16.8h, v16.8h, #4
+ ushr v17.8h, v17.8h, #4
+ stp q16, q17, [x14], #32
+ b 3f
+2:
+ // width > 8
+ ldur d5, [src, #1]
+ ldr d4, [src], #8
+ uxtl v7.8h, v5.8b
+ uxtl v6.8h, v4.8b
+ mul v6.8h, v6.8h, v0.8h
+ mla v6.8h, v7.8h, v1.8h
+ add v6.8h, v6.8h, v30.8h
+ ushr v6.8h, v6.8h, #(8 - 6)
+ str q6, [x13], #16
+
+ cbz w10, 3f
+
+ ldr q16, [x12], #16
+ mul v16.8h, v16.8h, v2.8h
+ mla v16.8h, v6.8h, v3.8h
+ add v16.8h, v16.8h, v31.8h
+ ushr v16.8h, v16.8h, #4
+ str q16, [x14], #16
+3:
+ ldr s5, [src, #1]
+ ldr s4, [src], #4
+ uxtl v7.8h, v5.8b
+ uxtl v6.8h, v4.8b
+ mul v6.4h, v6.4h, v0.4h
+ mla v6.4h, v7.4h, v1.4h
+ add v6.4h, v6.4h, v30.4h
+ ushr v6.4h, v6.4h, #(8 - 6)
+ str d6, [x13], #8
+
+ cbz w10, 4f
+
+ ldr d16, [x12], #8
+ mul v16.4h, v16.4h, v2.4h
+ mla v16.4h, v6.4h, v3.4h
+ add v16.4h, v16.4h, v31.4h
+ ushr v16.4h, v16.4h, #4
+ str d16, [x14], #8
+4:
+ subs height, height, #1
+ mov w10, #1
+ add src, src, src_stride
+ add dst, dst, #(VVC_MAX_PB_SIZE * 2)
+ eor tmp0, tmp0, tmp1
+ eor tmp1, tmp0, tmp1
+ eor tmp0, tmp0, tmp1
+ b.ne 1b
+
+ add sp, sp, #(VVC_MAX_PB_SIZE * 4)
+ ret
+endfunc
+
+function ff_vvc_dmvr_hv_12_neon, export=1
+ movi v29.4s, #(12 - 6)
+ movi v30.4s, #(1 << (12 - 7)) // offset1
+ b 0f
+endfunc
+
+function ff_vvc_dmvr_hv_10_neon, export=1
+ movi v29.4s, #(10 - 6)
+ movi v30.4s, #(1 << (10 - 7)) // offset1
+0:
+ movi v31.4s, #8 // offset2
+ neg v29.4s, v29.4s
+
+ sub sp, sp, #(VVC_MAX_PB_SIZE * 4)
+
+ movrel x9, X(ff_vvc_inter_luma_dmvr_filters)
+ add x12, x9, mx, lsl #1
+ ldrb w10, [x12]
+ ldrb w11, [x12, #1]
+ mov tmp0, sp
+ add tmp1, tmp0, #(VVC_MAX_PB_SIZE * 2)
+ // We know the value are positive
+ dup v0.8h, w10 // filter_x[0]
+ dup v1.8h, w11 // filter_x[1]
+
+ add x12, x9, my, lsl #1
+ ldrb w10, [x12]
+ ldrb w11, [x12, #1]
+ sxtw x6, w6
+ dup v2.8h, w10 // filter_y[0]
+ dup v3.8h, w11 // filter_y[1]
+
+ // Valid value for width can only be 8 + 4, 16 + 4
+ cmp width, #16
+ mov w10, #0 // start filter_y or not
+ add height, height, #1
+ sub dst, dst, #(VVC_MAX_PB_SIZE * 2)
+ sub src_stride, src_stride, x6, lsl #1
+ cset w15, gt // width > 16
+1:
+ mov x12, tmp0
+ mov x13, tmp1
+ mov x14, dst
+ cbz w15, 2f
+
+ // width > 16
+ add x16, src, #2
+ ldp q6, q16, [src], #32
+ ldp q7, q17, [x16]
+ umull v4.4s, v6.4h, v0.4h
+ umull2 v5.4s, v6.8h, v0.8h
+ umull v18.4s, v16.4h, v0.4h
+ umull2 v19.4s, v16.8h, v0.8h
+ umlal v4.4s, v7.4h, v1.4h
+ umlal2 v5.4s, v7.8h, v1.8h
+ umlal v18.4s, v17.4h, v1.4h
+ umlal2 v19.4s, v17.8h, v1.8h
+
+ add v4.4s, v4.4s, v30.4s
+ add v5.4s, v5.4s, v30.4s
+ add v18.4s, v18.4s, v30.4s
+ add v19.4s, v19.4s, v30.4s
+ ushl v4.4s, v4.4s, v29.4s
+ ushl v5.4s, v5.4s, v29.4s
+ ushl v18.4s, v18.4s, v29.4s
+ ushl v19.4s, v19.4s, v29.4s
+ uqxtn v6.4h, v4.4s
+ uqxtn2 v6.8h, v5.4s
+ uqxtn v7.4h, v18.4s
+ uqxtn2 v7.8h, v19.4s
+ stp q6, q7, [x13], #32
+
+ cbz w10, 3f
+
+ ldp q4, q5, [x12], #32
+ umull v17.4s, v4.4h, v2.4h
+ umull2 v18.4s, v4.8h, v2.8h
+ umull v19.4s, v5.4h, v2.4h
+ umull2 v20.4s, v5.8h, v2.8h
+ umlal v17.4s, v6.4h, v3.4h
+ umlal2 v18.4s, v6.8h, v3.8h
+ umlal v19.4s, v7.4h, v3.4h
+ umlal2 v20.4s, v7.8h, v3.8h
+ add v17.4s, v17.4s, v31.4s
+ add v18.4s, v18.4s, v31.4s
+ add v19.4s, v19.4s, v31.4s
+ add v20.4s, v20.4s, v31.4s
+ ushr v17.4s, v17.4s, #4
+ ushr v18.4s, v18.4s, #4
+ ushr v19.4s, v19.4s, #4
+ ushr v20.4s, v20.4s, #4
+ uqxtn v6.4h, v17.4s
+ uqxtn2 v6.8h, v18.4s
+ uqxtn v7.4h, v19.4s
+ uqxtn2 v7.8h, v20.4s
+ stp q6, q7, [x14], #32
+ b 3f
+2:
+ // width > 8
+ ldur q7, [src, #2]
+ ldr q6, [src], #16
+ umull v4.4s, v6.4h, v0.4h
+ umull2 v5.4s, v6.8h, v0.8h
+ umlal v4.4s, v7.4h, v1.4h
+ umlal2 v5.4s, v7.8h, v1.8h
+
+ add v4.4s, v4.4s, v30.4s
+ add v5.4s, v5.4s, v30.4s
+ ushl v4.4s, v4.4s, v29.4s
+ ushl v5.4s, v5.4s, v29.4s
+ uqxtn v6.4h, v4.4s
+ uqxtn2 v6.8h, v5.4s
+ str q6, [x13], #16
+
+ cbz w10, 3f
+
+ ldr q16, [x12], #16
+ umull v17.4s, v16.4h, v2.4h
+ umull2 v18.4s, v16.8h, v2.8h
+ umlal v17.4s, v6.4h, v3.4h
+ umlal2 v18.4s, v6.8h, v3.8h
+ add v17.4s, v17.4s, v31.4s
+ add v18.4s, v18.4s, v31.4s
+ ushr v17.4s, v17.4s, #4
+ ushr v18.4s, v18.4s, #4
+ uqxtn v16.4h, v17.4s
+ uqxtn2 v16.8h, v18.4s
+ str q16, [x14], #16
+3:
+ ldr d7, [src, #2]
+ ldr d6, [src], #8
+ umull v4.4s, v7.4h, v1.4h
+ umlal v4.4s, v6.4h, v0.4h
+ add v4.4s, v4.4s, v30.4s
+ ushl v4.4s, v4.4s, v29.4s
+ uqxtn v6.4h, v4.4s
+ str d6, [x13], #8
+
+ cbz w10, 4f
+
+ ldr d16, [x12], #8
+ umull v17.4s, v16.4h, v2.4h
+ umlal v17.4s, v6.4h, v3.4h
+ add v17.4s, v17.4s, v31.4s
+ ushr v17.4s, v17.4s, #4
+ uqxtn v16.4h, v17.4s
+ str d16, [x14], #8
+4:
+ subs height, height, #1
+ mov w10, #1
+ add src, src, src_stride
+ add dst, dst, #(VVC_MAX_PB_SIZE * 2)
+ eor tmp0, tmp0, tmp1
+ eor tmp1, tmp0, tmp1
+ eor tmp0, tmp0, tmp1
+ b.ne 1b
+
+ add sp, sp, #(VVC_MAX_PB_SIZE * 4)
+ ret
+
+.unreq dst
+.unreq src
+.unreq src_stride
+.unreq height
+.unreq mx
+.unreq my
+.unreq width
+.unreq tmp0
+.unreq tmp1
+endfunc
1
0
ffmpeg | branch: master | Zhao Zhili <zhilizhao(a)tencent.com> | Sun Sep 29 20:02:27 2024 +0800| [0ba9e8d0d492b8477eabbd8ec0c114bf05b7d7b7] | committer: Nuo Mi
aarch64/vvc: Add w_avg
w_avg_8_2x2_c: 0.0 ( 0.00x)
w_avg_8_2x2_neon: 0.0 ( 0.00x)
w_avg_8_4x4_c: 0.2 ( 1.00x)
w_avg_8_4x4_neon: 0.0 ( 0.00x)
w_avg_8_8x8_c: 1.2 ( 1.00x)
w_avg_8_8x8_neon: 0.2 ( 5.00x)
w_avg_8_16x16_c: 4.2 ( 1.00x)
w_avg_8_16x16_neon: 0.8 ( 5.67x)
w_avg_8_32x32_c: 16.2 ( 1.00x)
w_avg_8_32x32_neon: 2.5 ( 6.50x)
w_avg_8_64x64_c: 64.5 ( 1.00x)
w_avg_8_64x64_neon: 9.0 ( 7.17x)
w_avg_8_128x128_c: 269.5 ( 1.00x)
w_avg_8_128x128_neon: 35.5 ( 7.59x)
w_avg_10_2x2_c: 0.2 ( 1.00x)
w_avg_10_2x2_neon: 0.2 ( 1.00x)
w_avg_10_4x4_c: 0.2 ( 1.00x)
w_avg_10_4x4_neon: 0.2 ( 1.00x)
w_avg_10_8x8_c: 1.0 ( 1.00x)
w_avg_10_8x8_neon: 0.2 ( 4.00x)
w_avg_10_16x16_c: 4.2 ( 1.00x)
w_avg_10_16x16_neon: 0.8 ( 5.67x)
w_avg_10_32x32_c: 16.2 ( 1.00x)
w_avg_10_32x32_neon: 2.5 ( 6.50x)
w_avg_10_64x64_c: 66.2 ( 1.00x)
w_avg_10_64x64_neon: 10.0 ( 6.62x)
w_avg_10_128x128_c: 277.8 ( 1.00x)
w_avg_10_128x128_neon: 39.8 ( 6.99x)
w_avg_12_2x2_c: 0.0 ( 0.00x)
w_avg_12_2x2_neon: 0.2 ( 0.00x)
w_avg_12_4x4_c: 0.2 ( 1.00x)
w_avg_12_4x4_neon: 0.0 ( 0.00x)
w_avg_12_8x8_c: 1.2 ( 1.00x)
w_avg_12_8x8_neon: 0.5 ( 2.50x)
w_avg_12_16x16_c: 4.8 ( 1.00x)
w_avg_12_16x16_neon: 0.8 ( 6.33x)
w_avg_12_32x32_c: 17.0 ( 1.00x)
w_avg_12_32x32_neon: 2.8 ( 6.18x)
w_avg_12_64x64_c: 64.0 ( 1.00x)
w_avg_12_64x64_neon: 10.0 ( 6.40x)
w_avg_12_128x128_c: 269.2 ( 1.00x)
w_avg_12_128x128_neon: 42.0 ( 6.41x)
Signed-off-by: Zhao Zhili <zhilizhao(a)tencent.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0ba9e8d0d492b8477…
---
libavcodec/aarch64/vvc/dsp_init.c | 36 ++++++++++++++
libavcodec/aarch64/vvc/inter.S | 99 ++++++++++++++++++++++++++++++++-------
2 files changed, 118 insertions(+), 17 deletions(-)
diff --git a/libavcodec/aarch64/vvc/dsp_init.c b/libavcodec/aarch64/vvc/dsp_init.c
index ad767d17e2..ebe58a2ba5 100644
--- a/libavcodec/aarch64/vvc/dsp_init.c
+++ b/libavcodec/aarch64/vvc/dsp_init.c
@@ -52,6 +52,39 @@ void ff_vvc_avg_12_neon(uint8_t *dst, ptrdiff_t dst_stride,
const int16_t *src0, const int16_t *src1, int width,
int height);
+void ff_vvc_w_avg_8_neon(uint8_t *_dst, ptrdiff_t _dst_stride,
+ const int16_t *src0, const int16_t *src1,
+ int width, int height,
+ uintptr_t w0_w1, uintptr_t offset_shift);
+void ff_vvc_w_avg_10_neon(uint8_t *_dst, ptrdiff_t _dst_stride,
+ const int16_t *src0, const int16_t *src1,
+ int width, int height,
+ uintptr_t w0_w1, uintptr_t offset_shift);
+void ff_vvc_w_avg_12_neon(uint8_t *_dst, ptrdiff_t _dst_stride,
+ const int16_t *src0, const int16_t *src1,
+ int width, int height,
+ uintptr_t w0_w1, uintptr_t offset_shift);
+/* When passing arguments to functions, Apple platforms diverge from the ARM64
+ * standard ABI for functions that require passing arguments on the stack. To
+ * simplify portability in the assembly function interface, use a different
+ * function signature that doesn't require passing arguments on the stack.
+ */
+#define W_AVG_FUN(bit_depth) \
+static void vvc_w_avg_ ## bit_depth(uint8_t *dst, ptrdiff_t dst_stride, \
+ const int16_t *src0, const int16_t *src1, int width, int height, \
+ int denom, int w0, int w1, int o0, int o1) \
+{ \
+ int shift = denom + FFMAX(3, 15 - bit_depth); \
+ int offset = ((o0 + o1) * (1 << (bit_depth - 8)) + 1) * (1 << (shift - 1)); \
+ uintptr_t w0_w1 = ((uintptr_t)w0 << 32) | (uint32_t)w1; \
+ uintptr_t offset_shift = ((uintptr_t)offset << 32) | (uint32_t)shift; \
+ ff_vvc_w_avg_ ## bit_depth ## _neon(dst, dst_stride, src0, src1, width, height, w0_w1, offset_shift); \
+}
+
+W_AVG_FUN(8)
+W_AVG_FUN(10)
+W_AVG_FUN(12)
+
void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd)
{
int cpu_flags = av_get_cpu_flags();
@@ -123,6 +156,7 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd)
c->inter.put_uni_w[0][6][0][0] = ff_vvc_put_pel_uni_w_pixels128_8_neon;
c->inter.avg = ff_vvc_avg_8_neon;
+ c->inter.w_avg = vvc_w_avg_8;
for (int i = 0; i < FF_ARRAY_ELEMS(c->sao.band_filter); i++)
c->sao.band_filter[i] = ff_h26x_sao_band_filter_8x8_8_neon;
@@ -163,11 +197,13 @@ void ff_vvc_dsp_init_aarch64(VVCDSPContext *const c, const int bd)
}
} else if (bd == 10) {
c->inter.avg = ff_vvc_avg_10_neon;
+ c->inter.w_avg = vvc_w_avg_10;
c->alf.filter[LUMA] = alf_filter_luma_10_neon;
c->alf.filter[CHROMA] = alf_filter_chroma_10_neon;
} else if (bd == 12) {
c->inter.avg = ff_vvc_avg_12_neon;
+ c->inter.w_avg = vvc_w_avg_12;
c->alf.filter[LUMA] = alf_filter_luma_12_neon;
c->alf.filter[CHROMA] = alf_filter_chroma_12_neon;
diff --git a/libavcodec/aarch64/vvc/inter.S b/libavcodec/aarch64/vvc/inter.S
index 2f69274b86..c4c6ab1a72 100644
--- a/libavcodec/aarch64/vvc/inter.S
+++ b/libavcodec/aarch64/vvc/inter.S
@@ -22,9 +22,9 @@
#define VVC_MAX_PB_SIZE 128
-.macro vvc_avg, bit_depth
+.macro vvc_avg type, bit_depth
-.macro vvc_avg_\bit_depth\()_2_4, tap
+.macro vvc_\type\()_\bit_depth\()_2_4 tap
.if \tap == 2
ldr s0, [src0]
ldr s2, [src1]
@@ -32,9 +32,19 @@
ldr d0, [src0]
ldr d2, [src1]
.endif
+
+.ifc \type, avg
saddl v4.4s, v0.4h, v2.4h
add v4.4s, v4.4s, v16.4s
sqshrn v4.4h, v4.4s, #(15 - \bit_depth)
+.else
+ mov v4.16b, v16.16b
+ smlal v4.4s, v0.4h, v19.4h
+ smlal v4.4s, v2.4h, v20.4h
+ sqshl v4.4s, v4.4s, v22.4s
+ sqxtn v4.4h, v4.4s
+.endif
+
.if \bit_depth == 8
sqxtun v4.8b, v4.8h
.if \tap == 2
@@ -57,7 +67,7 @@
add dst, dst, dst_stride
.endm
-function ff_vvc_avg_\bit_depth\()_neon, export=1
+function ff_vvc_\type\()_\bit_depth\()_neon, export=1
dst .req x0
dst_stride .req x1
src0 .req x2
@@ -67,42 +77,64 @@ function ff_vvc_avg_\bit_depth\()_neon, export=1
mov x10, #(VVC_MAX_PB_SIZE * 2)
cmp width, #8
-.if \bit_depth == 8
- movi v16.4s, #64
-.else
-.if \bit_depth == 10
- mov w6, #1023
- movi v16.4s, #16
+.ifc \type, avg
+ movi v16.4s, #(1 << (14 - \bit_depth))
.else
- mov w6, #4095
- movi v16.4s, #4
-.endif
+ lsr x11, x6, #32 // weight0
+ mov w12, w6 // weight1
+ lsr x13, x7, #32 // offset
+ mov w14, w7 // shift
+
+ dup v19.8h, w11
+ neg w14, w14 // so we can use sqshl
+ dup v20.8h, w12
+ dup v16.4s, w13
+ dup v22.4s, w14
+.endif // avg
+
+ .if \bit_depth >= 10
+ // clip pixel
+ mov w6, #((1 << \bit_depth) - 1)
movi v18.8h, #0
dup v17.8h, w6
.endif
+
b.eq 8f
b.hi 16f
cmp width, #4
b.eq 4f
2: // width == 2
subs height, height, #1
- vvc_avg_\bit_depth\()_2_4 2
+ vvc_\type\()_\bit_depth\()_2_4 2
b.ne 2b
b 32f
4: // width == 4
subs height, height, #1
- vvc_avg_\bit_depth\()_2_4 4
+ vvc_\type\()_\bit_depth\()_2_4 4
b.ne 4b
b 32f
8: // width == 8
ld1 {v0.8h}, [src0], x10
ld1 {v2.8h}, [src1], x10
+.ifc \type, avg
saddl v4.4s, v0.4h, v2.4h
saddl2 v5.4s, v0.8h, v2.8h
add v4.4s, v4.4s, v16.4s
add v5.4s, v5.4s, v16.4s
sqshrn v4.4h, v4.4s, #(15 - \bit_depth)
sqshrn2 v4.8h, v5.4s, #(15 - \bit_depth)
+.else
+ mov v4.16b, v16.16b
+ mov v5.16b, v16.16b
+ smlal v4.4s, v0.4h, v19.4h
+ smlal v4.4s, v2.4h, v20.4h
+ smlal2 v5.4s, v0.8h, v19.8h
+ smlal2 v5.4s, v2.8h, v20.8h
+ sqshl v4.4s, v4.4s, v22.4s
+ sqshl v5.4s, v5.4s, v22.4s
+ sqxtn v4.4h, v4.4s
+ sqxtn2 v4.8h, v5.4s
+.endif
subs height, height, #1
.if \bit_depth == 8
sqxtun v4.8b, v4.8h
@@ -122,6 +154,7 @@ function ff_vvc_avg_\bit_depth\()_neon, export=1
17:
ldp q0, q1, [x7], #32
ldp q2, q3, [x8], #32
+.ifc \type, avg
saddl v4.4s, v0.4h, v2.4h
saddl2 v5.4s, v0.8h, v2.8h
saddl v6.4s, v1.4h, v3.4h
@@ -134,6 +167,28 @@ function ff_vvc_avg_\bit_depth\()_neon, export=1
sqshrn2 v4.8h, v5.4s, #(15 - \bit_depth)
sqshrn v6.4h, v6.4s, #(15 - \bit_depth)
sqshrn2 v6.8h, v7.4s, #(15 - \bit_depth)
+.else // avg
+ mov v4.16b, v16.16b
+ mov v5.16b, v16.16b
+ mov v6.16b, v16.16b
+ mov v7.16b, v16.16b
+ smlal v4.4s, v0.4h, v19.4h
+ smlal v4.4s, v2.4h, v20.4h
+ smlal2 v5.4s, v0.8h, v19.8h
+ smlal2 v5.4s, v2.8h, v20.8h
+ smlal v6.4s, v1.4h, v19.4h
+ smlal v6.4s, v3.4h, v20.4h
+ smlal2 v7.4s, v1.8h, v19.8h
+ smlal2 v7.4s, v3.8h, v20.8h
+ sqshl v4.4s, v4.4s, v22.4s
+ sqshl v5.4s, v5.4s, v22.4s
+ sqshl v6.4s, v6.4s, v22.4s
+ sqshl v7.4s, v7.4s, v22.4s
+ sqxtn v4.4h, v4.4s
+ sqxtn v6.4h, v6.4s
+ sqxtn2 v4.8h, v5.4s
+ sqxtn2 v6.8h, v7.4s
+.endif // w_avg
subs w6, w6, #16
.if \bit_depth == 8
sqxtun v4.8b, v4.8h
@@ -155,9 +210,19 @@ function ff_vvc_avg_\bit_depth\()_neon, export=1
b.ne 16b
32:
ret
+
+.unreq dst
+.unreq dst_stride
+.unreq src0
+.unreq src1
+.unreq width
+.unreq height
endfunc
.endm
-vvc_avg 8
-vvc_avg 10
-vvc_avg 12
+vvc_avg avg, 8
+vvc_avg avg, 10
+vvc_avg avg, 12
+vvc_avg w_avg, 8
+vvc_avg w_avg, 10
+vvc_avg w_avg, 12
1
0