[RFC,v2,34/43] ipa: simple: agc: Simplify min gain step handling
diff mbox series

Message ID 20260723154327.1357866-35-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • ipa: libipa: agc rework
Related show

Commit Message

Barnabás Pőcze July 23, 2026, 3:43 p.m. UTC
Use `std::{min,max}()` just like it is done for the exposure.

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

Patch
diff mbox series

diff --git a/src/ipa/simple/algorithms/agc.cpp b/src/ipa/simple/algorithms/agc.cpp
index f959abeba5..b25c303835 100644
--- a/src/ipa/simple/algorithms/agc.cpp
+++ b/src/ipa/simple/algorithms/agc.cpp
@@ -130,19 +130,13 @@  void Agc::updateExposure(IPAContext &context, IPAFrameContext &frameContext, dou
 			exposure = std::max(next, exposure + 1);
 		} else {
 			double next = again * factor;
-			if (next - again < context.configuration.agc.againMinStep)
-				again += context.configuration.agc.againMinStep;
-			else
-				again = next;
+			again = std::max(next, again + context.configuration.agc.againMinStep);
 		}
 	} else {
 		/* Scene too bright: decrease gain first, then exposure. */
 		if (again > context.configuration.agc.again10) {
 			double next = again * factor;
-			if (again - next < context.configuration.agc.againMinStep)
-				again -= context.configuration.agc.againMinStep;
-			else
-				again = next;
+			again = std::max(next, again - context.configuration.agc.againMinStep);
 		} else {
 			uint32_t next = exposure * factor;
 			exposure = std::min(next, exposure - 1);