This works out a bit more favourably than VP8's due to: - additional multiplications that can be vectored, - hardware-supported fixed-point rounding mode. vp7_luma_dc_wht_c: 3.2 vp7_luma_dc_wht_rvv_i64: 2.0
Unified · Split
| @@ -65,6 +65,8 @@ RVV-OBJS-$(CONFIG_UTVIDEO_DECODER) += riscv/utvideodsp_rvv.o · 64 unmodified lines | |||
| 65 | OBJS-$(CONFIG_VC1DSP) += riscv/vc1dsp_init.o | 65 | OBJS-$(CONFIG_VC1DSP) += riscv/vc1dsp_init.o |
| 66 | RV-OBJS-$(CONFIG_VC1DSP) += riscv/vc1dsp_rvi.o | 66 | RV-OBJS-$(CONFIG_VC1DSP) += riscv/vc1dsp_rvi.o |
| 67 | RVV-OBJS-$(CONFIG_VC1DSP) += riscv/vc1dsp_rvv.o | 67 | RVV-OBJS-$(CONFIG_VC1DSP) += riscv/vc1dsp_rvv.o |
| 68 | OBJS-$(CONFIG_VP7_DECODER) += riscv/vp7dsp_init.o | ||
| 69 | RVV-OBJS-$(CONFIG_VP7_DECODER) += riscv/vp7dsp_rvv.o | ||
| 68 | OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_init.o | 70 | OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_init.o |
| 69 | RV-OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_rvi.o | 71 | RV-OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_rvi.o |
| 70 | RVV-OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_rvv.o | 72 | RVV-OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_rvv.o |
| @@ -0,0 +1,41 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2024 Rémi Denis-Courmont. | ||
| 3 | * | ||
| 4 | * This file is part of FFmpeg. | ||
| 5 | * | ||
| 6 | * FFmpeg is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU Lesser General Public | ||
| 8 | * License as published by the Free Software Foundation; either | ||
| 9 | * version 2.1 of the License, or (at your option) any later version. | ||
| 10 | * | ||
| 11 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 14 | * Lesser General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU Lesser General Public | ||
| 17 | * License along with FFmpeg; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include "config.h" | ||
| 22 | |||
| 23 | #include "libavutil/attributes.h" | ||
| 24 | #include "libavutil/cpu.h" | ||
| 25 | #include "libavutil/riscv/cpu.h" | ||
| 26 | #include "libavcodec/vp8dsp.h" | ||
| 27 | |||
| 28 | void ff_vp7_luma_dc_wht_rvv(int16_t block[4][4][16], int16_t dc[16]); | ||
| 29 | |||
| 30 | av_cold void ff_vp7dsp_init_riscv(VP8DSPContext *c) | ||
| 31 | { | ||
| 32 | #if HAVE_RVV | ||
| 33 | int flags = av_get_cpu_flags(); | ||
| 34 | |||
| 35 | if ((flags & AV_CPU_FLAG_RVV_I32) && ff_rv_vlen_least(128)) { | ||
| 36 | #if __riscv_xlen >= 64 | ||
| 37 | c->vp8_luma_dc_wht = ff_vp7_luma_dc_wht_rvv; | ||
| 38 | #endif | ||
| 39 | } | ||
| 40 | #endif | ||
| 41 | } | ||
| @@ -0,0 +1,95 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2024 Rémi Denis-Courmont. | ||
| 3 | * | ||
| 4 | * This file is part of FFmpeg. | ||
| 5 | * | ||
| 6 | * FFmpeg is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU Lesser General Public | ||
| 8 | * License as published by the Free Software Foundation; either | ||
| 9 | * version 2.1 of the License, or (at your option) any later version. | ||
| 10 | * | ||
| 11 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 14 | * Lesser General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU Lesser General Public | ||
| 17 | * License along with FFmpeg; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include "libavutil/riscv/asm.S" | ||
| 22 | |||
| 23 | #if __riscv_xlen >= 64 | ||
| 24 | func ff_vp7_luma_dc_wht_rvv, zve32x | ||
| 25 | csrwi vxrm, 0 | ||
| 26 | li t4, 12540 | ||
| 27 | vsetivli zero, 4, e16, mf2, ta, ma | ||
| 28 | vlseg4e16.v v0, (a1) | ||
| 29 | li t6, 30274 | ||
| 30 | vwmul.vx v8, v1, t4 | ||
| 31 | li t5, 23170 | ||
| 32 | vwmul.vx v9, v3, t6 | ||
| 33 | addi t1, sp, -12 * 2 | ||
| 34 | vwmul.vx v10, v1, t6 | ||
| 35 | addi t2, sp, -8 * 2 | ||
| 36 | vwmul.vx v11, v3, t4 | ||
| 37 | addi t3, sp, -4 * 2 | ||
| 38 | vwadd.vv v4, v0, v2 | ||
| 39 | addi sp, sp, -16 * 2 | ||
| 40 | vwsub.vv v5, v0, v2 | ||
| 41 | vsetvli zero, zero, e32, m1, ta, ma | ||
| 42 | vadd.vv v7, v10, v11 | ||
| 43 | vmul.vx v4, v4, t5 | ||
| 44 | vsub.vv v6, v8, v9 | ||
| 45 | vmul.vx v5, v5, t5 | ||
| 46 | vadd.vv v0, v4, v7 | ||
| 47 | vsub.vv v3, v4, v7 | ||
| 48 | vadd.vv v1, v5, v6 | ||
| 49 | vsub.vv v2, v5, v6 | ||
| 50 | vsetvli zero, zero, e16, mf2, ta, ma | ||
| 51 | vnsra.wi v4, v0, 14 | ||
| 52 | vnsra.wi v7, v3, 14 | ||
| 53 | vnsra.wi v5, v1, 14 | ||
| 54 | vnsra.wi v6, v2, 14 | ||
| 55 | vsseg4e16.v v4, (sp) | ||
| 56 | vle16.v v0, (sp) | ||
| 57 | vle16.v v1, (t1) | ||
| 58 | vle16.v v2, (t2) | ||
| 59 | vle16.v v3, (t3) | ||
| 60 | vwmul.vx v8, v1, t4 | ||
| 61 | li t0, 16 * 2 | ||
| 62 | vwmul.vx v9, v3, t6 | ||
| 63 | addi t1, a0, 1 * 4 * 16 * 2 | ||
| 64 | vwmul.vx v10, v1, t6 | ||
| 65 | addi t2, a0, 2 * 4 * 16 * 2 | ||
| 66 | vwmul.vx v11, v3, t4 | ||
| 67 | addi t3, a0, 3 * 4 * 16 * 2 | ||
| 68 | vwadd.vv v4, v0, v2 | ||
| 69 | vwsub.vv v5, v0, v2 | ||
| 70 | vsetvli zero, zero, e32, m1, ta, ma | ||
| 71 | vmul.vx v4, v4, t5 | ||
| 72 | sd zero, (a1) | ||
| 73 | vadd.vv v7, v10, v11 | ||
| 74 | sd zero, 8(a1) | ||
| 75 | vmul.vx v5, v5, t5 | ||
| 76 | sd zero, 16(a1) | ||
| 77 | vsub.vv v6, v8, v9 | ||
| 78 | sd zero, 24(a1) | ||
| 79 | vadd.vv v0, v4, v7 | ||
| 80 | addi sp, sp, 16 * 2 | ||
| 81 | vsub.vv v3, v4, v7 | ||
| 82 | vadd.vv v1, v5, v6 | ||
| 83 | vsub.vv v2, v5, v6 | ||
| 84 | vsetvli zero, zero, e16, mf2, ta, ma | ||
| 85 | vnclip.wi v4, v0, 18 | ||
| 86 | vnclip.wi v5, v1, 18 | ||
| 87 | vnclip.wi v6, v2, 18 | ||
| 88 | vnclip.wi v7, v3, 18 | ||
| 89 | vsse16.v v4, (a0), t0 | ||
| 90 | vsse16.v v5, (t1), t0 | ||
| 91 | vsse16.v v6, (t2), t0 | ||
| 92 | vsse16.v v7, (t3), t0 | ||
| 93 | ret | ||
| 94 | endfunc | ||
| 95 | #endif | ||
| @@ -712,6 +712,10 @@ av_cold void ff_vp7dsp_init(VP8DSPContext *dsp) · 711 unmodified lines | |||
| 712 | 712 | ||
| 713 | dsp->vp8_v_loop_filter_simple = vp7_v_loop_filter_simple_c; | 713 | dsp->vp8_v_loop_filter_simple = vp7_v_loop_filter_simple_c; |
| 714 | dsp->vp8_h_loop_filter_simple = vp7_h_loop_filter_simple_c; | 714 | dsp->vp8_h_loop_filter_simple = vp7_h_loop_filter_simple_c; |
| 715 | |||
| 716 | #if ARCH_RISCV | ||
| 717 | ff_vp7dsp_init_riscv(dsp); | ||
| 718 | #endif | ||
| 715 | } | 719 | } |
| 716 | #endif /* CONFIG_VP7_DECODER */ | 720 | #endif /* CONFIG_VP7_DECODER */ |
| 717 | 721 | ||
| @@ -90,6 +90,8 @@ void ff_vp78dsp_init_ppc(VP8DSPContext *c); · 89 unmodified lines | |||
| 90 | void ff_vp78dsp_init_riscv(VP8DSPContext *c); | 90 | void ff_vp78dsp_init_riscv(VP8DSPContext *c); |
| 91 | void ff_vp78dsp_init_x86(VP8DSPContext *c); | 91 | void ff_vp78dsp_init_x86(VP8DSPContext *c); |
| 92 | 92 | ||
| 93 | void ff_vp7dsp_init_riscv(VP8DSPContext *c); | ||
| 94 | |||
| 93 | void ff_vp8dsp_init(VP8DSPContext *c); | 95 | void ff_vp8dsp_init(VP8DSPContext *c); |
| 94 | void ff_vp8dsp_init_aarch64(VP8DSPContext *c); | 96 | void ff_vp8dsp_init_aarch64(VP8DSPContext *c); |
| 95 | void ff_vp8dsp_init_arm(VP8DSPContext *c); | 97 | void ff_vp8dsp_init_arm(VP8DSPContext *c); |