[{"id":35764,"web_url":"https://patchwork.libcamera.org/comment/35764/","msgid":"<f63ec2ef-d61f-43d3-a039-882d481e5bdc@ideasonboard.com>","date":"2025-09-10T12:05:50","subject":"Re: [PATCH 5/5] libcamera: simple: Prevent division by zero in BLC","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n\nMaybe the title should be something like \"ipa: simple: blc: ...\"\n\n2025. 08. 21. 15:41 keltezéssel, Milan Zamazal írta:\n> When there are no values in the histogram, BLC simple IPA can crash on\n> division by zero.  We cannot get anything meaningful in such a case\n> anyway, let's simply return from `process()' then.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> ---\n>   src/ipa/simple/algorithms/blc.cpp | 5 +++++\n>   1 file changed, 5 insertions(+)\n> \n> diff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp\n> index 8c1e9ed08..71731c6f6 100644\n> --- a/src/ipa/simple/algorithms/blc.cpp\n> +++ b/src/ipa/simple/algorithms/blc.cpp\n> @@ -77,6 +77,11 @@ void BlackLevel::process(IPAContext &context,\n>   \tconstexpr float ignoredPercentage = 0.02;\n>   \tconst unsigned int total =\n>   \t\tstd::accumulate(begin(histogram), end(histogram), 0);\n> +\tif (total == 0) {\n> +\t\tLOG(IPASoftBL, Debug) << \"Not guessing black level, histogram is empty\";\n> +\t\treturn;\n> +\t};\n          ^-- no need\n\nTested-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\nReviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n\n\n> +\n>   \tconst unsigned int pixelThreshold = ignoredPercentage * total;\n>   \tconst unsigned int histogramRatio = 256 / SwIspStats::kYHistogramSize;\n>   \tconst unsigned int currentBlackIdx =","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 A0BFEBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 10 Sep 2025 12:05:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 485C86936F;\n\tWed, 10 Sep 2025 14:05:56 +0200 (CEST)","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 DF2E869357\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Sep 2025 14:05:54 +0200 (CEST)","from [192.168.33.8] (185.221.142.115.nat.pool.zt.hu\n\t[185.221.142.115])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2289ADAB;\n\tWed, 10 Sep 2025 14:04:41 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"T2EMzukV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1757505881;\n\tbh=T445zZc96Jexg268RaeT8fLnGe3CjgxOAPQCvnN2R6E=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=T2EMzukV7t2Hs1ZvhWhFgaCagc2TLEOSNugUhb2bH8Is+tL8zVWV9LL+eXfyrDOk4\n\tYLcEi5rD8xBdJIlZnpSZHTPw/BcDon8s+bLuf+5JBQ8VvyhYf821pZOAO8mwEk/XkK\n\tfjOTShvXMrRArY0h8WCucpx+JB+hfX5zSO9bYUlA=","Message-ID":"<f63ec2ef-d61f-43d3-a039-882d481e5bdc@ideasonboard.com>","Date":"Wed, 10 Sep 2025 14:05:50 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 5/5] libcamera: simple: Prevent division by zero in BLC","To":"Milan Zamazal <mzamazal@redhat.com>, libcamera-devel@lists.libcamera.org","Cc":"mail@maciej.szmigiero.name","References":"<20250821134141.83236-1-mzamazal@redhat.com>\n\t<20250821134141.83236-6-mzamazal@redhat.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20250821134141.83236-6-mzamazal@redhat.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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>"}}]