summaryrefslogtreecommitdiff
path: root/src/ipa/simple/soft_simple.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipa/simple/soft_simple.cpp')
-rw-r--r--src/ipa/simple/soft_simple.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/ipa/simple/soft_simple.cpp b/src/ipa/simple/soft_simple.cpp
index ff1d8e0c..b9fb58b5 100644
--- a/src/ipa/simple/soft_simple.cpp
+++ b/src/ipa/simple/soft_simple.cpp
@@ -26,8 +26,9 @@
#include "libipa/camera_sensor_helper.h"
-namespace libcamera {
+#include "black_level.h"
+namespace libcamera {
LOG_DEFINE_CATEGORY(IPASoft)
namespace ipa::soft {
@@ -54,7 +55,8 @@ class IPASoftSimple : public ipa::soft::IPASoftInterface
{
public:
IPASoftSimple()
- : params_(nullptr), stats_(nullptr), ignoreUpdates_(0)
+ : params_(nullptr), stats_(nullptr), blackLevel_(BlackLevel()),
+ ignoreUpdates_(0)
{
}
@@ -78,6 +80,7 @@ private:
SwIspStats *stats_;
std::unique_ptr<CameraSensorHelper> camHelper_;
ControlInfoMap sensorInfoMap_;
+ BlackLevel blackLevel_;
int32_t exposureMin_, exposureMax_;
int32_t exposure_;
@@ -255,6 +258,10 @@ void IPASoftSimple::processStats(const ControlList &sensorControls)
params_->gainG = 256;
params_->gamma = 0.5;
+ if (ignoreUpdates_ > 0)
+ blackLevel_.update(stats_->yHistogram);
+ params_->blackLevel = blackLevel_.get();
+
setIspParams.emit();
/* \todo Switch to the libipa/algorithm.h API someday. */
@@ -273,18 +280,20 @@ void IPASoftSimple::processStats(const ControlList &sensorControls)
* Calculate Mean Sample Value (MSV) according to formula from:
* https://www.araa.asn.au/acra/acra2007/papers/paper84final.pdf
*/
- constexpr unsigned int yHistValsPerBin =
- SwIspStats::kYHistogramSize / kExposureBinsCount;
- constexpr unsigned int yHistValsPerBinMod =
- SwIspStats::kYHistogramSize /
- (SwIspStats::kYHistogramSize % kExposureBinsCount + 1);
+ const unsigned int blackLevelHistIdx =
+ params_->blackLevel / (256 / SwIspStats::kYHistogramSize);
+ const unsigned int histogramSize =
+ SwIspStats::kYHistogramSize - blackLevelHistIdx;
+ const unsigned int yHistValsPerBin = histogramSize / kExposureBinsCount;
+ const unsigned int yHistValsPerBinMod =
+ histogramSize / (histogramSize % kExposureBinsCount + 1);
int exposureBins[kExposureBinsCount] = {};
unsigned int denom = 0;
unsigned int num = 0;
- for (unsigned int i = 0; i < SwIspStats::kYHistogramSize; i++) {
+ for (unsigned int i = 0; i < histogramSize; i++) {
unsigned int idx = (i - (i / yHistValsPerBinMod)) / yHistValsPerBin;
- exposureBins[idx] += stats_->yHistogram[i];
+ exposureBins[idx] += stats_->yHistogram[blackLevelHistIdx + i];
}
for (unsigned int i = 0; i < kExposureBinsCount; i++) {
@@ -320,7 +329,8 @@ void IPASoftSimple::processStats(const ControlList &sensorControls)
LOG(IPASoft, Debug) << "exposureMSV " << exposureMSV
<< " exp " << exposure_ << " again " << again_
- << " gain R/B " << params_->gainR << "/" << params_->gainB;
+ << " gain R/B " << params_->gainR << "/" << params_->gainB
+ << " black level " << params_->blackLevel;
}
void IPASoftSimple::updateExposure(double exposureMSV)