This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 570908af0963f03c8f7b629acde7edfa978c4a2e
Author:     Rémi Denis-Courmont <[email protected]>
AuthorDate: Mon Dec 15 20:37:54 2025 +0200
Commit:     Rémi Denis-Courmont <[email protected]>
CommitDate: Tue Dec 16 17:30:23 2025 +0200

    lavfi/vf_blackdetect: R-V V count_pixels_8
    
    SpacemiT X60:
    blackdetect8_c:                                      14911.0 ( 1.00x)
    blackdetect8_rvv_i32:                                  369.5 (40.35x)
---
 libavfilter/riscv/Makefile                         |  2 ++
 .../riscv/vf_blackdetect_init.c                    | 17 ++++++-------
 .../riscv/vf_blackdetect_rvv.S                     | 28 ++++++++++++++--------
 libavfilter/vf_blackdetect.h                       | 10 ++++++--
 4 files changed, 37 insertions(+), 20 deletions(-)

diff --git a/libavfilter/riscv/Makefile b/libavfilter/riscv/Makefile
index 14a4470d96..32b07eec1a 100644
--- a/libavfilter/riscv/Makefile
+++ b/libavfilter/riscv/Makefile
@@ -1,4 +1,6 @@
 OBJS-$(CONFIG_AFIR_FILTER)                   += riscv/af_afir_init.o
 RVV-OBJS-$(CONFIG_AFIR_FILTER)               += riscv/af_afir_rvv.o
+OBJS-$(CONFIG_BLACKDETECT_FILTER) += riscv/vf_blackdetect_init.o
+RVV-OBJS-$(CONFIG_BLACKDETECT_FILTER) += riscv/vf_blackdetect_rvv.o
 
 SHLIBOBJS += riscv/cpu_common.o
diff --git a/libavcodec/riscv/svqenc_init.c 
b/libavfilter/riscv/vf_blackdetect_init.c
similarity index 70%
copy from libavcodec/riscv/svqenc_init.c
copy to libavfilter/riscv/vf_blackdetect_init.c
index b2eacb6b44..665603c114 100644
--- a/libavcodec/riscv/svqenc_init.c
+++ b/libavfilter/riscv/vf_blackdetect_init.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Institute of Software Chinese Academy of Sciences 
(ISCAS).
+ * Copyright © 2025 Rémi Denis-Courmont.
  *
  * This file is part of FFmpeg.
  *
@@ -22,20 +22,21 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
-#include "libavcodec/svq1encdsp.h"
+#include "libavfilter/vf_blackdetect.h"
 
-int ff_ssd_int8_vs_int16_rvv(const int8_t *pix1, const int16_t *pix2,
-                              intptr_t size);
+unsigned ff_count_pixels_8_rvv(const uint8_t *src, ptrdiff_t stride,
+                               ptrdiff_t width, ptrdiff_t height,
+                               unsigned threshold);
 
-av_cold void ff_svq1enc_init_riscv(SVQ1EncDSPContext *c)
+ff_blackdetect_fn ff_blackdetect_get_fn_riscv(int depth)
 {
 #if HAVE_RVV
     int flags = av_get_cpu_flags();
 
     if (flags & AV_CPU_FLAG_RVV_I32) {
-        if (flags & AV_CPU_FLAG_RVB) {
-            c->ssd_int8_vs_int16 = ff_ssd_int8_vs_int16_rvv;
-        }
+        if (depth <= 8)
+            return ff_count_pixels_8_rvv;
     }
 #endif
+    return NULL;
 }
diff --git a/libavcodec/riscv/llviddsp_rvv.S 
b/libavfilter/riscv/vf_blackdetect_rvv.S
similarity index 65%
copy from libavcodec/riscv/llviddsp_rvv.S
copy to libavfilter/riscv/vf_blackdetect_rvv.S
index 9572e92dce..bd753effc0 100644
--- a/libavcodec/riscv/llviddsp_rvv.S
+++ b/libavfilter/riscv/vf_blackdetect_rvv.S
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2023 Rémi Denis-Courmont.
+ * Copyright © 2025 Rémi Denis-Courmont.
  *
  * This file is part of FFmpeg.
  *
@@ -20,18 +20,26 @@
 
 #include "libavutil/riscv/asm.S"
 
-func ff_llvid_add_bytes_rvv, zve32x
+func ff_count_pixels_8_rvv, zve32x
         lpad    0
+        mv      a5, zero
+        sub     a1, a1, a2
 1:
-        vsetvli t0, a2, e8, m8, ta, ma
-        vle8.v  v0, (a1)
-        sub     a2, a2, t0
+        mv      t2, a2
+        addi    a3, a3, -1
+2:
+        vsetvli t1, t2, e8, m8, ta, ma
         vle8.v  v8, (a0)
-        add     a1, t0, a1
-        vadd.vv v8, v0, v8
-        vse8.v  v8, (a0)
-        add     a0, t0, a0
-        bnez    a2, 1b
+        sub     t2, t2, t1
+        vmsleu.vx   v0, v8, a4
+        add     a0, t1, a0
+        vcpop.m t3, v0
+        add     a5, t3, a5
+        bnez    t2, 2b
 
+        add     a0, a0, a1
+        bnez    a3, 1b
+
+        mv      a0, a5
         ret
 endfunc
diff --git a/libavfilter/vf_blackdetect.h b/libavfilter/vf_blackdetect.h
index e51beda3a4..e5b3aa8833 100644
--- a/libavfilter/vf_blackdetect.h
+++ b/libavfilter/vf_blackdetect.h
@@ -28,6 +28,7 @@ typedef unsigned (*ff_blackdetect_fn)(const uint8_t *src, 
ptrdiff_t stride,
                                                    ptrdiff_t width, ptrdiff_t 
height,
                                                    unsigned threshold);
 
+ff_blackdetect_fn ff_blackdetect_get_fn_riscv(int depth);
 ff_blackdetect_fn ff_blackdetect_get_fn_x86(int depth);
 
 static unsigned count_pixels8_c(const uint8_t *src, ptrdiff_t stride,
@@ -60,9 +61,14 @@ static unsigned count_pixels16_c(const uint8_t *src, 
ptrdiff_t stride,
 
 static inline ff_blackdetect_fn ff_blackdetect_get_fn(int depth)
 {
-    ff_blackdetect_fn fn = NULL;
-#if ARCH_X86 && HAVE_X86ASM
+    ff_blackdetect_fn fn;
+
+#if ARCH_RISCV
+    fn = ff_blackdetect_get_fn_riscv(depth);
+#elif ARCH_X86 && HAVE_X86ASM
     fn = ff_blackdetect_get_fn_x86(depth);
+#else
+    fn = NULL;
 #endif
 
     if (!fn)

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to