{"id":27286,"url":"https://patchwork.libcamera.org/api/1.1/patches/27286/?format=json","web_url":"https://patchwork.libcamera.org/patch/27286/","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-v4-23-f0e99f035294@ideasonboard.com>","date":"2026-07-08T09:25:10","name":"[v4,23/35] 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/27286/mbox/","series":[{"id":6046,"url":"https://patchwork.libcamera.org/api/1.1/series/6046/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=6046","date":"2026-07-08T09:24:47","name":"ipa: libipa: Introduce libipa algorithms","version":4,"mbox":"https://patchwork.libcamera.org/series/6046/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/27286/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/27286/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 50CB0C3334\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Jul 2026 09:25:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0FA7B660D1;\n\tWed,  8 Jul 2026 11:25:34 +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 35A5D6608D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Jul 2026 11:25:12 +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 8B25F19A2;\n\tWed,  8 Jul 2026 11:24:22 +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=\"fv+fFNJp\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1783502662;\n\tbh=DRmqcmcgmgwa4JfnoVI42pgp1VvITHEjM0jUXbKB/D4=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=fv+fFNJp/NG0nOucSgnPynjWoNoggVvGqUXZcSBhPBfTtzz5QKVjE6HDaIg7R2oTw\n\tobF/rFx353plN2Vu+5WbpI7uAFaj6FdSnL/iXBJV14UOkUZPEmRmPD9VVKZKO9jXkR\n\tg7cPFRAfq/hxd8IRaAVxXgwqWmGTqj78RIyzX6dc=","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Date":"Wed, 08 Jul 2026 11:25:10 +0200","Subject":"[PATCH v4 23/35] 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-v4-23-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, \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=DRmqcmcgmgwa4JfnoVI42pgp1VvITHEjM0jUXbKB/D4=;\n\tb=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBqThduv/fHwZGeD3Y3ygpLe/3vJ3wrmvyxgSjup\n\t8jEPQO3iDeJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCak4XbgAKCRByNAaPFqFW\n\tPIuvD/4+k8jz/oHvtDYSFAyg9oTgM7Nk5vlcdwGhp9022dkuI58bdCK/4E/iy5mlNyzhoDeYrso\n\t9W02G0HRsxzYa08iI/hfkIPfkgITm9yi+F0gidJruF1dO5inS7/96A4WZZF1Gv16/wRD8BYTaW1\n\t4iqZh5Y5woHY91N5Z+18HdT8O6O3vSrceX+228Gi0ncBNhMGGzHPy+/ldIZb88Fr2eB/8XY0QKb\n\t/9zg5vVy/b8ZYMh8sp9en+U/L5L1M2VP7mKV/tbgfZGNOZhgVuv0xxr841C3hIysWDK2ywp+7U3\n\tcSmQ7ZNBB5nXiyoj3VYsPx/vm4DMmqZhiaaX183uhcXfNnHiz0KEXeHWxj6dTb03YQ5f32n0nRn\n\tl3dGE/EP8ELnBXaunFRBrmXuY0d2ZQR6/altXa/jB2lS9KpNmxIvi2/J/CplZdEA87hwbyHFXbn\n\textk1CF2XC1EdLldYl0tbK7MD7Fae4gk+KJC8sGT2+5ru7NkHBuPuA/5hSIqqNyRXULtK4my250\n\thLnoaIVMTyJYUla7+o5Xg54XCWGefHPS/Vpuy0twtYVajiXTWObXan2OlQKfy8nge8fk4ZdGArn\n\txITu8groE3Apx0QjB20ELQdkyFiYFq8U0H6PielJvnxVT/KBmD6oeWglaXUiBue8SZ51tmEBNWa\n\tCIGl7om96HU3Irg==","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 6da6dfdea9d4..b5561bbac870 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":["v4","23/35"]}