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 ESMTPS id 474CF4D32D for ; Wed, 19 Feb 2025 20:33:51 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C673068C34B; Wed, 19 Feb 2025 22:33:47 +0200 (EET) Received: from sender2-op-o11.zoho.eu (sender2-op-o11.zoho.eu [136.143.171.11]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 95BB568C0DB for ; Wed, 19 Feb 2025 22:33:41 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; t=1739997219; cv=none; d=zohomail.eu; s=zohoarc; b=DtqqbfHpAxEdmRlbpEMDwSm5ZRe90Ha+p1FDM+r/sZ0zS1pKddOKcjbS6OoLhWP8t/lROzx2ONpWT8KcDi3lVcpSS4CFSKregU6Ix2GXxmhU0aPwIS8CuGn15u4M5EoiFOWbP8rfcp/BVsUETzFwBtubllid9nBUX5qEH0H57A8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1739997219; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=mdB0Rk2nG3iwb3f51+PbuTeU60ozfjvRbi9YzzaKJI0=; b=EY35uFiwpKk63YqqPDgPnZ91X5tNIIToh/qypJge1iEejWHM5SIQm81Iudr5gUvrA/Iwb5OzYDuK6VTRkyIOO0b3ilZgyevAD4GUGTmvx6JS5vvQM87VWc2ti9Ftg5rePu5Q4emR/i6Yoi8DihondCi9UUPPiQjsxKtrLsPaaBI= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=frankplowman.com; spf=pass smtp.mailfrom=post@frankplowman.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1739997219; s=zmail; d=frankplowman.com; i=post@frankplowman.com; h=Message-ID:Date:Date:MIME-Version:Subject:Subject:To:To:Cc:Cc:References:From:From:In-Reply-To:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=mdB0Rk2nG3iwb3f51+PbuTeU60ozfjvRbi9YzzaKJI0=; b=IpLg8HrCWxL547552ElTVJ6GEV5JiQbDvccIS7wVzJnenASdhDL6dnRDlt0396A+ RQwmahSFDOSgLK20xEpP9hAPSis7j9O6XbFUlWsost7A/Gb4I7gh5U1ijAO92nUM8rY BCu0QmbjRVKY+tVVPRlh5lBS4pgRv4KSP9O0OVEA= Received: by mx.zoho.eu with SMTPS id 1739997216899742.0429348967415; Wed, 19 Feb 2025 21:33:36 +0100 (CET) Message-ID: <8dee0755-4f5c-4e46-8963-d90cdd1587a1@frankplowman.com> Date: Wed, 19 Feb 2025 20:33:36 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-GB To: ffmpeg-devel@ffmpeg.org References: <20250202121053.17147-1-post@frankplowman.com> From: Frank Plowman In-Reply-To: <20250202121053.17147-1-post@frankplowman.com> X-ZohoMailClient: External Subject: Re: [FFmpeg-devel] [PATCH] lavc/vvc: Fix derivation of inverse LMCS idx 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: nuomi2021@gmail.com 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: Ping On 02/02/2025 12:10, Frank Plowman wrote: > The clamping of idxYInv from H.266(V3) section 8.8.2.3 was missing. > This could lead to OOB reads from lmcs->pivot or input_pivot. > > I also changed the derivation of the forward LMCS idx to use a shift > rather than a division for speed and as this is actually how the > variable is declared in the specification (8.7.5.2). > > Signed-off-by: Frank Plowman > --- > libavcodec/vvc/ps.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/vvc/ps.c b/libavcodec/vvc/ps.c > index 01b4615eda..fae6655cc0 100644 > --- a/libavcodec/vvc/ps.c > +++ b/libavcodec/vvc/ps.c > @@ -786,7 +786,7 @@ static int lmcs_derive_lut(VVCLMCS *lmcs, const H266RawAPS *rlmcs, const H266Raw > > //derive lmcs_fwd_lut > for (uint16_t sample = 0; sample < max; sample++) { > - const int idx_y = sample / org_cw; > + const int idx_y = sample >> shift; > const uint16_t fwd_sample = lmcs_derive_lut_sample(sample, lmcs->pivot, > input_pivot, scale_coeff, idx_y, max); > if (bit_depth > 8) > @@ -802,6 +802,7 @@ static int lmcs_derive_lut(VVCLMCS *lmcs, const H266RawAPS *rlmcs, const H266Raw > uint16_t inv_sample; > while (i <= lmcs->max_bin_idx && sample >= lmcs->pivot[i + 1]) > i++; > + i = FFMIN(i, LMCS_MAX_BIN_SIZE - 1); > > inv_sample = lmcs_derive_lut_sample(sample, input_pivot, lmcs->pivot, > inv_scale_coeff, i, max); _______________________________________________ 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".