Skip to content

Commit

Permalink
ipa: libipa: algorithm: process(): Pass frame number
Browse files Browse the repository at this point in the history
Pass the frame number of the current frame being processed.

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>
  • Loading branch information
kbingham authored and pinchartl committed Sep 28, 2022
1 parent 87d36de commit 494662f
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/ipa/ipu3/algorithms/af.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ bool Af::afIsOutOfFocus(IPAContext &context)
/**
* \brief Determine the max contrast image and lens position.
* \param[in] context The IPA context.
* \param[in] frame The frame context sequence number
* \param[in] frameContext The current frame context
* \param[in] stats The statistics buffer of IPU3.
*
Expand All @@ -420,7 +421,8 @@ bool Af::afIsOutOfFocus(IPAContext &context)
*
* [1] Hill Climbing Algorithm, https://en.wikipedia.org/wiki/Hill_climbing
*/
void Af::process(IPAContext &context, [[maybe_unused]] IPAFrameContext &frameContext,
void Af::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
[[maybe_unused]] IPAFrameContext &frameContext,
const ipu3_uapi_stats_3a *stats)
{
/* Evaluate the AF buffer length */
Expand Down
3 changes: 2 additions & 1 deletion src/ipa/ipu3/algorithms/af.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class Af : public Algorithm
void prepare(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameContext,
ipu3_uapi_params *params) override;
void process(IPAContext &context, IPAFrameContext &frameContext,
void process(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameContext,
const ipu3_uapi_stats_3a *stats) override;

private:
Expand Down
4 changes: 3 additions & 1 deletion src/ipa/ipu3/algorithms/agc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,15 @@ double Agc::estimateLuminance(IPAActiveState &activeState,
/**
* \brief Process IPU3 statistics, and run AGC operations
* \param[in] context The shared IPA 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
*
* Identify the current image brightness, and use that to estimate the optimal
* new exposure and gain for the scene.
*/
void Agc::process(IPAContext &context, IPAFrameContext &frameContext,
void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
IPAFrameContext &frameContext,
const ipu3_uapi_stats_3a *stats)
{
/*
Expand Down
3 changes: 2 additions & 1 deletion src/ipa/ipu3/algorithms/agc.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class Agc : public Algorithm
~Agc() = default;

int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
void process(IPAContext &context, IPAFrameContext &frameContext,
void process(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameContext,
const ipu3_uapi_stats_3a *stats) override;

private:
Expand Down
3 changes: 2 additions & 1 deletion src/ipa/ipu3/algorithms/awb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ void Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats)
/**
* \copydoc libcamera::ipa::Algorithm::process
*/
void Awb::process(IPAContext &context, [[maybe_unused]] IPAFrameContext &frameContext,
void Awb::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
[[maybe_unused]] IPAFrameContext &frameContext,
const ipu3_uapi_stats_3a *stats)
{
calculateWBGains(stats);
Expand Down
3 changes: 2 additions & 1 deletion src/ipa/ipu3/algorithms/awb.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class Awb : public Algorithm
void prepare(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameContext,
ipu3_uapi_params *params) override;
void process(IPAContext &context, IPAFrameContext &frameContext,
void process(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameContext,
const ipu3_uapi_stats_3a *stats) override;

private:
Expand Down
4 changes: 3 additions & 1 deletion src/ipa/ipu3/algorithms/tone_mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@ void ToneMapping::prepare([[maybe_unused]] IPAContext &context,
/**
* \brief Calculate the tone mapping look up table
* \param[in] context The shared IPA 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
*
* The tone mapping look up table is generated as an inverse power curve from
* our gamma setting.
*/
void ToneMapping::process(IPAContext &context, [[maybe_unused]] IPAFrameContext &frameContext,
void ToneMapping::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
[[maybe_unused]] IPAFrameContext &frameContext,
[[maybe_unused]] const ipu3_uapi_stats_3a *stats)
{
/*
Expand Down
3 changes: 2 additions & 1 deletion src/ipa/ipu3/algorithms/tone_mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class ToneMapping : public Algorithm
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,
void process(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameContext,
const ipu3_uapi_stats_3a *stats) override;

private:
Expand Down
2 changes: 1 addition & 1 deletion src/ipa/ipu3/ipu3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame,
ControlList ctrls(controls::controls);

for (auto const &algo : algorithms())
algo->process(context_, frameContext, stats);
algo->process(context_, frame, frameContext, stats);

setControls(frame);

Expand Down
1 change: 1 addition & 0 deletions src/ipa/libipa/algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ namespace ipa {
* \fn Algorithm::process()
* \brief Process ISP statistics, and run algorithm operations
* \param[in] context The shared IPA context
* \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
*
Expand Down
1 change: 1 addition & 0 deletions src/ipa/libipa/algorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Algorithm
}

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)
{
Expand Down
3 changes: 2 additions & 1 deletion src/ipa/rkisp1/algorithms/agc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,14 @@ double Agc::measureBrightness(const rkisp1_cif_isp_hist_stat *hist) const
/**
* \brief Process RkISP1 statistics, and run AGC operations
* \param[in] context The shared IPA context
* \param[in] frame The frame context sequence number
* \param[in] frameContext The current frame context
* \param[in] stats The RKISP1 statistics and ISP results
*
* Identify the current image brightness, and use that to estimate the optimal
* new exposure and gain for the scene.
*/
void Agc::process(IPAContext &context,
void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,
[[maybe_unused]] IPAFrameContext &frameContext,
const rkisp1_stat_buffer *stats)
{
Expand Down
3 changes: 2 additions & 1 deletion src/ipa/rkisp1/algorithms/agc.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class Agc : public Algorithm
void prepare(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameContext,
rkisp1_params_cfg *params) override;
void process(IPAContext &context, IPAFrameContext &frameContext,
void process(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameContext,
const rkisp1_stat_buffer *stats) override;

private:
Expand Down
1 change: 1 addition & 0 deletions src/ipa/rkisp1/algorithms/awb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ void Awb::queueRequest(IPAContext &context,
* \copydoc libcamera::ipa::Algorithm::process
*/
void Awb::process([[maybe_unused]] IPAContext &context,
[[maybe_unused]] const uint32_t frame,
[[maybe_unused]] IPAFrameContext &frameCtx,
const rkisp1_stat_buffer *stats)
{
Expand Down
3 changes: 2 additions & 1 deletion src/ipa/rkisp1/algorithms/awb.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class Awb : public Algorithm
rkisp1_params_cfg *params) override;
void queueRequest(IPAContext &context, const uint32_t frame,
const ControlList &controls) override;
void process(IPAContext &context, IPAFrameContext &frameCtx,
void process(IPAContext &context, const uint32_t frame,
IPAFrameContext &frameCtx,
const rkisp1_stat_buffer *stats) override;

private:
Expand Down
2 changes: 1 addition & 1 deletion src/ipa/rkisp1/rkisp1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId
IPAFrameContext frameContext;

for (auto const &algo : algorithms())
algo->process(context_, frameContext, stats);
algo->process(context_, frame, frameContext, stats);

setControls(frame);

Expand Down

0 comments on commit 494662f

Please sign in to comment.