From patchwork Mon Jul 6 08:01:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 27219 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 10B9DC330F for ; Mon, 6 Jul 2026 08:02:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C410C66046; Mon, 6 Jul 2026 10:02:25 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="KcbHoquo"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DE94F6600D for ; Mon, 6 Jul 2026 10:02:09 +0200 (CEST) Received: from [192.168.125.177] (mob-109-113-60-81.net.vodafone.it [109.113.60.81]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8F1F53FB7; Mon, 6 Jul 2026 10:01:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1783324881; bh=8GlTgDyPd4f0znliQ0xwhTjrc5pCxzBor2pnK/OPgzY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=KcbHoquoeGq2yEUVlcbqxBWA/FutsjHiFCxXwwOTxJ24cL/BXNJe2Iudcswzu/brU FhdBLMZPNU2rpkGD+5a9mpYMj063gBjEW+vhei40k4T9Sr7W4Kh9aV6n081x/XKZHq TQpij4UnMjel/0xmEVsySVViZO0ROTRjw8V2U9uo= From: Jacopo Mondi Date: Mon, 06 Jul 2026 10:01:39 +0200 Subject: [PATCH v3 19/35] ipa: rksip1: lsc: Make parseSizes() a class function MIME-Version: 1.0 Message-Id: <20260706-libipa-algorithms-v3-19-968757b038bb@ideasonboard.com> References: <20260706-libipa-algorithms-v3-0-968757b038bb@ideasonboard.com> In-Reply-To: <20260706-libipa-algorithms-v3-0-968757b038bb@ideasonboard.com> To: libcamera-devel@lists.libcamera.org, Stefan Klug Cc: Jacopo Mondi X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3484; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=8GlTgDyPd4f0znliQ0xwhTjrc5pCxzBor2pnK/OPgzY=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBqS2DxUR/+gGv6EvV5PtMpO9Ku6pOvk0a5tDprd WWui36wMFqJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaktg8QAKCRByNAaPFqFW PCnkEADCFrSNiVuCrWEyLGdzHdnkyPgvArRyyEw67VGz8tPFxnQIWVklI+R7QOsMR+rlMi9cJY5 popIlO8Vgf/EBsojLwFcDl39tM+MHj3lBjL7tSVQLrKw08g/hgDaFtfvdS6NcdZvv23rRgDlnq9 e7eRqp1Hv2fa5S/yCPsGnfjaxHnjz90dOKs6h7gDRyJAEMXXY7BRPXqtqy/j0TeALXW6FsqQmHh uACLrqBfI5IcTxjRUk9Qjm9te8BWCyACBRHP8Kne4yOESACTb2YW8wQuqQdaK1Pydea89IgRfbD uFJBJeTWICCo1w+O2Nc5D9oJZREqHwVeu+mTIJcGRQ4LbA+FpN6QtMEI4p5IXvn4btejSPx0sju EIm+26EDMWzSEW3Qt/wwDaE4Tn9QQNFWvfUJO4VhhwLp9c9fkMUuZmlgijaClZfZR7DB114MqSk YjVS5giEo0cCc8DJuTyNZnyxxaUUarNNWzRiOMsHYNt7SRyc8Ga9v2DiX7Uv0OU/M8rKPY7uFeC 5Klf7fHs4NabdOuW7mShKK84Ivb8bh6kRLcYwM/DbYn8VgIQbtKjS6JCOpdOVLmSvF9ymGXnWH1 hwyE7PtQRgLoknRyNKXlnmE4gsKbX9sYUjkF9v6Dz7S0tbjG1ryM3bfmVhXFXfkgg+gXB4K/y4y ceMskWh77X1Ohng== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B 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" There are no reasons to have it as a static helper. Signed-off-by: Jacopo Mondi --- src/ipa/rkisp1/algorithms/lsc.cpp | 60 +++++++++++++++++++-------------------- src/ipa/rkisp1/algorithms/lsc.h | 2 ++ 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp index 974534175e06..0312ce2f8bb1 100644 --- a/src/ipa/rkisp1/algorithms/lsc.cpp +++ b/src/ipa/rkisp1/algorithms/lsc.cpp @@ -34,36 +34,6 @@ namespace { constexpr int kColourTemperatureQuantization = 10; -std::vector parseSizes(const ValueNode &tuningData, - const char *prop) -{ - std::vector sizes = - tuningData[prop].get>().value_or(utils::defopt); - if (sizes.size() != RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE) { - LOG(RkISP1Lsc, Error) - << "Invalid '" << prop << "' values: expected " - << RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE - << " elements, got " << sizes.size(); - return {}; - } - - /* - * The sum of all elements must be 0.5 to satisfy hardware constraints. - * Validate it here, allowing a 1% tolerance as rounding errors may - * prevent an exact match (further adjustments will be performed in - * LensShadingCorrection::prepare()). - */ - double sum = std::accumulate(sizes.begin(), sizes.end(), 0.0); - if (sum < 0.495 || sum > 0.505) { - LOG(RkISP1Lsc, Error) - << "Invalid '" << prop << "' values: sum of the elements" - << " should be 0.5, got " << sum; - return {}; - } - - return sizes; -} - unsigned int quantize(unsigned int value, unsigned int step) { return std::lround(value / static_cast(step)) * step; @@ -138,6 +108,36 @@ int LensShadingCorrection::init([[maybe_unused]] IPAContext &context, return 0; } +std::vector LensShadingCorrection::parseSizes(const ValueNode &tuningData, + const char *prop) +{ + std::vector sizes = + tuningData[prop].get>().value_or(utils::defopt); + if (sizes.size() != RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE) { + LOG(RkISP1Lsc, Error) + << "Invalid '" << prop << "' values: expected " + << RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE + << " elements, got " << sizes.size(); + return {}; + } + + /* + * The sum of all elements must be 0.5 to satisfy hardware constraints. + * Validate it here, allowing a 1% tolerance as rounding errors may + * prevent an exact match (further adjustments will be performed in + * LensShadingCorrection::prepare()). + */ + double sum = std::accumulate(sizes.begin(), sizes.end(), 0.0); + if (sum < 0.495 || sum > 0.505) { + LOG(RkISP1Lsc, Error) + << "Invalid '" << prop << "' values: sum of the elements" + << " should be 0.5, got " << sum; + return {}; + } + + return sizes; +} + /** * \copydoc libcamera::ipa::Algorithm::configure */ diff --git a/src/ipa/rkisp1/algorithms/lsc.h b/src/ipa/rkisp1/algorithms/lsc.h index 2a428293cb2e..ee037353bbe4 100644 --- a/src/ipa/rkisp1/algorithms/lsc.h +++ b/src/ipa/rkisp1/algorithms/lsc.h @@ -39,6 +39,8 @@ public: private: void setParameters(rkisp1_cif_isp_lsc_config &config); void copyTable(rkisp1_cif_isp_lsc_config &config, const lsc::Components &set0); + std::vector parseSizes(const ValueNode &tuningData, + const char *prop); std::vector xSize_; std::vector ySize_;