Commit graph

478 commits

Author SHA1 Message Date
Sebastian Wick
9cd08f4edd color: Clarify behavior of for not-ready image descriptions
In wp_color_management_surface_v1.set_image_description. Image
descriptions which have received neither failed nor ready are being
ignored by the current wording, making it undefined behavior.

Fix this by prohibiting image descriptions in all states other than
ready from being set on a surface.

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2025-02-10 14:55:11 +01:00
Pekka Paalanen
64ccadaed8 color: where did 0.2 cd/m² come from
So we don't forget again.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-02-10 13:21:30 +00:00
Pekka Paalanen
06bf109970 color: revert st2084_pq minimum luminance
This mostly reverts "color: st2084_pq dictates min/max_lum".

This aligns better with the improved definitions of minimum and maximum
luminance: they include display minimum emission and ambient flare.

Since the PQ EOTF has the range of [0.0, 10000.0] cd/m², require that to
be maintained so that max_lum - min_lum = EOTF range.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-02-10 13:21:30 +00:00
Pekka Paalanen
fa38f57c14 color: elaborate on luminance
'set_luminances' request is intended to reflect the viewing conditions,
not only the display emission levels. Mention explicitly that it
includes display light leak and ambient flare, as these cannot be
avoided while viewing.

Ambient flare is physically additive. I was thinking of LCD light
leaks as the minimum display emission, which I presume to be roughly
additive. Effects that are additive in non-optical spaces, e.g.
black-level lift in electrical space, would need their own
parametrization to account for. To keep things simpler, we assume
non-optical additives are zero.

The same definition is applied to the MDCV and target color volume. I
believe it would be confusing otherwise. I can only hope that this is
compatible with SMPTE ST 2086.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-02-10 13:21:30 +00:00
Dudemanguy
5848d5e269 color: bump ICC profile file size limit to 32 MB
Although most profiles are small in size in practice, one could
theoretically contain a 3D LUT in everyday. In the example suggested by
@pq, assuming 63 elements per dimensions would result in a calculation
of 12 tags * 63^3 elements/tag * 3 channels/element * 4 bytes/channel ~=
34 MB. That is well over the old limit. Raise the number and give a
comfortable amount of breathing room for any ICC profile realistically
out there in the wild.

Signed-off-by: Dudemanguy <random342@airmail.cc>
2025-02-06 08:06:23 -06:00
Xaver Hugl
06b86992a3 color: add get_preferred_parametric request
Not every client is able to or wants to deal with ICC profiles. This request
allows them to get a preferred parametric image description for the surface,
even if the compositor's actual preferred iamge description is an ICC profile.

Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
2025-01-30 14:42:31 +01:00
Xaver Hugl
93a6541ec0 color: clarify which events are sent in wp_image_description_info_v1
There was some confusion about which events are sent at which time, so this
simply explicitly lists all the events the compositor *must* send.

Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
2025-01-30 14:42:30 +01:00
Pekka Paalanen
8b57173a44 color: fix a typo
Suggested-by: @asciiwolf
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-01-27 16:00:58 +02:00
Xaver Hugl
abc7a51ba9 color: rename wp_color_management_feedback_surface_v1
Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
2025-01-23 17:28:36 +01:00
Pekka Paalanen
79ce1c161f color: rename TF bt709 to bt1886
BT.709 defines a camera characteristic (OETF). A camera characteristic
is irrelevant for video distribution and broadcast, because the signal
is color graded while watching the result on a reference display
(producing a display-referred signal). BT.709 does not define any
display characteristic, but refers to BT.1886 in a footnote.

BT.601 and BT.2020 are similar to BT.709 in this respect.

The meaning of this enum entry remains the same, only its name is
changed to refer to an actual display characteristic definition.

H.273 mentions more references. Two of them are historical and withdrawn
by the ITU in 2015. BT.1700 NTSC refers to SMPTE ST 170 which is unclear
about the display characteristic: it claims the display EOTF is the
exact inverse of the given OETF. This does not match BT.1886 even though
H.273 implies it does. Hence these are not listed in our enum entry.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-01-23 13:51:19 +00:00
Pekka Paalanen
7a3ffe3183 color: remove bt1361 TF
This historical recommendation has been withdrawn by ITU in 2015.

The "conventional color gamut" portion is equivalent to BT.709 which is
to be decoded with BT.1886.

The "extended color gamut" portion that uses negative RGB values is
unclear how it should be decoded. I haven't seen any recommendation to
that yet. BT.1886 clamps negative values to zero at zero black level
lift.

