summaryrefslogtreecommitdiff
path: root/src/ipa/simple
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2025-03-27 19:59:41 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2025-03-28 02:09:14 +0200
commita0b97475b1c026e2d562a7672c3f25ede2f4df3c (patch)
tree37e07fa5f3dc84635159b0aea6fc763972430104 /src/ipa/simple
parentfb9908158644c498cee3f3f0b45221d2605a1f20 (diff)
ipa: simple: Report the ColourGains in metadata
Provide the determined colour gains back into the metadata to add to completed requests. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/ipa/simple')
-rw-r--r--src/ipa/simple/algorithms/awb.cpp21
-rw-r--r--src/ipa/simple/algorithms/awb.h6
-rw-r--r--src/ipa/simple/ipa_context.h4
3 files changed, 29 insertions, 2 deletions
diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp
index ec77c6e5..55719059 100644
--- a/src/ipa/simple/algorithms/awb.cpp
+++ b/src/ipa/simple/algorithms/awb.cpp
@@ -17,6 +17,8 @@
#include "libipa/colours.h"
#include "simple/ipa_context.h"
+#include "control_ids.h"
+
namespace libcamera {
LOG_DEFINE_CATEGORY(IPASoftAwb)
@@ -32,15 +34,32 @@ int Awb::configure(IPAContext &context,
return 0;
}
+void Awb::prepare(IPAContext &context,
+ [[maybe_unused]] const uint32_t frame,
+ IPAFrameContext &frameContext,
+ [[maybe_unused]] DebayerParams *params)
+{
+ auto &gains = context.activeState.awb.gains;
+ frameContext.gains.red = gains.r();
+ frameContext.gains.blue = gains.b();
+}
+
void Awb::process(IPAContext &context,
[[maybe_unused]] const uint32_t frame,
- [[maybe_unused]] IPAFrameContext &frameContext,
+ IPAFrameContext &frameContext,
const SwIspStats *stats,
ControlList &metadata)
{
const SwIspStats::Histogram &histogram = stats->yHistogram;
const uint8_t blackLevel = context.activeState.blc.level;
+ const float maxGain = 1024.0;
+ const float mdGains[] = {
+ static_cast<float>(frameContext.gains.red / maxGain),
+ static_cast<float>(frameContext.gains.blue / maxGain)
+ };
+ metadata.set(controls::ColourGains, mdGains);
+
/*
* Black level must be subtracted to get the correct AWB ratios, they
* would be off if they were computed from the whole brightness range
diff --git a/src/ipa/simple/algorithms/awb.h b/src/ipa/simple/algorithms/awb.h
index db1496cd..ad993f39 100644
--- a/src/ipa/simple/algorithms/awb.h
+++ b/src/ipa/simple/algorithms/awb.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
- * Copyright (C) 2024, Red Hat Inc.
+ * Copyright (C) 2024-2025 Red Hat Inc.
*
* Auto white balance
*/
@@ -20,6 +20,10 @@ public:
~Awb() = default;
int configure(IPAContext &context, const IPAConfigInfo &configInfo) override;
+ void prepare(IPAContext &context,
+ const uint32_t frame,
+ IPAFrameContext &frameContext,
+ DebayerParams *params) override;
void process(IPAContext &context,
const uint32_t frame,
IPAFrameContext &frameContext,
diff --git a/src/ipa/simple/ipa_context.h b/src/ipa/simple/ipa_context.h
index 17bcd4ca..bfac835b 100644
--- a/src/ipa/simple/ipa_context.h
+++ b/src/ipa/simple/ipa_context.h
@@ -70,6 +70,10 @@ struct IPAFrameContext : public FrameContext {
int32_t exposure;
double gain;
} sensor;
+ struct {
+ double red;
+ double blue;
+ } gains;
};
struct IPAContext {