From patchwork Tue May 7 07:36:09 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: 48616 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:6816:b0:1af:836d:81b3 with SMTP id wr22csp209087pzb; Tue, 7 May 2024 00:38:08 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUIOxIBTVrO0YWLTf07Y0WP0obduBgP/e4LdhtjQSGXZAAavnj8QeZL5vBRBTwLrEIFPV8YaupKwCce5x1uGt8BZ3xRU/EkFYyebg== X-Google-Smtp-Source: AGHT+IGZ7vGL+i4A+yYYI96zKjRx2vBS1n0csNHd2bTJTWBAKKQlsPrQOnISk38+RC9UDp3rCpWT X-Received: by 2002:a05:651c:604:b0:2e0:4cbb:858a with SMTP id k4-20020a05651c060400b002e04cbb858amr6020822lje.27.1715067488171; Tue, 07 May 2024 00:38:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715067488; cv=none; d=google.com; s=arc-20160816; b=KkFbcHS7YrkHG+99JXCTGOpFsCrGgxFpSSBSl00f1fYE6f8L6iG/oiGumKUaUc2Ecd dDFhr7218AbV0GugE/YGFkc1rEhE5tqmng5vQfpllCJI50uRyFbtp5SeE3gt6MoFsIL2 iGwGc/94o50HAbp6gsWI9w8109VU2QC0V5z6+GUQMpBg+1D2VXM6A6WuMROOHvKDtt3d Ukur7F8FV3D1dovCLQP7fNw/z8KmkoyGfT7+HEqInLxpC2uAiV3bt3n/SGp2oMf3Tc8I gOqBq4sNyxrE9a/BBpq18MLUqnCv6DhuiCpIDpq1bk0QCjJ13rfO+VlXMn2GcR5z1B0i mVHA== 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=5OVzFYH041cdBcioYrJS55SW3TwDR50ntsbYGujtOWY=; fh=D0bFwGkf4X22/D/bfeDVrXKIx7S6kcXsNzy10j8ORbQ=; b=BwRm8FvCixcfdAlzOp+NNaLRJ7VwEujjC/B0G86bQlAL72kB0fM5e1xhBOPPDAKC7K aYwKhNyiUpRF+LqYjgUCGISNktnI3a/EpqnQTFDsPHrWbcBhCg38eK0lHdQEccrHkqar kh+BWMFXxHxZKmZnc9K7wMF4dLgs+KhTt+mrp1scLHEnBZwbzEWQJNNAlxUKRXGRG2XE ZtUip4K7rQ2r3PzjJ6elEzMuU3qXvVAPh73Gh4HtbmNCjl2kO294lY92Kh6l7Mh3XfyU Ukv7PfE0H7Rc3GW2LS5a+iWaJllJVc7H3j0D/PSGIaF0aE6q0HcYL7mDjO5v1mIWw6uy PC3Q==; 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=hQwvlFlw; 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 u19-20020a2e9f13000000b002dcaea129ddsi3321527ljk.642.2024.05.07.00.38.07; Tue, 07 May 2024 00:38:08 -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=hQwvlFlw; 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 5F34968D75B; Tue, 7 May 2024 10:36:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-202.mail.qq.com (out203-205-221-202.mail.qq.com [203.205.221.202]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3376B68D738 for ; Tue, 7 May 2024 10:36:45 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1715067389; bh=TiSjQvkrdCr4XN2rfTZT14rdn2wDZRj74lYI/A+RiPU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hQwvlFlwc9wK2rrm2ffBQ2B8h55V8FQMBxde3OK6lnTi7L5DKNLGSvHfnN5h81LiJ TJ8QyZ3FxKSqxOk3kqM3XvIdgL4uFVN7UFgFvlv13UVMh+z/waQY3GPh0Gq8TryJnh KUN+Fs7IKS+wgtsN2JdzlB5TRH7kg2Z5hqKIdZxA= Received: from localhost.localdomain ([42.56.223.122]) by newxmesmtplogicsvrsza29-0.qq.com (NewEsmtp) with SMTP id 9188D283; Tue, 07 May 2024 15:36:24 +0800 X-QQ-mid: xmsmtpt1715067388tfyog0qc3 Message-ID: X-QQ-XMAILINFO: Mm/8i8/T4yneGdED9/VUHygXyhjmFuEAvrsc9pAyh3tRDC7iUxWiMsi1GKpdSY M28ywtuxOLUvMitu85r00gw28FidYMZ1qH0aPN/gEoyPvBRgybpnT98pGROmbTOVaRJ2GnMtBmOH 3/lS4COpi2DxKonlPS7Kfz50hmhbN+2CM4mbEceWVZx0I7u30WbLW0rpfjTcWMW6WfH4WEAmpXTX Q3ZzEjhUnmToInf0dx8pk5g8l5PFp5z6ErUVCRMQy9TOZXDvJTDyw7ukxR5TOc+fICr95lUQB31z 5MtS46GcgWX9oua9oWAqf6qCrhwrkVKPCa5HYfnmvVU94Ofi8S7plTHXHXLYxuDKdkDEUor8Y3/p zEB7JSC8LwXhP8oE666EgDGVEBOc3s9E0Z3jLgIa1k9Fhkjiu2shHbbLfoJpuKPtcYwlZYLv1WCU m4ChNXKHGtkF29vVUd5eZMPB3OM5zz/6FSMVG/ipZUnmElCriINXiqDQEyT+ysKbjKqLc/WAXoc4 z4LQP9skGwuL/Vp4VtoLC4re7N7nFQQiAmH9vlqEcCBYEsEghHKGkCrKy7bV8wUJtiTNSDarD2rX GWLZIe67WEOApOt9DR8+ucChiiQJUgEX400X5iZO3F5uCV3Vq3cKXJvYtuefvsYyHfNhW/IGQUoW auHOSYzKRKj/H46y1xTHHHxG92K9StyYtoFlQOaWWzOficXEkrl9Eld46qjGxK2jZerqez0Rkd6/ M/moWAMv9tGidEfjdLDlnQXsKfEzNxBNo8B/AvJIKYEKiWfU1M4af9fMuvIHRedqZbB9yiYBId9K gu3CjmuAcxM+G8+TsX00AEw1WT1xL8yrTmFFBPHTytxT1ntCTOQX533dQopOHCk5Db3j3vHjbTEL 4FmEo4iRmpYN94V9tcuu5z5Z9CN+2aui6+UmdBfIpulGaC3yguvwG1NfY8ut2kmw== X-QQ-XMRINFO: NS+P29fieYNw95Bth2bWPxk= From: uk7b@foxmail.com To: ffmpeg-devel@ffmpeg.org Date: Tue, 7 May 2024 15:36:09 +0800 X-OQ-MSGID: <20240507073613.2871668-5-uk7b@foxmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240507073613.2871668-1-uk7b@foxmail.com> References: <20240507073613.2871668-1-uk7b@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 5/9] 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: Kdi5/UVe78wt 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 | 19 +++++++++++ 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 libavcodec/riscv/vp9_mc_rvv.S diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 5846861bac..73c9f24d97 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..81ecb49435 --- /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 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, \len + 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 +1: + addi a4, a4, -1 + vle8.v v8, (a2) + vle8.v v16, (a0) + vaaddu.vv v8, v8, v16 + 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 8023c333db..2caaf732db 100644 --- a/libavcodec/riscv/vp9dsp_init.c +++ b/libavcodec/riscv/vp9dsp_init.c @@ -92,6 +92,25 @@ static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext *dsp, int bpp) #undef init_fpel } + +#if HAVE_RVV + if (bpp == 8 && (flags & AV_CPU_FLAG_RVV_I64) && ff_get_rv_vlenb() >= 16) { + +#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 }