diff options
author | Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> | 2021-04-22 06:57:23 +0200 |
---|---|---|
committer | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2021-04-22 10:13:03 +0100 |
commit | 9e1bd62de3c61bf6771f656fc1ed7ccdde4f2bba (patch) | |
tree | 0f626e5b8ebddf7a53a0248d491f5f783f3d679d /src/ipa/ipu3/ipu3.cpp | |
parent | b2ddc9b11815976ec0bdf741fded993b8bc9ef4d (diff) |
ipa: ipu3: Add support for IPU3 AEC/AGC algorithm
Implement basic auto-exposure (AE) and auto-gain (AG) correction functions.
The functions computeTargetExposure() and computeGain() are adapted from
the Raspberry Pi AGC implementation to suit the IPU3 structures, and
filtering is added to reduce visible stepsize when there are large
exposure changes.
Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Tested-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/ipa/ipu3/ipu3.cpp')
-rw-r--r-- | src/ipa/ipu3/ipu3.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index a4d327ab..f5343547 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -21,6 +21,7 @@ #include "libcamera/internal/buffer.h" #include "libcamera/internal/log.h" +#include "ipu3_agc.h" #include "ipu3_awb.h" static constexpr uint32_t kMaxCellWidthPerSet = 160; @@ -72,6 +73,8 @@ private: /* Interface to the AWB algorithm */ std::unique_ptr<IPU3Awb> awbAlgo_; + /* Interface to the AEC/AGC algorithm */ + std::unique_ptr<IPU3Agc> agcAlgo_; /* Local parameter storage */ struct ipu3_uapi_params params_; @@ -170,6 +173,9 @@ void IPAIPU3::configure(const std::map<uint32_t, ControlInfoMap> &entityControls awbAlgo_ = std::make_unique<IPU3Awb>(); awbAlgo_->initialise(params_, bdsOutputSize, bdsGrid_); + + agcAlgo_ = std::make_unique<IPU3Agc>(); + agcAlgo_->initialise(bdsGrid_); } void IPAIPU3::mapBuffers(const std::vector<IPABuffer> &buffers) @@ -241,8 +247,8 @@ void IPAIPU3::processControls([[maybe_unused]] unsigned int frame, void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) { - /* Pass a default gamma of 1.0 (default linear correction) */ - awbAlgo_->updateWbParameters(params_, 1.0); + if (agcAlgo_->updateControls()) + awbAlgo_->updateWbParameters(params_, agcAlgo_->gamma()); *params = params_; @@ -257,8 +263,12 @@ void IPAIPU3::parseStatistics(unsigned int frame, { ControlList ctrls(controls::controls); + agcAlgo_->process(stats, exposure_, gain_); awbAlgo_->calculateWBGains(stats); + if (agcAlgo_->updateControls()) + setControls(frame); + IPU3Action op; op.op = ActionMetadataReady; op.controls = ctrls; |