From patchwork Sun Feb 2 19:02:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jai Luthra X-Patchwork-Id: 17662 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id DA9CD44B481 for ; Sun, 2 Feb 2020 21:03:13 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C695A688173; Sun, 2 Feb 2020 21:03:13 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from new4-smtp.messagingengine.com (new4-smtp.messagingengine.com [66.111.4.230]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 67EB5687FE0 for ; Sun, 2 Feb 2020 21:03:06 +0200 (EET) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailnew.nyi.internal (Postfix) with ESMTP id E62876837 for ; Sun, 2 Feb 2020 14:03:04 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Sun, 02 Feb 2020 14:03:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jailuthra.in; h= from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=4IlvduUv/7az4 JyUWj7w7giA2Osw4EKy6Ctt/AGdujU=; b=GYxybbJeUUDsywewBKBF7cMzNra9F tZbKnglyFw9GMIy9ZdXud5x2PB4kLUFuQ3KU6jlwlwD0XDgChCPfmiKQi+uNy87h 3XW9eFX707TzXqTr5s5DRugAgGw6Caua8cFFSI7Q64RXzDmFbqEhg3XbQijLQPLN kLQeeaEQrPf7ex1MSTE4l7TKtjhsYjaXAFPghc6xtde33/yOrsq0n1zHnm1gxaji mqT5MpweSdCup0x7qL1u+myw1T2V4X6WYfXIp1/A6kTMLoBm3+2WKm8Ifiw75YyS +IA/XA0X8vTZoqgdn4wGi5k7jvZhvjrxWQQ2xYUHEE9i99RYi7zpwvxgQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=4IlvduUv/7az4JyUWj7w7giA2Osw4EKy6Ctt/AGdujU=; b=nWVkkmgz NHC3bEoJV+4BzaQIHDEXrYGzFApl7ijsRSLamN8wRTvoCwEqSmwDIfRgckhbqMjm afAhuQAwAmCRio8byv3PNeSAHU1vbL22Z6CJLKeMmZJZoTWVaciigZoP26mFD0+t 0gBWDFN+cfn0jmNntA8DTDGfFOBDuQy+RZjttggqlivjMtLleeto3lT1PkvESm4H gNez3tdUGMwRvTzFGlOz4evqFX+Jo+rgJwlwAiG7xGki8rxZWGZemClneVi3bsfP hG3gnTQXH3sytmt61DMZ6TSsSclzqSpdzVY7jNnhhJyYoY0sr/Ykjr47F+VfUJBy HHChT6GcXv4gBA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrgeehgdduudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheplfgrihcunfhuthhhrhgruceomhgvsehjrghilhhuthhhrhgr rdhinheqnecukfhppeegledrvddtjedrheehrddugedvnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomhepmhgvsehjrghilhhuthhhrhgrrdhinh X-ME-Proxy: Received: from localhost.localdomain (unknown [49.207.55.142]) by mail.messagingengine.com (Postfix) with ESMTPA id 9BF5D306015E for ; Sun, 2 Feb 2020 14:03:03 -0500 (EST) From: Jai Luthra To: ffmpeg-devel@ffmpeg.org Date: Mon, 3 Feb 2020 00:32:59 +0530 Message-Id: <20200202190300.156267-1-me@jailuthra.in> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124103334.110855-1-me@jailuthra.in> References: <20200124103334.110855-1-me@jailuthra.in> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/7] mlpenc: fix -fsanitize=integer errors X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" Signed-off-by: Jai Luthra --- libavcodec/mlpenc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) Thanks to Paul for the original pastebin patch diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c index 347a43248c..af04648097 100644 --- a/libavcodec/mlpenc.c +++ b/libavcodec/mlpenc.c @@ -87,11 +87,11 @@ typedef struct { } DecodingParams; typedef struct BestOffset { - int16_t offset; + int32_t offset; int bitcount; int lsb_bits; - int16_t min; - int16_t max; + int32_t min; + int32_t max; } BestOffset; #define HUFF_OFFSET_MIN (-16384) @@ -1249,7 +1249,7 @@ static void input_data_internal(MLPEncodeContext *ctx, const uint8_t *samples, uint32_t abs_sample; int32_t sample; - sample = is24 ? *samples_32++ >> 8 : *samples_16++ * 256U; + sample = is24 ? *samples_32++ >> 8 : *samples_16++ * 256; /* TODO Find out if number_sbits can be used for negative values. */ abs_sample = FFABS(sample); @@ -1792,7 +1792,7 @@ static void determine_bits(MLPEncodeContext *ctx) #define SAMPLE_MAX(bitdepth) ((1 << (bitdepth - 1)) - 1) #define SAMPLE_MIN(bitdepth) (~SAMPLE_MAX(bitdepth)) -#define MSB_MASK(bits) (-(1u << (bits))) +#define MSB_MASK(bits) (-(int)(1u << (bits))) /** Applies the filter to the current samples, and saves the residual back * into the samples buffer. If the filter is too bad and overflows the