From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- third_party/jpeg-xl/lib/jxl/cms/jxl_cms_internal.h | 13 +++++++------ third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h | 6 +++--- third_party/jpeg-xl/lib/jxl/cms/transfer_functions-inl.h | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) (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 7f59e688d0..a787bd11d8 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 @@ -183,12 +183,12 @@ static Status ToneMapPixel(const JxlColorEncoding& c, const float in[3], const float f_y = lab_f(xyz[1] / kYn); const float f_z = lab_f(xyz[2] / kZn); - pcslab_out[0] = - static_cast(.5f + 255.f * Clamp1(1.16f * f_y - .16f, 0.f, 1.f)); + pcslab_out[0] = static_cast( + std::lroundf(255.f * Clamp1(1.16f * f_y - .16f, 0.f, 1.f))); pcslab_out[1] = static_cast( - .5f + 128.f + Clamp1(500 * (f_x - f_y), -128.f, 127.f)); + std::lroundf(128.f + Clamp1(500 * (f_x - f_y), -128.f, 127.f))); pcslab_out[2] = static_cast( - .5f + 128.f + Clamp1(200 * (f_y - f_z), -128.f, 127.f)); + std::lroundf(128.f + Clamp1(200 * (f_y - f_z), -128.f, 127.f))); return true; } @@ -581,7 +581,8 @@ static void CreateICCCurvCurvTag(const std::vector& curve, } // Writes 12 + 4*params.size() bytes -static Status CreateICCCurvParaTag(std::vector params, size_t curve_type, +static Status CreateICCCurvParaTag(const std::vector& params, + size_t curve_type, std::vector* tags) { WriteICCTag("para", tags->size(), tags); WriteICCUint32(0, tags->size(), tags); @@ -637,7 +638,7 @@ static Status CreateICCLutAtoBTagForXYB(std::vector* tags) { for (size_t ib = 0; ib < 2; ++ib) { const jxl::cms::ColorCube0D& out_f = cube[ix][iy][ib]; for (int i = 0; i < 3; ++i) { - int32_t val = static_cast(0.5f + 65535 * out_f[i]); + int32_t val = static_cast(std::lroundf(65535 * out_f[i])); JXL_DASSERT(val >= 0 && val <= 65535); WriteICCUint16(val, tags->size(), tags); } 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 81f301a31d..1f85dcca41 100644 --- a/third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h +++ b/third_party/jpeg-xl/lib/jxl/cms/tone_mapping.h @@ -22,8 +22,8 @@ class Rec2408ToneMapperBase { explicit Rec2408ToneMapperBase(std::pair source_range, std::pair target_range, const Vector3& primaries_luminances) - : source_range_(source_range), - target_range_(target_range), + : source_range_(std::move(source_range)), + target_range_(std::move(target_range)), red_Y_(primaries_luminances[0]), green_Y_(primaries_luminances[1]), blue_Y_(primaries_luminances[2]) {} @@ -56,7 +56,7 @@ class Rec2408ToneMapperBase { } protected: - float InvEOTF(const float luminance) const { + static float InvEOTF(const float luminance) { return TF_PQ_Base::EncodedFromDisplay(/*display_intensity_target=*/1.0, luminance); } diff --git a/third_party/jpeg-xl/lib/jxl/cms/transfer_functions-inl.h b/third_party/jpeg-xl/lib/jxl/cms/transfer_functions-inl.h index 84bcbb45ed..133e624c08 100644 --- a/third_party/jpeg-xl/lib/jxl/cms/transfer_functions-inl.h +++ b/third_party/jpeg-xl/lib/jxl/cms/transfer_functions-inl.h @@ -69,7 +69,7 @@ class TF_HLG : TF_HLG_Base { class TF_709 { public: - JXL_INLINE double EncodedFromDisplay(const double d) const { + static JXL_INLINE double EncodedFromDisplay(const double d) { if (d < kThresh) return kMulLow * d; return kMulHi * std::pow(d, kPowHi) + kSub; } -- cgit v1.2.3