@@ -7,6 +7,8 @@
#pragma once
+#include "../ipa_context.h"
+
#include "algorithm.h"
namespace libcamera {
@@ -27,8 +29,34 @@ class DenoiseBaseAlgorithm : public ipa::rkisp1::Algorithm
protected:
DenoiseBaseAlgorithm() = default;
~DenoiseBaseAlgorithm() = default;
+
+ unsigned computeIso(const IPAContext &context,
+ const IPAFrameContext &frameContext) const;
+ template<typename LevelContainer>
+ int selectIsoBand(unsigned iso, const LevelContainer &levels) const;
};
+inline unsigned DenoiseBaseAlgorithm::computeIso(const IPAContext &context,
+ const IPAFrameContext &frameContext) const
+{
+ double ag = frameContext.agc.gain ? frameContext.agc.gain
+ : context.activeState.agc.automatic.gain;
+ return static_cast<unsigned>(ag * 100.0 + 0.5);
+}
+
+template<typename LevelContainer>
+int DenoiseBaseAlgorithm::selectIsoBand(unsigned iso, const LevelContainer &levels) const
+{
+ if (levels.empty())
+ return -1;
+ int idx = 0;
+ while (idx < static_cast<int>(levels.size()) && iso > levels[idx].maxIso)
+ ++idx;
+ if (idx >= static_cast<int>(levels.size()))
+ idx = static_cast<int>(levels.size()) - 1;
+ return idx;
+}
+
} /* namespace ipa::rkisp1::algorithms */
} /* namespace libcamera */
Provide reusable ISO computation and band selection helpers. computeIso derives an effective ISO value from the AGC gain (approx ISO = gain * 100). selectIsoBand searches the tuning ISO level table for the appropriate band given the current ISO, falling back to the last band if ISO exceeds all defined ranges. Signed-off-by: Rui Wang <rui.wang@ideasonboard.com> --- src/ipa/rkisp1/algorithms/denoise.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)