[{"id":33380,"web_url":"https://patchwork.libcamera.org/comment/33380/","msgid":"<173979505990.1238111.12933892338289217709@ping.linuxembedded.co.uk>","date":"2025-02-17T12:24:19","subject":"Re: [PATCH 10/10] ipa: rkisp1: awb: Avoid division by zero","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-02-17 10:01:51)\n> As the gains can also be specified manually, the regulation can run\n> into numeric instabilities by dividing by near zero. Mitigate that by applying a small minium value.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\nThis sounds like a reasonable protection.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index 66e6aecedc4c..6315d2adaad9 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -310,9 +310,9 @@ void Awb::process(IPAContext &context,\n>         /*\n>          * The ISP computes the AWB means after applying the colour gains,\n>          * divide by the gains that were used to get the raw means from the\n> -        * sensor.\n> +        * sensor. Apply a minimum value to avoid divisions by near-zero.\n>          */\n> -       rgbMeans /= frameContext.awb.gains;\n> +       rgbMeans /= frameContext.awb.gains.max(0.01);\n>  \n>         /*\n>          * If the means are too small we don't have enough information to\n> -- \n> 2.43.0\n>","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 782F5BE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 17 Feb 2025 12:24:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 056776866D;\n\tMon, 17 Feb 2025 13:24:24 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D48F861865\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 17 Feb 2025 13:24:22 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8B59A886;\n\tMon, 17 Feb 2025 13:23:01 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"LwU2mwlr\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1739794981;\n\tbh=Z6u3t1qQ9nFQRZJ7y4+6F7doaklAGX0V50S7/RS1tJg=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=LwU2mwlrslB0ComlUGiIau700AP4YdY+KMiSeGPOFgGvswpoQgM1tiVBlEop1faTb\n\t5vCXL86f3a5Fo6SF7HDWkzXgN4nT/wThNJXRTgRsKEPx8mhWcGXzOr1TZ6g2ujNVEA\n\tk97ms+MBvOIKErm9bCM59NSGLBoR8HJCH93ZV688=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250217100203.297894-11-stefan.klug@ideasonboard.com>","References":"<20250217100203.297894-1-stefan.klug@ideasonboard.com>\n\t<20250217100203.297894-11-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH 10/10] ipa: rkisp1: awb: Avoid division by zero","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 17 Feb 2025 12:24:19 +0000","Message-ID":"<173979505990.1238111.12933892338289217709@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}}]