@@ -168,6 +168,65 @@ int AwbAlgorithm::configure(awb::ActiveState &state, awb::Session &session)
return 0;
}
+/**
+ * \brief Provide control values to the algorithm
+ * \param[in] state The AWB specific active state shared across frames
+ * \param[in] frame The frame number to apply the control values
+ * \param[in] frameContext The current frame's AWB specific context
+ * \param[in] controls The list of user controls
+ */
+void AwbAlgorithm::queueRequest(awb::ActiveState &state,
+ [[maybe_unused]] const uint32_t frame,
+ awb::FrameContext &frameContext,
+ const ControlList &controls)
+{
+ const auto &awbEnable = controls.get(controls::AwbEnable);
+ if (awbEnable && *awbEnable != state.autoEnabled) {
+ state.autoEnabled = *awbEnable;
+
+ LOG(Awb, Debug)
+ << (*awbEnable ? "Enabling" : "Disabling") << " AWB";
+ }
+
+ /* Handle controls from subclass algo (Grey or Bayes) */
+ handleControls(controls);
+
+ frameContext.autoEnabled = state.autoEnabled;
+
+ /* Todo: Check to see if we should always parse the following controls */
+ if (frameContext.autoEnabled)
+ return;
+
+ const auto &colourGains = controls.get(controls::ColourGains);
+ const auto &colourTemperature = controls.get(controls::ColourTemperature);
+ bool update = false;
+ if (colourGains) {
+ state.manual.gains.r() = (*colourGains)[0];
+ state.manual.gains.b() = (*colourGains)[1];
+ /*
+ * \todo Colour temperature reported in metadata is now
+ * incorrect, as we can't deduce the temperature from the gains.
+ * This will be fixed with the bayes AWB algorithm.
+ */
+ update = true;
+ } else if (colourTemperature) {
+ state.manual.temperatureK = *colourTemperature;
+ const auto &gains = gainsFromColourTemperature(*colourTemperature);
+ if (gains) {
+ state.manual.gains.r() = gains->r();
+ state.manual.gains.b() = gains->b();
+ update = true;
+ }
+ }
+
+ if (update)
+ LOG(Awb, Debug)
+ << "Set colour gains to " << state.manual.gains;
+
+ frameContext.gains = state.manual.gains;
+ frameContext.temperatureK = state.manual.temperatureK;
+}
+
/**
* \fn AwbAlgorithm::calculateAwb()
* \brief Calculate AWB data from the given statistics
@@ -68,6 +68,11 @@ public:
int configure(awb::ActiveState &state, awb::Session &session);
+ void queueRequest(awb::ActiveState &state,
+ [[maybe_unused]] const uint32_t frame,
+ awb::FrameContext &frameContext,
+ const ControlList &controls);
+
virtual AwbResult calculateAwb(const AwbStats &stats, unsigned int lux) = 0;
virtual std::optional<RGB<double>> gainsFromColourTemperature(double colourTemperature) = 0;
@@ -146,55 +146,12 @@ int Awb::configure(IPAContext &context,
* \copydoc libcamera::ipa::Algorithm::queueRequest
*/
void Awb::queueRequest(IPAContext &context,
- [[maybe_unused]] const uint32_t frame,
+ const uint32_t frame,
IPAFrameContext &frameContext,
const ControlList &controls)
{
- auto &awb = context.activeState.awb;
-
- const auto &awbEnable = controls.get(controls::AwbEnable);
- if (awbEnable && *awbEnable != awb.autoEnabled) {
- awb.autoEnabled = *awbEnable;
-
- LOG(RkISP1Awb, Debug)
- << (*awbEnable ? "Enabling" : "Disabling") << " AWB";
- }
-
- awbAlgo_->handleControls(controls);
-
- frameContext.awb.autoEnabled = awb.autoEnabled;
-
- if (awb.autoEnabled)
- return;
-
- const auto &colourGains = controls.get(controls::ColourGains);
- const auto &colourTemperature = controls.get(controls::ColourTemperature);
- bool update = false;
- if (colourGains) {
- awb.manual.gains.r() = (*colourGains)[0];
- awb.manual.gains.b() = (*colourGains)[1];
- /*
- * \todo Colour temperature reported in metadata is now
- * incorrect, as we can't deduce the temperature from the gains.
- * This will be fixed with the bayes AWB algorithm.
- */
- update = true;
- } else if (colourTemperature) {
- awb.manual.temperatureK = *colourTemperature;
- const auto &gains = awbAlgo_->gainsFromColourTemperature(*colourTemperature);
- if (gains) {
- awb.manual.gains.r() = gains->r();
- awb.manual.gains.b() = gains->b();
- update = true;
- }
- }
-
- if (update)
- LOG(RkISP1Awb, Debug)
- << "Set colour gains to " << awb.manual.gains;
-
- frameContext.awb.gains = awb.manual.gains;
- frameContext.awb.temperatureK = awb.manual.temperatureK;
+ awbAlgo_->queueRequest(context.activeState.awb, frame, frameContext.awb,
+ controls);
}
/**
@@ -114,55 +114,13 @@ int Awb::configure(IPAContext &context,
* \copydoc libcamera::ipa::Algorithm::queueRequest
*/
void Awb::queueRequest(IPAContext &context,
- [[maybe_unused]] const uint32_t frame,
- [[maybe_unused]] IPAFrameContext &frameContext,
+ const uint32_t frame,
+ IPAFrameContext &frameContext,
const ControlList &controls)
{
- auto &awb = context.activeState.awb;
-
- const auto &awbEnable = controls.get(controls::AwbEnable);
- if (awbEnable && *awbEnable != awb.autoEnabled) {
- awb.autoEnabled = *awbEnable;
-
- LOG(IPASoftAwb, Debug)
- << (*awbEnable ? "Enabling" : "Disabling") << " AWB";
- }
-
- awbAlgo_->handleControls(controls);
-
- frameContext.awb.autoEnabled = awb.autoEnabled;
-
- if (awb.autoEnabled)
- return;
-
- const auto &colourGains = controls.get(controls::ColourGains);
- const auto &colourTemperature = controls.get(controls::ColourTemperature);
- bool update = false;
- if (colourGains) {
- awb.manual.gains.r() = (*colourGains)[0];
- awb.manual.gains.b() = (*colourGains)[1];
- /*
- * \todo Colour temperature reported in metadata is now
- * incorrect, as we can't deduce the temperature from the gains.
- * This will be fixed with the bayes AWB algorithm.
- */
- update = true;
- } else if (colourTemperature) {
- awb.manual.temperatureK = *colourTemperature;
- const auto &gains = awbAlgo_->gainsFromColourTemperature(*colourTemperature);
- if (gains) {
- awb.manual.gains.r() = gains->r();
- awb.manual.gains.b() = gains->b();
- update = true;
- }
- }
-
- if (update)
- LOG(IPASoftAwb, Debug)
- << "Set colour gains to " << awb.manual.gains;
-
- frameContext.awb.gains = awb.manual.gains;
- frameContext.awb.temperatureK = awb.manual.temperatureK;
+ awbAlgo_->queueRequest(context.activeState.awb,
+ frame, frameContext.awb,
+ controls);
}
void Awb::prepare(IPAContext &context,
Move the now duplicated implementation for both soft IPA and rkisp1 IPA for managing requests at queue time into the common libipa AWB implementation. Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> --- src/ipa/libipa/awb.cpp | 59 +++++++++++++++++++++++++++++++++++++++ src/ipa/libipa/awb.h | 5 ++++ src/ipa/rkisp1/algorithms/awb.cpp | 49 ++------------------------------ src/ipa/simple/algorithms/awb.cpp | 52 ++++------------------------------ 4 files changed, 72 insertions(+), 93 deletions(-)