Patch Detail
Show a patch.
GET /api/patches/26619/?format=api
{ "id": 26619, "url": "https://patchwork.libcamera.org/api/patches/26619/?format=api", "web_url": "https://patchwork.libcamera.org/patch/26619/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20260504182658.590233-5-mzamazal@redhat.com>", "date": "2026-05-04T18:26:53", "name": "[RFC,v4,4/7] ipa: simple: Add LSC algorithm", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "8c676b7105c4d529581797439e4a59b597a9120d", "submitter": { "id": 177, "url": "https://patchwork.libcamera.org/api/people/177/?format=api", "name": "Milan Zamazal", "email": "mzamazal@redhat.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/26619/mbox/", "series": [ { "id": 5903, "url": "https://patchwork.libcamera.org/api/series/5903/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5903", "date": "2026-05-04T18:26:49", "name": "LSC for SoftISP simple pipeline", "version": 4, "mbox": "https://patchwork.libcamera.org/series/5903/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/26619/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/26619/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 864ECBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 4 May 2026 18:27:28 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3E56E6302A;\n\tMon, 4 May 2026 20:27:28 +0200 (CEST)", "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9172D62FEC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 4 May 2026 20:27:26 +0200 (CEST)", "from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-203-LujtyU_bPqyCTl1iIq_AzQ-1;\n\tMon, 04 May 2026 14:27:22 -0400", "from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.93])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS id 365F618001FA; Mon, 4 May 2026 18:27:20 +0000 (UTC)", "from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.32.69])\n\tby mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id AD47B1800480; Mon, 4 May 2026 18:27:17 +0000 (UTC)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"bUlOHPrI\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1777919245;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=a67noJrZ3ozLkKiOFpPB4jmJ6gBaKZ5Bx2lPmVRj1as=;\n\tb=bUlOHPrIQd4Q5KVh/9hqeguTRil3hQc+7EcpDvscbhi9OD7SpR+otfDUe/HL6zxMhBd9id\n\tPb28svJXeKUJNKN3PewmxZhGee6opdtFOJ0UAJ4e4vhrCPCERmAwIeFDUfSCpjySU9K+Xz\n\tNEuuYAB1GJ/9fPWIdn3Bt4xWglRyvmo=", "X-MC-Unique": "LujtyU_bPqyCTl1iIq_AzQ-1", "X-Mimecast-MFC-AGG-ID": "LujtyU_bPqyCTl1iIq_AzQ_1777919240", "From": "Milan Zamazal <mzamazal@redhat.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Xander Pronk <xander.c.pronk@gmail.com>,\n\tBryan O'Donoghue <bod.linux@nxsw.ie>,\n\tHans de Goede <johannes.goede@oss.qualcomm.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tRick ten Wolde <rick_libcamera@wolde.info>,\n\tMilan Zamazal <mzamazal@redhat.com>", "Subject": "[RFC PATCH v4 4/7] ipa: simple: Add LSC algorithm", "Date": "Mon, 4 May 2026 20:26:53 +0200", "Message-ID": "<20260504182658.590233-5-mzamazal@redhat.com>", "In-Reply-To": "<20260504182658.590233-1-mzamazal@redhat.com>", "References": "<20260504182658.590233-1-mzamazal@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.4.1 on 10.30.177.93", "X-Mimecast-Spam-Score": "0", "X-Mimecast-MFC-PROC-ID": "VSfyqAuWnmZi-dMO2QKoT88NgJ0ZyXRNXPx1miv41DI_1777919240", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "content-type": "text/plain; charset=\"US-ASCII\"; x-default=true", "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": "From: Xander Pronk <xander.c.pronk@gmail.com>\n\nThe lens shading algorithm uses grid-based interpolation. The grid\nvalues are specified in a tuning file as multiplication factors for each\nof the RGB colours.\n\nThe interpolated grid is transformed to an array to be used as an RGB\ntexture in debayering.\n\nCo-developed-by: Rick ten Wolde <rick_libcamera@wolde.info>\nSigned-off-by: Rick ten Wolde <rick_libcamera@wolde.info>\nSigned-off-by: Xander Pronk <xander.c.pronk@gmail.com>\nSigned-off-by: Milan Zamazal <mzamazal@redhat.com>\n---\n src/ipa/simple/algorithms/lsc.cpp | 63 +++++++++++++++++++++++++++\n src/ipa/simple/algorithms/lsc.h | 41 +++++++++++++++++\n src/ipa/simple/algorithms/meson.build | 1 +\n 3 files changed, 105 insertions(+)\n create mode 100644 src/ipa/simple/algorithms/lsc.cpp\n create mode 100644 src/ipa/simple/algorithms/lsc.h", "diff": "diff --git a/src/ipa/simple/algorithms/lsc.cpp b/src/ipa/simple/algorithms/lsc.cpp\nnew file mode 100644\nindex 000000000..29c11ead3\n--- /dev/null\n+++ b/src/ipa/simple/algorithms/lsc.cpp\n@@ -0,0 +1,63 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Lens shading correction\n+ */\n+\n+#include \"lsc.h\"\n+\n+#include <libcamera/base/log.h>\n+\n+#include \"awb.h\"\n+\n+namespace libcamera {\n+\n+namespace ipa::soft::algorithms {\n+\n+LOG_DEFINE_CATEGORY(IPASoftLsc)\n+\n+int Lsc::init([[maybe_unused]] IPAContext &context, const ValueNode &tuningData)\n+{\n+\tint ret_r = lscR.readYaml(tuningData[\"grids\"], \"ct\", \"r\");\n+\tint ret_g = lscG.readYaml(tuningData[\"grids\"], \"ct\", \"g\");\n+\tint ret_b = lscB.readYaml(tuningData[\"grids\"], \"ct\", \"b\");\n+\n+\tif (ret_r < 0 || ret_g < 0 || ret_b < 0) {\n+\t\tLOG(IPASoftLsc, Error)\n+\t\t\t<< \"Failed to parse 'lsc' parameter from tuning file.\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int Lsc::configure([[maybe_unused]] IPAContext &context,\n+\t\t [[maybe_unused]] const IPAConfigInfo &configInfo)\n+{\n+\treturn 0;\n+}\n+\n+void Lsc::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n+\t\t [[maybe_unused]] IPAFrameContext &frameContext, DebayerParams *params)\n+{\n+\tunsigned int ct =\n+\t\tcontext.activeState.awb.temperatureK.value_or(kDefaultTemperature);\n+\n+\tconst LscMatrix matrixR = lscR.getInterpolated(ct);\n+\tconst LscMatrix matrixG = lscG.getInterpolated(ct);\n+\tconst LscMatrix matrixB = lscB.getInterpolated(ct);\n+\n+\tDebayerParams::LscLookupTable lut;\n+\tconstexpr unsigned int gridSize = DebayerParams::kLscGridSize;\n+\tfor (unsigned int i = 0, j = 0; i < gridSize * gridSize; i++) {\n+\t\tlut[j++] = matrixR.data()[i];\n+\t\tlut[j++] = matrixG.data()[i];\n+\t\tlut[j++] = matrixB.data()[i];\n+\t}\n+\tparams->lscLut = lut;\n+}\n+\n+REGISTER_IPA_ALGORITHM(Lsc, \"Lsc\")\n+\n+} /* namespace ipa::soft::algorithms */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/simple/algorithms/lsc.h b/src/ipa/simple/algorithms/lsc.h\nnew file mode 100644\nindex 000000000..bed5a2c12\n--- /dev/null\n+++ b/src/ipa/simple/algorithms/lsc.h\n@@ -0,0 +1,41 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Lens shading correction\n+ */\n+\n+#pragma once\n+\n+#include \"libcamera/internal/matrix.h\"\n+\n+#include <libipa/interpolator.h>\n+\n+#include \"algorithm.h\"\n+\n+namespace libcamera {\n+\n+namespace ipa::soft::algorithms {\n+\n+class Lsc : public Algorithm\n+{\n+public:\n+\tLsc() = default;\n+\t~Lsc() = default;\n+\n+\tint init(IPAContext &context, const ValueNode &tuningData) override;\n+\tint configure(IPAContext &context,\n+\t\t const IPAConfigInfo &configInfo) override;\n+\tvoid prepare(IPAContext &context,\n+\t\t const uint32_t frame,\n+\t\t IPAFrameContext &frameContext,\n+\t\t DebayerParams *params) override;\n+\n+private:\n+\tusing LscMatrix = Matrix<float, DebayerParams::kLscGridSize, DebayerParams::kLscGridSize>;\n+\tInterpolator<LscMatrix> lscR;\n+\tInterpolator<LscMatrix> lscG;\n+\tInterpolator<LscMatrix> lscB;\n+};\n+\n+} /* namespace ipa::soft::algorithms */\n+\n+} /* namespace libcamera */\ndiff --git a/src/ipa/simple/algorithms/meson.build b/src/ipa/simple/algorithms/meson.build\nindex 73c637220..c9f6e5590 100644\n--- a/src/ipa/simple/algorithms/meson.build\n+++ b/src/ipa/simple/algorithms/meson.build\n@@ -6,4 +6,5 @@ soft_simple_ipa_algorithms = files([\n 'agc.cpp',\n 'blc.cpp',\n 'ccm.cpp',\n+ 'lsc.cpp',\n ])\n", "prefixes": [ "RFC", "v4", "4/7" ] }