From patchwork Sat May 4 15:03: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: 48500 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:e68f:b0:1af:836d:81b3 with SMTP id mz15csp431523pzb; Sat, 4 May 2024 08:04:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUIgr3W/y8lUoWqeitq5PPED+LjwVokfQknn+2a8oChv0jJz6VW8/MdpJ9E9s/EHghugtI9A9wlMtqFsRkeaGpTT9O55UhLr7v8pA== X-Google-Smtp-Source: AGHT+IGDbZyAp1HgncUy2SRZ+Vw1dK/iXtduOMZ6YxWBSxHEAercttff4sOeNSTiNF2cZhxFwF0L X-Received: by 2002:a19:5e11:0:b0:51f:23b8:d3c4 with SMTP id s17-20020a195e11000000b0051f23b8d3c4mr1681431lfb.27.1714835057527; Sat, 04 May 2024 08:04:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714835057; cv=none; d=google.com; s=arc-20160816; b=X3ma+CSfvgUSDlYgr31f3smtcYGMZYvePYQb2tRiCncRS9w/H65AkIShD+Fn6NzkM9 NvB+FqP1dRLV4bOOr5IR0STzluVKVzYPdJGMlYZzFGKPFdCesoDrfvW1wc1Ql5WqiIb/ wobIo6yApw65wzZPY+W7LP9+kjyfy3K5FCAjrMOPp17d1eXXIFiElqJS7mqX2xNlmGIu o29sYz2RxREJ05HyZco9lgeQrOKOySq59c2GQKaV7WtEPwWoTZdUz6DrANT7B+PDfmJE g5cJUv7PZiZTi+HdyIAXPn4NP6rf2RjsCCAQU59jwCoIxbtTyNjoK02fVK/dre/9CAnI mZVw== 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=BmGdKZZKSn/5M4iNogEuTscb9rPJEj7TMJhitb7eog0=; fh=D0bFwGkf4X22/D/bfeDVrXKIx7S6kcXsNzy10j8ORbQ=; b=hKj6/NsjPjaMLs3TTeGXbw1TsYXQ5tfWJdj7XtFuqyU055xAnv2Y9wezVMGgpyyHGD hIyRs5C3u/V5Aew/WikRihl5L45HB3ZwKUWCutXbe6hll5idHQn/TD3f1D2bFHa9Z5r4 Z+4RFLqBQ+079o9aRPoK9yp93e6YitdyjzHpmXfgVNLonheAHfEJbgMJs1N446cp6Id4 a3w49AaiSLdb8b8PZccP+XV+TCh/vXQqznymxqpYtWC4nbSE9vjDLrR1vFbY9rHFz7EE lMpcQ0lHX47y4Oal79tXz7Ot9s/+coyM1Sp8bgfIb6Gjta7CCOQ9u7hm82504ug5pkpM ckjA==; 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=aYNPHqr8; 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 n16-20020a05651203f000b0051f1c793062si1643353lfq.3.2024.05.04.08.04.17; Sat, 04 May 2024 08:04:17 -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=aYNPHqr8; 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 2E58468D79F; Sat, 4 May 2024 18:03:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-235.mail.qq.com (out203-205-221-235.mail.qq.com [203.205.221.235]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E1C8968D74C for ; Sat, 4 May 2024 18:03:31 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1714835003; bh=/okv3hVQ+yovNPGiFxJA5wpFZM59RDDauVYqUtemfic=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aYNPHqr8xo2CNHyLZJkCkhPofauyw/aGSkT3JvuPbrgHMj+I4+S3AeYVaIGIqjmMm uJ6EKoxXxRFzUDQmo3rJ/rDU7MDtlOhOUxWY8jLAjFI5+f6NYu4xCdm/ITv9rAiQ4/ EMfTxz/ENLmHfDLswxEvM9PkUIk3XXARMVC2dbK4= Received: from localhost.localdomain ([42.56.223.122]) by newxmesmtplogicsvrsza15-1.qq.com (NewEsmtp) with SMTP id D215A30; Sat, 04 May 2024 23:03:18 +0800 X-QQ-mid: xmsmtpt1714835002tq3lygvkj Message-ID: X-QQ-XMAILINFO: OZZSS56D9fAjkprx2Gm/FlbSVzH5e/VAWBASok2IzlxKTpFhez6sZF/s7m4YgQ AhkQvEBxl8CuVKGD9SM6r4l9eX+nRgSsDEjwi3idiPXlMc4hq7HWhIY6kT5Iew+pmyzpQFfBLnWv 707yj6RWITV0ouvL0A75IJJaJcoXC70S6w6L3rC+vEVQa1VHO4/aEhmOQFZ/4WyLq2SLb5mp3EUw eOkydwMIrrJP6tEku6KRRajHa0G5gmFdiQca68zcyLIvdEugRCGvvCRhV58wyUivLkPbOzWsMpsR Th2LpxiO7FTnFkbyGOroyoEYgOMh3IPn14pBIfJwWhw+yi7A/4Pb0S+fKSxWmXntbMAU+t01VPkc e4n+CaLCmYWO0R/X7MrEOb3BuzxhBmF/xaJkcxOrcN1GmpxIwGh+va30LDElGavj3a97IS9uojOd 8fvVYdGRyfZue3YID++j3kZ55KY/r4+kR14I6dLUZ7VGmicsZZ4uOan43MVR7ZaHe3i38h3QGZG5 ycaBBhqL0feiDYT8FolWhvo1W9sHtMHViskpkTTvJehvIG5PwdlvTLs0N6j5hPGcPPIPezeP4Rve btt8T2/HTCDeYULxU4iwLy5U2S8LxnZQF55JUGk/sESCiHMtyHZL7mZW2Nakh0nGidA9hmdrLNt0 OaaB6msHxMjvXxMeg/1/i8Zem5m0SMGTA7taufZt7xfgkgavImEyaKBg4nlZ0zwlEO7KaMXuYlY8 u5lsxFMpYqKOLjl8nBNOG5+RJf5qIFd3mgBVOrJU3V4T/gUJpGpnXHBBGwcOyEiUdnzNzZ6w6JPh VZAlCT8nkw7ruiyFl4i9mn6GDKX1XMfz0/9+xlzPucLmN4bl8Uzg0NMcOu7cksMHly3c40SdXKe5 4wPTbyiauYC5vxnDZHva/ufd4aCX/05KhMak8tjHBHldQKl+8XhVBUKzpZoCrC7aVQvVF44tEXKy EE0colqld0h5yX0eCudw== X-QQ-XMRINFO: MPJ6Tf5t3I/ycC2BItcBVIA= From: uk7b@foxmail.com To: ffmpeg-devel@ffmpeg.org Date: Sat, 4 May 2024 23:03:09 +0800 X-OQ-MSGID: <20240504150313.2472910-6-uk7b@foxmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240504150313.2472910-1-uk7b@foxmail.com> References: <20240504150313.2472910-1-uk7b@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/10] lavc/vp9dsp: R-V V mc tap h 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: jg5hjhH3Q1TT From: sunyuechi C908: vp9_avg_8tap_smooth_4h_8bpp_c: 12.7 vp9_avg_8tap_smooth_4h_8bpp_rvv_i64: 5.0 vp9_avg_8tap_smooth_8h_8bpp_c: 48.5 vp9_avg_8tap_smooth_8h_8bpp_rvv_i64: 9.2 vp9_avg_8tap_smooth_16h_8bpp_c: 191.7 vp9_avg_8tap_smooth_16h_8bpp_rvv_i64: 21.0 vp9_avg_8tap_smooth_32h_8bpp_c: 780.0 vp9_avg_8tap_smooth_32h_8bpp_rvv_i64: 66.5 vp9_avg_8tap_smooth_64h_8bpp_c: 3123.7 vp9_avg_8tap_smooth_64h_8bpp_rvv_i64: 264.2 vp9_put_8tap_smooth_4h_8bpp_c: 11.0 vp9_put_8tap_smooth_4h_8bpp_rvv_i64: 4.2 vp9_put_8tap_smooth_8h_8bpp_c: 42.0 vp9_put_8tap_smooth_8h_8bpp_rvv_i64: 8.2 vp9_put_8tap_smooth_16h_8bpp_c: 165.5 vp9_put_8tap_smooth_16h_8bpp_rvv_i64: 19.7 vp9_put_8tap_smooth_32h_8bpp_c: 659.0 vp9_put_8tap_smooth_32h_8bpp_rvv_i64: 64.0 vp9_put_8tap_smooth_64h_8bpp_c: 2682.0 vp9_put_8tap_smooth_64h_8bpp_rvv_i64: 272.2 --- libavcodec/riscv/vp9_mc_rvv.S | 233 +++++++++++++++++++++++++++++++++ libavcodec/riscv/vp9dsp_init.c | 8 +- 2 files changed, 240 insertions(+), 1 deletion(-) diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S index a97807633e..289c377a42 100644 --- a/libavcodec/riscv/vp9_mc_rvv.S +++ b/libavcodec/riscv/vp9_mc_rvv.S @@ -123,6 +123,231 @@ func ff_copy\len\()_rvv, zve32x endfunc .endr +const subpel_filters_regular + .byte 0, 0, 0, 128, 0, 0, 0, 0 + .byte 0, 1, -5, 126, 8, -3, 1, 0 + .byte -1, 3, -10, 122, 18, -6, 2, 0 + .byte -1, 4, -13, 118, 27, -9, 3, -1 + .byte -1, 4, -16, 112, 37, -11, 4, -1 + .byte -1, 5, -18, 105, 48, -14, 4, -1 + .byte -1, 5, -19, 97, 58, -16, 5, -1 + .byte -1, 6, -19, 88, 68, -18, 5, -1 + .byte -1, 6, -19, 78, 78, -19, 6, -1 + .byte -1, 5, -18, 68, 88, -19, 6, -1 + .byte -1, 5, -16, 58, 97, -19, 5, -1 + .byte -1, 4, -14, 48, 105, -18, 5, -1 + .byte -1, 4, -11, 37, 112, -16, 4, -1 + .byte -1, 3, -9, 27, 118, -13, 4, -1 + .byte 0, 2, -6, 18, 122, -10, 3, -1 + .byte 0, 1, -3, 8, 126, -5, 1, 0 +subpel_filters_sharp: + .byte 0, 0, 0, 128, 0, 0, 0, 0 + .byte -1, 3, -7, 127, 8, -3, 1, 0 + .byte -2, 5, -13, 125, 17, -6, 3, -1 + .byte -3, 7, -17, 121, 27, -10, 5, -2 + .byte -4, 9, -20, 115, 37, -13, 6, -2 + .byte -4, 10, -23, 108, 48, -16, 8, -3 + .byte -4, 10, -24, 100, 59, -19, 9, -3 + .byte -4, 11, -24, 90, 70, -21, 10, -4 + .byte -4, 11, -23, 80, 80, -23, 11, -4 + .byte -4, 10, -21, 70, 90, -24, 11, -4 + .byte -3, 9, -19, 59, 100, -24, 10, -4 + .byte -3, 8, -16, 48, 108, -23, 10, -4 + .byte -2, 6, -13, 37, 115, -20, 9, -4 + .byte -2, 5, -10, 27, 121, -17, 7, -3 + .byte -1, 3, -6, 17, 125, -13, 5, -2 + .byte 0, 1, -3, 8, 127, -7, 3, -1 +subpel_filters_smooth: + .byte 0, 0, 0, 128, 0, 0, 0, 0 + .byte -3, -1, 32, 64, 38, 1, -3, 0 + .byte -2, -2, 29, 63, 41, 2, -3, 0 + .byte -2, -2, 26, 63, 43, 4, -4, 0 + .byte -2, -3, 24, 62, 46, 5, -4, 0 + .byte -2, -3, 21, 60, 49, 7, -4, 0 + .byte -1, -4, 18, 59, 51, 9, -4, 0 + .byte -1, -4, 16, 57, 53, 12, -4, -1 + .byte -1, -4, 14, 55, 55, 14, -4, -1 + .byte -1, -4, 12, 53, 57, 16, -4, -1 + .byte 0, -4, 9, 51, 59, 18, -4, -1 + .byte 0, -4, 7, 49, 60, 21, -3, -2 + .byte 0, -4, 5, 46, 62, 24, -3, -2 + .byte 0, -4, 4, 43, 63, 26, -2, -2 + .byte 0, -3, 2, 41, 63, 29, -2, -2 + .byte 0, -3, 1, 38, 64, 32, -1, -3 +endconst + +.macro epel_filter name type regtype + lla \regtype\()2, subpel_filters_\name + li \regtype\()1, 8 + mul \regtype\()0, a5, \regtype\()1 + add \regtype\()0, \regtype\()0, \regtype\()2 + .irp n 1,2,3,4,5,6 + lb \regtype\n, \n(\regtype\()0) + .endr +.ifc \regtype,t + lb a7, 7(\regtype\()0) +.elseif \regtype == s + lb s7, 7(\regtype\()0) +.endif + lb \regtype\()0, 0(\regtype\()0) +.endm + +.macro epel_load dst len do name type from_mem regtype + li a5, 64 +.ifc \from_mem, 1 + vle8.v v22, (a2) + addi a2, a2, -1 + vle8.v v20, (a2) + addi a2, a2, 2 + vle8.v v24, (a2) + addi a2, a2, 1 + vle8.v v26, (a2) + addi a2, a2, 1 + vle8.v v28, (a2) + addi a2, a2, 1 + vle8.v v30, (a2) + +.ifc \name,smooth + vwmulu.vx v16, v24, \regtype\()4 + vwmaccu.vx v16, \regtype\()2, v20 + vwmaccu.vx v16, \regtype\()5, v26 + vwmaccsu.vx v16, \regtype\()6, v28 +.else + vwmulu.vx v16, v28, \regtype\()6 + vwmaccsu.vx v16, \regtype\()2, v20 + vwmaccsu.vx v16, \regtype\()5, v26 +.endif + +.ifc \regtype,t + vwmaccsu.vx v16, a7, v30 +.elseif \regtype == s + vwmaccsu.vx v16, s7, v30 +.endif + + addi a2, a2, -6 + vle8.v v28, (a2) + addi a2, a2, -1 + vle8.v v26, (a2) + addi a2, a2, 3 + +.ifc \name,smooth + vwmaccsu.vx v16, \regtype\()1, v28 +.else + vwmaccu.vx v16, \regtype\()1, v28 + vwmulu.vx v28, v24, \regtype\()4 +.endif + vwmaccsu.vx v16, \regtype\()0, v26 + vwmulu.vx v20, v22, \regtype\()3 +.else +.ifc \name,smooth + vwmulu.vx v16, v8, \regtype\()4 + vwmaccu.vx v16, \regtype\()2, v4 + vwmaccu.vx v16, \regtype\()5, v10 + vwmaccsu.vx v16, \regtype\()6, v12 + vwmaccsu.vx v16, \regtype\()1, v2 +.else + vwmulu.vx v16, v2, \regtype\()1 + vwmaccu.vx v16, \regtype\()6, v12 + vwmaccsu.vx v16, \regtype\()5, v10 + vwmaccsu.vx v16, \regtype\()2, v4 + vwmulu.vx v28, v8, \regtype\()4 +.endif + vwmaccsu.vx v16, \regtype\()0, v0 + vwmulu.vx v20, v6, \regtype\()3 + +.ifc \regtype,t + vwmaccsu.vx v16, a7, v14 +.elseif \regtype == s + vwmaccsu.vx v16, s7, v14 +.endif + +.endif + vwadd.wx v16, v16, a5 +.ifc \len,4 + vsetvli zero, zero, e16, mf2, ta, ma +.elseif \len == 8 + vsetvli zero, zero, e16, m1, ta, ma +.elseif \len == 16 + vsetvli zero, zero, e16, m2, ta, ma +.else + vsetvli zero, zero, e16, m4, ta, ma +.endif + +.ifc \name,smooth + vwadd.vv v24, v16, v20 +.else + vwadd.vv v24, v16, v28 + vwadd.wv v24, v24, v20 +.endif + vnsra.wi v24, v24, 7 + vmax.vx v24, v24, zero +.ifc \len,4 + vsetvli zero, zero, e8, mf4, ta, ma +.elseif \len == 8 + vsetvli zero, zero, e8, mf2, ta, ma +.elseif \len == 16 + vsetvli zero, zero, e8, m1, ta, ma +.else + vsetvli zero, zero, e8, m2, ta, ma +.endif + +.ifc \do,put + vnclipu.wi \dst, v24, 0 +.elseif \do == avg + vle8.v \dst, (a0) + vnclipu.wi v24, v24, 0 + vaaddu.vv \dst, \dst, v24 +.endif + +.endm + +.macro epel_load_inc dst len do name type from_mem regtype + epel_load \dst \len \do \name \type \from_mem \regtype + add a2, a2, a3 +.endm + +.macro epel len do name type + epel_filter \name \type t + +.ifc \len,4 + vsetivli zero, 4, e8, mf4, ta, ma +.elseif \len == 8 + vsetivli zero, 8, e8, mf2, ta, ma +.elseif \len == 16 + vsetivli zero, 16, e8, m1, ta, ma +.else + li a5, 32 + vsetvli zero, a5, e8, m2, ta, ma +.endif +.ifc \do,avg + csrwi vxrm, 0 +.endif + +1: + addi a4, a4, -1 + epel_load v30 \len \do \name \type 1 t + vse8.v v30, (a0) +.ifc \len,64 + addi a0, a0, 32 + addi a2, a2, 32 + epel_load v30 \len \do \name \type 1 t + vse8.v v30, (a0) + addi a0, a0, -32 + addi a2, a2, -32 +.endif + add a2, a2, a3 + add a0, a0, a1 + bnez a4, 1b + + ret +.endm + +.macro gen_epel len do name type +func ff_\do\()_8tap_\name\()_\len\()\type\()_rvv, zve32x + epel \len \do \name \type +endfunc +.endm + .irp len 64, 32, 16, 8, 4 func ff_avg\len\()_rvv, zve32x copy_avg \len avg @@ -134,4 +359,12 @@ endfunc func ff_avg_bilin_\len\()h_rvv, zve32x bilin_h \len avg endfunc + +.irp name regular sharp smooth + .irp do put avg + .irp type h + gen_epel \len \do \name \type + .endr + .endr +.endr .endr diff --git a/libavcodec/riscv/vp9dsp_init.c b/libavcodec/riscv/vp9dsp_init.c index 248501f5d2..97f02e601d 100644 --- a/libavcodec/riscv/vp9dsp_init.c +++ b/libavcodec/riscv/vp9dsp_init.c @@ -109,7 +109,13 @@ static av_cold void vp9dsp_mc_init_rvv(VP9DSPContext *dsp, int bpp) #define init_subpel1(idx1, idx2, idxh, idxv, sz, dir, type) \ dsp->mc[idx1][FILTER_BILINEAR ][idx2][idxh][idxv] = \ - ff_##type##_bilin_##sz##dir##_rvv; + ff_##type##_bilin_##sz##dir##_rvv; \ + dsp->mc[idx1][FILTER_8TAP_SMOOTH ][idx2][idxh][idxv] = \ + ff_##type##_8tap_smooth_##sz##dir##_rvv; \ + dsp->mc[idx1][FILTER_8TAP_REGULAR][idx2][idxh][idxv] = \ + ff_##type##_8tap_regular_##sz##dir##_rvv; \ + dsp->mc[idx1][FILTER_8TAP_SHARP ][idx2][idxh][idxv] = \ + ff_##type##_8tap_sharp_##sz##dir##_rvv; #define init_subpel2(idx, idxh, idxv, dir, type) \ init_subpel1(0, idx, idxh, idxv, 64, dir, type); \