From patchwork Wed Dec 2 15:13:01 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 29137 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 871F0C3304 for ; Wed, 2 Dec 2026 15:13:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 32D726AAF2; Wed, 2 Dec 2026 16:13:26 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="Z+gp+9g2"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8B8B16AAEA for ; Wed, 2 Dec 2026 16:13:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796224402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yaTkSfd8n7fVlyPx+F+sa6WDnrBotPycn4ICfiErCu0=; b=Z+gp+9g2ESd8BA3gpUEk8CCoK6yz1i2WtQo+qHa7JlGMpWgq2xabIR47nmqjYBGzMkkZTu 4N46cEidYydIO0Jz7gaJstjCmJkNvM4+LlPffhFMjVsThF53j3ZMsCFDuW12l08H64d7Fh upgl4hj59FNTnutNi+Att+m9QP4aSCE= X-MC-Rep: binary re single Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-441-riM0oNYeNXS4_g3z1XGlsA-1; Wed, 2 Dec 2026 15:13:17 +0000 X-MC-Unique: riM0oNYeNXS4_g3z1XGlsA-1 X-Mimecast-MFC-AGG-ID: riM0oNYeNXS4_g3z1XGlsA_1796224396 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5FF06191AF1E; Wed, 2 Dec 2026 15:13:16 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B1E203000398; Wed, 2 Dec 2026 15:13:14 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Hans de Goede , Robert Mader , Kieran Bingham Subject: [PATCH v4 1/4] utils: tuning: Add softisp script Date: Wed, 2 Dec 2026 16:13:01 +0100 Message-ID: <20261202151305.132644-2-mzamazal@redhat.com> In-Reply-To: <20261202151305.132644-1-mzamazal@redhat.com> References: <20261202151305.132644-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Kp7Xt0-r4b-la8AdaA-kUaZj9scWjEYJ4fFQFaXDEuE_1796224396 X-Mimecast-Originator: redhat.com 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Let's add a softisp tuning script. It mostly reuses the functionality already provided by the rkisp1 tuning script. The softisp script is modified for the softisp algorithms, i.e. for a different set of algorithms and a different LSC tuning data format. The LSC data differs in grid size, value ranges, and green tables (single green rather than Gr + Gb). Co-developed-by: Hans de Goede Signed-off-by: Hans de Goede Signed-off-by: Milan Zamazal Reviewed-by: Kieran Bingham Tested-by: Kieran Bingham --- .../tuning/libtuning/modules/lsc/__init__.py | 1 + utils/tuning/libtuning/modules/lsc/softisp.py | 105 ++++++++++++++++++ utils/tuning/softisp.py | 53 +++++++++ 3 files changed, 159 insertions(+) create mode 100644 utils/tuning/libtuning/modules/lsc/softisp.py create mode 100755 utils/tuning/softisp.py diff --git a/utils/tuning/libtuning/modules/lsc/__init__.py b/utils/tuning/libtuning/modules/lsc/__init__.py index 0ba4411b4..2518ab6c7 100644 --- a/utils/tuning/libtuning/modules/lsc/__init__.py +++ b/utils/tuning/libtuning/modules/lsc/__init__.py @@ -5,3 +5,4 @@ from libtuning.modules.lsc.lsc import LSC from libtuning.modules.lsc.raspberrypi import ALSCRaspberryPi from libtuning.modules.lsc.rkisp1 import LSCRkISP1 +from libtuning.modules.lsc.softisp import LSCSoftisp diff --git a/utils/tuning/libtuning/modules/lsc/softisp.py b/utils/tuning/libtuning/modules/lsc/softisp.py new file mode 100644 index 000000000..798553542 --- /dev/null +++ b/utils/tuning/libtuning/modules/lsc/softisp.py @@ -0,0 +1,105 @@ +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (C) 2019, Raspberry Pi Ltd +# Copyright (C) 2022, Paul Elder +# +# LSC module for tuning softisp + +from .lsc import LSC + +import libtuning as lt +import libtuning.utils as utils + +from numbers import Number +import numpy as np + + +class LSCSoftisp(LSC): + hr_name = 'LSC (Softisp)' + out_name = 'Lsc' + # \todo Not sure if this is useful. Probably will remove later. + compatible = ['softisp'] + + def __init__(self, *args, **kwargs): + super().__init__(**kwargs) + + # We don't actually need anything from the config file + def validate_config(self, config: dict) -> bool: + return True + + # @return Image color temperature, flattened array of red calibration table + # (containing {sector size} elements), flattened array of red + # calibration table, flattened array of green calibration + # table, flattened array of blue calibration table + + def _do_single_lsc(self, image: lt.Image): + # Perform LSC on each colour channel independently. A future enhancement + # worth investigating would be splitting the luminance and chrominance + # LSC as done by Raspberry Pi. + cr, _ = self._lsc_single_channel(image.channels[lt.Color.R], image) + cgr, _ = self._lsc_single_channel(image.channels[lt.Color.GR], image) + cgb, _ = self._lsc_single_channel(image.channels[lt.Color.GR], image) + cb, _ = self._lsc_single_channel(image.channels[lt.Color.B], image) + cg = (cgr + cgb) / 2 + + return image.color, cr.flatten(), cg.flatten(), cb.flatten() + + # @return List of dictionaries of color temperature, red table, green + # table and blue table + + def _do_all_lsc(self, images: list) -> list: + output_list = [] + output_map_func = lt.gradient.Linear().map + + # List of colour temperatures + list_col = [] + # Associated calibration tables + list_cr = [] + list_cg = [] + list_cb = [] + for image in self._enumerate_lsc_images(images): + col, cr, cg, cb = self._do_single_lsc(image) + list_col.append(col) + list_cr.append(cr) + list_cg.append(cg) + list_cb.append(cb) + + # Convert to numpy array for data manipulation + list_col = np.array(list_col) + list_cr = np.array(list_cr) + list_cg = np.array(list_cg) + list_cb = np.array(list_cb) + + for color_temperature in sorted(set(list_col)): + # Average tables for the same colour temperature + indices = np.where(list_col == color_temperature) + color_temperature = int(color_temperature) + + tables = [] + for lis in [list_cr, list_cg, list_cb]: + table = np.mean(lis[indices], axis=0) + table = output_map_func((1, 4), (64, 256), table) + table = np.clip(table, 64, 255) + table = np.round(table).astype('int32').tolist() + tables.append(table) + + entry = { + 'ct': color_temperature, + 'r': tables[0], + 'g': tables[1], + 'b': tables[2], + } + + output_list.append(entry) + + return output_list + + def process(self, config: dict, images: list, outputs: dict) -> dict: + output = {} + + output['sets'] = self._do_all_lsc(images) + + if len(output['sets']) == 0: + return None + + return output diff --git a/utils/tuning/softisp.py b/utils/tuning/softisp.py new file mode 100755 index 000000000..60c892df2 --- /dev/null +++ b/utils/tuning/softisp.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2022, Paul Elder +# Copyright (C) 2024, Ideas On Board +# +# Tuning script for software ISP, based on rkisp1 tuning + +import logging +import sys + +import coloredlogs +import libtuning as lt +from libtuning.generators import YamlOutput +# Re-use AWB + CCM from RKISP1k +from libtuning.modules.awb import AWBRkISP1 +from libtuning.modules.ccm import CCMRkISP1 +from libtuning.modules.lsc import LSCSoftisp +from libtuning.modules.static import StaticModule +from libtuning.parsers import YamlParser + +coloredlogs.install(level=logging.INFO, fmt='%(name)s %(levelname)s %(message)s') + +agc = StaticModule('Agc') +awb = AWBRkISP1(debug=[lt.Debug.Plot]) +adj = StaticModule('Adjust') +blc = StaticModule('BlackLevel') +ccm = CCMRkISP1(debug=[lt.Debug.Plot]) +lsc = LSCSoftisp(debug=[lt.Debug.Plot], + sector_shape=(17, 17), + + sector_x_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront), + sector_y_gradient=lt.gradient.Linear(lt.Remainder.DistributeFront), + + # This is the function that will be used to average the pixels in + # each sector. This can also be a custom function. + sector_average_function=lt.average.Mean(), + + # This is the function that will be used to smooth the color ratio + # values. This can also be a custom function. + smoothing_function=lt.smoothing.MedianBlur(3),) + +tuner = lt.Tuner('Softisp') +tuner.add([agc, awb, adj, blc, ccm, lsc]) +tuner.set_input_parser(YamlParser()) +tuner.set_output_formatter(YamlOutput()) + +# BLC must come first, since BL values are used by the AGC and AWB algorithms. +# Adj must come after CCM as it only adds a saturation control if there is a CCM. +tuner.set_output_order([blc, agc, awb, ccm, lsc, adj]) + +if __name__ == '__main__': + sys.exit(tuner.run(sys.argv)) From patchwork Wed Dec 2 15:13:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 29138 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 6BC5AC3304 for ; Wed, 2 Dec 2026 15:13:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1152E6AAF8; Wed, 2 Dec 2026 16:13:27 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="BwK5hb8A"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 328BF6AAEE for ; Wed, 2 Dec 2026 16:13:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796224405; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q5wWBasm5ZwZvAEIHm8xKi0Nix0Hh1ZLYBh+RAChGGU=; b=BwK5hb8AfHsbtHZ3MLEP/ecUOxjSqIobUAxzjcAGQJBXmYlhZCnBOyw8Cy2zaycLp+SLar 3OkFiwxEWLR8/SH50tR8JrB6/G0SHhIaExbHfVktPNoUEqt5aQpAh4VtoVQv2GlUFVI4N/ HL3p+SxLfUSR0zM1VwxRH1WSfCZkuIk= X-MC-Rep: binary re single Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-678-LBlDoDKxMfmAyuCOd3wcbA-1; Wed, 2 Dec 2026 15:13:19 +0000 X-MC-Unique: LBlDoDKxMfmAyuCOd3wcbA-1 X-Mimecast-MFC-AGG-ID: LBlDoDKxMfmAyuCOd3wcbA_1796224398 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5C7D01855799; Wed, 2 Dec 2026 15:13:18 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 07CC43000398; Wed, 2 Dec 2026 15:13:16 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Hans de Goede , Robert Mader Subject: [PATCH v4 2/4] libcamera: software_isp: Use specified LSC grid size in debayering Date: Wed, 2 Dec 2026 16:13:02 +0100 Message-ID: <20261202151305.132644-3-mzamazal@redhat.com> In-Reply-To: <20261202151305.132644-1-mzamazal@redhat.com> References: <20261202151305.132644-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: d2Zog8OodPxGqzu4EayUKPhRV-CHaolm8s7wT2F6c9w_1796224398 X-Mimecast-Originator: redhat.com 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org The lens shading correction texture (grid) has currently the fixed size of 17x17 cells in software ISP. Let's make the size flexible instead, in order to be able to reuse external tuning data, perhaps make GPU happier with sizes of powers of 2, and to provide size flexibility generally. This commit prepares GPU debayering for this change. lscEnabled_ is replaced by lscGridSize_. It is empty in case lens shading correction is disabled and contains the grid size otherwise. Software ISP still passes to GPU debayering either an empty grid size or the grid size of 17x17. Making the grid size flexible is implemented in the followup commits. Signed-off-by: Milan Zamazal --- .../internal/software_isp/software_isp.h | 1 + src/libcamera/software_isp/debayer.cpp | 3 ++- src/libcamera/software_isp/debayer.h | 2 +- src/libcamera/software_isp/debayer_cpu.cpp | 2 +- src/libcamera/software_isp/debayer_cpu.h | 2 +- src/libcamera/software_isp/debayer_egl.cpp | 18 +++++++++--------- src/libcamera/software_isp/debayer_egl.h | 4 ++-- src/libcamera/software_isp/software_isp.cpp | 7 ++++++- 8 files changed, 23 insertions(+), 16 deletions(-) diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h index b64910637..c8ed91949 100644 --- a/include/libcamera/internal/software_isp/software_isp.h +++ b/include/libcamera/internal/software_isp/software_isp.h @@ -102,6 +102,7 @@ private: DmaBufAllocator dmaHeap_; bool ccmEnabled_; bool lscEnabled_; + std::optional lscGridSize_; std::unique_ptr ipa_; std::deque queuedInputBuffers_; diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 4f6659000..65820eabd 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -112,7 +112,8 @@ Debayer::~Debayer() * \param[in] inputCfg The input configuration * \param[in] outputCfgs The output configurations * \param[in] ccmEnabled Whether a color correction matrix is applied - * \param[in] lscEnabled Whether lens shading correction grid is provided + * \param[in] lscGridSize The size of the lens shading correction grid; + empty if the correction is not enabled * * \return 0 on success, a negative errno on failure */ diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index e30a05279..246b85b67 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -41,7 +41,7 @@ public: virtual int configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfgs, bool ccmEnabled, - bool lscEnabled) = 0; + const std::optional &lscGridSize) = 0; virtual std::vector formats(PixelFormat inputFormat) = 0; diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index 91867baa6..2ac4f142f 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -625,7 +625,7 @@ int DebayerCpu::setDebayerFunctions(PixelFormat inputFormat, int DebayerCpu::configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfgs, bool ccmEnabled, - [[maybe_unused]] bool lscEnabled) + [[maybe_unused]] const std::optional &lscGridSize) { if (getInputConfig(inputCfg.pixelFormat, inputConfig_) != 0) { LOG(Debayer, Error) diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index ae570893b..5759ad08f 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -38,7 +38,7 @@ public: int configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfgs, bool ccmEnabled, - bool lscEnabled) override; + const std::optional &lscGridSize) override; Size patternSize(PixelFormat inputFormat) override; std::vector formats(PixelFormat input) override; std::tuple diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 33933b11d..ce836f088 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -146,7 +146,7 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm /* Specify GL_OES_EGL_image_external */ egl_.pushEnv(shaderEnv, "#extension GL_OES_EGL_image_external: enable"); - if (lscEnabled_) + if (lscGridSize_) egl_.pushEnv(shaderEnv, "#define APPLY_LSC"); /* @@ -280,7 +280,7 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm int DebayerEGL::configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfgs, [[maybe_unused]] bool ccmEnabled, - bool lscEnabled) + const std::optional &lscGridSize) { if (getInputConfig(inputCfg.pixelFormat, inputConfig_) != 0) { LOG(Debayer, Error) @@ -300,7 +300,7 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg, return -EINVAL; } - lscEnabled_ = lscEnabled; + lscGridSize_ = lscGridSize; inputConfig_.stride = inputCfg.stride; inputPixelFormat_ = inputCfg.pixelFormat; @@ -478,7 +478,7 @@ void DebayerEGL::setShaderVariableValues(eGLImage &eglImageIn, const DebayerPara glUniformMatrix3fv(ccmUniformDataIn_, 1, GL_FALSE, ccm.data().data()); LOG(Debayer, Debug) << " ccmUniformDataIn_ " << ccmUniformDataIn_ << " data " << params.combinedMatrix; - if (lscEnabled_ && params.lscLutVersion != lscLutVersion_) { + if (lscGridSize_ && params.lscLutVersion != lscLutVersion_) { egl_.updateTexture2D(*eglImageLscLookup_, params.lscLut.data()); lscLutVersion_ = params.lscLutVersion; glUniform1i(textureUniformLsc_, eglImageLscLookup_->texture_unit_uniform_id_); @@ -691,12 +691,12 @@ int DebayerEGL::start() if (initBayerShaders(inputPixelFormat_, outputPixelFormat_)) return -EINVAL; - if (lscEnabled_) { - constexpr unsigned int gridSize = DebayerParams::kLscGridSize; - constexpr unsigned int stride = gridSize * DebayerParams::kLscBytesPerCell; + if (lscGridSize_) { + const Size &gridSize = lscGridSize_.value(); + const unsigned int stride = gridSize.width * DebayerParams::kLscBytesPerCell; eglImageLscLookup_.emplace(GL_RGBA, - gridSize, - gridSize, + gridSize.width, + gridSize.height, stride, GL_TEXTURE2, 2); diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h index cbbc6a450..977e1871e 100644 --- a/src/libcamera/software_isp/debayer_egl.h +++ b/src/libcamera/software_isp/debayer_egl.h @@ -46,7 +46,7 @@ public: int configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfgs, bool ccmEnabled, - bool lscEnabled) override; + const std::optional &lscGridSize) override; Size patternSize(PixelFormat inputFormat) override; @@ -84,7 +84,7 @@ private: unsigned int outputBufferCount_; /* LSC lookup table */ - bool lscEnabled_; + std::optional lscGridSize_; std::optional eglImageLscLookup_; std::optional lscLutVersion_; diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 627625b4f..88349598a 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -171,6 +171,11 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, return; } + if (lscEnabled_) + lscGridSize_ = Size(DebayerParams::kLscGridSize, DebayerParams::kLscGridSize); + else + lscGridSize_.reset(); + ipa_->paramsComputed.connect(this, &SoftwareIsp::saveIspParams); ipa_->metadataReady.connect(this, [this](uint32_t frame, const ControlList &metadata) { @@ -294,7 +299,7 @@ int SoftwareIsp::configure(const StreamConfiguration &inputCfg, if (ret < 0) return ret; - ret = debayer_->configure(inputCfg, outputCfgs, ccmEnabled_, lscEnabled_); + ret = debayer_->configure(inputCfg, outputCfgs, ccmEnabled_, lscGridSize_); if (ret < 0) return ret; From patchwork Wed Dec 2 15:13:03 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 29140 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 7950FC3304 for ; Wed, 2 Dec 2026 15:13:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 09D166AAF4; Wed, 2 Dec 2026 16:13:31 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="CxiEICTr"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A5CF46AAF6 for ; Wed, 2 Dec 2026 16:13:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796224406; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sqwCy4B5XwxH0jNVi5NWgzn5Luq+ct7NoZZzuJgYE4U=; b=CxiEICTrYnAd81Y9qrB6uQgVraEKrNcqQDzdKBhPdsERCS5cAc8G0BhVcXLxhCRDfc8ESm 8JqBF+idjBxvtcehrHMfpbPbfsRzF+hme2tgiBAEX+7NKw30iizBVemA4nHqT0T0fectC1 pGyo5IagUXcMQy3/3NNNAcQJYilhDoM= X-MC-Rep: binary re single Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-575-LzZUK2u0PJ-kMD7HlAU9Vg-1; Wed, 2 Dec 2026 15:13:21 +0000 X-MC-Unique: LzZUK2u0PJ-kMD7HlAU9Vg-1 X-Mimecast-MFC-AGG-ID: LzZUK2u0PJ-kMD7HlAU9Vg_1796224400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3785E192C196; Wed, 2 Dec 2026 15:13:20 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EAEC53000398; Wed, 2 Dec 2026 15:13:18 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Hans de Goede , Robert Mader Subject: [PATCH v4 3/4] ipa: softisp: Support any LSC table sizes Date: Wed, 2 Dec 2026 16:13:03 +0100 Message-ID: <20261202151305.132644-4-mzamazal@redhat.com> In-Reply-To: <20261202151305.132644-1-mzamazal@redhat.com> References: <20261202151305.132644-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: rJ7bvWoixl_zQC8orJIWWNiCIY6PDOUjJCU7CC3xlh4_1796224400 X-Mimecast-Originator: redhat.com 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org This adds support of any lens shading correction table size to the software ISP and its IPA. The tuning file can specify the table grid size using a newly introduced `gridSize' parameter, for example: - Lsc: gridSize: width: 32 height: 32 sets: ... If unspecified, the old size of 17x17 is used for backward compatibility. While debayering uses a gridSize_ std::optional variable for the purpose, it cannot be used here because Mojo apparently doesn't support optional's. So separate "size" and "enabled" variables are used when talking to the IPA. Signed-off-by: Milan Zamazal --- .../internal/software_isp/debayer_params.h | 21 +++----- .../internal/software_isp/software_isp.h | 1 - include/libcamera/ipa/softisp.mojom | 3 +- src/ipa/softisp/algorithms/lsc.cpp | 53 ++++++++++++++----- src/ipa/softisp/algorithms/lsc.h | 6 ++- src/ipa/softisp/ipa_context.h | 1 + src/ipa/softisp/softisp.cpp | 10 ++-- src/libcamera/software_isp/debayer.cpp | 13 ----- src/libcamera/software_isp/software_isp.cpp | 9 ++-- 9 files changed, 67 insertions(+), 50 deletions(-) diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h index 300c3f2d6..0e3c3995c 100644 --- a/include/libcamera/internal/software_isp/debayer_params.h +++ b/include/libcamera/internal/software_isp/debayer_params.h @@ -10,8 +10,10 @@ #pragma once -#include #include +#include + +#include #include "libcamera/internal/matrix.h" #include "libcamera/internal/vector.h" @@ -32,23 +34,12 @@ struct DebayerParams { * must be a multiple of 4 (the initial value of GL_UNPACK_ALIGNMENT) * and lscLut is also aligned to 4 bytes. **/ - static constexpr unsigned int kLscGridSize = 17; static constexpr unsigned int kLscValuesPerCell = 4; static constexpr unsigned int kLscBytesPerCell = kLscValuesPerCell * sizeof(uint8_t); - using LscLookupTable = - std::array; - static constexpr auto identityLscLut = [] { - LscLookupTable lut = {}; - /* lut.fill(64) could be used, but it fails with older gcc versions */ - for (size_t i = 0; kLscValuesPerCell * i < lut.size(); i++) { - lut[i * kLscValuesPerCell + 0] = 64; /* == UQ<2, 6>(1.0f).quantized() */ - lut[i * kLscValuesPerCell + 1] = 64; - lut[i * kLscValuesPerCell + 2] = 64; - } - return lut; - }(); - alignas(4) LscLookupTable lscLut = identityLscLut; + using LscLookupTable = std::vector; + /* Minimum allowed alignment for the vector is 8. */ + alignas(8) LscLookupTable lscLut{}; uint64_t lscLutVersion = 0; }; diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h index c8ed91949..9958f6966 100644 --- a/include/libcamera/internal/software_isp/software_isp.h +++ b/include/libcamera/internal/software_isp/software_isp.h @@ -101,7 +101,6 @@ private: DebayerParams debayerParams_; DmaBufAllocator dmaHeap_; bool ccmEnabled_; - bool lscEnabled_; std::optional lscGridSize_; std::unique_ptr ipa_; diff --git a/include/libcamera/ipa/softisp.mojom b/include/libcamera/ipa/softisp.mojom index e42742ed7..e10819e93 100644 --- a/include/libcamera/ipa/softisp.mojom +++ b/include/libcamera/ipa/softisp.mojom @@ -20,7 +20,8 @@ interface IPASoftIspInterface { libcamera.ControlInfoMap sensorControls) => (int32 ret, libcamera.ControlInfoMap ipaControls, - bool ccmEnabled, bool lscEnabled); + bool ccmEnabled, bool lscEnabled, + libcamera.Size lscGridSize); start() => (int32 ret); stop(); configure(IPAConfigInfo configInfo) diff --git a/src/ipa/softisp/algorithms/lsc.cpp b/src/ipa/softisp/algorithms/lsc.cpp index 308939f19..d49ab58ab 100644 --- a/src/ipa/softisp/algorithms/lsc.cpp +++ b/src/ipa/softisp/algorithms/lsc.cpp @@ -13,22 +13,45 @@ namespace ipa::softisp::algorithms { LOG_DEFINE_CATEGORY(IPASoftIspLsc) -int Lsc::init(IPAContext &context, const ValueNode &tuningData) +DebayerParams::LscLookupTable identityLscLut(const Size &size) { - static constexpr unsigned int kGridSize = DebayerParams::kLscGridSize; + size_t lutSize = DebayerParams::kLscValuesPerCell * size.width * size.height; + /* 64 == UQ<2, 6>(1.0f).quantized() */ + return DebayerParams::LscLookupTable(lutSize, 64); +} - for (unsigned int i = 0; i < kGridSize; i++) - gridPos_.push_back(static_cast(i) / (kGridSize - 1)); +int Lsc::init(IPAContext &context, const ValueNode &tuningData) +{ + auto &tuningGridSize = tuningData["gridSize"]; + if (tuningGridSize.isEmpty()) { + /* Just for backward compatibility, should be erroneous otherwise. */ + gridSize_ = defaultGridSize_; + } else { + if (!tuningGridSize.isDictionary()) { + LOG(IPASoftIspLsc, Error) + << "Invalid LSC grid size specification in the tuning file"; + return -1; + } + auto gridWidth = tuningGridSize["width"].get(); + auto gridHeight = tuningGridSize["height"].get(); + if (!gridWidth || !gridHeight || gridWidth <= 1 || gridHeight <= 1) { + LOG(IPASoftIspLsc, Error) + << "Invalid LSC grid values in the tuning file"; + return -1; + } + gridSize_ = Size(gridWidth.value(), gridHeight.value()); + } int ret = lscAlgo_.init(tuningData, context.ctrlMap, - { .keys = { "r", "g", "b" }, - .numHSamples = kGridSize, - .numVSamples = kGridSize, - .sensorSize = context.sensorInfo.activeArea.size() }); + { .keys = { "r", "g", "b" }, + .numHSamples = gridSize_.width, + .numVSamples = gridSize_.height, + .sensorSize = context.sensorInfo.activeArea.size() }); if (ret) return ret; context.lscEnabled = true; + context.lscGridSize = gridSize_; return 0; } @@ -36,9 +59,15 @@ int Lsc::init(IPAContext &context, const ValueNode &tuningData) int Lsc::configure(IPAContext &context, [[maybe_unused]] const IPAConfigInfo &configInfo) { + std::vector gridPosX, gridPosY; + for (unsigned int i = 0; i < gridSize_.width; i++) + gridPosX.push_back(static_cast(i) / (gridSize_.width - 1)); + for (unsigned int i = 0; i < gridSize_.height; i++) + gridPosY.push_back(static_cast(i) / (gridSize_.height - 1)); + return lscAlgo_.configure(context.activeState.lsc, context.sensorInfo.analogCrop, - gridPos_, gridPos_); + gridPosX, gridPosY); } void Lsc::prepare([[maybe_unused]] IPAContext &context, @@ -51,7 +80,7 @@ void Lsc::prepare([[maybe_unused]] IPAContext &context, if (!frameContext.lsc.enabled) { if (lastAppliedCt_ != 0) { - params->lscLut = DebayerParams::identityLscLut; + params->lscLut = identityLscLut(gridSize_); params->lscLutVersion++; lastAppliedCt_ = 0; @@ -71,8 +100,8 @@ void Lsc::prepare([[maybe_unused]] IPAContext &context, const auto &blue = set.at("b"); DebayerParams::LscLookupTable &lut = params->lscLut; - constexpr unsigned int gridSize = DebayerParams::kLscGridSize; - for (unsigned int i = 0, j = 0; i < gridSize * gridSize; i++) { + lut.resize(DebayerParams::kLscValuesPerCell * gridSize_.width * gridSize_.height); + for (unsigned int i = 0, j = 0; i < gridSize_.width * gridSize_.height; i++) { lut[j++] = red[i]; lut[j++] = green[i]; lut[j++] = blue[i]; diff --git a/src/ipa/softisp/algorithms/lsc.h b/src/ipa/softisp/algorithms/lsc.h index 83ec5aec2..eebbd0e68 100644 --- a/src/ipa/softisp/algorithms/lsc.h +++ b/src/ipa/softisp/algorithms/lsc.h @@ -17,6 +17,8 @@ namespace libcamera { namespace ipa::softisp::algorithms { +DebayerParams::LscLookupTable identityLscLut(const Size &size); + class Lsc : public Algorithm { public: @@ -41,8 +43,8 @@ public: private: LscAlgorithm> lscAlgo_; - std::vector gridPos_; - + static constexpr Size defaultGridSize_ = Size(17, 17); + Size gridSize_ = defaultGridSize_; unsigned int lastAppliedCt_ = 0; }; diff --git a/src/ipa/softisp/ipa_context.h b/src/ipa/softisp/ipa_context.h index 62d1ae84b..9a4ae726b 100644 --- a/src/ipa/softisp/ipa_context.h +++ b/src/ipa/softisp/ipa_context.h @@ -91,6 +91,7 @@ struct IPAContext { ControlInfoMap::Map ctrlMap; bool ccmEnabled = false; bool lscEnabled = false; + Size lscGridSize; }; } /* namespace ipa::softisp */ diff --git a/src/ipa/softisp/softisp.cpp b/src/ipa/softisp/softisp.cpp index e35f07737..9926715f8 100644 --- a/src/ipa/softisp/softisp.cpp +++ b/src/ipa/softisp/softisp.cpp @@ -27,6 +27,7 @@ #include "libcamera/internal/yaml_parser.h" #include "algorithms/adjust.h" +#include "algorithms/lsc.h" #include "libipa/agc.h" #include "libipa/camera_sensor_helper.h" @@ -59,7 +60,8 @@ public: const ControlInfoMap &sensorControls, ControlInfoMap *ipaControls, bool *ccmEnabled, - bool *lscEnabled) override; + bool *lscEnabled, + Size *lscGridSize) override; int configure(const IPAConfigInfo &configInfo, ControlInfoMap *ipaControls) override; @@ -99,7 +101,8 @@ int IPASoftIsp::init(const IPASettings &settings, const ControlInfoMap &sensorControls, ControlInfoMap *ipaControls, bool *ccmEnabled, - bool *lscEnabled) + bool *lscEnabled, + Size *lscGridSize) { context_.camHelper = CameraSensorHelperFactoryBase::create(settings.sensorModel); if (!context_.camHelper) { @@ -140,6 +143,7 @@ int IPASoftIsp::init(const IPASettings &settings, *ccmEnabled = context_.ccmEnabled; *lscEnabled = context_.lscEnabled; + *lscGridSize = context_.lscGridSize; params_ = nullptr; stats_ = nullptr; @@ -168,7 +172,7 @@ int IPASoftIsp::init(const IPASettings &settings, params_->contrastExp = 1.0; params_->gains = { { 1.0, 1.0, 1.0 } }; params_->lscLutVersion = 0; - params_->lscLut = DebayerParams::identityLscLut; + params_->lscLut = DebayerParams::LscLookupTable(); /* combinedMatrix is reset for each frame. */ } diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 65820eabd..32bd6e432 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -43,11 +43,6 @@ namespace libcamera { * \brief Contrast value to be used as an exponent */ -/** - * \var DebayerParams::kLscGridSize - * \brief Number of lens shading grid areas in one direction - */ - /** * \var DebayerParams::kLscValuesPerCell * \brief Number of pixel values per each of the lens shading grid areas @@ -71,14 +66,6 @@ namespace libcamera { * \brief Lens shading lookup table */ -/** - * \var DebayerParams::identityLscLut - * \brief Lens shading lookup table of identity mapping - * - * This table can be used to initialise the lens shading lookup table or to - * not apply any real lens shading correction. - */ - /** * \var DebayerParams::lscLutVersion * \brief Incremented on each \a lscLut change diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 88349598a..4b86af7b5 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -157,6 +157,8 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, return; } + bool lscEnabled; + Size gridSize; ret = ipa_->init(IPASettings{ ipaTuningFile, sensor->model() }, debayer_->getStatsFD(), sharedParams_.fd(), @@ -164,15 +166,16 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, sensor->controls(), ipaControls, &ccmEnabled_, - &lscEnabled_); + &lscEnabled, + &gridSize); if (ret) { LOG(SoftwareIsp, Error) << "IPA init failed"; debayer_.reset(); return; } - if (lscEnabled_) - lscGridSize_ = Size(DebayerParams::kLscGridSize, DebayerParams::kLscGridSize); + if (lscEnabled) + lscGridSize_ = gridSize; else lscGridSize_.reset(); From patchwork Wed Dec 2 15:13:04 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 29139 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 32198C3304 for ; Wed, 2 Dec 2026 15:13:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D31316AAFA; Wed, 2 Dec 2026 16:13:29 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="WbIO/Ngx"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0A9DF6AAEE for ; Wed, 2 Dec 2026 16:13:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796224406; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZYZm8kwp+ZG/4TXbpqGBkSJx+FQhwPrqGHrCmiS5JJs=; b=WbIO/Ngx+WbROMkpPeQ4jPlNSCTK39+LSBee9fYQlqpvG5fj6Ht5gie9bAe1ZqyM7bEYje oCXBndzH1iEl4U90VaOKruRKiDGMSIwFGC3AhIqfsQSuqKOnNidvBNbGRm0E737R+EOQEj VvF9MRrpkgdq2xgZ2iLxfznIVDr056U= X-MC-Rep: binary re single Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-693-jC3CMvN5N-G2KKxq2RItIw-1; Wed, 2 Dec 2026 15:13:22 +0000 X-MC-Unique: jC3CMvN5N-G2KKxq2RItIw-1 X-Mimecast-MFC-AGG-ID: jC3CMvN5N-G2KKxq2RItIw_1796224401 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C7ECB1925267; Wed, 2 Dec 2026 15:13:21 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 933E13000398; Wed, 2 Dec 2026 15:13:20 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Hans de Goede , Robert Mader Subject: [PATCH v4 4/4] utils: tuning: Support variable softisp LSC size Date: Wed, 2 Dec 2026 16:13:04 +0100 Message-ID: <20261202151305.132644-5-mzamazal@redhat.com> In-Reply-To: <20261202151305.132644-1-mzamazal@redhat.com> References: <20261202151305.132644-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: uMqvf_qckxljrR_iDnEbIsCceNKj9Gt2ZhNGA_j300g_1796224401 X-Mimecast-Originator: redhat.com 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Software ISP supports arbitrary lens shading correction table sizes. Let's adjust the softisp tuning script to produce tables of any size too. The size can be specified in the tuning script configuration file. If unspecified, the default size of 17x17 cells is still used for compatibility with the last released libcamera. Signed-off-by: Milan Zamazal --- utils/tuning/config-example.yaml | 5 ++++- utils/tuning/libtuning/modules/lsc/softisp.py | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/utils/tuning/config-example.yaml b/utils/tuning/config-example.yaml index 238069a6f..c829ee937 100644 --- a/utils/tuning/config-example.yaml +++ b/utils/tuning/config-example.yaml @@ -52,4 +52,7 @@ general: macbeth: small: 1 show: 0 -# blacklevel: 32 \ No newline at end of file + lsc: + grid_width: 17 + grid_height: 17 +# blacklevel: 32 diff --git a/utils/tuning/libtuning/modules/lsc/softisp.py b/utils/tuning/libtuning/modules/lsc/softisp.py index 798553542..99c41427d 100644 --- a/utils/tuning/libtuning/modules/lsc/softisp.py +++ b/utils/tuning/libtuning/modules/lsc/softisp.py @@ -95,7 +95,11 @@ class LSCSoftisp(LSC): return output_list def process(self, config: dict, images: list, outputs: dict) -> dict: - output = {} + if 'lsc' in config['general']: + lsc_config = config['general']['lsc'] + self.sector_shape = (lsc_config['grid_width'], lsc_config['grid_height']) + + output = dict(gridSize=dict(width=self.sector_shape[0], height=self.sector_shape[1])) output['sets'] = self._do_all_lsc(images)