[FFmpeg-devel] [PATCH 10/10] lavc/vp9dsp: R-V V mc tap hv

uk7b at foxmail.com uk7b at foxmail.com
Sat May 4 18:03:13 EEST 2024


From: sunyuechi <sunyuechi at iscas.ac.cn>

C908:
vp9_avg_8tap_smooth_4hv_8bpp_c: 32.2
vp9_avg_8tap_smooth_4hv_8bpp_rvv_i64: 15.2
vp9_avg_8tap_smooth_8hv_8bpp_c: 98.5
vp9_avg_8tap_smooth_8hv_8bpp_rvv_i64: 23.5
vp9_avg_8tap_smooth_16hv_8bpp_c: 355.5
vp9_avg_8tap_smooth_16hv_8bpp_rvv_i64: 46.2
vp9_avg_8tap_smooth_32hv_8bpp_c: 1270.7
vp9_avg_8tap_smooth_32hv_8bpp_rvv_i64: 133.2
vp9_avg_8tap_smooth_64hv_8bpp_c: 4936.5
vp9_avg_8tap_smooth_64hv_8bpp_rvv_i64: 521.7
vp9_put_8tap_smooth_4hv_8bpp_c: 30.2
vp9_put_8tap_smooth_4hv_8bpp_rvv_i64: 14.2
vp9_put_8tap_smooth_8hv_8bpp_c: 91.5
vp9_put_8tap_smooth_8hv_8bpp_rvv_i64: 22.7
vp9_put_8tap_smooth_16hv_8bpp_c: 330.0
vp9_put_8tap_smooth_16hv_8bpp_rvv_i64: 45.0
vp9_put_8tap_smooth_32hv_8bpp_c: 1296.5
vp9_put_8tap_smooth_32hv_8bpp_rvv_i64: 131.0
vp9_put_8tap_smooth_64hv_8bpp_c: 4497.7
vp9_put_8tap_smooth_64hv_8bpp_rvv_i64: 513.2
---
 libavcodec/riscv/vp9_mc_rvv.S  | 79 ++++++++++++++++++++++++++++++++++
 libavcodec/riscv/vp9dsp_init.c |  3 +-
 2 files changed, 81 insertions(+), 1 deletion(-)

diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S
index c8a42c7159..6ad7ea2433 100644
--- a/libavcodec/riscv/vp9_mc_rvv.S
+++ b/libavcodec/riscv/vp9_mc_rvv.S
@@ -446,12 +446,90 @@ endconst
         ret
 .endm
 
+.macro epel_hv_once len name do
+        sub             a2, a2, a3
+        sub             a2, a2, a3
+        sub             a2, a2, a3
+        .irp n 0 2 4 6 8 10 12 14
+        epel_load_inc   v\n \len put \name h 1 t
+        .endr
+        addi            a4, a4, -1
+1:
+        addi            a4, a4, -1
+        epel_load       v30 \len \do \name v 0 s
+        vse8.v          v30, (a0)
+        vmv.v.v         v0, v2
+        vmv.v.v         v2, v4
+        vmv.v.v         v4, v6
+        vmv.v.v         v6, v8
+        vmv.v.v         v8, v10
+        vmv.v.v         v10, v12
+        vmv.v.v         v12, v14
+        epel_load       v14 \len put \name h 1 t
+        add             a2, a2, a3
+        add             a0, a0, a1
+        bnez            a4, 1b
+        epel_load       v30 \len \do \name v 0 s
+        vse8.v          v30, (a0)
+.endm
+
+.macro epel_hv do name len
+        addi            sp, sp, -64
+        .irp n 0,1,2,3,4,5,6,7
+        sd              s\n, \n\()<<3(sp)
+        .endr
+.ifc \len,64
+        addi            sp, sp, -48
+        .irp n 0,1,2,3,4,5
+        sd              a\n, \n\()<<3(sp)
+        .endr
+.endif
+.ifc \do,avg
+        csrwi           vxrm, 0
+.endif
+        epel_filter     \name h t
+        epel_filter     \name v s
+.ifc \len,4
+        vsetivli        zero, 4, e8, mf4, ta, ma
+.elseif \len == 8
+        vsetivli        zero, 8, e8, mf2, ta, ma
+.elseif \len == 16
+        vsetivli        zero, 16, e8, m1, ta, ma
+.else
+        li              a6, 32
+        vsetvli         zero, a6, e8, m2, ta, ma
+.endif
+        epel_hv_once    \len \name \do
+.ifc \len,64
+        .irp n 0,1,2,3,4,5
+        ld              a\n, \n\()<<3(sp)
+        .endr
+        addi            sp, sp, 48
+        addi            a0, a0, 32
+        addi            a2, a2, 32
+        epel_filter     \name h t
+        epel_hv_once    \len \name \do
+.endif
+        .irp n 0,1,2,3,4,5,6,7
+        ld              s\n, \n\()<<3(sp)
+        .endr
+        addi            sp, sp, 64
+
+        ret
+.endm
+
 .macro gen_epel len do name type
 func ff_\do\()_8tap_\name\()_\len\()\type\()_rvv, zve32x
         epel \len \do \name \type
 endfunc
 .endm
 
+.macro gen_epelhv len name do
+func ff_\do\()_8tap_\name\()_\len\()hv_rvv, zve32x
+        epel_hv \do \name \len
+endfunc
+.endm
+
 .irp len 64, 32, 16, 8, 4
 func ff_avg\len\()_rvv, zve32x
         copy_avg \len avg
@@ -481,6 +559,7 @@ endfunc
                 .irp type h v
                         gen_epel \len \do \name \type
                 .endr
+                gen_epelhv \len \name \do
         .endr
 .endr
 .endr
diff --git a/libavcodec/riscv/vp9dsp_init.c b/libavcodec/riscv/vp9dsp_init.c
index ff7d445f6a..0c75ef38dc 100644
--- a/libavcodec/riscv/vp9dsp_init.c
+++ b/libavcodec/riscv/vp9dsp_init.c
@@ -126,7 +126,8 @@ static av_cold void vp9dsp_mc_init_rvv(VP9DSPContext *dsp, int bpp)
 
 #define init_subpel3(idx, type)         \
     init_subpel2(idx, 1, 0, h, type);   \
-    init_subpel2(idx, 0, 1, v, type)
+    init_subpel2(idx, 0, 1, v, type);   \
+    init_subpel2(idx, 1, 1, hv, type)
 
     init_subpel3(0, put);
     init_subpel3(1, avg);
-- 
2.45.0



More information about the ffmpeg-devel mailing list