Skip to content

Commit

Permalink
More structures
Browse files Browse the repository at this point in the history
  • Loading branch information
awawa-dev committed Nov 27, 2024
1 parent 2649382 commit 9a5a5bf
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 13 deletions.
2 changes: 2 additions & 0 deletions include/lut-calibrator/BestResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ struct BestResult
double upYLimit = 0;
double downYLimit = 0;
double yShift = 0;
byte3 yuvRange = {};
bool isSourceP010 = false;
} signal;

Expand Down Expand Up @@ -124,6 +125,7 @@ struct BestResult
out << "bestResult.signal.yShift = " << std::to_string(signal.yShift) << ";" << std::endl;
out << "bestResult.signal.isSourceP010 = " << std::to_string(signal.isSourceP010) << ";" << std::endl;
out << "bestResult.minError = " << std::to_string(std::round(minError * 100.0) / 30000.0) << ";" << std::endl;
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;
out << "*/" << std::endl;
}
};
3 changes: 2 additions & 1 deletion include/lut-calibrator/BoardUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ namespace BoardUtils
double _yShift = 0;
double _downYLimit = 0;
double _upYLimit = 0;
byte3 _rangeYUV = {};

public:
CapturedColors() = default;
Expand All @@ -96,7 +97,7 @@ namespace BoardUtils
bool areAllCaptured();
void finilizeBoard();
static void correctYRange(double3& yuv, double yRange, double upYLimit, double downYLimit, double yShift);
void getSignalParams(double& yRange, double& upYLimit, double& downYLimit, double& yShift);
void getSignalParams(double& yRange, double& upYLimit, double& downYLimit, double& yShift, byte3& rangeYUV);
void setCaptured(int index);
void setRange(YuvConverter::COLOR_RANGE range);
YuvConverter::COLOR_RANGE getRange() const;
Expand Down
3 changes: 3 additions & 0 deletions include/utils/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace settings {
RAWUDPSERVER,
PROTOSERVER,
MQTT,
AUTOTONEMAPPING,
INVALID
};

Expand Down Expand Up @@ -65,6 +66,7 @@ namespace settings {
case type::RAWUDPSERVER: return "rawUdpServer";
case type::PROTOSERVER: return "protoServer";
case type::MQTT: return "mqtt";
case type::AUTOTONEMAPPING: return "automaticToneMapping";
default: return "invalid";
}
}
Expand Down Expand Up @@ -96,6 +98,7 @@ namespace settings {
else if (type == "rawUdpServer") return type::RAWUDPSERVER;
else if (type == "protoServer") return type::PROTOSERVER;
else if (type == "mqtt") return type::MQTT;
else if (type == "automaticToneMapping") return type::AUTOTONEMAPPING;
else return type::INVALID;
}
}
4 changes: 4 additions & 0 deletions sources/base/hyperhdr.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
"mqtt":
{
"$ref": "schema-mqtt.json"
},
"automaticToneMapping" :
{
"$ref": "schema-automaticToneMapping.json"
}
},
"additionalProperties" : false
Expand Down
1 change: 1 addition & 0 deletions sources/base/resource.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
<file alias="schema-videoDetection.json">schema/schema-videoDetection.json</file>
<file alias="schema-network.json">schema/schema-network.json</file>
<file alias="schema-mqtt.json">schema/schema-mqtt.json</file>
<file alias="schema-automaticToneMapping.json">schema/schema-automaticToneMapping.json</file>
</qresource>
</RCC>
35 changes: 29 additions & 6 deletions sources/base/schema/schema-automaticToneMapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,42 @@
"required" : true,
"propertyOrder" : 1
},
"tone_mapping_threshold" :
"tone_mapping_y_threshold" :
{
"type" : "integer",
"format": "stepper",
"step" : 1,
"title" : "edt_automatic_tone_mapping_threshold_title",
"minimum" : 155,
"title" : "edt_automatic_tone_mapping_y_threshold_title",
"minimum" : 150,
"maximum" : 255,
"default" : 165,
"append" : "edt_append_percent",
"default" : 155,
"required" : true,
"propertyOrder" : 2
},
"tone_mapping_u_threshold" :
{
"type" : "integer",
"format": "stepper",
"step" : 1,
"title" : "edt_automatic_tone_mapping_u_threshold_title",
"minimum" : 165,
"maximum" : 255,
"default" : 175,
"required" : true,
"propertyOrder" : 3
},
"tone_mapping_v_threshold" :
{
"type" : "integer",
"format": "stepper",
"step" : 1,
"title" : "edt_automatic_tone_mapping_v_threshold_title",
"minimum" : 155,
"maximum" : 255,
"default" : 160,
"required" : true,
"propertyOrder" : 4
},
"time_to_tone_mapping" :
{
"type" : "integer",
Expand All @@ -36,7 +59,7 @@
"default" : 30,
"append" : "edt_append_s",
"required" : true,
"propertyOrder" : 3
"propertyOrder" : 5
}
},
"additionalProperties" : false
Expand Down
2 changes: 1 addition & 1 deletion sources/db/SettingsTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ bool SettingsTable::isSettingGlobal(const QString& type) const
<< settings::typeToString(settings::type::VIDEOGRABBER) << settings::typeToString(settings::type::SYSTEMGRABBER)
<< settings::typeToString(settings::type::LOGGER) << settings::typeToString(settings::type::GENERAL)
<< settings::typeToString(settings::type::SNDEFFECT) << settings::typeToString(settings::type::VIDEODETECTION)
<< settings::typeToString(settings::type::MQTT)
<< settings::typeToString(settings::type::MQTT) << settings::typeToString(settings::type::AUTOTONEMAPPING)
// legacy
<< "grabberV4L2";

