[libcamera-devel,v3,08/14] ipa: ipu3: agc: Use filtered exposure values
diff mbox series

Message ID 20211021164401.110033-9-jeanmichel.hautbois@ideasonboard.com
State Superseded
Headers show
Series
  • ipa: ipu3: Fix AGC bugs
Related show

Commit Message

Jean-Michel Hautbois Oct. 21, 2021, 4:43 p.m. UTC
We are filtering the exposure value to limit the gain to apply, but we
are not using the result.

Fix it.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
---
 src/ipa/ipu3/algorithms/agc.cpp | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Kieran Bingham Oct. 21, 2021, 9:02 p.m. UTC | #1
Quoting Jean-Michel Hautbois (2021-10-21 17:43:55)
> We are filtering the exposure value to limit the gain to apply, but we
> are not using the result.
> 
> Fix it.
> 
> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  src/ipa/ipu3/algorithms/agc.cpp | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp
> index 984aed53..f5bb3328 100644
> --- a/src/ipa/ipu3/algorithms/agc.cpp
> +++ b/src/ipa/ipu3/algorithms/agc.cpp
> @@ -158,17 +158,17 @@ void Agc::lockExposureGain(uint32_t &exposure, double &gain)
>  
>                 utils::Duration newExposure = 0.0s;
>                 if (currentShutter < maxShutterSpeed) {
> -                       exposure = std::clamp<uint32_t>(exposure * currentExposure_ / currentExposureNoDg_,
> +                       exposure = std::clamp<uint32_t>(exposure * filteredExposure_ / currentExposureNoDg_,
>                                                         minExposureLines_,
>                                                         maxExposureLines_);
> -                       newExposure = currentExposure_ / exposure;
> -                       gain = std::clamp(gain * currentExposure_ / newExposure,
> +                       newExposure = filteredExposure_ / exposure;
> +                       gain = std::clamp(gain * filteredExposure_ / newExposure,
>                                           kMinGain, kMaxGain);
>                 } else {
> -                       gain = std::clamp(gain * currentExposure_ / currentExposureNoDg_,
> +                       gain = std::clamp(gain * filteredExposure_ / currentExposureNoDg_,
>                                           kMinGain, kMaxGain);
> -                       newExposure = currentExposure_ / gain;
> -                       exposure = std::clamp<uint32_t>(exposure * currentExposure_ / newExposure,
> +                       newExposure = filteredExposure_ / gain;
> +                       exposure = std::clamp<uint32_t>(exposure * filteredExposure_ / newExposure,
>                                                         minExposureLines_,
>                                                         maxExposureLines_);
>                 }
> -- 
> 2.32.0
>
Laurent Pinchart Oct. 22, 2021, 4:10 a.m. UTC | #2
Hi Jean-Michel,

Thank you for the patch.

On Thu, Oct 21, 2021 at 06:43:55PM +0200, Jean-Michel Hautbois wrote:
> We are filtering the exposure value to limit the gain to apply, but we
> are not using the result.
> 
> Fix it.
> 
> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/ipa/ipu3/algorithms/agc.cpp | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp
> index 984aed53..f5bb3328 100644
> --- a/src/ipa/ipu3/algorithms/agc.cpp
> +++ b/src/ipa/ipu3/algorithms/agc.cpp
> @@ -158,17 +158,17 @@ void Agc::lockExposureGain(uint32_t &exposure, double &gain)
>  
>  		utils::Duration newExposure = 0.0s;
>  		if (currentShutter < maxShutterSpeed) {
> -			exposure = std::clamp<uint32_t>(exposure * currentExposure_ / currentExposureNoDg_,
> +			exposure = std::clamp<uint32_t>(exposure * filteredExposure_ / currentExposureNoDg_,
>  							minExposureLines_,
>  							maxExposureLines_);
> -			newExposure = currentExposure_ / exposure;
> -			gain = std::clamp(gain * currentExposure_ / newExposure,
> +			newExposure = filteredExposure_ / exposure;
> +			gain = std::clamp(gain * filteredExposure_ / newExposure,
>  					  kMinGain, kMaxGain);
>  		} else {
> -			gain = std::clamp(gain * currentExposure_ / currentExposureNoDg_,
> +			gain = std::clamp(gain * filteredExposure_ / currentExposureNoDg_,
>  					  kMinGain, kMaxGain);
> -			newExposure = currentExposure_ / gain;
> -			exposure = std::clamp<uint32_t>(exposure * currentExposure_ / newExposure,
> +			newExposure = filteredExposure_ / gain;
> +			exposure = std::clamp<uint32_t>(exposure * filteredExposure_ / newExposure,
>  							minExposureLines_,
>  							maxExposureLines_);
>  		}

Patch
diff mbox series

diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp
index 984aed53..f5bb3328 100644
--- a/src/ipa/ipu3/algorithms/agc.cpp
+++ b/src/ipa/ipu3/algorithms/agc.cpp
@@ -158,17 +158,17 @@  void Agc::lockExposureGain(uint32_t &exposure, double &gain)
 
 		utils::Duration newExposure = 0.0s;
 		if (currentShutter < maxShutterSpeed) {
-			exposure = std::clamp<uint32_t>(exposure * currentExposure_ / currentExposureNoDg_,
+			exposure = std::clamp<uint32_t>(exposure * filteredExposure_ / currentExposureNoDg_,
 							minExposureLines_,
 							maxExposureLines_);
-			newExposure = currentExposure_ / exposure;
-			gain = std::clamp(gain * currentExposure_ / newExposure,
+			newExposure = filteredExposure_ / exposure;
+			gain = std::clamp(gain * filteredExposure_ / newExposure,
 					  kMinGain, kMaxGain);
 		} else {
-			gain = std::clamp(gain * currentExposure_ / currentExposureNoDg_,
+			gain = std::clamp(gain * filteredExposure_ / currentExposureNoDg_,
 					  kMinGain, kMaxGain);
-			newExposure = currentExposure_ / gain;
-			exposure = std::clamp<uint32_t>(exposure * currentExposure_ / newExposure,
+			newExposure = filteredExposure_ / gain;
+			exposure = std::clamp<uint32_t>(exposure * filteredExposure_ / newExposure,
 							minExposureLines_,
 							maxExposureLines_);
 		}