Therefore I believe it is unlikely to need this in the protocol.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-01-23 13:51:19 +00:00
Xaver Hugl
207ac5858d color: fix a typo and add some commas
Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
2025-01-22 00:47:50 +01:00
Xaver Hugl
c34d365bbe color: rename get_windows_scrgb and new_*_creator requests
Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
2025-01-21 13:53:28 +01:00
Pekka Paalanen
1ec1146505 color: improve HLG description
Even though the HLG OOTF adapts to a display, the HLG signal is still
display-referred because it is color graded by looking at a display
exclusively.

Explain the origin of the reference white level, similar to st2084_pq.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-12-17 14:02:29 +00:00
Leandro Ribeiro
247041df86 color: update some protocol errors
We've opted to graceful failure the image description creation when bad
custom primaries or mastering display primaries are set. But we forgot
to update the errors related to that.

This renames 'invalid_primaries' to 'invalid_named_primaries',
clarifying that it is only possible to have such errors when clients set
primaries through the enums.

Also, this drops the 'invalid_mastering' error, as it is now unused in
the spec.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-12-16 13:04:38 -03:00
Pekka Paalanen
8ac0dc6108 color: restore ext_linear min_lum
This changes the ext_linear default primary color volume minimum back to
0.2 cd/m². This is consistent with the sRGB reference display
characteristics, like with all other transfer functions except st2084_pq
and hlg.

The purpose is that whether content uses srgb, gamma22 or ext_linear
transfer function, it occupies the same (sRGB SDR) dynamic range by
default.

For rendering intents that employ black-point compensation, including
the perceptual rendering intent, this changes nothing.

The set_luminances request can be used to set more appropriate values as
necessary.

Suggested-by: @swick

Removed the wording about implied luminances, because it applies to
almost all TFs, not just this one.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-11-27 16:37:46 +02:00
Pekka Paalanen
e14bb785c0 color: MDCV min L < maxFALL <= maxCLL <= max L
These are the logical requirements. Also if the computation of maxFALL
and maxCLL follow the ANSI/CTA-861-I Annex P algorithms, then
necessarily maxFALL <= maxCLL.

On one hand, making these a protocol requirement causes clients to have
to check these themselves and fix things up in any arbitrary way, while
the compositors will do the exact same checks to send protocol errors.

On the other hand, clients checking these explicitly gives clients the
opportunity to employ a desired fix-up scheme and/or show a UI complaint
that the video content metadata is inconsistent. That would be more
difficult if only some compositors sent a graceful failure when these
requirements are not met.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-11-27 14:04:52 +00:00
Pekka Paalanen
b2e6674d7d color: st2084_pq dictates min/max_lum
ST 2084 a.k.a perceptual quantizer is an absolute luminance encoding
dealing in cd/m². This sets it apart for most other transfer
characteristics that are relative to the target display dynamic range.

Therefore the primary color volume minimum and maximum are fixed by the
ST 2084 specification, and cannot be changed. The reference white is not
fixed and remains settable.

ST 2084 allows displays to deviate from the specified EOTF due to
hardware limitations. How that works is not defined. Therefore code
point zero may produce more than 0 cd/m², but accoding to BT.2100 should
be less or equal to 0.005 cd/m². The difference between decoding with
the exact EOTF and then tone-mapping to display capability, and decoding
straight to display capability is mostly philosophical. The ideal
presentation is defined to be exactly as the ST 2084 specified EOTF.

I believe the image description should reflect this ideal presentation.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-11-25 14:57:25 +02:00
Pekka Paalanen
683a6b7058 color: extend linear transfer function
This change makes the scRGB color space transfer characteristics
encodable as "ext_linear". The key points are supporting negative and
greater than one values, and the implied luminances.

We avoid the need to add another TF just for scRGB. I am not aware of
any use case that would be broken by these differences to the H.273 code
point; material using H.273-linear code point should presumably work
just fine with the protocol "ext_linear". Still, the name "linear" is
left unused in case we need it later.

The luminances are chosen to represent typical SDR content. The minimum
luminance of zero anchors the black point, making it indifferent to the
choice of relative vs. absolute luminance.

When this TF is used in the absolute luminance context, it implies the
Windows-scRGB (HDR) convention of [1.0, 1.0, 1.0] = 80 cd/m².

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-11-07 17:11:26 +02:00
Pekka Paalanen
cc0b659b49 color: remove inconsistent_set protocol error
There seem to be no uses left for this error code. The error already_set
takes care of any inconsistency that could exist.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-11-07 16:14:39 +02:00
Pekka Paalanen
5d230df407 color: relax set_max_cll, set_max_fall
Originally, st2084_pq was the only transfer function providing cd/m².
Since MaxCLL and MaxFALL are defined in cd/m², it made sense to restrict
them to st2084_pq.

