[libcamera-devel,1/4] libipa: algorithm: Pass frame number to prepare() and process()
diff mbox series

Message ID 20220103170956.323025-2-umang.jain@ideasonboard.com
State Superseded
Delegated to: Umang Jain
Headers show
Series
  • IPAIPU3 - Rework interface and introduce context
Related show

Commit Message

Umang Jain Jan. 3, 2022, 5:09 p.m. UTC
The frame number will be used to retrieve their respective
IPAFrameContext from a container in subsequent commits.

Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
---
 src/ipa/ipu3/algorithms/agc.cpp          | 3 ++-
 src/ipa/ipu3/algorithms/agc.h            | 2 +-
 src/ipa/ipu3/algorithms/awb.cpp          | 4 ++--
 src/ipa/ipu3/algorithms/awb.h            | 4 ++--
 src/ipa/ipu3/algorithms/blc.cpp          | 6 ++++--
 src/ipa/ipu3/algorithms/blc.h            | 2 +-
 src/ipa/ipu3/algorithms/tone_mapping.cpp | 7 +++++--
 src/ipa/ipu3/algorithms/tone_mapping.h   | 4 ++--
 src/ipa/ipu3/ipu3.cpp                    | 4 ++--
 src/ipa/libipa/algorithm.cpp             | 2 ++
 src/ipa/libipa/algorithm.h               | 6 ++++--
 11 files changed, 27 insertions(+), 17 deletions(-)

Comments

Jean-Michel Hautbois Jan. 3, 2022, 5:19 p.m. UTC | #1
Hi Umang,

Thanks for the patch.

