libcamera: libcamera::ipa::FixedPointQTraits< I, F, T > Struct Template Reference

libcamera v0.7.1 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
libcamera::ipa::FixedPointQTraits< I, F, T > Struct Template Reference

Traits type implementing fixed-point quantization conversions. More...

## Public Types
using | QuantizedType = UT
| The integral storage type used for the fixed-point representation.

## Static Public Member Functions
static constexpr float | toFloat (QuantizedType q)
| Convert a fixed-point integer to a floating-point value.
static QuantizedType | fromFloat (float v)
| Convert a floating-point value to a fixed-point integer.

## Static Public Attributes
static constexpr UT | qMin
| Minimum representable quantized integer value.
static constexpr UT | qMax
| Maximum representable quantized integer value.
static constexpr float | min = toFloat(qMin)
| Minimum representable floating-point value corresponding to qMin.
static constexpr float | max = toFloat(qMax)
| Maximum representable floating-point value corresponding to qMax.

## Detailed Description

template<unsigned int I, unsigned int F, typename T>
struct libcamera::ipa::FixedPointQTraits< I, F, T >

Traits type implementing fixed-point quantization conversions.

The FixedPointQTraits structure defines a policy for mapping floating-point values to and from fixed-point 2's complement integer representations. It is parameterised by the number of integer bits I, fractional bits F, and the integral storage type T. The traits are used with Quantized<Traits> to create a quantized type that stores both the fixed-point representation and the corresponding floating-point value.

The signedness of the type is determined by the signedness of T. For signed types, the number of integer bits in I includes the sign bit.

Storage is determined by the total number of bits (I + F) and is automatically selected, but the internal storage type is always an unsigned integer to guarantee against sign extension when storing quantized values in registers.

The trait exposes compile-time constants describing the bit layout, limits, and scaling factors used in the fixed-point representation.

Template Parameters

  I | Number of integer bits
  F | Number of fractional bits
  T | Integral type used to store the quantized value

## Member Function Documentation

## ◆ fromFloat()

template<unsigned int I, unsigned int F, typename T>

QuantizedType libcamera::ipa::FixedPointQTraits< I, F, T >::fromFloat | ( | float | v | ) |
| inlinestatic

Convert a floating-point value to a fixed-point integer.

Parameters

  [in] | v | The floating-point value to be converted

Returns
  The quantized fixed-point integer representation

The conversion first clamps the floating-point input v to the range [min, max] and then rounds it to the nearest fixed-point value according to the scaling factor defined by the number of fractional bits F.

## ◆ toFloat()

template<unsigned int I, unsigned int F, typename T>

constexpr float libcamera::ipa::FixedPointQTraits< I, F, T >::toFloat | ( | QuantizedType | q | ) |
| inlinestaticconstexpr

Convert a fixed-point integer to a floating-point value.

Parameters

  [in] | q | The fixed-point integer value to be converted

Returns
  The corresponding floating-point value

The conversion sign-extends the integer value if required and divides by the scaling factor defined by the number of fractional bits F.

## Member Data Documentation

## ◆ qMax

template<unsigned int I, unsigned int F, typename T>

UT libcamera::ipa::FixedPointQTraits< I, F, T >::qMax
| staticconstexpr

Initial value:
= std::is_signed_v<T>
? (UT{ 1 } << (bits - 1)) - 1
: bitMask

Maximum representable quantized integer value.

## ◆ qMin

template<unsigned int I, unsigned int F, typename T>

UT libcamera::ipa::FixedPointQTraits< I, F, T >::qMin
| staticconstexpr

Initial value:
= std::is_signed_v<T>
? -(UT{ 1 } << (bits - 1))
: 0

Minimum representable quantized integer value.

This corresponds to the most negative value for signed formats or zero for unsigned formats.

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

- src/ipa/libipa/fixedpoint.h
- src/ipa/libipa/fixedpoint.cpp