[libcamera-devel] [PATCH] ipa: raspberrypi: agc: Fix overflow in Y value calculation
Naushir Patuck
naush at raspberrypi.com
Thu Mar 2 14:56:58 CET 2023
Hi David,
Thanks for fixing this.
On Thu, 2 Mar 2023 at 12:57, David Plowman via libcamera-devel <
libcamera-devel at lists.libcamera.org> wrote:
> 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 at raspberrypi.com>
>
Reviewed-by: Naushir Patuck <naush at raspberrypi.com>
PS: patchwork does seem to have correctly recognised Kieran's tag (
https://patchwork.libcamera.org/patch/18330/)
> ---
> src/ipa/raspberrypi/controller/rpi/agc.cpp | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> 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).
> --
> 2.30.2
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20230302/c4f21724/attachment.htm>
More information about the libcamera-devel
mailing list