libcamera: software_isp: Use floating point for color parameters

It's more natural to represent color gains as floating point numbers
rather than using a particular pixel-related representation.

double is used rather than float because it's a more common floating
point type in libcamera algorithms.  Otherwise there is no obvious
reason to select one over the other here.

The constructed color tables still use integer representation for
efficiency.

Black level still uses pixel (integer) values, for consistency with
other libcamera parts.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Milan Zamazal 2024-09-27 15:46:21 +02:00 committed by Kieran Bingham
parent 7fab2062d8
commit 8c84efa486
3 changed files with 15 additions and 13 deletions

View file

@ -24,7 +24,7 @@ int Awb::configure(IPAContext &context,
[[maybe_unused]] const IPAConfigInfo &configInfo)
{
auto &gains = context.activeState.gains;
gains.red = gains.green = gains.blue = 256;
gains.red = gains.green = gains.blue = 1.0;
return 0;
}
@ -53,12 +53,11 @@ void Awb::process(IPAContext &context,
/*
* Calculate red and blue gains for AWB.
* Clamp max gain at 4.0, this also avoids 0 division.
* Gain: 128 = 0.5, 256 = 1.0, 512 = 2.0, etc.
*/
auto &gains = context.activeState.gains;
gains.red = sumR <= sumG / 4 ? 1024 : 256 * sumG / sumR;
gains.blue = sumB <= sumG / 4 ? 1024 : 256 * sumG / sumB;
/* Green gain is fixed to 256 */
gains.red = sumR <= sumG / 4 ? 4.0 : static_cast<double>(sumG) / sumR;
gains.blue = sumB <= sumG / 4 ? 4.0 : static_cast<double>(sumG) / sumB;
/* Green gain is fixed to 1.0 */
LOG(IPASoftAwb, Debug) << "gain R/B " << gains.red << "/" << gains.blue;
}