From patchwork Sat Jun 20 23:00:30 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 26999 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 33053C3302 for ; Sat, 20 Jun 2026 23:00:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 85747656FC; Sun, 21 Jun 2026 01:00:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Am1Qqrew"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4739A656DE for ; Sun, 21 Jun 2026 01:00:36 +0200 (CEST) Received: from [192.168.0.240] (cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 331551049; Sun, 21 Jun 2026 00:59:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1781996399; bh=yNNkQomgjsnwQWfaoyVI0qozibfNlMv3i9Yw8PwVAwo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Am1QqrewIMMacxkxAr8NdE5WVMizI4yJGTmk+WRcS4Lem/NHxKX6FEoygdlLIMJNs w+Zh5EmgsZjVYhjGTIVn4J9dUDrAWSLHsuIFroF6Q82Hp0ES9THj+sFY3EwltGK2C3 jd2YL66+474gRCkvBq3K+e2Do3H14GXqq2BTyBaw= From: Kieran Bingham Date: Sun, 21 Jun 2026 00:00:30 +0100 Subject: [PATCH 3/7] ipa: simple: Limit the black level value MIME-Version: 1.0 Message-Id: <20260621-kbingham-awb-saturation-v1-3-b91ea59c6cfb@ideasonboard.com> References: <20260621-kbingham-awb-saturation-v1-0-b91ea59c6cfb@ideasonboard.com> In-Reply-To: <20260621-kbingham-awb-saturation-v1-0-b91ea59c6cfb@ideasonboard.com> To: libcamera-devel@lists.libcamera.org Cc: Kieran Bingham , Milan Zamazal , Bryan O'Donoghue X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1781996434; l=1658; i=kieran.bingham@ideasonboard.com; s=20260204; h=from:subject:message-id; bh=gmewv5noS55Y81VtEu3iVbH9ai00n6FV99WE4gKDKjQ=; b=8AAomWBRkQt327OI902Jv9DJ2Twfrw3PuKn3EOqSZ9e2/BuUdVD7DX6a9LRRW7cG9ehJbLbS1 jNTFuALfVPAAKvD5jYzSydU77GamHHgqJezRbg2BsZjJWC8d91x/ojx X-Developer-Key: i=kieran.bingham@ideasonboard.com; a=ed25519; pk=IOxS2C6nWHNjLfkDR71Iesk904i6wJDfEERqV7hDBdY= X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Milan Zamazal The black level value is passed to image processing, where it's used in pixel value computations. To avoid troubles with weird black level values (which are mostly theoretical but we should be still safe against e.g. crazy values in testing tuning files) like division by zero, let's make sure the black level passed to the image processing is lower than the maximum pixel value. Signed-off-by: Milan Zamazal Reviewed-by: Bryan O'Donoghue Signed-off-by: Kieran Bingham --- src/ipa/simple/algorithms/blc.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp index 677be56ed6699ae8aaa8a786ab16f7299a82eb46..058cb372620134cb15a0655d3553b3b767b47f0e 100644 --- a/src/ipa/simple/algorithms/blc.cpp +++ b/src/ipa/simple/algorithms/blc.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* - * Copyright (C) 2024-2025, Red Hat Inc. + * Copyright (C) 2024-2026, Red Hat Inc. * * Black level handling */ @@ -52,8 +52,9 @@ void BlackLevel::prepare(IPAContext &context, [[maybe_unused]] IPAFrameContext &frameContext, DebayerParams *params) { - /* Latch the blacklevel gain so GPUISP can apply. */ - params->blackLevel = RGB(context.activeState.blc.level / 255.0f); + /* Make sure the black level is sane, i.e. below maximum pixel value. */ + params->blackLevel = RGB(context.activeState.blc.level / 255.0f) + .min(0.99); } void BlackLevel::process(IPAContext &context,