From patchwork Sat May 18 18:15:29 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: 48993 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:3a48:b0:1af:fc2d:ff5a with SMTP id zu8csp3572042pzb; Sat, 18 May 2024 11:16:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVv3/+ltgjh4PW3lVj2jpu4oBmhBlgGQt/4T6t8+VqoMBVxL3mnYt6ioSMGh8cQ0DZW3By2PAEyqY11VP9txw1yKbN8L76Wy2csxQ== X-Google-Smtp-Source: AGHT+IHtcb+0uOawyiGRAwIiSK2580UUln02ntOX/Kbm8Ugw+hfRdm7UuSLdr4nRlmOisokR+r2f X-Received: by 2002:a17:907:1b08:b0:a5a:62c9:bdf3 with SMTP id a640c23a62f3a-a5a62c9be77mr1487200466b.1.1716056193262; Sat, 18 May 2024 11:16:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716056193; cv=none; d=google.com; s=arc-20160816; b=mMlSS5hO76TqM1+tHBvQnVqrrdDoWWbZRTOV4JVhKADfks4/ysFmjB9t1232VTtR2O fOs2YJ6uMQYq0VLNnwKbH0Q2F3FN/W6bpJaZgVFukzGEV2r/0pqH8RS1OTR6Nhj+B/1E ugT00LySQDAC931bk3w/Jx2ZstS4YH3T+RYvymkYyfoEZGOqDBem7RTTZmPVg+oMMJNG xZb/NnUPHQwR9nrT+fhdfbhLqXlbp8lO1/YYL6xv7LD9/+xJzBUl340oW9cLwibAKUIH ZJPO8rDFh4pF23hhun5pypNYVtGkyX0CT8u7m9baHnX7ND4aoMq+9OQsCQ8qLjCqEDnq H+bA== 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=ef674aU8kJ5b0Bwy2pU3YxDb8ygLFSjCMm705McSu7U=; fh=D0bFwGkf4X22/D/bfeDVrXKIx7S6kcXsNzy10j8ORbQ=; b=nBIAvxwiM34lGzaXyuNJ0mnqWtnmbgXvietcrHvZccGwed2HL85NNGhsYgT4oCG56U zPDiwAuJHakd6tfECRMu1zm67nTAxIa8cLyVaafYVk6jsynzFUURu1bXlke26C//LEC5 qmQcNlg5IuzVOBfn6GqD1I2mGA/ugTfqFySpoPUUsL1q77/t9zKhnZwL/JTu6NDNce5o RcV/acvBT2LXXkJtmJShESHFBVrAN/YyOoLnnwf1JRangKMcDVKGVcTiUIZaovi/1GiH /V2rOS7Uem40hwVa8qm8CS8nzL4NDcXJ6Cv6KyQmcUEbw2Vj3AGBrRc0iDxy904iElLf z4NA==; 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=LVsJiL6R; 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-a5a1794606fsi1227517666b.190.2024.05.18.11.16.32; Sat, 18 May 2024 11:16:33 -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=LVsJiL6R; 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 6A10B68CC58; Sat, 18 May 2024 21:16:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-190.mail.qq.com (out203-205-221-190.mail.qq.com [203.205.221.190]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8C6CF68CCDC for ; Sat, 18 May 2024 21:15:57 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1716056136; bh=5gfjgyBK/r7h+nIEyrlxA+BY+ej5HByzJ4xLkmVgvA8=; h=From:To:Cc:Subject:Date; b=LVsJiL6RTzUYvXHk7PXyRTjFzQ2Wtc49/vwZsJKMEQXBNphhaKewlHA5WLvp7d4ST ArXY9LVjzePZvKQK5SYEtHcoDLWuM2qpXUg8TJM15Trwv/ivgeIIrHt8EE1xOno7tz Iv/R0QpeLg6BH7XrF3WsfGfDcQVzZ3oSbA44tTDA= Received: from localhost.localdomain ([42.56.223.122]) by newxmesmtplogicsvrszb16-1.qq.com (NewEsmtp) with SMTP id 3E33EA47; Sun, 19 May 2024 02:15:35 +0800 X-QQ-mid: xmsmtpt1716056135t9v7iyjxz Message-ID: X-QQ-XMAILINFO: Nfm/+M6ONQ57RaE9uLTjB3orplYALrd3PdDwOybrUeq+lHoiaAnYCEG0/0ll4j h47CRStlAC991bGGcWYB55tFYpwZ/9BsWDZ0cwdlOEpyJQGUl1cZwYy2J0bo79HbnT9vEkVY5Sf1 t0Y1b1BL67eoZeu5/XfguCTS2BN3elBn/2eajoFV7ReYv28waGCeAgDjwFhesisTiG8vtzGCrBdI g7dyO/0U0Jz3+nN/KPtUEWO/KQyUoW8PguQCawU1NEXvRqZR+CdgyCvnUEUFDqALqj5RXxR7QZq3 0bRy4OHguz3adY8DjKLKc94w9COXZpN2wdubdTM1BMZJhgI50pY4lB/RsEV59K1TBmAvF0NQYfSl pvFDKSEVg959kH1C53WIGk5GJAH4sYGXInPbfOYINxJDYWTYcwfGVCySkQUIYSyju2MYU/JHHk/p qoAkxC91Sl7RpoAaQgHO23v4cDlNSBfT6QV8ldnMJUgAY0NsmzhGbfyvkOXbgCdEXr/WVnYzDm9g auUlYtAEC0A9BjbhTSUOpQUSuBlBBoqHknANPTymj7izGmkRonyelWUTaWZfgdmgPbu8ClfB+jCr rIr6sllzznTLNIiBex4v3jwYM1kMzhdNTtRuFMZjQZzmGy+tfAK+99fmBcsnFHwFVlDmyuyMY2/A gemLsZs5AaYKWJ90RqY13vIvjFeB6CYYoBbWnnFl7r1DMtTCOqoEt1rMzjCdv9870dcg86UlfHhB +GySXWlcr6FyItbQEtGV7RrtbHjPMufZvbUOergmJVFrAM5OJ/JkN0zXc2vLEJutCBMWPMJmkJUo SJAyiDtQ99lsoczX2pXQ6gnTemRfMAKQhymwq0ESjAqT5Dc27TGUtLHl5kUiVAD7Mefrwz2DYQZF KL6Uk+7C8w5LYljyBaL83Fa5rw64JvrntWihofNTdt X-QQ-XMRINFO: Nq+8W0+stu50PRdwbJxPCL0= From: uk7b@foxmail.com To: ffmpeg-devel@ffmpeg.org Date: Sun, 19 May 2024 02:15:29 +0800 X-OQ-MSGID: <20240518181533.3124314-1-uk7b@foxmail.com> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 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: JN8wOyCFUAOU 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..7811cd9928 --- /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 }