diff --git a/libweston/color-lcms/color-profile.c b/libweston/color-lcms/color-profile.c index 7fe56d0bf..380c4d6ee 100644 --- a/libweston/color-lcms/color-profile.c +++ b/libweston/color-lcms/color-profile.c @@ -550,24 +550,36 @@ make_icc_file_description(struct lcmsProfilePtr profile, } /** + * Build stock sRGB profile used as fallback * - * Build stock profile which available for clients unaware of color management + * BT.709 primaries with gamma-2.2 transfer characteristic. This is the + * expected sRGB display response. */ bool cmlcms_create_stock_profile(struct weston_color_manager_lcms *cm) { - struct lcmsProfilePtr profile; + static const cmsCIExyY D65 = { 0.3127, 0.3290, 1.0 }; + static const cmsCIExyYTRIPLE bt709 = { + { 0.6400, 0.3300, 1.0 }, + { 0.3000, 0.6000, 1.0 }, + { 0.1500, 0.0600, 1.0 } + }; + cmsToneCurve *gamma22[3]; + struct lcmsProfilePtr profile = { NULL }; struct cmlcms_md5_sum md5sum; char *desc = NULL; const char *err_msg = NULL; - profile.p = cmsCreate_sRGBProfileTHR(cm->lcms_ctx); + gamma22[0] = gamma22[1] = gamma22[2] = cmsBuildGamma(cm->lcms_ctx, 2.2); + if (gamma22[0]) + profile.p = cmsCreateRGBProfileTHR(cm->lcms_ctx, &D65, &bt709, gamma22); + cmsFreeToneCurve(gamma22[0]); if (!profile.p) { - weston_log("color-lcms: error: cmsCreate_sRGBProfileTHR failed\n"); + weston_log("color-lcms: error: failed to create stock sRGB profile.\n"); return false; } if (!cmsMD5computeID(profile.p)) { - weston_log("Failed to compute MD5 for ICC profile\n"); + weston_log("Failed to compute MD5 for stock sRGB profile.\n"); goto err_close; } diff --git a/tests/alpha-blending-test.c b/tests/alpha-blending-test.c index b7ea6c21b..1c4af369b 100644 --- a/tests/alpha-blending-test.c +++ b/tests/alpha-blending-test.c @@ -221,17 +221,14 @@ check_blend_pattern(struct buffer *bg, struct buffer *fg, struct buffer *shot, #endif /* - * Allow for +/- 1.5 code points of error in non-linear 8-bit channel - * value. This is necessary for the BLEND_LINEAR case. + * Allow for +/- 1.72 code points of two-norm error in non-linear + * 8-bit channel value. This is necessary for the BLEND_LINEAR case. * - * With llvmpipe, we could go as low as +/- 0.65 code points of error - * and still pass. - * - * AMD Polaris 11 would be ok with +/- 1.0 code points error threshold + * llvmpipe would be ok with +/- 1.0 code points error threshold * if not for one particular case of blending (a=254, r=0) into r=255, - * which results in error of 1.29 code points. + * which results in error of 1.701 code points. */ - const float tolerance = 1.5f / 255.f; + const float tolerance = 1.72f / 255.f; uint32_t *bg_row = get_middle_row(bg); uint32_t *fg_row = get_middle_row(fg); diff --git a/tests/color-icc-output-test.c b/tests/color-icc-output-test.c index e0c34afeb..6af224ee6 100644 --- a/tests/color-icc-output-test.c +++ b/tests/color-icc-output-test.c @@ -57,9 +57,9 @@ const struct lcms_pipeline pipeline_sRGB = { .Green = { 0.300, 0.600, 1.0 }, .Blue = { 0.150, 0.060, 1.0 } }, - .pre_fn = TRANSFER_FN_SRGB, + .pre_fn = TRANSFER_FN_POWER2_2_EOTF, .mat = WESTON_MAT3F_IDENTITY, - .post_fn = TRANSFER_FN_SRGB_INVERSE + .post_fn = TRANSFER_FN_POWER2_2_EOTF_INVERSE }; const struct lcms_pipeline pipeline_adobeRGB = { @@ -69,7 +69,7 @@ const struct lcms_pipeline pipeline_adobeRGB = { .Green = { 0.210, 0.710, 1.0 }, .Blue = { 0.150, 0.060, 1.0 } }, - .pre_fn = TRANSFER_FN_SRGB, + .pre_fn = TRANSFER_FN_POWER2_2_EOTF, .mat = WESTON_MAT3F( 0.715127, 0.284868, 0.000005, 0.000001, 0.999995, 0.000004, @@ -84,7 +84,7 @@ const struct lcms_pipeline pipeline_BT2020 = { .Green = { 0.170, 0.797, 1.0 }, .Blue = { 0.131, 0.046, 1.0 } }, - .pre_fn = TRANSFER_FN_SRGB, + .pre_fn = TRANSFER_FN_POWER2_2_EOTF, .mat = WESTON_MAT3F( 0.627402, 0.329292, 0.043306, 0.069095, 0.919544, 0.011360, @@ -131,12 +131,12 @@ struct setup_args { static const struct setup_args my_setup_args[] = { /* name, ref img, pipeline, tolerance, dim, profile type, clut tolerance, vcgt_exponents */ { { "sRGB->sRGB MAT" }, 0, &pipeline_sRGB, 0.0, 0, PTYPE_MATRIX_SHAPER }, - { { "sRGB->sRGB MAT VCGT" }, 3, &pipeline_sRGB, 0.8, 0, PTYPE_MATRIX_SHAPER, 0.0000, {1.1, 1.2, 1.3} }, + { { "sRGB->sRGB MAT VCGT" }, 3, &pipeline_sRGB, 0.9, 0, PTYPE_MATRIX_SHAPER, 0.0000, {1.1, 1.2, 1.3} }, { { "sRGB->adobeRGB MAT" }, 1, &pipeline_adobeRGB, 1.6, 0, PTYPE_MATRIX_SHAPER }, { { "sRGB->adobeRGB MAT VCGT" }, 4, &pipeline_adobeRGB, 1.0, 0, PTYPE_MATRIX_SHAPER, 0.0000, {1.1, 1.2, 1.3} }, { { "sRGB->BT2020 MAT" }, 2, &pipeline_BT2020, 1.1, 0, PTYPE_MATRIX_SHAPER }, - { { "sRGB->sRGB CLUT" }, 0, &pipeline_sRGB, 0.0, 17, PTYPE_CLUT, 0.0005 }, - { { "sRGB->sRGB CLUT VCGT" }, 3, &pipeline_sRGB, 0.9, 17, PTYPE_CLUT, 0.0005, {1.1, 1.2, 1.3} }, + { { "sRGB->sRGB CLUT" }, 0, &pipeline_sRGB, 1.8, 17, PTYPE_CLUT, 0.01 }, + { { "sRGB->sRGB CLUT VCGT" }, 3, &pipeline_sRGB, 1.3, 17, PTYPE_CLUT, 0.01, {1.1, 1.2, 1.3} }, { { "sRGB->adobeRGB CLUT" }, 1, &pipeline_adobeRGB, 1.8, 17, PTYPE_CLUT, 0.0065 }, { { "sRGB->adobeRGB CLUT VCGT" }, 4, &pipeline_adobeRGB, 1.1, 17, PTYPE_CLUT, 0.0065, {1.1, 1.2, 1.3} }, }; @@ -527,7 +527,7 @@ check_blend_pattern(struct buffer *bg_buf, fclose(dump); /* Test success condition: */ - return diffstat.two_norm.max < 1.5f / 255.0f; + return diffstat.two_norm.max < 1.72f / 255.0f; } static uint32_t diff --git a/tests/color_util.c b/tests/color_util.c index 27a2627d3..64e947e72 100644 --- a/tests/color_util.c +++ b/tests/color_util.c @@ -284,13 +284,13 @@ color_float_apply_curve(enum transfer_fn fn, struct color_float c) void sRGB_linearize(struct color_float *cf) { - *cf = color_float_apply_curve(TRANSFER_FN_SRGB, *cf); + *cf = color_float_apply_curve(TRANSFER_FN_POWER2_2_EOTF, *cf); } void sRGB_delinearize(struct color_float *cf) { - *cf = color_float_apply_curve(TRANSFER_FN_SRGB_INVERSE, *cf); + *cf = color_float_apply_curve(TRANSFER_FN_POWER2_2_EOTF_INVERSE, *cf); } struct color_float diff --git a/tests/lcms_util.c b/tests/lcms_util.c index 8f904c78e..b50701b7c 100644 --- a/tests/lcms_util.c +++ b/tests/lcms_util.c @@ -175,6 +175,10 @@ build_MPE_curve(cmsContext ctx, enum transfer_fn fn) 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_2_EOTF: + return build_MPE_curve_power(ctx, 2.2); + case TRANSFER_FN_POWER2_2_EOTF_INVERSE: + return build_MPE_curve_power(ctx, 1.0 / 2.2); case TRANSFER_FN_POWER2_4_EOTF: return build_MPE_curve_power(ctx, 2.4); case TRANSFER_FN_POWER2_4_EOTF_INVERSE: diff --git a/tests/reference/alpha_blend-01.png b/tests/reference/alpha_blend-01.png index fd93bd4ba..b4a97a102 100644 Binary files a/tests/reference/alpha_blend-01.png and b/tests/reference/alpha_blend-01.png differ diff --git a/tests/reference/output_icc_alpha_blend-00.png b/tests/reference/output_icc_alpha_blend-00.png index beec77b82..7ac543799 100644 Binary files a/tests/reference/output_icc_alpha_blend-00.png and b/tests/reference/output_icc_alpha_blend-00.png differ diff --git a/tests/reference/output_icc_alpha_blend-03.png b/tests/reference/output_icc_alpha_blend-03.png index 9072beda2..4112e66c4 100644 Binary files a/tests/reference/output_icc_alpha_blend-03.png and b/tests/reference/output_icc_alpha_blend-03.png differ diff --git a/tests/reference/shaper_matrix-02.png b/tests/reference/shaper_matrix-02.png index 0abca0be8..de7b6f767 100644 Binary files a/tests/reference/shaper_matrix-02.png and b/tests/reference/shaper_matrix-02.png differ