[libcamera-devel,v5,07/33] ipa: libipa: algorithm: process(): Pass frame number
diff mbox series

Message ID 20220927023642.12341-8-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • ipa: Frame context queue, IPU3 & RkISP consolidation, and RkISP1 improvements
Related show

Commit Message

Laurent Pinchart Sept. 27, 2022, 2:36 a.m. UTC
From: Kieran Bingham <kieran.bingham@ideasonboard.com>

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>
---
Changes since v4:

- Update the documentation of ipa::rkisp1::Awb::process()

Changes since v3:

- Use a const uint32_t instead of an unsigned int for the frame number
- Update the documentation of ipa::rkisp1::Agc::process()
---
 src/ipa/ipu3/algorithms/af.cpp           | 4 +++-
 src/ipa/ipu3/algorithms/af.h             | 3 ++-
 src/ipa/ipu3/algorithms/agc.cpp          | 4 +++-
 src/ipa/ipu3/algorithms/agc.h            | 3 ++-
 src/ipa/ipu3/algorithms/awb.cpp          | 3 ++-
 src/ipa/ipu3/algorithms/awb.h            | 3 ++-
 src/ipa/ipu3/algorithms/tone_mapping.cpp | 4 +++-
 src/ipa/ipu3/algorithms/tone_mapping.h   | 3 ++-
 src/ipa/ipu3/ipu3.cpp                    | 2 +-
 src/ipa/libipa/algorithm.cpp             | 1 +
 src/ipa/libipa/algorithm.h               | 1 +
 src/ipa/rkisp1/algorithms/agc.cpp        | 3 ++-
 src/ipa/rkisp1/algorithms/agc.h          | 3 ++-
 src/ipa/rkisp1/algorithms/awb.cpp        | 1 +
 src/ipa/rkisp1/algorithms/awb.h          | 3 ++-
 src/ipa/rkisp1/rkisp1.cpp                | 2 +-
 16 files changed, 30 insertions(+), 13 deletions(-)

Patch
diff mbox series

diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp
index bc01b232ec59..b00a34f9e090 100644
--- a/src/ipa/ipu3/algorithms/af.cpp
+++ b/src/ipa/ipu3/algorithms/af.cpp
@@ -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.
  *
@@ -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 */
diff --git a/src/ipa/ipu3/algorithms/af.h b/src/ipa/ipu3/algorithms/af.h
index fbfd171b6465..89d37ac18615 100644
--- a/src/ipa/ipu3/algorithms/af.h
+++ b/src/ipa/ipu3/algorithms/af.h
@@ -34,7 +34,8 @@  public:
 	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:
diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp
index f8ca29640a44..a1a3c38ffe84 100644
--- a/src/ipa/ipu3/algorithms/agc.cpp
+++ b/src/ipa/ipu3/algorithms/agc.cpp
@@ -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)
 {
 	/*
diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h
index 876fbbb6b585..59b4b9843c2f 100644
--- a/src/ipa/ipu3/algorithms/agc.h
+++ b/src/ipa/ipu3/algorithms/agc.h
@@ -28,7 +28,8 @@  public:
 	~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:
diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp
index e6e2951b8abb..0dbd7d4c374f 100644
--- a/src/ipa/ipu3/algorithms/awb.cpp
+++ b/src/ipa/ipu3/algorithms/awb.cpp
@@ -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);
diff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h
index e9e816928fb4..28e2d38a711c 100644
--- a/src/ipa/ipu3/algorithms/awb.h
+++ b/src/ipa/ipu3/algorithms/awb.h
@@ -42,7 +42,8 @@  public:
 	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:
diff --git a/src/ipa/ipu3/algorithms/tone_mapping.cpp b/src/ipa/ipu3/algorithms/tone_mapping.cpp
index 10a2fb1935dc..eac3d4064443 100644
--- a/src/ipa/ipu3/algorithms/tone_mapping.cpp
+++ b/src/ipa/ipu3/algorithms/tone_mapping.cpp
@@ -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)
 {
 	/*
diff --git a/src/ipa/ipu3/algorithms/tone_mapping.h b/src/ipa/ipu3/algorithms/tone_mapping.h
index c24a7e485aaf..822e5168df82 100644
--- a/src/ipa/ipu3/algorithms/tone_mapping.h
+++ b/src/ipa/ipu3/algorithms/tone_mapping.h
@@ -21,7 +21,8 @@  public:
 	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:
diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index ac6f66afecb5..e5a763fd2b08 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -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);
 
diff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp
index 0992e5de8dd5..30eab67f71fc 100644
--- a/src/ipa/libipa/algorithm.cpp
+++ b/src/ipa/libipa/algorithm.cpp
@@ -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
  *
diff --git a/src/ipa/libipa/algorithm.h b/src/ipa/libipa/algorithm.h
index cde2e6399e8e..ee93d260ca3f 100644
--- a/src/ipa/libipa/algorithm.h
+++ b/src/ipa/libipa/algorithm.h
@@ -52,6 +52,7 @@  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)
 	{
diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp
index 603fad183b87..f9c33f81a074 100644
--- a/src/ipa/rkisp1/algorithms/agc.cpp
+++ b/src/ipa/rkisp1/algorithms/agc.cpp
@@ -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)
 {
diff --git a/src/ipa/rkisp1/algorithms/agc.h b/src/ipa/rkisp1/algorithms/agc.h
index 8724cb602158..f115ba2ed85c 100644
--- a/src/ipa/rkisp1/algorithms/agc.h
+++ b/src/ipa/rkisp1/algorithms/agc.h
@@ -29,7 +29,8 @@  public:
 	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:
diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp
index da22a0970a4f..aefba6382807 100644
--- a/src/ipa/rkisp1/algorithms/awb.cpp
+++ b/src/ipa/rkisp1/algorithms/awb.cpp
@@ -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)
 {
diff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h
index 7ae6c7a9bb10..806e11a2ec93 100644
--- a/src/ipa/rkisp1/algorithms/awb.h
+++ b/src/ipa/rkisp1/algorithms/awb.h
@@ -25,7 +25,8 @@  public:
 		     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:
diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
index 0932c73b14e4..b2593a584a1a 100644
--- a/src/ipa/rkisp1/rkisp1.cpp
+++ b/src/ipa/rkisp1/rkisp1.cpp
@@ -333,7 +333,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);