| Message ID | 20260621-kbingham-awb-saturation-v1-4-b91ea59c6cfb@ideasonboard.com |
|---|---|
| State | Accepted |
| Headers | show |
| Series |
|
| Related | show |
Quoting Kieran Bingham (2026-06-21 00:00:31) > From: Milan Zamazal <mzamazal@redhat.com> > > In GPU ISP fragment shaders, the black level is simply subtracted from > the pixel value. This means the highest pixel values can never be > reached, possibly resulting in wrong brightness or colour shifts. Fix > this by spreading the resulting value to the whole 0.0..1.0 range. > > The preceding simple pipeline IPA patch ensures `blacklevel' is less > than 1.0, preventing division by zero here. > > Signed-off-by: Milan Zamazal <mzamazal@redhat.com> > Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> [Kieran: Add todo comment] Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > --- > src/libcamera/shaders/bayer_1x_packed.frag | 6 +++++- > src/libcamera/shaders/bayer_unpacked.frag | 6 +++++- > 2 files changed, 10 insertions(+), 2 deletions(-) > > diff --git a/src/libcamera/shaders/bayer_1x_packed.frag b/src/libcamera/shaders/bayer_1x_packed.frag > index 23747f78a6313503a46b61ed5bae6e7c178c5745..fbd15b32e5b3b510ba0dd5a75704f9ff3942e00c 100644 > --- a/src/libcamera/shaders/bayer_1x_packed.frag > +++ b/src/libcamera/shaders/bayer_1x_packed.frag > @@ -225,7 +225,11 @@ void main(void) > vec3(patterns.y, C, patterns.x) : > vec3(patterns.wz, C)); > > - rgb = rgb - blacklevel; > + /* > + * \todo: Black level normalising, AWB and digital gain could be > + * reworked into a single multiplication. > + */ > + rgb = (rgb - blacklevel) / (1.0 - blacklevel); > > /* > * CCM is a 3x3 in the format > diff --git a/src/libcamera/shaders/bayer_unpacked.frag b/src/libcamera/shaders/bayer_unpacked.frag > index 1b85196ae16130670eb3d1c077ab4884119ae63c..0f85e9a4ded7f43ce4fdabf1e045275ae2bc8f53 100644 > --- a/src/libcamera/shaders/bayer_unpacked.frag > +++ b/src/libcamera/shaders/bayer_unpacked.frag > @@ -128,7 +128,11 @@ void main(void) { > vec3(PATTERN.w, C, PATTERN.z) : > vec3(PATTERN.yx, C)); > > - rgb = rgb - blacklevel; > + /* > + * \todo: Black level normalising, AWB and digital gain could be > + * reworked into a single multiplication. > + */ > + rgb = (rgb - blacklevel) / (1.0 - blacklevel); > > /* > * CCM is a 3x3 in the format > > -- > 2.53.0 >
diff --git a/src/libcamera/shaders/bayer_1x_packed.frag b/src/libcamera/shaders/bayer_1x_packed.frag index 23747f78a6313503a46b61ed5bae6e7c178c5745..fbd15b32e5b3b510ba0dd5a75704f9ff3942e00c 100644 --- a/src/libcamera/shaders/bayer_1x_packed.frag +++ b/src/libcamera/shaders/bayer_1x_packed.frag @@ -225,7 +225,11 @@ void main(void) vec3(patterns.y, C, patterns.x) : vec3(patterns.wz, C)); - rgb = rgb - blacklevel; + /* + * \todo: Black level normalising, AWB and digital gain could be + * reworked into a single multiplication. + */ + rgb = (rgb - blacklevel) / (1.0 - blacklevel); /* * CCM is a 3x3 in the format diff --git a/src/libcamera/shaders/bayer_unpacked.frag b/src/libcamera/shaders/bayer_unpacked.frag index 1b85196ae16130670eb3d1c077ab4884119ae63c..0f85e9a4ded7f43ce4fdabf1e045275ae2bc8f53 100644 --- a/src/libcamera/shaders/bayer_unpacked.frag +++ b/src/libcamera/shaders/bayer_unpacked.frag @@ -128,7 +128,11 @@ void main(void) { vec3(PATTERN.w, C, PATTERN.z) : vec3(PATTERN.yx, C)); - rgb = rgb - blacklevel; + /* + * \todo: Black level normalising, AWB and digital gain could be + * reworked into a single multiplication. + */ + rgb = (rgb - blacklevel) / (1.0 - blacklevel); /* * CCM is a 3x3 in the format