From patchwork Sat Aug 3 09:50:37 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: 50880 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:1f5a:b0:489:2eb3:e4c4 with SMTP id jm26csp378731vqb; Sat, 3 Aug 2024 03:06:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXQRBtDF68fQ3qzYVgesdelpyT/9kDyuiG+KDav/tSvzof1QTLZAp5poWfBtWE2d/BoOrJlm/PSwTthRnrPDdZ+mWi86BD9gP7/eg== X-Google-Smtp-Source: AGHT+IHAxpQZzlsBYcdxYIv2qFWRmAr5CPOttbhAOmrzV6Pxfql/QlgvYclx3bdMOvInBJFTUxDX X-Received: by 2002:aa7:d357:0:b0:5a3:2af5:c722 with SMTP id 4fb4d7f45d1cf-5b7f38ebb2dmr4186321a12.13.1722679564783; Sat, 03 Aug 2024 03:06:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722679564; cv=none; d=google.com; s=arc-20160816; b=sCYWqdDkEAz09NZdeixIea0BEJ+UyUWB8jrhTj1B64Tdi5uCyZZSov4mNcRt4WH2JP enbsJxQAdC23t6hpYrM207dHfqRm8qcnWD1SATAXHpGiT+a2bSRo9K5/5/xIHXrFyy+T jXTjWnyfhH1OiIgr3Vw8KV18HF5Mg2DKbuW/EbcYmLP6NCG7LzRDUUDl+Qjt0MsgPGEm gQogQO5JdZ/Lcs///RQF1CIyff2NS2Ac20vJtd74O8zW91FLRdNkZtGfRCPSh61WI2a1 fAHj/FSym698dpIGinhSUDRYhbJK+gU2eDuGAgTP9jvvcuvySbnCU3vEhX0ld0iwsFj4 2mYQ== 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=TYWec1uLPiih/MsXtQt7+4WRu9kvavsBj/mZOYF7TMM=; fh=D0bFwGkf4X22/D/bfeDVrXKIx7S6kcXsNzy10j8ORbQ=; b=WfaHa102G6/SnyIKXqOfZlo3PL56VnX+LAE1uPUgT8dA8UHQn4S4EKMUC3HrHiDKl4 qxnAl+IriTq2IcQlD1tKgyvccSweagS9yXmduAeW62mEScbkRFV6svOSYdLmCr0QJmV3 JIBDIst0pFocgHHnL38bgfuTwVWxDb6N4goi2YW/ZNMFP1s8NTvC5cS/m3kIwP39oscn lLg7jUxK1qtQEYRNBjaxeBQqLYLzEasQqmlteOAJcD2dowC7yFnNavaaju1GOiYvkx9K bEVKu2E9EJpjMJg2/9KX3CPC2rF+uqjLfRCHI8vNS9wsTBJoDBViflfXTuK6RpxPkZ+W gBuA==; 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=hv+fYrMa; 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-5b83c61958fsi2032288a12.567.2024.08.03.03.06.04; Sat, 03 Aug 2024 03:06:04 -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=hv+fYrMa; 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 2EB0468D8AE; Sat, 3 Aug 2024 12:51:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out203-205-221-239.mail.qq.com (out203-205-221-239.mail.qq.com [203.205.221.239]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 09F7A68D80D for ; Sat, 3 Aug 2024 12:50:53 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1722678643; bh=pvbs1E3EvSHrpGZ6MKQXqhNqi49+RLATjssdE6YtQq8=; h=From:To:Cc:Subject:Date; b=hv+fYrMaPCTfjwYfjIND6VVHFpIl70YDoHE706W2JpaU/qTyBLygDa3U82DMN+2SZ IdyH/V09NXy2A4rfp7Ax/DgrHhFhh+sPASnQQz7xIRtmI6zbH7HQSv8sHUWvZx0Dez V9wlEZyTqH/h9HpnoEqfhFOmjpp/pYMAxsF40Br8= Received: from localhost.localdomain ([42.86.132.47]) by newxmesmtplogicsvrszb16-1.qq.com (NewEsmtp) with SMTP id CAA3C22C; Sat, 03 Aug 2024 17:50:42 +0800 X-QQ-mid: xmsmtpt1722678642td92dk6jq Message-ID: X-QQ-XMAILINFO: NDz66ktblfzJV21gBqGsaCfljXYpODnlkVFbIVNQJsgb1d4CrMOqmGU9Q92IG4 ppma8YJDQBBMOvGV+2Bj4ro87OO1aDtIHEbmKX6uQSlOYW5yBXzyc8z6d2+kI1YZRmnFyDEe414u 73jnaPd7OHm2jUDYwlNLxp+I394ve1fNrI9ipzr1yvtSqDOQ66TgC9Vgzu9IjTB260K0NJSIs0eV +i5n/XHjqjAME67TO80lzTwQQCHIFjual4mX6hbIU/W7lN2LxNhH4IDeXo+6RWdrahA0B0KTE/im J+1fA/BdAg4tFVwjXdqLFlyvrvfkizlA/E96yjoBDHDJ9gytZvBhUFKWmLlp4IQg0z7+tlsjwihg zck50710+0C9g3blG3VReX5HCA4lnXsi5hDBhQ63wuPqfj0lMi4jf6Uowh08PDgyzWsk/94W129c LwuPM2MQFWytBxLYRbaz4HxdjT4itAGfbLuojFVUoDOfAU2qqD8X++6ryTdtYuWGBvfTo/HsysJI UJr3lxgMNYJJfwYSM0riL+uJ6+NK5iBPvSEYKZHIMcHgWe5u7dl3C8gp4FFh2qtUS8Rzk6tiuZRp Xiahqli8NzG54FddiL06/wLocQys7iMYKXyR+DSczCZaZB9qAKL1ITPsXxALZ2XcAzSp1nRa/bgU CqF4FxmsKyAUY7Guxnn0aVU6Bfr3FMQm7wgJH+/lTZ2b0yqMhzni6/APkPs1qY26pPVBwFiBvF0M cWvxAXD70YT6/j1xI2I8kxbQQQOtr+8HYcM9XWQwowLtO9WtAS2BarffY37x4vSEmHxDAobZ9oMw KAHgkBadRWRZAf4Ahy8uqfQhOe58TKg0czQcUbYuKN3UAV97W2ZC3yVKU8H5r/9TBSEfrBVX69dr UqZN0CPPfduTXIchodeqn1Tbub7igw0mEjUp42PC5KdoYHnNdKX3M= X-QQ-XMRINFO: OD9hHCdaPRBwq3WW+NvGbIU= From: uk7b@foxmail.com To: ffmpeg-devel@ffmpeg.org Date: Sat, 3 Aug 2024 17:50:37 +0800 X-OQ-MSGID: <20240803095040.3648582-1-uk7b@foxmail.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] lavc/vp9dsp: R-V V mc bilin h v 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: fE+VJ10EX1sX From: sunyuechi C908 X60 vp9_avg_bilin_4h_8bpp_c : 5.5 4.7 vp9_avg_bilin_4h_8bpp_rvv_i32 : 1.7 1.5 vp9_avg_bilin_4v_8bpp_c : 5.5 4.7 vp9_avg_bilin_4v_8bpp_rvv_i32 : 1.5 1.2 vp9_avg_bilin_8h_8bpp_c : 20.0 17.7 vp9_avg_bilin_8h_8bpp_rvv_i32 : 3.0 2.7 vp9_avg_bilin_8v_8bpp_c : 20.7 18.7 vp9_avg_bilin_8v_8bpp_rvv_i32 : 3.0 2.7 vp9_avg_bilin_16h_8bpp_c : 78.2 69.7 vp9_avg_bilin_16h_8bpp_rvv_i32 : 7.0 6.2 vp9_avg_bilin_16v_8bpp_c : 98.5 73.2 vp9_avg_bilin_16v_8bpp_rvv_i32 : 7.0 6.0 vp9_avg_bilin_32h_8bpp_c : 325.5 275.5 vp9_avg_bilin_32h_8bpp_rvv_i32 : 23.0 20.5 vp9_avg_bilin_32v_8bpp_c : 342.2 290.0 vp9_avg_bilin_32v_8bpp_rvv_i32 : 21.7 19.5 vp9_avg_bilin_64h_8bpp_c : 1263.7 1095.7 vp9_avg_bilin_64h_8bpp_rvv_i32 : 91.2 81.2 vp9_avg_bilin_64v_8bpp_c : 1331.7 1155.2 vp9_avg_bilin_64v_8bpp_rvv_i32 : 91.2 81.0 vp9_put_bilin_4h_8bpp_c : 4.5 4.0 vp9_put_bilin_4h_8bpp_rvv_i32 : 1.0 1.0 vp9_put_bilin_4v_8bpp_c : 4.7 4.2 vp9_put_bilin_4v_8bpp_rvv_i32 : 1.0 1.0 vp9_put_bilin_8h_8bpp_c : 16.7 15.0 vp9_put_bilin_8h_8bpp_rvv_i32 : 2.2 2.0 vp9_put_bilin_8v_8bpp_c : 17.5 15.7 vp9_put_bilin_8v_8bpp_rvv_i32 : 2.2 2.0 vp9_put_bilin_16h_8bpp_c : 65.2 58.0 vp9_put_bilin_16h_8bpp_rvv_i32 : 6.0 5.5 vp9_put_bilin_16v_8bpp_c : 69.2 61.7 vp9_put_bilin_16v_8bpp_rvv_i32 : 5.7 5.2 vp9_put_bilin_32h_8bpp_c : 273.2 229.0 vp9_put_bilin_32h_8bpp_rvv_i32 : 19.7 17.7 vp9_put_bilin_32v_8bpp_c : 290.5 243.7 vp9_put_bilin_32v_8bpp_rvv_i32 : 18.7 16.7 vp9_put_bilin_64h_8bpp_c : 1040.5 910.5 vp9_put_bilin_64h_8bpp_rvv_i32 : 82.5 73.0 vp9_put_bilin_64v_8bpp_c : 1108.5 971.0 vp9_put_bilin_64v_8bpp_rvv_i32 : 82.2 73.2 --- libavcodec/riscv/vp9_mc_rvv.S | 116 +++++++++++++++++++++++++++++++++ libavcodec/riscv/vp9dsp.h | 12 ++-- libavcodec/riscv/vp9dsp_init.c | 21 ++++++ 3 files changed, 143 insertions(+), 6 deletions(-) diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S index 8d776661d9..817cc58b5e 100644 --- a/libavcodec/riscv/vp9_mc_rvv.S +++ b/libavcodec/riscv/vp9_mc_rvv.S @@ -54,6 +54,122 @@ func ff_vp9_avg\len\()_rvv, zve32x endfunc .endm +.macro bilin_load_h dst, op, mn + addi t5, a2, 1 + vle8.v v8, (a2) + vle8.v v0, (t5) + vwmulu.vx v16, v0, \mn + vwmaccsu.vx v16, t1, v8 + vwadd.wx v16, v16, t4 + vnsra.wi v16, v16, 4 + vadd.vv \dst, v16, v8 +.ifc \op,avg + vle8.v v16, (a0) + vaaddu.vv \dst, \dst, v16 +.endif +.endm + +.macro bilin_h_v op, type, mn +func ff_\op\()_vp9_bilin_64\type\()_rvv, zve32x + lpad 0 + vsetvlstatic8 64, t0, 64 +.ifc \op,avg + csrwi vxrm, 0 +.endif + li t4, 8 + neg t1, \mn +1: + addi a4, a4, -1 +.ifc \type,v + add t5, a2, a3 +.else + addi t5, a2, 1 +.endif + vle8.v v8, (a2) + vle8.v v0, (t5) + vwmulu.vx v16, v0, \mn + vwmaccsu.vx v16, t1, v8 + vwadd.wx v16, v16, t4 + vnsra.wi v16, v16, 4 + vadd.vv v0, v16, v8 +.ifc \op,avg + vle8.v v16, (a0) + vaaddu.vv v0, v0, v16 +.endif + vse8.v v0, (a0) + add a2, a2, a3 + add a0, a0, a1 + bnez a4, 1b + ret + +.Lbilin_\type\op: +.ifc \op,avg + csrwi vxrm, 0 +.endif + li t4, 8 + neg t1, \mn +1: + addi a4, a4, -2 + add t6, a0, a1 + add t0, a2, a3 + vle8.v v8, (a2) + vle8.v v4, (t0) +.ifc \type,v + add t2, t0, a3 + vwmulu.vx v16, v4, \mn +.else + addi t3, a2, 1 + addi t2, t0, 1 + vle8.v v0, (t3) + vwmulu.vx v16, v0, \mn +.endif + vle8.v v12, (t2) + vwmulu.vx v20, v12, \mn + vwmaccsu.vx v16, t1, v8 + vwmaccsu.vx v20, t1, v4 + vwadd.wx v16, v16, t4 + vwadd.wx v20, v20, t4 + vnsra.wi v16, v16, 4 + vnsra.wi v20, v20, 4 + vadd.vv v0, v16, v8 + vadd.vv v12, v20, v4 +.ifc \op,avg + vle8.v v16, (a0) + vle8.v v20, (t6) + vaaddu.vv v0, v0, v16 + vaaddu.vv v12, v12, v20 +.endif + vse8.v v0, (a0) + vse8.v v12, (t6) + add a2, t0, a3 + add a0, t6, a1 + bnez a4, 1b + + ret +endfunc +.endm + .irp len, 64, 32, 16, 8, 4 copy_avg \len .endr + +bilin_h_v put, h, a5 +bilin_h_v avg, h, a5 +bilin_h_v put, v, a6 +bilin_h_v avg, v, a6 + +.macro func_bilin_h_v len, op, type +func ff_\op\()_vp9_bilin_\len\()\type\()_rvv, zve32x + lpad 0 + vsetvlstatic8 \len, t0, 64 + j .Lbilin_\type\()\op +endfunc +.endm + +.irp len, 32, 16, 8, 4 + .irp op, put, avg + .irp type, h, v + func_bilin_h_v \len, \op, \type + .endr + .endr +.endr diff --git a/libavcodec/riscv/vp9dsp.h b/libavcodec/riscv/vp9dsp.h index ff8431591c..8fb326dae0 100644 --- a/libavcodec/riscv/vp9dsp.h +++ b/libavcodec/riscv/vp9dsp.h @@ -113,27 +113,27 @@ void ff_avg_8tap_##type##_##SIZE##hv_rvv(uint8_t *dst, ptrdiff_t dststride, \ int h, int mx, int my); #define VP9_BILINEAR_RISCV_RVV_FUNC(SIZE) \ -void ff_put_bilin_##SIZE##h_rvv(uint8_t *dst, ptrdiff_t dststride, \ +void ff_put_vp9_bilin_##SIZE##h_rvv(uint8_t *dst, ptrdiff_t dststride, \ const uint8_t *src, ptrdiff_t srcstride, \ int h, int mx, int my); \ \ -void ff_put_bilin_##SIZE##v_rvv(uint8_t *dst, ptrdiff_t dststride, \ +void ff_put_vp9_bilin_##SIZE##v_rvv(uint8_t *dst, ptrdiff_t dststride, \ const uint8_t *src, ptrdiff_t srcstride, \ int h, int mx, int my); \ \ -void ff_put_bilin_##SIZE##hv_rvv(uint8_t *dst, ptrdiff_t dststride, \ +void ff_put_vp9_bilin_##SIZE##hv_rvv(uint8_t *dst, ptrdiff_t dststride, \ const uint8_t *src, ptrdiff_t srcstride, \ int h, int mx, int my); \ \ -void ff_avg_bilin_##SIZE##h_rvv(uint8_t *dst, ptrdiff_t dststride, \ +void ff_avg_vp9_bilin_##SIZE##h_rvv(uint8_t *dst, ptrdiff_t dststride, \ const uint8_t *src, ptrdiff_t srcstride, \ int h, int mx, int my); \ \ -void ff_avg_bilin_##SIZE##v_rvv(uint8_t *dst, ptrdiff_t dststride, \ +void ff_avg_vp9_bilin_##SIZE##v_rvv(uint8_t *dst, ptrdiff_t dststride, \ const uint8_t *src, ptrdiff_t srcstride, \ int h, int mx, int my); \ \ -void ff_avg_bilin_##SIZE##hv_rvv(uint8_t *dst, ptrdiff_t dststride, \ +void ff_avg_vp9_bilin_##SIZE##hv_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 2034e1c976..83dbe1b5d9 100644 --- a/libavcodec/riscv/vp9dsp_init.c +++ b/libavcodec/riscv/vp9dsp_init.c @@ -63,6 +63,27 @@ static av_cold void vp9dsp_mc_init_riscv(VP9DSPContext *dsp, int bpp) init_fpel(3, 8); init_fpel(4, 4); + dsp->mc[0][FILTER_BILINEAR ][0][0][1] = ff_put_vp9_bilin_64v_rvv; + dsp->mc[0][FILTER_BILINEAR ][0][1][0] = ff_put_vp9_bilin_64h_rvv; + dsp->mc[0][FILTER_BILINEAR ][1][0][1] = ff_avg_vp9_bilin_64v_rvv; + dsp->mc[0][FILTER_BILINEAR ][1][1][0] = ff_avg_vp9_bilin_64h_rvv; + dsp->mc[1][FILTER_BILINEAR ][0][0][1] = ff_put_vp9_bilin_32v_rvv; + dsp->mc[1][FILTER_BILINEAR ][0][1][0] = ff_put_vp9_bilin_32h_rvv; + dsp->mc[1][FILTER_BILINEAR ][1][0][1] = ff_avg_vp9_bilin_32v_rvv; + dsp->mc[1][FILTER_BILINEAR ][1][1][0] = ff_avg_vp9_bilin_32h_rvv; + dsp->mc[2][FILTER_BILINEAR ][0][0][1] = ff_put_vp9_bilin_16v_rvv; + dsp->mc[2][FILTER_BILINEAR ][0][1][0] = ff_put_vp9_bilin_16h_rvv; + dsp->mc[2][FILTER_BILINEAR ][1][0][1] = ff_avg_vp9_bilin_16v_rvv; + dsp->mc[2][FILTER_BILINEAR ][1][1][0] = ff_avg_vp9_bilin_16h_rvv; + dsp->mc[3][FILTER_BILINEAR ][0][0][1] = ff_put_vp9_bilin_8v_rvv; + dsp->mc[3][FILTER_BILINEAR ][0][1][0] = ff_put_vp9_bilin_8h_rvv; + dsp->mc[3][FILTER_BILINEAR ][1][0][1] = ff_avg_vp9_bilin_8v_rvv; + dsp->mc[3][FILTER_BILINEAR ][1][1][0] = ff_avg_vp9_bilin_8h_rvv; + dsp->mc[4][FILTER_BILINEAR ][0][0][1] = ff_put_vp9_bilin_4v_rvv; + dsp->mc[4][FILTER_BILINEAR ][0][1][0] = ff_put_vp9_bilin_4h_rvv; + dsp->mc[4][FILTER_BILINEAR ][1][0][1] = ff_avg_vp9_bilin_4v_rvv; + dsp->mc[4][FILTER_BILINEAR ][1][1][0] = ff_avg_vp9_bilin_4h_rvv; + #undef init_fpel } #endif