@@ -96,11 +96,11 @@ void Awb::process(IPAContext &context,
RGB<double> rgbGains{ { 1 / gains.r(), 1 / gains.g(), 1 / gains.b() } };
context.activeState.awb.temperatureK = estimateCCT(rgbGains);
- metadata.set(controls::ColourTemperature, context.activeState.awb.temperatureK);
+ metadata.set(controls::ColourTemperature, context.activeState.awb.temperatureK.value_or(0));
LOG(IPASoftAwb, Debug)
<< "gain R/B: " << gains << "; temperature: "
- << context.activeState.awb.temperatureK;
+ << context.activeState.awb.temperatureK.value_or(0);
}
REGISTER_IPA_ALGORITHM(Awb, "Awb")
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
- * Copyright (C) 2024-2025 Red Hat Inc.
+ * Copyright (C) 2024-2026 Red Hat Inc.
*
* Auto white balance
*/
@@ -13,6 +13,8 @@ namespace libcamera {
namespace ipa::soft::algorithms {
+constexpr unsigned int kDefaultTemperature = 6500;
+
class Awb : public Algorithm
{
public:
@@ -15,6 +15,8 @@
#include "libcamera/internal/matrix.h"
+#include "awb.h"
+
namespace {
constexpr unsigned int kTemperatureThreshold = 100;
@@ -44,7 +46,8 @@ int Ccm::init([[maybe_unused]] IPAContext &context, const YamlObject &tuningData
void Ccm::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame,
IPAFrameContext &frameContext, [[maybe_unused]] DebayerParams *params)
{
- const unsigned int ct = context.activeState.awb.temperatureK;
+ const unsigned int ct =
+ context.activeState.awb.temperatureK.value_or(kDefaultTemperature);
/* Change CCM only on bigger temperature changes. */
if (!currentCcm_ ||
@@ -50,7 +50,7 @@ struct IPAActiveState {
struct {
RGB<float> gains;
- unsigned int temperatureK;
+ std::optional<unsigned int> temperatureK;
} awb;
Matrix<float, 3, 3> combinedMatrix;
Some algorithms use interpolated values based on temperature. Temperature is computed in the AWB algorithm. Technically, the AWB algorithm can be disabled and then no temperature is computed. Let's avoid implicit assumptions and introduce a constant for a default temperature value and make the temperature value optional. This is currently used by the CCM algorithm. It will be used also by the LSC algorithm in the followup patch. The default temperature value of 6500 is just a common value, there is no special reason to use this or another value. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> --- src/ipa/simple/algorithms/awb.cpp | 4 ++-- src/ipa/simple/algorithms/awb.h | 4 +++- src/ipa/simple/algorithms/ccm.cpp | 5 ++++- src/ipa/simple/ipa_context.h | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-)