[v6,0/4] libcamera: software_isp: Add support for raw monochrome formats
mbox series

Message ID 20261017111036.700859-1-alain.cousinie@laposte.net
Headers show
Series
  • libcamera: software_isp: Add support for raw monochrome formats
Related show

Message

Alain Cousinie Oct. 17, 2026, 11:10 a.m. UTC
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é <alain.cousinie@laposte.net>

---

 .../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

Comments

Alain Cousinie Oct. 17, 2026, 11:27 a.m. UTC | #1
Hi everyone,

Just a quick heads-up: I will be very busy over the coming weeks, so my 
responses to your feedback or a potential v7 might be delayed.

For context, software development is no longer my main profession and I am 
doing this on my spare time — remember that at the very beginning, I just wanted 
to get my own camera to work! So I might need a bit more time to process 
future remarks.

Thank you for your time, support and understanding!

Best regards,
Alain