libcamera v0.8.0+1-3c8337a0-nvm
Supporting cameras in Linux since 2019
Loading...
Searching...
No Matches
libcamera::ipa::GammaAlgorithm< NLutNodes, UQ > Class Template Reference

The libipa gamma correction algorithm. More...

Inheritance diagram for libcamera::ipa::GammaAlgorithm< NLutNodes, UQ >:
Collaboration diagram for libcamera::ipa::GammaAlgorithm< NLutNodes, UQ >:

Public Member Functions

int init (ControlInfoMap::Map &controls, const ValueNode &tuningData, std::optional< std::span< const unsigned int, NLutNodes - 1 > > segments={})
 Initialise the algorithm with the given tuning data.
 
template<typename T >
void prepare (gamma::FrameContext &context, std::span< T, NLutNodes > lut)
 
- Public Member Functions inherited from libcamera::ipa::GammaAlgorithmBase
 GammaAlgorithmBase (unsigned int nLutNodes)
 Construct an instance of the class.
 
void configure (gamma::ActiveState &state)
 Configure the gamma correction algorithm.
 
void queueRequest (gamma::ActiveState &state, const uint32_t frame, gamma::FrameContext &context, const ControlList &controls)
 Queue a request to the gamma correction algorithm.
 
void process (gamma::FrameContext &context, ControlList &metadata)
 Populate metadata with the gamma correction values for a frame.
 

Additional Inherited Members

- Protected Member Functions inherited from libcamera::ipa::GammaAlgorithmBase
int init (ControlInfoMap::Map &controls, const ValueNode &tuningData, std::span< const unsigned int > segments)
 Initialise the algorithm with the given tuning data.
 
- Protected Attributes inherited from libcamera::ipa::GammaAlgorithmBase
unsigned int nLutNodes_
 The number of gamma LUT sampling points.
 
float defaultGamma_
 The default gamma parameter.
 
std::vector< float > kneePoints_
 a vector holding the X-position of the knee points of the curve
 

Detailed Description

template<unsigned int NLutNodes, typename UQ>
class libcamera::ipa::GammaAlgorithm< NLutNodes, UQ >

The libipa gamma correction algorithm.

Template Parameters
NLutNodesThe number of gamma LUT sampling points
UQThe fixedpoint representation of the gamma correction values

Gamma correction adjusts for the differences in the way light is perceived by a camera and the human eye by applying a function to the input values. The GammaAlgorithm class facilitates this by building a piecewise linear function from a gamma parameter and supplying it in the hardware-specific formats defined by the IPA algorithms.

IPA modules are expected to store an instance of GammaAlgorithm as a class member, templated with the format and number of knee-points in the PWL expected by their hardware and then call its functions in their overload of the Algorithm class's function.

When an application queues a new value for the gamma parameter with a Request, the GammaAlgorithm will recalculate and populate the new LUT to be sent to the ISP.

Useful links:

Member Function Documentation

◆ init()

template<unsigned int NLutNodes, typename UQ >
libcamera::ipa::GammaAlgorithm< NLutNodes, UQ >::init ( ControlInfoMap::Map &  controls,
const ValueNode &  tuningData,
std::optional< std::span< const unsigned int, NLutNodes - 1 > >  segments = {} 
)
inline

Initialise the algorithm with the given tuning data.

Parameters
[out]controlsThe ControlList into which this algorithm's supported controls will be emplaced.
[in]tuningDataThe tuning data to use with the algorithm
[in]segmentsA vector of segment spacings to define a custom X coordinate system for the curve

Parse tuningData and segments to initialize the gamma correction curve. The tuning data may contain a default gamma value to use; otherwise the value of kDefaultGamma will be taken as the default. The piecewise linear function will be applied on a number of knots whose position is described by the optional segments argument, which describes each segment's relative length.

For example, if the gamma correction has to be applied on 16 equally spaced sampling points, a segments array like:

[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

would result in evenly spaced knee-points along the X-axis.

Hardware may expect the knee-points to be spaced more densely towards the start of the curve and more sparsely towards the end, in which case an alternative array might be:

[1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 8, 8, 8, 8, 8]

As the values in segments represent the distance between two knee-points relative to the total distance between the first and last point, the length of segments should be equal to the number of knee-points minus one. ; If an IPA implementation doesn't provide segments, the GammaAlgorithm class constructs an evenly-spaced default.

IPA modules are expected to call this function as part of their implementation of Algorithm::init()

Returns
0 on success, a negative error code otherwise

◆ prepare()

template<unsigned int NLutNodes, typename UQ >
template<typename T >
libcamera::ipa::GammaAlgorithm< NLutNodes, UQ >::prepare ( gamma::FrameContext &  context,
std::span< T, NLutNodes >  lut 
)
inline
Template Parameters
TThe type of data expected by the hardware's look-up table
Parameters
[in]contextThe frame context
[out]lutThe std::span into which to place the calculated look-up table

The documentation for this class was generated from the following files: