ipa: rpi: agc: Avoid overwriting caller's statistics pointer

The code was inadvertently overwriting the caller's StatisticsPtr,
meaning that subsequent algorithms would get the wrong image
statistics when AGC channels changed.

This could be fix using std::ref, though I find the C-style pointer
fix easier to understand!

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

View file

@ -311,15 +311,16 @@ void Agc::process(StatisticsPtr &stats, Metadata *imageMetadata)
* exist, and call process(). We must make the agc.status metadata record correctly * exist, and call process(). We must make the agc.status metadata record correctly
* which channel this is. * which channel this is.
*/ */
StatisticsPtr *statsPtr = &stats;
if (channelData.statistics && channelData.deviceStatus) { if (channelData.statistics && channelData.deviceStatus) {
deviceStatus = *channelData.deviceStatus; deviceStatus = *channelData.deviceStatus;
stats = channelData.statistics; statsPtr = &channelData.statistics;
} else { } else {
/* Can also happen when new channels start. */ /* Can also happen when new channels start. */
LOG(RPiAgc, Debug) << "process: channel " << channelIndex << " not seen yet"; LOG(RPiAgc, Debug) << "process: channel " << channelIndex << " not seen yet";
} }
channelData.channel.process(stats, deviceStatus, imageMetadata, channelTotalExposures_); channelData.channel.process(*statsPtr, deviceStatus, imageMetadata, channelTotalExposures_);
auto dur = setCurrentChannelIndexGetExposure(imageMetadata, "process: no AGC status found", auto dur = setCurrentChannelIndexGetExposure(imageMetadata, "process: no AGC status found",
channelIndex); channelIndex);
if (dur) if (dur)