44constexpr double PQ_M1 = 2610.0 / 16384.0;
47constexpr double PQ_M2 = 2523.0 / 4096.0 * 128.0;
50constexpr double PQ_C1 = 3424.0 / 4096.0;
53constexpr double PQ_C2 = 2413.0 / 4096.0 * 32.0;
56constexpr double PQ_C3 = 2392.0 / 4096.0 * 32.0;
59constexpr double HLG_A = 0.17883277;
68constexpr double HLG_C = 0.559910729529562;
90export template <
typename T>
92 { T::PREFIX } -> std::convertible_to<std::string_view>;
93 { T::encode(value) } -> std::same_as<float>;
94 { T::decode(value) } -> std::same_as<float>;
95 { T::clamp(value) } -> std::same_as<float>;
107export template <
typename T>
134 static constexpr std::string_view
PREFIX =
"Lin";
141 static constexpr float encode(
const float value) {
return value; }
148 static constexpr float decode(
const float value) {
return value; }
169 static constexpr std::string_view
PREFIX =
"";
182 return value <= 0.0031308f ? 12.92f * value
183 : 1.055f * std::pow(value, 1.0f /
SRGB_GAMMA) - 0.055f;
197 return value <= 0.04045f ? value / 12.92f : std::pow((value + 0.055f) / 1.055f,
SRGB_GAMMA);
225 static constexpr std::string_view
PREFIX =
"Rec709";
281 static constexpr std::string_view
PREFIX =
"PQ";
306 const double power = std::pow(
static_cast<double>(value), 1 /
PQ_M2);
307 const double ratio = std::max(power -
PQ_C1, 0.0) / (
PQ_C2 -
PQ_C3 * power);
333 static constexpr std::string_view
PREFIX =
"HLG";
347 return static_cast<float>(scene <= 1.0 / 12 ? std::sqrt(3 * scene)
359 const double signal = value;
361 signal <= 0.5 ? signal * signal / 3 : (std::exp((signal -
HLG_C) /
HLG_A) +
HLG_B) / 12;
constexpr float clamp(const float value)
Clamp a floating-point value to the 0-1 range.
constexpr float non_negative(const float value)
Clamp a floating-point value to be non-negative, leaving it unbounded above.
constexpr double PQ_C2
PQ constant c2 = 2413 / 4096 * 32, from SMPTE ST 2084.
constexpr float SRGB_GAMMA
Exponent of the sRGB transfer function.
constexpr double PQ_M1
PQ constant m1 = 2610 / 16384, from SMPTE ST 2084.
constexpr double PQ_C3
PQ constant c3 = 2392 / 4096 * 32, from SMPTE ST 2084.
constexpr double HLG_REFERENCE_WHITE
Scene light that HLG encodes to 75%, its BT.2408 reference white: (exp((0.75 - c) / a) + b) / 12.
constexpr float REC709_BETA
Linear light beta where the Rec. 709 OETF turns from its linear segment to its power curve; BT....
constexpr float REFERENCE_WHITE_NITS
Luminance of linear 1.0 in cd/m²: the HDR reference white of ITU-R BT.2408, and the scale of every li...
constexpr float REC709_ALPHA
Offset alpha of the Rec. 709 OETF, solved so that its two segments meet; ITU-R BT....
constexpr double PQ_PEAK_NITS
Luminance of the PQ signal 1.0 in cd/m², the peak of SMPTE ST 2084.
constexpr double HLG_A
HLG constant a, from ITU-R BT.2100.
constexpr float REC709_EXPONENT
Exponent of the power curve of the Rec. 709 OETF.
constexpr double PQ_C1
PQ constant c1 = 3424 / 4096, from SMPTE ST 2084.
constexpr double PQ_M2
PQ constant m2 = 2523 / 4096 * 128, from SMPTE ST 2084.
constexpr double HLG_B
HLG constant b = 1 - 4a, from ITU-R BT.2100.
constexpr float REC709_SLOPE
Slope of the linear segment of the Rec. 709 OETF.
constexpr double HLG_C
HLG constant c = 0.5 - a ln(4a), from ITU-R BT.2100.
A transfer function for HDR signals, such as PQ or HLG: a tag with a static IS_HDR set to true....
A transfer function tag, the second parameter of BasicRGB.
Transfer function tags, the second parameter of BasicRGB.
The Hybrid Log-Gamma OETF of ITU-R BT.2100 and ARIB STD-B67, the relative HDR transfer function of br...
static constexpr std::string_view PREFIX
Prefix of the color space name.
static float encode(const float value)
Encodes linear light into an HLG signal with the OETF.
static float decode(const float value)
Decodes an HLG signal to linear light with the inverse OETF.
static constexpr float clamp(const float value)
Brings a signal value into the encoded range.
static constexpr bool IS_HDR
HLG is an HDR signal.
No transfer function: channel values are proportional to light.
static constexpr float clamp(const float value)
Brings a channel value into the range of linear light.
static constexpr float decode(const float value)
Decodes a channel value to linear light, leaving it unchanged.
static constexpr float encode(const float value)
Encodes linear light, which this function leaves unchanged.
static constexpr std::string_view PREFIX
Prefix of the color space name.
The Perceptual Quantizer of SMPTE ST 2084 and ITU-R BT.2100, the absolute HDR transfer function of HD...
static constexpr bool IS_HDR
PQ is an HDR signal.
static float encode(const float value)
Encodes linear light into a PQ signal.
static float decode(const float value)
Decodes a PQ signal to linear light.
static constexpr std::string_view PREFIX
Prefix of the color space name.
static constexpr float clamp(const float value)
Brings a signal value into the encoded range.
The OETF of ITU-R BT.709, which BT.2020 shares for SDR: a linear segment near black,...
static constexpr std::string_view PREFIX
Prefix of the color space name.
static constexpr float clamp(const float value)
Brings a signal value into the encoded range.
static float encode(const float value)
Encodes linear scene light into a Rec. 709 signal with the OETF.
static float decode(const float value)
Decodes a Rec. 709 signal to linear scene light with the inverse OETF.
The sRGB transfer function of IEC 61966-2-1: a short linear segment near black, then a power curve wi...
static float decode(const float value)
Decodes an sRGB channel value to linear light.
static constexpr std::string_view PREFIX
Prefix of the color space name: none, encoded spaces go by the gamut name.
static constexpr float clamp(const float value)
Brings a channel value into the encoded range.
static float encode(const float value)
Encodes linear light into an sRGB channel value.