From patchwork Sun Nov 19 20:23:55 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: 44726 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6a89:b0:181:818d:5e7f with SMTP id bi9csp1210743pzb; Sun, 19 Nov 2023 12:24:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IG8olq/wJMXZOUkNWsLZ9x+hDEzZZtCLSSYd4M9JWGcgwhhNTzid+WaE/ujRI3Eu7atEW6I X-Received: by 2002:a19:ac03:0:b0:504:30eb:f2ac with SMTP id g3-20020a19ac03000000b0050430ebf2acmr3957013lfc.68.1700425453548; Sun, 19 Nov 2023 12:24:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700425453; cv=none; d=google.com; s=arc-20160816; b=DRVHjUz9SP5EN/nOJv4u+B2rYqJ+0YCvI2uq4Fz1Cjwt5kJKpyV/w0xBUJvQoENDtR MPbzvMzgRewL7LMeRCb0jRYdaO7tOwu/ADLpWgvNwZGZeqKLuQq1Brol/nfPr3Edltv3 rsD1UXqRemwAFSUunUvmLS6kzW3TdW4LNuNuWFj97xViEn5h+5DWvLVILB7dnmwStkSC D5Jim/LQzLYuYQL70K+1H2lON3hjFAAfWOj+fAkC2zQFjCKoo0GBmkrUCBKKaSYh7Jon Vcl1/UAlzL5CTL6s/L7QEeGulaZ9h9RIltfHD2+cg7bEb6RvdD+fB4n1W+q8Ul9iv3Xn 7PWg== 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=2dqon6p2u4M3UweWvO4uJ6XJLTnhJgyiY73vpgYM1LQ=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=EVZG2hWZdMstP24B6G4DM6BBC8o93C8YnkotT7F7oaGTYnrN7tJNUYof33Ks7iqLSx DRBoGjeCDE89V6FV0Tjf9tgDseDQRySxuK8idwv3+RsjWq1Q1QUCOczRfWcPVSbt3hsC 9Cd/IdhpFCYCd+pKlMHLNvPW5YUwXA/PJ8li3aHSalWbwc5rxy1uA7UbXTBmeKnLkJyl Gnyg8XLQevcpt14a1K+sZIrlK7bTbE4BxLyHSewUcY5ErdIbXN/H9BhE83q+8SasD+cZ xxmoeSq2/tVuPYkkYEQV+1ssKuJVYBJ/cirWjhZMNWJMM9IxF4m90OYrJDTMPGWx9A5y PNiA== 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 e5-20020a50a685000000b00544f56a46f3si3721942edc.604.2023.11.19.12.24.12; Sun, 19 Nov 2023 12:24:13 -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 2458F68CAC6; Sun, 19 Nov 2023 22:24:05 +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 7142968BDD0 for ; Sun, 19 Nov 2023 22:23:57 +0200 (EET) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id E5F2CC018B for ; Sun, 19 Nov 2023 22:23:56 +0200 (EET) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 19 Nov 2023 22:23:55 +0200 Message-ID: <20231119202356.33736-1-remi@remlab.net> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc/llvidencdsp: add R-V V diff_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: PJMLCmHS4+x/ diff_bytes_c: 163.0 diff_bytes_rvv_i32: 52.7 --- libavcodec/lossless_videoencdsp.c | 4 ++- libavcodec/lossless_videoencdsp.h | 1 + libavcodec/riscv/Makefile | 2 ++ libavcodec/riscv/llvidencdsp_init.c | 39 +++++++++++++++++++++++++++++ libavcodec/riscv/llvidencdsp_rvv.S | 37 +++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 libavcodec/riscv/llvidencdsp_init.c create mode 100644 libavcodec/riscv/llvidencdsp_rvv.S diff --git a/libavcodec/lossless_videoencdsp.c b/libavcodec/lossless_videoencdsp.c index b4130ebc7b..e2dc99e201 100644 --- a/libavcodec/lossless_videoencdsp.c +++ b/libavcodec/lossless_videoencdsp.c @@ -94,7 +94,9 @@ av_cold void ff_llvidencdsp_init(LLVidEncDSPContext *c) c->sub_median_pred = sub_median_pred_c; c->sub_left_predict = sub_left_predict_c; -#if ARCH_X86 +#if ARCH_RISCV + ff_llvidencdsp_init_riscv(c); +#elif ARCH_X86 ff_llvidencdsp_init_x86(c); #endif } diff --git a/libavcodec/lossless_videoencdsp.h b/libavcodec/lossless_videoencdsp.h index f2c2878485..07fff584af 100644 --- a/libavcodec/lossless_videoencdsp.h +++ b/libavcodec/lossless_videoencdsp.h @@ -40,6 +40,7 @@ typedef struct LLVidEncDSPContext { } LLVidEncDSPContext; void ff_llvidencdsp_init(LLVidEncDSPContext *c); +void ff_llvidencdsp_init_riscv(LLVidEncDSPContext *c); void ff_llvidencdsp_init_x86(LLVidEncDSPContext *c); #endif /* AVCODEC_LOSSLESS_VIDEOENCDSP_H */ diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 8f2a519827..2d0e6c19c8 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -30,6 +30,8 @@ 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_LLVIDENCDSP) += riscv/llvidencdsp_init.o +RVV-OBJS-$(CONFIG_LLVIDENCDSP) += riscv/llvidencdsp_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/llvidencdsp_init.c b/libavcodec/riscv/llvidencdsp_init.c new file mode 100644 index 0000000000..e35406dc41 --- /dev/null +++ b/libavcodec/riscv/llvidencdsp_init.c @@ -0,0 +1,39 @@ +/* + * 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_videoencdsp.h" + +void ff_llvidenc_diff_bytes_rvv(uint8_t *dst, const uint8_t *src1, + const uint8_t *src2, intptr_t w); + +av_cold void ff_llvidencdsp_init_riscv(LLVidEncDSPContext *c) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RVV_I32) { + c->diff_bytes = ff_llvidenc_diff_bytes_rvv; + } +#endif +} diff --git a/libavcodec/riscv/llvidencdsp_rvv.S b/libavcodec/riscv/llvidencdsp_rvv.S new file mode 100644 index 0000000000..0342165127 --- /dev/null +++ b/libavcodec/riscv/llvidencdsp_rvv.S @@ -0,0 +1,37 @@ +/* + * 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_llvidenc_diff_bytes_rvv, zve32x +1: + vsetvli t0, a3, e8, m8, ta, ma + vle8.v v0, (a1) + sub a3, a3, t0 + vle8.v v8, (a2) + add a1, t0, a1 + vsub.vv v8, v0, v8 + add a2, t0, a2 + vse8.v v8, (a0) + add a0, t0, a0 + bnez a3, 1b + + ret +endfunc