From patchwork Thu Jun 27 19:04:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 50199 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:2d88:b0:482:c625:d099 with SMTP id jb8csp15769vqb; Thu, 27 Jun 2024 12:05:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXsEudLn761Euedt0SvAzIru2uC4YBT4Tq82lCrHAOaPSR7/v/1MXp0k03WxtbKvpn/cwBLHMajKLrx1XawSZu3WQ6fxYpJFJv3wg== X-Google-Smtp-Source: AGHT+IHqVmmRZ4DdL1y7OmErlEWWILhDyVyJN/4BJfNQO0aZRUYyTeiUc9LcdDwnPWVq2cKPIlgg X-Received: by 2002:a05:6402:34ce:b0:586:1517:872c with SMTP id 4fb4d7f45d1cf-58615178745mr52657a12.15.1719515107229; Thu, 27 Jun 2024 12:05:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719515107; cv=none; d=google.com; s=arc-20160816; b=H0yxQSul/J+sGJljzDG3diM32WUOV9m6A3LjRqYmHCXIsMWAwrh0CxeHE9voykiKFg xECAJH5CivcZDwcaji8FWV+MbUmV0rJboX566DxKPA9mYk9wbaWDBRlsJi8CsqXr2skp TE6cm9Yfce8oSTpPKszsqIkiiJT1/5v21dlewfV2Qfci2zVGT7ll3TQBlYdQvTXW2d/V qNYdHIgXNtHm6mJZtcOoxMXcFmqAwICb7E5Suu2AsagsTPF5SIx83SWM4tIukNqy1ztl TqumnIkOasY/qaxCzGGGcVA6MGLKT5GQzlKXoXZNwwQOdveWdP5Wu/uoq9tB/IE0Mdve ZRIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=NTzKMzxfxDBH9bgbqRcKML0afgBfuoDWlNimyjGbHYk=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=WTJ2aGZhLzVA3kXMFJmrSpSarRDYQ/VFzUZuCKPWVmThuq19S7BKCEiFsVAJu1Ep9I SWVgKk/QWjqzAjWGCZD87u3AckFzxQTRQrZix87AqvdTQ2+TpycU3xVsWr08XH8CZOYN K6ENUTy6EYvsgyQNb2cEs008aTMqyQv5DiTSSeCfCPffHu/AYm0a0kk0ejrJ+hIyw9CG lUSHe2PfnrT1K8QNDVPWf2smBYJtouEpX55c4f0xVuBAq4TMjd5/9DKP+CjeReTvmouX AzRNjTz3nIH8jZ+51jzVEyyH9Wr7uHg8jTyc49ubHNt6FNBphL/m01R4fPd699egcjVk wJKg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-58615465cf6si28694a12.574.2024.06.27.12.05.06; Thu, 27 Jun 2024 12:05:07 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6C9F068D656; Thu, 27 Jun 2024 22:04:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org 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_Denis-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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: p1xY05vePaix 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