Skip to content

tests/color-icc-output: add blending test

Pekka Paalanen requested to merge pq/weston:mr/iccblend into main

This MR depends on !914 (merged).


This is adding basically a copy of alpha-blending-test.c. The difference is that here we use ICC files to set up the output color profile, and then test light-linear blending only. BLOCK_WIDTH is set to 1 to fit inside the output size used by the fixture setup, which is smaller than in the original, but does not change the results.

The test is aimed at testing how color-lcms module succeeds in linearizing the output of different ICC output profiles. Incorrect linearization should cause changes in blending results.

The tolerance is taken from the currently achieved error statistics (1.40908) and rounded up a little to achieve a suitable margin.


I tested the sensitivity of this test by modifying libweston/color-lcms/color-profile.c build_eotf_from_clut_profile() to overwrite the recovered EOTF with a hardcoded gamma curve:

 		/**
 		 * Build rgb tone curves
 		 */
 		for (point = 0; point < num_points; point++) {
 			rgb[ch] = (float)point / div;
 			cmsDoTransform(transform_rgb_to_xyz, rgb, prim_xyz.v, 1);
 			curve_array[ch][point] = xyz_dot_prod(prim_xyz,
 							      prim_xyz_max) /
 						 xyz_square_magnitude;
+
+			curve_array[ch][point] = pow(rgb[ch], 2.1);
 		}

Test fixture 5: "sRGB->adobeRGB" with cLUT; fails with two-norm error max = 4.2 and avg = 3.3. The AdobeRGB true gamma is 563 / 256 ~ 2.199.

Test fixture 4: "sRGB->sRGB" with cLUT fails as well.

When hard-coding override gamma 2.2 instead of 2.1, fixture 5 passes but fixture 4 fails with two-norm error max = 12.4 and avg = 2.1.

This means that even pure gamma 2.2, which is often used as roughly equivalent to the piece-wise sRGB EOTF, is not close enough to the piece-wise sRGB EOTF to fool the test. That's pretty neat.

This is strong evidence that the linearization a.k.a Graeme's algorithms is working correctly, at least for these "easy" cLUT-based ICC profiles that are equivalent to matrix-shaper.

cc @vitalyp

Merge request reports