Commit graph

13 commits

Author SHA1 Message Date
Pekka Paalanen
556272bae9 color-lcms: change stock sRGB to true power-2.2
The sRGB expected display behavior uses the pure power-law with exponent
2.2, not the two-piece sRGB transfer function.
cmsCreate_sRGBProfileTHR() used the two-piece TF, now we use the proper
display TF.

This is particularly meaningful when implicit sRGB content is converted
to HDR formats, in order to maintain the stimuli reproduction near zero.

cmlcms_send_image_desc_info() is already sending this, it doesn't need
fixing.

Changing the curve also changes the error tolerances. The change is
theoretically a no-op, but the curve and its inverse and temporary
rounding add error. The new curve is more prone to error, so it is not
surprising we need to raise the tolerance. The color transformation does
end up as power-2.2 analytical form and I do not think it is ever
lowered to a LUT in alpha-blending test, so there is no obvious fix
improving the accuracy. The worst case point in alpha-blending still
occurs at the very same point as before.

The test reference images are updated for the same reason, they would
fail otherwise.

Both alpha-blending and color-icc-output contain the same sRGB-optical
sub-test, hence the same error tolerance.

It is surprising to have to increase the ICC roundtrip error tolerance
in color-icc-output test, given that the curves are passed as parametric
to LittleCMS, and adobeRGB case works with the old tolerance even. I did
not investigate further.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-06-03 15:47:20 +03:00
Pekka Paalanen
8468289fa3 tests/color_util: move lcms2 data into struct tone_curve_info
Refactoring data about a thing into one place to simplify code.

Also this function is never expected to fail, so no need for the boolean
return.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-06-03 15:47:20 +03:00
Pekka Paalanen
338d727d99 tests: drop EOTF from TRANSFER_FN_SRGB_EOTF
The sRGB display uses a power-2.2 transfer characteristic. These enum
values refer to the two-piece sRGB transfer function instead, so they
should not be named "EOTF".

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-06-03 15:47:20 +03:00
Pekka Paalanen
d3561621e3 tests: change BPC to weston_mat4f
Stop using weston_matrix.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-04-01 15:59:54 +03:00
Pekka Paalanen
3fefb5ba44 libweston, clients, tests: implement weston_matrix in terms of weston_mat4f
This converts weston_matrix and weston_vector to use linalg-types
internally. All direct accesses to members had to be converted
everywhere, mostly in the simplest form possible which leaves some
trivially reducable code around.

The intention is that we can now gradually migrate away from
weston_matrix in the future.

Look like one trailing space got accidentally annihilated in
compositor.c.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2025-04-01 15:59:54 +03:00
Loïc Molinari
c855bc7af0 tests: Port all test clients to the new test asserts
This commit gets rid of libc's abort() usage in the test suite using
test asserts instead.

Asserts run in the server as plugins aren't converted because they are
shared between server and client.

Co-authored-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
2025-02-26 23:50:41 +01:00
Marius Vlad
207fed2710 Revert "shared/helpers.h: Migrate helpers.h to libweston"
This is problematic as we don't have namespacing for these and some of
the macros can interfere with other defines.

This reverts commit 8634c7e349.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2025-01-17 10:18:26 +02:00
Marius Vlad
8634c7e349 shared/helpers.h: Migrate helpers.h to libweston
As weston_windowed_output_get_api needs ARRAY_LENGTH() move helpers to a
libweston/ so other users can re-use that instead of re-defining these
all over. Easier for other front-ends to make use of them.

With this change windowed-output-api.h also includes the helpers header.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
2024-11-25 11:26:35 +00:00
Pekka Paalanen
9f4a9089f4 tests: fix perceptual intent in cLUT ICC profiles
The ICC profiles created for tests here are supposed to produce the same
results regardless of whether they are of the matrix-shaper or cLUT
form, and whether the compositor uses a colorimetric or perceptual
rendering intent. This is silly, but it fits our tests very well since
we mostly want to ensure correct computations in matrix and cLUT code
rather than meaningful results from different rendering intents.

