From patchwork Thu Sep 22 18:37:16 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: 38174 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp515916pzh; Thu, 22 Sep 2022 11:40:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4EiYQBwpYyCWCbBa3E88YXgphxsoR1hSlbxtZzrq7CJ70w1F8Rcb/bfUGZVFyrzoIVC1PW X-Received: by 2002:a17:907:75c1:b0:72f:248d:5259 with SMTP id jl1-20020a17090775c100b0072f248d5259mr4012286ejc.227.1663872001752; Thu, 22 Sep 2022 11:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663872001; cv=none; d=google.com; s=arc-20160816; b=g0BIx6+IciZvCakME20ojTgAB6Ho5xgw7+BDR6iWnOqvMKYNCxaUqx2fpS4k1NMF43 lAW1xLC6wVQyw80TzCVf8UJpoB2Q10YyEQa55xPzQTM1EsJ3WXxFSQdJ08rj2aZhb8I8 RZD4yKQpImSeecaxISFDcVBpCeTSk3mVeUr9mH/Q9CUjcOn3L14jaJBumLEAX2eJKPlb FsxmAwQP0v9+2QWBOYf+OYmWRNwME+AI+pytpM9iwS+OmBgHVLRHNka+KsgDrjzO4098 Qp1i1fu2s6jxHcPfpWWvapIa54lFWpVWsS8uZK7hdQgtCDJveIUfbMyLQdzRW3/jfHOx 9x3g== 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=1RYK1tQgLNxt8Pxer3ctLUAd+AgIEG36x5FafxYTHN4=; b=034lAGcWWNpcJzoq0A3L6XxjbS6ilInbnyv9f1uTFMeQ9yfH2s5nFr/Sr0m3tsukEn tK4MdXFUmuSKAQoJzP+x+CkEDaZO2f54bwRR54iExGvPZAZWlaMh4p2Tb7Xe9Uwn7CRA ZI1zTcjOxynhxZY5yjzCVkL6AVskCLtKUhZ4J+z0r2/p1F0mATBYKKNsUHmLWKgTHE1G 2qDcESfELCWKawGQzl2dvDzksHMqNMC5OUThut3ScDXfcDB4eLHSatbR3TsarCDlaCAt TYkI6u9smsxAc2pJOzoAqkjo3qBxb/NGYU+L3YLO8TT0qGHdE00xaT30c+5Rbe0l38tB b0HA== 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 dt9-20020a170907728900b0077f2c399241si6759609ejc.243.2022.09.22.11.40.01; Thu, 22 Sep 2022 11:40:01 -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 E55FA68BB49; Thu, 22 Sep 2022 21:37:50 +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 452F468B9A5 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 99864C00BF for ; Thu, 22 Sep 2022 21:37:29 +0300 (EEST) From: remi@remlab.net To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Sep 2022 21:37:16 +0300 Message-Id: <20220922183726.38624-19-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 19/29] 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: 3QgnmAV1lOeB From: Rémi Denis-Courmont --- libavcodec/riscv/Makefile | 1 + libavcodec/riscv/audiodsp_init.c | 9 ++++++++ libavcodec/riscv/audiodsp_rvv.S | 37 ++++++++++++++++++++++++++++++++ 3 files changed, 47 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..26b3cdffcf --- /dev/null +++ b/libavcodec/riscv/audiodsp_rvv.S @@ -0,0 +1,37 @@ +/* + * 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) + slli t1, t0, 2 + vmax.vx v8, v8, a2 + add a1, a1, t1 + vmin.vx v8, v8, a3 + sub a4, a4, t0 + vse32.v v8, (a0) + add a0, a0, t1 + bnez a4, 1b + + ret +endfunc