libcamera/src/ipa/simple/ipa_context.h
2025-07-12 00:00:59 +00:00

122 lines
2.2 KiB
C++

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2024-2025 Red Hat, Inc.
*
* Simple pipeline IPA Context
*/
#pragma once
#include <array>
#include <optional>
#include <stdint.h>
#include <libcamera/controls.h>
#include "libcamera/internal/matrix.h"
#include "libcamera/internal/vector.h"
#include <libipa/fc_queue.h>
#include "core_ipa_interface.h"
namespace libcamera {
namespace ipa::soft {
struct IPASessionConfiguration {
float gamma;
struct {
int32_t exposureMin, exposureMax;
double againMin, againMax, againMinStep;
utils::Duration lineDuration;
} agc;
struct {
std::optional<uint8_t> level;
} black;
struct {
int32_t focus_min, focus_max;
} focus;
};
struct IPAActiveState {
struct {
uint8_t level;
int32_t lastExposure;
double lastGain;
} blc;
struct {
RGB<float> gains;
unsigned int temperatureK;
} awb;
static constexpr unsigned int kGammaLookupSize = 1024;
struct {
std::array<double, kGammaLookupSize> gammaTable;
uint8_t blackLevel;
double contrast;
} gamma;
struct {
Matrix<float, 3, 3> ccm;
bool changed;
} ccm;
struct {
/* 0..2 range, 1.0 = normal */
std::optional<double> contrast;
std::optional<float> saturation;
/* 0..2 range, 1.0 = normal */
std::optional<double> brightness;
/* 0..1 range, 1 = normal */
std::optional<bool> ae_enabled;
/* 0..1 range, 0.5 = normal */
std::optional<double> exposure_value;
/* 0..100 range, 50.0 = normal */
std::optional<double> focus_pos;
/* 0..1 range, 1 = normal */
std::optional<bool> stats_enabled;
} knobs;
};
struct IPAFrameContext : public FrameContext {
struct {
Matrix<float, 3, 3> ccm;
} ccm;
struct {
int32_t exposure;
double gain;
} sensor;
struct {
int32_t focus_pos;
} lens;
struct {
double red;
double blue;
} gains;
std::optional<double> contrast;
std::optional<float> saturation;
};
struct IPAContext {
IPAContext(unsigned int frameContextSize)
: frameContexts(frameContextSize)
{
}
IPACameraSensorInfo sensorInfo;
IPASessionConfiguration configuration;
IPAActiveState activeState;
FCQueue<IPAFrameContext> frameContexts;
ControlInfoMap::Map ctrlMap;
bool ccmEnabled = false;
};
} /* namespace ipa::soft */
} /* namespace libcamera */