Nowadays we have set_luminances and its defaults, meaning we can always
compute cd/m², even from proportional luminance. We can allow MaxCLL and
MaxFALL always.

MaxCLL and MaxFALL were originally intended for the tone mapping in
st2084_pq mode displays as the video system inherently requires. These
values are unique from all the other values in the parametric interface,
and presumably they should help automatic tone mapping also outside of
st2084_pq.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-11-07 16:07:47 +02:00
Pekka Paalanen
425ff5e7d6 color: make invalid id illegal
This started from
https://gitlab.freedesktop.org/swick/wayland-protocols/-/merge_requests/90
where it was desireable for a compositor to send invalid image
description ids because it does not track and de-duplicate image
description records.

Concensus decided the opposite: the id number must be valid. The ability
to skip get_information request was seen valuable, and the effort to
implement id allocation was deemed not too high. It is also to the
majority taste to deliver image descriptions with valid id.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-11-04 16:56:18 +02:00
Pekka Paalanen
b14bb43711 color: add get_windows_scrgb
The Windows flavor of scRGB color space for HDR cannot easily be
represented with the parametric image description factory. The reference
white level is unknown, and the target color volume / MDCV is unknown
yet negative and greater than one color channel values must be
supported. Also gamescope wants to support this without implementing
set_luminances request.

I thought of writing a new factory for enumerated image descriptions,
but decided to reduce the boilerplate by making windows_scrgb just
another feature flag in itself. If we need more enumerated image
descriptions, extending this way seems fine, all the support
advertisements are in the wp_color_manager_v1 interface anyway even if
they are specific to a factory.

It is not possible for a compositor to indicate Windows-scRGB as an
output or a surface's preferred image description in this design. I
cannot see the use for that given how much of the image description is
essentially unknown, especially the reference white level.

Having Windows-scRGB is useful for supporting HDR applications and games
written primarily for Windows. It is not meant for "native" Wayland
applications, they can get better and more reliable results by using the
parametric image description factory.

See also: https://gitlab.freedesktop.org/swick/wayland-protocols/-/merge_requests/78

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-11-04 13:58:47 +00:00
Xaver Hugl
36fc9beaac color: add done event
It can be used by clients to avoid doing a roundtrip to get all the events.

Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
2024-10-31 14:21:55 +00:00
Xaver Hugl
49b794ffdd color: add staging protocol preamble
Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
2024-10-29 20:33:23 +01:00
Dudemanguy
772a0ca6d4 color: start primaries and transfer function enums from 1
Starting from 0 is pretty unwieldy for end users. Lots of clients will
probably need to do some kind of enum -> enum mapping (e.g. like mapping
libplacebo enums to xx-color-management ones). It's much more convenient
for 0 to be the "unsupported/don't use" value instead of forcing in a -1
or something similar.

Signed-off-by: Dudemanguy <random342@airmail.cc>
2024-10-16 11:06:08 +00:00
Matthias Clasen
719dc5c8f9 Fix an inconsistency
Don't say that max-cll and max-fall have well-defined defaults
when the setters say that these properties are undefined initially.

Signed-off-by: Matthias Clasen <mclasen@redhat.com>
2024-10-14 20:14:26 -04:00
Matthias Clasen
5f114fef38 Use consistent terminology
Change the single place that talks about a "pixel description" to
say "image description" like every other place.

Signed-off-by:  Matthias Clasen <mclasen@redhat.com>
2024-10-13 09:18:37 -04:00
Sebastian Wick
0551b010da color: Define out of bounds pixel values
When values are out of the defined transfer function range they cannot
be processed by the definition. State this, and recommend a workaround
to avoid producing an invalid composite image.

Clamping is not required, because the requirement might not be
fulfillable by display hardware via KMS. We don't want to lose KMS
off-loading opportunities by a mere possibility of badly formed data.

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
[Pekka: made clamping optional]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-10-09 12:53:17 +03:00
Pekka Paalanen
3585d00d0c color: define set_tf_power domain
H.273 CICP tends to define the valid domains for the transfer functions,
so we should do so as well. Then it will become possible to state about
the handling of out-of-range values.

