From patchwork Sun Sep 25 14:26:08 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: 38299 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a05:6a10:9905:b0:2f4:3559:b653 with SMTP id j5csp1811122pxh; Sun, 25 Sep 2022 07:29:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5gi0nmcHpckVXMuxh1Fzo+99keoFxwvKpaVoixpllFNc6V5HZbSdD05BT9j0qRGxuWBQjM X-Received: by 2002:a17:907:2d89:b0:781:eff0:9999 with SMTP id gt9-20020a1709072d8900b00781eff09999mr14675189ejc.194.1664116157546; Sun, 25 Sep 2022 07:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664116157; cv=none; d=google.com; s=arc-20160816; b=xnwc0i/otu90wyXOi37tLZKrSIjvBXrdDRSeT/oFSxM8lOO7UX1b6LBuYdWlGSveN1 ySy5N0BmwhRUfsqSfziYwZrrhPXGhY9171zJTHhhm+Iv4Jwxoc9o6mAuymkCKf5QO9xX k7+KyFV2QZr4WFpT+f19ZWgRU2ykAaWLuJiK9bbgPfMCZ7PR6ke7ZnrsoWViA40tUa6/ z0AmFsulU0+53uWVlyZ/ahhn/oSqs7TI0Xs/ZghOv5CcDknT87hL2dpTVCuxi0ZUrBAX 4iO9iPAkD9WNYhQp5B9uSLzVUB21FC9+aPkPZUaehns5nP0t/j5bZTcqdRWXP4xUVvtm bxUQ== 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=LmuxczhjW/9VF6jH/2qMcFDG/XCQ1l1aswDe0vSskEU=; b=KQXPxXNP+H+soWcNASC69J6g2qrJj9cynG53oRLyrrEzCWI4cI+RfG1IjqkRRpJVAc iHe+TQIG+I6R8fSYGfa453dBHWS8Gkxiw89e393mhKUU0ivgrUDdwCXLXSMEK4ZuTOSG A9Yp1N5UBta8WAB8jkX57Lu9CmhKSUQsuNyV2CsIbgiomR4g3iKxJLEZGxxkq76N+omL CzHWSU3IYnatEYSfEK67VqTzgKM6OG+2i92HIkl1r7Ncr2Cd8MQtTBY7hhXDmAE0HMb3 5JpkqbhcYiT0fuufjpddzoHCv6CKqVDGYSvDiF5WCS33L/0jUoqLRsMqvYZvECpGi/rQ LaCw== 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 qf23-20020a1709077f1700b0078363fceadbsi1102583ejc.528.2022.09.25.07.29.17; Sun, 25 Sep 2022 07:29:17 -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 042FA68BC10; Sun, 25 Sep 2022 17:26:44 +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 1F76D68BB45 for ; Sun, 25 Sep 2022 17:26:26 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 09B7BC00C0 for ; Sun, 25 Sep 2022 17:26:22 +0300 (EEST) From: remi@remlab.net To: ffmpeg-devel@ffmpeg.org Date: Sun, 25 Sep 2022 17:26:08 +0300 Message-Id: <20220925142619.67917-20-remi@remlab.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <5861881.lOV4Wx5bFT@basile.remlab.net> References: <5861881.lOV4Wx5bFT@basile.remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 20/31] lavc/audiodsp: RISC-V V vector_clip_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: Yusah4SUP8zC Content-Length: 4543 From: Rémi Denis-Courmont --- libavcodec/riscv/Makefile | 1 + libavcodec/riscv/audiodsp_init.c | 9 ++++++++ libavcodec/riscv/audiodsp_rvv.S | 36 ++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 libavcodec/riscv/audiodsp_rvv.S diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index da07f1fe96..99541b075e 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -1,4 +1,5 @@ OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o \ riscv/audiodsp_rvf.o +RVV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvv.o OBJS-$(CONFIG_PIXBLOCKDSP) += riscv/pixblockdsp_init.o \ riscv/pixblockdsp_rvi.o diff --git a/libavcodec/riscv/audiodsp_init.c b/libavcodec/riscv/audiodsp_init.c index c5842815d6..ce8b60ee52 100644 --- a/libavcodec/riscv/audiodsp_init.c +++ b/libavcodec/riscv/audiodsp_init.c @@ -18,16 +18,25 @@ * 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/audiodsp.h" void ff_vector_clipf_rvf(float *dst, const float *src, int len, float min, float max); +void ff_vector_clip_int32_rvv(int32_t *dst, const int32_t *src, int32_t min, + int32_t max, unsigned int len); + av_cold void ff_audiodsp_init_riscv(AudioDSPContext *c) { int flags = av_get_cpu_flags(); if (flags & AV_CPU_FLAG_RVF) c->vector_clipf = ff_vector_clipf_rvf; +#if HAVE_RVV + if (flags & AV_CPU_FLAG_RV_ZVE32X) + c->vector_clip_int32 = ff_vector_clip_int32_rvv; +#endif } diff --git a/libavcodec/riscv/audiodsp_rvv.S b/libavcodec/riscv/audiodsp_rvv.S new file mode 100644 index 0000000000..49546ee3c4 --- /dev/null +++ b/libavcodec/riscv/audiodsp_rvv.S @@ -0,0 +1,36 @@ +/* + * 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 "libavutil/riscv/asm.S" + +func ff_vector_clip_int32_rvv, zve32x +1: + vsetvli t0, a4, e32, m1, ta, ma + vle32.v v8, (a1) + sub a4, a4, t0 + vmax.vx v8, v8, a2 + sh2add a1, t0, a1 + vmin.vx v8, v8, a3 + vse32.v v8, (a0) + sh2add a0, t0, a0 + bnez a4, 1b + + ret +endfunc