From patchwork Thu Jan 8 16:05:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 25699 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 B8D28BE08B for ; Thu, 8 Jan 2026 16:06:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 82AD661FC7; Thu, 8 Jan 2026 17:06:53 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="K3UFe7u6"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 63F8061FBF for ; Thu, 8 Jan 2026 17:06:52 +0100 (CET) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:90af:8957:b721:10d4]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id EACB51AEE; Thu, 8 Jan 2026 17:06:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1767888390; bh=Wa1kb4jis2WTXYoMAut+ajSXm5wP3og7A8V9teDjUgg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=K3UFe7u6CRZlqSxOQRjGpoZABGD6eMghsqFI+VeUAMIuBVNkjsL8Q4fmGQFSRjZRl TqZXFtSlIGpYUXLHw1kNgEIfKdi6ROJFuLr+i3CsXSFDKQmvh0veARzoRzYrZBp2JM qYwELoJU7XAEz83kFAycxdMpVRMcyWMXl2ubiM/w= From: Stefan Klug Date: Thu, 08 Jan 2026 17:05:52 +0100 Subject: [PATCH v2 09/15] ipa: rkisp1: lsc: Handle quantization locally MIME-Version: 1.0 Message-Id: <20260108-sklug-lsc-resampling-v2-dev-v2-9-e682ec4b9893@ideasonboard.com> References: <20260108-sklug-lsc-resampling-v2-dev-v2-0-e682ec4b9893@ideasonboard.com> In-Reply-To: <20260108-sklug-lsc-resampling-v2-dev-v2-0-e682ec4b9893@ideasonboard.com> To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug X-Mailer: b4 0.14.2 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 quantization functionality in the Interpolator hinders in writing nice code. Don't use it and implement the functionality directly in the algorithm. This patch doesn't introduce any functional changes. Signed-off-by: Stefan Klug Reviewed-by: Kieran Bingham --- Changes in v2: - Added this patch --- src/ipa/rkisp1/algorithms/lsc.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp index c42f74557c7364935254d75ee1fb923d176e0dbd..d5e44021906bda22f16a2c0f2a344e4c40d46774 100644 --- a/src/ipa/rkisp1/algorithms/lsc.cpp +++ b/src/ipa/rkisp1/algorithms/lsc.cpp @@ -308,12 +308,16 @@ std::vector parseSizes(const YamlObject &tuningData, return sizes; } +static unsigned int quantize(unsigned int value, unsigned int step) +{ + return std::lround(value / static_cast(step)) * step; +} + } /* namespace */ LensShadingCorrection::LensShadingCorrection() : lastAppliedCt_(0), lastAppliedQuantizedCt_(0) { - sets_.setQuantization(kColourTemperatureChangeThreshhold); } /** @@ -426,17 +430,20 @@ void LensShadingCorrection::prepare([[maybe_unused]] IPAContext &context, RkISP1Params *params) { uint32_t ct = frameContext.awb.temperatureK; - if (std::abs(static_cast(ct) - static_cast(lastAppliedCt_)) < - kColourTemperatureChangeThreshhold) + unsigned int quantizedCt = quantize(ct, kColourTemperatureChangeThreshhold); + int ctDiff = static_cast(ct) - static_cast(lastAppliedCt_); + + if (quantizedCt == lastAppliedQuantizedCt_) return; - unsigned int quantizedCt; - const Components &set = sets_.getInterpolated(ct, &quantizedCt); - if (lastAppliedQuantizedCt_ == quantizedCt) + + if (std::abs(ctDiff) < kColourTemperatureChangeThreshhold) return; auto config = params->block(); config.setEnabled(true); setParameters(*config); + + const Components &set = sets_.getInterpolated(quantizedCt); copyTable(*config, set); lastAppliedCt_ = ct;