ipa: simple: awb: Fix ColourGains reported
diff mbox series

Message ID 20251215200614.41329-1-kieran.bingham@ideasonboard.com
State New
Headers show
Series
  • ipa: simple: awb: Fix ColourGains reported
Related show

Commit Message

Kieran Bingham Dec. 15, 2025, 8:06 p.m. UTC
The AWB gains reported in the metadata are currently scaled against the
maximum gain, but in fact the gain itself is already stored as a
floating point gain value.

Remove the incorrect scaling and report the gains directly.

Fixes: a0b97475b1c0 ("ipa: simple: Report the ColourGains in metadata")
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/ipa/simple/algorithms/awb.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Kieran Bingham Dec. 15, 2025, 8:22 p.m. UTC | #1
Quoting Kieran Bingham (2025-12-15 20:06:14)
> The AWB gains reported in the metadata are currently scaled against the
> maximum gain, but in fact the gain itself is already stored as a
> floating point gain value.
> 
> Remove the incorrect scaling and report the gains directly.
> 
> Fixes: a0b97475b1c0 ("ipa: simple: Report the ColourGains in metadata")
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  src/ipa/simple/algorithms/awb.cpp | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp
> index cf78e980098b..0080865aa34d 100644
> --- a/src/ipa/simple/algorithms/awb.cpp
> +++ b/src/ipa/simple/algorithms/awb.cpp
> @@ -55,10 +55,9 @@ void Awb::process(IPAContext &context,
>         const SwIspStats::Histogram &histogram = stats->yHistogram;
>         const uint8_t blackLevel = context.activeState.blc.level;
>  
> -       const float maxGain = 1024.0;
>         const float mdGains[] = {
> -               static_cast<float>(frameContext.gains.red / maxGain),
> -               static_cast<float>(frameContext.gains.blue / maxGain)
> +               static_cast<float>(frameContext.gains.red),
> +               static_cast<float>(frameContext.gains.blue)

Looks like the gains are a double for some reason. I think they could
probably be reduced to a float sometime and simplify this - but that's a
later patch.
--
Kieran

>         };
>         metadata.set(controls::ColourGains, mdGains);
>  
> -- 
> 2.52.0
>
Milan Zamazal Dec. 15, 2025, 8:52 p.m. UTC | #2
Kieran Bingham <kieran.bingham@ideasonboard.com> writes:

> Quoting Kieran Bingham (2025-12-15 20:06:14)
>> The AWB gains reported in the metadata are currently scaled against the
>> maximum gain, but in fact the gain itself is already stored as a
>
>> floating point gain value.
>> 
>> Remove the incorrect scaling and report the gains directly.
>> 
>> Fixes: a0b97475b1c0 ("ipa: simple: Report the ColourGains in metadata")
>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>> ---
>>  src/ipa/simple/algorithms/awb.cpp | 5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>> 
>> diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp
>> index cf78e980098b..0080865aa34d 100644
>> --- a/src/ipa/simple/algorithms/awb.cpp
>> +++ b/src/ipa/simple/algorithms/awb.cpp
>> @@ -55,10 +55,9 @@ void Awb::process(IPAContext &context,
>>         const SwIspStats::Histogram &histogram = stats->yHistogram;
>>         const uint8_t blackLevel = context.activeState.blc.level;
>>  
>> -       const float maxGain = 1024.0;
>>         const float mdGains[] = {
>> -               static_cast<float>(frameContext.gains.red / maxGain),
>> -               static_cast<float>(frameContext.gains.blue / maxGain)
>> +               static_cast<float>(frameContext.gains.red),
>> +               static_cast<float>(frameContext.gains.blue)
>
> Looks like the gains are a double for some reason. I think they could
> probably be reduced to a float sometime and simplify this - but that's a
> later patch.

It's done in my simple IPA refactoring patches, so no need to worry
about it other than dropping the type casting above.  (I'm always
confused whether to use double or float for values like these unless
there is some very obvious reason; is there any rule of thumb?)

Anyway, for this patch:

Reviewed-by: Milan Zamazal <mzamazal@redhat.com>

> --
> Kieran
>
>>         };
>>         metadata.set(controls::ColourGains, mdGains);
>>  
>> -- 
>> 2.52.0
>>

Patch
diff mbox series

diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp
index cf78e980098b..0080865aa34d 100644
--- a/src/ipa/simple/algorithms/awb.cpp
+++ b/src/ipa/simple/algorithms/awb.cpp
@@ -55,10 +55,9 @@  void Awb::process(IPAContext &context,
 	const SwIspStats::Histogram &histogram = stats->yHistogram;
 	const uint8_t blackLevel = context.activeState.blc.level;
 
-	const float maxGain = 1024.0;
 	const float mdGains[] = {
-		static_cast<float>(frameContext.gains.red / maxGain),
-		static_cast<float>(frameContext.gains.blue / maxGain)
+		static_cast<float>(frameContext.gains.red),
+		static_cast<float>(frameContext.gains.blue)
 	};
 	metadata.set(controls::ColourGains, mdGains);