From patchwork Sat Oct 17 11:10:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alain Cousinie X-Patchwork-Id: 28494 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 435E6C3305 for ; Sat, 17 Oct 2026 11:11:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7388668E76; Sat, 17 Oct 2026 13:11:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=laposte.net header.i=@laposte.net header.b="F/kDjI9k"; dkim-atps=neutral Received: from smtp-outgoing-1702.laposte.net (smtp-outgoing-1702.laposte.net [160.92.124.100]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5027B689D0 for ; Sat, 17 Oct 2026 13:11:49 +0200 (CEST) X-mail-filterd: {"version":"1.9.7", "queueID":"4j6JzN3jZvzdZLg", "contextId": "d080e684-d7b6-47c6-9c66-ec4bb2f53508"} Received: from outgoing-mail.laposte.net (localhost.localdomain [127.0.0.1]) by mlpnf0106.laposte.net (SMTP Server) with ESMTP id 4j6JzN3jZvzdZLg; Sat, 17 Oct 2026 13:11:44 +0200 (CEST) X-mail-filterd: {"version":"1.9.7", "queueID":"4j6JzN0dx1zdZLZ", "contextId": "1e039e19-5dd9-4ab5-b85e-999924848065"} X-lpn-mailing: LEGIT X-lpn-spamrating: 36 X-lpn-spamlevel: not-spam Received: from debian.home (m-dj.hd.free.fr [82.67.82.126]) (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 mlpnf0106.laposte.net (SMTP Server) with ESMTPSA id 4j6JzN0dx1zdZLZ; Sat, 17 Oct 2026 13:11:44 +0200 (CEST) From: alain.cousinie@laposte.net To: libcamera-devel@lists.libcamera.org Cc: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= , Milan Zamazal , Hans de Goede , Bryan O'Donoghue , =?utf-8?q?Alain_Cousini=C3=A9?= Subject: [PATCH v6 0/4] libcamera: software_isp: Add support for raw monochrome formats Date: Sat, 17 Oct 2026 13:10:27 +0200 Message-ID: <20261017111036.700859-1-alain.cousinie@laposte.net> X-Mailer: git-send-email 2.55.0 In-Reply-To: <10d396ff-2270-46ef-a641-967df76917be@laposte.net> References: <10d396ff-2270-46ef-a641-967df76917be@laposte.net> MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=laposte.net; s=lpn-wlmd; t=1792235509; bh=8d6bbwru+R9OQfcuymeWfLaO4vG9UeYrg1nO+MSBs60=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding; b=F/kDjI9kTx6RoAjFd4FV6aV3mrhzWFC8ieuFVvH2XpNsMGgCGVhlAjW3JBIhLdjpbn2Nme39XG09LoKghMN4AGXA6k0N3Maed/u3zu409Vz/WHFl4Ug5DUXUmiSDD2LJtPqR0MbbaDgvQYHROTfnxQdVGMK9WRSxkNDLp3vtnz7HVCBSk8qLNEtKEcBbEHYFATPic1jFmQabEOfW1laICvz4RBSVovoo53u9xleMvpTz6XlivM0X/UCuZYXy1OalGxQyXmtOmijnkWEQ8SsgoUTp2qJoANUiFfeouhNB2novcUN3IAOw/rDSj4OuBeVzeunQ2y3VPcch/wLHx4APlw==; 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" Hello everyone, This is the sixth version (v6) of the patch series adding comprehensive support for raw monochrome formats (R8 to R16, as well as MIPI CSI-2 packed formats) within the Software ISP. This version addresses all the critical feedback received during the v5 review. To facilitate evaluation and preserve project bisectability, the contribution has been split into 4 distinct patches. Changes since v5: 1. Contribution Splitting (Bryan O'Donoghue, Hans de Goede): - Split the global refactoring into 4 digestible patches: Shaders, Statistics loops (Stats), CPU pipeline, and GPU pipeline (EGL). 2. Shader Optimizations and Fixes (Milan Zamazal, Bryan O'Donoghue): - Introduced a dedicated vertex shader (mono.vert) to pre-calculate pixel coordinates, reducing fragment shader overhead. - Restructured the mathematical logic for LSB extraction in mono_1x_packed.frag to eliminate code redundancy. - Renamed ambiguous variables and added explicit code comments detailing the mechanics of the branchless S-curve contrast stretching. - Cleaned up unused pushEnv() macros in the GLSL code. - Added clear documentation regarding the necessity of high precision (precision highp float) to prevent float rounding errors during bit-shifting. 3. CPU and C++ Code Improvements (Milan Zamazal): - Added a dedicated processMono2() routine in DebayerCpuThread to efficiently process monochrome formats on a single pointer plane. This avoids the overhead and memory overflow crashes associated with the legacy color loops. - Replaced all C-style casts with safe, explicit reinterpret_cast<> and static_cast<>. - Added comments clarifying why patternSize.height is kept at 2 to seamlessly fit into the historical loop structures. - Secured 'borderHeight' initialization in the sizes() function by moving it safely after the isNull() sanity check, eliminating potential Undefined Behavior (UB). 4. CCM Handling and GPU Pipeline (Hans de Goede, Milan Zamazal): - Added and initialized the ccmEnabled_ member variable within the EGL pipeline. - Forced ccmEnabled to false with a \todo comment for a cleaner, dynamic future handling on the IPA side, effectively preventing any parasitic image coloration. Thank you in advance for your feedback and reviews! Alain CousiniƩ (4): libcamera: software_isp: Add support for monochrome formats - Shaders libcamera: software_isp: Add support for monochrome formats - Stats libcamera: software_isp: Add support for monochrome formats - CPU libcamera: software_isp: Add support for monochrome formats - GPU Best regards, Alain Signed-off-by: Alain CousiniƩ --- .../internal/software_isp/swstats_cpu.h | 13 ++ src/libcamera/shaders/meson.build | 3 + src/libcamera/shaders/mono.vert | 25 +++ src/libcamera/shaders/mono_1x_packed.frag | 69 ++++++ src/libcamera/shaders/mono_unpacked.frag | 51 +++++ src/libcamera/software_isp/debayer_cpu.cpp | 199 ++++++++++++++++-- src/libcamera/software_isp/debayer_cpu.h | 19 ++ src/libcamera/software_isp/debayer_egl.cpp | 137 ++++++++++-- src/libcamera/software_isp/debayer_egl.h | 2 + src/libcamera/software_isp/swstats_cpu.cpp | 180 ++++++++++++++++ 10 files changed, 674 insertions(+), 24 deletions(-) create mode 100644 src/libcamera/shaders/mono.vert create mode 100644 src/libcamera/shaders/mono_1x_packed.frag create mode 100644 src/libcamera/shaders/mono_unpacked.frag -- 2.55.0