{"id":14449,"url":"https://patchwork.libcamera.org/api/1.1/patches/14449/?format=json","web_url":"https://patchwork.libcamera.org/patch/14449/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20211102124657.1038011-1-naush@raspberrypi.com>","date":"2021-11-02T12:46:57","name":"[libcamera-devel] pipeline: raspberrypi: Fix rounding issue in findBestFormat()","commit_ref":"06008c6e81e8d62c3ebf45025448a3137b76d394","pull_url":null,"state":"accepted","archived":false,"hash":"8ebe19d17051d74678fcab1f06528a4c6d837dc5","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14449/mbox/","series":[{"id":2686,"url":"https://patchwork.libcamera.org/api/1.1/series/2686/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2686","date":"2021-11-02T12:46:57","name":"[libcamera-devel] pipeline: raspberrypi: Fix rounding issue in findBestFormat()","version":1,"mbox":"https://patchwork.libcamera.org/series/2686/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14449/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14449/checks/","tags":{},"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 1F1F5BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  2 Nov 2021 12:47:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4C92660325;\n\tTue,  2 Nov 2021 13:47:34 +0100 (CET)","from mail-wm1-x331.google.com (mail-wm1-x331.google.com\n\t[IPv6:2a00:1450:4864:20::331])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5A009600B8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Nov 2021 13:47:33 +0100 (CET)","by mail-wm1-x331.google.com with SMTP id\n\tc71-20020a1c9a4a000000b0032cdcc8cbafso1992030wme.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 02 Nov 2021 05:47:33 -0700 (PDT)","from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:34fe:b3d0:b6e2:78dc])\n\tby smtp.gmail.com with ESMTPSA id\n\tu10sm21495242wrs.5.2021.11.02.05.47.31\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 02 Nov 2021 05:47:31 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"ea0lcWrz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=SYUO1PYnmOPjZcfZJWZ0/h35oIBSqp+gSAIzj1MqJjE=;\n\tb=ea0lcWrzYwCi74w5e+oYCZQUl4iRJv3CGeioSFeGwc5ICuM92KHUB4jEIRv8geVYiZ\n\tNEF2hUH59sSLnQpfJyser5x5tABtpUBXFyikRQ7u2wNydyJ2VgSuT7xzBvWvtJyDuVEX\n\tmydYbqfwDBzKWNOwdWQytQvEhuupL6gJ+FUH78gcNYzsMO9fkbirkW1cgxEUT6jHF9VZ\n\tcYwa7RGpI/lhtQMgG/a2EqCIfOpogWPomVmwcIhlMJOCKFPZpI+Idu4d3n285td20UAe\n\tV0bCiJsgz1NNRGTPvx7ZLEi1AV3CI3O+3gE2u/X6RZUqFR8XU337Jpypx0DkShEJx7OX\n\t6urw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=SYUO1PYnmOPjZcfZJWZ0/h35oIBSqp+gSAIzj1MqJjE=;\n\tb=gWYYDaFox+6CQraOoEVkt8hOfdIdtCBTGe1MwUxlVrMJNr9XS8EW0krOaVqEW38yNR\n\t4XDxXyJejlvSBPld5/ZwNB4QpiqBCke+ASAicw+5FP/dMf9UiQWTB83GHuo9vM4131bM\n\tEECBGRI+RHSYzEcDkKOdrS3moR6QaqST7+B+lqa+czjUkXdE7y4pa0QeW+e9Uy3eG/yN\n\t6Pm8IZPxRcXsGAJFHJ93FDOfm1l+3SUuz+RBBqFAoJoNmdm7SEUn+1CbznTewGOyDRLR\n\tiOMz4apN6ortwhzPhIKnS2rNE8mrAs5GWuCb0hQ6IOYmsTozb8GSq+ehjGhbTg1d2+V+\n\t9Srw==","X-Gm-Message-State":"AOAM5335SuDPtSdcZFqaxadzrp7LXuhlWWQKAJqD8TuDljf8DlwBU5Yz\n\t2Z7z9fheP3aVcl3RCHq5xBvpFb3EF4Q+tpVR","X-Google-Smtp-Source":"ABdhPJynn+snuhJE+nyrwi6Oz+9Nb57bN3Z13W6DvzsVNaIbvp1oNTpqay5e7nr/Wti1EYWw6BLz9A==","X-Received":"by 2002:a05:600c:1d0e:: with SMTP id\n\tl14mr6656522wms.64.1635857252562; \n\tTue, 02 Nov 2021 05:47:32 -0700 (PDT)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue,  2 Nov 2021 12:46:57 +0000","Message-Id":"<20211102124657.1038011-1-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] pipeline: raspberrypi: Fix rounding issue\n\tin 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>"},"content":"The aspect ratio calculation divides two integer values then casts to a double.\nThis might reduce precision when scoring for aspect rato differences.\n\nFix this by casting the integer to a double before the division.\n\nReported-by: Coverity CID=361652\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 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 \t\tfor (const Size &size : iter.second) {\n \t\t\tdouble reqAr = static_cast<double>(req.width) / req.height;\n-\t\t\tdouble fmtAr = size.width / size.height;\n+\t\t\tdouble fmtAr = static_cast<double>(size.width) / size.height;\n \n \t\t\t/* Score the dimensions for closeness. */\n \t\t\tscore = scoreFormat(req.width, size.width);\n","prefixes":["libcamera-devel"]}