Skip to content

Commit 9a5a5bf

Browse files
committed
More structures
1 parent 2649382 commit 9a5a5bf

File tree

10 files changed

+69
-13
lines changed

10 files changed

+69
-13
lines changed

include/lut-calibrator/BestResult.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ struct BestResult
8080
double upYLimit = 0;
8181
double downYLimit = 0;
8282
double yShift = 0;
83+
byte3 yuvRange = {};
8384
bool isSourceP010 = false;
8485
} signal;
8586

@@ -124,6 +125,7 @@ struct BestResult
124125
out << "bestResult.signal.yShift = " << std::to_string(signal.yShift) << ";" << std::endl;
125126
out << "bestResult.signal.isSourceP010 = " << std::to_string(signal.isSourceP010) << ";" << std::endl;
126127
out << "bestResult.minError = " << std::to_string(std::round(minError * 100.0) / 30000.0) << ";" << std::endl;
128+
out << "bestResult.signal.yuvRange = byte3{ " << std::to_string(signal.yuvRange[0]) << ", " << std::to_string(signal.yuvRange[1]) << ", " << std::to_string(signal.yuvRange[2]) << "};" << std::endl;
127129
out << "*/" << std::endl;
128130
}
129131
};

include/lut-calibrator/BoardUtils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ namespace BoardUtils
8484
double _yShift = 0;
8585
double _downYLimit = 0;
8686
double _upYLimit = 0;
87+
byte3 _rangeYUV = {};
8788

8889
public:
8990
CapturedColors() = default;
@@ -96,7 +97,7 @@ namespace BoardUtils
9697
bool areAllCaptured();
9798
void finilizeBoard();
9899
static void correctYRange(double3& yuv, double yRange, double upYLimit, double downYLimit, double yShift);
99-
void getSignalParams(double& yRange, double& upYLimit, double& downYLimit, double& yShift);
100+
void getSignalParams(double& yRange, double& upYLimit, double& downYLimit, double& yShift, byte3& rangeYUV);
100101
void setCaptured(int index);
101102
void setRange(YuvConverter::COLOR_RANGE range);
102103
YuvConverter::COLOR_RANGE getRange() const;

include/utils/settings.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ namespace settings {
3333
RAWUDPSERVER,
3434
PROTOSERVER,
3535
MQTT,
36+
AUTOTONEMAPPING,
3637
INVALID
3738
};
3839

@@ -65,6 +66,7 @@ namespace settings {
6566
case type::RAWUDPSERVER: return "rawUdpServer";
6667
case type::PROTOSERVER: return "protoServer";
6768
case type::MQTT: return "mqtt";
69+
case type::AUTOTONEMAPPING: return "automaticToneMapping";
6870
default: return "invalid";
6971
}
7072
}
@@ -96,6 +98,7 @@ namespace settings {
9698
else if (type == "rawUdpServer") return type::RAWUDPSERVER;
9799
else if (type == "protoServer") return type::PROTOSERVER;
98100
else if (type == "mqtt") return type::MQTT;
101+
else if (type == "automaticToneMapping") return type::AUTOTONEMAPPING;
99102
else return type::INVALID;
100103
}
101104
}

sources/base/hyperhdr.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@
102102
"mqtt":
103103
{
104104
"$ref": "schema-mqtt.json"
105+
},
106+
"automaticToneMapping" :
107+
{
108+
"$ref": "schema-automaticToneMapping.json"
105109
}
106110
},
107111
"additionalProperties" : false

sources/base/resource.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@
2626
<file alias="schema-videoDetection.json">schema/schema-videoDetection.json</file>
2727
<file alias="schema-network.json">schema/schema-network.json</file>
2828
<file alias="schema-mqtt.json">schema/schema-mqtt.json</file>
29+
<file alias="schema-automaticToneMapping.json">schema/schema-automaticToneMapping.json</file>
2930
</qresource>
3031
</RCC>

sources/base/schema/schema-automaticToneMapping.json

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,42 @@
1212
"required" : true,
1313
"propertyOrder" : 1
1414
},
15-
"tone_mapping_threshold" :
15+
"tone_mapping_y_threshold" :
1616
{
1717
"type" : "integer",
1818
"format": "stepper",
1919
"step" : 1,
20-
"title" : "edt_automatic_tone_mapping_threshold_title",
21-
"minimum" : 155,
20+
"title" : "edt_automatic_tone_mapping_y_threshold_title",
21+
"minimum" : 150,
2222
"maximum" : 255,
23-
"default" : 165,
24-
"append" : "edt_append_percent",
23+
"default" : 155,
2524
"required" : true,
2625
"propertyOrder" : 2
2726
},
27+
"tone_mapping_u_threshold" :
28+
{
29+
"type" : "integer",
30+
"format": "stepper",
31+
"step" : 1,
32+
"title" : "edt_automatic_tone_mapping_u_threshold_title",
33+
"minimum" : 165,
34+
"maximum" : 255,
35+
"default" : 175,
36+
"required" : true,
37+
"propertyOrder" : 3
38+
},
39+
"tone_mapping_v_threshold" :
40+
{
41+
"type" : "integer",
42+
"format": "stepper",
43+
"step" : 1,
44+
"title" : "edt_automatic_tone_mapping_v_threshold_title",
45+
"minimum" : 155,
46+
"maximum" : 255,
47+
"default" : 160,
48+
"required" : true,
49+
"propertyOrder" : 4
50+
},
2851
"time_to_tone_mapping" :
2952
{
3053
"type" : "integer",
@@ -36,7 +59,7 @@
3659
"default" : 30,
3760
"append" : "edt_append_s",
3861
"required" : true,
39-
"propertyOrder" : 3
62+
"propertyOrder" : 5
4063
}
4164
},
4265
"additionalProperties" : false

