7#include <KLocalizedString>
8#include <lager/constant.hpp>
9#include <lager/setter.hpp>
14static constexpr std::array<double, 2> refWhiteList {
19double calcEffectiveReferenceWhite(
bool imageProfileIsRelative,
double imageProfileReferenceWhite,
double imageMetadataReferenceWhite)
21 return imageProfileIsRelative ? imageMetadataReferenceWhite : imageProfileReferenceWhite;
24auto referenceWhiteToInt =
25 lager::lenses::getset(
26 [] (
const double &
value) ->
int {
29 for (
size_t i = 0; i < refWhiteList.size(); i++) {
37 [] (
double value,
const int &newValue) {
38 if (newValue >= 0 && newValue <
int(refWhiteList.size())) {
39 value = refWhiteList[newValue];
45ComboBoxState calcWhiteTypeToComboBoxState(
int index,
bool enabled)
50 for (
size_t i = 0; i < refWhiteList.size(); i++) {
51 values << i18nc(
"Image reference white value",
"%1 cd/m²", QString::number(refWhiteList.at(i)));
55 return {values, index, enabled, toolTips};
63 values << i18nc(
"CLLI calculation type",
"XYZ Luminance");
64 values << i18nc(
"CLLI calculation type",
"Rec 2020 Per Component");
65 values << i18nc(
"CLLI calculation type",
"RGB Per Component");
67 toolTips << i18nc(
"@info:tooltip",
"Calculate the brightness in nits against XYZ luminance.");
68 toolTips << i18nc(
"@info:tooltip",
"Calculate the brightness in nits by testing the components in linear rec 2020.");
69 toolTips << i18nc(
"@info:tooltip",
"Calculate the brightness in nits by testing the components in linear RGB, if possible, falls back to using XYZ luminance.");
71 return {values,
static_cast<int>(type), enabled, toolTips};
74auto noopSetter = [] (
auto) {};
76auto calcRelativeToAbsoluteWhiteLevel = lager::lenses::getset(
79 [] (
const std::tuple<double,double> &packed) ->
double {
80 return std::get<0>(packed) * std::get<1>(packed);
82 [] (std::tuple<double,double> packed,
double absoluteValue) {
84 std::get<0>(packed) = absoluteValue / std::get<1>(packed);
90auto effectivePresetIndexForCvi =
91 lager::lenses::getset(
104 }
else if (index == 1) {
113 ComboBoxState calcCviEffectivePresetIndexState(
int index,
bool enabled) {
117 values << i18n(
"Rec. 2100 PQ");
118 values << i18n(
"DCI-P3 D65");
119 values << i18n(
"Custom");
121 toolTips << i18nc(
"@info:tooltip",
"Reset color volume to the values defined by Rec. 2100 PQ");
122 toolTips << i18nc(
"@info:tooltip",
"Reset color volume to the values defined by DCI-P3 D65");
123 toolTips << i18nc(
"@info:tooltip",
"Use custom values for color volume");
125 return {values, index, enabled, toolTips};
136 , imageProfileReferenceWhiteData(203.0)
137 , referenceWhiteData(203.0)
138 , imageProfileIsRelativeData(false)
139 , referenceWhitePresentData(false)
140 , clliPresentData(false)
141 , cviPresentData(false)
145 lager::with(referenceWhitePresentData,
146 imageProfileIsRelativeData.map(std::logical_not<>{})
147 ).map(std::logical_or<>{})}
148 ,
LAGER_QT(effectiveReferenceWhiteEnabled){imageProfileIsRelativeData}
155 imageProfileIsRelativeData,
156 imageProfileReferenceWhiteData,
158 ).map(&calcEffectiveReferenceWhite)}
159 ,
LAGER_QT(effectiveReferenceWhiteIndex){
LAGER_QT(effectiveReferenceWhite).zoom(referenceWhiteToInt)}
161 .map(&calcWhiteTypeToComboBoxState)}
167 LAGER_QT(effectiveReferenceWhitePresent)
168 ).map(std::logical_and<>{})}
174 lager::with_setter(
LAGER_QT(effectiveReferenceWhite), noopSetter)
175 ).zoom(calcRelativeToAbsoluteWhiteLevel)}
179 lager::with_setter(
LAGER_QT(effectiveReferenceWhite), noopSetter)
180 ).zoom(calcRelativeToAbsoluteWhiteLevel)}
184 .map(&calcTypeComboBoxState)}
188 ,
LAGER_QT(cviEffectivePresetIndex){cviData.zoom(effectivePresetIndexForCvi)}
196 ).map(&calcCviEffectivePresetIndexState)}
float value(const T *src, size_t ch)
static bool qFuzzyCompare(half p1, half p2)
static bool qFuzzyIsNull(half h)
double maxFrameAverageLightLevel
maxFrameAverage MaxFrameAverageLightLevel or MaxFALL is the average of average pixel brightnesses in ...
double maxContentLightLevel