Also make this TF an extended one for no particular reason.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-10-07 16:49:44 +03:00
Xaver Hugl
782f2327d2 color: change the multiplier for primaries to 1 million
Some standards require a higher resolution than 1/10000 for primaries, so the protocol
needs be able to transfer sufficient resolution for all these use cases.
50.000 is the biggest used multiplier for primaries that I know of, so 1 million
should be safe.

Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
2024-09-26 20:54:26 +02:00
Pekka Paalanen
3a2f622e24 color: relax reference_lum requirements
The case where reference white luminance would be higher than the
primary color volume maximum luminance is the Windows-style linear
scRGB. (1.0, 1.0, 1.0) is 80 cd/m², but the reference white could e.g.
match the PQ system's 203 cd/m² ~ (2.5, 2.5, 2.5).

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-09-11 14:05:09 +03:00
Xaver Hugl
0a89c38360 color: clarify when set_mastering_luminance is supported
Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
2024-08-05 21:01:50 +02:00
Xaver Hugl
3549451a6a color: clarify destroying the image description after setting it on a surface
To make the client's life slightly easier, allow destroying the image description
immediately after setting it.

Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
2024-08-05 17:49:23 +00:00
Xaver Hugl
59af6d8fd5 color: add inert error for wp_color_management_surface_v1
Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
2024-08-05 19:23:16 +02:00
Benjamin Otte
ba4221f9ff Send identity of new preferred state
This allows longer-running clients who keep a cache to quickly reuse
the image description without needing further communication.

Signed-off-by: Benjamin Otte <otte@redhat.com>
2024-07-28 23:01:45 +02:00
Xaver Hugl
60698a12c1 color: split color management surface into a read only and a write only object
There's no reason to restrict getting the preferred image description on a surface
to only the part of the code that also sets the color management properties on it.

Signed-off-by: Xaver Hugl <xaver.hugl@kde.org>
2024-07-16 00:52:02 +02:00
Sebastian Wick
337cd25beb color: add primary color volume and reference white luminance levels
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2024-07-11 17:36:28 +02:00
Sebastian Wick
060c7b6c09 color: Add the unsupported_feature error to the params creator
Use a more specific error instead of reusing other, existing errors for
this case.

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2024-07-11 17:33:43 +02:00
Pekka Paalanen
2fe18aff12 color: accept also ColorSpace ICC profiles
ICC v4.4 specification explicitly says that ColorSpace profiles may be
embedded in images.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-06-18 13:51:28 +03:00
Sebastian Wick
d8a273ce97 color: Explain what output and preferred image descriptions are
Clears up what happens when an image description is attached to a
wl_surface, as well as what an image description from an output means
and what the preffered image description does.

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2024-06-14 17:37:09 +02:00
Sebastian Wick
32963e9e8e color: Specify what transfer function and power curve mean
The expectation is that the named, well-known transfer characteristics
of an image description describes that the image was encoded according
to the specification of that transfer characteristic.

Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2024-06-07 18:40:46 +02:00
Sebastian Wick
308826f4a5 color: H.273 is authority for well-known transfer functions
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2024-06-06 17:36:07 +02:00
Sebastian Wick
47d55eb1f1 color: Improve formatting and enforce line length limit
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
2024-06-06 17:28:06 +02:00
Pekka Paalanen
d5fb3a52a2 color: allow negative CIE xy coordinates
The one example needing this is the ACES AP0 color space.

For consistency, allow negative values everywhere.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-05-27 14:55:42 +03:00
Leandro Ribeiro
3df41b8c1d color: document inconsistent_set on the create request for the param API
Some requests set_* from wp_image_description_creator_params_v1
documents that an inconsistent param set results in the
inconsistent_protocol error on the create request.

E.g. using set_max_cll but setting the TF to something different from
Rec. ITU-R BT.2100-2 perceptual quantization system.

This patch documents that on the create request description itself.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-05-23 12:20:03 -03:00
Leandro Ribeiro
21eaabfbfa color: do not accept invalid image description
Currently request set_image_description does not have a protocol error
for invalid image description. This adds that.

Invalid image description are those that didn't receive the "ready"
event, but the "failed" one.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-04-04 11:56:36 -03:00
Colin Marc
ab8a7f8a88 color: use qualified names for enums
This trips up codegen in wayland-rs.

Signed-off-by: Colin Marc <hi@colinmarc.com>
2024-03-25 14:09:29 +01:00
Pekka Paalanen
c2f13ff1ff color: forbid multiple wp_color_management_surface_v1
After inspecting EGL and Vulkan APIs, there does not seem to be a need
to allow multiple color management extensions on the same wl_surface.

This reduces the chances of application components fighting over who
sets up the image description.

(There is also an unrelated whitespace fix.)

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-13 17:32:02 +02:00
Pekka Paalanen
b55f9eb03f color: rename set_default_image_description to unset_image_description
"set default" may give the impression that there is a specific default
image description that would be set. There is no such though, a surface
without an image description could be processed differently on different
outputs for example.

The new wording is less misleading.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-02-07 15:39:20 +00:00