From patchwork Fri May 17 16:05:16 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: 48958 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:3a48:b0:1af:fc2d:ff5a with SMTP id zu8csp2973663pzb; Fri, 17 May 2024 09:05:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV8PwgLuHG1gMyhuVbd3EsOf1jYva44HqINCw1eO8AqbCSVf04YU8SwlLSARHhzKJUGQjSqZW3aoNJXlRMwxakNokmbVkCdATYIyA== X-Google-Smtp-Source: AGHT+IHYS6DTOA8t5f1Krlm1A0Ac3Z5K9EIyA/w7yZ7XeoRfLSuzSBSbN1O/rvvAs1Udf6rmkNjM X-Received: by 2002:a50:8ace:0:b0:574:ec40:3ada with SMTP id 4fb4d7f45d1cf-574ec403b18mr8351414a12.40.1715961946258; Fri, 17 May 2024 09:05:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715961946; cv=none; d=google.com; s=arc-20160816; b=VOsoRaU3vWnuUoRIyPD9MCi/h/6M0oLfElGO+RA/HHPt/VzsG7riVYUVGL8uOo219Z 4CNiTgtqh9la57RFRKYtonbGKE6/wJYaCcIRZzdhKhxZYnxSa9VsRdDjBFJ9NTPVev4k 3Pf8mD7HHAFy5XefuHekes3lguIdhR/wVh+DO01IB0LhJsHjOD9GM/PFG/+NNTQ+hY+y /utAGrR6fR84lioouZU/jJzwnLz7q+s9Sc/oJg4uA8fbqKdNFjqZ6ofBm7lYBuvVvs1u RO3Ziu7lrERH3o1hLeOEPlxgXzL4E5XO4d3G2miEe9rcw+f0qMMUlu2jikcEg37QptXK H6wQ== 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=rTe488h/6MW6f+xXiIM0M/FgLRhzVO+W+r0VOLqm+es=; fh=D0bFwGkf4X22/D/bfeDVrXKIx7S6kcXsNzy10j8ORbQ=; b=LueSxYOUPrL7l2zQaCIJyJtgzYW/89NeVJeocPp19Y6d6KgknonF6oul0zUQ9JmXs8 PbLKSVWKBnzuGsTCUi6xe1bMcH/SVTPlNHbUCWrNDxVPLW0Rcs4LXRuaMazFiLkmZYNu FDBUA5dn5aZeiUyVyMyOFyBfSbucIzWUAJJM9DmvbdMXTVqfx2pfyn6byoqMIFwMX7Es 7jnfOB3vjxTgQ86cCZfRSeytWLFVCsPZUg4zD99iwFUv/QUtSbVA3JLId9KQhSQLwRJN Fe7m0bGLNDKmlki4niUSLxeq8PcKcmzNPjVw9nYtAsLX6UvIgtOivmUfoJGIgrBEc390 EpdQ==; 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=vG0O9oJP; 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 4fb4d7f45d1cf-5751ec258edsi722511a12.177.2024.05.17.09.05.45; Fri, 17 May 2024 09:05:46 -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=vG0O9oJP; 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 6936468D2E3; Fri, 17 May 2024 19:05:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-231.mail.qq.com (out203-205-221-231.mail.qq.com [203.205.221.231]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D32F968D159 for ; Fri, 17 May 2024 19:05:33 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1715961921; bh=ep38uoFIP4ryyPjcFvCI5FiYLpXKFq5a0and/IZlCG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vG0O9oJPRhVUDWLqy9NZpfi65Go1KyOnA3CkqLzpGT8RhvZxzbq4929Ym0X/Eebgo 834bRPFJydhtK7Qhr04Yho3/yswzUTXW3Ie/C7zRdMCLhXwMasUU+58umRS+CHMSaw DMC+HcGf5Mn8sR9aKnWtubkafSkIboYigZk7yKZI= Received: from localhost.localdomain ([42.56.223.122]) by newxmesmtplogicsvrszc19-0.qq.com (NewEsmtp) with SMTP id 153820FE; Sat, 18 May 2024 00:05:19 +0800 X-QQ-mid: xmsmtpt1715961919tssk9j2dy Message-ID: X-QQ-XMAILINFO: MB5+LsFw85NoAJJTEGHOWMBJ7dqrVFmQYGeUwcmK/oH4XvY14p7qphssDZ2crA quKgWJjlPXeRxBDPCoQo29wGicYNZemmAt0DLEvH1/MZg45lwTLn1oUBDkmqSHZKRWJV6TUrNTMD ZrXM3lmHvcBhY8dERI8ldERulDrTWvNSKhQ7fYaVXVmd1gJy9eZcbl23XpYwIbbiGP/VZynKOyJQ VrblQjpU5xyz3sGV5k/BdqgXlCnR4lkkyddSr10KiwrczQmo1OQ3qaKamHueEJEFD9PvleIhiSTs xRUQgxPS/TdNFrWzsXO+KMAApSd4gyBBN0KDrBS7jDMToLSVLSpKPnqvsYgFjZEnWKDVF8RwH/vE yvI+eCb9jeZi/TNh5/1wwL1XL9kPXAKFR4+RGQdvnVwGVAHCbVB1yFEtbMN9lVEejhYZIsJrI2z5 93eJngnajEZsEs/2I+lTLAgQq++VgIMgaHMrRcLlkJs4sCAuYeG4AwNPAI+3RZI4/tNGgb0WGcyF NBBLPSzOnCHlRuoJiQl67RtT6zNuVXzKK5qrnBmDcXRONhcCrSwDAWGB1lzhqWc9z+peLVFjO2+d v5rIAzbu+a7OKThmfTN8bhyBg7oux+w3wM/74E4yIEz/FWPHRMGtX0tLyst1VhpUVqgI6u54j6q0 dUOa+zPUI29CkdAmnE/hlGPxI9PpLJBXGV2I1HwB6uuSGc9AwPI1L1zrIu8mZnSdC1vGKw6YgeUZ tdEZIc4/pBvk8OHIrf8cGKBZQKP9gJnXK2gMnCizhMLP2vxTvxNKqePVxrrCjdE5niBwwu5xdRNR dQtpC991MdKKdqapMAUTvxbUZ5M2Ttd/wZw1TwRoJYG8eeTb/fUfOuLoxYYEcPu+4oyfxz6GZakZ NvnrstCSn4TLTlrdIzfFCjNzQ69JyjD+dFfHPfIdiA+rF8MbEbr8HPimrqyyCXJg== X-QQ-XMRINFO: Nq+8W0+stu50PRdwbJxPCL0= From: uk7b@foxmail.com To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 May 2024 00:05:16 +0800 X-OQ-MSGID: <20240517160516.92542-1-uk7b@foxmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <9276774.vF19fDgCsf@basile.remlab.net> References: <9276774.vF19fDgCsf@basile.remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/5] lavc/vp9dsp: R-V V mc avg 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: s7K2bthLc3eD From: sunyuechi C908: vp9_avg4_8bpp_c: 1.2 vp9_avg4_8bpp_rvv_i64: 1.0 vp9_avg8_8bpp_c: 3.7 vp9_avg8_8bpp_rvv_i64: 1.5 vp9_avg16_8bpp_c: 14.7 vp9_avg16_8bpp_rvv_i64: 3.5 vp9_avg32_8bpp_c: 57.7 vp9_avg32_8bpp_rvv_i64: 10.0 vp9_avg64_8bpp_c: 229.0 vp9_avg64_8bpp_rvv_i64: 31.7 --- libavcodec/riscv/Makefile | 3 +- libavcodec/riscv/vp9_mc_rvv.S | 58 ++++++++++++++++++++++++++++++++++ libavcodec/riscv/vp9dsp_init.c | 18 +++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 libavcodec/riscv/vp9_mc_rvv.S diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 27b268ae39..4739d83522 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -65,6 +65,7 @@ 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 \ riscv/vp9_mc_rvi.o -RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvv.o +RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvv.o \ + riscv/vp9_mc_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_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S new file mode 100644 index 0000000000..9ee7f04dd1 --- /dev/null +++ b/libavcodec/riscv/vp9_mc_rvv.S @@ -0,0 +1,58 @@ +/* + * 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" + +.macro vsetvlstatic8 len an maxlen mn=m4 +.if \len == 4 + vsetivli zero, \len, e8, mf4, ta, ma +.elseif \len == 8 + vsetivli zero, \len, e8, mf2, ta, ma +.elseif \len == 16 + vsetivli zero, \len, e8, m1, ta, ma +.elseif \len == 32 + li \an, \len + vsetvli zero, \an, e8, m2, ta, ma +.elseif \len == 64 + li \an, \maxlen + vsetvli zero, \an, e8, \mn, ta, ma +.endif +.endm + +.macro copy_avg len +func ff_avg\len\()_rvv, zve32x + csrwi vxrm, 0 + vsetvlstatic8 \len t0 64 +1: + vle8.v v8, (a2) + vle8.v v16, (a0) + vaaddu.vv v8, v8, v16 + addi a4, a4, -1 + vse8.v v8, (a0) + add a2, a2, a3 + add a0, a0, a1 + bnez a4, 1b + ret +endfunc +.endm + +.irp len 64, 32, 16, 8, 4 + copy_avg \len +.endr diff --git a/libavcodec/riscv/vp9dsp_init.c b/libavcodec/riscv/vp9dsp_init.c index ab99294d44..6bfe23563a 100644 --- a/libavcodec/riscv/vp9dsp_init.c +++ b/libavcodec/riscv/vp9dsp_init.c @@ -48,6 +48,24 @@ static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext *dsp, int bpp) } # endif +#if HAVE_RVV + if (bpp == 8 && (flags & AV_CPU_FLAG_RVV_I32) && ff_rv_vlen_least(128)) { + +#define init_fpel(idx1, sz) \ + dsp->mc[idx1][FILTER_8TAP_SMOOTH ][1][0][0] = ff_avg##sz##_rvv; \ + dsp->mc[idx1][FILTER_8TAP_REGULAR][1][0][0] = ff_avg##sz##_rvv; \ + dsp->mc[idx1][FILTER_8TAP_SHARP ][1][0][0] = ff_avg##sz##_rvv; \ + dsp->mc[idx1][FILTER_BILINEAR ][1][0][0] = ff_avg##sz##_rvv + + 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 }