When trying to switch the compositor from colorimetric to perceptual
rendering intent as required by the color-management protocol extension,
all and only the cLUT based tests failed (color-icc-output test).

The reason is that ICCv4 defines the perceptual PCS having a specific
non-zero black point. It requires ICC profiles to convert device black
to the PCS black and vice versa. However, matrix-shaper type ICC
profiles have no way to provide a perceptual transformation to/from PCS
separate from the colorimetric transformation. Hence, LittleCMS exempts
ICCv4 matrix-shaper profiles from the ICCv4 perceptual PCS definition.

Black point compensation (BPC) is always added by LittleCMS with the
perceptual rendering intent. If an ICC profile claims to be ICC version
4, the perceptual transformation in it is assumed to adhere to the
percptual PCS black point, which is non-zero. Hence, DToB0 and BToD0
tags need to respect that so that BPC works correctly.

Before this patch, DToB0 and BToD0 transformations did not use the
correct PCS black point, so when BPC got added, the color space
conversion went wrong. This patch replicates the BPC algorithm that
LittleCMS uses in order to respect the perceptual PCS definition. This
will then cancel out with the BPC added by LittleCMS, producing the
expected color space conversion.

The problem arises only with cLUT ICC profiles because matrix-shaper
profiles are exempt: the black points between source (always
matrix-shaper sRGB profile for now) and destination color spaces match,
and no BPC is added by LittleCMS.

There is no way to ask LittleCMS to add its BPC on our will, so we need
to copy that code from LittleCMS 2.16.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-04-19 12:19:36 +00:00
Pekka Paalanen
94ccce4e38 tests: replace mat2XYZ
The primaries and the white point are the fundamental definition of the
color spaces in these tests. Instead of hard-coding mat2XYZ, use
LittleCMS to derive the result from the fundamental definition.

This removes derived hard-coded constants, which is a benefit in itself.
How these constants were originally produced was not mentioned in
0c5860fafb but I was able to reproduce
them with python3:

import colour
import numpy as np
x = colour.RGB_COLOURSPACES['sRGB']
w_d50 = np.array([0.34567, 0.35850])
print(x.chromatically_adapt(w_d50, 'D50', 'Bradford'))

It's identical to 3-4 decimals of the hardcoded values, and also for
Adobe RGB. I printed the LittleCMS generated values as well, and they
are the same as with python up to roughly 4 decimals.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2024-04-19 12:19:36 +00:00
Leandro Ribeiro
ac3e416402 tests: move functions that create ICC profiles to lcms_util.c
We'll need to craft ICC profiles in the CM&HDR protocol implementation
tests. So move it from color-icc-output-test.c to the LittleCMS helper
in our test suite.

This also removes some unused headers from color-icc-output-test.c, as
we've moved a bunch of code to the LittleCMS helper.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2024-02-12 14:10:44 +00:00
Pekka Paalanen
5921a00b38 tests/lcms_util: add SetTextTags()
This function sets some basic text tags to make an ICC file better
formed.

The code is taken from LittleCMS, https://github.com/mm2/Little-CMS.git
git revision
lcms2.13.1-28-g6ae2e99 (6ae2e99a3535417ca5c95b602eb61fdd29d294d0)
file src/cmsvirt.c.

Suggested-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen
44c3079567 tests: add lcms-util with MPE curves
This adds a new test helper library that depends on LittleCMS 2.

For starters, the library implements conversion from enum transfer_fn to
ICC multiProcessingElements compatible LittleCMS curve object.

That conversion allows encoding transfer funtions in ICC files and
LittleCMS pipelines with full float32 precision instead of forcing a
conversion to a 1D LUT which for power-type curves is surprisingly
imprecise.

This also adds CI tests to make sure the conversion matches our
hand-coded transfer functions.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00