From 85541db7bbb5caba1ba0ed5fe85cf5855d024e0b Mon Sep 17 00:00:00 2001 From: David Plowman Date: Thu, 2 Mar 2023 12:57:31 +0000 Subject: 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 Reviewed-by: Kieran Bingham Reviewed-by: Naushir Patuck Signed-off-by: Kieran Bingham --- src/ipa/raspberrypi/controller/rpi/agc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ipa') 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). -- cgit v1.2.1