sources/db/SettingsTable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ bool SettingsTable::isSettingGlobal(const QString& type) const
122122
<< settings::typeToString(settings::type::VIDEOGRABBER) << settings::typeToString(settings::type::SYSTEMGRABBER)
123123
<< settings::typeToString(settings::type::LOGGER) << settings::typeToString(settings::type::GENERAL)
124124
<< settings::typeToString(settings::type::SNDEFFECT) << settings::typeToString(settings::type::VIDEODETECTION)
125-
<< settings::typeToString(settings::type::MQTT)
125+
<< settings::typeToString(settings::type::MQTT) << settings::typeToString(settings::type::AUTOTONEMAPPING)
126126
// legacy
127127
<< "grabberV4L2";
128128

sources/lut-calibrator/BoardUtils.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,13 @@ namespace BoardUtils
443443
for (int b = 0; b < SCREEN_COLOR_DIMENSION; b++)
444444
{
445445
all[r][g][b].setCoords(byte3(r, g, b));
446+
447+
if (all[r][g][b].Y() > _rangeYUV.x)
448+
_rangeYUV.x = all[r][g][b].Y();
449+
if (all[r][g][b].U() > _rangeYUV.y)
450+
_rangeYUV.y = all[r][g][b].U();
451+
if (all[r][g][b].V() > _rangeYUV.z)
452+
_rangeYUV.z = all[r][g][b].V();
446453
}
447454
}
448455

@@ -451,12 +458,13 @@ namespace BoardUtils
451458
yuv.x = ((yuv.x - downYLimit) / (upYLimit - downYLimit)) * yRange + yShift;
452459
}
453460

454-
void CapturedColors::getSignalParams(double& yRange, double& upYLimit, double& downYLimit, double& yShift)
461+
void CapturedColors::getSignalParams(double& yRange, double& upYLimit, double& downYLimit, double& yShift, byte3& rangeYUV)
455462
{
456463
yRange = _yRange;
457464
upYLimit = _upYLimit;
458465
downYLimit = _downYLimit;
459466
yShift = _yShift;
467+
rangeYUV = _rangeYUV;
460468
}
461469

462470
void CapturedColors::setCaptured(int index)

sources/lut-calibrator/LutCalibrator.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ void LutCalibrator::fineTune(bool precise)
11251125

11261126
// set startup parameters (signal)
11271127
bestResult->signal.range = _capturedColors->getRange();
1128-
_capturedColors->getSignalParams(bestResult->signal.yRange, bestResult->signal.upYLimit, bestResult->signal.downYLimit, bestResult->signal.yShift);
1128+
_capturedColors->getSignalParams(bestResult->signal.yRange, bestResult->signal.upYLimit, bestResult->signal.downYLimit, bestResult->signal.yShift, bestResult->signal.yuvRange);
11291129

11301130
if (bestResult->signal.isSourceP010)
11311131
{
@@ -1136,6 +1136,16 @@ void LutCalibrator::fineTune(bool precise)
11361136
double down = bestResult->signal.downYLimit;
11371137
unpackP010(&down, nullptr, nullptr);
11381138
bestResult->signal.downYLimit = down;
1139+
1140+
double3 yuvrange = static_cast<double3>(bestResult->signal.yuvRange);
1141+
yuvrange.x /= 255.0;
1142+
yuvrange.y = (yuvrange.y - 128.0) / 128.0;
1143+
yuvrange.z = (yuvrange.z - 128.0) / 128.0;
1144+
unpackP010(yuvrange);
1145+
yuvrange.x *= 255.0;
1146+
yuvrange.y = yuvrange.y * 128.0 + 128.0;
1147+
yuvrange.z = yuvrange.z * 128.0 + 128.0;
1148+
bestResult->signal.yuvRange = static_cast<byte3>(yuvrange);
11391149
}
11401150

11411151
if (bestResult->signal.range == YuvConverter::COLOR_RANGE::LIMITED)

www/i18n/en.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,8 +1255,12 @@
12551255
"edt_automatic_tone_mapping_title" : "Automatic tone mapping",
12561256
"edt_automatic_tone_mapping_enable_title" : "Enable automatic tone mapping",
12571257
"edt_automatic_tone_mapping_enable_expl" : "Automatic tone mapping is only available for YUV/NV12/P010 formats with 'Quarter of frame' mode enabled",
1258-
"edt_automatic_tone_mapping_threshold_title" : "Brightness threshold",
1259-
"edt_automatic_tone_mapping_threshold_expl" : "The brightness level that separates raw dark HDR material from the SDR signal",
1258+
"edt_automatic_tone_mapping_y_threshold_title" : "Brightness threshold (Y)",
1259+
"edt_automatic_tone_mapping_y_threshold_expl" : "The brightness level that separates raw dark HDR material from the SDR signal",
1260+
"edt_automatic_tone_mapping_u_threshold_title" : "Blue chroma threshold (U)",
1261+
"edt_automatic_tone_mapping_u_threshold_expl" : "Blue chroma level that separates raw pale HDR material from the SDR signal",
1262+
"edt_automatic_tone_mapping_v_threshold_title" : "Red chroma threshold (V)",
1263+
"edt_automatic_tone_mapping_v_threshold_expl" : "Red chroma level that separates raw pale HDR material from the SDR signal",
12601264
"edt_automatic_tone_mapping_time_title" : "Time to turn on tone mapping",
1261-
"edt_automatic_tone_mapping_time_title_expl" : "Time to turn on tone mapping if the signal does not exceed the set brightness level"
1265+
"edt_automatic_tone_mapping_time_title_expl" : "Time to turn on tone mapping if the signal does not exceed the configured threshold levels"
12621266
}

0 commit comments

Comments
 (0)