From patchwork Thu Sep 22 18:37:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 38177 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp516151pzh; Thu, 22 Sep 2022 11:40:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ZcG2H+D3Qr2f9nHGhL+FIgr1QEOCPV4KRdn5Q8l9I0MJmfXc1RIhxhEVuA23qcchN17/G X-Received: by 2002:a17:906:6a0e:b0:782:31be:e91 with SMTP id qw14-20020a1709066a0e00b0078231be0e91mr3994188ejc.280.1663872029112; Thu, 22 Sep 2022 11:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663872029; cv=none; d=google.com; s=arc-20160816; b=YhQ4K7SGVHkXHjPzrNF2YLQESY/N3FeZ0B9I1Jej7mTxpkNkHMfWaZoBKsVjkZsnmX FMxmFot3aT8u38E5F1fxqVyfZSSAdli2bgLv6xidGg8t7GpkgzVvIwf9q96ZzlFEjKoh CK2Z2PU7SfRlXXjnYjhrDGfbBoCAXHHsQ0dwcDQ0GUQOU8JTmUUDK7BI4g1KFBeLAypg p1JWG1RaP+Hix5D2MHMyNLuL6X4h6VyARGe/aMrX/n53CxCRjHhAEV9RxRvIxrWObMz6 PKeIUjEFD4Nu5BnSFnP9z4I/Jb7X8TQSc5WUyqHRj+sE8Kv+p7RgKDo163cVzBwvB43d orLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=cdmDsMaaddQKtwH0QDNn1WhvHX0lITx4vDVNUkjOpW4=; b=VQjX4pm2afwnU229qE8gWOcvHYkuC7P5XdekTB+qWfH1KM9sTVn5Bu5ma0Fd1hhWrB R/TaQrSRe1CLaGtkWp/QIxzzQ3VfWJ6tHvnkrZsYV6Kw4fiyEa6vN1E0gCKvPMDGlE+V O0nmzK0iCiigQopn6Tnv9OEiv/7ojB2txg2rgxj7om9+i9qaRadweYLAgaRPZloisXGB SSTxQ7ZKK5tx59VQVCV5B9KwkOPSYtEPQ/GRnAWZlOOoHslSR0YonWea+cV92uufuY0E h7OSCeHvSdNLhUNfAXMoG1CtIVSL5VWfdM+X6ameZIIbFEvKLBKLp0UrmCV9kJz0bVkZ fKNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id dt8-20020a170907728800b00770880dff50si6354570ejc.586.2022.09.22.11.40.28; Thu, 22 Sep 2022 11:40:29 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 08B1F68BB39; Thu, 22 Sep 2022 21:37:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 560D068BB5A for ; Thu, 22 Sep 2022 21:37:32 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 2D7BCC00C2 for ; Thu, 22 Sep 2022 21:37:30 +0300 (EEST) From: remi@remlab.net To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Sep 2022 21:37:19 +0300 Message-Id: <20220922183726.38624-22-remi@remlab.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <12078904.O9o76ZdvQC@basile.remlab.net> References: <12078904.O9o76ZdvQC@basile.remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 22/29] lavc/fmtconvert: RISC-V V int32_to_float_fmul_scalar X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: A7j/RUA21Zvr From: Rémi Denis-Courmont --- libavcodec/fmtconvert.c | 2 ++ libavcodec/fmtconvert.h | 1 + libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/fmtconvert_init.c | 39 +++++++++++++++++++++++++++++ libavcodec/riscv/fmtconvert_rvv.S | 40 ++++++++++++++++++++++++++++++ 5 files changed, 84 insertions(+) create mode 100644 libavcodec/riscv/fmtconvert_init.c create mode 100644 libavcodec/riscv/fmtconvert_rvv.S diff --git a/libavcodec/fmtconvert.c b/libavcodec/fmtconvert.c index cedfd61138..d889e61aca 100644 --- a/libavcodec/fmtconvert.c +++ b/libavcodec/fmtconvert.c @@ -52,6 +52,8 @@ av_cold void ff_fmt_convert_init(FmtConvertContext *c) ff_fmt_convert_init_arm(c); #elif ARCH_PPC ff_fmt_convert_init_ppc(c); +#elif ARCH_RISCV + ff_fmt_convert_init_riscv(c); #elif ARCH_X86 ff_fmt_convert_init_x86(c); #endif diff --git a/libavcodec/fmtconvert.h b/libavcodec/fmtconvert.h index da244e05a5..1cb4628a64 100644 --- a/libavcodec/fmtconvert.h +++ b/libavcodec/fmtconvert.h @@ -61,6 +61,7 @@ void ff_fmt_convert_init(FmtConvertContext *c); void ff_fmt_convert_init_aarch64(FmtConvertContext *c); void ff_fmt_convert_init_arm(FmtConvertContext *c); void ff_fmt_convert_init_ppc(FmtConvertContext *c); +void ff_fmt_convert_init_riscv(FmtConvertContext *c); void ff_fmt_convert_init_x86(FmtConvertContext *c); void ff_fmt_convert_init_mips(FmtConvertContext *c); diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 99541b075e..682174e875 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -1,5 +1,7 @@ OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o \ riscv/audiodsp_rvf.o RVV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvv.o +OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_init.o +RVV-OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_rvv.o OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o \ riscv/pixblockdsp_rvi.o diff --git a/libavcodec/riscv/fmtconvert_init.c b/libavcodec/riscv/fmtconvert_init.c new file mode 100644 index 0000000000..fd2f58d060 --- /dev/null +++ b/libavcodec/riscv/fmtconvert_init.c @@ -0,0 +1,39 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * 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 + +#include "config.h" +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavcodec/fmtconvert.h" + +void ff_int32_to_float_fmul_scalar_rvv(float *dst, const int32_t *src, + float mul, int len); + +av_cold void ff_fmt_convert_init_riscv(FmtConvertContext *c) +{ +#ifdef HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RV_ZVE32F) + c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_rvv; +#endif +} diff --git a/libavcodec/riscv/fmtconvert_rvv.S b/libavcodec/riscv/fmtconvert_rvv.S new file mode 100644 index 0000000000..c19b77e38a --- /dev/null +++ b/libavcodec/riscv/fmtconvert_rvv.S @@ -0,0 +1,40 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * 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/riscv/asm.S" + +func ff_int32_to_float_fmul_scalar_rvv, zve32f +NOHWF fmv.w.x fa0, a2 +NOHWF mv a2, a3 +1: + vsetvli t0, a2, e32, m1, ta, ma + vle32.v v24, (a1) + slli t1, t0, 2 + vfcvt.f.x.v v24, v24 + sub a2, a2, t0 + vfmul.vf v24, v24, fa0 + add a1, a1, t1 + vse32.v v24, (a0) + add a0, a0, t1 + bnez a2, 1b + + ret +endfunc