From patchwork Tue Sep 20 14:40:06 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: 38091 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp1989832pzh; Tue, 20 Sep 2022 07:42:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4m1WXql/29JC5ypV/DXfrOgf2zGjM64WLgEVIMwDndjcZmWE866qAjWiN8V9O8Z/Arm+Aw X-Received: by 2002:a17:907:2d88:b0:781:44ff:443f with SMTP id gt8-20020a1709072d8800b0078144ff443fmr8751602ejc.358.1663684962231; Tue, 20 Sep 2022 07:42:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663684962; cv=none; d=google.com; s=arc-20160816; b=dHhkzpqnk0+fJU30U6pskny0YmuIKHH5zZ44ju0f9unrj6wcoZD55sascjVtn2U3yO bb3CVXMLvs3zSfBJKnDHUxhHeFimvlzzn8BFUbWS8O7MAhM5AYp1iUpoey7uY0etwfAz qn24unnnib1VWDwVvJH+XJ0lwg9fxF9K0qLD1AevAg7oVJwk9t+z4PiMN4biD5WlsV01 ESKsS5xLa7Y8PBV74SAtaOgIfjWr+CSvLM7mO4xYtx+/ynFdVD6o7+/o2bMqXYk+RBNP 0yvcPnmevwHfjnJrJM7ToYObVeQtJYCt/N0TA0kkVwTJ+RjQ7Ru8XgPDgFJHir2C7slA Iyyw== 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=mELXzkTYUT94Aa1XZmRDohs950wvnfXWowdnpKS6rG8yQR6Sdge8bjllMD9GVkm5od P2IquLhLKH2AJJPx1t4oaUpA9QY7yd3OuVcDg8YR6W7FbQx6GT1MOYzpHL+zzl96ytJM fuUuKNaLco0QAqEnwRp5d/MyE8xLTqJA2SzU9oEWeH36uRb+wel5F0hfzBiqPEsEDAHx dyXdb8HrHFjNfwDGrFNHlD7XICt6AA99vi7E2wFW5Pg1z1OaYREGf04tZsJQl2xlVGgm TCQTJFgW4gBvPqzotI335pdV2atxV6jbkwGZDYuYhUwrgmCd7Mb2ql4L1vdmjhn5UF4n euTA== 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 t25-20020a170906065900b0073d8830e4c7si1081505ejb.954.2022.09.20.07.42.41; Tue, 20 Sep 2022 07:42:42 -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 805B168BA3B; Tue, 20 Sep 2022 17:40:37 +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 3D05468BA6F for ; Tue, 20 Sep 2022 17:40:20 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 4BFB6C00BF for ; Tue, 20 Sep 2022 17:40:17 +0300 (EEST) From: remi@remlab.net To: ffmpeg-devel@ffmpeg.org Date: Tue, 20 Sep 2022 17:40:06 +0300 Message-Id: <20220920144013.4959-19-remi@remlab.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <5602865.DvuYhMxLoT@basile.remlab.net> References: <5602865.DvuYhMxLoT@basile.remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 19/26] 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: y84zkKGNqSag 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