From patchwork Wed Feb 11 13:17:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 26131 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 87C86BDE6B for ; Wed, 11 Feb 2026 13:17:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2923D621AB; Wed, 11 Feb 2026 14:17:50 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="gpJ6NpyY"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8A5F7621A3 for ; Wed, 11 Feb 2026 14:17:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1770815867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WPk1K/IdOSge/OcmzVdWPq8Ni5XtNG11l5wnfhNyd8M=; b=gpJ6NpyYPRtyPGGwdnIbcVVSk9dilWs97HsBhzvdY9NDBdXVYc57NQSlFFnw8maRybQAQw WeHbUlfqqfEwcKvmKDkwE6iL9t0lVBzDC0TsOrVp+6Lfto5LhXmzAX0qUQkg5f25XC2Att ilWRQhWlYWZQLjFpcARiljRi3+Xjpsc= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-658-R7OVeE5nPtu2bWCe4fdxzQ-1; Wed, 11 Feb 2026 08:17:45 -0500 X-MC-Unique: R7OVeE5nPtu2bWCe4fdxzQ-1 X-Mimecast-MFC-AGG-ID: R7OVeE5nPtu2bWCe4fdxzQ_1770815864 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6193B195609F; Wed, 11 Feb 2026 13:17:44 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.45.226.74]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 520D019560A3; Wed, 11 Feb 2026 13:17:42 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Kieran Bingham , Bryan O'Donoghue Subject: [PATCH 1/2] ipa: simple: Limit the black level value Date: Wed, 11 Feb 2026 14:17:27 +0100 Message-ID: <20260211131728.96413-2-mzamazal@redhat.com> In-Reply-To: <20260211131728.96413-1-mzamazal@redhat.com> References: <20260211131728.96413-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 29MFmCD8UmfZsCKL-lVM5nUxiq-J8PXARyPKbG__eho_1770815864 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true 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" 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 --- 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 464e43c27..b318d0354 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,