summaryrefslogtreecommitdiff
path: root/src/ipa/simple
diff options
context:
space:
mode:
authorMilan Zamazal <mzamazal@redhat.com>2024-09-27 15:46:24 +0200
committerKieran Bingham <kieran.bingham@ideasonboard.com>2024-09-27 15:01:57 +0100
commit6c0aefdaf92b62e77bdc3b8add2b8107e50a5544 (patch)
tree3d67dd8320f1b1a2647b1eb06a084653f71aa15b /src/ipa/simple
parentfb8ad13dc3e38a1bb056c209f692af53588c7b84 (diff)
libcamera: software_isp: Update black level only on exposure changes
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> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/ipa/simple')
-rw-r--r--src/ipa/simple/algorithms/blc.cpp9
-rw-r--r--src/ipa/simple/algorithms/blc.h4
2 files changed, 12 insertions, 1 deletions
diff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp
index 755108b0..b9f2aaa6 100644
--- a/src/ipa/simple/algorithms/blc.cpp
+++ b/src/ipa/simple/algorithms/blc.cpp
@@ -30,10 +30,15 @@ int BlackLevel::configure(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,
seen += histogram[i];
if (seen >= pixelThreshold) {
context.activeState.blc.level = i * histogramRatio;
+ 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 49bdcc61..828ad8b1 100644
--- a/src/ipa/simple/algorithms/blc.h
+++ b/src/ipa/simple/algorithms/blc.h
@@ -24,6 +24,10 @@ public:
IPAFrameContext &frameContext,
const SwIspStats *stats,
ControlList &metadata) override;
+
+private:
+ uint32_t exposure_;
+ double gain_;
};
} /* namespace ipa::soft::algorithms */
">getDelays(int &exposureDelay, int &gainDelay, int &vblankDelay, int &hblankDelay) const override; private: static constexpr uint32_t minExposureLines = 1; static constexpr uint32_t maxGainCode = 239; static constexpr Duration timePerLine = 550.0 / 37.125e6 * 1.0s; /* * Smallest difference between the frame length and integration time, * in units of lines. */ static constexpr int frameIntegrationDiff = 4; }; CamHelperImx296::CamHelperImx296() : CamHelper(nullptr, frameIntegrationDiff) { } uint32_t CamHelperImx296::gainCode(double gain) const { uint32_t code = 20 * std::log10(gain) * 10; return std::min(code, maxGainCode); } double CamHelperImx296::gain(uint32_t gainCode) const { return std::pow(10.0, gainCode / 200.0); } uint32_t CamHelperImx296::exposureLines(const Duration exposure, [[maybe_unused]] const Duration lineLength) const { return std::max<uint32_t>(minExposureLines, (exposure - 14.26us) / timePerLine); } Duration CamHelperImx296::exposure(uint32_t exposureLines, [[maybe_unused]] const Duration lineLength) const { return std::max<uint32_t>(minExposureLines, exposureLines) * timePerLine + 14.26us; } void CamHelperImx296::getDelays(int &exposureDelay, int &gainDelay, int &vblankDelay, int &hblankDelay) const { exposureDelay = 2; gainDelay = 2; vblankDelay = 2; hblankDelay = 2; } static CamHelper *create() { return new CamHelperImx296(); } static RegisterCamHelper reg("imx296", &create);