From patchwork Wed Apr 10 13:31:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 48002 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c90a:b0:1a7:a0dc:8de5 with SMTP id gx10csp557124pzb; Wed, 10 Apr 2024 06:32:25 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVv8XSDB+0wMAObX0Ij8EuP3dy+W8OrpIAjmROpD4bfyP17qMhZx9IdZ5UvvibqjhxACM0vd8OsvbKIlb8+L4UgfZhD0FjvBNvqCw== X-Google-Smtp-Source: AGHT+IGfzHcGrS7YQLU9nc7pytcoNVrPQox+b2zQsGP8DSRgpErIrI3yc/o5sk7GTq8P/Oy9heOR X-Received: by 2002:a2e:7808:0:b0:2d8:1b2a:6526 with SMTP id t8-20020a2e7808000000b002d81b2a6526mr1871865ljc.4.1712755945419; Wed, 10 Apr 2024 06:32:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712755945; cv=none; d=google.com; s=arc-20160816; b=NNfTzQucEFrPyxgLnzvv2MUOtFOcdgMlsaORFt1B/DmHeSNl0Ju2uBy3ZxpzvNpPXq GxMbBD8hYDJy2NBqEChrvfJWAJXwEG2YaPudoCarc0WKzCjjgLVqpwXLjbGNR1avPMJe pYJU416LMstyxDy1FTU+/HKiNOCGq0qw76hLEtRWgWsgd9Gc/iOraA0EunvHSGkRA0Mh 7D9ZIDxB/Ja/9q2EEyqn6DYe1SuUkI9863ePv7lMlrji+lG9GR57Jju9hnGiobMGx90M /S6akzt8GUTmDvDiDZBahgEaZnMVzGYNlw/ySqMkfP0UmWegljZqnNoVEZhfxuyCiCyV fAqw== 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:dkim-signature:delivered-to; bh=n89kPwXCnmvL4n47CaM/EvPHqykFM7eGpG663JRRJqQ=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=as/hTmKwedXwmZcfDd9hDWSqZz+3N7WJfQ6mgEkiAnKgv672venkbn8D7z/veTkzrd UVM4PsSYjaNGjC5ZkQ4ArMfVQmQ9POMfVq/w/dB4sCVvBjXYclqc2niDObRMuOQwaEMu bNc+VbfLCwujJM/77S2R0Yp9XTIX+5sPxZ+tGSCAtxDdUDDMhrZXUkOMCmdVR+5I8/TU EqSOI5a7uue8aofhzICYXHRJkG6X9HBtE57ibzADzwi0bpd2dSs1DRMHdjy+uwgeTK8f /TXfHC6pmM1gWrL+6Li+yj0fWjvuBm4AcRlq44M5Mxgvn0OoWfL9Gf/L6uYHoEW0xhmK GBEA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=XkhUYrHv; 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 2-20020a05651c00c200b002d6b3f5cdb5si330076ljr.192.2024.04.10.06.32.24; Wed, 10 Apr 2024 06:32:25 -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=@khirnov.net header.s=mail header.b=XkhUYrHv; 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 3DF6D68D15D; Wed, 10 Apr 2024 16:31:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4D4D468CEE6 for ; Wed, 10 Apr 2024 16:31:32 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=XkhUYrHv; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 341384D76 for ; Wed, 10 Apr 2024 15:31:27 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id JxKNfof3G_za for ; Wed, 10 Apr 2024 15:31:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712755884; bh=qA0AuMxYm78poykhZjKwFh+DOADjTReX+N8NqWCqBbk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XkhUYrHvmbdvVWelsQfDQNN21sxMciANGqLVRJjmcgkwFnvUnEwz4pvrLr3ySNSdy df/x5qvDqhfUNYQoHbDMakMNHWhHBx7y30hb+c8xLSLKyn8zD0wgDWPYRZTXahLlhI wHvCBHMq106enI59g1CFWwMukHoTfNObEH2rTXNQUoDZ63YaLTJweXY4SexHPskLS1 BZytw4SixnpSESUvl8SuqIMZQgIYDMmFz6Nshm5mDuDJOiFnR0icP5Y82FOw13mK+B jUtP7YJlhQXXlKMk8QXJPeaMYJ8Dj53pWety5cjTKC9HyWK4YWTmfmfIK4GmG+quM2 LJk/06GqgGCXQ== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id E01664D79 for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id C98643A0379 for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Apr 2024 15:31:15 +0200 Message-ID: <20240410133118.28144-7-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410133118.28144-1-anton@khirnov.net> References: <20240410133118.28144-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/10] lavc/hevc_ps: fix variable signedness in ff_hevc_decode_short_term_rps() 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: cEn6qARusLlw It is actually supposed to go negative in the loop over num_negative pics, but underflow does not break anything as the result is then assigned to a signed int. --- libavcodec/hevc_ps.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index 1af691414e..d90f172c46 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -197,7 +197,8 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, } } } else { - unsigned int prev, nb_positive_pics; + unsigned int nb_positive_pics; + rps->num_negative_pics = get_ue_golomb_long(gb); nb_positive_pics = get_ue_golomb_long(gb); @@ -209,7 +210,8 @@ int ff_hevc_decode_short_term_rps(GetBitContext *gb, AVCodecContext *avctx, rps->num_delta_pocs = rps->num_negative_pics + nb_positive_pics; if (rps->num_delta_pocs) { - prev = 0; + int prev = 0; + for (i = 0; i < rps->num_negative_pics; i++) { delta_poc = rps->delta_poc_s0[i] = get_ue_golomb_long(gb) + 1; if (delta_poc < 1 || delta_poc > 32768) {