Automatic black level setting in software ISP updates the determined black level value when exposure or gain change. It stores the last exposure and gain values to detect the change. BlackLevel::configure() resets the stored black level value but not the exposure and gain values. This can prevent updating the black value and cause bad image output, e.g. after suspending and resuming a camera, if exposure and gain remain unchanged. Let's store exposure and gain in IPAActiveState. Although the values are not supposed to be used outside BlackLevel class, storing them in the context has the advantage of their automatic reset together with the other context contents and having them in `blc' struct indicates their relationship to the black value computation. Bug: https://bugs.libcamera.org/show_bug.cgi?id=259 Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Tested-by: Robert Mader <robert.mader@collabora.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
102 lines
1.7 KiB
C++
102 lines
1.7 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 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;
|
|
} knobs;
|
|
};
|
|
|
|
struct IPAFrameContext : public FrameContext {
|
|
struct {
|
|
Matrix<float, 3, 3> ccm;
|
|
} ccm;
|
|
|
|
struct {
|
|
int32_t exposure;
|
|
double gain;
|
|
} sensor;
|
|
struct {
|
|
double red;
|
|
double blue;
|
|
} gains;
|
|
std::optional<double> contrast;
|
|
};
|
|
|
|
struct IPAContext {
|
|
IPAContext(unsigned int frameContextSize)
|
|
: frameContexts(frameContextSize)
|
|
{
|
|
}
|
|
|
|
IPACameraSensorInfo sensorInfo;
|
|
IPASessionConfiguration configuration;
|
|
IPAActiveState activeState;
|
|
FCQueue<IPAFrameContext> frameContexts;
|
|
ControlInfoMap::Map ctrlMap;
|
|
bool ccmEnabled;
|
|
};
|
|
|
|
} /* namespace ipa::soft */
|
|
|
|
} /* namespace libcamera */
|