[{"id":37939,"web_url":"https://patchwork.libcamera.org/comment/37939/","msgid":"<8cdfa7dd-7102-48d1-86db-9a1731b0c6bb@ideasonboard.com>","date":"2026-01-26T11:30:34","subject":"Re: [PATCH 3/7] ipa: simple: Add LSC algorithm","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n2026. 01. 26. 11:42 keltezéssel, Rick ten Wolde írta:\n> From: Xander Pronk <xander.c.pronk@gmail.com>\n> \n> Add LSC algorithm module.\n> \n> Co-authored-by: Rick ten Wolde <rick_libcamera@wolde.info>\n> Signed-off-by: Rick ten Wolde <rick_libcamera@wolde.info>\n> Signed-off-by: Xander Pronk <xander.c.pronk@gmail.com>\n> ---\n>   src/ipa/simple/algorithms/lsc.cpp     | 69 +++++++++++++++++++++++++++\n>   src/ipa/simple/algorithms/lsc.h       | 49 +++++++++++++++++++\n>   src/ipa/simple/algorithms/meson.build |  1 +\n>   3 files changed, 119 insertions(+)\n>   create mode 100644 src/ipa/simple/algorithms/lsc.cpp\n>   create mode 100644 src/ipa/simple/algorithms/lsc.h\n> \n> diff --git a/src/ipa/simple/algorithms/lsc.cpp b/src/ipa/simple/algorithms/lsc.cpp\n> new file mode 100644\n> index 00000000..95783e4e\n> --- /dev/null\n> +++ b/src/ipa/simple/algorithms/lsc.cpp\n> @@ -0,0 +1,69 @@\n> +#include \"lsc.h\"\n> +\n> +#include <iostream>\n> +\n> +#include <libcamera/base/log.h>\n> +#include <libcamera/base/utils.h>\n> +\n> +#include <libcamera/control_ids.h>\n\nAt least the preceding two includes seem unnecessary.\n\n\n> +\n> +#include \"libcamera/internal/matrix.h\"\n> +\n> +\n> +namespace libcamera {\n> +\n> +namespace ipa::soft::algorithms {\n> +\n> +LOG_DEFINE_CATEGORY(IPASoftLsc)\n\nEmpty line after this.\n\n\n> +int Lsc::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData)\n> +{\n> +\tint ret_r = lsc_r.readYaml(tuningData[\"grids\"], \"ct\", \"r\");\n> +\tint ret_g = lsc_r.readYaml(tuningData[\"grids\"], \"ct\", \"g\");\n> +\tint ret_b = lsc_r.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 -1;\n\nThis should a valid error code, e.g. `return -EINVAL`.\n\n\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> +\n> +void Lsc::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n> +\t\t  [[maybe_unused]] IPAFrameContext &frameContext, [[maybe_unused]] DebayerParams *params)\n> +{\n> +\tunsigned int ct = context.activeState.awb.temperatureK;\n> +\tif (ct == 0)\n> +\t\tct = 2700;\n> +\tconst Matrix<uint8_t, 16, 16> matrix_r = lsc_r.getInterpolated(ct);\n> +\tconst Matrix<uint8_t, 16, 16> matrix_g = lsc_r.getInterpolated(ct);\n> +\tconst Matrix<uint8_t, 16, 16> matrix_b = lsc_r.getInterpolated(ct);\n> +\n> +\tfor (unsigned long i = 0;  i < matrix_r.data().size(); ++i) {\n> +\t\tparams->LSC_red[i] = matrix_r.data()[i];\n> +\t\tparams->LSC_green[i] = matrix_g.data()[i];\n> +\t\tparams->LSC_blue[i] = matrix_b.data()[i];\n> +\t}\n\nI suggest using 3 `std::copy` calls instead.\n\n\n> +}\n> +\n> +void Lsc::process([[maybe_unused]] IPAContext &context,\n> +\t\t  [[maybe_unused]] const uint32_t frame,\n> +\t\t  [[maybe_unused]] IPAFrameContext &frameContext,\n> +\t\t  [[maybe_unused]] const SwIspStats *stats,\n> +\t\t  [[maybe_unused]] ControlList &metadata)\n> +{\n> +}\n\nIf empty, it's probably better to omit this completely.\n\n\n\n> +\n> +REGISTER_IPA_ALGORITHM(Lsc, \"Lsc\")\n> +\n> +} /* namespace ipa::soft::algorithms */\n> +\n> +} /* namespace libcamera */\n> diff --git a/src/ipa/simple/algorithms/lsc.h b/src/ipa/simple/algorithms/lsc.h\n> new file mode 100644\n> index 00000000..8a3123ad\n> --- /dev/null\n> +++ b/src/ipa/simple/algorithms/lsc.h\n> @@ -0,0 +1,49 @@\n> +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> +/*\n> + * Copyright (C) 2024-2025, Red Hat Inc.\n> + *\n> + * Color correction matrix\n\nThe above needs adjustment.\n\n\n> + */\n> +\n> +#pragma once\n> +\n> +#include <optional>\n\nSeems unnecessary?\n\n\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> +\n> +class Lsc : public Algorithm\n> +{\n> +public:\n> +\tLsc() = default;\n> +\t~Lsc() = default;\n> +\n> +\tint init(IPAContext &context, const YamlObject &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> +\tvoid process(IPAContext &context, const uint32_t frame,\n> +\t\t     IPAFrameContext &frameContext,\n> +\t\t     const SwIspStats *stats,\n> +\t\t     ControlList &metadata) override;\n> +\n> +private:\n> +\tInterpolator<Matrix<uint8_t, 16, 16>> lsc_r;\n> +\tInterpolator<Matrix<uint8_t, 16, 16>> lsc_g;\n> +\tInterpolator<Matrix<uint8_t, 16, 16>> lsc_b;\n\nCamel case again.\n\n\nRegards,\nBarnabás Pőcze\n\n> +};\n> +\n> +} /* namespace ipa::soft::algorithms */\n> +\n> +} /* namespace libcamera */\n> diff --git a/src/ipa/simple/algorithms/meson.build b/src/ipa/simple/algorithms/meson.build\n> index 2d0adb05..9cfc8030 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>       'blc.cpp',\n>       'ccm.cpp',\n>       'lut.cpp',\n> +    'lsc.cpp',\n>   ])","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 C6B5BC3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 26 Jan 2026 11:30:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 73AF461FCA;\n\tMon, 26 Jan 2026 12:30:37 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7D6F361A35\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 26 Jan 2026 12:30:35 +0100 (CET)","from [192.168.33.36] (185.221.142.123.nat.pool.zt.hu\n\t[185.221.142.123])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BA07063F;\n\tMon, 26 Jan 2026 12:29:59 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"YdOuTgpn\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1769427000;\n\tbh=iZBjNZg7aebMxD97XbtPoHnThwFsZR2hy7dUC78pjtk=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=YdOuTgpnk8mHHkXst2o6zt91P+6lAJnRx+aPsLpnJudQJ7JXNuwpjSSIvSptAcLxJ\n\t19D4o16W89qPTpE381hFya4k+cLZHPCgOBF9Tg3H0j7EqUbIqL4h8vebleilLze4U4\n\tzgqh4H5izIuz4ZV1ApbWKNVUguP6qfn30u/MFT94=","Message-ID":"<8cdfa7dd-7102-48d1-86db-9a1731b0c6bb@ideasonboard.com>","Date":"Mon, 26 Jan 2026 12:30:34 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 3/7] ipa: simple: Add LSC algorithm","To":"Rick ten Wolde <rick.w.ten.wolde@gmail.com>,\n\tlibcamera-devel@lists.libcamera.org","Cc":"xander.c.pronk@gmail.com, derekgielen@outlook.com,\n\t22012540@student.hhs.nl, johannes.goede@oss.qualcomm.com,\n\tRick ten Wolde <rick_libcamera@wolde.info>","References":"<20260126104256.119697-1-rick.w.ten.wolde@gmail.com>\n\t<20260126104256.119697-4-rick.w.ten.wolde@gmail.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20260126104256.119697-4-rick.w.ten.wolde@gmail.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","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>"}},{"id":37953,"web_url":"https://patchwork.libcamera.org/comment/37953/","msgid":"<85bjigcqud.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2026-01-26T15:54:02","subject":"Re: [PATCH 3/7] ipa: simple: Add LSC algorithm","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Hi,\n\nthank you for the patch.\n\nRick ten Wolde <rick.w.ten.wolde@gmail.com> writes:\n\n> From: Xander Pronk <xander.c.pronk@gmail.com>\n>\n> Add LSC algorithm module.\n>\n> Co-authored-by: Rick ten Wolde <rick_libcamera@wolde.info>\n> Signed-off-by: Rick ten Wolde <rick_libcamera@wolde.info>\n> Signed-off-by: Xander Pronk <xander.c.pronk@gmail.com>\n> ---\n>  src/ipa/simple/algorithms/lsc.cpp     | 69 +++++++++++++++++++++++++++\n>  src/ipa/simple/algorithms/lsc.h       | 49 +++++++++++++++++++\n>  src/ipa/simple/algorithms/meson.build |  1 +\n>  3 files changed, 119 insertions(+)\n>  create mode 100644 src/ipa/simple/algorithms/lsc.cpp\n>  create mode 100644 src/ipa/simple/algorithms/lsc.h\n>\n> diff --git a/src/ipa/simple/algorithms/lsc.cpp b/src/ipa/simple/algorithms/lsc.cpp\n> new file mode 100644\n> index 00000000..95783e4e\n> --- /dev/null\n> +++ b/src/ipa/simple/algorithms/lsc.cpp\n> @@ -0,0 +1,69 @@\n> +#include \"lsc.h\"\n> +\n> +#include <iostream>\n> +\n> +#include <libcamera/base/log.h>\n> +#include <libcamera/base/utils.h>\n> +\n> +#include <libcamera/control_ids.h>\n> +\n> +#include \"libcamera/internal/matrix.h\"\n> +\n> +\n> +namespace libcamera {\n> +\n> +namespace ipa::soft::algorithms {\n> +\n> +LOG_DEFINE_CATEGORY(IPASoftLsc)\n> +int Lsc::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData)\n> +{\n> +\tint ret_r = lsc_r.readYaml(tuningData[\"grids\"], \"ct\", \"r\");\n> +\tint ret_g = lsc_r.readYaml(tuningData[\"grids\"], \"ct\", \"g\");\n> +\tint ret_b = lsc_r.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 -1;\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> +\n> +void Lsc::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n> +\t\t  [[maybe_unused]] IPAFrameContext &frameContext, [[maybe_unused]] DebayerParams *params)\n> +{\n> +\tunsigned int ct = context.activeState.awb.temperatureK;\n> +\tif (ct == 0)\n> +\t\tct = 2700;\n\nWhy exactly this value?  It should be explained somewhere.\n\nI was thinking whether it would be better to disable the correction until\nthe temperature is available, but this wouldn't work when white balance\nalgorithm is disabled.\n\nI'm not sure whether the initial temperature value is guaranteed to be\n0.  I think we should have some common initial temperature value set, to\nat least to use the same value in different algorithms (the other one is\ncurrently Ccm).\n\n> +\tconst Matrix<uint8_t, 16, 16> matrix_r = lsc_r.getInterpolated(ct);\n> +\tconst Matrix<uint8_t, 16, 16> matrix_g = lsc_r.getInterpolated(ct);\n> +\tconst Matrix<uint8_t, 16, 16> matrix_b = lsc_r.getInterpolated(ct);\n> +\n> +\tfor (unsigned long i = 0;  i < matrix_r.data().size(); ++i) {\n> +\t\tparams->LSC_red[i] = matrix_r.data()[i];\n> +\t\tparams->LSC_green[i] = matrix_g.data()[i];\n> +\t\tparams->LSC_blue[i] = matrix_b.data()[i];\n> +\t}\n> +}\n> +\n> +void Lsc::process([[maybe_unused]] IPAContext &context,\n> +\t\t  [[maybe_unused]] const uint32_t frame,\n> +\t\t  [[maybe_unused]] IPAFrameContext &frameContext,\n> +\t\t  [[maybe_unused]] const SwIspStats *stats,\n> +\t\t  [[maybe_unused]] ControlList &metadata)\n> +{\n> +}\n> +\n> +REGISTER_IPA_ALGORITHM(Lsc, \"Lsc\")\n> +\n> +} /* namespace ipa::soft::algorithms */\n> +\n> +} /* namespace libcamera */\n> diff --git a/src/ipa/simple/algorithms/lsc.h b/src/ipa/simple/algorithms/lsc.h\n> new file mode 100644\n> index 00000000..8a3123ad\n> --- /dev/null\n> +++ b/src/ipa/simple/algorithms/lsc.h\n> @@ -0,0 +1,49 @@\n> +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> +/*\n> + * Copyright (C) 2024-2025, Red Hat Inc.\n> + *\n> + * Color correction matrix\n> + */\n> +\n> +#pragma once\n> +\n> +#include <optional>\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> +\n> +class Lsc : public Algorithm\n> +{\n> +public:\n> +\tLsc() = default;\n> +\t~Lsc() = default;\n> +\n> +\tint init(IPAContext &context, const YamlObject &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> +\tvoid process(IPAContext &context, const uint32_t frame,\n> +\t\t     IPAFrameContext &frameContext,\n> +\t\t     const SwIspStats *stats,\n> +\t\t     ControlList &metadata) override;\n> +\n> +private:\n> +\tInterpolator<Matrix<uint8_t, 16, 16>> lsc_r;\n> +\tInterpolator<Matrix<uint8_t, 16, 16>> lsc_g;\n> +\tInterpolator<Matrix<uint8_t, 16, 16>> lsc_b;\n> +};\n> +\n> +} /* namespace ipa::soft::algorithms */\n> +\n> +} /* namespace libcamera */\n> diff --git a/src/ipa/simple/algorithms/meson.build b/src/ipa/simple/algorithms/meson.build\n> index 2d0adb05..9cfc8030 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>      'blc.cpp',\n>      'ccm.cpp',\n>      'lut.cpp',\n> +    'lsc.cpp',\n>  ])","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 4E84CC3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 26 Jan 2026 15:54:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 556BC61FCC;\n\tMon, 26 Jan 2026 16:54:11 +0100 (CET)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1F10261A35\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 26 Jan 2026 16:54:09 +0100 (CET)","from mail-wm1-f69.google.com (mail-wm1-f69.google.com\n\t[209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-518-Qr5IQMVMPBOUt5OX1JdryQ-1; Mon, 26 Jan 2026 10:54:06 -0500","by mail-wm1-f69.google.com with SMTP id\n\t5b1f17b1804b1-4803e8b6007so36225135e9.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 26 Jan 2026 07:54:06 -0800 (PST)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-48047028928sm503836405e9.2.2026.01.26.07.54.03\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 26 Jan 2026 07:54:03 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"RJXq4pkn\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1769442848;\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\tin-reply-to:in-reply-to:references:references;\n\tbh=J3VkOtFUQwJqUoLI9eRDn+Xpj6YULuYAfyMItCNf6hI=;\n\tb=RJXq4pknHjeifXZjME0KvadNEqXVFYithM5WnpcECivK2PlBFsnz0P4ookAgDBBsmc/vn2\n\tdgS4PiZHmEz4RXdUwIFWGFJdO848q09GsXos8Eg1M8jLNp6h46wBAwarrEqUmjcKqzZBMD\n\thab0bzhjEIuIKS7LJkpnQ0HPCXXRfVI=","X-MC-Unique":"Qr5IQMVMPBOUt5OX1JdryQ-1","X-Mimecast-MFC-AGG-ID":"Qr5IQMVMPBOUt5OX1JdryQ_1769442845","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1769442845; x=1770047645;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject\n\t:date:message-id:reply-to;\n\tbh=J3VkOtFUQwJqUoLI9eRDn+Xpj6YULuYAfyMItCNf6hI=;\n\tb=L6h9BlW82sdZ7tHN7Ug68ero8E7WKo6E43H6A+6BNafH1d8qYq6JPn+slbbAY3nca2\n\tQd03YsPiwkgQTrL6hkm8WC1K6xx8KGOh+W+JpMMU5rMJ5HcQL9VMuLyq6C3tyKkFbncl\n\tDbcuExfSDdaI1lA8/HsqoEwNhvpgyn4j1htSmGRy+pqWQ6lsAv6Jhp56Biiu0FNzKmZW\n\tKUxtMd2Uf+mNIq70s2Cea8fTkZPsrIxCGcSLA83UdGZSKFsSmIUYkFcI2fKfr9Nr1ArN\n\tPoS2nUh20kArI1ymbf1N8R64Wt4+MsSMVP7IcXrFoRmSIHORK+ZRprk3l1ds2OZg8U4I\n\tW60A==","X-Gm-Message-State":"AOJu0Yx5Muh9Vvl5xVvkn84GBy8yOnoFXV2Ua+LAnUZmBFzh2JSYq6a/\n\t/vZGC8TvBMkaCgmO+XFIJ219Xm464VU1IyMRXqnfKqrbA7dhPqedQdzzzRp2M8+Go5uRqwbP3cI\n\tskLHs57DQEa8z7740n2WuPtqkDVE/xZ1L+kZJR5IakuN9XSBr+xEnGs3s0AW6G9DVF+DxKpdZ0J\n\tU=","X-Gm-Gg":"AZuq6aJxbgBvaOo4ewHxpQOUFdyaduhqDzDX8sJr2fu/gO+OjfM1kw56fGwk4CWP9C4\n\t/LXsU/ILbUsp3GB32FiPicTkNWiD3N3K1MEhf0anEHBKSGg56J4oGXrQRryFaNgpDjdtVUUrEwW\n\tdVT8vkDYheDf9kKQ1JMY84rrRzQeMlJOcuyqfkK087UUjPCU4eh2g/vd0WdvM1aWq5fcHJvoPOH\n\t91vxp9+y15r2SLgqmeG/YhP8JnNblZhCSlqEW5h0YZfgrdBakOv55a1FwrA6uuY250moSPF6U/y\n\t9VviA6lhLHQqhP6EcaDms6FmM5nY64RgPo88zdE6RKHS05pL8axpTrJoC4QVIYlDL3YAd7559Jr\n\ttbE+0s04yS8IJBiaw3UGec+hV1tdI/rKa0Tsoid5jumuwbzK4hGChchcBfsO+y7M=","X-Received":["by 2002:a05:600c:c04b:10b0:46e:4e6d:79f4 with SMTP id\n\t5b1f17b1804b1-4805dd3722bmr64026095e9.15.1769442845143; \n\tMon, 26 Jan 2026 07:54:05 -0800 (PST)","by 2002:a05:600c:c04b:10b0:46e:4e6d:79f4 with SMTP id\n\t5b1f17b1804b1-4805dd3722bmr64025805e9.15.1769442844718; \n\tMon, 26 Jan 2026 07:54:04 -0800 (PST)"],"From":"Milan Zamazal <mzamazal@redhat.com>","To":"Rick ten Wolde <rick.w.ten.wolde@gmail.com>","Cc":"libcamera-devel@lists.libcamera.org,  xander.c.pronk@gmail.com,\n\tderekgielen@outlook.com,  22012540@student.hhs.nl,\n\tjohannes.goede@oss.qualcomm.com,  Rick ten Wolde\n\t<rick_libcamera@wolde.info>","Subject":"Re: [PATCH 3/7] ipa: simple: Add LSC algorithm","In-Reply-To":"<20260126104256.119697-4-rick.w.ten.wolde@gmail.com> (Rick ten\n\tWolde's message of \"Mon, 26 Jan 2026 11:42:51 +0100\")","References":"<20260126104256.119697-1-rick.w.ten.wolde@gmail.com>\n\t<20260126104256.119697-4-rick.w.ten.wolde@gmail.com>","Date":"Mon, 26 Jan 2026 16:54:02 +0100","Message-ID":"<85bjigcqud.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"opglUzgAl33l9dxlCzox09IomqKSSI4AGXbOvIPGBlI_1769442845","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","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>"}},{"id":38078,"web_url":"https://patchwork.libcamera.org/comment/38078/","msgid":"<564bc2ef-7846-436a-9c1d-72c3b9b0b87f@nxsw.ie>","date":"2026-02-04T15:10:20","subject":"Re: [PATCH 3/7] ipa: simple: Add LSC algorithm","submitter":{"id":226,"url":"https://patchwork.libcamera.org/api/people/226/","name":"Bryan O'Donoghue","email":"bod.linux@nxsw.ie"},"content":"On 26/01/2026 10:42, Rick ten Wolde wrote:\n> From: Xander Pronk <xander.c.pronk@gmail.com>\n> \n> Add LSC algorithm module.\n> \n> Co-authored-by: Rick ten Wolde <rick_libcamera@wolde.info>\n> Signed-off-by: Rick ten Wolde <rick_libcamera@wolde.info>\n> Signed-off-by: Xander Pronk <xander.c.pronk@gmail.com>\n> ---\n>   src/ipa/simple/algorithms/lsc.cpp     | 69 +++++++++++++++++++++++++++\n>   src/ipa/simple/algorithms/lsc.h       | 49 +++++++++++++++++++\n>   src/ipa/simple/algorithms/meson.build |  1 +\n>   3 files changed, 119 insertions(+)\n>   create mode 100644 src/ipa/simple/algorithms/lsc.cpp\n>   create mode 100644 src/ipa/simple/algorithms/lsc.h\n> \n> diff --git a/src/ipa/simple/algorithms/lsc.cpp b/src/ipa/simple/algorithms/lsc.cpp\n> new file mode 100644\n> index 00000000..95783e4e\n> --- /dev/null\n> +++ b/src/ipa/simple/algorithms/lsc.cpp\n> @@ -0,0 +1,69 @@\n> +#include \"lsc.h\"\n> +\n> +#include <iostream>\n> +\n> +#include <libcamera/base/log.h>\n> +#include <libcamera/base/utils.h>\n> +\n> +#include <libcamera/control_ids.h>\n> +\n> +#include \"libcamera/internal/matrix.h\"\n> +\n> +\n> +namespace libcamera {\n> +\n> +namespace ipa::soft::algorithms {\n> +\n> +LOG_DEFINE_CATEGORY(IPASoftLsc)\n> +int Lsc::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData)\n> +{\n> +\tint ret_r = lsc_r.readYaml(tuningData[\"grids\"], \"ct\", \"r\");\n> +\tint ret_g = lsc_r.readYaml(tuningData[\"grids\"], \"ct\", \"g\");\n> +\tint ret_b = lsc_r.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 -1;\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> +\n> +void Lsc::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n> +\t\t  [[maybe_unused]] IPAFrameContext &frameContext, [[maybe_unused]] DebayerParams *params)\n> +{\n> +\tunsigned int ct = context.activeState.awb.temperatureK;\n> +\tif (ct == 0)\n> +\t\tct = 2700;\n> +\tconst Matrix<uint8_t, 16, 16> matrix_r = lsc_r.getInterpolated(ct);\n> +\tconst Matrix<uint8_t, 16, 16> matrix_g = lsc_r.getInterpolated(ct);\n> +\tconst Matrix<uint8_t, 16, 16> matrix_b = lsc_r.getInterpolated(ct);\n> +\n> +\tfor (unsigned long i = 0;  i < matrix_r.data().size(); ++i) {\n> +\t\tparams->LSC_red[i] = matrix_r.data()[i];\n> +\t\tparams->LSC_green[i] = matrix_g.data()[i];\n> +\t\tparams->LSC_blue[i] = matrix_b.data()[i];\n> +\t}\n> +}\n> +\n> +void Lsc::process([[maybe_unused]] IPAContext &context,\n> +\t\t  [[maybe_unused]] const uint32_t frame,\n> +\t\t  [[maybe_unused]] IPAFrameContext &frameContext,\n> +\t\t  [[maybe_unused]] const SwIspStats *stats,\n> +\t\t  [[maybe_unused]] ControlList &metadata)\n> +{\n> +}\n> +\n> +REGISTER_IPA_ALGORITHM(Lsc, \"Lsc\")\n> +\n> +} /* namespace ipa::soft::algorithms */\n> +\n> +} /* namespace libcamera */\n> diff --git a/src/ipa/simple/algorithms/lsc.h b/src/ipa/simple/algorithms/lsc.h\n> new file mode 100644\n> index 00000000..8a3123ad\n> --- /dev/null\n> +++ b/src/ipa/simple/algorithms/lsc.h\n> @@ -0,0 +1,49 @@\n> +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> +/*\n> + * Copyright (C) 2024-2025, Red Hat Inc.\n> + *\n> + * Color correction matrix\n> + */\n> +\n> +#pragma once\n> +\n> +#include <optional>\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> +\n> +class Lsc : public Algorithm\n> +{\n> +public:\n> +\tLsc() = default;\n> +\t~Lsc() = default;\n> +\n> +\tint init(IPAContext &context, const YamlObject &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> +\tvoid process(IPAContext &context, const uint32_t frame,\n> +\t\t     IPAFrameContext &frameContext,\n> +\t\t     const SwIspStats *stats,\n> +\t\t     ControlList &metadata) override;\n> +\n> +private:\n> +\tInterpolator<Matrix<uint8_t, 16, 16>> lsc_r;\n> +\tInterpolator<Matrix<uint8_t, 16, 16>> lsc_g;\n> +\tInterpolator<Matrix<uint8_t, 16, 16>> lsc_b;\n\nI guess this is the 16x16 in your previous patch.\n\nSo again if this is instead based on one or two defines you can change \nthe define once and expand/contract the table easily..\n\n> +};\n> +\n> +} /* namespace ipa::soft::algorithms */\n> +\n> +} /* namespace libcamera */\n> diff --git a/src/ipa/simple/algorithms/meson.build b/src/ipa/simple/algorithms/meson.build\n> index 2d0adb05..9cfc8030 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>       'blc.cpp',\n>       'ccm.cpp',\n>       'lut.cpp',\n> +    'lsc.cpp',\n>   ])\n> --\n> 2.51.0\n>","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 B99C5C31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  4 Feb 2026 15:10:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7CB7C62037;\n\tWed,  4 Feb 2026 16:10:28 +0100 (CET)","from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 04B9A61FBF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  4 Feb 2026 16:10:26 +0100 (CET)","from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n\tby sea.source.kernel.org (Postfix) with ESMTP id 5951143EF2;\n\tWed,  4 Feb 2026 15:10:24 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id BAD4CC4CEF7;\n\tWed,  4 Feb 2026 15:10:22 +0000 (UTC)"],"Message-ID":"<564bc2ef-7846-436a-9c1d-72c3b9b0b87f@nxsw.ie>","Date":"Wed, 4 Feb 2026 15:10:20 +0000","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 3/7] ipa: simple: Add LSC algorithm","To":"Rick ten Wolde <rick.w.ten.wolde@gmail.com>,\n\tlibcamera-devel@lists.libcamera.org","Cc":"xander.c.pronk@gmail.com, derekgielen@outlook.com,\n\t22012540@student.hhs.nl, johannes.goede@oss.qualcomm.com,\n\tRick ten Wolde <rick_libcamera@wolde.info>","References":"<20260126104256.119697-1-rick.w.ten.wolde@gmail.com>\n\t<5usF7Rd7ccsCQ0f-PAuK6agxXDDfX9l1T4xYygt_EXi_3E-bNuWVIIkyWjfDdV6cXfzJEfX1Q3XfBVRvKzo8eg==@protonmail.internalid>\n\t<20260126104256.119697-4-rick.w.ten.wolde@gmail.com>","From":"Bryan O'Donoghue <bod.linux@nxsw.ie>","Content-Language":"en-US","In-Reply-To":"<20260126104256.119697-4-rick.w.ten.wolde@gmail.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","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>"}}]