From patchwork Sun Apr 24 04:42:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 35418 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b9e:b0:7d:cfb5:dc7c with SMTP id b30csp1237671pzh; Sat, 23 Apr 2022 21:43:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMjQM/UN3GaDG5p3Tgoou0f4NA2xl3VhyRocMGGZytdj+4ZXSow8W/O95SL3IozlYERpCv X-Received: by 2002:a17:906:cec3:b0:6e8:a49f:2189 with SMTP id si3-20020a170906cec300b006e8a49f2189mr10738978ejb.119.1650775399324; Sat, 23 Apr 2022 21:43:19 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 17-20020a170906309100b006e8d12994c7si11218337ejv.395.2022.04.23.21.43.18; Sat, 23 Apr 2022 21:43:19 -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=@outlook.com header.s=selector1 header.b=tW3Bb9w8; arc=fail (body hash mismatch); 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=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 36DD168B411; Sun, 24 Apr 2022 07:43:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03olkn2093.outbound.protection.outlook.com [40.92.58.93]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 18B8A68B08F for ; Sun, 24 Apr 2022 07:43:10 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lssZaP6TdDu/pHXx91ETAoXcgGGKMjVtaaPCM8pWa+eaM/wsHgJF7gEJz50XU3sqdMXL9P6Cl0t2vaxafJWMhX8/h7UpQOmDnh4EJcxtgb4eV108MHTKuyQxz2Y4Jazup7PzsVNd9q6J0aKMODAQm5dp7PpEY2NRMQnZ42SJvw5J3H11TAs5J9d7LSHJBNS9Du2NELbVew3avIYqiK7SP/9xKQifzOei2dAq7HR8yDVH1ZFB3JO+JVgPiiW0qI4vkjrCsCKexVOJ4gs1WXaFnFyvLK1Ty16eYUWNetW0FVI6nMEg1yolkqI2hBc4okdY/XalTLzKX3Cx5z0H9R2euQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=30Fy50ifajwaPp3a/e3SW6RfmN22H69mQ9Vj3XkAUJw=; b=Rxh0B/eC1efnjWuRGuX2B3WGqmqOvOTuq05jn1q8rihC+YToDOeGdBRhS3Qxkobp+bO1OWeTw5AWvzsk5ote4lKyDez1gshsHF7J+GnndV0IpZSctIYtaHahBc3xbt6XPXyyuq87IVUxcIMCoEEg0hD7A7wIOrSfLWigKYdaNhPkinOFts6ZsQ9HwuxQSucOZwKfYluGZ+UYVZFp3lRgnJQAWFWWLBIXjrzdpZr8XzcKJIzjJ9nj7X4F4SdwYo+NHzuHNd18l7+pJwe/nsigTujf2hThoWBZhwbBTXUJRycQ9xM5X5J91QjW3kaMOJasKJyoRpBn5j8BMGxRsg3urg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=30Fy50ifajwaPp3a/e3SW6RfmN22H69mQ9Vj3XkAUJw=; b=tW3Bb9w8CTh54xnExPX5hx7KjZ2GHeMD3g0knFU202EoF4n7JkSwZVdt1i9m3P1fu1y5C7D1PzHi2zVnfPXm0xe/9I8vgqSqrHS15nVAUvc0vhEqSNfQeILpTgdWnho2qq7liP5iugOGSCQfPh9kvyXAzyP8PMYoTAjaIEkqwFBtvBeXAkfhNBJl+KfG5x53pBKZee6oqQApDXgR1Aq4YIuNSLKEkWl8y1DAD+QUSKwg4dqBmICml6yzEsec0oCmNKwt/d7UIs2ZJ2TQSs8pqmRPElStSq592nzgLykMKNGP6Bp6qJoAyvlKwOY8UPTZj/bzHzJKKDKFmhu/oR4q2w== Received: from AS8PR01MB7944.eurprd01.prod.exchangelabs.com (2603:10a6:20b:373::5) by AM4PR0101MB2210.eurprd01.prod.exchangelabs.com (2603:10a6:200:53::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.13; Sun, 24 Apr 2022 04:43:07 +0000 Received: from AS8PR01MB7944.eurprd01.prod.exchangelabs.com ([fe80::1854:2c30:7ba1:c431]) by AS8PR01MB7944.eurprd01.prod.exchangelabs.com ([fe80::1854:2c30:7ba1:c431%6]) with mapi id 15.20.5186.020; Sun, 24 Apr 2022 04:43:07 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 24 Apr 2022 06:42:53 +0200 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [N0ciJusYpSNENa4LQl2thW89P/3zni5L] X-ClientProxiedBy: ZR0P278CA0069.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:21::20) To AS8PR01MB7944.eurprd01.prod.exchangelabs.com (2603:10a6:20b:373::5) X-Microsoft-Original-Message-ID: <20220424044258.888081-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6beda58a-c53a-4b83-c39a-08da25aced9c X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiT4+P6zBac8z1eXEhCqSjjDzSBxYXPTajp35rHqPEqPyodSCsEo2uauvS8PDzbBdiwZUjgQ2VXX/7Rz7ta/SvpHwmo5H2+JZcf1Qtye7D6IKgYUkFcgGFuTH903ulyiMs+Uwxj3l9z6A+8e5Hp/A6p1sFYN1jWdmazXGB2tIjmDC/RwXWAtowEovlONdYj4giyAp1vd2VDAhfUbRDGHaRzuV1W6o3BuJDRnL/IlisRqPOhlQGfErA57j8/nmbxy5HzKvo5G8JPZ9nJqyax7xzncJXOIJvzMhHGdBHeyGd/wPzXk2ZAL8xJbgIbWdiNmbz8ZDZgLdPJkqo2FSr/eAdcoGzsbxt2KdgNwo/kurIPm0HnK0Eij1QjbkzFgTlaEcEv9RBwTVGEUSFNATshvLg7J80t/fOrRTDJTwoRoddK3I/TD5EO0Vn4UBo9i1x8xz7h3T1uMx2gn4r/V9TpGxM27Be5k5rTti77rRkCA70iPvH2b+cYNeEC6Ha6lABqvHTbmFua4IEnSwf+7EEp+8DYsSauQML+gxAbR75tab8rmkJue48vCecIwPSQ2CNNZvNbqsWfEO3fpYaETaraSfcmqX9aVctYxnMJRQpEVYZFTGKR1X0MURqlME5/gGlLv8cLpE655ao9v8ziyPl53SxhbdNnXc79ML6uazI82Qj2GuyD+kEmjAazjNQfRiudmyWmMarWWb4udSOpBfGA+0Mwxwtpq8SF8q5SogZGoSZfEursX2BLTMRh7fQ6t+vDrS2g= X-MS-TrafficTypeDiagnostic: AM4PR0101MB2210:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xm42+bjfQVfBuP8Z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message-Id: 6beda58a-c53a-4b83-c39a-08da25aced9c X-MS-Exchange-CrossTenant-AuthSource: AS8PR01MB7944.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Apr 2022 04:43:07.9298 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0101MB2210 Subject: [FFmpeg-devel] [PATCH 2/7] avcodec/pgxdec: Avoid always-false checks 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: +POv1HSvzRtm We have already checked that there is data to be read. Signed-off-by: Andreas Rheinhardt --- libavcodec/pgxdec.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libavcodec/pgxdec.c b/libavcodec/pgxdec.c index 154a683b4f..9c474036da 100644 --- a/libavcodec/pgxdec.c +++ b/libavcodec/pgxdec.c @@ -32,9 +32,9 @@ static int pgx_get_number(AVCodecContext *avctx, GetByteContext *g, int *number) *number = 0; while (1) { uint64_t temp; - if (!bytestream2_get_bytes_left(g)) + if (bytestream2_get_bytes_left(g) <= 0) return AVERROR_INVALIDDATA; - digit = bytestream2_get_byte(g); + digit = bytestream2_get_byteu(g); if (digit == ' ' || digit == 0xA || digit == 0xD) break; else if (digit < '0' || digit > '9') @@ -59,22 +59,22 @@ static int pgx_decode_header(AVCodecContext *avctx, GetByteContext *g, if (bytestream2_get_bytes_left(g) < 12) return AVERROR_INVALIDDATA; - bytestream2_skip(g, 6); + bytestream2_skipu(g, 6); // Is the component signed? - byte = bytestream2_peek_byte(g); + byte = bytestream2_peek_byteu(g); if (byte == '+') { *sign = 0; - bytestream2_skip(g, 1); + bytestream2_skipu(g, 1); } else if (byte == '-') { *sign = 1; - bytestream2_skip(g, 1); + bytestream2_skipu(g, 1); } else if (byte == 0) goto error; - byte = bytestream2_peek_byte(g); + byte = bytestream2_peek_byteu(g); if (byte == ' ') - bytestream2_skip(g, 1); + bytestream2_skipu(g, 1); else if (byte == 0) goto error; @@ -104,9 +104,9 @@ error: for (j = 0; j < width; j++) { \ unsigned val; \ if (sign) \ - val = (PIXEL)bytestream2_get_ ##suffix(g) + (1 << (depth - 1)); \ + val = (PIXEL)bytestream2_get_ ##suffix##u(g) + (1 << (depth - 1)); \ else \ - val = bytestream2_get_ ##suffix(g); \ + val = bytestream2_get_ ##suffix##u(g); \ val <<= (D - depth); \ *(line + j) = val; \ } \