From patchwork Sun May 12 10:03:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: uk7b@foxmail.com X-Patchwork-Id: 48804 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1706:b0:1af:cdee:28c5 with SMTP id nv6csp505619pzb; Sun, 12 May 2024 03:04:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVca+XW7odJ4v2hsQ1op1a0iGIRHkREtuPC4sAi0j1z5ctcIeZ+V+JK41984B00SaIaTLidBr/LUrMdVXI7oopjKedDXWygzGhyGw== X-Google-Smtp-Source: AGHT+IE9z97A0BvPQ0W7+f5cBTgDhohdEWel8shd+e9AOjDzzLZaEgz4nk5cCuC8LwJ+DvzDIRiZ X-Received: by 2002:a17:906:b0c:b0:a59:d5f7:a697 with SMTP id a640c23a62f3a-a5a2d54c47fmr436708266b.9.1715508263105; Sun, 12 May 2024 03:04:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715508263; cv=none; d=google.com; s=arc-20160816; b=bd+oYvRWW6IWqcNJXzIeTYc4a0Pz3Bafk9JgfJAuHrAh2j337Yb2vhquzW8O1hdspe Zu2GSy+P2mBD8wvZTk5OcS2V8eU3k4P8GWARKTgK1Qbp2XpLTMVNhw1ddTZXM1J40lZj CwEi6hV6TB2G14JJATzns11R3MbF8sqO1XPqmt/XotSRzmxRNAfyHgkU5KvGpSAxoNzc 5g/0rqaDXluq2z2vyY+xHhI4JhCytZ7IPhHZZA1o72CUy8bxjIWoCy4yWtWPmYBrVn1t SaRpU86ru02u3aojFSYox7ksGkwfLrmM40iVe5YUG58oDI/Tg8JBRlmh+zxL1YUUdPiw Rnrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to:date :to:from:message-id:dkim-signature:delivered-to; bh=dBRrBRoTXANzv2D5+0V860oZRKhP7Vt52OXWntZYC+I=; fh=D0bFwGkf4X22/D/bfeDVrXKIx7S6kcXsNzy10j8ORbQ=; b=CG0Oc8ARaGZhJeXW8mlGisykXoTaPnSmL/EcyawR9KQA99L20HztSJLTufMBHj1BHP vMPi3O9vDeaMmkZlePaKs4YkRtEIKceLZcC99RJtFoCROOYFck6YThbXCOe0JRJVmeaZ eQa+G7UizSwqzlZwOgCgmmP2anDuoYNS1+ZmjCguzyutYJGlffwEnR3LtSBy1FbKbnL4 ZitKtzYnvykndsfLT1GPKoFMDXD4VBG15nPFv40xZr6vi/Hv+pMfSBxP2hl8kKy00uBr 1CaOsoGkW3R5oblfFvQuI6Br90OBhFdyzQz/4EFEEboIQleDTF+T1/7JN07XhZE6EFAg dPBQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=fHJgB1kN; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a5a17c2d4absi384513466b.1050.2024.05.12.03.04.22; Sun, 12 May 2024 03:04:23 -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; dkim=neutral (body hash did not verify) header.i=@foxmail.com header.s=s201512 header.b=fHJgB1kN; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=foxmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 380C268D621; Sun, 12 May 2024 13:03:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-251-73.mail.qq.com (out203-205-251-73.mail.qq.com [203.205.251.73]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DEAC668D4CF for ; Sun, 12 May 2024 13:03:46 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1715508215; bh=xZX1KIuXeY29zUArnvprTbwrjaBMJnuKC8PwQ9XSmBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fHJgB1kNG01hclPshORB5jyOGyNUMoz8arKgzBKUdwHfxQhuQjAM5S2y7hQ++fDmy AMrWjrTqn5udRPmQz2N1CjGYhytDyA2CPcyZWG5uejerlTZju7DhGtWXPMKMkxwuh8 K/qKuv4pBtODex37+xceNoNqBbxYZDIGvr/JRHXA= Received: from localhost.localdomain ([42.56.223.122]) by newxmesmtplogicsvrszb9-0.qq.com (NewEsmtp) with SMTP id E135E56; Sun, 12 May 2024 18:03:33 +0800 X-QQ-mid: xmsmtpt1715508214tvba2ibmo Message-ID: X-QQ-XMAILINFO: NkHKfw09D6j8yFnvrp2MwV/VcnmBXwzyCmMVPhKhPO7iFl+eKAihCLBmhwj4up VgCS/ifU4VohzczY7szjy1/f5rsDe2pmB558mO2BcS8/JkaMdu9Z+5jdclNJcXpdNAnlKlBU3s4Y g5LoITPgQJI+j8GhPDyuk5h6we0tBj0nNYbv/IZiQoWA7Qyw/fnOYIaxiL26pKXCwpPPNX6PqV/T PYvSREDtpnrUvbeqLrGDFNk7YpCHwyvDf5KUPaILiOyTEouIZ/Uz+qGhZJu6zOAG6oZf/BJM1sED kEbHL/+eyXMcv86Nqhkciz/bObhEwBAywEXulvk/CbNQ9vNKTItaT0rKarx/mtSNWgdC0HiKafPa KDWx4fkK453XlhNxBbbkJqwLlkqiZ9vtPGAWVY+24YgzB3h4G7R9Gr15lhY1oviXNiySMGdCJMiH QE+3YSBl14X3/+ZUNEIQtm94uE2KBfHlS3g4pXbTTs+2oIpukjxcYITDG8OP65Fr5sEin24uZ/sE wlV2c37uwobWxyscvDwPd5Nj3mtkLUoGycG4OBMwMTEouQWDhxclY7SmXY3ZZGUSNT3uHpLntYHL rMVcoeEU65JvQVPS8C9eN/7qis4RGNxf/mKKWByPuNCWQyVLHS290F0/4cbNkssY3MiugEvO+1tZ coZtchVgwiw2gkNxKGX0Vq1DiFgq02+UsjWrtUMeAHImR47C5ClL/zzHiRUIsBNTSQQW8pAReeb4 xinC1SkC2c43Hsh/DzaIi3UFH7/jC88z7fJasQb+1Ebmuh3SC2KVI44+buFyMh0uUUIJcvQAJYNp ZdkHtWZeZkmNDI7JSzO8GhA2iLVqfQb64npchZH/epvf8j8ZOeoNhuu9ITekEIiloahwZ9lHwrdt qsS3Wuu5Xj57kiSzr32ksBaLg45tG6Jt392SxVDEVOHKoQILhnwcALb0IhjJ70cMOUAo81rqTjkl wLVhAgSjk= X-QQ-XMRINFO: Nq+8W0+stu50PRdwbJxPCL0= From: uk7b@foxmail.com To: ffmpeg-devel@ffmpeg.org Date: Sun, 12 May 2024 18:03:24 +0800 X-OQ-MSGID: <20240512100331.995415-2-uk7b@foxmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240512100331.995415-1-uk7b@foxmail.com> References: <20240512100331.995415-1-uk7b@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 2/9] lavc/vp9dsp: R-V mc copy 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 Cc: sunyuechi Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: o78iCl01VXOY From: sunyuechi C908: vp9_put4_8bpp_c: 0.7 vp9_put4_8bpp_rvi: 0.5 vp9_put8_8bpp_c: 2.5 vp9_put8_8bpp_rvi: 0.5 vp9_put16_8bpp_c: 16.7 vp9_put16_8bpp_rvi: 1.5 vp9_put32_8bpp_c: 37.2 vp9_put32_8bpp_rvi: 5.7 vp9_put64_8bpp_c: 107.5 vp9_put64_8bpp_rvi: 21.7 --- libavcodec/riscv/Makefile | 3 +- libavcodec/riscv/vp9_mc_rvi.S | 105 +++++++++++++++++++++++++++++++++ libavcodec/riscv/vp9dsp.h | 3 + libavcodec/riscv/vp9dsp_init.c | 28 +++++++++ 4 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 libavcodec/riscv/vp9_mc_rvi.S diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index ccd060c666..0cd900104f 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -62,7 +62,8 @@ OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_init.o RV-OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_rvi.o RVV-OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_rvv.o OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9dsp_init.o -RV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvi.o +RV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvi.o \ + riscv/vp9_mc_rvi.o RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvv.o OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_init.o RVV-OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_rvv.o diff --git a/libavcodec/riscv/vp9_mc_rvi.S b/libavcodec/riscv/vp9_mc_rvi.S new file mode 100644 index 0000000000..0db14e83c7 --- /dev/null +++ b/libavcodec/riscv/vp9_mc_rvi.S @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences (ISCAS). + * + * 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" + +#if __riscv_xlen >= 64 +func ff_copy64_rvi +1: + addi a4, a4, -1 + ld t0, (a2) + ld t1, 8(a2) + ld t2, 16(a2) + ld t3, 24(a2) + ld t4, 32(a2) + ld t5, 40(a2) + ld t6, 48(a2) + ld a7, 56(a2) + sd t0, (a0) + sd t1, 8(a0) + sd t2, 16(a0) + sd t3, 24(a0) + sd t4, 32(a0) + sd t5, 40(a0) + sd t6, 48(a0) + sd a7, 56(a0) + add a2, a2, a3 + add a0, a0, a1 + bnez a4, 1b + + ret +endfunc + +func ff_copy32_rvi +1: + addi a4, a4, -1 + ld t0, (a2) + ld t1, 8(a2) + ld t2, 16(a2) + ld t3, 24(a2) + sd t0, (a0) + sd t1, 8(a0) + sd t2, 16(a0) + sd t3, 24(a0) + add a2, a2, a3 + add a0, a0, a1 + bnez a4, 1b + + ret +endfunc + +func ff_copy16_rvi +1: + addi a4, a4, -1 + ld t0, (a2) + ld t1, 8(a2) + sd t0, (a0) + sd t1, 8(a0) + add a2, a2, a3 + add a0, a0, a1 + bnez a4, 1b + + ret +endfunc + +func ff_copy8_rvi +1: + addi a4, a4, -1 + ld t0, (a2) + sd t0, (a0) + add a2, a2, a3 + add a0, a0, a1 + bnez a4, 1b + + ret +endfunc +#endif + +func ff_copy4_rvi +1: + addi a4, a4, -1 + lw t0, (a2) + sw t0, (a0) + add a2, a2, a3 + add a0, a0, a1 + bnez a4, 1b + + ret +endfunc diff --git a/libavcodec/riscv/vp9dsp.h b/libavcodec/riscv/vp9dsp.h index f8bc6563a5..b8ff282f8a 100644 --- a/libavcodec/riscv/vp9dsp.h +++ b/libavcodec/riscv/vp9dsp.h @@ -167,6 +167,9 @@ void ff_copy##SIZE##_rvi(uint8_t *dst, ptrdiff_t dststride, \ const uint8_t *src, ptrdiff_t srcstride, \ int h, int mx, int my); +VP9_COPY_RISCV_RVI_FUNC(64); +VP9_COPY_RISCV_RVI_FUNC(32); +VP9_COPY_RISCV_RVI_FUNC(16); VP9_COPY_RISCV_RVI_FUNC(8); VP9_COPY_RISCV_RVI_FUNC(4); diff --git a/libavcodec/riscv/vp9dsp_init.c b/libavcodec/riscv/vp9dsp_init.c index e377d377e3..fa9c3f4d8c 100644 --- a/libavcodec/riscv/vp9dsp_init.c +++ b/libavcodec/riscv/vp9dsp_init.c @@ -24,6 +24,33 @@ #include "libavcodec/vp9dsp.h" #include "vp9dsp.h" +static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext *dsp, int bpp) +{ +#if HAVE_RV + int flags = av_get_cpu_flags(); + +# if __riscv_xlen >= 64 + if (bpp == 8 && flags & AV_CPU_FLAG_RVI) { + +#define init_fpel(idx1, sz) \ + dsp->mc[idx1][FILTER_8TAP_SMOOTH ][0][0][0] = ff_copy##sz##_rvi; \ + dsp->mc[idx1][FILTER_8TAP_REGULAR][0][0][0] = ff_copy##sz##_rvi; \ + dsp->mc[idx1][FILTER_8TAP_SHARP ][0][0][0] = ff_copy##sz##_rvi; \ + dsp->mc[idx1][FILTER_BILINEAR ][0][0][0] = ff_copy##sz##_rvi + + init_fpel(0, 64); + init_fpel(1, 32); + init_fpel(2, 16); + init_fpel(3, 8); + init_fpel(4, 4); + +#undef init_fpel + } +# endif + +#endif +} + static av_cold void vp9dsp_intrapred_init_riscv(VP9DSPContext *dsp, int bpp) { #if HAVE_RV @@ -67,4 +94,5 @@ static av_cold void vp9dsp_intrapred_init_riscv(VP9DSPContext *dsp, int bpp) av_cold void ff_vp9dsp_init_riscv(VP9DSPContext *dsp, int bpp, int bitexact) { vp9dsp_intrapred_init_riscv(dsp, bpp); + vp9dsp_mc_init_riscv(dsp, bpp); }