[v4,08/23] libcamera: shaders: Add support for black level compenstation
diff mbox series

Message ID 20251120233347.5046-9-bryan.odonoghue@linaro.org
State New
Headers show
Series
  • Add GLES 2.0 GPUISP to libcamera
Related show

Commit Message

Bryan O'Donoghue Nov. 20, 2025, 11:33 p.m. UTC
Add the ability to apply a int blacklevel gain against the demosaiced data
prior to application of colour correction data.

We calculate the index into the RGB black-level table so that we can apply
the black level when we sample the input prior to the demosiac operation.

Don't do this when using the lookup tables as the black level is
already calculated in those.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 include/libcamera/internal/shaders/bayer_1x_packed.frag | 4 ++++
 include/libcamera/internal/shaders/bayer_unpacked.frag  | 4 ++++
 2 files changed, 8 insertions(+)

Patch
diff mbox series

diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag
index c0632eb1f..6bca07b6e 100644
--- a/include/libcamera/internal/shaders/bayer_1x_packed.frag
+++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag
@@ -69,6 +69,7 @@  uniform sampler2D red_param;
 uniform sampler2D green_param;
 uniform sampler2D blue_param;
 uniform mat3 ccm;
+uniform vec3 blacklevel;
 
 void main(void)
 {
@@ -217,6 +218,9 @@  void main(void)
 			vec3(patterns.wz, C));
 
 #if defined(APPLY_CCM_PARAMETERS)
+
+	rgb = rgb - blacklevel;
+
 	/*
 	 *   CCM is a 3x3 in the format
 	 *
diff --git a/include/libcamera/internal/shaders/bayer_unpacked.frag b/include/libcamera/internal/shaders/bayer_unpacked.frag
index b545fbbdc..ae214a9ae 100644
--- a/include/libcamera/internal/shaders/bayer_unpacked.frag
+++ b/include/libcamera/internal/shaders/bayer_unpacked.frag
@@ -28,6 +28,7 @@  varying vec4            center;
 varying vec4            yCoord;
 varying vec4            xCoord;
 uniform mat3		ccm;
+uniform vec3		blacklevel;
 
 void main(void) {
     vec3 rgb;
@@ -112,6 +113,9 @@  void main(void) {
             vec3(PATTERN.yx, C));
 
 #if defined(APPLY_CCM_PARAMETERS)
+
+	rgb = rgb - blacklevel;
+
 	/*
 	 *   CCM is a 3x3 in the format
 	 *