[3/7] ipa: simple: Limit the black level value
diff mbox series

Message ID 20260621-kbingham-awb-saturation-v1-3-b91ea59c6cfb@ideasonboard.com
State New
Headers show
Series
  • softisp: Fix Saturation and Black level handling
Related show

Commit Message

Kieran Bingham June 20, 2026, 11 p.m. UTC
From: Milan Zamazal <mzamazal@redhat.com>

The black level value is passed to image processing, where it's used in
pixel value computations.  To avoid troubles with weird black level
values (which are mostly theoretical but we should be still safe against
e.g. crazy values in testing tuning files) like division by zero, let's
make sure the black level passed to the image processing is lower than
the maximum pixel value.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/ipa/simple/algorithms/blc.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp
index 677be56ed6699ae8aaa8a786ab16f7299a82eb46..058cb372620134cb15a0655d3553b3b767b47f0e 100644
--- a/src/ipa/simple/algorithms/blc.cpp
+++ b/src/ipa/simple/algorithms/blc.cpp
@@ -1,6 +1,6 @@ 
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 /*
- * Copyright (C) 2024-2025, Red Hat Inc.
+ * Copyright (C) 2024-2026, Red Hat Inc.
  *
  * Black level handling
  */
@@ -52,8 +52,9 @@  void BlackLevel::prepare(IPAContext &context,
 			 [[maybe_unused]] IPAFrameContext &frameContext,
 			 DebayerParams *params)
 {
-	/* Latch the blacklevel gain so GPUISP can apply. */
-	params->blackLevel = RGB<float>(context.activeState.blc.level / 255.0f);
+	/* Make sure the black level is sane, i.e. below maximum pixel value. */
+	params->blackLevel = RGB<float>(context.activeState.blc.level / 255.0f)
+				     .min(0.99);
 }
 
 void BlackLevel::process(IPAContext &context,