From 06aee9135f9fd135a8c0bc0b55971b29f7617d02 Mon Sep 17 00:00:00 2001 From: Milan Zamazal Date: Fri, 17 Oct 2025 17:44:12 +0200 Subject: [PATCH] libcamera: software_isp: Apply CCM swap also on green When CPU ISP is asked to apply the CCM matrix [0 1 0] [0 0 0] [0 0 0] for a format that requires swapping red and blue channels, the resulting image has a wrong colour. The CCM matrix above should take green from pixels and make it red. Instead, the image is blue. The problem is that the lookup tables setup in CPU debayering swaps red and blue in the lookup tables for red and blue, but not for green. The colours must be swapped also in the lookup table for green, which this patch adds. Signed-off-by: Milan Zamazal Reviewed-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham Signed-off-by: Kieran Bingham --- src/libcamera/software_isp/debayer_cpu.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index c2fb11ba..67a303c6 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -803,6 +803,7 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output blueCcm_ = params.redCcm; for (unsigned int i = 0; i < 256; i++) { std::swap(redCcm_[i].r, redCcm_[i].b); + std::swap(greenCcm_[i].r, greenCcm_[i].b); std::swap(blueCcm_[i].r, blueCcm_[i].b); } } else {