From: sunyuechi <sunyue...@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) 28.0 ( 2.12x) put_chroma_pixels_8_8x8_c: 211.8 ( 1.00x) 215.5 ( 1.00x) put_chroma_pixels_8_8x8_rvv_i32: 54.3 ( 3.90x) 48.8 ( 4.42x) put_chroma_pixels_8_16x16_c: 841.3 ( 1.00x) 830.0 ( 1.00x) put_chroma_pixels_8_16x16_rvv_i32: 137.5 ( 6.12x) 121.8 ( 6.82x) put_chroma_pixels_8_32x32_c: 3248.8 ( 1.00x) 3288.2 ( 1.00x) put_chroma_pixels_8_32x32_rvv_i32: 350.5 ( 9.27x) 288.5 (11.40x) put_chroma_pixels_8_64x64_c: 12998.3 ( 1.00x) 12976.2 ( 1.00x) put_chroma_pixels_8_64x64_rvv_i32: 1100.5 (11.81x) 924.0 (14.04x) put_chroma_pixels_8_128x128_c: 54284.0 ( 1.00x) 52654.5 ( 1.00x) put_chroma_pixels_8_128x128_rvv_i32: 7192.8 ( 7.55x) 2934.2 (17.94x) put_luma_pixels_8_4x4_c: 63.5 ( 1.00x) 69.5 ( 1.00x) put_luma_pixels_8_4x4_rvv_i32: 26.5 ( 2.39x) 28.0 ( 2.48x) put_luma_pixels_8_8x8_c: 211.5 ( 1.00x) 225.8 ( 1.00x) put_luma_pixels_8_8x8_rvv_i32: 54.3 ( 3.90x) 38.5 ( 5.86x) put_luma_pixels_8_16x16_c: 850.5 ( 1.00x) 830.0 ( 1.00x) put_luma_pixels_8_16x16_rvv_i32: 137.5 ( 6.18x) 100.8 ( 8.24x) put_luma_pixels_8_32x32_c: 3248.8 ( 1.00x) 3257.2 ( 1.00x) put_luma_pixels_8_32x32_rvv_i32: 341.3 ( 9.52x) 246.8 (13.20x) put_luma_pixels_8_64x64_c: 13007.5 ( 1.00x) 13038.8 ( 1.00x) put_luma_pixels_8_64x64_rvv_i32: 1119.0 (11.62x) 684.2 (19.06x) put_luma_pixels_8_128x128_c: 54219.3 ( 1.00x) 52060.8 ( 1.00x) put_luma_pixels_8_128x128_rvv_i32: 6813.5 ( 7.96x) 2548.8 (20.43x) --- libavcodec/riscv/h26x/asm.S | 169 +++++++++++++++++++++++++++++ libavcodec/riscv/h26x/h2656dsp.h | 27 +++++ libavcodec/riscv/vvc/vvc_mc_rvv.S | 120 ++------------------ libavcodec/riscv/vvc/vvcdsp_init.c | 23 ++++ 4 files changed, 227 insertions(+), 112 deletions(-) create mode 100644 libavcodec/riscv/h26x/asm.S create mode 100644 libavcodec/riscv/h26x/h2656dsp.h
diff --git a/libavcodec/riscv/h26x/asm.S b/libavcodec/riscv/h26x/asm.S new file mode 100644 index 0000000000..d37b459f66 --- /dev/null +++ b/libavcodec/riscv/h26x/asm.S @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences (ISCAS). + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/riscv/asm.S" + +.macro vsetvlstatic8 w, vlen + .if \w == 2 && \vlen == 128 + vsetivli zero, \w, e8, mf8, ta, ma + .elseif \w <= 4 && \vlen == 128 + vsetivli zero, \w, e8, mf4, ta, ma + .elseif \w <= 8 && \vlen == 128 + vsetivli zero, \w, e8, mf2, ta, ma + .elseif \w <= 16 && \vlen == 128 + vsetivli zero, \w, e8, m1, ta, ma + .elseif \w <= 32 && \vlen == 128 + li t0, \w + vsetvli zero, t0, e8, m2, ta, ma + .elseif \w <= 4 && \vlen == 256 + vsetivli zero, \w, e8, mf8, ta, ma + .elseif \w <= 8 && \vlen == 256 + vsetivli zero, \w, e8, mf4, ta, ma + .elseif \w <= 16 && \vlen == 256 + vsetivli zero, \w, e8, mf2, ta, ma + .elseif \w <= 32 && \vlen == 256 + li t0, \w + vsetvli zero, t0, e8, m1, ta, ma + .elseif \w <= 64 && \vlen == 256 + li t0, \w + vsetvli zero, t0, e8, m2, ta, ma + .else + li t0, \w + vsetvli zero, t0, e8, m4, ta, ma + .endif +.endm + +.macro vsetvlstatic16 w, vlen + .if \w == 2 && \vlen == 128 + vsetivli zero, \w, e16, mf4, ta, ma + .elseif \w <= 4 && \vlen == 128 + vsetivli zero, \w, e16, mf2, ta, ma + .elseif \w <= 8 && \vlen == 128 + vsetivli zero, \w, e16, m1, ta, ma + .elseif \w <= 16 && \vlen == 128 + vsetivli zero, \w, e16, m2, ta, ma + .elseif \w <= 32 && \vlen == 128 + li t0, \w + vsetvli zero, t0, e16, m4, ta, ma + .elseif \w <= 4 && \vlen == 256 + vsetivli zero, \w, e16, mf4, ta, ma + .elseif \w <= 8 && \vlen == 256 + vsetivli zero, \w, e16, mf2, ta, ma + .elseif \w <= 16 && \vlen == 256 + vsetivli zero, \w, e16, m1, ta, ma + .elseif \w <= 32 && \vlen == 256 + li t0, \w + vsetvli zero, t0, e16, m2, ta, ma + .elseif \w <= 64 && \vlen == 256 + li t0, \w + vsetvli zero, t0, e16, m4, ta, ma + .else + li t0, \w + vsetvli zero, t0, e16, m8, ta, ma + .endif +.endm + +.macro vsetvlstatic32 w, vlen + .if \w == 2 + vsetivli zero, \w, e32, mf2, ta, ma + .elseif \w <= 4 && \vlen == 128 + vsetivli zero, \w, e32, m1, ta, ma + .elseif \w <= 8 && \vlen == 128 + vsetivli zero, \w, e32, m2, ta, ma + .elseif \w <= 16 && \vlen == 128 + vsetivli zero, \w, e32, m4, ta, ma + .elseif \w <= 4 && \vlen == 256 + vsetivli zero, \w, e32, mf2, ta, ma + .elseif \w <= 8 && \vlen == 256 + vsetivli zero, \w, e32, m1, ta, ma + .elseif \w <= 16 && \vlen == 256 + vsetivli zero, \w, e32, m2, ta, ma + .elseif \w <= 32 && \vlen == 256 + li t0, \w + vsetvli zero, t0, e32, m4, ta, ma + .else + li t0, \w + vsetvli zero, t0, e32, m8, ta, ma + .endif +.endm + +.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 + .4byte \id\()8\vlen\()f - jmp_table_\id\vlen + .4byte \id\()16\vlen\()f - jmp_table_\id\vlen + .4byte \id\()32\vlen\()f - jmp_table_\id\vlen + .4byte \id\()64\vlen\()f - jmp_table_\id\vlen + .4byte \id\()128\vlen\()f - jmp_table_\id\vlen +endconst +.endm + +.macro POW2_J vlen, id, w + clz t1, \w + neg t1, t1 + lla t5, jmp_table_\id\vlen + sh2add t1, t1, t5 + lw t1, ((__riscv_xlen-2)<<2)(t1) + add t1, t1, t5 + jr t1 +.endm + +.macro put_pixels w, vlen, id, MAX_PB_SIZE +\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, \MAX_PB_SIZE<<1 + bnez a3, 1b +.endif + ret +.endm + +.macro func_put_pixels vlen, MAX_PB_SIZE, name +func ff_\name\()_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, \MAX_PB_SIZE + .endr +endfunc +.endm diff --git a/libavcodec/riscv/h26x/h2656dsp.h b/libavcodec/riscv/h26x/h2656dsp.h new file mode 100644 index 0000000000..5ddfb99881 --- /dev/null +++ b/libavcodec/riscv/h26x/h2656dsp.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences (ISCAS). + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_RISCV_H26X_H2656DSP_H +#define AVCODEC_RISCV_H26X_H2656DSP_H + +void ff_h2656_put_pixels_8_rvv_256(int16_t *dst, const uint8_t *src, ptrdiff_t srcstride, int height, intptr_t mx, intptr_t my, int width); +void ff_h2656_put_pixels_8_rvv_128(int16_t *dst, const uint8_t *src, ptrdiff_t srcstride, int height, intptr_t mx, intptr_t my, int width); + +#endif diff --git a/libavcodec/riscv/vvc/vvc_mc_rvv.S b/libavcodec/riscv/vvc/vvc_mc_rvv.S index 1dcbaf7d5b..329fc0648c 100644 --- a/libavcodec/riscv/vvc/vvc_mc_rvv.S +++ b/libavcodec/riscv/vvc/vvc_mc_rvv.S @@ -18,91 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/riscv/asm.S" - -.macro vsetvlstatic8 w, vlen - .if \w == 2 && \vlen == 128 - vsetivli zero, \w, e8, mf8, ta, ma - .elseif \w <= 4 && \vlen == 128 - vsetivli zero, \w, e8, mf4, ta, ma - .elseif \w <= 8 && \vlen == 128 - vsetivli zero, \w, e8, mf2, ta, ma - .elseif \w <= 16 && \vlen == 128 - vsetivli zero, \w, e8, m1, ta, ma - .elseif \w <= 32 && \vlen == 128 - li t0, \w - vsetvli zero, t0, e8, m2, ta, ma - .elseif \w <= 4 && \vlen == 256 - vsetivli zero, \w, e8, mf8, ta, ma - .elseif \w <= 8 && \vlen == 256 - vsetivli zero, \w, e8, mf4, ta, ma - .elseif \w <= 16 && \vlen == 256 - vsetivli zero, \w, e8, mf2, ta, ma - .elseif \w <= 32 && \vlen == 256 - li t0, \w - vsetvli zero, t0, e8, m1, ta, ma - .elseif \w <= 64 && \vlen == 256 - li t0, \w - vsetvli zero, t0, e8, m2, ta, ma - .else - li t0, \w - vsetvli zero, t0, e8, m4, ta, ma - .endif -.endm - -.macro vsetvlstatic16 w, vlen - .if \w == 2 && \vlen == 128 - vsetivli zero, \w, e16, mf4, ta, ma - .elseif \w <= 4 && \vlen == 128 - vsetivli zero, \w, e16, mf2, ta, ma - .elseif \w <= 8 && \vlen == 128 - vsetivli zero, \w, e16, m1, ta, ma - .elseif \w <= 16 && \vlen == 128 - vsetivli zero, \w, e16, m2, ta, ma - .elseif \w <= 32 && \vlen == 128 - li t0, \w - vsetvli zero, t0, e16, m4, ta, ma - .elseif \w <= 4 && \vlen == 256 - vsetivli zero, \w, e16, mf4, ta, ma - .elseif \w <= 8 && \vlen == 256 - vsetivli zero, \w, e16, mf2, ta, ma - .elseif \w <= 16 && \vlen == 256 - vsetivli zero, \w, e16, m1, ta, ma - .elseif \w <= 32 && \vlen == 256 - li t0, \w - vsetvli zero, t0, e16, m2, ta, ma - .elseif \w <= 64 && \vlen == 256 - li t0, \w - vsetvli zero, t0, e16, m4, ta, ma - .else - li t0, \w - vsetvli zero, t0, e16, m8, ta, ma - .endif -.endm - -.macro vsetvlstatic32 w, vlen - .if \w == 2 - vsetivli zero, \w, e32, mf2, ta, ma - .elseif \w <= 4 && \vlen == 128 - vsetivli zero, \w, e32, m1, ta, ma - .elseif \w <= 8 && \vlen == 128 - vsetivli zero, \w, e32, m2, ta, ma - .elseif \w <= 16 && \vlen == 128 - vsetivli zero, \w, e32, m4, ta, ma - .elseif \w <= 4 && \vlen == 256 - vsetivli zero, \w, e32, mf2, ta, ma - .elseif \w <= 8 && \vlen == 256 - vsetivli zero, \w, e32, m1, ta, ma - .elseif \w <= 16 && \vlen == 256 - vsetivli zero, \w, e32, m2, ta, ma - .elseif \w <= 32 && \vlen == 256 - li t0, \w - vsetvli zero, t0, e32, m4, ta, ma - .else - li t0, \w - vsetvli zero, t0, e32, m8, ta, ma - .endif -.endm +#include "libavcodec/riscv/h26x/asm.S" .macro avg w, vlen, id \id\w\vlen: @@ -157,35 +73,12 @@ ret .endm - -.macro AVG_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 - .4byte \id\()8\vlen\()f - jmp_table_\id\vlen - .4byte \id\()16\vlen\()f - jmp_table_\id\vlen - .4byte \id\()32\vlen\()f - jmp_table_\id\vlen - .4byte \id\()64\vlen\()f - jmp_table_\id\vlen - .4byte \id\()128\vlen\()f - jmp_table_\id\vlen -endconst -.endm - -.macro AVG_J vlen, id - clz t1, a4 - neg t1, t1 - lla t5, jmp_table_\id\vlen - sh2add t1, t1, t5 - lw t1, ((__riscv_xlen-2)<<2)(t1) - add t1, t1, t5 - jr t1 -.endm - .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 +158,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 +168,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 +300,6 @@ func_dmvr \vlen, dmvr_h func_dmvr \vlen, dmvr_v func_dmvr \vlen, dmvr_hv .endr + +func_put_pixels 256, 128, vvc +func_put_pixels 128, 128, vvc diff --git a/libavcodec/riscv/vvc/vvcdsp_init.c b/libavcodec/riscv/vvc/vvcdsp_init.c index aa5ab83a45..2fe93029aa 100644 --- a/libavcodec/riscv/vvc/vvcdsp_init.c +++ b/libavcodec/riscv/vvc/vvcdsp_init.c @@ -24,6 +24,8 @@ #include "libavutil/cpu.h" #include "libavutil/riscv/cpu.h" #include "libavcodec/vvc/dsp.h" +#include "libavcodec/vvc/dec.h" +#include "libavcodec/riscv/h26x/h2656dsp.h" #define bf(fn, bd, opt) fn##_##bd##_##opt @@ -57,6 +59,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 +94,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 +108,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@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".