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

Git pushed a commit to branch master
in repository ffmpeg.

commit 55200f999c1e85bc68785742528151193c2f4bce
Author:     Rémi Denis-Courmont <[email protected]>
AuthorDate: Sun Dec 14 14:45:16 2025 +0200
Commit:     Rémi Denis-Courmont <[email protected]>
CommitDate: Fri Dec 19 19:56:13 2025 +0200

    lavc/mathops: R-V B optimisation for mid_pred
    
    If Zbb is enabled at compilation (e.g. Ubuntu), the compiler should
    compile the new C mid_pred() function correctly. But if Zbb is *not*
    enabled (e.g. Debian), then we can at least fallback at run-time.
    
    On SiFive-U74, before:
    sub_median_pred_c:                                    1331.9 ( 1.00x)
    sub_median_pred_rvb_b:                                 881.8 ( 1.51x)
    
    After:
    sub_median_pred_c:                                    1133.1 ( 1.00x)
    sub_median_pred_rvb_b:                                 875.7 ( 1.29x)
---
 libavcodec/mathops.h                               |  2 +
 .../riscv/mathops.h                                | 47 +++++++++++++---------
 2 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h
index 4411d138b4..64431b8a15 100644
--- a/libavcodec/mathops.h
+++ b/libavcodec/mathops.h
@@ -44,6 +44,8 @@ extern const uint8_t ff_zigzag_scan[16+1];
 #   include "mips/mathops.h"
 #elif ARCH_PPC
 #   include "ppc/mathops.h"
+#elif ARCH_RISCV
+#   include "riscv/mathops.h"
 #elif ARCH_X86
 #   include "x86/mathops.h"
 #endif
diff --git a/libavfilter/riscv/vf_blackdetect_init.c 
b/libavcodec/riscv/mathops.h
similarity index 51%
copy from libavfilter/riscv/vf_blackdetect_init.c
copy to libavcodec/riscv/mathops.h
index fcf63501e5..c2258f49d7 100644
--- a/libavfilter/riscv/vf_blackdetect_init.c
+++ b/libavcodec/riscv/mathops.h
@@ -18,30 +18,37 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "config.h"
+#ifndef AVCODEC_RISCV_MATHOPS_H
+#define AVCODEC_RISCV_MATHOPS_H
 
-#include "libavutil/attributes.h"
-#include "libavutil/cpu.h"
-#include "libavfilter/vf_blackdetect.h"
+#include "config.h"
+#include <stdbool.h>
+#include "libavutil/attributes_internal.h"
+#include "libavutil/riscv/cpu.h"
 
-unsigned ff_count_pixels_8_rvv(const uint8_t *src, ptrdiff_t stride,
-                               ptrdiff_t width, ptrdiff_t height,
-                               unsigned threshold);
-unsigned ff_count_pixels_16_rvv(const uint8_t *src, ptrdiff_t stride,
-                                ptrdiff_t width, ptrdiff_t height,
-                                unsigned threshold);
+#if HAVE_RV && !defined(__riscv_zbb)
+static inline int median3_c(int a, int b, int c);
 
-ff_blackdetect_fn ff_blackdetect_get_fn_riscv(int depth)
+static inline av_const int median3_rv(int a, int b, int c)
 {
-#if HAVE_RVV
-    int flags = av_get_cpu_flags();
+    if (__builtin_expect(ff_rv_zbb_support(), true)) {
+        int min2, max2;
+
+        __asm__ (
+           ".option push\n"
+           ".option arch, +zbb\n"
+           "max     %1, %2, %3\n"
+           "min     %0, %2, %3\n"
+           "min     %1, %4, %1\n"
+           "max     %0, %0, %1\n"
+           ".option pop\n"
+           : "=&r" (min2), "=&r" (max2) : "r" (a), "r" (b), "r" (c));
 
-    if (flags & AV_CPU_FLAG_RVV_I32) {
-        if (depth <= 8)
-            return ff_count_pixels_8_rvv;
-        if ((flags & AV_CPU_FLAG_RVB) && (depth <= 16))
-            return ff_count_pixels_16_rvv;
+        return min2;
     }
-#endif
-    return NULL;
+    return median3_c(a, b, c);
 }
+#define mid_pred median3_rv
+#endif
+
+#endif /* HAVE_RVV */

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

Reply via email to