ipa: rpi: Prepare ALSC for PiSP support

Prepare the ALSC algorithm to support the PiSP hardware. The key change
is to avoid factoring out the WB correction in the AWB zone statistics.

Add the ALSC correction to the global metadata so that AWB can use it to
factor the gains back in for the AWB calculations.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Naushir Patuck 2023-10-13 08:48:30 +01:00 committed by Kieran Bingham
parent 56ca5091de
commit 0be32012ef

View file

@ -348,9 +348,11 @@ static void copyStats(RgbyRegions &regions, StatisticsPtr &stats,
const std::vector<double> &bTable = status.b; const std::vector<double> &bTable = status.b;
for (unsigned int i = 0; i < stats->awbRegions.numRegions(); i++) { for (unsigned int i = 0; i < stats->awbRegions.numRegions(); i++) {
auto r = stats->awbRegions.get(i); auto r = stats->awbRegions.get(i);
if (stats->colourStatsPos == Statistics::ColourStatsPos::PostLsc) {
r.val.rSum = static_cast<uint64_t>(r.val.rSum / rTable[i]); r.val.rSum = static_cast<uint64_t>(r.val.rSum / rTable[i]);
r.val.gSum = static_cast<uint64_t>(r.val.gSum / gTable[i]); r.val.gSum = static_cast<uint64_t>(r.val.gSum / gTable[i]);
r.val.bSum = static_cast<uint64_t>(r.val.bSum / bTable[i]); r.val.bSum = static_cast<uint64_t>(r.val.bSum / bTable[i]);
}
regions.set(i, r); regions.set(i, r);
} }
} }
@ -368,7 +370,8 @@ void Alsc::restartAsync(StatisticsPtr &stats, Metadata *imageMetadata)
* the LSC table that the pipeline applied to them. * the LSC table that the pipeline applied to them.
*/ */
AlscStatus alscStatus; AlscStatus alscStatus;
if (imageMetadata->get("alsc.status", alscStatus) != 0) { if (stats->colourStatsPos == Statistics::ColourStatsPos::PostLsc &&
imageMetadata->get("alsc.status", alscStatus) != 0) {
LOG(RPiAlsc, Warning) LOG(RPiAlsc, Warning)
<< "No ALSC status found for applied gains!"; << "No ALSC status found for applied gains!";
alscStatus.r.resize(config_.tableSize.width * config_.tableSize.height, 1.0); alscStatus.r.resize(config_.tableSize.width * config_.tableSize.height, 1.0);
@ -414,6 +417,11 @@ void Alsc::prepare(Metadata *imageMetadata)
status.g = prevSyncResults_[1].data(); status.g = prevSyncResults_[1].data();
status.b = prevSyncResults_[2].data(); status.b = prevSyncResults_[2].data();
imageMetadata->set("alsc.status", status); imageMetadata->set("alsc.status", status);
/*
* Put the results in the global metadata as well. This will be used by
* AWB to factor in the colour shading correction.
*/
getGlobalMetadata().set("alsc.status", status);
} }
void Alsc::process(StatisticsPtr &stats, Metadata *imageMetadata) void Alsc::process(StatisticsPtr &stats, Metadata *imageMetadata)