{"id":27333,"url":"https://patchwork.libcamera.org/api/1.1/patches/27333/?format=json","web_url":"https://patchwork.libcamera.org/patch/27333/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260708-libipa-algorithms-v5-24-0759d0359f52@ideasonboard.com>","date":"2026-07-08T15:51:06","name":"[v5,24/36] ipa: libipa: lsc: Move sizesListToPositions() back to rkisp1","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"4cbe9c06709d0063f47d1d5a19939cd94bedce40","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/1.1/people/143/?format=json","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/27333/mbox/","series":[{"id":6048,"url":"https://patchwork.libcamera.org/api/1.1/series/6048/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=6048","date":"2026-07-08T15:50:42","name":"ipa: libipa: Introduce libipa algorithms","version":5,"mbox":"https://patchwork.libcamera.org/series/6048/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/27333/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/27333/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D42C0C3333\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Jul 2026 15:51:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 67EFB660F6;\n\tWed,  8 Jul 2026 17:51:51 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A0A3A660C5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Jul 2026 17:51:19 +0200 (CEST)","from [192.168.1.182] (93-46-82-201.ip106.fastwebnet.it\n\t[93.46.82.201])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C39943FC2;\n\tWed,  8 Jul 2026 17:50:29 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"C9fq82Fg\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1783525829;\n\tbh=Q5YJZEdg9Su7OB5LPR0JNlstpE3TNjG8bKxHZqN+ZCk=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=C9fq82Fg/B4d3onRYP5/rVbI5WVxib1XGQBj5lweMc/ReuiXDNgUOUt1D/pbZs749\n\tUJKn3XUonOUjT+c6ZNZ8JBgYLLgp7jIPDCQItpyBrOzkdkx8Hxwgx200LSQiTUq14/\n\tUA4xGMMQM88og7gnp9tWb5E5C0LuThgQQUbOMNoA=","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Date":"Wed, 08 Jul 2026 17:51:06 +0200","Subject":"[PATCH v5 24/36] ipa: libipa: lsc: Move sizesListToPositions()\n\tback to rkisp1","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","Message-Id":"<20260708-libipa-algorithms-v5-24-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, \n\tStefan Klug <stefan.klug@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","X-Mailer":"b4 0.14.3","X-Developer-Signature":"v=1; a=openpgp-sha256; l=9808;\n\ti=jacopo.mondi@ideasonboard.com; h=from:subject:message-id;\n\tbh=Q5YJZEdg9Su7OB5LPR0JNlstpE3TNjG8bKxHZqN+ZCk=;\n\tb=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBqTnHpGjUSLGpN3G4KRaXH3O0/VliNZ4tyabPcK\n\tgvjZmIfQHuJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCak5x6QAKCRByNAaPFqFW\n\tPE5rD/9OIadVZvCmkZLq59dIFq5ExovSHTcSuSOsOnY9WtC/AFMMTvA/dJR6t8AnKpCwBXa3dJA\n\tJay+yOECtIvSgBvLYnhmObmrxn/n4c6rjYNriOJZmHFFJkxzjyr0P5Hh9UEFFYw5NcGU+nQ8fkK\n\tWGH5yQvOW9KDLRAG2S8Yl2AH+VEMcccO8FMuloVcutgmQ7sVm9gWOovlP8rnF8QY4dQoyGWDivY\n\tLYowq0/fS5KHFI1ICJHLZG6AAXk7GPuUx68nuVPi4NSL6vpDEp67/XU8kLONqWqipQ+ScbVI1eA\n\tQ5HhoQ6C+qHyKjyPIFIKH/LN7mR4A5k+Mmx/YEK+NIIEbEN1r35ry5/s8SvxxWvrQ02u5J95u/z\n\tMQ26mFsz+a8vCSjL6ms2XPZn1N26Ej9l/Q5uCVKxKh2LFDfBK1kU20FLTvnWpmonHaYCRuBcTvk\n\tl9j7BOibtl5EqsdUV1eQX4OM/UiTxevp8T2bS3J/5cjDGojRK3rrA0gnfgsQd4cYwb0Cx9zOgds\n\tXG0CBKFfUI1ISIxjIV7cUmWR8laQr9lJ9QeWbsiO6OSX6VXdMvB5Sm3OF50mUFBoldbA4l8rF9g\n\tYWUwYoc0Dcr6Ahsz9Gz9QIR2L3cQR4Z3iHFG+l+GGJmFZf4lSc28fpaAymYO0/mBcbiniASXvgz\n\tLkjsB/9xZWudKZg==","X-Developer-Key":"i=jacopo.mondi@ideasonboard.com; a=openpgp;\n\tfpr=72392EDC88144A65C701EA9BA5826A2587AD026B","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The LscPolynomial::sampleForCrop() function is designed to receive a\nlist of segment sizes and translates it to a list of grid vertexes\ninternally with the sizesListToPositions() function.\n\nAs the sizesListToPositions() implementation is RkISP1-specific, move it\nback to the RkISP1 IPA and change the prototype of the sampleForCrop()\nfunction to accept a vector of grid vertexes instead of a span of\nsegment sizes.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n src/ipa/libipa/lsc_base.cpp       |  6 +++---\n src/ipa/libipa/lsc_base.h         |  3 +--\n src/ipa/libipa/lsc_polynomial.cpp | 38 ++++----------------------------------\n src/ipa/libipa/lsc_polynomial.h   |  4 +---\n src/ipa/libipa/lsc_table.h        |  4 ++--\n src/ipa/rkisp1/algorithms/lsc.cpp | 32 +++++++++++++++++++++++++++++++-\n src/ipa/rkisp1/algorithms/lsc.h   |  3 +++\n 7 files changed, 45 insertions(+), 45 deletions(-)","diff":"diff --git a/src/ipa/libipa/lsc_base.cpp b/src/ipa/libipa/lsc_base.cpp\nindex 678ba8a9a808..cc691e17a694 100644\n--- a/src/ipa/libipa/lsc_base.cpp\n+++ b/src/ipa/libipa/lsc_base.cpp\n@@ -88,8 +88,8 @@ void Interpolator<lsc::Components>::\n  * \\fn LscImplementation::sampleForCrop\n  * \\brief Re-sample the LSC components for \\a cropRectangle\n  * \\param[in] cropRectangle The sensor analogue crop rectangle\n- * \\param[in] xSizes List of horizontal positions of the LSC grid nodes\n- * \\param[in] ySizes List of vertical positions of the LSC grid nodes\n+ * \\param[in] xPos List of horizontal positions of the LSC grid nodes\n+ * \\param[in] yPos List of vertical positions of the LSC grid nodes\n  *\n  * LSC tables have to be re-sampled every time a new sensor configuration is\n  * used, as each streaming session might use a different sensor crop rectangle\n@@ -98,7 +98,7 @@ void Interpolator<lsc::Components>::\n  * \\a cropRectangle represents the size of the frame on which the LSC tables\n  * have to be re-sampled on.\n  *\n- * \\a xSizes and \\a ySizes represent the position of the grid nodes vertexes in\n+ * \\a xPos and \\a yPos represent the position of the grid nodes vertexes in\n  * the [0, 1] interval. In example an equally spaced grid of 16 nodes will have\n  * each segment of size 0.0625 and the list of nodes position will be\n  * [0, 0.0625, 0.125, 0.1875, ... , 1]. It is expected that the first position\ndiff --git a/src/ipa/libipa/lsc_base.h b/src/ipa/libipa/lsc_base.h\nindex 51cc35888209..8d1843a5d4fd 100644\n--- a/src/ipa/libipa/lsc_base.h\n+++ b/src/ipa/libipa/lsc_base.h\n@@ -65,8 +65,7 @@ public:\n \n \tvirtual lsc::ComponentsMap\n \tsampleForCrop(const Rectangle &cropRectangle,\n-\t\t      Span<const double> xSizes,\n-\t\t      Span<const double> ySizes) = 0;\n+\t\t      std::vector<double> xPos, std::vector<double> yPos);\n };\n \n } /* namespace ipa */\ndiff --git a/src/ipa/libipa/lsc_polynomial.cpp b/src/ipa/libipa/lsc_polynomial.cpp\nindex f095a5a92024..682e2f14fe09 100644\n--- a/src/ipa/libipa/lsc_polynomial.cpp\n+++ b/src/ipa/libipa/lsc_polynomial.cpp\n@@ -184,8 +184,8 @@ int LscPolynomial::parseLscData(const ValueNode &sets)\n /**\n  * \\brief Re-sample the LSC components for \\a cropRectangle\n  * \\param[in] cropRectangle The sensor analogue crop rectangle\n- * \\param[in] xSizes List of horizontal positions of the LSc grid nodes\n- * \\param[in] ySizes List of vertical positions of the LSC grid nodes\n+ * \\param[in] xPos List of horizontal positions of the LSC grid nodes\n+ * \\param[in] yPos List of vertical positions of the LSC grid nodes\n  *\n  * LSC tables have to be re-sampled every time a new sensor configuration is\n  * used, as each streaming session might use a different sensor crop rectangle.\n@@ -197,7 +197,7 @@ int LscPolynomial::parseLscData(const ValueNode &sets)\n  * \\a cropRectangle represents the size of the frame on which the LSC tables\n  * have to be re-sampled on.\n  *\n- * \\a xSizes and \\a ySizes represent the position of the grid nodes vertexes in\n+ * \\a xPos and \\a yPos represent the position of the grid nodes vertexes in\n  * the [0, 1] interval. In example an equally spaced grid of 16 nodes will have\n  * each segment of size 0.0625 and the list of nodes position will be\n  * [0, 0.0625, 0.125, 0.1875, ... , 1]. It is expected that the first position\n@@ -205,11 +205,8 @@ int LscPolynomial::parseLscData(const ValueNode &sets)\n  */\n lsc::ComponentsMap\n LscPolynomial::sampleForCrop(const Rectangle &cropRectangle,\n-\t\t\t     Span<const double> xSizes,\n-\t\t\t     Span<const double> ySizes)\n+\t\t\t     std::vector<double> xPos, std::vector<double> yPos)\n {\n-\tstd::vector<double> xPos = sizesListToPositions(xSizes);\n-\tstd::vector<double> yPos = sizesListToPositions(ySizes);\n \n \tlsc::ComponentsMap components;\n \n@@ -259,33 +256,6 @@ LscPolynomial::samplePolynomial(const lsc::Polynomial &poly,\n \treturn samples;\n }\n \n-/*\n- * The rkisp1 LSC grid spacing is defined by the cell sizes on the top-left\n- * quadrant of the grid. This is then mirrored in hardware to the other\n- * quadrants. See parseSizes() for further details. For easier handling, this\n- * function converts the cell sizes of half the grid to a list of position of\n- * the whole grid (on one axis). Example:\n- *\n- * input:   | 0.2 | 0.3 |\n- * output: 0.0   0.2   0.5   0.8   1.0\n- */\n-std::vector<double>\n-LscPolynomial::sizesListToPositions(Span<const double> sizes)\n-{\n-\tconst int half = sizes.size();\n-\tstd::vector<double> positions(half * 2 + 1);\n-\tdouble x = 0.0;\n-\n-\tpositions[half] = 0.5;\n-\tfor (int i = 1; i <= half; i++) {\n-\t\tx += sizes[half - i];\n-\t\tpositions[half - i] = 0.5 - x;\n-\t\tpositions[half + i] = 0.5 + x;\n-\t}\n-\n-\treturn positions;\n-}\n-\n } /* namespace ipa */\n \n #ifndef __DOXYGEN__\ndiff --git a/src/ipa/libipa/lsc_polynomial.h b/src/ipa/libipa/lsc_polynomial.h\nindex 17c2c34499f0..d2276ecc6f6b 100644\n--- a/src/ipa/libipa/lsc_polynomial.h\n+++ b/src/ipa/libipa/lsc_polynomial.h\n@@ -71,11 +71,9 @@ public:\n \n \tlsc::ComponentsMap\n \tsampleForCrop(const Rectangle &cropRectangle,\n-\t\t      Span<const double> xSizes,\n-\t\t      Span<const double> ySizes) override;\n+\t\t      std::vector<double> xPos, std::vector<double> yPos) override;\n \n private:\n-\tstd::vector<double> sizesListToPositions(Span<const double> sizes);\n \tstd::vector<uint16_t> samplePolynomial(const lsc::Polynomial &poly,\n \t\t\t\t\t       Span<const double> xPositions,\n \t\t\t\t\t       Span<const double> yPositions,\ndiff --git a/src/ipa/libipa/lsc_table.h b/src/ipa/libipa/lsc_table.h\nindex 0983b78c3f6b..67c7464ea5b6 100644\n--- a/src/ipa/libipa/lsc_table.h\n+++ b/src/ipa/libipa/lsc_table.h\n@@ -30,8 +30,8 @@ public:\n \n \tlsc::ComponentsMap\n \tsampleForCrop([[maybe_unused]] const Rectangle &cropRectangle,\n-\t\t      [[maybe_unused]] Span<const double> xSizes,\n-\t\t      [[maybe_unused]] Span<const double> ySizes) override\n+\t\t      [[maybe_unused]] std::vector<double> xPos,\n+\t\t      [[maybe_unused]] std::vector<double> yPos) override\n \t{\n \t\tLOG(LscTable, Warning)\n \t\t\t<< \"Tabular LSC data doesn't support resampling\";\ndiff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp\nindex e03bf361c4b9..7010c97db22e 100644\n--- a/src/ipa/rkisp1/algorithms/lsc.cpp\n+++ b/src/ipa/rkisp1/algorithms/lsc.cpp\n@@ -70,6 +70,9 @@ int LensShadingCorrection::init([[maybe_unused]] IPAContext &context,\n \tif (xSize_.empty() || ySize_.empty())\n \t\treturn -EINVAL;\n \n+\txPos_ = sizesListToPositions(xSize_);\n+\tyPos_ = sizesListToPositions(ySize_);\n+\n \t/* Get all defined sets to apply. */\n \tconst ValueNode &sets = tuningData[\"sets\"];\n \tif (!sets.isList()) {\n@@ -138,6 +141,33 @@ std::vector<double> LensShadingCorrection::parseSizes(const ValueNode &tuningDat\n \treturn sizes;\n }\n \n+/*\n+ * The rkisp1 LSC grid spacing is defined by the cell sizes on the top-left\n+ * quadrant of the grid. This is then mirrored in hardware to the other\n+ * quadrants. See parseSizes() for further details. For easier handling, this\n+ * function converts the cell sizes of half the grid to a list of position of\n+ * the whole grid (on one axis). Example:\n+ *\n+ * input:   | 0.2 | 0.3 |\n+ * output: 0.0   0.2   0.5   0.8   1.0\n+ */\n+std::vector<double>\n+LensShadingCorrection::sizesListToPositions(Span<const double> sizes)\n+{\n+\tconst int half = sizes.size();\n+\tstd::vector<double> positions(half * 2 + 1);\n+\tdouble x = 0.0;\n+\n+\tpositions[half] = 0.5;\n+\tfor (int i = 1; i <= half; i++) {\n+\t\tx += sizes[half - i];\n+\t\tpositions[half - i] = 0.5 - x;\n+\t\tpositions[half + i] = 0.5 + x;\n+\t}\n+\n+\treturn positions;\n+}\n+\n /**\n  * \\copydoc libcamera::ipa::Algorithm::configure\n  */\n@@ -171,7 +201,7 @@ int LensShadingCorrection::configure(IPAContext &context,\n \n \tLOG(RkISP1Lsc, Debug) << \"Sample LSC data for \" << configInfo.analogCrop;\n \tlsc::ComponentsMap shadingData = algo_->sampleForCrop(configInfo.analogCrop,\n-\t\t\t\t\t\t\t      xSize_, ySize_);\n+\t\t\t\t\t\t\t      xPos_, yPos_);\n \tsets_.setData(std::move(shadingData));\n \n \tcontext.activeState.lsc.enabled = true;\ndiff --git a/src/ipa/rkisp1/algorithms/lsc.h b/src/ipa/rkisp1/algorithms/lsc.h\nindex ee037353bbe4..06aa7a5f133c 100644\n--- a/src/ipa/rkisp1/algorithms/lsc.h\n+++ b/src/ipa/rkisp1/algorithms/lsc.h\n@@ -41,9 +41,12 @@ private:\n \tvoid copyTable(rkisp1_cif_isp_lsc_config &config, const lsc::Components &set0);\n \tstd::vector<double> parseSizes(const ValueNode &tuningData,\n \t\t\t\t       const char *prop);\n+\tstd::vector<double> sizesListToPositions(Span<const double> sizes);\n \n \tstd::vector<double> xSize_;\n \tstd::vector<double> ySize_;\n+\tstd::vector<double> xPos_;\n+\tstd::vector<double> yPos_;\n \tuint16_t xGrad_[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];\n \tuint16_t yGrad_[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];\n \tuint16_t xSizes_[RKISP1_CIF_ISP_LSC_SECTORS_TBL_SIZE];\n","prefixes":["v5","24/36"]}