diff --git a/libavfilter/riscv/vf_blackdetect_init.c b/libavfilter/riscv/vf_blackdetect_init.c index 665603c114..fcf63501e5 100644 --- a/libavfilter/riscv/vf_blackdetect_init.c +++ b/libavfilter/riscv/vf_blackdetect_init.c @@ -27,6 +27,9 @@ 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); ff_blackdetect_fn ff_blackdetect_get_fn_riscv(int depth) { @@ -36,6 +39,8 @@ ff_blackdetect_fn ff_blackdetect_get_fn_riscv(int depth) 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; } #endif return NULL; diff --git a/libavfilter/riscv/vf_blackdetect_rvv.S b/libavfilter/riscv/vf_blackdetect_rvv.S index bd753effc0..89152e1a8d 100644 --- a/libavfilter/riscv/vf_blackdetect_rvv.S +++ b/libavfilter/riscv/vf_blackdetect_rvv.S @@ -43,3 +43,28 @@ func ff_count_pixels_8_rvv, zve32x mv a0, a5 ret endfunc + +func ff_count_pixels_16_rvv, zve32x, zba + lpad 0 + slli t2, a2, 1 + mv a5, zero + sub a1, a1, t2 +1: + mv t2, a2 + addi a3, a3, -1 +2: + vsetvli t1, t2, e16, m8, ta, ma + vle16.v v8, (a0) + sub t2, t2, t1 + vmsleu.vx v0, v8, a4 + sh1add 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