From patchwork Sun Jul 28 18:19:05 2024 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: 50805 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:16f:b0:489:2eb3:e4c4 with SMTP id h47csp752846vqi; Sun, 28 Jul 2024 11:19:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXk5PPW/MYtIGpk/6Z35u0wLiqiZLe5zYBG5uLi4EuukkHLoGIoCbRY7f6sADJ0x+19qzIWnCkxvaIOymFUd5pwnzDZh/VNvMUhUQ== X-Google-Smtp-Source: AGHT+IErEbK2PkoveAL80HCH9fxtxufBO4lgHFBgH56PspCMr9VJOtbG/TfKvlQJfaMRlM2XRfwB X-Received: by 2002:a17:907:728e:b0:a77:bfca:da57 with SMTP id a640c23a62f3a-a7d401769bfmr375104566b.44.1722190757531; Sun, 28 Jul 2024 11:19:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722190757; cv=none; d=google.com; s=arc-20160816; b=VLwvO3xldxoevUgFO55Tqog4XsvirvdOz+tGpFt0Tie4M3GK8Gq4xBgIXaJwFcdc1H bII0IhssJBwWTdfRIYJ6xgQ44UFEF7DpygqVzdGRbBkaMrv3zRggwrj/hCMgPyQ9Zxy4 Y9dQaaDWZQwpcuDwRuBEsdW/EYEIEqgrFlG8+BdN0ZDgtoerB3Cue7a2s9WP+R3tdjqU sFvKnOMjnXxY/ottXcgNldjNWh2rJCBdWqrE/O6GOwP56M1o1et3SYhSS3eTWWlhKA2p HTQQsFQ7i14RoZ+Wyym23vkxVAyfCIgGPWPQMF5/6AVI2cHxyU6NHhGFNpYe93Ve6duX GyQQ== 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=JhcpXQ9zxb3ela8oNy8ZxnSyAzYCoa0nclHgJ1xJMwU=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=m0ggIZ2hgNoOeaeAZEGG8fpgVqfYmVO0PrYnFMYlLTO3r4FyR7MEsKIfSygfmLtuWh ON1+3Kz0R/BSbEF9iAU5a7Ca6poD9wiam1cl8g24qNFoSlFd33axhXEs25mVXyyp1gzB 8et4I5GgBejJHqnkRU4UrjXlYr3piR+TwnzpMU4kHh0T5zj8jVYBekntaDc78NRbQl/L k72EHHdPnjlVCev/8cabVHe4a5kot4ojWWWZ9/5o+rgSnQO43PaGPHeL/Z7p//vkTvaG zDU6XFGB2uR7mgQFDnoxmtyxq+/jHxLxLBtLgX8x3ee6TSaLcgt59hWM3OYwIgYaCvqv WF/g==; dara=google.com 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 a640c23a62f3a-a7acab3dc16si529133566b.339.2024.07.28.11.19.17; Sun, 28 Jul 2024 11:19: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 F025B68D8BE; Sun, 28 Jul 2024 21:19:13 +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 9068D68D7A9 for ; Sun, 28 Jul 2024 21:19:07 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id DED93C0137 for ; Sun, 28 Jul 2024 21:19:06 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 28 Jul 2024 21:19:05 +0300 Message-ID: <20240728181906.72673-1-remi@remlab.net> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc/bswapdsp: add RV Zvbb bswap16 and bswap32 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: zD4FLew/zQlB --- libavcodec/riscv/Makefile | 1 + libavcodec/riscv/bswapdsp_init.c | 11 ++++++- libavcodec/riscv/bswapdsp_rvvb.S | 52 ++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 libavcodec/riscv/bswapdsp_rvvb.S diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 0bbdd38116..8195c7a388 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -16,6 +16,7 @@ RVV-OBJS-$(CONFIG_BLOCKDSP) += riscv/blockdsp_rvv.o OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o RV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvb.o RVV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvv.o +RVVB-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvvb.o OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_init.o RVV-OBJS-$(CONFIG_EXR_DECODER) += riscv/exrdsp_rvv.o OBJS-$(CONFIG_FLAC_DECODER) += riscv/flacdsp_init.o diff --git a/libavcodec/riscv/bswapdsp_init.c b/libavcodec/riscv/bswapdsp_init.c index d490c434e7..ce36d419d2 100644 --- a/libavcodec/riscv/bswapdsp_init.c +++ b/libavcodec/riscv/bswapdsp_init.c @@ -27,6 +27,8 @@ void ff_bswap32_buf_rvb(uint32_t *dst, const uint32_t *src, int len); void ff_bswap16_buf_rvv(uint16_t *dst, const uint16_t *src, int len); +void ff_bswap32_buf_rvvb(uint32_t *dst, const uint32_t *src, int len); +void ff_bswap16_buf_rvvb(uint16_t *dst, const uint16_t *src, int len); av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c) { @@ -39,8 +41,15 @@ av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c) c->bswap_buf = ff_bswap32_buf_rvb; #endif #if HAVE_RVV - if (flags & AV_CPU_FLAG_RVV_I32) + if (flags & AV_CPU_FLAG_RVV_I32) { c->bswap16_buf = ff_bswap16_buf_rvv; +# if HAVE_RV_ZVBB + if (flags & AV_CPU_FLAG_RV_ZVBB) { + c->bswap_buf = ff_bswap32_buf_rvvb; + c->bswap16_buf = ff_bswap16_buf_rvvb; + } +# endif + } #endif } #endif diff --git a/libavcodec/riscv/bswapdsp_rvvb.S b/libavcodec/riscv/bswapdsp_rvvb.S new file mode 100644 index 0000000000..165ac104a9 --- /dev/null +++ b/libavcodec/riscv/bswapdsp_rvvb.S @@ -0,0 +1,52 @@ +/* + * Copyright © 2024 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_bswap32_buf_rvvb, zve32x, zvbb, zba + lpad 0 +1: + vsetvli t0, a2, e32, m8, ta, ma + vle32.v v8, (a1) + sub a2, a2, t0 + vrev8.v v8, v8 + sh2add a1, t0, a1 + vse32.v v8, (a0) + sh2add a0, t0, a0 + bnez a2, 1b + + ret +endfunc + +func ff_bswap16_buf_rvvb, zve32x, zvbb, zba + lpad 0 +1: + vsetvli t0, a2, e16, m8, ta, ma + vle16.v v8, (a1) + sub a2, a2, t0 + vrev8.v v8, v8 + sh1add a1, t0, a1 + vse16.v v8, (a0) + sh1add a0, t0, a0 + bnez a2, 1b + + ret +endfunc