From patchwork Mon Sep 29 13:13:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 24487 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 229DFC328C for ; Mon, 29 Sep 2025 13:14:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DF0496B5F3; Mon, 29 Sep 2025 15:14:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="Hwf1/LjD"; dkim-atps=neutral Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A0CFC6B599 for ; Mon, 29 Sep 2025 15:13:59 +0200 (CEST) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id A9A146220A for ; Mon, 29 Sep 2025 13:13:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B666C4CEF4; Mon, 29 Sep 2025 13:13:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759151638; bh=T5nt2Y3bCWrMnpkOPcFkdrdM2njfw/CGpuAGXcpoxYs=; h=From:To:Cc:Subject:Date:From; b=Hwf1/LjDzDNC/6qofd1vdPhwSTceueOudy7z86/pDCAynFzq/oB92WhRfVgcvgaHE BUwTFj25xbzN/f3RNyJRxa5kYwLo30cgl1up7TiW45v1HkPJUk1VsdmgCEXbcUm+IH kRcGHqlI7tLoHW9uq1wWUVIUWS2XjXsektTF+4wF/+4b9QvzrsaCe7vnMm+ngv3yjz oE/emSPVlx/OgGyMrQomZ1nD8qXzdzRZOX9GzKnL1+F8f2pnUIjaF8KDx88awaaBiT P13DAQnWp6o1VXwxv8ky+zzNQXwcGU1pvdUVc7BPTLCf3IHQ2wdpo7jzjehzt+J8I0 oGCaYPQYOE1sQ== From: Hans de Goede To: libcamera-devel@lists.libcamera.org Cc: Hans de Goede Subject: [PATCH] ipa: simple: blc: Use 16 as starting blacklevel when there is no sensor-info Date: Mon, 29 Sep 2025 15:13:55 +0200 Message-ID: <20250929131355.25897-1-hansg@kernel.org> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 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" At the moment the blc code uses 255 as starting blacklevel for sensors where there is no blacklevel info in the sensor-helper. There are a number of issues with this: 1. When the first frame is bad (e.g. mostly white) which happens sometimes the initial blacklevel will be kept leading to a divide by zero problem in the AGC code (this divide by 0 problem is avoided in the AGC code by not running the AGC algorithm). 2. Not runnning the AGC algorithm means that the gain/exposure do not change, which causes the BLC algorithm to not run on the next frames, so we keep the bad 255 blacklevel which stops AGC from running which stops BLC from running. Leaving things stuck at a 255 blacklevel resulting in an unusuable image. 3. Sometimes the auto-blc code leads to an unrealistic high blacklevel detection which results in lower image quality. To fix this start with a blacklevel of 16, which is the highest (4096 / 256) blacklevel used for any sensor listing a blackLevel_ value in the sensor-helper class. Note 2. could alternatively be fixed by disabling the check for exposure/gain changes when the blacklevel is unrealistic high, but that still leaves the other problems. Signed-off-by: Hans de Goede Reviewed-by: Milan Zamazal --- src/ipa/simple/algorithms/blc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp index ec71e154e..370385afc 100644 --- a/src/ipa/simple/algorithms/blc.cpp +++ b/src/ipa/simple/algorithms/blc.cpp @@ -43,7 +43,7 @@ int BlackLevel::configure(IPAContext &context, if (definedLevel_.has_value()) context.configuration.black.level = definedLevel_; context.activeState.blc.level = - context.configuration.black.level.value_or(255); + context.configuration.black.level.value_or(16); return 0; }