|
libcamera v0.7.0+1595-4b6c47bd-nvm
Supporting cameras in Linux since 2019
|
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. | |
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.
| I | Number of integer bits |
| F | Number of fractional bits |
| T | Integral type used to store the quantized value |
|
inlinestatic |
Convert a floating-point value to a fixed-point integer.
| [in] | v | The floating-point value to be converted |
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.
|
inlinestaticconstexpr |
Convert a fixed-point integer to a floating-point value.
| [in] | q | The fixed-point integer value to be converted |
The conversion sign-extends the integer value if required and divides by the scaling factor defined by the number of fractional bits F.
|
staticconstexpr |
Maximum representable quantized integer value.
|
staticconstexpr |
Minimum representable quantized integer value.
This corresponds to the most negative value for signed formats or zero for unsigned formats.