From patchwork Tue Sep 13 15:51:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 37902 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp781307pzh; Tue, 13 Sep 2022 08:51:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR7wvatJN3JnTMG8DdfROhfRZ/lNwmJMQeekOaFyWvSbqPJIo6T5fsRRkNGsgTFaqBnqg2uH X-Received: by 2002:a05:6402:190d:b0:44e:98b9:3d7b with SMTP id e13-20020a056402190d00b0044e98b93d7bmr1543317edz.259.1663084278354; Tue, 13 Sep 2022 08:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663084278; cv=none; d=google.com; s=arc-20160816; b=IycuQnLrvd/gltc1Gi6DLDT/07OQDBxg4yfV92doAc6XUUJlNky593BSVjiX2ncwXn DOqKPKpweVi7RxuVVb8jKFy5pPPFWXMhzX7I/tKD7SN9kvtrblXIYeBdYzlN7RDXjioB yESd8tbs0LZdNlwNKRW8eVUZfDOnng0dplK638Nv3sHEyZeABwn/EeshBtWodfUKk6Uo NMuqSoWe7vDzLP0giICcI1zMvIk2yepGOuh6SvqS7lBM5PWtjxcBhMDRFGgiPGzo3ktv Kiz7PXEaO6jU1EdRN8N2+cmGvDQEJwj/DVQ+dJBRxIfr5LYRwlS0gONds+a+kol+yxms Y/+A== 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:message-id:date:to:from :delivered-to; bh=aMRizTqrkIarNOZ7kmst5CRbaEcKOcNa5Kv8uTVp/Qs=; b=clo/w8R/e1bPQn0rtjkQqQxgQ71Paq3UZrLYVmYmPUMhAUcJS49Yw+jIHWyw3de8oL C1FxMIulz0MYHlWo9iOd0usWadUrYYd4QKVEx9yQUT2QwkPR5z3ONS3JohcW+fw53TVS WH0fRoX4TtEGBKizYEM2y9BKeoHc8Xupl9UDKAc3EzTBO9hdmU0hjzXx+Zohn2qRTvNB JFIDGV1HM6scWlXAFnfPFwdpcYH+XvSqHzp47xBwydP/LTfwtWnzL554c4aqEtXYh4SZ bfdfDnqw1zczXsTo0hnL8PEJJgqiHDjpwcc8tBurICS+w1woH8+6LekocY5UWE+2Xzld BSHA== 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 dp15-20020a170906c14f00b007747fa1062asi9528388ejc.487.2022.09.13.08.51.17; Tue, 13 Sep 2022 08:51:18 -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 C107C68BAD5; Tue, 13 Sep 2022 18:51:15 +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 7232968B730 for ; Tue, 13 Sep 2022 18:51:08 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 2F0D8C0012 for ; Tue, 13 Sep 2022 18:51:08 +0300 (EEST) From: remi@remlab.net To: ffmpeg-devel@ffmpeg.org Date: Tue, 13 Sep 2022 18:51:08 +0300 Message-Id: <20220913155108.14384-1-remi@remlab.net> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCHv2] lavc: avoid rounding errors in float constants 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: KT39enKz3T35 From: RĂ©mi Denis-Courmont INT_MAX is (typically) a value with 31 significant bits but float can only represent 23 significant bits, leading to a rounding error. This substitutes the actual rounded value as an unsigned int, to avoid a clang warning while not overflowing signed int: warning: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Wimplicit-const-int-float-conversion] --- libavcodec/aaccoder.c | 2 +- libavcodec/imc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index e3b6b2f02c..4eab81c43f 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -531,7 +531,7 @@ static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, int nz = 0; bandaddr[idx] = w * 16 + g; - qmin = INT_MAX; + qmin = 1U << 31; qmax = 0.0f; for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; diff --git a/libavcodec/imc.c b/libavcodec/imc.c index 92f9980ded..afdb93636a 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -917,7 +917,7 @@ static int imc_decode_block(AVCodecContext *avctx, IMCContext *q, int ch) chctx->flcoeffs1, chctx->flcoeffs2); for(i=0; iflcoeffs1[i] > INT_MAX) { + if(chctx->flcoeffs1[i] > (1U << 31)) { av_log(avctx, AV_LOG_ERROR, "scalefactor out of range\n"); return AVERROR_INVALIDDATA; }