On 03/01/2022 18:09, Umang Jain wrote:
> The frame number will be used to retrieve their respective
> IPAFrameContext from a container in subsequent commits.
> 
> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>   src/ipa/ipu3/algorithms/agc.cpp          | 3 ++-
>   src/ipa/ipu3/algorithms/agc.h            | 2 +-
>   src/ipa/ipu3/algorithms/awb.cpp          | 4 ++--
>   src/ipa/ipu3/algorithms/awb.h            | 4 ++--
>   src/ipa/ipu3/algorithms/blc.cpp          | 6 ++++--
>   src/ipa/ipu3/algorithms/blc.h            | 2 +-
>   src/ipa/ipu3/algorithms/tone_mapping.cpp | 7 +++++--
>   src/ipa/ipu3/algorithms/tone_mapping.h   | 4 ++--
>   src/ipa/ipu3/ipu3.cpp                    | 4 ++--
>   src/ipa/libipa/algorithm.cpp             | 2 ++
>   src/ipa/libipa/algorithm.h               | 6 ++++--
>   11 files changed, 27 insertions(+), 17 deletions(-)
> 
> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp
> index 8d6f18f6..1d0778d8 100644
> --- a/src/ipa/ipu3/algorithms/agc.cpp
> +++ b/src/ipa/ipu3/algorithms/agc.cpp
> @@ -307,13 +307,14 @@ double Agc::estimateLuminance(IPAFrameContext &frameContext,
>   
>   /**
>    * \brief Process IPU3 statistics, and run AGC operations
> + * \param frame The frame number
>    * \param[in] context The shared IPA 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, const ipu3_uapi_stats_3a *stats)
> +void Agc::process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats)

This is true for all the rest: why are you passing it to the function 
instead of including it in the frameContext ?

>   {
>   	/*
>   	 * Estimate the gain needed to have the proportion of pixels in a given
> diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h
> index 96ec7005..c6ab8e91 100644
> --- a/src/ipa/ipu3/algorithms/agc.h
> +++ b/src/ipa/ipu3/algorithms/agc.h
> @@ -28,7 +28,7 @@ public:
>   	~Agc() = default;
>   
>   	int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
> -	void process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override;
> +	void process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats) override;
>   
>   private:
>   	double measureBrightness(const ipu3_uapi_stats_3a *stats,
> diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp
> index 1dc27fc9..99fb5305 100644
> --- a/src/ipa/ipu3/algorithms/awb.cpp
> +++ b/src/ipa/ipu3/algorithms/awb.cpp
> @@ -379,7 +379,7 @@ void Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats)
>   /**
>    * \copydoc libcamera::ipa::Algorithm::process
>    */
> -void Awb::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)
> +void Awb::process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats)
>   {
>   	calculateWBGains(stats);
>   
> @@ -403,7 +403,7 @@ constexpr uint16_t Awb::threshold(float value)
>   /**
>    * \copydoc libcamera::ipa::Algorithm::prepare
>    */
> -void Awb::prepare(IPAContext &context, ipu3_uapi_params *params)
> +void Awb::prepare([[maybe_unused]] const uint32_t frame, IPAContext &context, ipu3_uapi_params *params)
>   {
>   	/*
>   	 * Green saturation thresholds are reduced because we are using the
> diff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h
> index ab4b0a33..ef177a4a 100644
> --- a/src/ipa/ipu3/algorithms/awb.h
> +++ b/src/ipa/ipu3/algorithms/awb.h
> @@ -39,8 +39,8 @@ public:
>   	~Awb();
>   
>   	int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
> -	void prepare(IPAContext &context, ipu3_uapi_params *params) override;
> -	void process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override;
> +	void prepare(const uint32_t frame, IPAContext &context, ipu3_uapi_params *params) override;
> +	void process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats) override;
>   
>   private:
>   	/* \todo Make these structs available to all the ISPs ? */
> diff --git a/src/ipa/ipu3/algorithms/blc.cpp b/src/ipa/ipu3/algorithms/blc.cpp
> index 78ab7bff..e9b4bed8 100644
> --- a/src/ipa/ipu3/algorithms/blc.cpp
> +++ b/src/ipa/ipu3/algorithms/blc.cpp
> @@ -38,14 +38,16 @@ BlackLevelCorrection::BlackLevelCorrection()
>   
>   /**
>    * \brief Fill in the parameter structure, and enable black level correction
> + * \param frame The frame number
>    * \param context The shared IPA context
>    * \param 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)
> +void BlackLevelCorrection::prepare([[maybe_unused]] const uint32_t frame,
> +				   [[maybe_unused]] IPAContext &context,
> +				   ipu3_uapi_params *params)
>   {
>   	/*
>   	 * The Optical Black Level correction values
> diff --git a/src/ipa/ipu3/algorithms/blc.h b/src/ipa/ipu3/algorithms/blc.h
> index d8da1748..e4c22070 100644
> --- a/src/ipa/ipu3/algorithms/blc.h
> +++ b/src/ipa/ipu3/algorithms/blc.h
> @@ -18,7 +18,7 @@ class BlackLevelCorrection : public Algorithm
>   public:
>   	BlackLevelCorrection();
>   
> -	void prepare(IPAContext &context, ipu3_uapi_params *params) override;
> +	void prepare(const uint32_t frame, IPAContext &context, ipu3_uapi_params *params) override;
>   };
>   
>   } /* namespace ipa::ipu3::algorithms */
> diff --git a/src/ipa/ipu3/algorithms/tone_mapping.cpp b/src/ipa/ipu3/algorithms/tone_mapping.cpp
> index 2040eda5..bba5bc9a 100644
> --- a/src/ipa/ipu3/algorithms/tone_mapping.cpp
> +++ b/src/ipa/ipu3/algorithms/tone_mapping.cpp
> @@ -49,13 +49,15 @@ int ToneMapping::configure(IPAContext &context,
>   
>   /**
>    * \brief Fill in the parameter structure, and enable gamma control
> + * \param frame The frame number
>    * \param context The shared IPA context
>    * \param 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,
> +void ToneMapping::prepare([[maybe_unused]] const uint32_t frame,
> +			  [[maybe_unused]] IPAContext &context,
>   			  ipu3_uapi_params *params)
>   {
>   	/* Copy the calculated LUT into the parameters buffer. */
> @@ -71,13 +73,14 @@ void ToneMapping::prepare([[maybe_unused]] IPAContext &context,
>   
>   /**
>    * \brief Calculate the tone mapping look up table
> + * \param frame The frame number
>    * \param context The shared IPA context
>    * \param 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,
> +void ToneMapping::process(const uint32_t frame, IPAContext &context,
>   			  [[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 b727ab1e..041c9c0d 100644
> --- a/src/ipa/ipu3/algorithms/tone_mapping.h
> +++ b/src/ipa/ipu3/algorithms/tone_mapping.h
> @@ -19,8 +19,8 @@ public:
>   	ToneMapping();
>   
>   	int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
> -	void prepare(IPAContext &context, ipu3_uapi_params *params) override;
> -	void process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override;
> +	void prepare(const uint32_t frame, IPAContext &context, ipu3_uapi_params *params) override;
> +	void process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats) override;
>   
>   private:
>   	double gamma_;
> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
> index 3d307708..aef232c3 100644
> --- a/src/ipa/ipu3/ipu3.cpp
> +++ b/src/ipa/ipu3/ipu3.cpp
> @@ -595,7 +595,7 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)
>   	params->use = {};
>   
>   	for (auto const &algo : algorithms_)
> -		algo->prepare(context_, params);
> +		algo->prepare(frame, context_, params);
>   
>   	IPU3Action op;
>   	op.op = ActionParamFilled;
> @@ -620,7 +620,7 @@ void IPAIPU3::parseStatistics(unsigned int frame,
>   	ControlList ctrls(controls::controls);
>   
>   	for (auto const &algo : algorithms_)
> -		algo->process(context_, stats);
> +		algo->process(frame, context_, stats);
>   
>   	setControls(frame);
>   
> diff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp
> index 398d5372..01967f07 100644
> --- a/src/ipa/libipa/algorithm.cpp
> +++ b/src/ipa/libipa/algorithm.cpp
> @@ -48,6 +48,7 @@ namespace ipa {
>   /**
>    * \fn Algorithm::prepare()
>    * \brief Fill the \a params buffer with ISP processing parameters for a frame
> + * \param[in] frame The frame number
>    * \param[in] context The shared IPA context
>    * \param[out] params The ISP specific parameters.
>    *
> @@ -63,6 +64,7 @@ namespace ipa {
>   /**
>    * \fn Algorithm::process()
>    * \brief Process ISP statistics, and run algorithm operations
> + * \param[in] frame The frame number
>    * \param[in] context The shared IPA 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 766aee5d..1df93625 100644
> --- a/src/ipa/libipa/algorithm.h
> +++ b/src/ipa/libipa/algorithm.h
> @@ -22,12 +22,14 @@ public:
>   		return 0;
>   	}
>   
> -	virtual void prepare([[maybe_unused]] Context &context,
> +	virtual void prepare([[maybe_unused]] const uint32_t frame,
> +			     [[maybe_unused]] Context &context,
>   			     [[maybe_unused]] Params *params)
>   	{
>   	}
>   
> -	virtual void process([[maybe_unused]] Context &context,
> +	virtual void process([[maybe_unused]] const uint32_t frame,
> +			     [[maybe_unused]] Context &context,
>   			     [[maybe_unused]] const Stats *stats)
>   	{
>   	}
>
Umang Jain Jan. 4, 2022, 3:13 a.m. UTC | #2
Hi JM,

On 1/3/22 10:49 PM, Jean-Michel Hautbois wrote:
> Hi Umang,
>
> Thanks for the patch.
>
> On 03/01/2022 18:09, Umang Jain wrote:
>> The frame number will be used to retrieve their respective
>> IPAFrameContext from a container in subsequent commits.
>>
>> Signed-off-by: Umang Jain <umang.jain@ideasonboard.com>
>> ---
>>   src/ipa/ipu3/algorithms/agc.cpp          | 3 ++-
>>   src/ipa/ipu3/algorithms/agc.h            | 2 +-
>>   src/ipa/ipu3/algorithms/awb.cpp          | 4 ++--
>>   src/ipa/ipu3/algorithms/awb.h            | 4 ++--
>>   src/ipa/ipu3/algorithms/blc.cpp          | 6 ++++--
>>   src/ipa/ipu3/algorithms/blc.h            | 2 +-
>>   src/ipa/ipu3/algorithms/tone_mapping.cpp | 7 +++++--
>>   src/ipa/ipu3/algorithms/tone_mapping.h   | 4 ++--
>>   src/ipa/ipu3/ipu3.cpp                    | 4 ++--
>>   src/ipa/libipa/algorithm.cpp             | 2 ++
>>   src/ipa/libipa/algorithm.h               | 6 ++++--
>>   11 files changed, 27 insertions(+), 17 deletions(-)
>>
>> diff --git a/src/ipa/ipu3/algorithms/agc.cpp 
>> b/src/ipa/ipu3/algorithms/agc.cpp
>> index 8d6f18f6..1d0778d8 100644
>> --- a/src/ipa/ipu3/algorithms/agc.cpp
>> +++ b/src/ipa/ipu3/algorithms/agc.cpp
>> @@ -307,13 +307,14 @@ double Agc::estimateLuminance(IPAFrameContext 
>> &frameContext,
>>     /**
>>    * \brief Process IPU3 statistics, and run AGC operations
>> + * \param frame The frame number
>>    * \param[in] context The shared IPA 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, const ipu3_uapi_stats_3a *stats)
>> +void Agc::process(const uint32_t frame, IPAContext &context, const 
>> ipu3_uapi_stats_3a *stats)
>
> This is true for all the rest: why are you passing it to the function 
> instead of including it in the frameContext ?


I couldn't understand the initial part - "This is true for all the rest"

I think going forwards, IPAContext will be more whole-some preserving 
the context of all the frames queued to IPU3, hence  I don't want to 
introduce any per-frame member variable there, although I am not very 
much opposed to the idea.

The Algorithm prepare() and process() are documented to be run "for 
every frame", hence  I find passing the frame-number to those functions 
as a more suitable option.

>
>>   {
>>       /*
>>        * Estimate the gain needed to have the proportion of pixels in 
>> a given
>> diff --git a/src/ipa/ipu3/algorithms/agc.h 
>> b/src/ipa/ipu3/algorithms/agc.h
>> index 96ec7005..c6ab8e91 100644
>> --- a/src/ipa/ipu3/algorithms/agc.h
>> +++ b/src/ipa/ipu3/algorithms/agc.h
>> @@ -28,7 +28,7 @@ public:
>>       ~Agc() = default;
>>         int configure(IPAContext &context, const IPAConfigInfo 
>> &configInfo) override;
>> -    void process(IPAContext &context, const ipu3_uapi_stats_3a 
>> *stats) override;
>> +    void process(const uint32_t frame, IPAContext &context, const 
>> ipu3_uapi_stats_3a *stats) override;
>>     private:
>>       double measureBrightness(const ipu3_uapi_stats_3a *stats,
>> diff --git a/src/ipa/ipu3/algorithms/awb.cpp 
>> b/src/ipa/ipu3/algorithms/awb.cpp
>> index 1dc27fc9..99fb5305 100644
>> --- a/src/ipa/ipu3/algorithms/awb.cpp
>> +++ b/src/ipa/ipu3/algorithms/awb.cpp
>> @@ -379,7 +379,7 @@ void Awb::calculateWBGains(const 
>> ipu3_uapi_stats_3a *stats)
>>   /**
>>    * \copydoc libcamera::ipa::Algorithm::process
>>    */
>> -void Awb::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)
>> +void Awb::process(const uint32_t frame, IPAContext &context, const 
>> ipu3_uapi_stats_3a *stats)
>>   {
>>       calculateWBGains(stats);
>>   @@ -403,7 +403,7 @@ constexpr uint16_t Awb::threshold(float value)
>>   /**
>>    * \copydoc libcamera::ipa::Algorithm::prepare
>>    */
>> -void Awb::prepare(IPAContext &context, ipu3_uapi_params *params)
>> +void Awb::prepare([[maybe_unused]] const uint32_t frame, IPAContext 
>> &context, ipu3_uapi_params *params)
>>   {
>>       /*
>>        * Green saturation thresholds are reduced because we are using 
>> the
>> diff --git a/src/ipa/ipu3/algorithms/awb.h 
>> b/src/ipa/ipu3/algorithms/awb.h
>> index ab4b0a33..ef177a4a 100644
>> --- a/src/ipa/ipu3/algorithms/awb.h
>> +++ b/src/ipa/ipu3/algorithms/awb.h
>> @@ -39,8 +39,8 @@ public:
>>       ~Awb();
>>         int configure(IPAContext &context, const IPAConfigInfo 
>> &configInfo) override;
>> -    void prepare(IPAContext &context, ipu3_uapi_params *params) 
>> override;
>> -    void process(IPAContext &context, const ipu3_uapi_stats_3a 
>> *stats) override;
>> +    void prepare(const uint32_t frame, IPAContext &context, 
>> ipu3_uapi_params *params) override;
>> +    void process(const uint32_t frame, IPAContext &context, const 
>> ipu3_uapi_stats_3a *stats) override;
>>     private:
>>       /* \todo Make these structs available to all the ISPs ? */
>> diff --git a/src/ipa/ipu3/algorithms/blc.cpp 
>> b/src/ipa/ipu3/algorithms/blc.cpp
>> index 78ab7bff..e9b4bed8 100644
>> --- a/src/ipa/ipu3/algorithms/blc.cpp
>> +++ b/src/ipa/ipu3/algorithms/blc.cpp
>> @@ -38,14 +38,16 @@ BlackLevelCorrection::BlackLevelCorrection()
>>     /**
>>    * \brief Fill in the parameter structure, and enable black level 
>> correction
>> + * \param frame The frame number
>>    * \param context The shared IPA context
>>    * \param 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)
>> +void BlackLevelCorrection::prepare([[maybe_unused]] const uint32_t 
>> frame,
>> +                   [[maybe_unused]] IPAContext &context,
>> +                   ipu3_uapi_params *params)
>>   {
>>       /*
>>        * The Optical Black Level correction values
>> diff --git a/src/ipa/ipu3/algorithms/blc.h 
>> b/src/ipa/ipu3/algorithms/blc.h
>> index d8da1748..e4c22070 100644
>> --- a/src/ipa/ipu3/algorithms/blc.h
>> +++ b/src/ipa/ipu3/algorithms/blc.h
>> @@ -18,7 +18,7 @@ class BlackLevelCorrection : public Algorithm
>>   public:
>>       BlackLevelCorrection();
>>   -    void prepare(IPAContext &context, ipu3_uapi_params *params) 
>> override;
>> +    void prepare(const uint32_t frame, IPAContext &context, 
>> ipu3_uapi_params *params) override;
>>   };
>>     } /* namespace ipa::ipu3::algorithms */
>> diff --git a/src/ipa/ipu3/algorithms/tone_mapping.cpp 
>> b/src/ipa/ipu3/algorithms/tone_mapping.cpp
>> index 2040eda5..bba5bc9a 100644
>> --- a/src/ipa/ipu3/algorithms/tone_mapping.cpp
>> +++ b/src/ipa/ipu3/algorithms/tone_mapping.cpp
>> @@ -49,13 +49,15 @@ int ToneMapping::configure(IPAContext &context,
>>     /**
>>    * \brief Fill in the parameter structure, and enable gamma control
>> + * \param frame The frame number
>>    * \param context The shared IPA context
>>    * \param 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,
>> +void ToneMapping::prepare([[maybe_unused]] const uint32_t frame,
>> +              [[maybe_unused]] IPAContext &context,
>>                 ipu3_uapi_params *params)
>>   {
>>       /* Copy the calculated LUT into the parameters buffer. */
>> @@ -71,13 +73,14 @@ void ToneMapping::prepare([[maybe_unused]] 
>> IPAContext &context,
>>     /**
>>    * \brief Calculate the tone mapping look up table
>> + * \param frame The frame number
>>    * \param context The shared IPA context
>>    * \param 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,
>> +void ToneMapping::process(const uint32_t frame, IPAContext &context,
>>                 [[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 b727ab1e..041c9c0d 100644
>> --- a/src/ipa/ipu3/algorithms/tone_mapping.h
>> +++ b/src/ipa/ipu3/algorithms/tone_mapping.h
>> @@ -19,8 +19,8 @@ public:
>>       ToneMapping();
>>         int configure(IPAContext &context, const IPAConfigInfo 
>> &configInfo) override;
>> -    void prepare(IPAContext &context, ipu3_uapi_params *params) 
>> override;
>> -    void process(IPAContext &context, const ipu3_uapi_stats_3a 
>> *stats) override;
>> +    void prepare(const uint32_t frame, IPAContext &context, 
>> ipu3_uapi_params *params) override;
>> +    void process(const uint32_t frame, IPAContext &context, const 
>> ipu3_uapi_stats_3a *stats) override;
>>     private:
>>       double gamma_;
>> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
>> index 3d307708..aef232c3 100644
>> --- a/src/ipa/ipu3/ipu3.cpp
>> +++ b/src/ipa/ipu3/ipu3.cpp
>> @@ -595,7 +595,7 @@ void IPAIPU3::fillParams(unsigned int frame, 
>> ipu3_uapi_params *params)
>>       params->use = {};
>>         for (auto const &algo : algorithms_)
>> -        algo->prepare(context_, params);
>> +        algo->prepare(frame, context_, params);
>>         IPU3Action op;
>>       op.op = ActionParamFilled;
>> @@ -620,7 +620,7 @@ void IPAIPU3::parseStatistics(unsigned int frame,
>>       ControlList ctrls(controls::controls);
>>         for (auto const &algo : algorithms_)
>> -        algo->process(context_, stats);
>> +        algo->process(frame, context_, stats);
>>         setControls(frame);
>>   diff --git a/src/ipa/libipa/algorithm.cpp 
>> b/src/ipa/libipa/algorithm.cpp
>> index 398d5372..01967f07 100644
>> --- a/src/ipa/libipa/algorithm.cpp
>> +++ b/src/ipa/libipa/algorithm.cpp
>> @@ -48,6 +48,7 @@ namespace ipa {
>>   /**
>>    * \fn Algorithm::prepare()
>>    * \brief Fill the \a params buffer with ISP processing parameters 
>> for a frame
>> + * \param[in] frame The frame number
>>    * \param[in] context The shared IPA context
>>    * \param[out] params The ISP specific parameters.
>>    *
>> @@ -63,6 +64,7 @@ namespace ipa {
>>   /**
>>    * \fn Algorithm::process()
>>    * \brief Process ISP statistics, and run algorithm operations
>> + * \param[in] frame The frame number
>>    * \param[in] context The shared IPA 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 766aee5d..1df93625 100644
>> --- a/src/ipa/libipa/algorithm.h
>> +++ b/src/ipa/libipa/algorithm.h
>> @@ -22,12 +22,14 @@ public:
>>           return 0;
>>       }
>>   -    virtual void prepare([[maybe_unused]] Context &context,
>> +    virtual void prepare([[maybe_unused]] const uint32_t frame,
>> +                 [[maybe_unused]] Context &context,
>>                    [[maybe_unused]] Params *params)
>>       {
>>       }
>>   -    virtual void process([[maybe_unused]] Context &context,
>> +    virtual void process([[maybe_unused]] const uint32_t frame,
>> +                 [[maybe_unused]] Context &context,
>>                    [[maybe_unused]] const Stats *stats)
>>       {
>>       }
>>

Patch
diff mbox series

diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp
index 8d6f18f6..1d0778d8 100644
--- a/src/ipa/ipu3/algorithms/agc.cpp
+++ b/src/ipa/ipu3/algorithms/agc.cpp
@@ -307,13 +307,14 @@  double Agc::estimateLuminance(IPAFrameContext &frameContext,
 
 /**
  * \brief Process IPU3 statistics, and run AGC operations
+ * \param frame The frame number
  * \param[in] context The shared IPA 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, const ipu3_uapi_stats_3a *stats)
+void Agc::process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats)
 {
 	/*
 	 * Estimate the gain needed to have the proportion of pixels in a given
diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h
index 96ec7005..c6ab8e91 100644
--- a/src/ipa/ipu3/algorithms/agc.h
+++ b/src/ipa/ipu3/algorithms/agc.h
@@ -28,7 +28,7 @@  public:
 	~Agc() = default;
 
 	int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
-	void process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override;
+	void process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats) override;
 
 private:
 	double measureBrightness(const ipu3_uapi_stats_3a *stats,
diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp
index 1dc27fc9..99fb5305 100644
--- a/src/ipa/ipu3/algorithms/awb.cpp
+++ b/src/ipa/ipu3/algorithms/awb.cpp
@@ -379,7 +379,7 @@  void Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats)
 /**
  * \copydoc libcamera::ipa::Algorithm::process
  */
-void Awb::process(IPAContext &context, const ipu3_uapi_stats_3a *stats)
+void Awb::process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats)
 {
 	calculateWBGains(stats);
 
@@ -403,7 +403,7 @@  constexpr uint16_t Awb::threshold(float value)
 /**
  * \copydoc libcamera::ipa::Algorithm::prepare
  */
-void Awb::prepare(IPAContext &context, ipu3_uapi_params *params)
+void Awb::prepare([[maybe_unused]] const uint32_t frame, IPAContext &context, ipu3_uapi_params *params)
 {
 	/*
 	 * Green saturation thresholds are reduced because we are using the
diff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h
index ab4b0a33..ef177a4a 100644
--- a/src/ipa/ipu3/algorithms/awb.h
+++ b/src/ipa/ipu3/algorithms/awb.h
@@ -39,8 +39,8 @@  public:
 	~Awb();
 
 	int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
-	void prepare(IPAContext &context, ipu3_uapi_params *params) override;
-	void process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override;
+	void prepare(const uint32_t frame, IPAContext &context, ipu3_uapi_params *params) override;
+	void process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats) override;
 
 private:
 	/* \todo Make these structs available to all the ISPs ? */
diff --git a/src/ipa/ipu3/algorithms/blc.cpp b/src/ipa/ipu3/algorithms/blc.cpp
index 78ab7bff..e9b4bed8 100644
--- a/src/ipa/ipu3/algorithms/blc.cpp
+++ b/src/ipa/ipu3/algorithms/blc.cpp
@@ -38,14 +38,16 @@  BlackLevelCorrection::BlackLevelCorrection()
 
 /**
  * \brief Fill in the parameter structure, and enable black level correction
+ * \param frame The frame number
  * \param context The shared IPA context
  * \param 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)
+void BlackLevelCorrection::prepare([[maybe_unused]] const uint32_t frame,
+				   [[maybe_unused]] IPAContext &context,
+				   ipu3_uapi_params *params)
 {
 	/*
 	 * The Optical Black Level correction values
diff --git a/src/ipa/ipu3/algorithms/blc.h b/src/ipa/ipu3/algorithms/blc.h
index d8da1748..e4c22070 100644
--- a/src/ipa/ipu3/algorithms/blc.h
+++ b/src/ipa/ipu3/algorithms/blc.h
@@ -18,7 +18,7 @@  class BlackLevelCorrection : public Algorithm
 public:
 	BlackLevelCorrection();
 
-	void prepare(IPAContext &context, ipu3_uapi_params *params) override;
+	void prepare(const uint32_t frame, IPAContext &context, ipu3_uapi_params *params) override;
 };
 
 } /* namespace ipa::ipu3::algorithms */
diff --git a/src/ipa/ipu3/algorithms/tone_mapping.cpp b/src/ipa/ipu3/algorithms/tone_mapping.cpp
index 2040eda5..bba5bc9a 100644
--- a/src/ipa/ipu3/algorithms/tone_mapping.cpp
+++ b/src/ipa/ipu3/algorithms/tone_mapping.cpp
@@ -49,13 +49,15 @@  int ToneMapping::configure(IPAContext &context,
 
 /**
  * \brief Fill in the parameter structure, and enable gamma control
+ * \param frame The frame number
  * \param context The shared IPA context
  * \param 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,
+void ToneMapping::prepare([[maybe_unused]] const uint32_t frame,
+			  [[maybe_unused]] IPAContext &context,
 			  ipu3_uapi_params *params)
 {
 	/* Copy the calculated LUT into the parameters buffer. */
@@ -71,13 +73,14 @@  void ToneMapping::prepare([[maybe_unused]] IPAContext &context,
 
 /**
  * \brief Calculate the tone mapping look up table
+ * \param frame The frame number
  * \param context The shared IPA context
  * \param 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,
+void ToneMapping::process(const uint32_t frame, IPAContext &context,
 			  [[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 b727ab1e..041c9c0d 100644
--- a/src/ipa/ipu3/algorithms/tone_mapping.h
+++ b/src/ipa/ipu3/algorithms/tone_mapping.h
@@ -19,8 +19,8 @@  public:
 	ToneMapping();
 
 	int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
-	void prepare(IPAContext &context, ipu3_uapi_params *params) override;
-	void process(IPAContext &context, const ipu3_uapi_stats_3a *stats) override;
+	void prepare(const uint32_t frame, IPAContext &context, ipu3_uapi_params *params) override;
+	void process(const uint32_t frame, IPAContext &context, const ipu3_uapi_stats_3a *stats) override;
 
 private:
 	double gamma_;
diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index 3d307708..aef232c3 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -595,7 +595,7 @@  void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)
 	params->use = {};
 
 	for (auto const &algo : algorithms_)
-		algo->prepare(context_, params);
+		algo->prepare(frame, context_, params);
 
 	IPU3Action op;
 	op.op = ActionParamFilled;
@@ -620,7 +620,7 @@  void IPAIPU3::parseStatistics(unsigned int frame,
 	ControlList ctrls(controls::controls);
 
 	for (auto const &algo : algorithms_)
-		algo->process(context_, stats);
+		algo->process(frame, context_, stats);
 
 	setControls(frame);
 
diff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp
index 398d5372..01967f07 100644
--- a/src/ipa/libipa/algorithm.cpp
+++ b/src/ipa/libipa/algorithm.cpp
@@ -48,6 +48,7 @@  namespace ipa {
 /**
  * \fn Algorithm::prepare()
  * \brief Fill the \a params buffer with ISP processing parameters for a frame
+ * \param[in] frame The frame number
  * \param[in] context The shared IPA context
  * \param[out] params The ISP specific parameters.
  *
@@ -63,6 +64,7 @@  namespace ipa {
 /**
  * \fn Algorithm::process()
  * \brief Process ISP statistics, and run algorithm operations
+ * \param[in] frame The frame number
  * \param[in] context The shared IPA 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 766aee5d..1df93625 100644
--- a/src/ipa/libipa/algorithm.h
+++ b/src/ipa/libipa/algorithm.h
@@ -22,12 +22,14 @@  public:
 		return 0;
 	}
 
-	virtual void prepare([[maybe_unused]] Context &context,
+	virtual void prepare([[maybe_unused]] const uint32_t frame,
+			     [[maybe_unused]] Context &context,
 			     [[maybe_unused]] Params *params)
 	{
 	}
 
-	virtual void process([[maybe_unused]] Context &context,
+	virtual void process([[maybe_unused]] const uint32_t frame,
+			     [[maybe_unused]] Context &context,
 			     [[maybe_unused]] const Stats *stats)
 	{
 	}