From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 65CC84B0D2 for ; Thu, 27 Jun 2024 19:05:04 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1168468D655; Thu, 27 Jun 2024 22:04:47 +0300 (EEST) Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 952AA68D478 for ; Thu, 27 Jun 2024 22:04:36 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id D49BBC013D for ; Thu, 27 Jun 2024 22:04:35 +0300 (EEST) From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Thu, 27 Jun 2024 22:04:34 +0300 Message-ID: <20240627190435.12159-2-remi@remlab.net> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240627190435.12159-1-remi@remlab.net> References: <20240627190435.12159-1-remi@remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] lavc/vc1dsp: fix overflow in R-V V inv_trans_8 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: The last set of additions/subtractions can break the 16-bit limit, and require 17 bits of precision. This uses widening adds accordingly to fix the MSS2 FATE tests. --- libavcodec/riscv/vc1dsp_rvv.S | 37 ++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/libavcodec/riscv/vc1dsp_rvv.S b/libavcodec/riscv/vc1dsp_rvv.S index b3a1f55ab9..d038981a02 100644 --- a/libavcodec/riscv/vc1dsp_rvv.S +++ b/libavcodec/riscv/vc1dsp_rvv.S @@ -145,44 +145,49 @@ func ff_vc1_inv_trans_8_rvv, zve32x vadd.vv v20, v20, v21 vadd.vv v22, v22, v23 vsll.vi v21, v3, 2 - vadd.vv v16, v20, v22 # t1 + vadd.vv v24, v20, v22 # t1 vmul.vx v20, v1, t5 vsll.vi v22, v5, 4 vmul.vx v23, v7, t3 vsub.vv v20, v20, v21 vadd.vv v22, v22, v23 vsll.vi v21, v3, 4 - vsub.vv v17, v20, v22 # t2 + vsub.vv v25, v20, v22 # t2 vmul.vx v20, v1, t3 vsll.vi v22, v5, 2 vmul.vx v23, v7, t5 vsub.vv v20, v20, v21 vadd.vv v22, v22, v23 vmul.vx v21, v3, t3 - vadd.vv v18, v20, v22 # t3 + vadd.vv v26, v20, v22 # t3 vsll.vi v20, v1, 2 vmul.vx v22, v5, t5 vsll.vi v23, v7, 4 vsub.vv v20, v20, v21 vsub.vv v22, v22, v23 + vadd.vv v27, v20, v22 # t4 srli t2, t1, 2 - vadd.vv v0, v28, v16 - vadd.vv v19, v20, v22 # t4 - vadd.vv v1, v29, v17 - vadd.vv v2, v30, v18 - vadd.vv v3, v31, v19 - vsub.vv v4, v31, v19 - vsub.vv v5, v30, v18 - vsub.vv v6, v29, v17 - vsub.vv v7, v28, v16 + vwadd.vv v8, v28, v24 + vwadd.vv v10, v29, v25 + vwadd.vv v12, v30, v26 + vwadd.vv v14, v31, v27 beqz t2, 1f # faster than 4x add t2=zero - .irp n,4,5,6,7 + .irp n,31,30,29,28 vadd.vi v\n, v\n, 1 .endr 1: - .irp n,0,1,2,3,4,5,6,7 - vssra.vx v\n, v\n, t1 - .endr + vwsub.vv v16, v31, v27 + vwsub.vv v18, v30, v26 + vwsub.vv v20, v29, v25 + vwsub.vv v22, v28, v24 + vnclip.wx v0, v8, t1 + vnclip.wx v1, v10, t1 + vnclip.wx v2, v12, t1 + vnclip.wx v3, v14, t1 + vnclip.wx v4, v16, t1 + vnclip.wx v5, v18, t1 + vnclip.wx v6, v20, t1 + vnclip.wx v7, v22, t1 jr t0 endfunc -- 2.45.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".