summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>2022-02-24 16:11:13 +0100
committerUmang Jain <umang.jain@ideasonboard.com>2022-03-11 20:47:51 +0530
commite41854a4e6fde2dd9e2a2a7290670943235776cd (patch)
tree5a9c00e19082351427306d1c69bf89cd43094052 /src
parentb5d2adbeabeacdba6e887de2aef39aa320f4abe1 (diff)
ipa: ipu3: awb: Clamp gain values
The gain values are coded as u3.13 fixed point values, ie they can not be more than 8. Clamp the values in order to avoid any off limits value which could make the IPU3 behave in a weird manner. Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/ipa/ipu3/algorithms/awb.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp
index 1dc27fc9..87a6cc7a 100644
--- a/src/ipa/ipu3/algorithms/awb.cpp
+++ b/src/ipa/ipu3/algorithms/awb.cpp
@@ -353,6 +353,14 @@ void Awb::awbGreyWorld()
/* Color temperature is not relevant in Grey world but still useful to estimate it :-) */
asyncResults_.temperatureK = estimateCCT(sumRed.R, sumRed.G, sumBlue.B);
+
+ /*
+ * Gain values are unsigned integer value ranging [0, 8) with 13 bit
+ * fractional part.
+ */
+ redGain = std::clamp(redGain, 0.0, 65535.0 / 8192);
+ blueGain = std::clamp(blueGain, 0.0, 65535.0 / 8192);
+
asyncResults_.redGain = redGain;
/* Hardcode the green gain to 1.0. */
asyncResults_.greenGain = 1.0;