ipa: Pass metadata to Algorithm::process() function

Extend the Algorithm::process() function with a metadata control list,
to be filled by individual algorithms with frame metadata. Update the
rkisp1 and ipu3 IPA modules accordingly, and drop the dead code in the
IPARkISP1::prepareMetadata() function while at it.

This only creates the infrastructure, filling metadata in individual
algorithms will be handled separately.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Laurent Pinchart 2022-10-05 12:46:03 +03:00
parent dac1a0549a
commit c20ca6587d
16 changed files with 44 additions and 37 deletions

View file

@ -409,6 +409,7 @@ bool Af::afIsOutOfFocus(IPAContext &context)
* \param[in] frame The frame context sequence number
* \param[in] frameContext The current frame context
* \param[in] stats The statistics buffer of IPU3
* \param[out] metadata Metadata for the frame, to be filled by the algorithm
*
* Ideally, a clear image also has a relatively higher contrast. So, every
* image for each focus step should be tested to find an optimal focus step.
@ -423,7 +424,8 @@ bool Af::afIsOutOfFocus(IPAContext &context)
*/
void Af::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
[[maybe_unused]] IPAFrameContext &frameContext,
const ipu3_uapi_stats_3a *stats)
const ipu3_uapi_stats_3a *stats,
[[maybe_unused]] ControlList &metadata)
{
/* Evaluate the AF buffer length */
uint32_t afRawBufferLen = context.configuration.af.afGrid.width *

View file

@ -36,7 +36,8 @@ public:
ipu3_uapi_params *params) override;
void process(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameContext,
const ipu3_uapi_stats_3a *stats) override;
const ipu3_uapi_stats_3a *stats,
ControlList &metadata) override;
private:
void afCoarseScan(IPAContext &context);

View file

@ -320,13 +320,15 @@ double Agc::estimateLuminance(IPAActiveState &activeState,
* \param[in] frame The current frame sequence number
* \param[in] frameContext The current frame context
* \param[in] stats The IPU3 statistics and ISP results
* \param[out] metadata Metadata for the frame, to be filled by the algorithm
*
* Identify the current image brightness, and use that to estimate the optimal
* new exposure and gain for the scene.
*/
void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
IPAFrameContext &frameContext,
const ipu3_uapi_stats_3a *stats)
const ipu3_uapi_stats_3a *stats,
[[maybe_unused]] ControlList &metadata)
{
/*
* Estimate the gain needed to have the proportion of pixels in a given

View file

@ -30,7 +30,8 @@ public:
int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
void process(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameContext,
const ipu3_uapi_stats_3a *stats) override;
const ipu3_uapi_stats_3a *stats,
ControlList &metadata) override;
private:
double measureBrightness(const ipu3_uapi_stats_3a *stats,

View file

@ -389,7 +389,8 @@ void Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats)
*/
void Awb::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
[[maybe_unused]] IPAFrameContext &frameContext,
const ipu3_uapi_stats_3a *stats)
const ipu3_uapi_stats_3a *stats,
[[maybe_unused]] ControlList &metadata)
{
calculateWBGains(stats);

View file

@ -44,7 +44,8 @@ public:
ipu3_uapi_params *params) override;
void process(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameContext,
const ipu3_uapi_stats_3a *stats) override;
const ipu3_uapi_stats_3a *stats,
ControlList &metadata) override;
private:
/* \todo Make these structs available to all the ISPs ? */

View file

