Commit Graph

20 Commits

Author SHA1 Message Date
Leandro Ribeiro 8c9dd4febb tests/color-icc-output: add ICC VCGT tests
There are some ICC profiles that contain something named VCGT tag. These
are usually power curves (y = x ^ exp) that were loaded in the video
card when the ICC profile was created. So the compositor should mimic
that in order to use the profile.

Weston already has support for that, but our ICC profile tests were
missing this case. This adds such tests.

For testing purposes, we have added tests with different exponents per
color channel.

Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
2023-04-27 10:37:38 +00:00
Pekka Paalanen 2c0ff9a3b4 tests/color_util: expose color_float_apply_curve()
I will be needing this in color-icc-output blending test.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-07-01 07:46:02 +00:00
Pekka Paalanen be281478dc tests/color_util: doc rgb_diff_stat and scalar_stat
Add documentation for test authors.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-30 09:08:32 +00:00
Pekka Paalanen e103ef4d0d tests: add rgb_diff_stat dumps
This is a special case of scalar_stat dumps to record all of two-norm
and RGB differences on the same line in the dump file.

This makes the dump file easier to handle when you want full RGB errors
recorded.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-30 09:08:32 +00:00
Pekka Paalanen 3f60542405 tests/color_util: make rgb_diff_stat pos explicit
The recently introduced rgb_diff_stat value dumping feature logs the
"position" where the value or error was measured. The reference value
was used as the position, but the problem with the reference value is
that it is an output value and not an input value. Therefore mapping
that back to which input values promoted the error is not easy.

Fix that problem by passing the position explicitly into
rgb_diff_stat_update(), just like it is already passed in to
scalar_stat_update().

Currently the only user simply passes the reference value as position,
because there the input value is also the reference value. This is not
true for future uses of rgb_diff_stat.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-30 09:08:32 +00:00
Pekka Paalanen 912ea2cb20 tests: add scalar_stat dumps
The new field in struct scalar_stat allows recording all tested values
into a file. This is intended to replace ad hoc dumping code like in
alpha-blending-test.c.

To make it easy to set up, also offer a helper to open a writable file
whose name consists of a custom prefix and test name.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-30 09:08:32 +00:00
Pekka Paalanen f31d26669d tests/color_util: constify *_stat_update()
These arguments are not meant to be changed, and a new test will need
this const.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-30 09:08:32 +00:00
Pekka Paalanen 9026293bff tests: change rgb_diff_stat printing
Seems it will be common to print all four min/max/avg sets of errors, so
move the printing code into a shared place.

While 0.0-1.0 is the natural range for color values, people are often
accustomed to working with 8-bit or even 10-bit pixel values. An error
of +/- 1 in 8-bit is more intuitive than +/- 0.004 in floating-point.
Hence 'scaling_bits' is added so the caller can determine the value
scaling. This will scale both the reported error numbers, and the
recorded error positions (rgb-tuples), so they are all comparable.

I'm happy to get rid of those two macros as well.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-30 09:08:32 +00:00
Pekka Paalanen 0d385ffacb tests/alpha-blending: move unpremult to color_util
More tests are going to need this.

The API is changed to work by copy in and copy out to match the other
color_util API. Hopefully this makes the caller code easier to read.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-30 09:08:32 +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
Pekka Paalanen 0225453fb1 tests/color_util: add transfer_fn_name()
This helps reporting test results, then you can print the fn by name.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen 142d8e5125 tests/color_util: add RGB diff stat
These helpers allow collecting color difference statistics easily.

To be used in color-shaper-matrix-test.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen c76e4abb60 tests/color_util: add lcmsMAT3_invert()
Needed to invert device-to-PCS color transformation matrices.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen 141cd3021e tests/color_util: add transfer_fn_invert()
When defining a color space with a transfer function, this looks up the
inverse transfer function without needing to store that separately.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen fa477d2407 tests/color_util: add TRANSFER_FN_IDENTITY
This will be useful to make a curve in a color pipeline pass-through
without needing to special-case skipping the curve.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen 53b1268018 tests/color_util: refactor into color_float_apply_matrix()
Make process_pixel_using_pipeline() slightly easier to read by
extracting a meaningful function.

Pure refactoring, no behavioral changes.

Compared to previous, flip the scalar multiplication around, so that it
matches the mathematical order of matrix-vector multiplication.

Also document the layout conventions for lcmsVEC3 and lcmsMAT3. These
follow the convention used in LittleCMS for cmsVEC3 and cmsMAT3, and are
necessary to understand to review the matrix-vector multiplication for
correctness.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen 85738af912 tests/color_util: protect header from re-reading
Looks like this was forgotten, and I managed to get compiler errors
about redeclaring all enums.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-06-03 10:22:25 +00:00
Pekka Paalanen 4012062228 tests: add rgb[] alias in color_float
Individual struct fields are inconvenient to index into, yet most
operations on a color just repeat the same for each of RGB channel.
Being able to index into RGB avoids repeating the same code for each
channel.

Alpha channel is left as separate, since it is almost never handled the
same as RGB.

The union keeps the old .r, .g and .b addressing working. The static
asserts ensure the aliasing is correct.

For demonstration, two simple functions in color_util.c are converted.

Unfortunately initializers need to be corrected everywhere. Field .a is
not explicitly initialized because it is unused in these cases.

This change should make code easier to read.

This change requires gnu99 or c11 standard. gnu99 is already the default
in top-level meson.build.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
2022-02-18 15:22:44 +00:00
Vitaly Prosyak 264a18f01a tests: shared color processing functions
Added pixel pipeline processing as following:
tone curve(EOTF) + 3x3 matrix + tone curve(INV_EOTF)

Co-authored-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2022-02-12 23:19:02 -05:00
Vitaly Prosyak 15d7546b2d tests: refactoring alpha-blending
No functional change. Moved color processing
functions into shared files which can be used
between different tests.

Signed-off-by: Vitaly Prosyak <vitaly.prosyak@amd.com>
2021-11-13 00:17:03 +00:00