From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- third_party/jpeg-xl/lib/jxl/cms/jxl_cms_internal.h | 16 +++++++++++++++- third_party/jpeg-xl/lib/jxl/cms/opsin_params.h | 3 +++ third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'third_party/jpeg-xl/lib/jxl/cms') diff --git a/third_party/jpeg-xl/lib/jxl/cms/jxl_cms_internal.h b/third_party/jpeg-xl/lib/jxl/cms/jxl_cms_internal.h index a787bd11d8..69a5dc434e 100644 --- a/third_party/jpeg-xl/lib/jxl/cms/jxl_cms_internal.h +++ b/third_party/jpeg-xl/lib/jxl/cms/jxl_cms_internal.h @@ -405,7 +405,7 @@ static Status WriteICCS15Fixed16(float value, size_t pos, // Even the first value works well,... bool ok = (-32767.995f <= value) && (value <= 32767.995f); if (!ok) return JXL_FAILURE("ICC value is out of range / NaN"); - int32_t i = value * 65536.0f + 0.5f; + int32_t i = static_cast(std::lround(value * 65536.0f)); // Use two's complement uint32_t u = static_cast(i); WriteICCUint32(u, pos, icc); @@ -849,6 +849,20 @@ static std::string ToString(JxlRenderingIntent rendering_intent) { } static std::string ColorEncodingDescriptionImpl(const JxlColorEncoding& c) { + if (c.color_space == JXL_COLOR_SPACE_RGB && + c.white_point == JXL_WHITE_POINT_D65) { + if (c.rendering_intent == JXL_RENDERING_INTENT_PERCEPTUAL && + c.transfer_function == JXL_TRANSFER_FUNCTION_SRGB) { + if (c.primaries == JXL_PRIMARIES_SRGB) return "sRGB"; + if (c.primaries == JXL_PRIMARIES_P3) return "DisplayP3"; + } + if (c.rendering_intent == JXL_RENDERING_INTENT_RELATIVE && + c.primaries == JXL_PRIMARIES_2100) { + if (c.transfer_function == JXL_TRANSFER_FUNCTION_PQ) return "Rec2100PQ"; + if (c.transfer_function == JXL_TRANSFER_FUNCTION_HLG) return "Rec2100HLG"; + } + } + std::string d = ToString(c.color_space); bool explicit_wp_tf = (c.color_space != JXL_COLOR_SPACE_XYB); diff --git a/third_party/jpeg-xl/lib/jxl/cms/opsin_params.h b/third_party/jpeg-xl/lib/jxl/cms/opsin_params.h index 69dcd0b512..0af852c745 100644 --- a/third_party/jpeg-xl/lib/jxl/cms/opsin_params.h +++ b/third_party/jpeg-xl/lib/jxl/cms/opsin_params.h @@ -6,6 +6,9 @@ #ifndef LIB_JXL_CMS_OPSIN_PARAMS_H_ #define LIB_JXL_CMS_OPSIN_PARAMS_H_ +#include +#include + #include "lib/jxl/base/matrix_ops.h" // Constants that define the XYB color space. diff --git a/third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h b/third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h index 1f85dcca41..c1f43f4d31 100644 --- a/third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h +++ b/third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h @@ -8,6 +8,7 @@ #include #include +#include #include #include "lib/jxl/base/common.h" -- cgit v1.2.3