From patchwork Tue May 21 17:13:15 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: 49104 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:9214:b0:1af:fc2d:ff5a with SMTP id tl20csp127422pzb; Tue, 21 May 2024 10:14:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXwPU0CNNGxJI5jLWO/wR8FKRdRk40xMC8K2TsyWet6cyMUaM1Y25OzUvikzPbv8ZajvmzXuc9rRzVnTlgYYTWn45PziPtJeTGX6A== X-Google-Smtp-Source: AGHT+IFeYRbbuN/3rHvcT0BBY4Sq5GIJJ0XGuH+lIipITTOPAnDnASyAP3khsrQko2HVSU+TmhDf X-Received: by 2002:a17:907:75c4:b0:a61:8c98:88c7 with SMTP id a640c23a62f3a-a618c98895bmr336520666b.2.1716311658322; Tue, 21 May 2024 10:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716311658; cv=none; d=google.com; s=arc-20160816; b=C1XDul+Yd6yvLfytGkfyqWB3L2LJoJ/v2nC/DXD//owwla+oVCu9NZSDfBtn3W7Q8a Buipr9+qLFfpSSJoSmTvNpEM/OCjC5ufWBdYgi2vrny6lLqY8RDpq5hh1d+gAj5nmdHW Dl7MLXI9wc1c1GqlA5ngWmMRexwg/MlxdRXYNnvdgghdjXvXnZyYVUFhJjdImZZbfvc/ TU0dJfp11teQR+0KTac3Z9hsD4/7ViQ0ibYBKp9LXwJbMbRpOGtG9nKdKKDiDYkcOefQ bN6VkDiffGqYlRqE4pFkC1L5YWjHb0jjYDgVq9fJoivt+yeGFNM4k7o2G9OryETq+Kwf CmbQ== 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:date:to:from:message-id :dkim-signature:delivered-to; bh=//N4pNZQI5UlPNfrwvTBp9F7OMm7sp0+QR3wlul7yok=; fh=D0bFwGkf4X22/D/bfeDVrXKIx7S6kcXsNzy10j8ORbQ=; b=0dhYMi1j3OplHMb8ttDkpykz2jryKxQvuJ+Lf5Jk4/p0zSRvpM9jz6MsQD+8Lwbvjj t09IQCvGxmN20qm44bKTbo6dK0D49pV4OjHm+SBSu2jFfJN5LGaPin5dCdxQwGBDqnLB RYjytG3IykMcgua6Wq2srvS/zOvuQ8OrFRW9kw21lp9zvL6N0uHfHbYQQBpI8ZAzmF2n 5pmxgE/V0GlJLL5jbH9vD6FpfhRA08u2n5hR5pq81rqswl0RLhtmXEOfVKKVlqFCjgFg AZ/G3WoOoKGgD6pdq4EqX1Tx7ENr2299l4DYguFktlB0hsKmgDg3w8DvH6SVP07ZHc60 XPGQ==; 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=v+TCpYPC; 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-a5a17b4c747si1363785366b.309.2024.05.21.10.14.16; Tue, 21 May 2024 10:14:18 -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=v+TCpYPC; 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 6975A68D362; Tue, 21 May 2024 20:14:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out162-62-58-216.mail.qq.com (out162-62-58-216.mail.qq.com [162.62.58.216]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4BEBB68D2A9 for ; Tue, 21 May 2024 20:14:03 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1716311634; bh=gl8I/BCAqBQT57+P8EvAgTro76kd1GqRcTSDKc8XcG8=; h=From:To:Cc:Subject:Date; b=v+TCpYPCL431pIF7hpqzIjtjhEnze6yXij1qTT0zs0Tchfh0qKtYGv9JBD8bzJhqm TvNUo1eFOdNGrMpwakQXpjbv6/jmqmjzj7md8MAMOwtO3fAevFE8o8TV7lpAiCR/ax VF+jFgxWQAfYx4/91iQxnd2m18+U++WgVz8gtkTc= Received: from localhost.localdomain ([42.177.176.187]) by newxmesmtplogicsvrszb9-1.qq.com (NewEsmtp) with SMTP id 374AC612; Wed, 22 May 2024 01:13:52 +0800 X-QQ-mid: xmsmtpt1716311632tcp6kgdlb Message-ID: X-QQ-XMAILINFO: NvxNySBpH0QldVXeWP53Pucc/5l2vhHDVIcWYERC5B50NZ6dYR3XjLZMasuSpZ 4iMAAKhycvMFDrxt8ejzJlEOxVX/ousY6Pp0e07ZYMd6afJnabgXaPeZTMCGGLx30YsKUiBWqm3a Um4dv2Kjk05q6uc7VDJqeq8RIWDgg/XirFpSzNYzpX7fSWEkQSQ6mLpxgQEMDKcILnvMmmzThs+e KZ/yoNtqxZ9zywAr5cipmNwbd93g6OSIMMtTB558GCnLiMGZ/uvFZJR9zPHF5EcWxx6flZ7pBVsI gOtWMslbdtIw8Q0nasU24GEn3101aelKu9LnOo4u8sWoBi8jSFLMvRw2hVb6vtGexgTTTlTiher/ 2zPS7sPnMk+QHCNiaYPVUO/6/7HrPlEkOrRirEi/nfOR0zwncxrRyou8P8b4BFVwjG09f0AvdoeD E3w3lxrKx5PFxcNafREfa8F1fh/vAPDzFYEVBzPvqLyNa0F/E2kHovKLRofxDXQDNTlbA0sM86XE RtxL0Gdsh4wpmPtGsizP8pFpTNKFEBzNQP+dLhUAWZNLK6GWFdJCb7vZ5Dl/IoKwV3YGHghXTjbZ vHPEvoenSc8bCq7A7nPYLzpWgauS3ny8qopu5ysfbR7mGxjqP5OKI3c4wq1ZRWmK8k1DRyOzvuC5 W1iSu0fXJ7/aEmXjAivNdFwPrDr1MHDikjyfo1CsmWFp1CUKEeh3QH3bNsTKT2p8fBF+Dq7mf9AS BQP0gp4AGp9fWyMMzwS7GUGG8+eOBBHo5xsou2CSF7td0tXAJoTq+7Xc+HYD6U9l7mCWboL1F1wt moW7/GKsqS699+qHUseWoNx8Y5696ynYl6hVu4o4KwVpYdtR6jQNIli/BlrK0Fjfdp4LDc//iUAy zKOfFzLb6PjQ2B1uKEEheTSYit9yS8HN9sVFSnvTb2 X-QQ-XMRINFO: MSVp+SPm3vtS1Vd6Y4Mggwc= From: uk7b@foxmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 22 May 2024 01:13:15 +0800 X-OQ-MSGID: <20240521171319.2629938-1-uk7b@foxmail.com> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 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: FpA9XOoQeAH0 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.h | 4 +-- libavcodec/riscv/vp9dsp_init.c | 18 +++++++++++ 4 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 libavcodec/riscv/vp9_mc_rvv.S diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile index 07d5c2915d..67e198d754 100644 --- a/libavcodec/riscv/Makefile +++ b/libavcodec/riscv/Makefile @@ -69,6 +69,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..7cb38ec94a --- /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_vp9_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.h b/libavcodec/riscv/vp9dsp.h index 79330b4968..ff8431591c 100644 --- a/libavcodec/riscv/vp9dsp.h +++ b/libavcodec/riscv/vp9dsp.h @@ -138,11 +138,11 @@ void ff_avg_bilin_##SIZE##hv_rvv(uint8_t *dst, ptrdiff_t dststride, \ int h, int mx, int my); #define VP9_COPY_AVG_RISCV_RVV_FUNC(SIZE) \ -void ff_copy##SIZE##_rvv(uint8_t *dst, ptrdiff_t dststride, \ +void ff_vp9_copy##SIZE##_rvv(uint8_t *dst, ptrdiff_t dststride, \ const uint8_t *src, ptrdiff_t srcstride, \ int h, int mx, int my); \ \ -void ff_avg##SIZE##_rvv(uint8_t *dst, ptrdiff_t dststride, \ +void ff_vp9_avg##SIZE##_rvv(uint8_t *dst, ptrdiff_t dststride, \ const uint8_t *src, ptrdiff_t srcstride, \ int h, int mx, int my); diff --git a/libavcodec/riscv/vp9dsp_init.c b/libavcodec/riscv/vp9dsp_init.c index ab99294d44..454dcd963f 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_vp9_avg##sz##_rvv; \ + dsp->mc[idx1][FILTER_8TAP_REGULAR][1][0][0] = ff_vp9_avg##sz##_rvv; \ + dsp->mc[idx1][FILTER_8TAP_SHARP ][1][0][0] = ff_vp9_avg##sz##_rvv; \ + dsp->mc[idx1][FILTER_BILINEAR ][1][0][0] = ff_vp9_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 }