summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/controller/rpi
diff options
context:
space:
mode:
authorDavid Plowman <david.plowman@raspberrypi.com>2023-03-02 12:57:31 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2023-03-07 21:55:05 +0000
commit85541db7bbb5caba1ba0ed5fe85cf5855d024e0b (patch)
tree904c5d667df2a28282490d26c1d073bf6ad73fa9 /src/ipa/raspberrypi/controller/rpi
parent2a261d911f50d925be7b8921c1af58cde8a7f545 (diff)
ipa: raspberrypi: agc: Fix overflow in Y value calculation
The maxVal variable in the computeInitialY function needs to be a uint64_t, otherwise the subsequent multiplications in the function can overflow on relatively high resolution images (when the counts in the regions go over 16 bits). Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/ipa/raspberrypi/controller/rpi')
-rw-r--r--src/ipa/raspberrypi/controller/rpi/agc.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp
index ea0c82b5..4ea0dd41 100644
--- a/src/ipa/raspberrypi/controller/rpi/agc.cpp
+++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp
@@ -584,7 +584,7 @@ void Agc::fetchAwbStatus(Metadata *imageMetadata)
static double computeInitialY(StatisticsPtr &stats, AwbStatus const &awb,
double weights[], double gain)
{
- constexpr unsigned int maxVal = 1 << Statistics::NormalisationFactorPow2;
+ constexpr uint64_t maxVal = 1 << Statistics::NormalisationFactorPow2;
/*
* Note how the calculation below means that equal weights give you
* "average" metering (i.e. all pixels equally important).