{"id":27281,"url":"https://patchwork.libcamera.org/api/1.1/patches/27281/?format=json","web_url":"https://patchwork.libcamera.org/patch/27281/","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-16-f0e99f035294@ideasonboard.com>","date":"2026-07-08T09:25:03","name":"[v4,16/35] ipa: libipa: lsc_polynomial: Move LscPolynomial from RkISP1","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"b2d91c1785020023c2d8ec0b14674381359b0dac","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/27281/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/27281/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/27281/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 13664C3330\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Jul 2026 09:25:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5FCD766094;\n\tWed,  8 Jul 2026 11:25:26 +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 EB40765FEF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Jul 2026 11:25:09 +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 4A1C63F97;\n\tWed,  8 Jul 2026 11:24:20 +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=\"otkLKJNe\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1783502660;\n\tbh=wCqPjILm+lPOCaD99y9cPOoEAOZKACLZk96y9Sm+O2A=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=otkLKJNeo8fGIyKhAZ+tHEWtYMUNqw8TrBrvp4B9dZR6e2wOKo9FNuwty1hwuh4oN\n\tbSHOXPjGo2eF3L6gEtKjQ2gkc0XrBgxpWfXDRz9SZdOPfOmTf6vP8JJIeKag6W3p1h\n\tIb0SMt5tgOtxHP7NDW3DwwbpDNqjaqnb0REdX3lM=","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Date":"Wed, 08 Jul 2026 11:25:03 +0200","Subject":"[PATCH v4 16/35] ipa: libipa: lsc_polynomial: Move LscPolynomial\n\tfrom RkISP1","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","Message-Id":"<20260708-libipa-algorithms-v4-16-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>, \n\tKieran Bingham <kieran.bingham@ideasonboard.com>","X-Mailer":"b4 0.14.3","X-Developer-Signature":"v=1; a=openpgp-sha256; l=14483;\n\ti=jacopo.mondi@ideasonboard.com; h=from:subject:message-id;\n\tbh=wCqPjILm+lPOCaD99y9cPOoEAOZKACLZk96y9Sm+O2A=;\n\tb=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBqThdumlKyyvFwFhaQ8ebd8R7G8k10vJ+XtCZ/H\n\tsL91ccSBAqJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCak4XbgAKCRByNAaPFqFW\n\tPMK4D/sG2tRFqpatKRS1Ze0A2GaAofWWvzHUofm7ALgODeRlGUsar3E9yF/VwtE2oO3RuVda76Z\n\tuRJOYwWvkLKSBHtLnugyN2vRtpMQTcOSDjziGD4HHTv9fJ+pRkanZle6BPMODM8kKpJLK1qui3+\n\t3NffjaT60F3scNqMaiI2tE+cjSQuaZE2YLQGat4xVJpIrXSsgTOORR6DbbIgAAMSD4RqXyauGAS\n\tmaGrO80A9aJf9QB3GeIcfy5+kTW9PL13GWyDVYrmpBjiHGC/baxQgmohahDSGZ3U7xeSX1xsLcC\n\tmZXZ7GCMvzIwZh7qeMxBYsdkt7Ann2ArAgVGK/NtPQQGFY9ujugJ5Lczz3p980vwjomwo2xefcz\n\t7oxiyULyoTCe8BGPRJBTMdRym8Y2vGiSbCQSpkbM8jpj/9nmf/G7wvDWYO3aUw8tQ6jRmk3pqZT\n\teWKf2TYlx4dqc39xOqmPHP/ffL2VU2vWSigmGrRlwhB0MX08+J5mrdt8WzinJrhwm3WyGYRYdaK\n\t3XZIYomPgBX2hd/c73nArkEOVd4bMPghX7zqHhgGR9AZQNTs+TZ0H7ThhAuRJjBO4M2BuSxZCJq\n\tjMBQ0ZO5mkuAiBMEiepy7ty/oq9GJtu6rDY3w+PZIGDHYQKplwy+FoxN+yJuCGcp3NmfE4qVn21\n\ttvh2iB3OIqxjeDg==","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":"Move the LscPolynomial class to libipa from RkISP1.\n\nRename the class from LscPolynomialImpl to a simpler LscPolynomial.\nThe class is copied verbatim, only documentation has been added.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/ipa/libipa/lsc_polynomial.cpp | 179 +++++++++++++++++++++++++++++++++++++-\n src/ipa/libipa/lsc_polynomial.h   |  46 ++++++++--\n src/ipa/rkisp1/algorithms/lsc.cpp | 162 +---------------------------------\n src/ipa/rkisp1/algorithms/lsc.h   |   1 -\n 4 files changed, 218 insertions(+), 170 deletions(-)","diff":"diff --git a/src/ipa/libipa/lsc_polynomial.cpp b/src/ipa/libipa/lsc_polynomial.cpp\nindex a845d8b1783b..6da6dfdea9d4 100644\n--- a/src/ipa/libipa/lsc_polynomial.cpp\n+++ b/src/ipa/libipa/lsc_polynomial.cpp\n@@ -2,11 +2,14 @@\n /*\n  * Copyright (C) 2024, Ideas On Board\n  *\n- * Polynomial class to represent lens shading correction\n+ * Polynomial based lens shading correction\n  */\n \n #include \"lsc_polynomial.h\"\n \n+#include <assert.h>\n+#include <cmath>\n+\n #include <libcamera/base/log.h>\n \n /**\n@@ -109,6 +112,180 @@ void Polynomial::setReferenceImageSize(const Size &size)\n \n } /* namespace lsc */\n \n+/**\n+ * \\class LscPolynomial\n+ * \\brief Radial Polynomial LSC algorithm implementation\n+ *\n+ * Polynomial-based LSC algorithm implementation. The LscPolynomial class\n+ * implements LSC support using a Polynomial to represent the shading artifacts\n+ * map.\n+ *\n+ * \\sa LscImplementation\n+ */\n+\n+/**\n+ * \\fn LscPolynomial::LscPolynomial\n+ * \\param[in] sensorSize The physical sensor size\n+ *\n+ * Construct an LscPolynomial\n+ */\n+\n+/**\n+ * \\brief Parse polynomial LSC data\n+ * \\param[in] sets The tuning file content\n+ *\n+ * Parse the LSC data in polyomial form from the \\a sets tuning data.\n+ *\n+ * \\return 0 on success or a negative error number otherwise\n+ */\n+int LscPolynomial::parseLscData(const ValueNode &sets)\n+{\n+\tfor (const auto &set : sets.asList()) {\n+\t\tstd::optional<lsc::Polynomial> pr, pgr, pgb, pb;\n+\t\tuint32_t ct = set[\"ct\"].get<uint32_t>(0);\n+\n+\t\tif (lscData_.count(ct)) {\n+\t\t\tLOG(LscPolynomial, Error)\n+\t\t\t\t<< \"Multiple sets found for \"\n+\t\t\t\t<< \"color temperature \" << ct;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tpr = set[\"r\"].get<lsc::Polynomial>();\n+\t\tpgr = set[\"gr\"].get<lsc::Polynomial>();\n+\t\tpgb = set[\"gb\"].get<lsc::Polynomial>();\n+\t\tpb = set[\"b\"].get<lsc::Polynomial>();\n+\n+\t\tif (!(pr || pgr || pgb || pb)) {\n+\t\t\tLOG(LscPolynomial, Error)\n+\t\t\t\t<< \"Failed to parse polynomial for \"\n+\t\t\t\t<< \"colour temperature \" << ct;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tpr->setReferenceImageSize(sensorSize_);\n+\t\tpgr->setReferenceImageSize(sensorSize_);\n+\t\tpgb->setReferenceImageSize(sensorSize_);\n+\t\tpb->setReferenceImageSize(sensorSize_);\n+\n+\t\tlscData_.emplace(std::piecewise_construct,\n+\t\t\t\t std::forward_as_tuple(ct),\n+\t\t\t\t std::forward_as_tuple(PolynomialComponents{ *pr, *pgr, *pgb, *pb }));\n+\t}\n+\n+\tif (lscData_.empty()) {\n+\t\tLOG(LscPolynomial, Error) << \"Failed to load any sets\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\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+ *\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+ *\n+ * Polynomial LSC tables can be re-sampled for a given sensor frame resolution\n+ * using a list of horizontal and vertical nodes that define the LSC grid on\n+ * which the polynomial is re-sampled on.\n+ *\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+ * 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+ * is 0 and the last position is 1.\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+{\n+\tstd::vector<double> xPos = sizesListToPositions(xSizes);\n+\tstd::vector<double> yPos = sizesListToPositions(ySizes);\n+\n+\tlsc::ComponentsMap components;\n+\n+\tfor (const auto &[k, p] : lscData_) {\n+\t\tcomponents[k] = {\n+\t\t\tsamplePolynomial(p.pr, xPos, yPos, cropRectangle),\n+\t\t\tsamplePolynomial(p.pgr, xPos, yPos, cropRectangle),\n+\t\t\tsamplePolynomial(p.pgb, xPos, yPos, cropRectangle),\n+\t\t\tsamplePolynomial(p.pb, xPos, yPos, cropRectangle)\n+\t\t};\n+\t}\n+\n+\treturn components;\n+}\n+\n+std::vector<uint16_t>\n+LscPolynomial::samplePolynomial(const lsc::Polynomial &poly,\n+\t\t\t\tSpan<const double> xPositions,\n+\t\t\t\tSpan<const double> yPositions,\n+\t\t\t\tconst Rectangle &cropRectangle)\n+{\n+\tdouble m = poly.getM();\n+\tdouble x0 = cropRectangle.x / m;\n+\tdouble y0 = cropRectangle.y / m;\n+\tdouble w = cropRectangle.width / m;\n+\tdouble h = cropRectangle.height / m;\n+\tstd::vector<uint16_t> samples;\n+\n+\tsamples.reserve(xPositions.size() * yPositions.size());\n+\n+\tfor (double y : yPositions) {\n+\t\tfor (double x : xPositions) {\n+\t\t\tdouble xp = x0 + x * w;\n+\t\t\tdouble yp = y0 + y * h;\n+\t\t\t/*\n+\t\t\t * The hardware uses 2.10 fixed point format and limits\n+\t\t\t * the legal values to [1..3.999]. Scale and clamp the\n+\t\t\t * sampled value accordingly.\n+\t\t\t */\n+\t\t\tint v = static_cast<int>(\n+\t\t\t\tpoly.sampleAtNormalizedPixelPos(xp, yp) *\n+\t\t\t\t1024);\n+\t\t\tv = std::clamp(v, 1024, 4095);\n+\t\t\tsamples.push_back(v);\n+\t\t}\n+\t}\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 2caf46d2d759..17c2c34499f0 100644\n--- a/src/ipa/libipa/lsc_polynomial.h\n+++ b/src/ipa/libipa/lsc_polynomial.h\n@@ -2,25 +2,23 @@\n /*\n  * Copyright (C) 2024, Ideas On Board\n  *\n- * Helper for radial polynomial used in lens shading correction.\n+ * Polynomial based lens shading correction\n  */\n #pragma once\n \n-#include <algorithm>\n #include <array>\n-#include <assert.h>\n-#include <cmath>\n+#include <map>\n+#include <vector>\n \n-#include <libcamera/base/log.h>\n #include <libcamera/base/span.h>\n \n #include <libcamera/geometry.h>\n \n #include \"libcamera/internal/value_node.h\"\n \n-namespace libcamera {\n+#include \"lsc_base.h\"\n \n-LOG_DECLARE_CATEGORY(LscPolynomial)\n+namespace libcamera {\n \n namespace ipa {\n \n@@ -52,6 +50,40 @@ private:\n \n } /* namespace lsc */\n \n+class LscPolynomial : public LscImplementation\n+{\n+private:\n+\tstruct PolynomialComponents {\n+\t\tlsc::Polynomial pr;\n+\t\tlsc::Polynomial pgr;\n+\t\tlsc::Polynomial pgb;\n+\t\tlsc::Polynomial pb;\n+\t};\n+\tusing PolynomialComponentsMap = std::map<unsigned int, PolynomialComponents>;\n+\n+public:\n+\tLscPolynomial(const Size &sensorSize)\n+\t\t: sensorSize_(sensorSize)\n+\t{\n+\t}\n+\n+\tint parseLscData(const ValueNode &sets) override;\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+\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,\n+\t\t\t\t\t       const Rectangle &cropRectangle);\n+\tPolynomialComponentsMap lscData_;\n+\tSize sensorSize_;\n+};\n+\n } /* namespace ipa */\n \n } /* namespace libcamera */\ndiff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp\nindex 839525f16746..b161798763cb 100644\n--- a/src/ipa/rkisp1/algorithms/lsc.cpp\n+++ b/src/ipa/rkisp1/algorithms/lsc.cpp\n@@ -33,166 +33,6 @@ namespace {\n \n constexpr int kColourTemperatureQuantization = 10;\n \n-class LscPolynomialImpl : public LscImplementation\n-{\n-private:\n-\tstruct PolynomialComponents {\n-\t\tlsc::Polynomial pr;\n-\t\tlsc::Polynomial pgr;\n-\t\tlsc::Polynomial pgb;\n-\t\tlsc::Polynomial pb;\n-\t};\n-\tusing PolynomialComponentsMap = std::map<unsigned int, PolynomialComponents>;\n-\n-public:\n-\tLscPolynomialImpl(const Size &sensorSize)\n-\t\t: sensorSize_(sensorSize)\n-\t{\n-\t}\n-\n-\tint parseLscData(const ValueNode &sets) override;\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-\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,\n-\t\t\t\t\t       const Rectangle &cropRectangle);\n-\tPolynomialComponentsMap lscData_;\n-\tSize sensorSize_;\n-};\n-\n-int LscPolynomialImpl::parseLscData(const ValueNode &sets)\n-{\n-\tfor (const auto &set : sets.asList()) {\n-\t\tstd::optional<lsc::Polynomial> pr, pgr, pgb, pb;\n-\t\tuint32_t ct = set[\"ct\"].get<uint32_t>(0);\n-\n-\t\tif (lscData_.count(ct)) {\n-\t\t\tLOG(RkISP1Lsc, Error)\n-\t\t\t\t<< \"Multiple sets found for \"\n-\t\t\t\t<< \"color temperature \" << ct;\n-\t\t\treturn -EINVAL;\n-\t\t}\n-\n-\t\tpr = set[\"r\"].get<lsc::Polynomial>();\n-\t\tpgr = set[\"gr\"].get<lsc::Polynomial>();\n-\t\tpgb = set[\"gb\"].get<lsc::Polynomial>();\n-\t\tpb = set[\"b\"].get<lsc::Polynomial>();\n-\n-\t\tif (!(pr || pgr || pgb || pb)) {\n-\t\t\tLOG(RkISP1Lsc, Error)\n-\t\t\t\t<< \"Failed to parse polynomial for \"\n-\t\t\t\t<< \"colour temperature \" << ct;\n-\t\t\treturn -EINVAL;\n-\t\t}\n-\n-\t\tpr->setReferenceImageSize(sensorSize_);\n-\t\tpgr->setReferenceImageSize(sensorSize_);\n-\t\tpgb->setReferenceImageSize(sensorSize_);\n-\t\tpb->setReferenceImageSize(sensorSize_);\n-\n-\t\tlscData_.emplace(std::piecewise_construct,\n-\t\t\t\t std::forward_as_tuple(ct),\n-\t\t\t\t std::forward_as_tuple(PolynomialComponents{ *pr, *pgr, *pgb, *pb }));\n-\t}\n-\n-\tif (lscData_.empty()) {\n-\t\tLOG(RkISP1Lsc, Error) << \"Failed to load any sets\";\n-\t\treturn -EINVAL;\n-\t}\n-\n-\treturn 0;\n-}\n-\n-lsc::ComponentsMap\n-LscPolynomialImpl::sampleForCrop(const Rectangle &cropRectangle,\n-\t\t\t\t Span<const double> xSizes,\n-\t\t\t\t Span<const double> ySizes)\n-{\n-\tstd::vector<double> xPos = sizesListToPositions(xSizes);\n-\tstd::vector<double> yPos = sizesListToPositions(ySizes);\n-\n-\tlsc::ComponentsMap components;\n-\n-\tfor (const auto &[k, p] : lscData_) {\n-\t\tcomponents[k] = {\n-\t\t\tsamplePolynomial(p.pr, xPos, yPos, cropRectangle),\n-\t\t\tsamplePolynomial(p.pgr, xPos, yPos, cropRectangle),\n-\t\t\tsamplePolynomial(p.pgb, xPos, yPos, cropRectangle),\n-\t\t\tsamplePolynomial(p.pb, xPos, yPos, cropRectangle)\n-\t\t};\n-\t}\n-\n-\treturn components;\n-}\n-\n-std::vector<uint16_t>\n-LscPolynomialImpl::samplePolynomial(const lsc::Polynomial &poly,\n-\t\t\t\t    Span<const double> xPositions,\n-\t\t\t\t    Span<const double> yPositions,\n-\t\t\t\t    const Rectangle &cropRectangle)\n-{\n-\tdouble m = poly.getM();\n-\tdouble x0 = cropRectangle.x / m;\n-\tdouble y0 = cropRectangle.y / m;\n-\tdouble w = cropRectangle.width / m;\n-\tdouble h = cropRectangle.height / m;\n-\tstd::vector<uint16_t> samples;\n-\n-\tsamples.reserve(xPositions.size() * yPositions.size());\n-\n-\tfor (double y : yPositions) {\n-\t\tfor (double x : xPositions) {\n-\t\t\tdouble xp = x0 + x * w;\n-\t\t\tdouble yp = y0 + y * h;\n-\t\t\t/*\n-\t\t\t * The hardware uses 2.10 fixed point format and limits\n-\t\t\t * the legal values to [1..3.999]. Scale and clamp the\n-\t\t\t * sampled value accordingly.\n-\t\t\t */\n-\t\t\tint v = static_cast<int>(\n-\t\t\t\tpoly.sampleAtNormalizedPixelPos(xp, yp) *\n-\t\t\t\t1024);\n-\t\t\tv = std::clamp(v, 1024, 4095);\n-\t\t\tsamples.push_back(v);\n-\t\t}\n-\t}\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-LscPolynomialImpl::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 class LscTableImpl : public LscImplementation\n {\n public:\n@@ -358,7 +198,7 @@ int LensShadingCorrection::init([[maybe_unused]] IPAContext &context,\n \t\t * \\todo: Most likely the reference frame should be native_size.\n \t\t * Let's wait how the internal discussions progress.\n \t\t */\n-\t\talgo_ = std::make_unique<LscPolynomialImpl>(context.sensorInfo.activeAreaSize);\n+\t\talgo_ = std::make_unique<LscPolynomial>(context.sensorInfo.activeAreaSize);\n \t\tret = algo_->parseLscData(sets);\n \t} else {\n \t\tLOG(RkISP1Lsc, Error) << \"Unsupported LSC data type '\"\ndiff --git a/src/ipa/rkisp1/algorithms/lsc.h b/src/ipa/rkisp1/algorithms/lsc.h\nindex b21c91c0d81f..2a428293cb2e 100644\n--- a/src/ipa/rkisp1/algorithms/lsc.h\n+++ b/src/ipa/rkisp1/algorithms/lsc.h\n@@ -7,7 +7,6 @@\n \n #pragma once\n \n-#include <map>\n #include <memory>\n \n #include \"libipa/interpolator.h\"\n","prefixes":["v4","16/35"]}