[v4,18/18] libcamera: software_isp: Update black level only on exposure changes
diff mbox series

Message ID 20240815081622.174210-19-mzamazal@redhat.com
State Superseded
Headers show
Series
  • Software ISP refactoring
Related show

Commit Message

Milan Zamazal Aug. 15, 2024, 8:16 a.m. UTC
The black level is likely to get updated, if ever, only after exposure
or gain changes.  Don't compute its possible updates if exposure and
gain are unchanged.

It's probably not worth trying to implement something more
sophisticated.  Better to spend the effort on supporting tuning files.

Signed-off-by: Milan Zamazal <mzamazal@redhat.com>
---
 src/ipa/simple/algorithms/blc.cpp | 9 ++++++++-
 src/ipa/simple/algorithms/blc.h   | 4 ++++
 2 files changed, 12 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp
index ab7e7dd9..d01c2c14 100644
--- a/src/ipa/simple/algorithms/blc.cpp
+++ b/src/ipa/simple/algorithms/blc.cpp
@@ -30,10 +30,15 @@  int BlackLevel::init(IPAContext &context,
 
 void BlackLevel::process(IPAContext &context,
 			 [[maybe_unused]] const uint32_t frame,
-			 [[maybe_unused]] IPAFrameContext &frameContext,
+			 IPAFrameContext &frameContext,
 			 const SwIspStats *stats,
 			 [[maybe_unused]] ControlList &metadata)
 {
+	if (frameContext.sensor.exposure == exposure_ &&
+	    frameContext.sensor.gain == gain_) {
+		return;
+	}
+
 	const SwIspStats::Histogram &histogram = stats->yHistogram;
 
 	/*
@@ -54,6 +59,8 @@  void BlackLevel::process(IPAContext &context,
 		if (seen >= pixelThreshold) {
 			context.activeState.black.level =
 				static_cast<double>(i) / SwIspStats::kYHistogramSize;
+			exposure_ = frameContext.sensor.exposure;
+			gain_ = frameContext.sensor.gain;
 			LOG(IPASoftBL, Debug)
 				<< "Auto-set black level: "
 				<< i << "/" << SwIspStats::kYHistogramSize
diff --git a/src/ipa/simple/algorithms/blc.h b/src/ipa/simple/algorithms/blc.h
index 2f73db52..9b9daab1 100644
--- a/src/ipa/simple/algorithms/blc.h
+++ b/src/ipa/simple/algorithms/blc.h
@@ -30,6 +30,10 @@  public:
 		     IPAFrameContext &frameContext,
 		     const SwIspStats *stats,
 		     ControlList &metadata) override;
+
+private:
+	uint32_t exposure_;
+	double gain_;
 };
 
 } /* namespace ipa::soft::algorithms */