From 494662f082932c925c3e7ae4563c4e2d4db9cb35 Mon Sep 17 00:00:00 2001
From: Kieran Bingham <kieran.bingham@ideasonboard.com>
Date: Thu, 21 Jul 2022 13:13:07 +0100
Subject: ipa: libipa: algorithm: process(): Pass frame number

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>
---
 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 +-
 9 files changed, 20 insertions(+), 9 deletions(-)

(limited to 'src/ipa/ipu3')

diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp
index bc01b232..b00a34f9 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 fbfd171b..89d37ac1 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 f8ca2964..a1a3c38f 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 876fbbb6..59b4b984 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 e6e2951b..0dbd7d4c 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 e9e81692..28e2d38a 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 10a2fb19..eac3d406 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 c24a7e48..822e5168 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 ac6f66af..e5a763fd 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);
 
-- 
cgit v1.2.1