@@ -14,6 +14,8 @@
#include "simple/ipa_context.h"
+#include "control_ids.h"
+
namespace libcamera {
LOG_DEFINE_CATEGORY(IPASoftAwb)
@@ -33,10 +35,16 @@ void Awb::process(IPAContext &context,
[[maybe_unused]] const uint32_t frame,
[[maybe_unused]] IPAFrameContext &frameContext,
const SwIspStats *stats,
- [[maybe_unused]] ControlList &metadata)
+ ControlList &metadata)
{
const SwIspStats::Histogram &histogram = stats->yHistogram;
const uint8_t blackLevel = context.activeState.blc.level;
+ auto &gains = context.activeState.gains;
+
+ const float maxGain = 1024.0;
+ const float mdGains[] = { static_cast<float>(gains.red / maxGain),
+ static_cast<float>(gains.blue / maxGain) };
+ metadata.set(controls::ColourGains, mdGains);
/*
* Black level must be subtracted to get the correct AWB ratios, they
@@ -54,7 +62,6 @@ void Awb::process(IPAContext &context,
* Calculate red and blue gains for AWB.
* Clamp max gain at 4.0, this also avoids 0 division.
*/
- auto &gains = context.activeState.gains;
gains.red = sumR <= sumG / 4 ? 4.0 : static_cast<double>(sumG) / sumR;
gains.blue = sumB <= sumG / 4 ? 4.0 : static_cast<double>(sumG) / sumB;
/* Green gain is fixed to 1.0 */