summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2021-11-02 12:46:57 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2021-11-02 13:03:50 +0000
commit06008c6e81e8d62c3ebf45025448a3137b76d394 (patch)
tree686a6bd9eca03d3757257151265a391922ff3c59 /src
parent5004d8a969330c52449e6840bbef6552cfa8ee1a (diff)
pipeline: raspberrypi: Fix rounding issue in findBestFormat()
The aspect ratio calculation divides two integer values then casts to a double. This might reduce precision when scoring for aspect rato differences. Fix this by casting the integer to a double before the division. Reported-by: Coverity CID=361652 Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/pipeline/raspberrypi/raspberrypi.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index 44760093..5e1f2273 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -141,7 +141,7 @@ V4L2SubdeviceFormat findBestFormat(const SensorFormats &formatsMap, const Size &
for (const Size &size : iter.second) {
double reqAr = static_cast<double>(req.width) / req.height;
- double fmtAr = size.width / size.height;
+ double fmtAr = static_cast<double>(size.width) / size.height;
/* Score the dimensions for closeness. */
score = scoreFormat(req.width, size.width);