From patchwork Sun Nov 12 20:14:07 2023 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: 44644 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:92a5:b0:181:818d:5e7f with SMTP id q37csp962677pzg; Sun, 12 Nov 2023 12:14:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IGks/fn3d9cv4Kes9ZQuTyLfSfvNgQzS6f/2O6p/OVrvLTQBHqZRh5ZbC4cQuH3KpgTWnsX X-Received: by 2002:a19:ac03:0:b0:508:1a25:a190 with SMTP id g3-20020a19ac03000000b005081a25a190mr3070269lfc.23.1699820062931; Sun, 12 Nov 2023 12:14:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699820062; cv=none; d=google.com; s=arc-20160816; b=oV+e9dEh0lgMd57FrB2gsGVHsUX40YFE3xAKjxqOxVAy3vpAXzKYAjw7sfhCnuNhoi 8Fflf1WmchPmx8eonU1Mco08qdcz36iBbAUVCyg9hwpGPh3QEkE4n4gGC1gUy6k3ok98 qsWvvOomlY2EOdUK6NpQh8/Vm2ef1qxLT1lkhwbIOIYP4AFFhTRY4M/Q7Bc6cy4LxAmp IkcR7UgWVEFw0sQ4oChQBHSQsiMxL/vsyfu5HQgqfOAnU5wuuS0RCNb37oegFWxVV9dR x9irQy8EwouCe/Yuu6gT/cMYuPVQfGNU8egNGeXA+k+tbkpaqrPTSUloFhMrULJA8WJN KpKQ== 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:message-id:date:to:from :delivered-to; bh=HT7sZvQp1vq9b7pT4APy8D2aaOwrZaK/6oo5o4N0KM0=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=hBy+hD3+LVAeDKNsiZSidnSkw9PCmsqes7qx4xFhIDSoFBIarinWgdG2CvV9keWuFH CaR4yujID4h/xFeSohOGlK9YKejlsSiqRm39A01hvrkNJ01fmUfMiO2qQ6xxxwKpQ6HV OthCaW0yv8PBLSM1RevrLrTJnBcK7scRMW6ETWmCP3o4q9/dDXvCNANt9RUzrilItllZ kryYs72VV2lOm1oMBeG/wqiUMyONiWXuwrvvVV0eWTm9nECcamDVfAgh9yBrT/EjfmiQ vxn40gBCIENPKfD3uCKtJklfFfmijzS9RaQvDz9Kq9c0YfGi5auE8k7vvO33yZQydYGa itYg== 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 x59-20020a50bac1000000b00540486f3f9fsi1899085ede.420.2023.11.12.12.14.22; Sun, 12 Nov 2023 12:14:22 -0800 (PST) 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 D1E0C68CC09; Sun, 12 Nov 2023 22:14:13 +0200 (EET) 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 AA9EC68CADE for ; Sun, 12 Nov 2023 22:14:11 +0200 (EET) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id C8F47C006F for ; Sun, 12 Nov 2023 22:14:10 +0200 (EET) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 12 Nov 2023 22:14:07 +0200 Message-ID: <20231112201410.25525-1-remi@remlab.net> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] lavc/llauddsp: R-V V scalarproduct_and_madd_int16 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: Ic8T0iDoRO5J scalarproduct_and_madd_int16_c: 10355.7 scalarproduct_and_madd_int16_rvv_i32: 1480.0 --- libavcodec/lossless_audiodsp.c | 2 ++ libavcodec/lossless_audiodsp.h | 1 + libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/llauddsp_init.c | 40 ++++++++++++++++++++++++++++ libavcodec/riscv/llauddsp_rvv.S | 45 ++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+) create mode 100644 libavcodec/riscv/llauddsp_init.c create mode 100644 libavcodec/riscv/llauddsp_rvv.S diff --git a/libavcodec/lossless_audiodsp.c b/libavcodec/lossless_audiodsp.c index 1daf2e4c12..b0d64cf5b3 100644 --- a/libavcodec/lossless_audiodsp.c +++ b/libavcodec/lossless_audiodsp.c @@ -63,6 +63,8 @@ av_cold void ff_llauddsp_init(LLAudDSPContext *c) ff_llauddsp_init_arm(c); #elif ARCH_PPC ff_llauddsp_init_ppc(c); +#elif ARCH_RISCV + ff_llauddsp_init_riscv(c); #elif ARCH_X86 ff_llauddsp_init_x86(c); #endif diff --git a/libavcodec/lossless_audiodsp.h b/libavcodec/lossless_audiodsp.h index eea5d49fa9..cf2d43d7c9 100644 --- a/libavcodec/lossless_audiodsp.h +++ b/libavcodec/lossless_audiodsp.h @@ -46,6 +46,7 @@ typedef struct LLAudDSPContext { void ff_llauddsp_init(LLAudDSPContext *c); void ff_llauddsp_init_arm(LLAudDSPContext *c); void ff_llauddsp_init_ppc(LLAudDSPContext *c); +void ff_llauddsp_init_riscv(LLAudDSPContext *c); void ff_llauddsp_init_x86(LLAudDSPContext *c); #endif /* AVCODEC_LOSSLESS_AUDIODSP_H */ diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 2c9af16782..57c1708dbb 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -24,6 +24,8 @@ OBJS-$(CONFIG_HUFFYUV_DECODER) += riscv/huffyuvdsp_init.o RVV-OBJS-$(CONFIG_HUFFYUV_DECODER) += riscv/huffyuvdsp_rvv.o OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_init.o RVV-OBJS-$(CONFIG_IDCTDSP) += riscv/idctdsp_rvv.o +OBJS-$(CONFIG_LLAUDDSP) += riscv/llauddsp_init.o +RVV-OBJS-$(CONFIG_LLAUDDSP) += riscv/llauddsp_rvv.o OBJS-$(CONFIG_OPUS_DECODER) += riscv/opusdsp_init.o RVV-OBJS-$(CONFIG_OPUS_DECODER) += riscv/opusdsp_rvv.o OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o \ diff --git a/libavcodec/riscv/llauddsp_init.c b/libavcodec/riscv/llauddsp_init.c new file mode 100644 index 0000000000..ea023f73e6 --- /dev/null +++ b/libavcodec/riscv/llauddsp_init.c @@ -0,0 +1,40 @@ +/* + * Copyright © 2023 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/attributes.h" +#include "libavutil/cpu.h" +#include "libavcodec/lossless_audiodsp.h" + +int32_t ff_scalarproduct_and_madd_int16_rvv(int16_t *v1, const int16_t *v2, + const int16_t *v3, int len, + int mul); + +av_cold void ff_llauddsp_init_riscv(LLAudDSPContext *c) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB_ADDR)) { + c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_rvv; + } +#endif +} diff --git a/libavcodec/riscv/llauddsp_rvv.S b/libavcodec/riscv/llauddsp_rvv.S new file mode 100644 index 0000000000..74adb338a9 --- /dev/null +++ b/libavcodec/riscv/llauddsp_rvv.S @@ -0,0 +1,45 @@ +/* + * Copyright © 2023 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 "libavutil/riscv/asm.S" + +func ff_scalarproduct_and_madd_int16_rvv, zve32x + vsetvli t0, zero, e32, m8, ta, ma + vmv.v.x v0, zero +1: + vsetvli t0, a3, e16, m4, tu, ma + vle16.v v8, (a0) + sub a3, a3, t0 + vle16.v v16, (a1) + sh1add a1, t0, a1 + vwmacc.vv v0, v8, v16 + vle16.v v24, (a2) + sh1add a2, t0, a2 + vmacc.vx v8, a4, v24 + vse16.v v8, (a0) + sh1add a0, t0, a0 + bnez a3, 1b + + vsetvli t0, zero, e32, m8, ta, ma + vmv.s.x v8, zero + vredsum.vs v0, v0, v8 + vmv.x.s a0, v0 + ret +endfunc From patchwork Sun Nov 12 20:14:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 44643 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:92a5:b0:181:818d:5e7f with SMTP id q37csp962625pzg; Sun, 12 Nov 2023 12:14:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IFtLyhXrrJLnorY+hHD5X1pmFt47rDm90RJ6URDJH7nhE9wcxjmGW1ndSq5YAx+mVMAg8A/ X-Received: by 2002:a17:906:897:b0:9c7:5a01:ffe7 with SMTP id n23-20020a170906089700b009c75a01ffe7mr3210649eje.12.1699820055848; Sun, 12 Nov 2023 12:14:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699820055; cv=none; d=google.com; s=arc-20160816; b=f+lIcmI1UgmcJkKYie/ZcdJ+MKrfAiDvxAIO5oTD13WbvThssOLg1YzTGu3MhLUExq 0HqddjXUBeGD9kHQAumXzlF07L11KW4aJ78CrlXxQsMmVh4RsN1jGvEUd1tD0SeHj8dv 7bB8yTHjEpbZ3U83ZXwSkEL6Zy1K3pi/87L6CusTa2j9PpMGLcQx0JwqAQNaVHR/VqN5 Q6RBTV9wcGmN5Dwi5IWIQ/O3LOofRzniXLYJIkyz84aeAPy+2+5vwdbU5v1iy6M30bGO RXpJj5RvKF6tp0e3f/oq8exRvyVvPtmPlyXhfwtaYfb+wJVxZqs7VuxMZ9x0U6MBKLsh eTzg== 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=LytR7GS50pRQJYcTdyeVDs2klkyfzexWlTiSVqX/1zk=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=trpnLuXhh1HVEJVr7quNnncA0eEVaHLhzsIhbbyyTKmFK5MM4U33N0Yv3dZUFyfTBq P96rd8cMyvOGIAJtPiwuNtlMk3LU9e2qVcxokseoMBotOz6YWUl11q/BIA2+tfgTQOV2 YYFeSb68lG/KhyuTlTiImtg6ICnJo8XHjB6OVJ+AGYp6plYgJrQMl8dcVbZnlfccktqA AB+LoLHUORjiuxQR4Tie+srfyRsUII30e9PISdNO5eeH7JPeBY8OYstgER7sTHV1x64w 3ecFrY9fhUfaSF89hK9L15nJ6/MQdzAe8x7H8Wp/WEgoZKn4dG1uUyZHbxR3LjN3A8/2 lodw== 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 q16-20020a17090622d000b009e0e6097d89si1949968eja.106.2023.11.12.12.14.15; Sun, 12 Nov 2023 12:14:15 -0800 (PST) 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 CB7DD68CC67; Sun, 12 Nov 2023 22:14:12 +0200 (EET) 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 A77C668CA9B for ; Sun, 12 Nov 2023 22:14:11 +0200 (EET) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 03AE3C009A for ; Sun, 12 Nov 2023 22:14:10 +0200 (EET) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 12 Nov 2023 22:14:08 +0200 Message-ID: <20231112201410.25525-2-remi@remlab.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231112201410.25525-1-remi@remlab.net> References: <20231112201410.25525-1-remi@remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] lavc/llauddsp: R-V V scalarproduct_and_madd_int32 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: RJJ6gnqLva59 scalarproduct_and_madd_int32_c: 10899.7 scalarproduct_and_madd_int32_rvv_i32: 1749.0 --- libavcodec/riscv/llauddsp_init.c | 4 ++++ libavcodec/riscv/llauddsp_rvv.S | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/libavcodec/riscv/llauddsp_init.c b/libavcodec/riscv/llauddsp_init.c index ea023f73e6..1924b36821 100644 --- a/libavcodec/riscv/llauddsp_init.c +++ b/libavcodec/riscv/llauddsp_init.c @@ -27,6 +27,9 @@ int32_t ff_scalarproduct_and_madd_int16_rvv(int16_t *v1, const int16_t *v2, const int16_t *v3, int len, int mul); +int32_t ff_scalarproduct_and_madd_int32_rvv(int16_t *v1, const int32_t *v2, + const int16_t *v3, int len, + int mul); av_cold void ff_llauddsp_init_riscv(LLAudDSPContext *c) { @@ -35,6 +38,7 @@ av_cold void ff_llauddsp_init_riscv(LLAudDSPContext *c) if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB_ADDR)) { c->scalarproduct_and_madd_int16 = ff_scalarproduct_and_madd_int16_rvv; + c->scalarproduct_and_madd_int32 = ff_scalarproduct_and_madd_int32_rvv; } #endif } diff --git a/libavcodec/riscv/llauddsp_rvv.S b/libavcodec/riscv/llauddsp_rvv.S index 74adb338a9..5569864832 100644 --- a/libavcodec/riscv/llauddsp_rvv.S +++ b/libavcodec/riscv/llauddsp_rvv.S @@ -43,3 +43,29 @@ func ff_scalarproduct_and_madd_int16_rvv, zve32x vmv.x.s a0, v0 ret endfunc + +func ff_scalarproduct_and_madd_int32_rvv, zve32x + vsetvli t0, zero, e32, m8, ta, ma + vmv.v.x v0, zero +1: + vsetvli t0, a3, e32, m8, tu, ma + vle16.v v8, (a0) + sub a3, a3, t0 + vsext.vf2 v24, v8 + vle32.v v16, (a1) + sh2add a1, t0, a1 + vmacc.vv v0, v16, v24 + vsetvli zero, zero, e16, m4, ta, ma + vle16.v v24, (a2) + sh1add a2, t0, a2 + vmacc.vx v8, a4, v24 + vse16.v v8, (a0) + sh1add a0, t0, a0 + bnez a3, 1b + + vsetvli t0, zero, e32, m8, ta, ma + vmv.s.x v8, zero + vredsum.vs v0, v0, v8 + vmv.x.s a0, v0 + ret +endfunc