From 3f77bf25d10548bd6dd282e3c5b5733db7e374e1 Mon Sep 17 00:00:00 2001 From: UjinT34 Date: Sun, 26 Apr 2026 09:54:15 +0300 Subject: [PATCH] fix hl tf -> wp tf --- src/helpers/cm/ColorManagement.hpp | 11 +++++++++-- src/protocols/ColorManagement.cpp | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/helpers/cm/ColorManagement.hpp b/src/helpers/cm/ColorManagement.hpp index 183a8544d..e970ff592 100644 --- a/src/helpers/cm/ColorManagement.hpp +++ b/src/helpers/cm/ColorManagement.hpp @@ -5,6 +5,7 @@ #include #include "../../helpers/memory/Memory.hpp" #include "../../helpers/math/Math.hpp" +#include "../../debug/log/Logger.hpp" #include #include @@ -45,6 +46,7 @@ namespace NColorManagement { }; enum eTransferFunction : uint8_t { + CM_TRANSFER_FUNCTION_LINEAR = 0, CM_TRANSFER_FUNCTION_BT1886 = 1, CM_TRANSFER_FUNCTION_GAMMA22 = 2, CM_TRANSFER_FUNCTION_GAMMA28 = 3, @@ -68,9 +70,14 @@ namespace NColorManagement { inline ePrimaries convertPrimaries(wpColorManagerV1Primaries primaries) { return sc(primaries); } - inline wpColorManagerV1TransferFunction convertTransferFunction(eTransferFunction tf) { + inline wpColorManagerV1TransferFunction convertTransferFunction(eTransferFunction tf, bool useV1SRGB = true) { switch (tf) { - case CM_TRANSFER_FUNCTION_SRGB: return WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_COMPOUND_POWER_2_4; + case CM_TRANSFER_FUNCTION_LINEAR: + Log::logger->log(Log::TRACE, + "CM_TRANSFER_FUNCTION_LINEAR is internal and buffers with this TF shouldn't go outside. Returning " + "WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR for preferred description instead"); + return WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_EXT_LINEAR; + case CM_TRANSFER_FUNCTION_SRGB: return useV1SRGB ? WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_SRGB : WP_COLOR_MANAGER_V1_TRANSFER_FUNCTION_COMPOUND_POWER_2_4; default: return sc(tf); } } diff --git a/src/protocols/ColorManagement.cpp b/src/protocols/ColorManagement.cpp index fce91691b..a704d4d7a 100644 --- a/src/protocols/ColorManagement.cpp +++ b/src/protocols/ColorManagement.cpp @@ -807,7 +807,7 @@ CColorManagementImageDescriptionInfo::CColorManagementImageDescriptionInfo(SPsendPrimariesNamed(m_settings.primariesNamed); - m_resource->sendTfNamed(m_settings.transferFunction); + m_resource->sendTfNamed(convertTransferFunction(m_settings.transferFunction, m_resource->version() == 1)); if (m_settings.transferFunctionPower != 1.0f) m_resource->sendTfPower(std::round(m_settings.transferFunctionPower * 10000));