Expand Down
10 changes: 9 additions & 1 deletion sources/lut-calibrator/BoardUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,13 @@ namespace BoardUtils
for (int b = 0; b < SCREEN_COLOR_DIMENSION; b++)
{
all[r][g][b].setCoords(byte3(r, g, b));

if (all[r][g][b].Y() > _rangeYUV.x)
_rangeYUV.x = all[r][g][b].Y();
if (all[r][g][b].U() > _rangeYUV.y)
_rangeYUV.y = all[r][g][b].U();
if (all[r][g][b].V() > _rangeYUV.z)
_rangeYUV.z = all[r][g][b].V();
}
}

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

void CapturedColors::getSignalParams(double& yRange, double& upYLimit, double& downYLimit, double& yShift)
void CapturedColors::getSignalParams(double& yRange, double& upYLimit, double& downYLimit, double& yShift, byte3& rangeYUV)
{
yRange = _yRange;
upYLimit = _upYLimit;
downYLimit = _downYLimit;
yShift = _yShift;
rangeYUV = _rangeYUV;
}

void CapturedColors::setCaptured(int index)
Expand Down
12 changes: 11 additions & 1 deletion sources/lut-calibrator/LutCalibrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ void LutCalibrator::fineTune(bool precise)

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

if (bestResult->signal.isSourceP010)
{
Expand All @@ -1136,6 +1136,16 @@ void LutCalibrator::fineTune(bool precise)
double down = bestResult->signal.downYLimit;
unpackP010(&down, nullptr, nullptr);
bestResult->signal.downYLimit = down;

double3 yuvrange = static_cast<double3>(bestResult->signal.yuvRange);
yuvrange.x /= 255.0;
yuvrange.y = (yuvrange.y - 128.0) / 128.0;
yuvrange.z = (yuvrange.z - 128.0) / 128.0;
unpackP010(yuvrange);
yuvrange.x *= 255.0;
yuvrange.y = yuvrange.y * 128.0 + 128.0;
yuvrange.z = yuvrange.z * 128.0 + 128.0;
bestResult->signal.yuvRange = static_cast<byte3>(yuvrange);
}

if (bestResult->signal.range == YuvConverter::COLOR_RANGE::LIMITED)
Expand Down
10 changes: 7 additions & 3 deletions www/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1255,8 +1255,12 @@
"edt_automatic_tone_mapping_title" : "Automatic tone mapping",
"edt_automatic_tone_mapping_enable_title" : "Enable automatic tone mapping",
"edt_automatic_tone_mapping_enable_expl" : "Automatic tone mapping is only available for YUV/NV12/P010 formats with 'Quarter of frame' mode enabled",
"edt_automatic_tone_mapping_threshold_title" : "Brightness threshold",
"edt_automatic_tone_mapping_threshold_expl" : "The brightness level that separates raw dark HDR material from the SDR signal",
"edt_automatic_tone_mapping_y_threshold_title" : "Brightness threshold (Y)",
"edt_automatic_tone_mapping_y_threshold_expl" : "The brightness level that separates raw dark HDR material from the SDR signal",
"edt_automatic_tone_mapping_u_threshold_title" : "Blue chroma threshold (U)",
"edt_automatic_tone_mapping_u_threshold_expl" : "Blue chroma level that separates raw pale HDR material from the SDR signal",
"edt_automatic_tone_mapping_v_threshold_title" : "Red chroma threshold (V)",
"edt_automatic_tone_mapping_v_threshold_expl" : "Red chroma level that separates raw pale HDR material from the SDR signal",
"edt_automatic_tone_mapping_time_title" : "Time to turn on tone mapping",
"edt_automatic_tone_mapping_time_title_expl" : "Time to turn on tone mapping if the signal does not exceed the set brightness level"
"edt_automatic_tone_mapping_time_title_expl" : "Time to turn on tone mapping if the signal does not exceed the configured threshold levels"
}

0 comments on commit 9a5a5bf

Please sign in to comment.