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 ESMTP id 8943944431 for ; Fri, 11 Nov 2022 18:15:56 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C64F268B192; Fri, 11 Nov 2022 20:15:52 +0200 (EET) Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5718968A55A for ; Fri, 11 Nov 2022 20:15:46 +0200 (EET) Received: by mail-ot1-f49.google.com with SMTP id w26-20020a056830061a00b0066c320f5b49so3231925oti.5 for ; Fri, 11 Nov 2022 10:15:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=HdK3p50+Z9JYEX+4n2wHtu3Y2S18ajlatJyVSbN+NcE=; b=n0iOxGHKuPznfm9VBN6bivQIZ002QpXQzVI5aNtseCmkJ1A7Sziwa+L1nUYDtSBjBy /I9CJg3c1YhNX/eSD7TxcTEK9G87FFY8abJ2IuVGL6ZfWUCbZM5JxRJGoQdZ9+Y6dQMs B/TzlIMsbC4QLUQxLnw2vxcFJ+IPuz0lcGdo6EOfMmNr/yXY0YEOg7o1lDZtU4EAYPcR CF0KdgqkB0GfhJDkeQmkwCT97KpxnkUsux943Q8pLHCOZzeJauE5qd9FfDMf0qZgkuQK 5CNL27XAQEf3ZDHDh9Xy94JRUgHC0HkxKiX4OANxUhVcPbqXSw9rG7Q6HkxPvy7aOSMZ fhRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HdK3p50+Z9JYEX+4n2wHtu3Y2S18ajlatJyVSbN+NcE=; b=RnN9qWozRUvBytwL9Q9VW/o+/URFLfrx1TkjbPpCdGlsIBUhITTl2sjdFSXxHHqK4g hvKSVCHCuUeN0mZVKWppb6bVxebkeB5LZuQeXff9nm01hFD9mGemvXi0Z+enf01RgeS+ IAi356cZiIN139MtG+3/nIvkHLylMOjzyWjMUvjulmYNzXB9O/0ntt7qw1pOdoiHuJxX YAHr1P4nCzUkiPUiTAeBUNE9ZBLsbSySuLeXKjJd1u4MRyX+qrTupWznGMbTWaYXKRAg JT+NfZv5k6u+Oz7tboPJK62Nx8nrgrtJ/J4lRYXto+Vow0ZlsN2BLpjnq0DDHRY8wrQR ss2w== X-Gm-Message-State: ANoB5pnCwHd3ngbLouLcyw/usKak8JWjC1yA6JvONE/+gL73fzrWkwEi 19w0bivQW1Xdi5Y9EpEdgSxCyIlp7Sc= X-Google-Smtp-Source: AA0mqf6qpyfbqDFGXPEwK4URrxwjhx9UqWSAlWpUSjeAedPRuHB7J2HzUGb9cGAl27YEtL36MlMCJw== X-Received: by 2002:a9d:480f:0:b0:66c:6cf1:7967 with SMTP id c15-20020a9d480f000000b0066c6cf17967mr1864766otf.139.1668190544417; Fri, 11 Nov 2022 10:15:44 -0800 (PST) Received: from [192.168.0.15] ([181.85.72.69]) by smtp.gmail.com with ESMTPSA id n3-20020a0568080a0300b00354978180d8sm1096325oij.22.2022.11.11.10.15.43 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Nov 2022 10:15:43 -0800 (PST) Message-ID: <09257d5c-0ffe-9336-a143-e9a9c83356a4@gmail.com> Date: Fri, 11 Nov 2022 15:15:56 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 To: ffmpeg-devel@ffmpeg.org References: <20221109223132.1795504-1-tfoucu@gmail.com> Content-Language: en-US From: James Almer In-Reply-To: <20221109223132.1795504-1-tfoucu@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH] motion_est: fixed signed_integer_overflow when computing score 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 11/9/2022 7:31 PM, Thierry Foucu wrote: > --- > libavcodec/motion_est.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c > index d17ffe42b4..95978d95dd 100644 > --- a/libavcodec/motion_est.c > +++ b/libavcodec/motion_est.c > @@ -1571,7 +1571,7 @@ void ff_estimate_b_frame_motion(MpegEncContext * s, > type= CANDIDATE_MB_TYPE_BACKWARD_I; > } > > - score= ((unsigned)(score*score + 128*256))>>16; > + score= ((uint64_t)(score)*(uint64_t)(score) + 128*256)>>16; Is it not enough just doing score= ((unsigned)score*score + 128*256)>>16; If not, then use uint64_t, but like the above, you should only need to cast score once. > c->mc_mb_var_sum_temp += score; > s->mc_mb_var[mb_y*s->mb_stride + mb_x] = score; //FIXME use SSE > } _______________________________________________ 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".