libcamera: software_isp: Add valid flag to struct SwIspStats

Generating statistics for every single frame is not really necessary.

However a roundtrip through ipa_->processStats() still need to be done
every frame, even if there are no stats to make the IPA generate metadata
for every frame.

Add a valid flag to the statistics struct to let the IPA know when there
are no statistics for the frame being processed and modify the IPA to
only generate metadata for frames without valid statistics.

This is a preparation patch for skipping statistics generation for some
frames.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Milan Zamazal <mzamazal@redhat.com>
Tested-by: Milan Zamazal <mzamazal@redhat.com>
Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Hans de Goede <hansg@kernel.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Hans de Goede
2025-09-30 17:04:27 +02:00
committed by Kieran Bingham
parent b5c89375f9
commit 9b441cf198
6 changed files with 40 additions and 1 deletions
+23 -1
View File
@@ -91,13 +91,16 @@ void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, dou
again = std::clamp(again, context.configuration.agc.againMin,
context.configuration.agc.againMax);
context.activeState.agc.exposure = exposure;
context.activeState.agc.again = again;
LOG(IPASoftExposure, Debug)
<< "exposureMSV " << exposureMSV
<< " exp " << exposure << " again " << again;
}
void Agc::process(IPAContext &context,
[[maybe_unused]] const uint32_t frame,
const uint32_t frame,
IPAFrameContext &frameContext,
const SwIspStats *stats,
ControlList &metadata)
@@ -107,6 +110,25 @@ void Agc::process(IPAContext &context,
metadata.set(controls::ExposureTime, exposureTime.get<std::micro>());
metadata.set(controls::AnalogueGain, frameContext.sensor.gain);
if (frame == 0) {
/*
* Init active-state from sensor values in case updateExposure()
* does not run for the first frame.
*/
context.activeState.agc.exposure = frameContext.sensor.exposure;
context.activeState.agc.again = frameContext.sensor.gain;
}
if (!stats->valid) {
/*
* Use the new exposure and gain values calculated the last time
* there were valid stats.
*/
frameContext.sensor.exposure = context.activeState.agc.exposure;
frameContext.sensor.gain = context.activeState.agc.again;
return;
}
/*
* Calculate Mean Sample Value (MSV) according to formula from:
* https://www.araa.asn.au/acra/acra2007/papers/paper84final.pdf