[FFmpeg-devel] [PATCH 1/5] lavc/vvc_mc: R-V V put_pixels
flow gg
hlefthleft at gmail.com
Mon Oct 28 19:12:14 EET 2024
> Even without Zvbb's widening shift, widening multiplication is probably
faster
here.
Updated, it has indeed gotten faster.
<uk7b at foxmail.com> 于2024年10月29日周二 00:44写道:
> From: sunyuechi <sunyuechi at iscas.ac.cn>
>
> k230
> banana_f3
> put_chroma_pixels_8_4x4_c: 63.5 ( 1.00x)
> 59.2 ( 1.00x)
> put_chroma_pixels_8_4x4_rvv_i32: 26.5 ( 2.39x)
> 27.8 ( 2.14x)
> put_chroma_pixels_8_8x8_c: 184.0 ( 1.00x)
> 173.8 ( 1.00x)
> put_chroma_pixels_8_8x8_rvv_i32: 54.3 ( 3.39x)
> 48.8 ( 3.56x)
> put_chroma_pixels_8_16x16_c: 665.3 ( 1.00x)
> 653.0 ( 1.00x)
> put_chroma_pixels_8_16x16_rvv_i32: 146.8 ( 4.53x)
> 111.2 ( 5.87x)
> put_chroma_pixels_8_32x32_c: 2730.0 ( 1.00x)
> 2497.2 ( 1.00x)
> put_chroma_pixels_8_32x32_rvv_i32: 350.5 ( 7.79x)
> 257.0 ( 9.72x)
> put_chroma_pixels_8_64x64_c: 11470.5 ( 1.00x)
> 10248.5 ( 1.00x)
> put_chroma_pixels_8_64x64_rvv_i32: 1146.8 (10.00x)
> 694.8 (14.75x)
> put_chroma_pixels_8_128x128_c: 43506.5 ( 1.00x)
> 43286.2 ( 1.00x)
> put_chroma_pixels_8_128x128_rvv_i32: 6433.8 ( 6.76x)
> 2663.8 (16.25x)
> put_luma_pixels_8_4x4_c: 54.5 ( 1.00x)
> 59.2 ( 1.00x)
> put_luma_pixels_8_4x4_rvv_i32: 26.8 ( 2.04x)
> 28.0 ( 2.12x)
> put_luma_pixels_8_8x8_c: 184.0 ( 1.00x)
> 184.2 ( 1.00x)
> put_luma_pixels_8_8x8_rvv_i32: 54.3 ( 3.39x)
> 48.8 ( 3.78x)
> put_luma_pixels_8_16x16_c: 674.8 ( 1.00x)
> 653.0 ( 1.00x)
> put_luma_pixels_8_16x16_rvv_i32: 137.5 ( 4.91x)
> 101.0 ( 6.47x)
> put_luma_pixels_8_32x32_c: 2730.0 ( 1.00x)
> 2486.8 ( 1.00x)
> put_luma_pixels_8_32x32_rvv_i32: 350.8 ( 7.78x)
> 257.2 ( 9.67x)
> put_luma_pixels_8_64x64_c: 10313.3 ( 1.00x)
> 10238.2 ( 1.00x)
> put_luma_pixels_8_64x64_rvv_i32: 1156.3 ( 8.92x)
> 819.8 (12.49x)
> put_luma_pixels_8_128x128_c: 43516.0 ( 1.00x)
> 44923.0 ( 1.00x)
> put_luma_pixels_8_128x128_rvv_i32: 5720.8 ( 7.61x)
> 2663.8 (16.86x)
> ---
> libavcodec/riscv/vvc/vvc_mc_rvv.S | 59 ++++++++++++++++++++++++++----
> libavcodec/riscv/vvc/vvcdsp_init.c | 22 +++++++++++
> 2 files changed, 74 insertions(+), 7 deletions(-)
>
> diff --git a/libavcodec/riscv/vvc/vvc_mc_rvv.S
> b/libavcodec/riscv/vvc/vvc_mc_rvv.S
> index 1dcbaf7d5b..00d9c9e614 100644
> --- a/libavcodec/riscv/vvc/vvc_mc_rvv.S
> +++ b/libavcodec/riscv/vvc/vvc_mc_rvv.S
> @@ -158,7 +158,7 @@
> .endm
>
>
> -.macro AVG_JMP_TABLE id, vlen
> +.macro POW2_JMP_TABLE id, vlen
> const jmp_table_\id\vlen
> .4byte \id\()2\vlen\()f - jmp_table_\id\vlen
> .4byte \id\()4\vlen\()f - jmp_table_\id\vlen
> @@ -170,8 +170,8 @@ const jmp_table_\id\vlen
> endconst
> .endm
>
> -.macro AVG_J vlen, id
> - clz t1, a4
> +.macro POW2_J vlen, id, w
> + clz t1, \w
> neg t1, t1
> lla t5, jmp_table_\id\vlen
> sh2add t1, t1, t5
> @@ -183,9 +183,9 @@ endconst
> .macro func_avg vlen
> func ff_vvc_avg_8_rvv_\vlen\(), zve32x, zbb, zba
> lpad 0
> - AVG_JMP_TABLE 1, \vlen
> + POW2_JMP_TABLE 1, \vlen
> csrwi vxrm, 0
> - AVG_J \vlen, 1
> + POW2_J \vlen, 1, a4
> .irp w,2,4,8,16,32,64,128
> avg \w, \vlen, 1
> .endr
> @@ -265,7 +265,7 @@ func_avg 256
> .macro func_w_avg vlen
> func ff_vvc_w_avg_8_rvv_\vlen\(), zve32x, zbb, zba
> lpad 0
> - AVG_JMP_TABLE 2, \vlen
> + POW2_JMP_TABLE 2, \vlen
> csrwi vxrm, 0
> addi t6, a6, 7
> ld t3, (sp)
> @@ -275,7 +275,7 @@ func ff_vvc_w_avg_8_rvv_\vlen\(), zve32x, zbb, zba
> add t4, t4, t5
> addi t5, t6, -1 // shift - 1
> sll t4, t4, t5
> - AVG_J \vlen, 2
> + POW2_J \vlen, 2, a4
> .irp w,2,4,8,16,32,64,128
> w_avg \w, \vlen, 2
> .endr
> @@ -407,3 +407,48 @@ func_dmvr \vlen, dmvr_h
> func_dmvr \vlen, dmvr_v
> func_dmvr \vlen, dmvr_hv
> .endr
> +
> +.macro put_pixels w, vlen, id
> +\id\w\vlen:
> + vsetvlstatic8 \w, \vlen
> + li t2, 1<<6
> +.if \w == 128 && \vlen == 128
> +1:
> + addi t0, a1, 64
> + addi t1, a0, 64*2
> + vle8.v v0, (a1)
> + vle8.v v16, (t0)
> + vwmulu.vx v8, v0, t2
> + vwmulu.vx v24, v16, t2
> + vse16.v v8, (a0)
> + vse16.v v24, (t1)
> + add a1, a1, a2
> + addi a3, a3, -1
> + addi a0, a0, 128*2
> + bnez a3, 1b
> +.else
> +1:
> + vle8.v v0, (a1)
> + vwmulu.vx v8, v0, t2
> + vse16.v v8, (a0)
> + add a1, a1, a2
> + addi a3, a3, -1
> + addi a0, a0, 128*2
> + bnez a3, 1b
> +.endif
> + ret
> +.endm
> +
> +.macro func_put_pixels vlen
> +func ff_vvc_put_pixels_8_rvv_\vlen\(), zve32x, zbb, zba
> + lpad 0
> + POW2_JMP_TABLE 3, \vlen
> + POW2_J \vlen, 3, a6
> + .irp w,2,4,8,16,32,64,128
> + put_pixels \w, \vlen, 3
> + .endr
> +endfunc
> +.endm
> +
> +func_put_pixels 256
> +func_put_pixels 128
> diff --git a/libavcodec/riscv/vvc/vvcdsp_init.c
> b/libavcodec/riscv/vvc/vvcdsp_init.c
> index aa5ab83a45..bee892cb7c 100644
> --- a/libavcodec/riscv/vvc/vvcdsp_init.c
> +++ b/libavcodec/riscv/vvc/vvcdsp_init.c
> @@ -24,6 +24,7 @@
> #include "libavutil/cpu.h"
> #include "libavutil/riscv/cpu.h"
> #include "libavcodec/vvc/dsp.h"
> +#include "libavcodec/vvc/dec.h"
>
> #define bf(fn, bd, opt) fn##_##bd##_##opt
>
> @@ -57,6 +58,23 @@ DMVR_PROTOTYPES(8, rvv_256)
> c->inter.dmvr[1][1] = ff_vvc_dmvr_hv_##bd##_##opt; \
> } while (0)
>
> +#define PUT_PIXELS_PROTOTYPES2(bd, opt)
> \
> +void bf(ff_vvc_put_pixels, bd, opt)(int16_t *dst,
> \
> + const uint8_t *_src, const ptrdiff_t _src_stride,
> \
> + const int height, const int8_t *hf, const int8_t *vf, const int
> width);
> +
> +PUT_PIXELS_PROTOTYPES2(8, rvv_128)
> +PUT_PIXELS_PROTOTYPES2(8, rvv_256)
> +
> +#define PEL_FUNC(dst, C, idx1, idx2, a)
> \
> + do {
> \
> + for (int w = 1; w < 7; w++)
> \
> + c->inter.dst[C][w][idx1][idx2] = a;
> \
> + } while (0)
> \
> +
> +#define FUNCS(C, opt)
> \
> + PEL_FUNC(put, C, 0, 0, ff_vvc_put_pixels_8_##opt);
> \
> +
> void ff_vvc_dsp_init_riscv(VVCDSPContext *const c, const int bd)
> {
> #if HAVE_RVV
> @@ -75,6 +93,8 @@ void ff_vvc_dsp_init_riscv(VVCDSPContext *const c, const
> int bd)
> c->inter.w_avg = ff_vvc_w_avg_8_rvv_256;
> # endif
> DMVR_INIT(8, rvv_256);
> + FUNCS(LUMA, rvv_256);
> + FUNCS(CHROMA, rvv_256);
> break;
> default:
> break;
> @@ -87,6 +107,8 @@ void ff_vvc_dsp_init_riscv(VVCDSPContext *const c,
> const int bd)
> c->inter.w_avg = ff_vvc_w_avg_8_rvv_128;
> # endif
> DMVR_INIT(8, rvv_128);
> + FUNCS(LUMA, rvv_128);
> + FUNCS(CHROMA, rvv_128);
> break;
> default:
> break;
> --
> 2.47.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>
More information about the ffmpeg-devel
mailing list