From 11f5c3ad0561a4e4b1e06f477ab2022c69803ad2 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 19 Oct 2022 02:34:13 +0300 Subject: ipa: ipu3: Fill AGC and AWB metadata in algorithms Fill the frame metadata in the AGC and AWB algorithm's prepare() function. This removes the need to fill metadata manually in the IPA module's processStatsBuffer() function. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/ipa/ipu3/algorithms/agc.cpp | 16 +++++++++++++++- src/ipa/ipu3/algorithms/awb.cpp | 10 ++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src/ipa/ipu3/algorithms') diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp index f4e559bf..b5309bdb 100644 --- a/src/ipa/ipu3/algorithms/agc.cpp +++ b/src/ipa/ipu3/algorithms/agc.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include "libipa/histogram.h" @@ -328,7 +329,7 @@ double Agc::estimateLuminance(IPAActiveState &activeState, void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, IPAFrameContext &frameContext, const ipu3_uapi_stats_3a *stats, - [[maybe_unused]] ControlList &metadata) + ControlList &metadata) { /* * Estimate the gain needed to have the proportion of pixels in a given @@ -365,6 +366,19 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, computeExposure(context, frameContext, yGain, iqMeanGain); frameCount_++; + + utils::Duration exposureTime = context.configuration.sensor.lineDuration + * frameContext.sensor.exposure; + metadata.set(controls::AnalogueGain, frameContext.sensor.gain); + metadata.set(controls::ExposureTime, exposureTime.get()); + + /* \todo Use VBlank value calculated from each frame exposure. */ + uint32_t vTotal = context.configuration.sensor.size.height + + context.configuration.sensor.defVBlank; + utils::Duration frameDuration = context.configuration.sensor.lineDuration + * vTotal; + metadata.set(controls::FrameDuration, frameDuration.get()); + } REGISTER_IPA_ALGORITHM(Agc, "Agc") diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp index 6452b6a1..dd7ebc07 100644 --- a/src/ipa/ipu3/algorithms/awb.cpp +++ b/src/ipa/ipu3/algorithms/awb.cpp @@ -11,6 +11,8 @@ #include +#include + /** * \file awb.h */ @@ -403,6 +405,14 @@ void Awb::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, context.activeState.awb.gains.green = asyncResults_.greenGain; context.activeState.awb.gains.red = asyncResults_.redGain; context.activeState.awb.temperatureK = asyncResults_.temperatureK; + + metadata.set(controls::AwbEnable, true); + metadata.set(controls::ColourGains, { + static_cast(context.activeState.awb.gains.red), + static_cast(context.activeState.awb.gains.blue) + }); + metadata.set(controls::ColourTemperature, + context.activeState.awb.temperatureK); } constexpr uint16_t Awb::threshold(float value) -- cgit v1.2.1