protocols/cm: Fix image description info events (#12781)

* fix image description info events

* always send some target primaries

* set edid values as target primaries and luminances

* init monitor image description

* set default luminances for tf

* fix BT1886 luminances

* fix mastering values and overrides

* set maxCLL & maxFALL

* typo

* add FALL & CLL to preferred HDR image description

* fix ref luminances
This commit is contained in:
UjinT34 2026-01-13 18:44:36 +03:00 committed by GitHub
parent e43f949f8a
commit e0cf88809d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 151 additions and 74 deletions

View file

@ -505,6 +505,14 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SP<CWpImage
return;
}
if ((m_valuesSet & PC_TF) && !(m_valuesSet & PC_LUMINANCES)) {
m_settings.luminances = {
.min = m_settings.getTFMinLuminance(),
.max = m_settings.getTFMaxLuminance(),
.reference = m_settings.getTFRefLuminance(),
};
}
RESOURCE->m_self = RESOURCE;
RESOURCE->m_settings = CImageDescription::from(m_settings);
RESOURCE->resource()->sendReady(RESOURCE->m_settings->id());
@ -730,19 +738,39 @@ CColorManagementImageDescriptionInfo::CColorManagementImageDescriptionInfo(SP<CW
m_resource->sendPrimaries(toProto(m_settings.primaries.red.x), toProto(m_settings.primaries.red.y), toProto(m_settings.primaries.green.x),
toProto(m_settings.primaries.green.y), toProto(m_settings.primaries.blue.x), toProto(m_settings.primaries.blue.y),
toProto(m_settings.primaries.white.x), toProto(m_settings.primaries.white.y));
if (m_settings.primariesNameSet)
m_resource->sendPrimariesNamed(m_settings.primariesNamed);
m_resource->sendTfPower(std::round(m_settings.transferFunctionPower * 10000));
m_resource->sendTfNamed(m_settings.transferFunction);
if (m_settings.transferFunctionPower != 1.0f)
m_resource->sendTfPower(std::round(m_settings.transferFunctionPower * 10000));
m_resource->sendLuminances(std::round(m_settings.luminances.min * 10000), m_settings.luminances.max, m_settings.luminances.reference);
// send expected display paramateres
m_resource->sendTargetPrimaries(toProto(m_settings.masteringPrimaries.red.x), toProto(m_settings.masteringPrimaries.red.y), toProto(m_settings.masteringPrimaries.green.x),
toProto(m_settings.masteringPrimaries.green.y), toProto(m_settings.masteringPrimaries.blue.x), toProto(m_settings.masteringPrimaries.blue.y),
toProto(m_settings.masteringPrimaries.white.x), toProto(m_settings.masteringPrimaries.white.y));
m_resource->sendTargetLuminance(std::round(m_settings.masteringLuminances.min * 10000), m_settings.masteringLuminances.max);
m_resource->sendTargetMaxCll(m_settings.maxCLL);
m_resource->sendTargetMaxFall(m_settings.maxFALL);
const auto& targetPrimaries = ( //
m_settings.masteringPrimaries.red.x != 0 || m_settings.masteringPrimaries.red.y != 0 || //
m_settings.masteringPrimaries.green.x != 0 || m_settings.masteringPrimaries.green.y != 0 || //
m_settings.masteringPrimaries.blue.x != 0 || m_settings.masteringPrimaries.blue.y != 0) ?
m_settings.masteringPrimaries :
m_settings.primaries;
m_resource->sendTargetPrimaries( //
toProto(targetPrimaries.red.x), toProto(targetPrimaries.red.y), //
toProto(targetPrimaries.green.x), toProto(targetPrimaries.green.y), //
toProto(targetPrimaries.blue.x), toProto(targetPrimaries.blue.y), //
toProto(targetPrimaries.white.x), toProto(targetPrimaries.white.y));
if (m_settings.masteringLuminances.max > 0)
m_resource->sendTargetLuminance(std::round(m_settings.masteringLuminances.min * 10000), m_settings.masteringLuminances.max);
else
m_resource->sendTargetLuminance(std::round(m_settings.luminances.min * 10000), m_settings.luminances.max);
if (m_settings.maxCLL > 0 || m_settings.maxFALL > 0) {
m_resource->sendTargetMaxCll(m_settings.maxCLL);
m_resource->sendTargetMaxFall(m_settings.maxFALL);
}
m_resource->sendDone();
}

View file

@ -223,9 +223,9 @@ namespace NColorManagement {
case CM_TRANSFER_FUNCTION_EXT_LINEAR: return 0;
case CM_TRANSFER_FUNCTION_ST2084_PQ:
case CM_TRANSFER_FUNCTION_HLG: return HDR_MIN_LUMINANCE;
case CM_TRANSFER_FUNCTION_BT1886: return 0.01;
case CM_TRANSFER_FUNCTION_GAMMA22:
case CM_TRANSFER_FUNCTION_GAMMA28:
case CM_TRANSFER_FUNCTION_BT1886:
case CM_TRANSFER_FUNCTION_ST240:
case CM_TRANSFER_FUNCTION_LOG_100:
case CM_TRANSFER_FUNCTION_LOG_316:
@ -243,9 +243,9 @@ namespace NColorManagement {
return SDR_MAX_LUMINANCE; // assume Windows scRGB. white color range 1.0 - 125.0 maps to SDR_MAX_LUMINANCE (80) - HDR_MAX_LUMINANCE (10000)
case CM_TRANSFER_FUNCTION_ST2084_PQ: return HDR_MAX_LUMINANCE;
case CM_TRANSFER_FUNCTION_HLG: return HLG_MAX_LUMINANCE;
case CM_TRANSFER_FUNCTION_BT1886: return 100;
case CM_TRANSFER_FUNCTION_GAMMA22:
case CM_TRANSFER_FUNCTION_GAMMA28:
case CM_TRANSFER_FUNCTION_BT1886:
case CM_TRANSFER_FUNCTION_ST240:
case CM_TRANSFER_FUNCTION_LOG_100:
case CM_TRANSFER_FUNCTION_LOG_316:
@ -262,9 +262,9 @@ namespace NColorManagement {
case CM_TRANSFER_FUNCTION_EXT_LINEAR:
case CM_TRANSFER_FUNCTION_ST2084_PQ:
case CM_TRANSFER_FUNCTION_HLG: return HDR_REF_LUMINANCE;
case CM_TRANSFER_FUNCTION_BT1886: return 100;
case CM_TRANSFER_FUNCTION_GAMMA22:
case CM_TRANSFER_FUNCTION_GAMMA28:
case CM_TRANSFER_FUNCTION_BT1886:
case CM_TRANSFER_FUNCTION_ST240:
case CM_TRANSFER_FUNCTION_LOG_100:
case CM_TRANSFER_FUNCTION_LOG_316: