summaryrefslogtreecommitdiff
path: root/src/protocols
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2026-03-04 19:50:28 +0000
committerGitHub <noreply@github.com>2026-03-04 19:50:28 +0000
commit10754745a97c99449ef40db58bd425f5a91f9993 (patch)
tree8aa9f57bcfb2157b9fbdc387c9021db6e6a38e46 /src/protocols
parent8271cfc97b76d573f9122032d6cf5db256d63470 (diff)
render/cm: add ICC profile pipeline (#12711)
Adds an ICC profile pipeline, loading via config and applying via 3D LUTs.
Diffstat (limited to 'src/protocols')
-rw-r--r--src/protocols/ColorManagement.cpp25
-rw-r--r--src/protocols/ColorManagement.hpp10
-rw-r--r--src/protocols/GammaControl.cpp6
-rw-r--r--src/protocols/core/Compositor.hpp2
-rw-r--r--src/protocols/types/ColorManagement.cpp110
-rw-r--r--src/protocols/types/ColorManagement.hpp323
6 files changed, 26 insertions, 450 deletions
diff --git a/src/protocols/ColorManagement.cpp b/src/protocols/ColorManagement.cpp
index 90840217..b9c3143b 100644
--- a/src/protocols/ColorManagement.cpp
+++ b/src/protocols/ColorManagement.cpp
@@ -3,7 +3,7 @@
#include "color-management-v1.hpp"
#include "../helpers/Monitor.hpp"
#include "core/Output.hpp"
-#include "types/ColorManagement.hpp"
+#include "../helpers/cm/ColorManagement.hpp"
#include <cstdint>
using namespace NColorManagement;
@@ -388,12 +388,6 @@ CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SP<CWpColorMana
RESOURCE->m_settings = m_surface->getPreferredImageDescription();
m_currentPreferredId = RESOURCE->m_settings->id();
- if (!PROTO::colorManagement->m_debug && RESOURCE->m_settings->value().icc.fd >= 0) {
- LOGM(Log::ERR, "FIXME: parse icc profile");
- r->error(WP_COLOR_MANAGER_V1_ERROR_UNSUPPORTED_FEATURE, "ICC profiles are not supported");
- return;
- }
-
RESOURCE->resource()->sendReady(m_currentPreferredId);
});
@@ -429,7 +423,7 @@ CColorManagementIccCreator::CColorManagementIccCreator(SP<CWpImageDescriptionCre
LOGM(Log::TRACE, "Create image description from icc for id {}", id);
// FIXME actually check completeness
- if (m_settings.icc.fd < 0 || !m_settings.icc.length) {
+ if (m_icc.fd < 0 || !m_icc.length) {
r->error(WP_IMAGE_DESCRIPTION_CREATOR_PARAMS_V1_ERROR_INCOMPLETE_SET, "Missing required settings");
return;
}
@@ -443,10 +437,10 @@ CColorManagementIccCreator::CColorManagementIccCreator(SP<CWpImageDescriptionCre
return;
}
- LOGM(Log::ERR, "FIXME: Parse icc file {}({},{}) for id {}", m_settings.icc.fd, m_settings.icc.offset, m_settings.icc.length, id);
+ LOGM(Log::ERR, "FIXME: Parse icc file {}({},{}) for id {}", m_icc.fd, m_icc.offset, m_icc.length, id);
// FIXME actually check support
- if (m_settings.icc.fd < 0 || !m_settings.icc.length) {
+ if (m_icc.fd < 0 || !m_icc.length) {
RESOURCE->resource()->sendFailed(WP_IMAGE_DESCRIPTION_V1_CAUSE_UNSUPPORTED, "unsupported");
return;
}
@@ -459,9 +453,9 @@ CColorManagementIccCreator::CColorManagementIccCreator(SP<CWpImageDescriptionCre
});
m_resource->setSetIccFile([this](CWpImageDescriptionCreatorIccV1* r, int fd, uint32_t offset, uint32_t length) {
- m_settings.icc.fd = fd;
- m_settings.icc.offset = offset;
- m_settings.icc.length = length;
+ m_icc.fd = fd;
+ m_icc.offset = offset;
+ m_icc.length = length;
});
}
@@ -731,8 +725,9 @@ CColorManagementImageDescriptionInfo::CColorManagementImageDescriptionInfo(SP<CW
const auto toProto = [](float value) { return sc<int32_t>(std::round(value * PRIMARIES_SCALE)); };
- if (m_settings.icc.fd >= 0)
- m_resource->sendIccFile(m_settings.icc.fd, m_settings.icc.length);
+ // FIXME:
+ // if (m_icc.fd >= 0)
+ // m_resource->sendIccFile(m_icc.fd, m_icc.length);
// send preferred client paramateres
m_resource->sendPrimaries(toProto(m_settings.primaries.red.x), toProto(m_settings.primaries.red.y), toProto(m_settings.primaries.green.x),
diff --git a/src/protocols/ColorManagement.hpp b/src/protocols/ColorManagement.hpp
index d43d5c12..7cdab37d 100644
--- a/src/protocols/ColorManagement.hpp
+++ b/src/protocols/ColorManagement.hpp
@@ -7,7 +7,7 @@
#include "../helpers/Monitor.hpp"
#include "core/Compositor.hpp"
#include "color-management-v1.hpp"
-#include "types/ColorManagement.hpp"
+#include "../helpers/cm/ColorManagement.hpp"
class CColorManager;
class CColorManagementOutput;
@@ -109,6 +109,14 @@ class CColorManagementIccCreator {
WP<CColorManagementIccCreator> m_self;
NColorManagement::SImageDescription m_settings;
+ struct SIccFile {
+ int fd = -1;
+ uint32_t length = 0;
+ uint32_t offset = 0;
+ bool operator==(const SIccFile& i2) const {
+ return fd == i2.fd;
+ }
+ } m_icc;
private:
SP<CWpImageDescriptionCreatorIccV1> m_resource;
diff --git a/src/protocols/GammaControl.cpp b/src/protocols/GammaControl.cpp
index 2517c754..c28b881f 100644
--- a/src/protocols/GammaControl.cpp
+++ b/src/protocols/GammaControl.cpp
@@ -56,6 +56,12 @@ CGammaControl::CGammaControl(SP<CZwlrGammaControlV1> resource_, wl_resource* out
LOGM(Log::DEBUG, "setGamma for {}", m_monitor->m_name);
+ if UNLIKELY (m_monitor->gammaRampsInUse()) {
+ LOGM(Log::ERR, "Monitor has gamma ramps in use (ICC?)");
+ m_resource->sendFailed();
+ return;
+ }
+
// TODO: make CFileDescriptor getflags use F_GETFL
int fdFlags = fcntl(gammaFd.get(), F_GETFL, 0);
if UNLIKELY (fdFlags < 0) {
diff --git a/src/protocols/core/Compositor.hpp b/src/protocols/core/Compositor.hpp
index b5357520..37ca51b7 100644
--- a/src/protocols/core/Compositor.hpp
+++ b/src/protocols/core/Compositor.hpp
@@ -20,7 +20,7 @@
#include "../../helpers/math/Math.hpp"
#include "../../helpers/time/Time.hpp"
#include "../types/Buffer.hpp"
-#include "../types/ColorManagement.hpp"
+#include "../../helpers/cm/ColorManagement.hpp"
#include "../types/SurfaceRole.hpp"
#include "../types/SurfaceState.hpp"
diff --git a/src/protocols/types/ColorManagement.cpp b/src/protocols/types/ColorManagement.cpp
deleted file mode 100644
index 5d23d1c9..00000000
--- a/src/protocols/types/ColorManagement.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-#include "ColorManagement.hpp"
-#include "../../macros.hpp"
-#include <hyprutils/memory/UniquePtr.hpp>
-#include <map>
-#include <vector>
-
-namespace NColorManagement {
- // expected to be small
- static std::vector<UP<const CPrimaries>> knownPrimaries;
- static std::vector<UP<const CImageDescription>> knownDescriptions;
- static std::map<std::pair<uint, uint>, Hyprgraphics::CMatrix3> primariesConversion;
-
- const SPCPRimaries& getPrimaries(ePrimaries name) {
- switch (name) {
- case CM_PRIMARIES_SRGB: return NColorPrimaries::BT709;
- case CM_PRIMARIES_BT2020: return NColorPrimaries::BT2020;
- case CM_PRIMARIES_PAL_M: return NColorPrimaries::PAL_M;
- case CM_PRIMARIES_PAL: return NColorPrimaries::PAL;
- case CM_PRIMARIES_NTSC: return NColorPrimaries::NTSC;
- case CM_PRIMARIES_GENERIC_FILM: return NColorPrimaries::GENERIC_FILM;
- case CM_PRIMARIES_CIE1931_XYZ: return NColorPrimaries::CIE1931_XYZ;
- case CM_PRIMARIES_DCI_P3: return NColorPrimaries::DCI_P3;
- case CM_PRIMARIES_DISPLAY_P3: return NColorPrimaries::DISPLAY_P3;
- case CM_PRIMARIES_ADOBE_RGB: return NColorPrimaries::ADOBE_RGB;
- default: return NColorPrimaries::DEFAULT_PRIMARIES;
- }
- }
-
- CPrimaries::CPrimaries(const SPCPRimaries& primaries, const uint primariesId) : m_id(primariesId), m_primaries(primaries) {
- m_primaries2XYZ = m_primaries.toXYZ();
- }
-
- WP<const CPrimaries> CPrimaries::from(const SPCPRimaries& primaries) {
- for (const auto& known : knownPrimaries) {
- if (known->value() == primaries)
- return known;
- }
-
- knownPrimaries.emplace_back(CUniquePointer(new CPrimaries(primaries, knownPrimaries.size() + 1)));
- return knownPrimaries.back();
- }
-
- WP<const CPrimaries> CPrimaries::from(const ePrimaries name) {
- return from(getPrimaries(name));
- }
-
- WP<const CPrimaries> CPrimaries::from(const uint primariesId) {
- ASSERT(primariesId <= knownPrimaries.size());
- return knownPrimaries[primariesId - 1];
- }
-
- const SPCPRimaries& CPrimaries::value() const {
- return m_primaries;
- }
-
- uint CPrimaries::id() const {
- return m_id;
- }
-
- const Hyprgraphics::CMatrix3& CPrimaries::toXYZ() const {
- return m_primaries2XYZ;
- }
-
- const Hyprgraphics::CMatrix3& CPrimaries::convertMatrix(const WP<const CPrimaries> dst) const {
- const auto cacheKey = std::make_pair(m_id, dst->m_id);
- if (!primariesConversion.contains(cacheKey))
- primariesConversion.insert(std::make_pair(cacheKey, m_primaries.convertMatrix(dst->m_primaries)));
-
- return primariesConversion[cacheKey];
- }
-
- CImageDescription::CImageDescription(const SImageDescription& imageDescription, const uint imageDescriptionId) :
- m_id(imageDescriptionId), m_imageDescription(imageDescription) {
- m_primariesId = CPrimaries::from(m_imageDescription.getPrimaries())->id();
- }
-
- PImageDescription CImageDescription::from(const SImageDescription& imageDescription) {
- for (const auto& known : knownDescriptions) {
- if (known->value() == imageDescription)
- return known;
- }
-
- knownDescriptions.emplace_back(CUniquePointer(new CImageDescription(imageDescription, knownDescriptions.size() + 1)));
- return knownDescriptions.back();
- }
-
- PImageDescription CImageDescription::from(const uint imageDescriptionId) {
- ASSERT(imageDescriptionId <= knownDescriptions.size());
- return knownDescriptions[imageDescriptionId - 1];
- }
-
- PImageDescription CImageDescription::with(const SImageDescription::SPCLuminances& luminances) const {
- auto desc = m_imageDescription;
- desc.luminances = luminances;
- return CImageDescription::from(desc);
- }
-
- const SImageDescription& CImageDescription::value() const {
- return m_imageDescription;
- }
-
- uint CImageDescription::id() const {
- return m_id;
- }
-
- WP<const CPrimaries> CImageDescription::getPrimaries() const {
- return CPrimaries::from(m_primariesId);
- }
-
-} \ No newline at end of file
diff --git a/src/protocols/types/ColorManagement.hpp b/src/protocols/types/ColorManagement.hpp
deleted file mode 100644
index c1f58316..00000000
--- a/src/protocols/types/ColorManagement.hpp
+++ /dev/null
@@ -1,323 +0,0 @@
-#pragma once
-
-#include "color-management-v1.hpp"
-#include <hyprgraphics/color/Color.hpp>
-#include "../../helpers/memory/Memory.hpp"
-
-#define SDR_MIN_LUMINANCE 0.2
-#define SDR_MAX_LUMINANCE 80.0
-#define SDR_REF_LUMINANCE 80.0
-#define HDR_MIN_LUMINANCE 0.005
-#define HDR_MAX_LUMINANCE 10000.0
-#define HDR_REF_LUMINANCE 203.0
-#define HLG_MAX_LUMINANCE 1000.0
-
-namespace NColorManagement {
- enum eNoShader : uint8_t {
- CM_NS_DISABLE = 0,
- CM_NS_ALWAYS = 1,
- CM_NS_ONDEMAND = 2,
- CM_NS_IGNORE = 3,
- };
-
- enum ePrimaries : uint8_t {
- CM_PRIMARIES_SRGB = 1,
- CM_PRIMARIES_PAL_M = 2,
- CM_PRIMARIES_PAL = 3,
- CM_PRIMARIES_NTSC = 4,
- CM_PRIMARIES_GENERIC_FILM = 5,
- CM_PRIMARIES_BT2020 = 6,
- CM_PRIMARIES_CIE1931_XYZ = 7,
- CM_PRIMARIES_DCI_P3 = 8,
- CM_PRIMARIES_DISPLAY_P3 = 9,
- CM_PRIMARIES_ADOBE_RGB = 10,
- };
-
- enum eTransferFunction : uint8_t {
- CM_TRANSFER_FUNCTION_BT1886 = 1,
- CM_TRANSFER_FUNCTION_GAMMA22 = 2,
- CM_TRANSFER_FUNCTION_GAMMA28 = 3,
- CM_TRANSFER_FUNCTION_ST240 = 4,
- CM_TRANSFER_FUNCTION_EXT_LINEAR = 5,
- CM_TRANSFER_FUNCTION_LOG_100 = 6,
- CM_TRANSFER_FUNCTION_LOG_316 = 7,
- CM_TRANSFER_FUNCTION_XVYCC = 8,
- CM_TRANSFER_FUNCTION_SRGB = 9,
- CM_TRANSFER_FUNCTION_EXT_SRGB = 10,
- CM_TRANSFER_FUNCTION_ST2084_PQ = 11,
- CM_TRANSFER_FUNCTION_ST428 = 12,
- CM_TRANSFER_FUNCTION_HLG = 13,
- };
-
- // NOTE should be ok this way. unsupported primaries/tfs must be rejected earlier. supported enum values should be in sync with proto.
- // might need a proper switch-case and additional INVALID enum value.
- inline wpColorManagerV1Primaries convertPrimaries(ePrimaries primaries) {
- return sc<wpColorManagerV1Primaries>(primaries);
- }
- inline ePrimaries convertPrimaries(wpColorManagerV1Primaries primaries) {
- return sc<ePrimaries>(primaries);
- }
- inline wpColorManagerV1TransferFunction convertTransferFunction(eTransferFunction tf) {
- return sc<wpColorManagerV1TransferFunction>(tf);
- }
- inline eTransferFunction convertTransferFunction(wpColorManagerV1TransferFunction tf) {
- return sc<eTransferFunction>(tf);
- }
-
- using SPCPRimaries = Hyprgraphics::SPCPRimaries;
-
- namespace NColorPrimaries {
- static const auto DEFAULT_PRIMARIES = SPCPRimaries{};
-
- static const auto BT709 = SPCPRimaries{
- .red = {.x = 0.64, .y = 0.33},
- .green = {.x = 0.30, .y = 0.60},
- .blue = {.x = 0.15, .y = 0.06},
- .white = {.x = 0.3127, .y = 0.3290},
- };
-
- static const auto PAL_M = SPCPRimaries{
- .red = {.x = 0.67, .y = 0.33},
- .green = {.x = 0.21, .y = 0.71},
- .blue = {.x = 0.14, .y = 0.08},
- .white = {.x = 0.310, .y = 0.316},
- };
-
- static const auto PAL = SPCPRimaries{
- .red = {.x = 0.640, .y = 0.330},
- .green = {.x = 0.290, .y = 0.600},
- .blue = {.x = 0.150, .y = 0.060},
- .white = {.x = 0.3127, .y = 0.3290},
- };
-
- static const auto NTSC = SPCPRimaries{
- .red = {.x = 0.630, .y = 0.340},
- .green = {.x = 0.310, .y = 0.595},
- .blue = {.x = 0.155, .y = 0.070},
- .white = {.x = 0.3127, .y = 0.3290},
- };
-
- static const auto GENERIC_FILM = SPCPRimaries{
- .red = {.x = 0.243, .y = 0.692},
- .green = {.x = 0.145, .y = 0.049},
- .blue = {.x = 0.681, .y = 0.319}, // NOLINT(modernize-use-std-numbers)
- .white = {.x = 0.310, .y = 0.316},
- };
-
- static const auto BT2020 = SPCPRimaries{
- .red = {.x = 0.708, .y = 0.292},
- .green = {.x = 0.170, .y = 0.797},
- .blue = {.x = 0.131, .y = 0.046},
- .white = {.x = 0.3127, .y = 0.3290},
- };
-
- static const auto CIE1931_XYZ = SPCPRimaries{
- .red = {.x = 1.0, .y = 0.0},
- .green = {.x = 0.0, .y = 1.0},
- .blue = {.x = 0.0, .y = 0.0},
- .white = {.x = 1.0 / 3.0, .y = 1.0 / 3.0},
- };
-
- static const auto DCI_P3 = SPCPRimaries{
- .red = {.x = 0.680, .y = 0.320},
- .green = {.x = 0.265, .y = 0.690},
- .blue = {.x = 0.150, .y = 0.060},
- .white = {.x = 0.314, .y = 0.351},
- };
-
- static const auto DISPLAY_P3 = SPCPRimaries{
- .red = {.x = 0.680, .y = 0.320},
- .green = {.x = 0.265, .y = 0.690},
- .blue = {.x = 0.150, .y = 0.060},
- .white = {.x = 0.3127, .y = 0.3290},
- };
-
- static const auto ADOBE_RGB = SPCPRimaries{
- .red = {.x = 0.6400, .y = 0.3300},
- .green = {.x = 0.2100, .y = 0.7100},
- .blue = {.x = 0.1500, .y = 0.0600},
- .white = {.x = 0.3127, .y = 0.3290},
- };
- }
-
- const SPCPRimaries& getPrimaries(ePrimaries name);
-
- class CPrimaries {
- public:
- static WP<const CPrimaries> from(const SPCPRimaries& primaries);
- static WP<const CPrimaries> from(const ePrimaries name);
- static WP<const CPrimaries> from(const uint primariesId);
-
- const SPCPRimaries& value() const;
- uint id() const;
-
- const Hyprgraphics::CMatrix3& toXYZ() const; // toXYZ() * rgb -> xyz
- const Hyprgraphics::CMatrix3& convertMatrix(const WP<const CPrimaries> dst) const; // convertMatrix(dst) * rgb with "this" primaries -> rgb with dst primaries
-
- private:
- CPrimaries(const SPCPRimaries& primaries, const uint primariesId);
- uint m_id;
- SPCPRimaries m_primaries;
-
- Hyprgraphics::CMatrix3 m_primaries2XYZ;
- };
-
- struct SImageDescription {
- struct SIccFile {
- int fd = -1;
- uint32_t length = 0;
- uint32_t offset = 0;
- bool operator==(const SIccFile& i2) const {
- return fd == i2.fd;
- }
- } icc;
-
- bool windowsScRGB = false;
-
- eTransferFunction transferFunction = CM_TRANSFER_FUNCTION_GAMMA22;
- float transferFunctionPower = 1.0f;
-
- bool primariesNameSet = false;
- ePrimaries primariesNamed = CM_PRIMARIES_SRGB;
- // primaries are stored as FP values with the same scale as standard defines (0.0 - 1.0)
- // wayland protocol expects int32_t values multiplied by 1000000
- // drm expects uint16_t values multiplied by 50000
- SPCPRimaries primaries, masteringPrimaries;
-
- // luminances in cd/m²
- // protos and drm expect min * 10000
- struct SPCLuminances {
- float min = 0.2; // 0.2 cd/m²
- uint32_t max = 80; // 80 cd/m²
- uint32_t reference = 80; // 80 cd/m²
- bool operator==(const SPCLuminances& l2) const {
- return min == l2.min && max == l2.max && reference == l2.reference;
- }
- } luminances;
- struct SPCMasteringLuminances {
- float min = 0;
- uint32_t max = 0;
- bool operator==(const SPCMasteringLuminances& l2) const {
- return min == l2.min && max == l2.max;
- }
- } masteringLuminances;
-
- uint32_t maxCLL = 0;
- uint32_t maxFALL = 0;
-
- bool operator==(const SImageDescription& d2) const {
- return icc == d2.icc && windowsScRGB == d2.windowsScRGB && transferFunction == d2.transferFunction && transferFunctionPower == d2.transferFunctionPower &&
- (primariesNameSet == d2.primariesNameSet && (primariesNameSet ? primariesNamed == d2.primariesNamed : primaries == d2.primaries)) &&
- masteringPrimaries == d2.masteringPrimaries && luminances == d2.luminances && masteringLuminances == d2.masteringLuminances && maxCLL == d2.maxCLL &&
- maxFALL == d2.maxFALL;
- }
-
- const SPCPRimaries& getPrimaries() const {
- if (primariesNameSet || primaries == SPCPRimaries{})
- return NColorManagement::getPrimaries(primariesNamed);
- return primaries;
- }
-
- float getTFMinLuminance(float sdrMinLuminance = -1.0f) const {
- switch (transferFunction) {
- 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_ST240:
- case CM_TRANSFER_FUNCTION_LOG_100:
- case CM_TRANSFER_FUNCTION_LOG_316:
- case CM_TRANSFER_FUNCTION_XVYCC:
- case CM_TRANSFER_FUNCTION_EXT_SRGB:
- case CM_TRANSFER_FUNCTION_ST428:
- case CM_TRANSFER_FUNCTION_SRGB:
- default: return sdrMinLuminance >= 0 ? sdrMinLuminance : SDR_MIN_LUMINANCE;
- }
- };
-
- float getTFMaxLuminance(int sdrMaxLuminance = -1) const {
- switch (transferFunction) {
- case CM_TRANSFER_FUNCTION_EXT_LINEAR:
- 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_ST240:
- case CM_TRANSFER_FUNCTION_LOG_100:
- case CM_TRANSFER_FUNCTION_LOG_316:
- case CM_TRANSFER_FUNCTION_XVYCC:
- case CM_TRANSFER_FUNCTION_EXT_SRGB:
- case CM_TRANSFER_FUNCTION_ST428:
- case CM_TRANSFER_FUNCTION_SRGB:
- default: return sdrMaxLuminance >= 0 ? sdrMaxLuminance : SDR_MAX_LUMINANCE;
- }
- };
-
- float getTFRefLuminance(int sdrRefLuminance = -1) const {
- switch (transferFunction) {
- 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_ST240:
- case CM_TRANSFER_FUNCTION_LOG_100:
- case CM_TRANSFER_FUNCTION_LOG_316:
- case CM_TRANSFER_FUNCTION_XVYCC:
- case CM_TRANSFER_FUNCTION_EXT_SRGB:
- case CM_TRANSFER_FUNCTION_ST428:
- case CM_TRANSFER_FUNCTION_SRGB:
- default: return sdrRefLuminance >= 0 ? sdrRefLuminance : SDR_REF_LUMINANCE;
- }
- };
- };
-
- class CImageDescription {
- public:
- static WP<const CImageDescription> from(const SImageDescription& imageDescription);
- static WP<const CImageDescription> from(const uint imageDescriptionId);
-
- WP<const CImageDescription> with(const SImageDescription::SPCLuminances& luminances) const;
-
- const SImageDescription& value() const;
- uint id() const;
-
- WP<const CPrimaries> getPrimaries() const;
-
- private:
- CImageDescription(const SImageDescription& imageDescription, const uint imageDescriptionId);
- uint m_id;
- uint m_primariesId;
- SImageDescription m_imageDescription;
- };
-
- using PImageDescription = WP<const CImageDescription>;
-
- static const auto DEFAULT_IMAGE_DESCRIPTION = CImageDescription::from(SImageDescription{.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_GAMMA22,
- .primariesNameSet = true,
- .primariesNamed = NColorManagement::CM_PRIMARIES_SRGB,
- .primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_SRGB),
- .luminances = {.min = SDR_MIN_LUMINANCE, .max = 80, .reference = 80}});
-
- static const auto DEFAULT_HDR_IMAGE_DESCRIPTION = CImageDescription::from(SImageDescription{.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_ST2084_PQ,
- .primariesNameSet = true,
- .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020,
- .primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_BT2020),
- .luminances = {.min = HDR_MIN_LUMINANCE, .max = 10000, .reference = 203}});
- ;
- static const auto SCRGB_IMAGE_DESCRIPTION = CImageDescription::from(SImageDescription{
- .windowsScRGB = true,
- .transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_EXT_LINEAR,
- .primariesNameSet = true,
- .primariesNamed = NColorManagement::CM_PRIMARIES_SRGB,
- .primaries = NColorPrimaries::BT709,
- .luminances = {.reference = 203},
- });
- ;
-
-} \ No newline at end of file