[{"id":20661,"web_url":"https://patchwork.libcamera.org/comment/20661/","msgid":"<CAHW6GY+8YmpTRvSYixo=Gq8jwLsbkpkDdx02_tObCOBMjg80Ow@mail.gmail.com>","date":"2021-11-02T12:49:51","subject":"Re: [libcamera-devel] [PATCH] pipeline: raspberrypi: Fix rounding\n\tissue in findBestFormat()","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Naush\n\nOops, yes we should have spotted that! Thanks!\n\nOn Tue, 2 Nov 2021 at 12:47, Naushir Patuck <naush@raspberrypi.com> wrote:\n\n> The aspect ratio calculation divides two integer values then casts to a\n> double.\n> This might reduce precision when scoring for aspect rato differences.\n>\n> Fix this by casting the integer to a double before the division.\n>\n> Reported-by: Coverity CID=361652\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n>\n\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n\nThanks\nDavid\n\n\n> ---\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 44760093f7ab..5e1f227398a9 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -141,7 +141,7 @@ V4L2SubdeviceFormat findBestFormat(const SensorFormats\n> &formatsMap, const Size &\n>\n>                 for (const Size &size : iter.second) {\n>                         double reqAr = static_cast<double>(req.width) /\n> req.height;\n> -                       double fmtAr = size.width / size.height;\n> +                       double fmtAr = static_cast<double>(size.width) /\n> size.height;\n>\n>                         /* Score the dimensions for closeness. */\n>                         score = scoreFormat(req.width, size.width);\n> --\n> 2.25.1\n>\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 8E98EBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  2 Nov 2021 12:50:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E6628600C2;\n\tTue,  2 Nov 2021 13:50:03 +0100 (CET)","from mail-wr1-x431.google.com (mail-wr1-x431.google.com\n\t[IPv6:2a00:1450:4864:20::431])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B6826600B8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Nov 2021 13:50:02 +0100 (CET)","by mail-wr1-x431.google.com with SMTP id u1so1531046wru.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 02 Nov 2021 05:50:02 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"dlzBEB9k\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=7TUksQSjXfRaZMHLoa0cjbsTTWH9tAktNGndzHCLP4E=;\n\tb=dlzBEB9kuc7fSrvH+o+GZcWYJ/mjzcgvzvLU6efbDriA20j/tenk0Ip1TtWdU0hKUc\n\tZnk1yZ+bltV3zwlzdlr5Djpi30rv8L/O2nIX/VduhjpJP+R5Qcq9u+FGKo1Q4+OW4MPJ\n\tKsQW+H+R8lAIAfnJKGOsMTVjC7PSFpgNe9yChu0a+7ahW+Rk6TS/n1l3SDqd99XTykaD\n\tAi91zEbt7s/OrKWxQfd3FjdLp+agf+f4m7mFenfHKSD9SRf3M3Ft+U29zlJ6f/+6cFsz\n\t5e0qWtZBsSpEo2zBN9jGPeqq7QQz9H1UnRyG7QEepxYWN/G/ngNYXCqYdRQ3qS8wnyE/\n\tp5cw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=7TUksQSjXfRaZMHLoa0cjbsTTWH9tAktNGndzHCLP4E=;\n\tb=JoBi7xNbslth53NcydYB2tQYN2oKMdNg13V3BJttm5mDpCIj5CAeaJkTr3XEhsjImw\n\tLqiQ3bzXUhm1njcyWnDWgSlgUU31KpVOfeuzNFgna2F/FuLYSjN+eq2/QT+wHRdJ2nTj\n\tNOpscV6qBPVZ6aSuzWynX4SpoasmsN/m5AOm9S1vTwLnB6EoWINeDZrv3logQ2+tYCAm\n\tq9hWg7B3ZAiEknLqmuYeHsUR9PqfQ7JSlMMchZv4k1ovEHRrC8kQMK5HGRGnzRRj0lxX\n\tu1AkIiAFnRN7CkPWgoUcVKxzd5cZCjAVtWdiwFNI5/TEub2XtxlYt9ci6gAPqTsjjh8E\n\txBXA==","X-Gm-Message-State":"AOAM531359eVysBAmbJYs2q1GyIGi5cGt6sxPsw8ehjwfKDvWfLCu/l3\n\tpxV0HMQ3wqHo3sF3BJ2o8lfDsVzBdTIP39inrPQ+3w==","X-Google-Smtp-Source":"ABdhPJyATfbvRd+jX5ZF2AN87B/gXdwpB8I28KCDmYKUE8d+l+odaRKq8SbcypmqdqwH4sPvthm5WoLg6pPjqr3pRf8=","X-Received":"by 2002:a5d:6d84:: with SMTP id l4mr6189925wrs.266.1635857402304;\n\tTue, 02 Nov 2021 05:50:02 -0700 (PDT)","MIME-Version":"1.0","References":"<20211102124657.1038011-1-naush@raspberrypi.com>","In-Reply-To":"<20211102124657.1038011-1-naush@raspberrypi.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Tue, 2 Nov 2021 12:49:51 +0000","Message-ID":"<CAHW6GY+8YmpTRvSYixo=Gq8jwLsbkpkDdx02_tObCOBMjg80Ow@mail.gmail.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Content-Type":"multipart/alternative; boundary=\"0000000000005e2bdd05cfcdbbad\"","Subject":"Re: [libcamera-devel] [PATCH] pipeline: raspberrypi: Fix rounding\n\tissue in findBestFormat()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":20662,"web_url":"https://patchwork.libcamera.org/comment/20662/","msgid":"<163585817023.275423.218183227277611699@Monstersaurus>","date":"2021-11-02T13:02:50","subject":"Re: [libcamera-devel] [PATCH] pipeline: raspberrypi: Fix rounding\n\tissue in findBestFormat()","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Naushir Patuck (2021-11-02 12:46:57)\n> The aspect ratio calculation divides two integer values then casts to a double.\n> This might reduce precision when scoring for aspect rato differences.\n> \n> Fix this by casting the integer to a double before the division.\n> \n> Reported-by: Coverity CID=361652\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 44760093f7ab..5e1f227398a9 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -141,7 +141,7 @@ V4L2SubdeviceFormat findBestFormat(const SensorFormats &formatsMap, const Size &\n>  \n>                 for (const Size &size : iter.second) {\n>                         double reqAr = static_cast<double>(req.width) / req.height;\n> -                       double fmtAr = size.width / size.height;\n> +                       double fmtAr = static_cast<double>(size.width) / size.height;\n>  \n>                         /* Score the dimensions for closeness. */\n>                         score = scoreFormat(req.width, size.width);\n> -- \n> 2.25.1\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id E57B4BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  2 Nov 2021 13:02:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4954860325;\n\tTue,  2 Nov 2021 14:02:54 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E3FF0600B8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Nov 2021 14:02:52 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 802FE3E5;\n\tTue,  2 Nov 2021 14:02:52 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"XQdA8aaz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1635858172;\n\tbh=oLkt2StYrbYgn/sQ0oSxL5TLZObo8xkG91hhlUCMPO4=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=XQdA8aaz3YuOG3xBSXjS5UKHYeK9OeV+SS9jZMIt7vsIOPDxMcnWxIKQ3oMK1a8/C\n\twWxgbeLuEFNjjZ9RJmsJy7qFn5RNiPwVUY0MblAg/naVDONoIyCtopWBsQtGUyEa+n\n\tWg6bifMSm5BrrAUAkpMHXA6Szq0GlEpSL37EaRzY=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20211102124657.1038011-1-naush@raspberrypi.com>","References":"<20211102124657.1038011-1-naush@raspberrypi.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Tue, 02 Nov 2021 13:02:50 +0000","Message-ID":"<163585817023.275423.218183227277611699@Monstersaurus>","User-Agent":"alot/0.9.1","Subject":"Re: [libcamera-devel] [PATCH] pipeline: raspberrypi: Fix rounding\n\tissue in findBestFormat()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]