[libcamera-devel,v1,3/7] ipa: ipu3: awb: Correct the gain multipliers
diff mbox series

Message ID 20210823124937.253539-4-jeanmichel.hautbois@ideasonboard.com
State Superseded
Headers show
Series
  • IPU3: AWB and AGC improvements
Related show

Commit Message

Jean-Michel Hautbois Aug. 23, 2021, 12:49 p.m. UTC
The gains have a precision u3.13, range [0, 8) which means that a gain
multiplier value of 1.0 is represented as a multiplication by 8192 in
the ImgU. Correct the gains as this was misunderstood in the first
place.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
---
 src/ipa/ipu3/algorithms/awb.cpp | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Laurent Pinchart Aug. 23, 2021, 4:06 p.m. UTC | #1
Hi Jean-Michel,

Thank you for the patch.

On Mon, Aug 23, 2021 at 02:49:33PM +0200, Jean-Michel Hautbois wrote:
> The gains have a precision u3.13, range [0, 8) which means that a gain
> multiplier value of 1.0 is represented as a multiplication by 8192 in
> the ImgU. Correct the gains as this was misunderstood in the first
> place.
> 
> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
> ---
>  src/ipa/ipu3/algorithms/awb.cpp | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp
> index 9497a21b..60a5fc52 100644
> --- a/src/ipa/ipu3/algorithms/awb.cpp
> +++ b/src/ipa/ipu3/algorithms/awb.cpp
> @@ -329,13 +329,12 @@ void Awb::prepare(IPAContext &context, ipu3_uapi_params *params)
>  							* params->acc_param.bnr.opt_center.y_reset;
>  	/*
>  	 * Green gains should not be touched and considered 1.

Is this line still relevant here, or should it be moved to
Awb::awbGreyWorld() where we hardcode asyncResults_.greenGain to 1.0 ?

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> -	 * Default is 16, so do not change it at all.
> -	 * 4096 is the value for a gain of 1.0
> +	 * 8192 is the multiplier for a gain of 1.0
>  	 */
> -	params->acc_param.bnr.wb_gains.gr = 16 * context.frameContext.awb.gains.green;
> -	params->acc_param.bnr.wb_gains.r = 4096 * context.frameContext.awb.gains.red;
> -	params->acc_param.bnr.wb_gains.b = 4096 * context.frameContext.awb.gains.blue;
> -	params->acc_param.bnr.wb_gains.gb = 16 * context.frameContext.awb.gains.green;
> +	params->acc_param.bnr.wb_gains.gr = 8192 * context.frameContext.awb.gains.green;
> +	params->acc_param.bnr.wb_gains.r = 8192 * context.frameContext.awb.gains.red;
> +	params->acc_param.bnr.wb_gains.b = 8192 * context.frameContext.awb.gains.blue;
> +	params->acc_param.bnr.wb_gains.gb = 8192 * context.frameContext.awb.gains.green;
>  
>  	LOG(IPU3Awb, Debug) << "Color temperature estimated: " << asyncResults_.temperatureK;
>

Patch
diff mbox series

diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp
index 9497a21b..60a5fc52 100644
--- a/src/ipa/ipu3/algorithms/awb.cpp
+++ b/src/ipa/ipu3/algorithms/awb.cpp
@@ -329,13 +329,12 @@  void Awb::prepare(IPAContext &context, ipu3_uapi_params *params)
 							* params->acc_param.bnr.opt_center.y_reset;
 	/*
 	 * Green gains should not be touched and considered 1.
-	 * Default is 16, so do not change it at all.
-	 * 4096 is the value for a gain of 1.0
+	 * 8192 is the multiplier for a gain of 1.0
 	 */
-	params->acc_param.bnr.wb_gains.gr = 16 * context.frameContext.awb.gains.green;
-	params->acc_param.bnr.wb_gains.r = 4096 * context.frameContext.awb.gains.red;
-	params->acc_param.bnr.wb_gains.b = 4096 * context.frameContext.awb.gains.blue;
-	params->acc_param.bnr.wb_gains.gb = 16 * context.frameContext.awb.gains.green;
+	params->acc_param.bnr.wb_gains.gr = 8192 * context.frameContext.awb.gains.green;
+	params->acc_param.bnr.wb_gains.r = 8192 * context.frameContext.awb.gains.red;
+	params->acc_param.bnr.wb_gains.b = 8192 * context.frameContext.awb.gains.blue;
+	params->acc_param.bnr.wb_gains.gb = 8192 * context.frameContext.awb.gains.green;
 
 	LOG(IPU3Awb, Debug) << "Color temperature estimated: " << asyncResults_.temperatureK;