lavc/llvidencdsp: R-V V sub_median_pred

SpacemiT X60:
sub_median_pred_c:                                  297862.8 ( 1.00x)
sub_median_pred_rvb_b:                              101992.2 ( 2.92x)
sub_median_pred_rvv_i32:                              4820.0 (61.80x)
This commit is contained in:
Rémi Denis-Courmont
2025-12-11 17:24:28 +02:00
parent 87190fff6e
commit 71db4f3cc1
2 changed files with 35 additions and 0 deletions

View File

@@ -32,6 +32,9 @@ void ff_llvidenc_sub_median_pred_rvb(uint8_t *dst, const uint8_t *src1,
int *left, int *left_top);
void ff_llvidenc_diff_bytes_rvv(uint8_t *dst, const uint8_t *src1,
const uint8_t *src2, intptr_t w);
void ff_llvidenc_sub_median_pred_rvv(uint8_t *dst, const uint8_t *src1,
const uint8_t *src2, intptr_t width,
int *left, int *left_top);
void ff_llvidenc_sub_left_predict_rvv(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride, ptrdiff_t width,
int height);
@@ -47,6 +50,7 @@ av_cold void ff_llvidencdsp_init_riscv(LLVidEncDSPContext *c)
#if HAVE_RVV
if (flags & AV_CPU_FLAG_RVV_I32) {
c->diff_bytes = ff_llvidenc_diff_bytes_rvv;
c->sub_median_pred = ff_llvidenc_sub_median_pred_rvv;
c->sub_left_predict = ff_llvidenc_sub_left_predict_rvv;
}
#endif

View File

@@ -37,6 +37,37 @@ func ff_llvidenc_diff_bytes_rvv, zve32x
ret
endfunc
func ff_llvidenc_sub_median_pred_rvv, zve32x
lpad 0
lw t4, (a4)
lw t5, (a5)
1:
vsetvli t3, a3, e8, m4, ta, ma
vle8.v v16, (a1) # src1
sub a3, a3, t3
vle8.v v24, (a2) # src2
add a1, t3, a1
vslide1up.vx v20, v16, t5 # lt
add a2, t3, a2
vslide1up.vx v28, v24, t4 # l
lbu t5, -1(a1)
vsub.vv v20, v16, v20
lbu t4, -1(a2)
vmaxu.vv v8, v28, v16
vadd.vv v20, v28, v20 # l + src1 - lt
vminu.vv v12, v28, v16
vminu.vv v8, v8, v20
vmaxu.vv v8, v12, v8 # mid_pred(...)
vsub.vv v8, v24, v8
vse8.v v8, (a0)
add a0, t3, a0
bnez a3, 1b
sw t4, (a4)
sw t5, (a5)
ret
endfunc
func ff_llvidenc_sub_left_predict_rvv, zve32x
lpad 0
li a5, -0x80