From patchwork Wed Jul 8 15:51:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 27328 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 8D930C331D for ; Wed, 8 Jul 2026 15:51:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E920166119; Wed, 8 Jul 2026 17:51:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FZYcuV6B"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 71583660BC for ; Wed, 8 Jul 2026 17:51:18 +0200 (CEST) Received: from [192.168.1.182] (93-46-82-201.ip106.fastwebnet.it [93.46.82.201]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 931FC3FB9; Wed, 8 Jul 2026 17:50:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1783525828; bh=pxt5DHoOyWUjji1QJzKfDgjBXNlzEGrF4ewNXFDC9v4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=FZYcuV6BTdesC+wQWxFwslmFId7pMPNe4j3uv9VSmrhq4007ry9mx5AKDmNj5V8PM J0bOvxvig2OkKRcUJ7Nyzigv9/Qq59/fc+kuIZf8lDFuf7ORPPfmPqQsZx+2IxVB4h m2+hSxR1sZCXdADD5MclMLwjV1uJ6EF7t2cHZiLk= From: Jacopo Mondi Date: Wed, 08 Jul 2026 17:51:02 +0200 Subject: [PATCH v5 20/36] ipa: rksip1: lsc: Make parseSizes() a class function MIME-Version: 1.0 Message-Id: <20260708-libipa-algorithms-v5-20-0759d0359f52@ideasonboard.com> References: <20260708-libipa-algorithms-v5-0-0759d0359f52@ideasonboard.com> In-Reply-To: <20260708-libipa-algorithms-v5-0-0759d0359f52@ideasonboard.com> To: libcamera-devel@lists.libcamera.org, Stefan Klug Cc: Jacopo Mondi , Kieran Bingham X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3547; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=pxt5DHoOyWUjji1QJzKfDgjBXNlzEGrF4ewNXFDC9v4=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBqTnHo7ErOyP0ef+58CuJFn7xZxom9baUDpV+8D azvfNxZ0z6JAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCak5x6AAKCRByNAaPFqFW PGSTD/9RAcCaEnpMxNEl8CAOS0uGmFWjeqVsUQuvJ1P49Jcmi6t8k3HJ0fe/cJGBvwnBCmS5g2V JDBWJE8DPrTVOteqTT78ZnnIEMiNN1QV8q93jWb91+ViQJLQxiQgSsFVsMEHXv1u/43S4AXwa9K iWESj7Xj/JjTVJp5JVu1MFW7tXSe57zJBFTE3qUjM8/U5cVc1m8Jv3E6olVeGWZN3lY+lJ6r7YC 5RCTlu7CN8iwKZLp7EX0E2Sm6znvo9rPLqtF0jTNLFpsVWZE/l/VJibv6At2PUybwpW9DYeaV6j a5j9xpOJWDOX0mk9cQm4wM8O75b2I0KFSE63qdgDLyJuAMvmYmqqMw8oV6v/cA7rSRzLFfH9iIz EprLQMmt1yc8K6evItV+K4jMY6xv97+bARsJ2kMVsIfopJQzwk7cXoSyrQFEp++nrRhs5NR3zrt PKsxmxoOTpTWhUJrLAM+Ne9H2MyduDpv7GsYjTiNv4hTA83hlIDYxvzo4EraSnzPdkC+O/00RjW YHtZnEQivYestQS4wcN/L1PY3rtGvnJqvaRjAQUjn1NlrC/orRdteVD3Ur1tXE+zZEpsVADcQ/L 8xrCsMyiiWZx5gFRblhpIs3mA1Sp+57WSTNmdyx9IKQuZsJVwvAmRQIy/K4zrbAxs1/a08Fyz7c 68gpyz5Ael0adqQ== 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 Reviewed-by: Kieran Bingham --- 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 f32c46084dd1..e03bf361c4b9 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_;