From patchwork Wed Nov 15 21:04:38 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: 44681 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:92a5:b0:181:818d:5e7f with SMTP id q37csp2967576pzg; Wed, 15 Nov 2023 13:04:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IFuB+b7+b4lF4T4xx+uREOaTLxgIiwVPAtyRPtJkwnaayqNIcsNcJoXGvjky23Kl2F4SRUy X-Received: by 2002:a17:906:25d:b0:9dd:5609:55b9 with SMTP id 29-20020a170906025d00b009dd560955b9mr5123795ejl.2.1700082291009; Wed, 15 Nov 2023 13:04:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700082290; cv=none; d=google.com; s=arc-20160816; b=t2gLYhXtzzCWUJMh5lQ8oGbm8e26abozIBMb3+vXeq5YVafGxLi95t3rnubDgL62MK M/mCz70F0Q8fy4X11g+rZHa/9QDaqmGHf86rxEXVzUAe7L6vM3QDsZTS8vVzO2ycFnCx 60HtApxJD03yyPrfphz7Aq8r0nNoLmN8ZCJekeVOqHj0146B+IqxL9kfy97b7a8yEdTM Y+c8bt/S8jBa3UrqpnB804OZRjs0W+5CtuXHw3mvYaJ24lCAgSTtgV++RwB3fK84XZuZ qW11rJtFnlX9eCqF1dGpoKErjxD8UBvUykFWtI/jiS3L9YrQNXgNifAO3+ULBVyIe5tq qeLA== 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=sHYC5GGmWe9WFMZ825imcNf9JQXeUZHCQSBqkMOEU0s=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=lloZnlY+PnjtwftJs5hRmU9CICDi9++zVzCgK1j9aRCFnjS+3D/grot0ThZ99T0g8H uguU3ha233J/eUl9zCiJwRcU1Khbm5p3ZH+y1W0E3i4Hvx4jruCAQv/JtVhYHOqD3aw1 7BgAw5a5+lXQExm3pm0JtZvXfU994gsysNcroOyRVQQK85yRyswPSSfNWac97LfHSxdD XCWm2rm9b6a4dnA5Ak0wKaMLr7xmgTd0g1bUU0LQhjjz/g6HU45AjazadtKEcVngMn/2 LOsBIgOJlAN+Z9T5L9YVnHB2OwsKW/2V1RyG2AHzbrCiHs5osLjCESnhcaSMDBj0k04A /Tag== 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 ji7-20020a170907980700b009e6bf7b9b3asi5958195ejc.866.2023.11.15.13.04.50; Wed, 15 Nov 2023 13:04:50 -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 506E368CD2A; Wed, 15 Nov 2023 23:04:47 +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 89A3668C3E2 for ; Wed, 15 Nov 2023 23:04:40 +0200 (EET) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id DDE59C006A for ; Wed, 15 Nov 2023 23:04:39 +0200 (EET) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 15 Nov 2023 23:04:38 +0200 Message-ID: <20231115210439.57800-1-remi@remlab.net> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc/llviddsp: R-V V add_bytes 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: 3CMaI/vsci9q add_bytes_c: 2077.2 add_bytes_rvv_i32: 105.0 --- libavcodec/lossless_videodsp.c | 2 ++ libavcodec/lossless_videodsp.h | 1 + libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/llviddsp_init.c | 38 ++++++++++++++++++++++++++++++++ libavcodec/riscv/llviddsp_rvv.S | 36 ++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+) create mode 100644 libavcodec/riscv/llviddsp_init.c create mode 100644 libavcodec/riscv/llviddsp_rvv.S diff --git a/libavcodec/lossless_videodsp.c b/libavcodec/lossless_videodsp.c index 359606981c..876decb1e6 100644 --- a/libavcodec/lossless_videodsp.c +++ b/libavcodec/lossless_videodsp.c @@ -121,6 +121,8 @@ void ff_llviddsp_init(LLVidDSPContext *c) #if ARCH_PPC ff_llviddsp_init_ppc(c); +#elif ARCH_RISCV + ff_llviddsp_init_riscv(c); #elif ARCH_X86 ff_llviddsp_init_x86(c); #endif diff --git a/libavcodec/lossless_videodsp.h b/libavcodec/lossless_videodsp.h index da4baa1414..5309ce4be7 100644 --- a/libavcodec/lossless_videodsp.h +++ b/libavcodec/lossless_videodsp.h @@ -40,6 +40,7 @@ typedef struct LLVidDSPContext { } LLVidDSPContext; void ff_llviddsp_init(LLVidDSPContext *llviddsp); +void ff_llviddsp_init_riscv(LLVidDSPContext *llviddsp); void ff_llviddsp_init_x86(LLVidDSPContext *llviddsp); void ff_llviddsp_init_ppc(LLVidDSPContext *llviddsp); diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index d34dc77458..8f2a519827 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -28,6 +28,8 @@ 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_LLVIDDSP) += riscv/llviddsp_init.o +RVV-OBJS-$(CONFIG_LLVIDDSP) += riscv/llviddsp_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/llviddsp_init.c b/libavcodec/riscv/llviddsp_init.c new file mode 100644 index 0000000000..f042eeab32 --- /dev/null +++ b/libavcodec/riscv/llviddsp_init.c @@ -0,0 +1,38 @@ +/* + * 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_videodsp.h" + +void ff_llvid_add_bytes_rvv(uint8_t *, uint8_t *src, ptrdiff_t w); + +av_cold void ff_llviddsp_init_riscv(LLVidDSPContext *c) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RVV_I32) { + c->add_bytes = ff_llvid_add_bytes_rvv; + } +#endif +} diff --git a/libavcodec/riscv/llviddsp_rvv.S b/libavcodec/riscv/llviddsp_rvv.S new file mode 100644 index 0000000000..a4814837b9 --- /dev/null +++ b/libavcodec/riscv/llviddsp_rvv.S @@ -0,0 +1,36 @@ +/* + * 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_llvid_add_bytes_rvv, zve32x +1: + vsetvli t0, a2, e8, m8, ta, ma + vle8.v v0, (a1) + sub a2, a2, t0 + vle8.v v8, (a0) + add a1, t0, a1 + vadd.vv v8, v0, v8 + vse8.v v8, (a0) + add a0, t0, a0 + bnez a2, 1b + + ret +endfunc