[FFmpeg-devel] [PATCH 4/5] lavc/hevc: R-V V pel_uni(pow2)
flow gg
hlefthleft at gmail.com
Sat Oct 12 09:25:58 EEST 2024
Fix init.
<uk7b at foxmail.com> 于2024年10月12日周六 14:25写道:
> From: sunyuechi <sunyuechi at iscas.ac.cn>
>
> k230
> banana_f3
> put_hevc_pel_uni_pixels4_8_c: 126.3 ( 1.00x)
> 90.5 ( 1.00x)
> put_hevc_pel_uni_pixels4_8_rvv_i32: 24.6 ( 5.14x)
> 17.5 ( 5.18x)
> put_hevc_pel_uni_pixels8_8_c: 293.1 ( 1.00x)
> 153.0 ( 1.00x)
> put_hevc_pel_uni_pixels8_8_rvv_i32: 34.1 ( 8.60x)
> 38.5 ( 3.98x)
> put_hevc_pel_uni_pixels16_8_c: 1172.6 ( 1.00x)
> 288.2 ( 1.00x)
> put_hevc_pel_uni_pixels16_8_rvv_i32: 61.6 (19.04x)
> 48.7 ( 5.92x)
> put_hevc_pel_uni_pixels32_8_c: 1135.8 ( 1.00x)
> 517.5 ( 1.00x)
> put_hevc_pel_uni_pixels32_8_rvv_i32: 209.8 ( 5.41x)
> 121.7 ( 4.25x)
> put_hevc_pel_uni_pixels64_8_c: 2617.1 ( 1.00x)
> 1257.0 ( 1.00x)
> put_hevc_pel_uni_pixels64_8_rvv_i32: 709.6 ( 3.69x)
> 486.2 ( 2.59x)
> ---
> libavcodec/hevc/dsp.c | 2 +
> libavcodec/hevc/dsp.h | 1 +
> libavcodec/riscv/Makefile | 2 +
> libavcodec/riscv/hevcdsp.h | 32 +++++++++++++
> libavcodec/riscv/hevcdsp_init.c | 82 +++++++++++++++++++++++++++++++++
> 5 files changed, 119 insertions(+)
> create mode 100644 libavcodec/riscv/hevcdsp.h
> create mode 100644 libavcodec/riscv/hevcdsp_init.c
>
> diff --git a/libavcodec/hevc/dsp.c b/libavcodec/hevc/dsp.c
> index 60f059292c..c2e72cd0f5 100644
> --- a/libavcodec/hevc/dsp.c
> +++ b/libavcodec/hevc/dsp.c
> @@ -265,6 +265,8 @@ int i = 0;
> ff_hevc_dsp_init_arm(hevcdsp, bit_depth);
> #elif ARCH_PPC
> ff_hevc_dsp_init_ppc(hevcdsp, bit_depth);
> +#elif ARCH_RISCV
> + ff_hevc_dsp_init_riscv(hevcdsp, bit_depth);
> #elif ARCH_X86
> ff_hevc_dsp_init_x86(hevcdsp, bit_depth);
> #elif ARCH_MIPS
> diff --git a/libavcodec/hevc/dsp.h b/libavcodec/hevc/dsp.h
> index 02b8e0e8e2..6d77a470ff 100644
> --- a/libavcodec/hevc/dsp.h
> +++ b/libavcodec/hevc/dsp.h
> @@ -133,6 +133,7 @@ extern const int8_t ff_hevc_qpel_filters[4][16];
> void ff_hevc_dsp_init_aarch64(HEVCDSPContext *c, const int bit_depth);
> void ff_hevc_dsp_init_arm(HEVCDSPContext *c, const int bit_depth);
> void ff_hevc_dsp_init_ppc(HEVCDSPContext *c, const int bit_depth);
> +void ff_hevc_dsp_init_riscv(HEVCDSPContext *c, const int bit_depth);
> void ff_hevc_dsp_init_x86(HEVCDSPContext *c, const int bit_depth);
> void ff_hevc_dsp_init_mips(HEVCDSPContext *c, const int bit_depth);
> void ff_hevc_dsp_init_loongarch(HEVCDSPContext *c, const int bit_depth);
> diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile
> index 1f1fa03329..a80d2fa2e7 100644
> --- a/libavcodec/riscv/Makefile
> +++ b/libavcodec/riscv/Makefile
> @@ -35,6 +35,8 @@ RVV-OBJS-$(CONFIG_H264DSP) += riscv/h264addpx_rvv.o
> riscv/h264dsp_rvv.o \
> riscv/h264idct_rvv.o
> OBJS-$(CONFIG_H264QPEL) += riscv/h264qpel_init.o
> RVV-OBJS-$(CONFIG_H264QPEL) += riscv/h264qpel_rvv.o
> +OBJS-$(CONFIG_HEVC_DECODER) += riscv/hevcdsp_init.o
> +RVV-OBJS-$(CONFIG_HEVC_DECODER) += riscv/h26x/h2656_inter_rvv.o
> OBJS-$(CONFIG_HUFFYUV_DECODER) += riscv/huffyuvdsp_init.o
> RVV-OBJS-$(CONFIG_HUFFYUV_DECODER) += riscv/huffyuvdsp_rvv.o
> OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_init.o
> diff --git a/libavcodec/riscv/hevcdsp.h b/libavcodec/riscv/hevcdsp.h
> new file mode 100644
> index 0000000000..7b42e49f41
> --- /dev/null
> +++ b/libavcodec/riscv/hevcdsp.h
> @@ -0,0 +1,32 @@
> +/*
> + * HEVC video decoder
> + *
> + * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences
> (ISCAS).
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> + */
> +
> +#ifndef AVCODEC_RISCV_HEVCDSP_H
> +#define AVCODEC_RISCV_HEVCDSP_H
> +
> +#include <stddef.h>
> +#include <stdint.h>
> +
> +void ff_hevc_put_hevc_pel_uni_pixels_8_rvv_256(uint8_t *dst, ptrdiff_t
> dststride,const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t
> mx, intptr_t my,int width);
> +void ff_hevc_put_hevc_pel_uni_pixels_8_rvv_128(uint8_t *dst, ptrdiff_t
> dststride,const uint8_t *_src, ptrdiff_t _srcstride, int height, intptr_t
> mx, intptr_t my,int width);
> +
> +#endif // AVCODEC_RISCV_HEVCDSP_H
> diff --git a/libavcodec/riscv/hevcdsp_init.c
> b/libavcodec/riscv/hevcdsp_init.c
> new file mode 100644
> index 0000000000..61486fb533
> --- /dev/null
> +++ b/libavcodec/riscv/hevcdsp_init.c
> @@ -0,0 +1,82 @@
> +/*
> + * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences
> (ISCAS).
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> + */
> +
> +#include "config.h"
> +
> +#include "libavutil/attributes.h"
> +#include "libavutil/cpu.h"
> +#include "libavutil/riscv/cpu.h"
> +
> +#include "libavcodec/hevc/dsp.h"
> +#include "libavcodec/riscv/hevcdsp.h"
> +#include "libavcodec/riscv/h26x/h2656dsp.h"
> +
> +#define FW_PUT_UNI(p, a, b, depth, opt) \
> +void ff_hevc_put_hevc_ ## p ## _uni_pixels_ ## depth ## _##opt(uint8_t
> *dst, ptrdiff_t dststride, \
> + const uint8_t
> *src, ptrdiff_t srcstride, \
> + int height,
> intptr_t mx, intptr_t my, int width) \
> +{
> \
> + ff_h2656_put_uni_ ## b ## _ ## depth ## _##opt(dst, dststride, src,
> srcstride, height, NULL, NULL, width); \
> +}
> +
> +#define FW_PUT_FUNCS(p, a, b, depth, opt) \
> + FW_PUT_UNI(p, a, b, depth, opt)
> +
> +FW_PUT_FUNCS(pel, pel_pixels, pixels, 8, rvv_256)
> +FW_PUT_FUNCS(pel, pel_pixels, pixels, 8, rvv_128)
> +
> +#define RVV_FNASSIGN(member, v, h, fn, ext) \
> + member[1][v][h] = ff_hevc_put_hevc_##fn##_##8_##ext; \
> + member[3][v][h] = ff_hevc_put_hevc_##fn##_##8_##ext; \
> + member[5][v][h] = ff_hevc_put_hevc_##fn##_##8_##ext; \
> + member[7][v][h] = ff_hevc_put_hevc_##fn##_##8_##ext; \
> + member[9][v][h] = ff_hevc_put_hevc_##fn##_##8_##ext;
> +
> +void ff_hevc_dsp_init_riscv(HEVCDSPContext *c, const int bit_depth)
> +{
> +#if HAVE_RVV
> + const int flags = av_get_cpu_flags();
> + int vlenb;
> +
> + if (!(flags & AV_CPU_FLAG_RVV_I32) || !(flags & AV_CPU_FLAG_RVB))
> + return;
> +
> + vlenb = ff_get_rv_vlenb();
> + if (vlenb >= 32) {
> + switch (bit_depth) {
> + case 8:
> + RVV_FNASSIGN(c->put_hevc_qpel_uni, 0, 0, pel_uni_pixels,
> rvv_256);
> + RVV_FNASSIGN(c->put_hevc_epel_uni, 0, 0, pel_uni_pixels,
> rvv_256);
> + break;
> + default:
> + break;
> + }
> + } else if (vlenb >= 16) {
> + switch (bit_depth) {
> + case 8:
> + RVV_FNASSIGN(c->put_hevc_qpel_uni, 0, 0, pel_uni_pixels,
> rvv_128);
> + RVV_FNASSIGN(c->put_hevc_epel_uni, 0, 0, pel_uni_pixels,
> rvv_128);
> + break;
> + default:
> + break;
> + }
> + }
> +#endif
> +}
> --
> 2.47.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>
More information about the ffmpeg-devel
mailing list