libcamera: simple: Fix black level offsets in AWB

The black level offset subtracted in AWB is wrong.  It assumes that the
stats contain sums of the individual colour pixels.  But they actually
contain sums of the colour channels of larger "superpixels" consisting
of the individual colour pixels.  Each of the RGB colour values and the
computed luminosity (a histogram entry) are added once to the stats per
such a superpixel.  This means the offset computed from the black level
and the number of pixels should be used as it is, not divided.

The patch fixes the subtracted offset.  Since the evaluation is the same
for all the three colours now, the individual class variables are
replaced with a single RGB variable.

Fixes: 4e13c6f55b ("Honor black level in AWB")
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Robert Mader <robert.mader@collabora.com>
Tested-by: Robert Mader <robert.mader@collabora.com>
Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Milan Zamazal
2026-01-27 21:47:11 +01:00
committed by Kieran Bingham
parent 10e4e5ba1e
commit 07240afa12
3 changed files with 17 additions and 23 deletions
@@ -10,6 +10,8 @@
#include <array>
#include <stdint.h>
#include "libcamera/internal/vector.h"
namespace libcamera {
/**
@@ -26,17 +28,9 @@ struct SwIspStats {
*/
bool valid;
/**
* \brief Holds the sum of all sampled red pixels
* \brief Sums of colour channels of all the sampled pixels
*/
uint64_t sumR_;
/**
* \brief Holds the sum of all sampled green pixels
*/
uint64_t sumG_;
/**
* \brief Holds the sum of all sampled blue pixels
*/
uint64_t sumB_;
RGB<uint64_t> sum_;
/**
* \brief Number of bins in the yHistogram
*/
@@ -46,7 +40,7 @@ struct SwIspStats {
*/
using Histogram = std::array<uint32_t, kYHistogramSize>;
/**
* \brief A histogram of luminance values
* \brief A histogram of luminance values of all the sampled pixels
*/
Histogram yHistogram;
};