@@ -24,6 +24,7 @@
#include "libavcodec/mpegvideoencdsp.h"
int ff_pix_sum_rvv(const uint8_t *pix, int line_size);
+int ff_pix_norm1_rvv(const uint8_t *pix, int line_size);
av_cold void ff_mpegvideoencdsp_init_riscv(MpegvideoEncDSPContext *c,
AVCodecContext *avctx)
@@ -31,8 +32,10 @@ av_cold void ff_mpegvideoencdsp_init_riscv(MpegvideoEncDSPContext *c,
#if HAVE_RVV
int flags = av_get_cpu_flags();
- if ((flags & AV_CPU_FLAG_RVV_I64) && (flags & AV_CPU_FLAG_RVB) &&
- ff_rv_vlen_least(128))
- c->pix_sum = ff_pix_sum_rvv;
+ if (flags & AV_CPU_FLAG_RVV_I64) {
+ if ((flags & AV_CPU_FLAG_RVB) && ff_rv_vlen_least(128))
+ c->pix_sum = ff_pix_sum_rvv;
+ c->pix_norm1 = ff_pix_norm1_rvv;
+ }
#endif
}
@@ -44,3 +44,30 @@ func ff_pix_sum_rvv, zve64x, b
zext.h a0, a0
ret
endfunc
+
+func ff_pix_norm1_rvv, zve64x
+ lpad 0
+ li t1, 16
+ vsetvli t0, zero, e32, m8, ta, ma
+ vmv.v.x v16, zero
+ vmv.s.x v1, zero
+1:
+ vsetvli t0, t1, e64, m2, ta, ma
+ vlsseg2e64.v v8, (a0), a1
+ slli t2, t0, 3
+ vsetvli zero, t2, e8, m2, ta, ma
+ vwmulu.vv v24, v8, v8
+ sub t1, t1, t0
+ vwmulu.vv v28, v10, v10
+ mul t3, a1, t0
+ vsetvli zero, zero, e16, m4, tu, ma
+ vwaddu.wv v16, v16, v24
+ add a0, t3, a0
+ vwaddu.wv v16, v16, v28
+ bnez t1, 1b
+
+ vsetvli zero, zero, e32, m8, ta, ma
+ vredsum.vs v1, v16, v1
+ vmv.x.s a0, v1
+ ret
+endfunc