From patchwork Tue May 12 12:36:04 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 26723 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 7CB07BDB1C for ; Tue, 12 May 2026 12:36:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7A28463029; Tue, 12 May 2026 14:36:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="S7FvYwwD"; 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 2AF516271A for ; Tue, 12 May 2026 14:36:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778589391; 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; bh=HtpqEl8Wf1Ihvpqfbcx96nygTg2smdA2b5YYDjVAxYk=; b=S7FvYwwDCXuKz5bO/AqhRxwlmkkMUvOADolfOnrvZ5HBOLXH+ib3IE2YxDHn3BuhJ4Nrr7 TsXhH/GgoeTue+5AM9T+0u4DW9iBdaGqE3iFPdKXkJ5j66q7RwGFj5Jh0S8jt4+sUnKLH7 M32RFkGfUsDFGVDIw3Wu9dBhlNBt9qw= 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-67-sSy6GuqvNX-ZzlIkKWaJMQ-1; Tue, 12 May 2026 08:36:30 -0400 X-MC-Unique: sSy6GuqvNX-ZzlIkKWaJMQ-1 X-Mimecast-MFC-AGG-ID: sSy6GuqvNX-ZzlIkKWaJMQ_1778589389 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 0817C18002FC; Tue, 12 May 2026 12:36:29 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.50.44]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2C6191955D84; Tue, 12 May 2026 12:36:25 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Bryan O'Donoghue , Hans de Goede , Laurent Pinchart Subject: [RFC PATCH v5 00/10] LSC for SoftISP simple pipeline Date: Tue, 12 May 2026 14:36:04 +0200 Message-ID: <20260512123619.120068-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: u6sZiQow32HBFUjZSdcYXmCQjUofP-mRrPI7Ghf0fl8_1778589389 X-Mimecast-Originator: redhat.com 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 Sender: "libcamera-devel" Hi everyone, Over the last few months we (students from THUAS) have been working on adding LSC support to the SoftISP simple pipline. These patches are the result of those efforts. The project was under the supervision of Hans de Goede. There are patches to both the GpuISP and some scrips for generating the corrections tables. The changes to the GpuISP are integrated as an algorithm, including automatically choosing a correction table based on the measured colour temperature. The current version of the LSC textures make use of the type GLubyte instead of float. This is because we could not get floating points values to play nice with the shader. The result is that the LSC factors ranging from 1.0 to 4.0 are maped to 0 to 255. The last patch (HACK: Add test LSC to src/ipa/simple/data/uncalibrated.yaml) adds sample data to uncalibrated.yaml file for testing, and is a reference of how the tables should (currently) be structured. Regards, Xander Pronk, Rick ten Wolde, Derek Gielen, Aron Dosti. Taken over by Milan Zamazal: Changes in v5: - ‘grids’ tuning file item renamed to ‘sets’ for consistency with rkisp1. - Underscores appended to Lsc::lsc* names. - Other minor stylistic changes. - Proof-of-concept polynomial LSC implemented. Changes in v4: - glFilterParam -> param - Indentation changes in the shaders. - A commit message part about temperature reworded. - Updated for YamlObject -> ValueNode. - New constant kLscValuesPerCell to distinguish between the constants for the params array size (values) and for the stride (bytes). - The lookup array switched to floats and the texture to half-floats. Changes in v3: - LSC scripts patch dropped due to missing licences. - DO_LSC -> APPLY_LSC - textureUniformLsc_ is assigned unconditionally now. - New constant DebayerParams::kLscBytesPerCell. - LSC values in the tuning file are floats now and converted to bytes internally. - Source code comments added to clarify the usage of the byte LUTs. Changes in v2: - Remaining issues from the reviews (hopefully) addressed. - Especially there is only a single texture now and LSC is fully conditional. - Major cleanup, hacks removed or replaced, typo fixes, cosmetic changes, making linters happy, etc. - See https://lists.libcamera.org/pipermail/libcamera-devel/2026-January/056883.html for an example how to add the grid data. It’s posted as RFC because: - It’s not yet completely tested although it seems to be working in my environment. - The GPU ISP is going to be changed to multipass soon, which may require changes in this patch series; similarly with the libipa effort. Milan Zamazal (5): ipa: simple: Introduce default temperature value libcamera: software_isp: Pass LSC availability to debayering ipa: simple: Add LSC type libcamera: software_isp: Use LSC type instead of LSC enabled libcamera: software_isp: Add polynomial LSC Xander Pronk (5): libcamera: software_isp: egl: Add filter parameter to createTexture2D() libcamera: software_isp: Add LSC data to DebayerParams ipa: simple: Add LSC algorithm libcamera: shaders: Add LSC support libcamera: software_isp: debayer_egl: Add LSC support include/libcamera/internal/egl.h | 9 +- .../internal/software_isp/debayer_params.h | 18 +++ .../internal/software_isp/software_isp.h | 1 + include/libcamera/ipa/soft.mojom | 4 +- src/ipa/simple/algorithms/awb.cpp | 4 +- src/ipa/simple/algorithms/awb.h | 4 +- src/ipa/simple/algorithms/ccm.cpp | 5 +- src/ipa/simple/algorithms/lsc.cpp | 103 ++++++++++++++++++ src/ipa/simple/algorithms/lsc.h | 46 ++++++++ src/ipa/simple/algorithms/meson.build | 1 + src/ipa/simple/ipa_context.h | 4 +- src/ipa/simple/soft_simple.cpp | 7 +- src/libcamera/egl.cpp | 22 +++- src/libcamera/shaders/bayer_1x_packed.frag | 17 +++ src/libcamera/shaders/bayer_unpacked.frag | 17 +++ src/libcamera/software_isp/debayer.cpp | 59 ++++++++++ src/libcamera/software_isp/debayer.h | 3 +- src/libcamera/software_isp/debayer_cpu.cpp | 3 +- src/libcamera/software_isp/debayer_cpu.h | 3 +- src/libcamera/software_isp/debayer_egl.cpp | 70 +++++++++++- src/libcamera/software_isp/debayer_egl.h | 13 ++- src/libcamera/software_isp/software_isp.cpp | 5 +- 22 files changed, 394 insertions(+), 24 deletions(-) create mode 100644 src/ipa/simple/algorithms/lsc.cpp create mode 100644 src/ipa/simple/algorithms/lsc.h