Skip to content
Commits on Source (17)
......@@ -97,18 +97,17 @@ if get_option('screenshare')
endif
if get_option('color-management-lcms')
config_h.set('HAVE_LCMS', '1')
srcs_lcms = [
'cms-static.c',
'cms-helper.c',
]
dep_lcms2 = dependency('lcms2', required: false)
if not dep_lcms2.found()
error('cms-static requires lcms2 which was not found. Or, you can use \'-Dcolor-management-lcms=false\'.')
endif
config_h.set('HAVE_LCMS', '1')
plugin_lcms = shared_library(
'cms-static',
srcs_lcms,
......
......@@ -2,7 +2,6 @@ if not get_option('color-management-lcms')
subdir_done()
endif
dep_lcms2 = dependency('lcms2', version: '>= 2.9', required: false)
if not dep_lcms2.found()
error('color-lcms plugin requires lcms2 which was not found. Or, you can use \'-Dcolor-management-lcms=false\'.')
endif
......
......@@ -158,6 +158,8 @@ if dep_libdrm_version.version_compare('>=2.4.107')
config_h.set('HAVE_HUMAN_FORMAT_MODIFIER', '1')
endif
dep_lcms2 = dependency('lcms2', version: '>= 2.9', required: false)
prog_python = import('python').find_installation('python3')
files_xxd_py = files('tools/xxd.py')
cmd_xxd = [ prog_python, files_xxd_py, '@INPUT@', '@OUTPUT@' ]
......
......@@ -26,13 +26,15 @@
#include "config.h"
#include <math.h>
#include <string.h>
#include <linux/limits.h>
#include <lcms2.h>
#include "weston-test-client-helper.h"
#include "weston-test-fixture-compositor.h"
#include "color_util.h"
#include <string.h>
#include <lcms2.h>
#include <linux/limits.h>
#include "lcms_util.h"
struct lcms_pipeline {
/**
......@@ -52,13 +54,14 @@ struct lcms_pipeline {
*/
struct lcmsMAT3 mat;
/**
* tone curve enum
* matrix from prim_output to XYZ, for example matrix conversion
* sRGB->XYZ, adobeRGB->XYZ, bt2020->XYZ
*/
enum transfer_fn post_fn;
struct lcmsMAT3 mat2XYZ;
/**
* 2/255 or 3/255 maximum possible error, where 255 is 8 bit max value
* tone curve enum
*/
int tolerance;
enum transfer_fn post_fn;
};
static const int WINDOW_WIDTH = 256;
......@@ -66,9 +69,9 @@ static const int WINDOW_HEIGHT = 24;
static cmsCIExyY wp_d65 = { 0.31271, 0.32902, 1.0 };
struct setup_args {
struct fixture_metadata meta;
struct lcms_pipeline pipeline;
enum profile_type {
PTYPE_MATRIX_SHAPER,
PTYPE_CLUT,
};
/*
......@@ -78,69 +81,89 @@ struct setup_args {
* colour.matrix_RGB_to_RGB(colour.RGB_COLOURSPACES['sRGB'], colour.RGB_COLOURSPACES['Adobe RGB (1998)'], None)
* colour.matrix_RGB_to_RGB(colour.RGB_COLOURSPACES['sRGB'], colour.RGB_COLOURSPACES['ITU-R BT.2020'], None)
*/
const struct setup_args arr_setup[] = {
{
.meta.name = "sRGB->sRGB unity",
.pipeline = {
.color_space = "sRGB",
.prim_output = {
.Red = { 0.640, 0.330, 1.0 },
.Green = { 0.300, 0.600, 1.0 },
.Blue = { 0.150, 0.060, 1.0 }
},
.pre_fn = TRANSFER_FN_SRGB_EOTF,
.mat = LCMSMAT3(1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0),
.post_fn = TRANSFER_FN_SRGB_EOTF_INVERSE,
.tolerance = 0
}
const struct lcms_pipeline pipeline_sRGB = {
.color_space = "sRGB",
.prim_output = {
.Red = { 0.640, 0.330, 1.0 },
.Green = { 0.300, 0.600, 1.0 },
.Blue = { 0.150, 0.060, 1.0 }
},
{
.meta.name = "sRGB->adobeRGB",
.pipeline = {
.color_space = "adobeRGB",
.prim_output = {
.Red = { 0.640, 0.330, 1.0 },
.Green = { 0.210, 0.710, 1.0 },
.Blue = { 0.150, 0.060, 1.0 }
},
.pre_fn = TRANSFER_FN_SRGB_EOTF,
.mat = LCMSMAT3(0.715119, 0.284881, 0.0,
0.0, 1.0, 0.0,
0.0, 0.041169, 0.958831),
.post_fn = TRANSFER_FN_ADOBE_RGB_EOTF_INVERSE,
.tolerance = 1
/*
* Tolerance depends more on the 1D LUT used for the
* inv EOTF than the tested 3D LUT size:
* 9x9x9, 17x17x17, 33x33x33, 127x127x127
*/
}
.pre_fn = TRANSFER_FN_SRGB_EOTF,
.mat = LCMSMAT3(1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0),
.mat2XYZ = LCMSMAT3(0.436037, 0.385124, 0.143039,
0.222482, 0.716913, 0.060605,
0.013922, 0.097078, 0.713899),
.post_fn = TRANSFER_FN_SRGB_EOTF_INVERSE
};
const struct lcms_pipeline pipeline_adobeRGB = {
.color_space = "adobeRGB",
.prim_output = {
.Red = { 0.640, 0.330, 1.0 },
.Green = { 0.210, 0.710, 1.0 },
.Blue = { 0.150, 0.060, 1.0 }
},
{
.meta.name = "sRGB->bt2020",
.pipeline = {
.color_space = "bt2020",
.prim_output = {
.Red = { 0.708, 0.292, 1.0 },
.Green = { 0.170, 0.797, 1.0 },
.Blue = { 0.131, 0.046, 1.0 }
},
.pre_fn = TRANSFER_FN_SRGB_EOTF,
.mat = LCMSMAT3(0.627402, 0.329292, 0.043306,
0.069095, 0.919544, 0.011360,
0.016394, 0.088028, 0.895578),
/* this is equivalent to BT.1886 with zero black level */
.post_fn = TRANSFER_FN_POWER2_4_EOTF_INVERSE,
.tolerance = 5
/*
* TODO: when we add power-law in the curve enumeration
* in GL-renderer, then we should fix the tolerance
* as the error should reduce a lot.
*/
}
}
.pre_fn = TRANSFER_FN_SRGB_EOTF,
.mat = LCMSMAT3( 0.715127, 0.284868, 0.000005,
0.000001, 0.999995, 0.000004,
-0.000003, 0.041155, 0.958848),
.mat2XYZ = LCMSMAT3(0.609740, 0.205279, 0.149181,
0.311111, 0.625681, 0.063208,
0.019469, 0.060879, 0.744552),
.post_fn = TRANSFER_FN_ADOBE_RGB_EOTF_INVERSE
};
const struct lcms_pipeline pipeline_BT2020 = {
.color_space = "bt2020",
.prim_output = {
.Red = { 0.708, 0.292, 1.0 },
.Green = { 0.170, 0.797, 1.0 },
.Blue = { 0.131, 0.046, 1.0 }
},
.pre_fn = TRANSFER_FN_SRGB_EOTF,
.mat = LCMSMAT3(0.627402, 0.329292, 0.043306,
0.069095, 0.919544, 0.011360,
0.016394, 0.088028, 0.895578),
/* this is equivalent to BT.1886 with zero black level */
.post_fn = TRANSFER_FN_POWER2_4_EOTF_INVERSE,
};
struct setup_args {
struct fixture_metadata meta;
int ref_image_index;
const struct lcms_pipeline *pipeline;
/**
* 2/255 or 3/255 maximum possible error, where 255 is 8 bit max value
*
* Tolerance depends more on the 1D LUT used for the
* inv EOTF than the tested 3D LUT size:
* 9x9x9, 17x17x17, 33x33x33, 127x127x127
*
* TODO: when we add power-law in the curve enumeration
* in GL-renderer, then we should fix the tolerance
* as the error should reduce a lot.
*/
int tolerance;
/**
* 3DLUT dimension size
*/
int dim_size;
enum profile_type type;
/** Two-norm error limit for cLUT DToB->BToD roundtrip */
float clut_roundtrip_tolerance;
};
static const struct setup_args my_setup_args[] = {
/* name, ref img, pipeline, tolerance, dim, profile type, clut tolerance */
{ { "sRGB->sRGB" }, 0, &pipeline_sRGB, 0, 0, PTYPE_MATRIX_SHAPER },
{ { "sRGB->adobeRGB" }, 1, &pipeline_adobeRGB, 1, 0, PTYPE_MATRIX_SHAPER },
{ { "sRGB->BT2020" }, 2, &pipeline_BT2020, 5, 0, PTYPE_MATRIX_SHAPER },
{ { "sRGB->sRGB" }, 0, &pipeline_sRGB, 0, 17, PTYPE_CLUT, 0.0005 },
{ { "sRGB->adobeRGB" }, 1, &pipeline_adobeRGB, 1, 17, PTYPE_CLUT, 0.0065 },
};
struct image_header {
......@@ -218,8 +241,187 @@ gen_ramp_rgb(const struct image_header *header, int bitwidth, int width_bar)
}
}
static void
test_roundtrip(uint8_t r, uint8_t g, uint8_t b, cmsPipeline *pip,
struct rgb_diff_stat *stat)
{
struct color_float in = { .rgb = { r / 255.0, g / 255.0, b / 255.0 } };
struct color_float out = {};
cmsPipelineEvalFloat(in.rgb, out.rgb, pip);
rgb_diff_stat_update(stat, &in, &out);
}
/*
* Roundtrip verification tests that converting device -> PCS -> device
* results in the original color values close enough.
*
* This ensures that the two pipelines are probably built correctly, and we
* do not have problems with unexpected value clamping or with representing
* (inverse) EOTF curves.
*/
static void
roundtrip_verification(cmsPipeline *DToB, cmsPipeline *BToD, float tolerance)
{
const char *const chan_name[COLOR_CHAN_NUM] = { "r", "g", "b" };
unsigned i;
unsigned r, g, b;
struct rgb_diff_stat stat = {};
cmsPipeline *pip;
pip = cmsPipelineDup(DToB);
cmsPipelineCat(pip, BToD);
/*
* Inverse-EOTF is known to have precision problems near zero, so
* sample near zero densely, the rest can be more sparse to run faster.
*/
for (r = 0; r < 256; r += (r < 15) ? 1 : 8) {
for (g = 0; g < 256; g += (g < 15) ? 1 : 8) {
for (b = 0; b < 256; b += (b < 15) ? 1 : 8)
test_roundtrip(r, g, b, pip, &stat);
}
}
cmsPipelineFree(pip);
testlog("DToB->BToD roundtrip error statistics (%u samples):\n",
stat.two_norm.count);
for (i = 0; i < COLOR_CHAN_NUM; i++) {
testlog(" ch %s error:\n", chan_name[i]);
scalar_stat_print_rgb8bit(&stat.rgb[i]);
}
testlog(" Two-norm error:\n");
scalar_stat_print_rgb8bit(&stat.two_norm);
assert(stat.two_norm.max < tolerance);
}
static cmsInt32Number
sampler_matrix(const float src[], float dst[], void *cargo)
{
const struct lcmsMAT3 *mat = cargo;
struct color_float in = { .r = src[0], .g = src[1], .b = src[2] };
struct color_float cf;
unsigned i;
cf = color_float_apply_matrix(mat, in);
for (i = 0; i < COLOR_CHAN_NUM; i++)
dst[i] = cf.rgb[i];
return 1;
}
static cmsStage *
create_cLUT_from_matrix(cmsContext context_id, const struct lcmsMAT3 *mat, int dim_size)
{
cmsStage *cLUT_stage;
cLUT_stage = cmsStageAllocCLutFloat(context_id, dim_size, 3, 3, NULL);
cmsStageSampleCLutFloat(cLUT_stage, sampler_matrix, (void *)mat, 0);
return cLUT_stage;
}
/*
* Originally the cLUT profile test attempted to use the AToB/BToA tags. Those
* come with serious limitations though: at most uint16 representation for
* values in a LUT which means LUT entry precision is limited and range is
* [0.0, 1.0]. This poses difficulties such as:
* - for AToB, the resulting PCS XYZ values may need to be > 1.0
* - for BToA, it is easy to fall outside of device color volume meaning that
* out-of-range values are needed in the 3D LUT
* Working around these could require offsetting and scaling of values
* before and after the 3D LUT, and even that may not always be possible.
*
* DToB/BToD tags do not have most of these problems, because there pipelines
* use float32 representation throughout. We have much more precision, and
* we can mostly use negative and greater than 1.0 values. LUT elements
* still clamp their input to [0.0, 1.0] before applying the LUT. This type of
* pipeline is called multiProcessElement (MPE).
*
* MPE also allows us to represent curves in a few analytical forms. These are
* just enough to represent the EOTF curves we have and their inverses, but
* they do not allow encoding extended EOTF curves or their inverses
* (defined for all real numbers by extrapolation, and mirroring for negative
* inputs). Using MPE curves we avoid the precision problems that arise from
* attempting to represent an inverse-EOTF as a LUT. For the precision issue,
* see: https://gitlab.freedesktop.org/pq/color-and-hdr/-/merge_requests/9
*
* MPE is not a complete remedy, because 3D LUT inputs are still always clamped
* to [0.0, 1.0]. Therefore a 3D LUT cannot represent the inverse of a matrix
* that can produce negative or greater than 1.0 values without further tricks
* (scaling and offsetting) in the pipeline. Rather than implementing that
* complication, we decided to just not test with such matrices. Therefore
* BT.2020 color space is not used in the cLUT test. AdobeRGB is enough.
*/
static cmsHPROFILE
build_lcms_profile_output(const struct lcms_pipeline *pipeline)
build_lcms_clut_profile_output(cmsContext context_id,
const struct setup_args *arg)
{
enum transfer_fn inv_eotf_fn = arg->pipeline->post_fn;
enum transfer_fn eotf_fn = transfer_fn_invert(inv_eotf_fn);
cmsHPROFILE hRGB;
cmsPipeline *DToB0, *BToD0;
cmsStage *stage;
cmsStage *stage_inv_eotf;
cmsStage *stage_eotf;
struct lcmsMAT3 mat2XYZ_inv;
lcmsMAT3_invert(&mat2XYZ_inv, &arg->pipeline->mat2XYZ);
hRGB = cmsCreateProfilePlaceholder(context_id);
cmsSetProfileVersion(hRGB, 4.3);
cmsSetDeviceClass(hRGB, cmsSigDisplayClass);
cmsSetColorSpace(hRGB, cmsSigRgbData);
cmsSetPCS(hRGB, cmsSigXYZData);
SetTextTags(hRGB, L"cLut profile");
stage_eotf = build_MPE_curve_stage(context_id, eotf_fn);
stage_inv_eotf = build_MPE_curve_stage(context_id, inv_eotf_fn);
/*
* Pipeline from PCS (optical) to device (electrical)
*/
BToD0 = cmsPipelineAlloc(context_id, 3, 3);
stage = create_cLUT_from_matrix(context_id, &mat2XYZ_inv, arg->dim_size);
cmsPipelineInsertStage(BToD0, cmsAT_END, stage);
cmsPipelineInsertStage(BToD0, cmsAT_END, cmsStageDup(stage_inv_eotf));
cmsWriteTag(hRGB, cmsSigBToD0Tag, BToD0);
cmsLinkTag(hRGB, cmsSigBToD1Tag, cmsSigBToD0Tag);
cmsLinkTag(hRGB, cmsSigBToD2Tag, cmsSigBToD0Tag);
cmsLinkTag(hRGB, cmsSigBToD3Tag, cmsSigBToD0Tag);
/*
* Pipeline from device (electrical) to PCS (optical)
*/
DToB0 = cmsPipelineAlloc(context_id, 3, 3);
cmsPipelineInsertStage(DToB0, cmsAT_END, cmsStageDup(stage_eotf));
stage = create_cLUT_from_matrix(context_id, &arg->pipeline->mat2XYZ, arg->dim_size);
cmsPipelineInsertStage(DToB0, cmsAT_END, stage);
cmsWriteTag(hRGB, cmsSigDToB0Tag, DToB0);
cmsLinkTag(hRGB, cmsSigDToB1Tag, cmsSigDToB0Tag);
cmsLinkTag(hRGB, cmsSigDToB2Tag, cmsSigDToB0Tag);
cmsLinkTag(hRGB, cmsSigDToB3Tag, cmsSigDToB0Tag);
roundtrip_verification(DToB0, BToD0, arg->clut_roundtrip_tolerance);
cmsPipelineFree(BToD0);
cmsPipelineFree(DToB0);
cmsStageFree(stage_eotf);
cmsStageFree(stage_inv_eotf);
return hRGB;
}
static cmsHPROFILE
build_lcms_matrix_shaper_profile_output(cmsContext context_id,
const struct lcms_pipeline *pipeline)
{
cmsToneCurve *arr_curves[3];
cmsHPROFILE hRGB;
......@@ -240,12 +442,12 @@ build_lcms_profile_output(const struct lcms_pipeline *pipeline)
*/
arr_curves[0] = arr_curves[1] = arr_curves[2] =
cmsBuildParametricToneCurve(NULL,
cmsBuildParametricToneCurve(context_id,
(-1) * type_inverse_tone_curve,
inverse_tone_curve_param);
assert(arr_curves[0]);
hRGB = cmsCreateRGBProfileTHR(NULL, &wp_d65,
hRGB = cmsCreateRGBProfileTHR(context_id, &wp_d65,
&pipeline->prim_output, arr_curves);
assert(hRGB);
......@@ -253,8 +455,22 @@ build_lcms_profile_output(const struct lcms_pipeline *pipeline)
return hRGB;
}
static cmsHPROFILE
build_lcms_profile_output(cmsContext context_id, const struct setup_args *arg)
{
switch (arg->type) {
case PTYPE_MATRIX_SHAPER:
return build_lcms_matrix_shaper_profile_output(context_id,
arg->pipeline);
case PTYPE_CLUT:
return build_lcms_clut_profile_output(context_id, arg);
}
return NULL;
}
static char *
build_output_icc_profile(const struct lcms_pipeline *pipe)
build_output_icc_profile(const struct setup_args *arg)
{
char *profile_name = NULL;
cmsHPROFILE profile = NULL;
......@@ -264,27 +480,42 @@ build_output_icc_profile(const struct lcms_pipeline *pipe)
wd = realpath(".", NULL);
assert(wd);
ret = asprintf(&profile_name, "%s/matrix-shaper-test-%s.icm", wd,
pipe->color_space);
if (arg->type == PTYPE_MATRIX_SHAPER)
ret = asprintf(&profile_name, "%s/matrix-shaper-test-%s.icm", wd,
arg->pipeline->color_space);
else
ret = asprintf(&profile_name, "%s/cLUT-test-%s.icm", wd,
arg->pipeline->color_space);
assert(ret > 0);
profile = build_lcms_profile_output(pipe);
profile = build_lcms_profile_output(NULL, arg);
assert(profile);
saved = cmsSaveProfileToFile(profile, profile_name);
assert(saved);
cmsCloseProfile(profile);
free(wd);
return profile_name;
}
static void
test_lcms_error_logger(cmsContext context_id,
cmsUInt32Number error_code,
const char *text)
{
testlog("LittleCMS error: %s\n", text);
}
static enum test_result_code
fixture_setup(struct weston_test_harness *harness, const struct setup_args *arg)
{
struct compositor_setup setup;
char *file_name;
cmsSetLogErrorHandler(test_lcms_error_logger);
compositor_setup_defaults(&setup);
setup.renderer = RENDERER_GL;
setup.backend = WESTON_BACKEND_HEADLESS;
......@@ -292,7 +523,7 @@ fixture_setup(struct weston_test_harness *harness, const struct setup_args *arg)
setup.height = WINDOW_HEIGHT;
setup.shell = SHELL_TEST_DESKTOP;
file_name = build_output_icc_profile(&arg->pipeline);
file_name = build_output_icc_profile(arg);
if (!file_name)
return RESULT_HARD_ERROR;
......@@ -307,7 +538,7 @@ fixture_setup(struct weston_test_harness *harness, const struct setup_args *arg)
return weston_test_harness_execute_as_client(harness, &setup);
}
DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, arr_setup, meta);
DECLARE_FIXTURE_SETUP_WITH_ARG(fixture_setup, my_setup_args, meta);
static bool
compare_float(float ref, float dst, int x, const char *chan,
......@@ -361,7 +592,7 @@ process_pipeline_comparison(const struct image_header *src,
const char *const chan_name[COLOR_CHAN_NUM] = { "r", "g", "b" };
const float max_pixel_value = 255.0;
struct color_float max_diff_pipeline = { .rgb = { 0.0f, 0.0f, 0.0f } };
float max_allow_diff = arg->pipeline.tolerance / max_pixel_value;
float max_allow_diff = arg->tolerance / max_pixel_value;
float max_err = 0.0f;
bool ok = true;
uint32_t *row_ptr, *row_ptr_shot;
......@@ -379,9 +610,9 @@ process_pipeline_comparison(const struct image_header *src,
pix_src = a8r8g8b8_to_float(row_ptr[x]);
pix_shot = a8r8g8b8_to_float(row_ptr_shot[x]);
/* do pipeline processing */
process_pixel_using_pipeline(arg->pipeline.pre_fn,
&arg->pipeline.mat,
arg->pipeline.post_fn,
process_pixel_using_pipeline(arg->pipeline->pre_fn,
&arg->pipeline->mat,
arg->pipeline->post_fn,
&pix_src, &pix_src_pipeline);
/* check if pipeline matches to shader variant */
......@@ -398,11 +629,12 @@ process_pipeline_comparison(const struct image_header *src,
for (chan = 0; chan < COLOR_CHAN_NUM; chan++)
max_err = MAX(max_err, max_diff_pipeline.rgb[chan]);
testlog("%s %s %s tol_req %d, tol_cal %f, max diff: r=%f, g=%f, b=%f\n",
testlog("%s %s %s tol_req %d, tol_cal %f, max diff: r=%f, g=%f, b=%f %s\n",
__func__, ok == true? "SUCCESS":"FAILURE",
arg->meta.name, arg->pipeline.tolerance,
arg->meta.name, arg->tolerance,
max_err * max_pixel_value,
max_diff_pipeline.r, max_diff_pipeline.g, max_diff_pipeline.b);
max_diff_pipeline.r, max_diff_pipeline.g, max_diff_pipeline.b,
arg->type == PTYPE_MATRIX_SHAPER ? "matrix-shaper" : "cLUT");
return ok;
}
......@@ -430,8 +662,10 @@ check_process_pattern_ex(struct buffer *src, struct buffer *shot,
/*
* Test that matrix-shaper profile does CM correctly, it is used color ramp pattern
*/
TEST(shaper_matrix)
TEST(shaper_matrix_and_cLUT)
{
int seq_no = get_test_fixture_index();
const struct setup_args *arg = &my_setup_args[seq_no];
const int width = WINDOW_WIDTH;
const int height = WINDOW_HEIGHT;
const int bitwidth = 8;
......@@ -443,7 +677,6 @@ TEST(shaper_matrix)
struct wl_surface *surface;
struct image_header image;
bool match;
int seq_no = get_test_fixture_index();
client = create_client_and_test_surface(0, 0, width, height);
assert(client);
......@@ -460,8 +693,9 @@ TEST(shaper_matrix)
shot = capture_screenshot_of_output(client);
assert(shot);
match = verify_image(shot, "shaper_matrix", seq_no, NULL, seq_no);
assert(check_process_pattern_ex(buf, shot, &arr_setup[seq_no]));
match = verify_image(shot, "shaper_matrix", arg->ref_image_index,
NULL, seq_no);
assert(check_process_pattern_ex(buf, shot, arg));
assert(match);
buffer_destroy(shot);
buffer_destroy(buf);
......
......@@ -23,13 +23,18 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "config.h"
#include <math.h>
#include "color_util.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include <libweston/matrix.h>
#include "color_util.h"
#include "weston-test-runner.h"
#include "shared/helpers.h"
static_assert(sizeof(struct color_float) == 4 * sizeof(float),
......@@ -50,26 +55,26 @@ struct color_tone_curve {
double param[5];
};
/* Mapping from enum transfer_fn to LittleCMS curve parameters. */
const struct color_tone_curve arr_curves[] = {
{
.fn = TRANSFER_FN_SRGB_EOTF,
.inv_fn = TRANSFER_FN_SRGB_EOTF_INVERSE,
.internal_type = 4,
.param = { 2.4, 1. / 1.055, 0.055 / 1.055, 1. / 12.92, 0.04045 } ,
},
{
.fn = TRANSFER_FN_ADOBE_RGB_EOTF,
.inv_fn = TRANSFER_FN_ADOBE_RGB_EOTF_INVERSE,
.internal_type = 1,
.param = { 563./256., 0.0, 0.0, 0.0 , 0.0 } ,
},
{
.fn = TRANSFER_FN_POWER2_4_EOTF,
.inv_fn = TRANSFER_FN_POWER2_4_EOTF_INVERSE,
.internal_type = 1,
.param = { 2.4, 0.0, 0.0, 0.0 , 0.0 } ,
}
{
.fn = TRANSFER_FN_SRGB_EOTF,
.inv_fn = TRANSFER_FN_SRGB_EOTF_INVERSE,
.internal_type = 4,
.param = { 2.4, 1. / 1.055, 0.055 / 1.055, 1. / 12.92, 0.04045 },
},
{
.fn = TRANSFER_FN_ADOBE_RGB_EOTF,
.inv_fn = TRANSFER_FN_ADOBE_RGB_EOTF_INVERSE,
.internal_type = 1,
.param = { 563./256., 0.0, 0.0, 0.0 , 0.0 },
},
{
.fn = TRANSFER_FN_POWER2_4_EOTF,
.inv_fn = TRANSFER_FN_POWER2_4_EOTF_INVERSE,
.internal_type = 1,
.param = { 2.4, 0.0, 0.0, 0.0 , 0.0 },
}
};
bool
......@@ -93,6 +98,52 @@ find_tone_curve_type(enum transfer_fn fn, int *type, double params[5])
return false;
}
enum transfer_fn
transfer_fn_invert(enum transfer_fn fn)
{
switch (fn) {
case TRANSFER_FN_ADOBE_RGB_EOTF:
return TRANSFER_FN_ADOBE_RGB_EOTF_INVERSE;
case TRANSFER_FN_ADOBE_RGB_EOTF_INVERSE:
return TRANSFER_FN_ADOBE_RGB_EOTF;
case TRANSFER_FN_IDENTITY:
return TRANSFER_FN_IDENTITY;
case TRANSFER_FN_POWER2_4_EOTF:
return TRANSFER_FN_POWER2_4_EOTF_INVERSE;
case TRANSFER_FN_POWER2_4_EOTF_INVERSE:
return TRANSFER_FN_POWER2_4_EOTF;
case TRANSFER_FN_SRGB_EOTF:
return TRANSFER_FN_SRGB_EOTF_INVERSE;
case TRANSFER_FN_SRGB_EOTF_INVERSE:
return TRANSFER_FN_SRGB_EOTF;
}
assert(0 && "bad transfer_fn");
return 0;
}
const char *
transfer_fn_name(enum transfer_fn fn)
{
switch (fn) {
case TRANSFER_FN_ADOBE_RGB_EOTF:
return "AdobeRGB EOTF";
case TRANSFER_FN_ADOBE_RGB_EOTF_INVERSE:
return "inverse AdobeRGB EOTF";
case TRANSFER_FN_IDENTITY:
return "identity";
case TRANSFER_FN_POWER2_4_EOTF:
return "power 2.4";
case TRANSFER_FN_POWER2_4_EOTF_INVERSE:
return "inverse power 2.4";
case TRANSFER_FN_SRGB_EOTF:
return "sRGB EOTF";
case TRANSFER_FN_SRGB_EOTF_INVERSE:
return "inverse sRGB EOTF";
}
assert(0 && "bad transfer_fn");
return 0;
}
/**
* NaN comes out as is
*This function is not intended for hiding NaN.
......@@ -161,21 +212,15 @@ Power2_4_EOTF_inv(float o)
return pow(o, 1./2.4);
}
void
sRGB_linearize(struct color_float *cf)
{
int i;
for (i = 0; i < COLOR_CHAN_NUM; i++)
cf->rgb[i] = sRGB_EOTF(cf->rgb[i]);
}
static float
float
apply_tone_curve(enum transfer_fn fn, float r)
{
float ret = 0;
switch(fn) {
case TRANSFER_FN_IDENTITY:
ret = r;
break;
case TRANSFER_FN_SRGB_EOTF:
ret = sRGB_EOTF(r);
break;
......@@ -199,15 +244,6 @@ apply_tone_curve(enum transfer_fn fn, float r)
return ret;
}
void
sRGB_delinearize(struct color_float *cf)
{
int i;
for (i = 0; i < COLOR_CHAN_NUM; i++)
cf->rgb[i] = sRGB_EOTF_inv(cf->rgb[i]);
}
struct color_float
a8r8g8b8_to_float(uint32_t v)
{
......@@ -221,6 +257,52 @@ a8r8g8b8_to_float(uint32_t v)
return cf;
}
static struct color_float
color_float_apply_curve(enum transfer_fn fn, struct color_float c)
{
unsigned i;
for (i = 0; i < COLOR_CHAN_NUM; i++)
c.rgb[i] = apply_tone_curve(fn, c.rgb[i]);
return c;
}
void
sRGB_linearize(struct color_float *cf)
{
*cf = color_float_apply_curve(TRANSFER_FN_SRGB_EOTF, *cf);
}
void
sRGB_delinearize(struct color_float *cf)
{
*cf = color_float_apply_curve(TRANSFER_FN_SRGB_EOTF_INVERSE, *cf);
}
/*
* Returns the result of the matrix-vector multiplication mat * c.
*/
struct color_float
color_float_apply_matrix(const struct lcmsMAT3 *mat, struct color_float c)
{
struct color_float result;
unsigned i, j;
/*
* The matrix has an array of columns, hence i indexes to rows and
* j indexes to columns.
*/
for (i = 0; i < 3; i++) {
result.rgb[i] = 0.0f;
for (j = 0; j < 3; j++)
result.rgb[i] += mat->v[j].n[i] * c.rgb[j];
}
result.a = c.a;
return result;
}
void
process_pixel_using_pipeline(enum transfer_fn pre_curve,
const struct lcmsMAT3 *mat,
......@@ -228,20 +310,106 @@ process_pixel_using_pipeline(enum transfer_fn pre_curve,
const struct color_float *in,
struct color_float *out)
{
int i, j;
struct color_float cf;
float tmp;
for (i = 0; i < COLOR_CHAN_NUM; i++)
cf.rgb[i] = apply_tone_curve(pre_curve, in->rgb[i]);
cf = color_float_apply_curve(pre_curve, *in);
cf = color_float_apply_matrix(mat, cf);
*out = color_float_apply_curve(post_curve, cf);
}
for (i = 0; i < 3; i++) {
tmp = 0.0f;
for (j = 0; j < 3; j++)
tmp += cf.rgb[j] * mat->v[j].n[i];
out->rgb[i] = tmp;
static void
weston_matrix_from_lcmsMAT3(struct weston_matrix *w, const struct lcmsMAT3 *m)
{
unsigned r, c;
/* column-major */
weston_matrix_init(w);
for (c = 0; c < 3; c++) {
for (r = 0; r < 3; r++)
w->d[c * 4 + r] = m->v[c].n[r];
}
}
for (i = 0; i < COLOR_CHAN_NUM; i++)
out->rgb[i] = apply_tone_curve(post_curve, out->rgb[i]);
static void
lcmsMAT3_from_weston_matrix(struct lcmsMAT3 *m, const struct weston_matrix *w)
{
unsigned r, c;
for (c = 0; c < 3; c++) {
for (r = 0; r < 3; r++)
m->v[c].n[r] = w->d[c * 4 + r];
}
}
void
lcmsMAT3_invert(struct lcmsMAT3 *result, const struct lcmsMAT3 *mat)
{
struct weston_matrix inv;
struct weston_matrix w;
int ret;
weston_matrix_from_lcmsMAT3(&w, mat);
ret = weston_matrix_invert(&inv, &w);
assert(ret == 0);
lcmsMAT3_from_weston_matrix(result, &inv);
}
void
scalar_stat_update(struct scalar_stat *stat, double val, struct color_float *pos)
{
if (stat->count == 0 || stat->min > val) {
stat->min = val;
stat->min_pos = *pos;
}
if (stat->count == 0 || stat->max < val) {
stat->max = val;
stat->max_pos = *pos;
}
stat->sum += val;
stat->count++;
}
float
scalar_stat_avg(const struct scalar_stat *stat)
{
return stat->sum / stat->count;
}
#define RGB888_FMT "(%3u, %3u, %3u)"
#define RGB888_VAL(cf) (unsigned)round((cf).r * 255.0), (unsigned)round((cf).g * 255.0), (unsigned)round((cf).b * 255.0)
void
scalar_stat_print_rgb8bit(const struct scalar_stat *stat)
{
testlog(" min %8.5f at " RGB888_FMT "\n", stat->min, RGB888_VAL(stat->min_pos));
testlog(" max %8.5f at " RGB888_FMT "\n", stat->max, RGB888_VAL(stat->max_pos));
testlog(" avg %8.5f\n", scalar_stat_avg(stat));
}
void
scalar_stat_print_float(const struct scalar_stat *stat)
{
testlog(" min %11.5g at %.5f\n", stat->min, stat->min_pos.r);
testlog(" max %11.5g at %.5f\n", stat->max, stat->max_pos.r);
testlog(" avg %11.5g\n", scalar_stat_avg(stat));
}
void
rgb_diff_stat_update(struct rgb_diff_stat *stat,
struct color_float *ref, struct color_float *val)
{
unsigned i;
double ssd = 0.0;
for (i = 0; i < COLOR_CHAN_NUM; i++) {
double diff = val->rgb[i] - ref->rgb[i];
scalar_stat_update(&stat->rgb[i], diff, ref);
ssd += diff * diff;
}
scalar_stat_update(&stat->two_norm, sqrt(ssd), ref);
}
......@@ -24,6 +24,8 @@
* SOFTWARE.
*/
#pragma once
#include <stdint.h>
#include <stdbool.h>
......@@ -34,6 +36,7 @@ enum color_chan_index {
COLOR_CHAN_NUM
};
/* column vector when used in linear algebra */
struct color_float {
union {
float rgb[COLOR_CHAN_NUM];
......@@ -44,15 +47,18 @@ struct color_float {
float a;
};
/* column vector */
struct lcmsVEC3 {
float n[3];
};
struct lcmsMAT3 {
/* array of columns */
struct lcmsVEC3 v[3];
};
enum transfer_fn {
TRANSFER_FN_IDENTITY,
TRANSFER_FN_SRGB_EOTF,
TRANSFER_FN_SRGB_EOTF_INVERSE,
TRANSFER_FN_ADOBE_RGB_EOTF,
......@@ -91,9 +97,56 @@ a8r8g8b8_to_float(uint32_t v);
bool
find_tone_curve_type(enum transfer_fn fn, int *type, double params[5]);
float
apply_tone_curve(enum transfer_fn fn, float r);
void
process_pixel_using_pipeline(enum transfer_fn pre_curve,
const struct lcmsMAT3 *mat,
enum transfer_fn post_curve,
const struct color_float *in,
struct color_float *out);
struct color_float
color_float_apply_matrix(const struct lcmsMAT3 *mat, struct color_float c);
enum transfer_fn
transfer_fn_invert(enum transfer_fn fn);
const char *
transfer_fn_name(enum transfer_fn fn);
void
lcmsMAT3_invert(struct lcmsMAT3 *result, const struct lcmsMAT3 *mat);
struct scalar_stat {
double min;
struct color_float min_pos;
double max;
struct color_float max_pos;
double sum;
unsigned count;
};
struct rgb_diff_stat {
struct scalar_stat rgb[COLOR_CHAN_NUM];
struct scalar_stat two_norm;
};
void
scalar_stat_update(struct scalar_stat *stat, double val, struct color_float *pos);
float
scalar_stat_avg(const struct scalar_stat *stat);
void
scalar_stat_print_rgb8bit(const struct scalar_stat *stat);
void
scalar_stat_print_float(const struct scalar_stat *stat);
void
rgb_diff_stat_update(struct rgb_diff_stat *stat,
struct color_float *ref, struct color_float *val);
/*
* Copyright 2022 Collabora, Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "config.h"
#include <math.h>
#include <lcms2.h>
#include "weston-test-client-helper.h"
#include "color_util.h"
#include "lcms_util.h"
static void
compare_pipeline_to_transfer_fn(cmsPipeline *pipeline, enum transfer_fn fn,
struct scalar_stat *stat)
{
const unsigned N = 100000;
unsigned i;
for (i = 0; i < N; i++) {
float x = (double)i / N;
float ref = apply_tone_curve(fn, x);
float y;
cmsPipelineEvalFloat(&x, &y, pipeline);
scalar_stat_update(stat, y - ref, &(struct color_float){ .r = x });
}
}
static const enum transfer_fn build_MPE_curves_test_set[] = {
TRANSFER_FN_SRGB_EOTF,
TRANSFER_FN_SRGB_EOTF_INVERSE,
TRANSFER_FN_ADOBE_RGB_EOTF,
TRANSFER_FN_ADOBE_RGB_EOTF_INVERSE,
TRANSFER_FN_POWER2_4_EOTF,
TRANSFER_FN_POWER2_4_EOTF_INVERSE,
};
TEST_P(build_MPE_curves, build_MPE_curves_test_set)
{
const enum transfer_fn *fn = data;
const cmsContext ctx = 0;
cmsToneCurve *curve;
cmsStage *stage;
cmsPipeline *pipeline;
struct scalar_stat stat = {};
curve = build_MPE_curve(ctx, *fn);
stage = cmsStageAllocToneCurves(ctx, 1, &curve);
cmsFreeToneCurve(curve);
pipeline = cmsPipelineAlloc(ctx, 1, 1);
cmsPipelineInsertStage(pipeline, cmsAT_END, stage);
compare_pipeline_to_transfer_fn(pipeline, *fn, &stat);
testlog("Transfer function %s as a segmented curve element, error:\n",
transfer_fn_name(*fn));
scalar_stat_print_float(&stat);
assert(fabs(stat.max) < 1e-7);
assert(fabs(stat.min) < 1e-7);
cmsPipelineFree(pipeline);
}
/*
* Copyright 2022 Collabora, Ltd.
* Copyright (c) 1998-2022 Marti Maria Saguer
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "config.h"
#include <math.h>
#include <lcms2.h>
#include <assert.h>
#include "shared/helpers.h"
#include "color_util.h"
#include "lcms_util.h"
/*
* MPE tone curves can only use LittleCMS parametric curve types 6-8 and not
* inverses.
* type 6: Y = (aX + b)^g + c; params [g, a, b, c]
* type 7: Y = a log(bX^g + c) + d; params [g, a, b, c, d]
* type 8: Y = a b^(cX + d) + e; params [a, b, c, d, e]
* Additionally, type 0 is sampled segment.
*
* cmsCurveSegment.x1 is the breakpoint stored in ICC files, except for the
* last segment. First segment always begins at -Inf, and last segment always
* ends at Inf.
*/
static cmsToneCurve *
build_MPE_curve_sRGB(cmsContext ctx)
{
cmsCurveSegment segments[] = {
{
/* Constant zero segment */
.x0 = -HUGE_VAL,
.x1 = 0.0,
.Type = 6,
.Params = { 1.0, 0.0, 0.0, 0.0 },
},
{
/* Linear segment y = x / 12.92 */
.x0 = 0.0,
.x1 = 0.04045,
.Type = 0,
.nGridPoints = 2,
.SampledPoints = (float[]){ 0.0, 0.04045 / 12.92 },
},
{
/* Power segment y = ((x + 0.055) / 1.055)^2.4
* which is translated to
* y = (1/1.055 * x + 0.055 / 1.055)^2.4 + 0.0
*/
.x0 = 0.04045,
.x1 = 1.0,
.Type = 6,
.Params = { 2.4, 1.0 / 1.055, 0.055 / 1.055, 0.0 },
},
{
/* Constant one segment */
.x0 = 1.0,
.x1 = HUGE_VAL,
.Type = 6,
.Params = { 1.0, 0.0, 0.0, 1.0 },
}
};
return cmsBuildSegmentedToneCurve(ctx, ARRAY_LENGTH(segments), segments);
}
static cmsToneCurve *
build_MPE_curve_sRGB_inv(cmsContext ctx)
{
cmsCurveSegment segments[] = {
{
/* Constant zero segment */
.x0 = -HUGE_VAL,
.x1 = 0.0,
.Type = 6,
.Params = { 1.0, 0.0, 0.0, 0.0 },
},
{
/* Linear segment y = x * 12.92 */
.x0 = 0.0,
.x1 = 0.04045 / 12.92,
.Type = 0,
.nGridPoints = 2,
.SampledPoints = (float[]){ 0.0, 0.04045 },
},
{
/* Power segment y = 1.055 * x^(1/2.4) - 0.055
* which is translated to
* y = (1.055^2.4 * x + 0.0)^(1/2.4) - 0.055
*/
.x0 = 0.04045 / 12.92,
.x1 = 1.0,
.Type = 6,
.Params = { 1.0 / 2.4, pow(1.055, 2.4), 0.0, -0.055 },
},
{
/* Constant one segment */
.x0 = 1.0,
.x1 = HUGE_VAL,
.Type = 6,
.Params = { 1.0, 0.0, 0.0, 1.0 },
}
};
return cmsBuildSegmentedToneCurve(ctx, ARRAY_LENGTH(segments), segments);
}
static cmsToneCurve *
build_MPE_curve_power(cmsContext ctx, double exponent)
{
cmsCurveSegment segments[] = {
{
/* Constant zero segment */
.x0 = -HUGE_VAL,
.x1 = 0.0,
.Type = 6,
.Params = { 1.0, 0.0, 0.0, 0.0 },
},
{
/* Power segment y = x^exponent
* which is translated to
* y = (1.0 * x + 0.0)^exponent + 0.0
*/
.x0 = 0.0,
.x1 = 1.0,
.Type = 6,
.Params = { exponent, 1.0, 0.0, 0.0 },
},
{
/* Constant one segment */
.x0 = 1.0,
.x1 = HUGE_VAL,
.Type = 6,
.Params = { 1.0, 0.0, 0.0, 1.0 },
}
};
return cmsBuildSegmentedToneCurve(ctx, ARRAY_LENGTH(segments), segments);
}
cmsToneCurve *
build_MPE_curve(cmsContext ctx, enum transfer_fn fn)
{
switch (fn) {
case TRANSFER_FN_ADOBE_RGB_EOTF:
return build_MPE_curve_power(ctx, 563.0 / 256.0);
case TRANSFER_FN_ADOBE_RGB_EOTF_INVERSE:
return build_MPE_curve_power(ctx, 256.0 / 563.0);
case TRANSFER_FN_POWER2_4_EOTF:
return build_MPE_curve_power(ctx, 2.4);
case TRANSFER_FN_POWER2_4_EOTF_INVERSE:
return build_MPE_curve_power(ctx, 1.0 / 2.4);
case TRANSFER_FN_SRGB_EOTF:
return build_MPE_curve_sRGB(ctx);
case TRANSFER_FN_SRGB_EOTF_INVERSE:
return build_MPE_curve_sRGB_inv(ctx);
default:
assert(0 && "unimplemented MPE curve");
}
return NULL;
}
cmsStage *
build_MPE_curve_stage(cmsContext context_id, enum transfer_fn fn)
{
cmsToneCurve *c;
cmsStage *stage;
c = build_MPE_curve(context_id, fn);
stage = cmsStageAllocToneCurves(context_id, 3,
(cmsToneCurve *[3]){ c, c, c });
assert(stage);
cmsFreeToneCurve(c);
return stage;
}
/* This function is taken from LittleCMS, pardon the odd style */
cmsBool
SetTextTags(cmsHPROFILE hProfile, const wchar_t* Description)
{
cmsMLU *DescriptionMLU, *CopyrightMLU;
cmsBool rc = FALSE;
cmsContext ContextID = cmsGetProfileContextID(hProfile);
DescriptionMLU = cmsMLUalloc(ContextID, 1);
CopyrightMLU = cmsMLUalloc(ContextID, 1);
if (DescriptionMLU == NULL || CopyrightMLU == NULL) goto Error;
if (!cmsMLUsetWide(DescriptionMLU, "en", "US", Description)) goto Error;
if (!cmsMLUsetWide(CopyrightMLU, "en", "US", L"No copyright, use freely")) goto Error;
if (!cmsWriteTag(hProfile, cmsSigProfileDescriptionTag, DescriptionMLU)) goto Error;
if (!cmsWriteTag(hProfile, cmsSigCopyrightTag, CopyrightMLU)) goto Error;
rc = TRUE;
Error:
if (DescriptionMLU)
cmsMLUfree(DescriptionMLU);
if (CopyrightMLU)
cmsMLUfree(CopyrightMLU);
return rc;
}
/*
* Copyright 2022 Collabora, Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#pragma once
#include <lcms2.h>
#include "color_util.h"
cmsToneCurve *
build_MPE_curve(cmsContext ctx, enum transfer_fn fn);
cmsStage *
build_MPE_curve_stage(cmsContext context_id, enum transfer_fn fn);
cmsBool
SetTextTags(cmsHPROFILE hProfile, const wchar_t* Description);
......@@ -60,6 +60,21 @@ dep_test_client = declare_dependency(
]
)
lib_lcms_util = static_library(
'lib_lcms_util',
[ 'lcms_util.c' ],
include_directories: common_inc,
dependencies: [
dep_lcms2, dep_libm
],
build_by_default: false,
install: false,
)
dep_lcms_util = declare_dependency(
link_with: lib_lcms_util,
dependencies: [ dep_lcms2 ]
)
exe_plugin_test = shared_library(
'test-plugin',
'weston-test.c',
......@@ -239,16 +254,19 @@ if get_option('renderer-gl')
endif
if get_option('color-management-lcms')
dep_lcms2 = dependency('lcms2', version: '>= 2.9', required: false)
if not dep_lcms2.found()
error('color-management-lcms tests require lcms2 which was not found. Or, you can use \'-Dcolor-management-lcms=false\'.')
endif
tests += [
{ 'name': 'color-metadata-parsing' },
{
'name': 'color-shaper-matrix',
'dep_objs': [ dep_libm, dep_lcms2 ]
'dep_objs': [ dep_libm, dep_lcms_util ]
},
{
'name': 'lcms-util',
'dep_objs': [ dep_lcms_util ]
},
{ 'name': 'color-metadata-parsing' },
]
endif
......