@ -79,13 +79,15 @@ void ToneMapping::prepare([[maybe_unused]] IPAContext &context,
* \param[in] frame The current frame sequence number
* \param[in] frameContext The current frame context
* \param[in] stats The IPU3 statistics and ISP results
* \param[out] metadata Metadata for the frame, to be filled by the algorithm
*
* The tone mapping look up table is generated as an inverse power curve from
* our gamma setting.
*/
void ToneMapping::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
[[maybe_unused]] IPAFrameContext &frameContext,
[[maybe_unused]] const ipu3_uapi_stats_3a *stats)
[[maybe_unused]] const ipu3_uapi_stats_3a *stats,
[[maybe_unused]] ControlList &metadata)
{
/*
* Hardcode gamma to 1.1 as a default for now.

View file

@ -23,7 +23,8 @@ public:
IPAFrameContext &frameContext, ipu3_uapi_params *params) override;
void process(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameContext,
const ipu3_uapi_stats_3a *stats) override;
const ipu3_uapi_stats_3a *stats,
ControlList &metadata) override;
private:
double gamma_;

View file

@ -630,22 +630,22 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame,
double lineDuration = context_.configuration.sensor.lineDuration.get<std::micro>();
int32_t vBlank = context_.configuration.sensor.defVBlank;
ControlList ctrls(controls::controls);
ControlList metadata(controls::controls);
for (auto const &algo : algorithms())
algo->process(context_, frame, frameContext, stats);
algo->process(context_, frame, frameContext, stats, metadata);
setControls(frame);
/* \todo Use VBlank value calculated from each frame exposure. */
int64_t frameDuration = (vBlank + sensorInfo_.outputSize.height) * lineDuration;
ctrls.set(controls::FrameDuration, frameDuration);
metadata.set(controls::FrameDuration, frameDuration);
ctrls.set(controls::AnalogueGain, frameContext.sensor.gain);
metadata.set(controls::AnalogueGain, frameContext.sensor.gain);
ctrls.set(controls::ColourTemperature, context_.activeState.awb.temperatureK);
metadata.set(controls::ColourTemperature, context_.activeState.awb.temperatureK);
ctrls.set(controls::ExposureTime, frameContext.sensor.exposure * lineDuration);
metadata.set(controls::ExposureTime, frameContext.sensor.exposure * lineDuration);
/*
* \todo The Metadata provides a path to getting extended data
@ -655,7 +655,7 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame,
* likely want to avoid putting platform specific metadata in.
*/
metadataReady.emit(frame, ctrls);
metadataReady.emit(frame, metadata);
}
/**

View file

@ -107,11 +107,12 @@ namespace ipa {
* \param[in] frame The frame context sequence number
* \param[in] frameContext The current frame's context
* \param[in] stats The IPA statistics and ISP results
* \param[out] metadata Metadata for the frame, to be filled by the algorithm
*
* This function is called while camera is running for every frame processed by
* the ISP, to process statistics generated from that frame by the ISP.
* Algorithms shall use this data to run calculations and update their state
* accordingly.
* Algorithms shall use this data to run calculations, update their state
* accordingly, and fill the frame metadata.
*
* Processing shall not take an undue amount of time, and any extended or
* computationally expensive calculations or operations must be handled

View file

@ -55,7 +55,8 @@ public:
virtual void process([[maybe_unused]] typename Module::Context &context,
[[maybe_unused]] const uint32_t frame,
[[maybe_unused]] typename Module::FrameContext &frameContext,
[[maybe_unused]] const typename Module::Stats *stats)
[[maybe_unused]] const typename Module::Stats *stats,
[[maybe_unused]] ControlList &metadata)
{
}
};

View file

@ -283,12 +283,14 @@ double Agc::measureBrightness(const rkisp1_cif_isp_hist_stat *hist) const
* \param[in] frame The frame context sequence number
* \param[in] frameContext The current frame context
* \param[in] stats The RKISP1 statistics and ISP results
* \param[out] metadata Metadata for the frame, to be filled by the algorithm
*
* Identify the current image brightness, and use that to estimate the optimal
* new exposure and gain for the scene.
*/
void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
IPAFrameContext &frameContext, const rkisp1_stat_buffer *stats)
IPAFrameContext &frameContext, const rkisp1_stat_buffer *stats,
[[maybe_unused]] ControlList &metadata)
{
/*
* \todo Verify that the exposure and gain applied by the sensor for

View file

@ -31,7 +31,8 @@ public:
rkisp1_params_cfg *params) override;
void process(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameContext,
const rkisp1_stat_buffer *stats) override;
const rkisp1_stat_buffer *stats,
ControlList &metadata) override;
private:
void computeExposure(IPAContext &Context, IPAFrameContext &frameContext,

View file

@ -208,7 +208,8 @@ void Awb::queueRequest(IPAContext &context,
void Awb::process(IPAContext &context,
[[maybe_unused]] const uint32_t frame,
IPAFrameContext &frameContext,
const rkisp1_stat_buffer *stats)
const rkisp1_stat_buffer *stats,
[[maybe_unused]] ControlList &metadata)
{
const rkisp1_cif_isp_stat *params = &stats->params;
const rkisp1_cif_isp_awb_stat *awb = &params->awb;

View file

@ -27,8 +27,9 @@ public:
IPAFrameContext &frameContext,
const ControlList &controls) override;
void process(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameCtx,
const rkisp1_stat_buffer *stats) override;
IPAFrameContext &frameContext,
const rkisp1_stat_buffer *stats,
ControlList &metadata) override;
private:
uint32_t estimateCCT(double red, double green, double blue);

View file

@ -69,7 +69,6 @@ protected:
private:
void setControls(unsigned int frame);
void prepareMetadata(unsigned int frame, unsigned int aeState);
std::map<unsigned int, FrameBuffer> buffers_;
std::map<unsigned int, MappedFrameBuffer> mappedBuffers_;
@ -338,14 +337,14 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId
frameContext.sensor.gain =
camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());
unsigned int aeState = 0;
ControlList metadata(controls::controls);
for (auto const &algo : algorithms())
algo->process(context_, frame, frameContext, stats);
algo->process(context_, frame, frameContext, stats, metadata);
setControls(frame);
prepareMetadata(frame, aeState);
metadataReady.emit(frame, metadata);
}
void IPARkISP1::setControls(unsigned int frame)
@ -366,16 +365,6 @@ void IPARkISP1::setControls(unsigned int frame)
setSensorControls.emit(frame, ctrls);
}
void IPARkISP1::prepareMetadata(unsigned int frame, unsigned int aeState)
{
ControlList ctrls(controls::controls);
if (aeState)
ctrls.set(controls::AeLocked, aeState == 2);
metadataReady.emit(frame, ctrls);
}
} /* namespace ipa::rkisp1 */
/*