From patchwork Wed Jul 8 09:25:06 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 27284 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 51FA2C3333 for ; Wed, 8 Jul 2026 09:25:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4E48366098; Wed, 8 Jul 2026 11:25:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Ee1BF5ww"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 19C4B66081 for ; Wed, 8 Jul 2026 11:25:11 +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 6C6163FB2; Wed, 8 Jul 2026 11:24:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1783502661; bh=pxt5DHoOyWUjji1QJzKfDgjBXNlzEGrF4ewNXFDC9v4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Ee1BF5wwIHsDSYx7DknK/GuOaLXz6WSe4ZadLYtmJTaRavcD96zsE907W6qIyz2bV SveEzplIIOBqQE9cfLvboQ9A8IB1BtANzu4/v+u/bdmiQAo9qf3NxHLmqVp7tQHNYJ c+g2OQZASsPoNMIqvygJK+y5ZMFsFdPnQSwIk3cg= From: Jacopo Mondi Date: Wed, 08 Jul 2026 11:25:06 +0200 Subject: [PATCH v4 19/35] ipa: rksip1: lsc: Make parseSizes() a class function MIME-Version: 1.0 Message-Id: <20260708-libipa-algorithms-v4-19-f0e99f035294@ideasonboard.com> References: <20260708-libipa-algorithms-v4-0-f0e99f035294@ideasonboard.com> In-Reply-To: <20260708-libipa-algorithms-v4-0-f0e99f035294@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/ZANAwAKAXI0Bo8WoVY8AcsmYgBqThduUjtdsaA+F11YAnEw1FcaUgCSjoxja8ZEs 5TNvl6w0fiJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCak4XbgAKCRByNAaPFqFW PIj9D/948/X3yjENqLFvkOTExxhET4pDm8LX2WkFr4aqZJAbsWWHBW7k9vgi9DT/btqt3Kud60l tzbFkBAhb78aq8TwuSgZ/4ycxlK3QGzsdw32JiD4/o2mJeG+oqMVb+AyjC/0VaSHQHm8l/CjcT7 TrsPRXVWQ3wBRxyLCZ2cPBi3tnVxWjbZMNf5Rpznkp6Js3Bf/uz5v2xHZ+2JUEjA1Tk3zMftNnq KBc5TsgpCwlHM1oXOzZGqAEorJzeC8RQGPCcFm9pg96W1Evp8naxIrbq3fyDvbFuKt8g0Fmmei6 xWOwmzJ7QVmHSJ+q+DEDpga378a3NOC8d5b6/ZcR/yDK7trf2OFhG0EDKD4eJRoSBhNPTOuW9Wg aP8Vt2T0Mupc4FcxERCzodZo8/WTgu6kuARBz6e4NzIOOF5pMXaecytq1JxP7EkOH/K9kHkYzOB L2Q2uw/0kJWTCqnLKr0XlZcePqh2idfnZXYTtsm1AEieRv5DZJbtyydPUTX4/ucc18Y7bsgSNnN 4gpdWCmeof7qRGLzdt3h62Ljmp9A3HzUSefHvD+fiPE0bwQVnzT+mLRgTsB9fvt44uUKPa7yBcA ZSNt0IIH9hZyoizuxCLucGjdj7nIYPtbtMFv1wWM8LT6fM6rGyvUuMxy4O4kq+h8/SpfEEmMI0y TSQZfN5ZzLEaKOA== 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_;