ipa: libipa: algorithm: prepare(): Pass frame and frame Context
Pass the current frame number, and the current FrameContext for calls to prepare. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> 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:
committed by
Laurent Pinchart
parent
ef447647b6
commit
87d36de543
@@ -116,7 +116,10 @@ Af::Af()
|
||||
/**
|
||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||
*/
|
||||
void Af::prepare(IPAContext &context, ipu3_uapi_params *params)
|
||||
void Af::prepare(IPAContext &context,
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||
ipu3_uapi_params *params)
|
||||
{
|
||||
const struct ipu3_uapi_grid_config &grid = context.configuration.af.afGrid;
|
||||
params->acc_param.af.grid_cfg = grid;
|
||||
|
||||
@@ -30,8 +30,10 @@ public:
|
||||
Af();
|
||||
~Af() = default;
|
||||
|
||||
void prepare(IPAContext &context, ipu3_uapi_params *params) override;
|
||||
int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
|
||||
void prepare(IPAContext &context, const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
ipu3_uapi_params *params) override;
|
||||
void process(IPAContext &context, IPAFrameContext &frameContext,
|
||||
const ipu3_uapi_stats_3a *stats) override;
|
||||
|
||||
|
||||
@@ -429,7 +429,10 @@ constexpr uint16_t Awb::gainValue(double gain)
|
||||
/**
|
||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||
*/
|
||||
void Awb::prepare(IPAContext &context, ipu3_uapi_params *params)
|
||||
void Awb::prepare(IPAContext &context,
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||
ipu3_uapi_params *params)
|
||||
{
|
||||
/*
|
||||
* Green saturation thresholds are reduced because we are using the
|
||||
|
||||
@@ -39,7 +39,9 @@ public:
|
||||
~Awb();
|
||||
|
||||
int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
|
||||
void prepare(IPAContext &context, ipu3_uapi_params *params) override;
|
||||
void prepare(IPAContext &context, const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
ipu3_uapi_params *params) override;
|
||||
void process(IPAContext &context, IPAFrameContext &frameContext,
|
||||
const ipu3_uapi_stats_3a *stats) override;
|
||||
|
||||
|
||||
@@ -39,13 +39,17 @@ BlackLevelCorrection::BlackLevelCorrection()
|
||||
/**
|
||||
* \brief Fill in the parameter structure, and enable black level correction
|
||||
* \param[in] context The shared IPA context
|
||||
* \param[in] frame The frame context sequence number
|
||||
* \param[in] frameContext The FrameContext for this frame
|
||||
* \param[out] params The IPU3 parameters
|
||||
*
|
||||
* Populate the IPU3 parameter structure with the correction values for each
|
||||
* channel and enable the corresponding ImgU block processing.
|
||||
*/
|
||||
void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,
|
||||
ipu3_uapi_params *params)
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||
ipu3_uapi_params *params)
|
||||
{
|
||||
/*
|
||||
* The Optical Black Level correction values
|
||||
|
||||
@@ -18,7 +18,9 @@ class BlackLevelCorrection : public Algorithm
|
||||
public:
|
||||
BlackLevelCorrection();
|
||||
|
||||
void prepare(IPAContext &context, ipu3_uapi_params *params) override;
|
||||
void prepare(IPAContext &context, const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
ipu3_uapi_params *params) override;
|
||||
};
|
||||
|
||||
} /* namespace ipa::ipu3::algorithms */
|
||||
|
||||
@@ -50,12 +50,16 @@ int ToneMapping::configure(IPAContext &context,
|
||||
/**
|
||||
* \brief Fill in the parameter structure, and enable gamma control
|
||||
* \param[in] context The shared IPA context
|
||||
* \param[in] frame The frame context sequence number
|
||||
* \param[in] frameContext The FrameContext for this frame
|
||||
* \param[out] params The IPU3 parameters
|
||||
*
|
||||
* Populate the IPU3 parameter structure with our tone mapping look up table and
|
||||
* enable the gamma control module in the processing blocks.
|
||||
*/
|
||||
void ToneMapping::prepare([[maybe_unused]] IPAContext &context,
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||
ipu3_uapi_params *params)
|
||||
{
|
||||
/* Copy the calculated LUT into the parameters buffer. */
|
||||
|
||||
@@ -19,7 +19,8 @@ public:
|
||||
ToneMapping();
|
||||
|
||||
int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
|
||||
void prepare(IPAContext &context, ipu3_uapi_params *params) override;
|
||||
void prepare(IPAContext &context, const uint32_t frame,
|
||||
IPAFrameContext &frameContext, ipu3_uapi_params *params) override;
|
||||
void process(IPAContext &context, IPAFrameContext &frameContext,
|
||||
const ipu3_uapi_stats_3a *stats) override;
|
||||
|
||||
|
||||
@@ -572,8 +572,10 @@ void IPAIPU3::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)
|
||||
*/
|
||||
params->use = {};
|
||||
|
||||
IPAFrameContext &frameContext = context_.frameContexts[frame % kMaxFrameContexts];
|
||||
|
||||
for (auto const &algo : algorithms())
|
||||
algo->prepare(context_, params);
|
||||
algo->prepare(context_, frame, frameContext, params);
|
||||
|
||||
paramsBufferReady.emit(frame);
|
||||
}
|
||||
|
||||
@@ -70,6 +70,8 @@ namespace ipa {
|
||||
* \fn Algorithm::prepare()
|
||||
* \brief Fill the \a params buffer with ISP processing parameters for a frame
|
||||
* \param[in] context The shared IPA context
|
||||
* \param[in] frame The frame context sequence number
|
||||
* \param[in] frameContext The FrameContext for this frame
|
||||
* \param[out] params The ISP specific parameters.
|
||||
*
|
||||
* This function is called for every frame when the camera is running before it
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
|
||||
#include <libcamera/controls.h>
|
||||
@@ -38,6 +39,8 @@ public:
|
||||
}
|
||||
|
||||
virtual void prepare([[maybe_unused]] typename Module::Context &context,
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
[[maybe_unused]] typename Module::FrameContext &frameContext,
|
||||
[[maybe_unused]] typename Module::Params *params)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -323,7 +323,10 @@ void Agc::process(IPAContext &context,
|
||||
/**
|
||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||
*/
|
||||
void Agc::prepare(IPAContext &context, rkisp1_params_cfg *params)
|
||||
void Agc::prepare(IPAContext &context,
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params)
|
||||
{
|
||||
if (context.frameContext.frameCount > 0)
|
||||
return;
|
||||
|
||||
@@ -26,7 +26,9 @@ public:
|
||||
~Agc() = default;
|
||||
|
||||
int configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override;
|
||||
void prepare(IPAContext &context, rkisp1_params_cfg *params) override;
|
||||
void prepare(IPAContext &context, const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params) override;
|
||||
void process(IPAContext &context, IPAFrameContext &frameContext,
|
||||
const rkisp1_stat_buffer *stats) override;
|
||||
|
||||
|
||||
@@ -74,7 +74,10 @@ uint32_t Awb::estimateCCT(double red, double green, double blue)
|
||||
/**
|
||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||
*/
|
||||
void Awb::prepare(IPAContext &context, rkisp1_params_cfg *params)
|
||||
void Awb::prepare(IPAContext &context,
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params)
|
||||
{
|
||||
params->others.awb_gain_config.gain_green_b = 256 * context.frameContext.awb.gains.green;
|
||||
params->others.awb_gain_config.gain_blue = 256 * context.frameContext.awb.gains.blue;
|
||||
|
||||
@@ -20,7 +20,9 @@ public:
|
||||
~Awb() = default;
|
||||
|
||||
int configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override;
|
||||
void prepare(IPAContext &context, rkisp1_params_cfg *params) override;
|
||||
void prepare(IPAContext &context, const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params) override;
|
||||
void queueRequest(IPAContext &context, const uint32_t frame,
|
||||
const ControlList &controls) override;
|
||||
void process(IPAContext &context, IPAFrameContext &frameCtx,
|
||||
|
||||
@@ -66,6 +66,8 @@ int BlackLevelCorrection::init([[maybe_unused]] IPAContext &context,
|
||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||
*/
|
||||
void BlackLevelCorrection::prepare(IPAContext &context,
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params)
|
||||
{
|
||||
if (context.frameContext.frameCount > 0)
|
||||
|
||||
@@ -20,7 +20,9 @@ public:
|
||||
~BlackLevelCorrection() = default;
|
||||
|
||||
int init(IPAContext &context, const YamlObject &tuningData) override;
|
||||
void prepare(IPAContext &context, rkisp1_params_cfg *params) override;
|
||||
void prepare(IPAContext &context, const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params) override;
|
||||
|
||||
private:
|
||||
bool tuningParameters_;
|
||||
|
||||
@@ -71,6 +71,8 @@ void ColorProcessing::queueRequest(IPAContext &context,
|
||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||
*/
|
||||
void ColorProcessing::prepare(IPAContext &context,
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params)
|
||||
{
|
||||
auto &cproc = context.frameContext.cproc;
|
||||
|
||||
@@ -23,7 +23,9 @@ public:
|
||||
|
||||
void queueRequest(IPAContext &context, const uint32_t frame,
|
||||
const ControlList &controls) override;
|
||||
void prepare(IPAContext &context, rkisp1_params_cfg *params) override;
|
||||
void prepare(IPAContext &context, const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params) override;
|
||||
};
|
||||
|
||||
} /* namespace ipa::rkisp1::algorithms */
|
||||
|
||||
@@ -232,6 +232,8 @@ int DefectPixelClusterCorrection::init([[maybe_unused]] IPAContext &context,
|
||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||
*/
|
||||
void DefectPixelClusterCorrection::prepare(IPAContext &context,
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params)
|
||||
{
|
||||
if (context.frameContext.frameCount > 0)
|
||||
|
||||
@@ -20,7 +20,9 @@ public:
|
||||
~DefectPixelClusterCorrection() = default;
|
||||
|
||||
int init(IPAContext &context, const YamlObject &tuningData) override;
|
||||
void prepare(IPAContext &context, rkisp1_params_cfg *params) override;
|
||||
void prepare(IPAContext &context, const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params) override;
|
||||
|
||||
private:
|
||||
bool initialized_;
|
||||
|
||||
@@ -206,7 +206,9 @@ void Dpf::queueRequest(IPAContext &context,
|
||||
/**
|
||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||
*/
|
||||
void Dpf::prepare(IPAContext &context, rkisp1_params_cfg *params)
|
||||
void Dpf::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,
|
||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params)
|
||||
{
|
||||
if (!initialized_)
|
||||
return;
|
||||
|
||||
@@ -24,7 +24,9 @@ public:
|
||||
int init(IPAContext &context, const YamlObject &tuningData) override;
|
||||
void queueRequest(IPAContext &context, const uint32_t frame,
|
||||
const ControlList &controls) override;
|
||||
void prepare(IPAContext &context, rkisp1_params_cfg *params) override;
|
||||
void prepare(IPAContext &context, const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params) override;
|
||||
|
||||
private:
|
||||
bool initialized_;
|
||||
|
||||
@@ -85,7 +85,10 @@ void Filter::queueRequest(IPAContext &context,
|
||||
/**
|
||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||
*/
|
||||
void Filter::prepare(IPAContext &context, rkisp1_params_cfg *params)
|
||||
void Filter::prepare(IPAContext &context,
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params)
|
||||
{
|
||||
auto &filter = context.frameContext.filter;
|
||||
|
||||
|
||||
@@ -23,7 +23,9 @@ public:
|
||||
|
||||
void queueRequest(IPAContext &context, const uint32_t frame,
|
||||
const ControlList &controls) override;
|
||||
void prepare(IPAContext &context, rkisp1_params_cfg *params) override;
|
||||
void prepare(IPAContext &context, const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params) override;
|
||||
};
|
||||
|
||||
} /* namespace ipa::rkisp1::algorithms */
|
||||
|
||||
@@ -119,6 +119,8 @@ int GammaSensorLinearization::init([[maybe_unused]] IPAContext &context,
|
||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||
*/
|
||||
void GammaSensorLinearization::prepare(IPAContext &context,
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params)
|
||||
{
|
||||
if (context.frameContext.frameCount > 0)
|
||||
|
||||
@@ -20,7 +20,9 @@ public:
|
||||
~GammaSensorLinearization() = default;
|
||||
|
||||
int init(IPAContext &context, const YamlObject &tuningData) override;
|
||||
void prepare(IPAContext &context, rkisp1_params_cfg *params) override;
|
||||
void prepare(IPAContext &context, const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params) override;
|
||||
|
||||
private:
|
||||
bool initialized_;
|
||||
|
||||
@@ -133,6 +133,8 @@ int LensShadingCorrection::configure(IPAContext &context,
|
||||
* \copydoc libcamera::ipa::Algorithm::prepare
|
||||
*/
|
||||
void LensShadingCorrection::prepare(IPAContext &context,
|
||||
[[maybe_unused]] const uint32_t frame,
|
||||
[[maybe_unused]] IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params)
|
||||
{
|
||||
if (context.frameContext.frameCount > 0)
|
||||
|
||||
@@ -21,7 +21,9 @@ public:
|
||||
|
||||
int init(IPAContext &context, const YamlObject &tuningData) override;
|
||||
int configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override;
|
||||
void prepare(IPAContext &context, rkisp1_params_cfg *params) override;
|
||||
void prepare(IPAContext &context, const uint32_t frame,
|
||||
IPAFrameContext &frameContext,
|
||||
rkisp1_params_cfg *params) override;
|
||||
|
||||
private:
|
||||
bool initialized_;
|
||||
|
||||
@@ -297,6 +297,9 @@ void IPARkISP1::queueRequest(const uint32_t frame, const ControlList &controls)
|
||||
|
||||
void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)
|
||||
{
|
||||
/* \todo Obtain the frame context to pass to process from the FCQueue */
|
||||
IPAFrameContext frameContext;
|
||||
|
||||
rkisp1_params_cfg *params =
|
||||
reinterpret_cast<rkisp1_params_cfg *>(
|
||||
mappedBuffers_.at(bufferId).planes()[0].data());
|
||||
@@ -305,7 +308,7 @@ void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)
|
||||
memset(params, 0, sizeof(*params));
|
||||
|
||||
for (auto const &algo : algorithms())
|
||||
algo->prepare(context_, params);
|
||||
algo->prepare(context_, frame, frameContext, params);
|
||||
|
||||
paramsBufferReady.emit(frame);
|
||||
context_.frameContext.frameCount++;
|
||||
|
||||
Reference in New Issue
Block a user