[RFC,v3,36/50] ipa: simple: Store exposure as `uint32_t`
diff mbox series

Message ID 20260803131435.153927-37-barnabas.pocze@ideasonboard.com
State Superseded
Headers show
Series
  • ipa: libipa: agc rework
Related show

Commit Message

Barnabás Pőcze Aug. 3, 2026, 1:14 p.m. UTC
Every other IPA module does that, so switch to `uint32_t` here as well.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/ipa/simple/algorithms/agc.cpp |  6 +++---
 src/ipa/simple/ipa_context.h      | 10 +++++-----
 2 files changed, 8 insertions(+), 8 deletions(-)

Comments

Milan Zamazal Aug. 4, 2026, 9:56 a.m. UTC | #1
Barnabás Pőcze <barnabas.pocze@ideasonboard.com> writes:

> Every other IPA module does that, so switch to `uint32_t` here as well.
>
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>

Reviewed-by: Milan Zamazal <mzamazal@redhat.com>

> ---
>  src/ipa/simple/algorithms/agc.cpp |  6 +++---
>  src/ipa/simple/ipa_context.h      | 10 +++++-----
>  2 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/src/ipa/simple/algorithms/agc.cpp b/src/ipa/simple/algorithms/agc.cpp
> index e9bcb2c032..93505f7665 100644
> --- a/src/ipa/simple/algorithms/agc.cpp
> +++ b/src/ipa/simple/algorithms/agc.cpp
> @@ -67,7 +67,7 @@ Agc::Agc()
>  
>  void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, double exposureMSV)
>  {
> -	int32_t exposure = frameContext.sensor.exposure;
> +	uint32_t exposure = frameContext.sensor.exposure;
>  	double again = frameContext.sensor.gain;
>  
>  	double error = kExposureOptimal - exposureMSV;
> @@ -87,7 +87,7 @@ void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, dou
>  	if (factor > 1.0f) {
>  		/* Scene too dark: increase exposure first, then gain. */
>  		if (exposure < context.configuration.agc.exposureMax) {
> -			int32_t next = static_cast<int32_t>(exposure * factor);
> +			uint32_t next = exposure * factor;
>  			exposure = std::max(next, exposure + 1);
>  		} else {
>  			double next = again * factor;
> @@ -105,7 +105,7 @@ void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, dou
>  			else
>  				again = next;
>  		} else {
> -			int32_t next = static_cast<int32_t>(exposure * factor);
> +			uint32_t next = exposure * factor;
>  			exposure = std::min(next, exposure - 1);
>  		}
>  	}
> diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h
> index d35fb1e91d..980dc93cc4 100644
> --- a/src/ipa/simple/ipa_context.h
> +++ b/src/ipa/simple/ipa_context.h
> @@ -26,7 +26,7 @@ namespace ipa::soft {
>  
>  struct IPASessionConfiguration {
>  	struct {
> -		int32_t exposureMin, exposureMax;
> +		uint32_t exposureMin, exposureMax;
>  		double againMin, againMax, again10, againMinStep;
>  		utils::Duration lineDuration;
>  	} agc;
> @@ -37,14 +37,14 @@ struct IPASessionConfiguration {
>  
>  struct IPAActiveState {
>  	struct {
> -		int32_t exposure;
> +		uint32_t exposure;
>  		double again;
>  		bool valid;
>  	} agc;
>  
>  	struct {
>  		uint8_t level;
> -		int32_t lastExposure;
> +		uint32_t lastExposure;
>  		double lastGain;
>  	} blc;
>  
> @@ -67,12 +67,12 @@ struct IPAFrameContext : public FrameContext {
>  	Matrix<float, 3, 3> ccm;
>  
>  	struct {
> -		int32_t exposure;
> +		uint32_t exposure;
>  		double gain;
>  	} agc;
>  
>  	struct {
> -		int32_t exposure;
> +		uint32_t exposure;
>  		double gain;
>  	} sensor;

Patch
diff mbox series

diff --git a/src/ipa/simple/algorithms/agc.cpp b/src/ipa/simple/algorithms/agc.cpp
index e9bcb2c032..93505f7665 100644
--- a/src/ipa/simple/algorithms/agc.cpp
+++ b/src/ipa/simple/algorithms/agc.cpp
@@ -67,7 +67,7 @@  Agc::Agc()
 
 void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, double exposureMSV)
 {
-	int32_t exposure = frameContext.sensor.exposure;
+	uint32_t exposure = frameContext.sensor.exposure;
 	double again = frameContext.sensor.gain;
 
 	double error = kExposureOptimal - exposureMSV;
@@ -87,7 +87,7 @@  void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, dou
 	if (factor > 1.0f) {
 		/* Scene too dark: increase exposure first, then gain. */
 		if (exposure < context.configuration.agc.exposureMax) {
-			int32_t next = static_cast<int32_t>(exposure * factor);
+			uint32_t next = exposure * factor;
 			exposure = std::max(next, exposure + 1);
 		} else {
 			double next = again * factor;
@@ -105,7 +105,7 @@  void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, dou
 			else
 				again = next;
 		} else {
-			int32_t next = static_cast<int32_t>(exposure * factor);
+			uint32_t next = exposure * factor;
 			exposure = std::min(next, exposure - 1);
 		}
 	}
diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h
index d35fb1e91d..980dc93cc4 100644
--- a/src/ipa/simple/ipa_context.h
+++ b/src/ipa/simple/ipa_context.h
@@ -26,7 +26,7 @@  namespace ipa::soft {
 
 struct IPASessionConfiguration {
 	struct {
-		int32_t exposureMin, exposureMax;
+		uint32_t exposureMin, exposureMax;
 		double againMin, againMax, again10, againMinStep;
 		utils::Duration lineDuration;
 	} agc;
@@ -37,14 +37,14 @@  struct IPASessionConfiguration {
 
 struct IPAActiveState {
 	struct {
-		int32_t exposure;
+		uint32_t exposure;
 		double again;
 		bool valid;
 	} agc;
 
 	struct {
 		uint8_t level;
-		int32_t lastExposure;
+		uint32_t lastExposure;
 		double lastGain;
 	} blc;
 
@@ -67,12 +67,12 @@  struct IPAFrameContext : public FrameContext {
 	Matrix<float, 3, 3> ccm;
 
 	struct {
-		int32_t exposure;
+		uint32_t exposure;
 		double gain;
 	} agc;
 
 	struct {
-		int32_t exposure;
+		uint32_t exposure;
 		double gain;
 	} sensor;