[libcamera-devel] [RFC PATCH 09/12] ipa: libipa: algorithm: process(): Pass frame number

Jacopo Mondi jacopo at jmondi.org
Mon Jul 25 17:48:42 CEST 2022


Hi Kieran

On Thu, Jul 21, 2022 at 01:13:07PM +0100, Kieran Bingham via libcamera-devel wrote:
> Pass the frame number of the current frame being processed.
>
> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
>
>  - Use RKISP1FrameContext from the queue during IPARkISP1::processStatsBuffer
>
> Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>

If I'm not mistaken this is not currently used.
How do you think it will ? The algorithms receive the frameContext
already, so they don't need the frame id to access it, right ?

> ---
>  src/ipa/ipu3/algorithms/af.cpp           | 2 ++
>  src/ipa/ipu3/algorithms/af.h             | 4 +++-
>  src/ipa/ipu3/algorithms/agc.cpp          | 2 ++
>  src/ipa/ipu3/algorithms/agc.h            | 3 ++-
>  src/ipa/ipu3/algorithms/awb.cpp          | 1 +
>  src/ipa/ipu3/algorithms/awb.h            | 3 ++-
>  src/ipa/ipu3/algorithms/tone_mapping.cpp | 2 ++
>  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        | 1 +
>  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, 26 insertions(+), 8 deletions(-)
>
> diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp
> index 1faf92969ee5..29a9f520d93c 100644
> --- a/src/ipa/ipu3/algorithms/af.cpp
> +++ b/src/ipa/ipu3/algorithms/af.cpp
> @@ -409,6 +409,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.
>   *
> @@ -424,6 +425,7 @@ bool Af::afIsOutOfFocus(IPAContext context)
>   * [1] Hill Climbing Algorithm, https://en.wikipedia.org/wiki/Hill_climbing
>   */
>  void Af::process(IPAContext &context,
> +		 [[maybe_unused]] unsigned int frame,
>  		 [[maybe_unused]] IPU3FrameContext &frameContext,
>  		 const ipu3_uapi_stats_3a *stats)
>  {
> diff --git a/src/ipa/ipu3/algorithms/af.h b/src/ipa/ipu3/algorithms/af.h
> index 4e2bbd08c3bf..977112506c98 100644
> --- a/src/ipa/ipu3/algorithms/af.h
> +++ b/src/ipa/ipu3/algorithms/af.h
> @@ -31,10 +31,12 @@ public:
>  	~Af() = default;
>
>  	int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
> +
>  	void prepare(IPAContext &context, unsigned int frame,
>  		     IPU3FrameContext &frameContext,
>  		     ipu3_uapi_params *params) override;
> -	void process(IPAContext &context, IPU3FrameContext &frameContext,
> +	void process(IPAContext &context, unsigned int frame,
> +		     IPU3FrameContext &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 92ea6249798d..00ef54d45574 100644
> --- a/src/ipa/ipu3/algorithms/agc.cpp
> +++ b/src/ipa/ipu3/algorithms/agc.cpp
> @@ -317,6 +317,7 @@ 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
>   *
> @@ -324,6 +325,7 @@ double Agc::estimateLuminance(IPAActiveState &activeState,
>   * new exposure and gain for the scene.
>   */
>  void Agc::process(IPAContext &context,
> +		  [[maybe_unused]] unsigned int frame,
>  		  IPU3FrameContext &frameContext,
>  		  const ipu3_uapi_stats_3a *stats)
>  {
> diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h
> index 96585f48933f..5bb9dc8f610e 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, IPU3FrameContext &frameContext,
> +	void process(IPAContext &context, unsigned int frame,
> +		     IPU3FrameContext &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 b110ad404fd1..8943ead6fc4c 100644
> --- a/src/ipa/ipu3/algorithms/awb.cpp
> +++ b/src/ipa/ipu3/algorithms/awb.cpp
> @@ -388,6 +388,7 @@ void Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats)
>   * \copydoc libcamera::ipa::Algorithm::process
>   */
>  void Awb::process(IPAContext &context,
> +		  [[maybe_unused]] unsigned int frame,
>  		  [[maybe_unused]] IPU3FrameContext &frameContext,
>  		  const ipu3_uapi_stats_3a *stats)
>  {
> diff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h
> index 731e5bae17de..094b177672ca 100644
> --- a/src/ipa/ipu3/algorithms/awb.h
> +++ b/src/ipa/ipu3/algorithms/awb.h
> @@ -43,7 +43,8 @@ public:
>  	void prepare(IPAContext &context, unsigned int frame,
>  		     IPU3FrameContext &frameContext,
>  		     ipu3_uapi_params *params) override;
> -	void process(IPAContext &context, IPU3FrameContext &frameContext,
> +	void process(IPAContext &context, unsigned int frame,
> +		     IPU3FrameContext &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 9ca3f471cbaf..e545011ce203 100644
> --- a/src/ipa/ipu3/algorithms/tone_mapping.cpp
> +++ b/src/ipa/ipu3/algorithms/tone_mapping.cpp
> @@ -76,6 +76,7 @@ void ToneMapping::prepare([[maybe_unused]] IPAContext &context,
>  /**
>   * \brief Calculate the tone mapping look up table
>   * \param context The shared IPA context
> + * \param frame The current frame sequence number
>   * \param frameContext The current frame context
>   * \param stats The IPU3 statistics and ISP results
>   *
> @@ -83,6 +84,7 @@ void ToneMapping::prepare([[maybe_unused]] IPAContext &context,
>   * our gamma setting.
>   */
>  void ToneMapping::process(IPAContext &context,
> +			  [[maybe_unused]] unsigned int frame,
>  			  [[maybe_unused]] IPU3FrameContext &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 cfb3de01b7f3..a3ab285c927f 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, unsigned int frame,
>  		     IPU3FrameContext &frameContext, ipu3_uapi_params *params) override;
> -	void process(IPAContext &context, IPU3FrameContext &frameContext,
> +	void process(IPAContext &context, unsigned int frame,
> +		     IPU3FrameContext &frameContext,
>  		     const ipu3_uapi_stats_3a *stats) override;
>
>  private:
> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
> index 5663b1f4bb51..4d7a54f8d1a5 100644
> --- a/src/ipa/ipu3/ipu3.cpp
> +++ b/src/ipa/ipu3/ipu3.cpp
> @@ -585,7 +585,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 bc7c130d3e09..65e9e8a56fc4 100644
> --- a/src/ipa/libipa/algorithm.cpp
> +++ b/src/ipa/libipa/algorithm.cpp
> @@ -87,6 +87,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 ce5c7cc491d8..1d2544a767eb 100644
> --- a/src/ipa/libipa/algorithm.h
> +++ b/src/ipa/libipa/algorithm.h
> @@ -43,6 +43,7 @@ public:
>  	}
>
>  	virtual void process([[maybe_unused]] typename Module::Context &context,
> +			     [[maybe_unused]] unsigned int 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 2d436511caf7..60018db73260 100644
> --- a/src/ipa/rkisp1/algorithms/agc.cpp
> +++ b/src/ipa/rkisp1/algorithms/agc.cpp
> @@ -281,6 +281,7 @@ double Agc::measureBrightness(const rkisp1_cif_isp_hist_stat *hist) const
>   * new exposure and gain for the scene.
>   */
>  void Agc::process(IPAContext &context,
> +		  [[maybe_unused]] unsigned int frame,
>  		  [[maybe_unused]] RKISP1FrameContext &frameContext,
>  		  const rkisp1_stat_buffer *stats)
>  {
> diff --git a/src/ipa/rkisp1/algorithms/agc.h b/src/ipa/rkisp1/algorithms/agc.h
> index 7844cd2e3b47..05bda50c5962 100644
> --- a/src/ipa/rkisp1/algorithms/agc.h
> +++ b/src/ipa/rkisp1/algorithms/agc.h
> @@ -31,7 +31,8 @@ public:
>  	void prepare(IPAContext &context, unsigned int frame,
>  		     RKISP1FrameContext &frameContext,
>  		     rkisp1_params_cfg *params) override;
> -	void process(IPAContext &context, RKISP1FrameContext &frameContext,
> +	void process(IPAContext &context, unsigned int frame,
> +		     RKISP1FrameContext &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 1af6d98c5252..b3ffa6cda4ea 100644
> --- a/src/ipa/rkisp1/algorithms/awb.cpp
> +++ b/src/ipa/rkisp1/algorithms/awb.cpp
> @@ -123,6 +123,7 @@ void Awb::prepare(IPAContext &context,
>   * \copydoc libcamera::ipa::Algorithm::process
>   */
>  void Awb::process([[maybe_unused]] IPAContext &context,
> +		  [[maybe_unused]] unsigned int frame,
>  		  [[maybe_unused]] RKISP1FrameContext &frameCtx,
>  		  const rkisp1_stat_buffer *stats)
>  {
> diff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h
> index 8fd5b706861a..510fbad9958e 100644
> --- a/src/ipa/rkisp1/algorithms/awb.h
> +++ b/src/ipa/rkisp1/algorithms/awb.h
> @@ -25,7 +25,8 @@ public:
>  	void prepare(IPAContext &context, unsigned int frame,
>  		     RKISP1FrameContext &frameContext,
>  		     rkisp1_params_cfg *params) override;
> -	void process(IPAContext &context, RKISP1FrameContext &frameCtx,
> +	void process(IPAContext &context, unsigned int frame,
> +		     RKISP1FrameContext &frameCtx,
>  		     const rkisp1_stat_buffer *stats) override;
>
>  private:
> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
> index f97484ce5030..b468e08a67fa 100644
> --- a/src/ipa/rkisp1/rkisp1.cpp
> +++ b/src/ipa/rkisp1/rkisp1.cpp
> @@ -308,7 +308,7 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId
>  	unsigned int aeState = 0;
>
>  	for (auto const &algo : algorithms())
> -		algo->process(context_, frameContext, stats);
> +		algo->process(context_, frame, frameContext, stats);
>
>  	setControls(frame);
>
> --
> 2.34.1
>


More information about the libcamera-devel mailing list