diff options
author | Alexander Smirnov <alex@ydb.tech> | 2025-02-11 00:51:38 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2025-02-11 00:51:38 +0000 |
commit | 1c380be4486e3fbc7209069d5cb04ebb2eb179ac (patch) | |
tree | 7460a5e24909c32fd88b8c8cd94d2548d26401e4 /contrib/libs | |
parent | 1b5d9e2ff1d57aaa4d1d784c37756d92331e5dc2 (diff) | |
parent | 098dbd39a7651dcc945ab33e751fdf93cc87c914 (diff) | |
download | ydb-1c380be4486e3fbc7209069d5cb04ebb2eb179ac.tar.gz |
Merge branch 'rightlib' into merge-libs-250211-0050
Diffstat (limited to 'contrib/libs')
33 files changed, 947 insertions, 186 deletions
diff --git a/contrib/libs/grpc/patches/pr37742_gzip.patch b/contrib/libs/grpc/patches/pr37742_gzip.patch new file mode 100644 index 0000000000..f2d41a3d74 --- /dev/null +++ b/contrib/libs/grpc/patches/pr37742_gzip.patch @@ -0,0 +1,30 @@ +--- a/src/core/ext/filters/client_channel/retry_filter.cc (index) ++++ b/src/core/ext/filters/client_channel/retry_filter.cc (working tree) +@@ -462,6 +462,9 @@ class RetryFilter::CallData { + grpc_transport_stream_op_batch_payload batch_payload_; + // For send_initial_metadata. + grpc_metadata_batch send_initial_metadata_{calld_->arena_}; ++ ++ SliceBuffer send_message_; ++ + // For send_trailing_metadata. + grpc_metadata_batch send_trailing_metadata_{calld_->arena_}; + // For intercepting recv_initial_metadata. +@@ -1911,6 +1914,7 @@ void RetryFilter::CallData::CallAttempt::BatchData::OnComplete( + } + if (batch_data->batch_.send_message) { + ++call_attempt->completed_send_message_count_; ++ call_attempt->send_message_.Clear(); + } + if (batch_data->batch_.send_trailing_metadata) { + call_attempt->completed_send_trailing_metadata_ = true; +@@ -1999,7 +2003,8 @@ void RetryFilter::CallData::CallAttempt::BatchData:: + calld->send_messages_[call_attempt_->started_send_message_count_]; + ++call_attempt_->started_send_message_count_; + batch_.send_message = true; +- batch_.payload->send_message.send_message = cache.slices; ++ call_attempt_->send_message_ = cache.slices->Copy(); ++ batch_.payload->send_message.send_message = &call_attempt_->send_message_; + batch_.payload->send_message.flags = cache.flags; + } + diff --git a/contrib/libs/grpc/src/core/ext/filters/client_channel/retry_filter.cc b/contrib/libs/grpc/src/core/ext/filters/client_channel/retry_filter.cc index bc965c4731..e92398f4b2 100644 --- a/contrib/libs/grpc/src/core/ext/filters/client_channel/retry_filter.cc +++ b/contrib/libs/grpc/src/core/ext/filters/client_channel/retry_filter.cc @@ -462,6 +462,9 @@ class RetryFilter::CallData { grpc_transport_stream_op_batch_payload batch_payload_; // For send_initial_metadata. grpc_metadata_batch send_initial_metadata_{calld_->arena_}; + + SliceBuffer send_message_; + // For send_trailing_metadata. grpc_metadata_batch send_trailing_metadata_{calld_->arena_}; // For intercepting recv_initial_metadata. @@ -1911,6 +1914,7 @@ void RetryFilter::CallData::CallAttempt::BatchData::OnComplete( } if (batch_data->batch_.send_message) { ++call_attempt->completed_send_message_count_; + call_attempt->send_message_.Clear(); } if (batch_data->batch_.send_trailing_metadata) { call_attempt->completed_send_trailing_metadata_ = true; @@ -1999,7 +2003,8 @@ void RetryFilter::CallData::CallAttempt::BatchData:: calld->send_messages_[call_attempt_->started_send_message_count_]; ++call_attempt_->started_send_message_count_; batch_.send_message = true; - batch_.payload->send_message.send_message = cache.slices; + call_attempt_->send_message_ = cache.slices->Copy(); + batch_.payload->send_message.send_message = &call_attempt_->send_message_; batch_.payload->send_message.flags = cache.flags; } diff --git a/contrib/libs/libpng/.yandex_meta/override.nix b/contrib/libs/libpng/.yandex_meta/override.nix index cc7d52c21c..56a98cd3b0 100644 --- a/contrib/libs/libpng/.yandex_meta/override.nix +++ b/contrib/libs/libpng/.yandex_meta/override.nix @@ -1,11 +1,11 @@ pkgs: attrs: with pkgs; rec { - version = "1.6.45"; + version = "1.6.46"; src = fetchFromGitHub { owner = "pnggroup"; repo = "libpng"; rev = "v${version}"; - hash = "sha256-kO0f65oHhnwrdhCIe2XbyihODxKKKWsJsh+QJS2uBtc="; + hash = "sha256-SP4rpTKFihEEyZ6Zuomy3mhhvIqMkWURjnrntsWO8fo="; }; # nixpkgs applies apng patch from sourceforge.net, which changes for every libpng version. diff --git a/contrib/libs/libpng/ANNOUNCE b/contrib/libs/libpng/ANNOUNCE index 719b23abc4..579824fbe9 100644 --- a/contrib/libs/libpng/ANNOUNCE +++ b/contrib/libs/libpng/ANNOUNCE @@ -1,5 +1,5 @@ -libpng 1.6.45 - January 7, 2025 -=============================== +libpng 1.6.46 - January 23, 2025 +================================ This is a public release of libpng, intended for use in production code. @@ -9,13 +9,13 @@ Files available for download Source files with LF line endings (for Unix/Linux): - * libpng-1.6.45.tar.xz (LZMA-compressed, recommended) - * libpng-1.6.45.tar.gz (deflate-compressed) + * libpng-1.6.46.tar.xz (LZMA-compressed, recommended) + * libpng-1.6.46.tar.gz (deflate-compressed) Source files with CRLF line endings (for Windows): - * lpng1645.7z (LZMA-compressed, recommended) - * lpng1645.zip (deflate-compressed) + * lpng1646.7z (LZMA-compressed, recommended) + * lpng1646.zip (deflate-compressed) Other information: @@ -25,18 +25,17 @@ Other information: * TRADEMARK.md -Changes from version 1.6.44 to version 1.6.45 +Changes from version 1.6.45 to version 1.6.46 --------------------------------------------- - * Added support for the cICP chunk. - (Contributed by Lucas Chollet and John Bowler) - * Adjusted and improved various checks in colorspace calculations. + * Added support for the mDCV and cLLI chunks. (Contributed by John Bowler) - * Rearranged the write order of colorspace chunks for better conformance - with the PNG v3 draft specification. + * Fixed a build issue affecting C89 compilers. + This was a regression introduced in libpng-1.6.45. (Contributed by John Bowler) - * Raised the minimum required CMake version from 3.6 to 3.14. - * Forked off a development branch for libpng version 1.8. + * Added makefile.c89, specifically for testing C89 compilers. + * Cleaned up contrib/pngminus: corrected an old typo, removed an old + workaround, and updated the CMake file. Send comments/corrections/commendations to png-mng-implement at lists.sf.net. diff --git a/contrib/libs/libpng/CHANGES b/contrib/libs/libpng/CHANGES index 3f37f3f393..e6aa1db13f 100644 --- a/contrib/libs/libpng/CHANGES +++ b/contrib/libs/libpng/CHANGES @@ -6229,6 +6229,16 @@ Version 1.6.45 [January 7, 2025] Raised the minimum required CMake version from 3.6 to 3.14. Forked off a development branch for libpng version 1.8. +Version 1.6.46 [January 23, 2025] + Added support for the mDCV and cLLI chunks. + (Contributed by John Bowler) + Fixed a build issue affecting C89 compilers. + This was a regression introduced in libpng-1.6.45. + (Contributed by John Bowler) + Added makefile.c89, specifically for testing C89 compilers. + Cleaned up contrib/pngminus: corrected an old typo, removed an old + workaround, and updated the CMake file. + Send comments/corrections/commendations to png-mng-implement at lists.sf.net. Subscription is required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement diff --git a/contrib/libs/libpng/README b/contrib/libs/libpng/README index 1f73eb58cf..3f3f02023e 100644 --- a/contrib/libs/libpng/README +++ b/contrib/libs/libpng/README @@ -1,4 +1,4 @@ -README for libpng version 1.6.45 +README for libpng version 1.6.46 ================================ See the note about version numbers near the top of `png.h`. diff --git a/contrib/libs/libpng/patches/apng.patch b/contrib/libs/libpng/patches/apng.patch index d84f400e8e..28bd8b0ebc 100644 --- a/contrib/libs/libpng/patches/apng.patch +++ b/contrib/libs/libpng/patches/apng.patch @@ -29,7 +29,7 @@ Index: pngread.c png_ptr->idat_size = length; break; } -@@ -259,6 +262,17 @@ +@@ -269,6 +272,17 @@ png_handle_iTXt(png_ptr, info_ptr, length); #endif @@ -47,7 +47,7 @@ Index: pngread.c else png_handle_unknown(png_ptr, info_ptr, length, PNG_HANDLE_CHUNK_AS_DEFAULT); -@@ -266,6 +280,72 @@ +@@ -276,6 +290,72 @@ } #endif /* SEQUENTIAL_READ */ @@ -124,7 +124,7 @@ Index: pngget.c =================================================================== --- a/pngget.c +++ b/pngget.c -@@ -1288,4 +1288,166 @@ +@@ -1393,4 +1393,166 @@ # endif #endif @@ -337,18 +337,7 @@ Index: png.h /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -@@ -745,6 +767,10 @@ - #define PNG_INFO_IDAT 0x8000U /* ESR, 1.0.6 */ - #define PNG_INFO_eXIf 0x10000U /* GR-P, 1.6.31 */ - #define PNG_INFO_cICP 0x20000U -+#ifdef PNG_APNG_SUPPORTED -+#define PNG_INFO_acTL 0x40000U -+#define PNG_INFO_fcTL 0x80000U -+#endif - - /* This is used for the transformation routines, as some of them - * change these values for the row. It also should enable using -@@ -782,6 +808,10 @@ +@@ -796,6 +818,10 @@ #ifdef PNG_PROGRESSIVE_READ_SUPPORTED typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop)); typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop)); @@ -359,75 +348,75 @@ Index: png.h /* The following callback receives png_uint_32 row_number, int pass for the * png_bytep data of the row. When transforming an interlaced image the -@@ -3241,6 +3271,75 @@ +@@ -3338,6 +3364,75 @@ * END OF HARDWARE AND SOFTWARE OPTIONS ******************************************************************************/ +#ifdef PNG_APNG_SUPPORTED -+PNG_EXPORT(252, png_uint_32, png_get_acTL, (png_structp png_ptr, ++PNG_EXPORT(260, png_uint_32, png_get_acTL, (png_structp png_ptr, + png_infop info_ptr, png_uint_32 *num_frames, png_uint_32 *num_plays)); + -+PNG_EXPORT(253, png_uint_32, png_set_acTL, (png_structp png_ptr, ++PNG_EXPORT(261, png_uint_32, png_set_acTL, (png_structp png_ptr, + png_infop info_ptr, png_uint_32 num_frames, png_uint_32 num_plays)); + -+PNG_EXPORT(254, png_uint_32, png_get_num_frames, (png_structp png_ptr, ++PNG_EXPORT(262, png_uint_32, png_get_num_frames, (png_structp png_ptr, + png_infop info_ptr)); + -+PNG_EXPORT(255, png_uint_32, png_get_num_plays, (png_structp png_ptr, ++PNG_EXPORT(263, png_uint_32, png_get_num_plays, (png_structp png_ptr, + png_infop info_ptr)); + -+PNG_EXPORT(256, png_uint_32, png_get_next_frame_fcTL, ++PNG_EXPORT(264, png_uint_32, png_get_next_frame_fcTL, + (png_structp png_ptr, png_infop info_ptr, png_uint_32 *width, + png_uint_32 *height, png_uint_32 *x_offset, png_uint_32 *y_offset, + png_uint_16 *delay_num, png_uint_16 *delay_den, png_byte *dispose_op, + png_byte *blend_op)); + -+PNG_EXPORT(257, png_uint_32, png_set_next_frame_fcTL, ++PNG_EXPORT(265, png_uint_32, png_set_next_frame_fcTL, + (png_structp png_ptr, png_infop info_ptr, png_uint_32 width, + png_uint_32 height, png_uint_32 x_offset, png_uint_32 y_offset, + png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op, + png_byte blend_op)); + -+PNG_EXPORT(258, png_uint_32, png_get_next_frame_width, ++PNG_EXPORT(266, png_uint_32, png_get_next_frame_width, + (png_structp png_ptr, png_infop info_ptr)); -+PNG_EXPORT(259, png_uint_32, png_get_next_frame_height, ++PNG_EXPORT(267, png_uint_32, png_get_next_frame_height, + (png_structp png_ptr, png_infop info_ptr)); -+PNG_EXPORT(260, png_uint_32, png_get_next_frame_x_offset, ++PNG_EXPORT(268, png_uint_32, png_get_next_frame_x_offset, + (png_structp png_ptr, png_infop info_ptr)); -+PNG_EXPORT(261, png_uint_32, png_get_next_frame_y_offset, ++PNG_EXPORT(269, png_uint_32, png_get_next_frame_y_offset, + (png_structp png_ptr, png_infop info_ptr)); -+PNG_EXPORT(262, png_uint_16, png_get_next_frame_delay_num, ++PNG_EXPORT(270, png_uint_16, png_get_next_frame_delay_num, + (png_structp png_ptr, png_infop info_ptr)); -+PNG_EXPORT(263, png_uint_16, png_get_next_frame_delay_den, ++PNG_EXPORT(271, png_uint_16, png_get_next_frame_delay_den, + (png_structp png_ptr, png_infop info_ptr)); -+PNG_EXPORT(264, png_byte, png_get_next_frame_dispose_op, ++PNG_EXPORT(272, png_byte, png_get_next_frame_dispose_op, + (png_structp png_ptr, png_infop info_ptr)); -+PNG_EXPORT(265, png_byte, png_get_next_frame_blend_op, ++PNG_EXPORT(273, png_byte, png_get_next_frame_blend_op, + (png_structp png_ptr, png_infop info_ptr)); -+PNG_EXPORT(266, png_byte, png_get_first_frame_is_hidden, ++PNG_EXPORT(274, png_byte, png_get_first_frame_is_hidden, + (png_structp png_ptr, png_infop info_ptr)); -+PNG_EXPORT(267, png_uint_32, png_set_first_frame_is_hidden, ++PNG_EXPORT(275, png_uint_32, png_set_first_frame_is_hidden, + (png_structp png_ptr, png_infop info_ptr, png_byte is_hidden)); + +#ifdef PNG_READ_APNG_SUPPORTED -+PNG_EXPORT(268, void, png_read_frame_head, (png_structp png_ptr, ++PNG_EXPORT(276, void, png_read_frame_head, (png_structp png_ptr, + png_infop info_ptr)); +#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -+PNG_EXPORT(269, void, png_set_progressive_frame_fn, (png_structp png_ptr, ++PNG_EXPORT(277, void, png_set_progressive_frame_fn, (png_structp png_ptr, + png_progressive_frame_ptr frame_info_fn, + png_progressive_frame_ptr frame_end_fn)); +#endif /* PROGRESSIVE_READ */ +#endif /* READ_APNG */ + +#ifdef PNG_WRITE_APNG_SUPPORTED -+PNG_EXPORT(270, void, png_write_frame_head, (png_structp png_ptr, ++PNG_EXPORT(278, void, png_write_frame_head, (png_structp png_ptr, + png_infop info_ptr, png_bytepp row_pointers, + png_uint_32 width, png_uint_32 height, + png_uint_32 x_offset, png_uint_32 y_offset, + png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op, + png_byte blend_op)); + -+PNG_EXPORT(271, void, png_write_frame_tail, (png_structp png_ptr, ++PNG_EXPORT(279, void, png_write_frame_tail, (png_structp png_ptr, + png_infop info_ptr)); +#endif /* WRITE_APNG */ +#endif /* APNG */ @@ -435,14 +424,14 @@ Index: png.h /* Maintainer: Put new public prototypes here ^, in libpng.3, in project * defs, and in scripts/symbols.def. */ -@@ -3249,7 +3348,11 @@ +@@ -3346,7 +3441,11 @@ * one to use is one more than this.) */ #ifdef PNG_EXPORT_LAST_ORDINAL +#ifdef PNG_APNG_SUPPORTED -+ PNG_EXPORT_LAST_ORDINAL(271); ++ PNG_EXPORT_LAST_ORDINAL(279); +#else - PNG_EXPORT_LAST_ORDINAL(251); + PNG_EXPORT_LAST_ORDINAL(259); +#endif /* APNG */ #endif @@ -462,7 +451,7 @@ Index: pngpriv.h /* Flags for the transformations the PNG library does on the image data */ #define PNG_BGR 0x0001U -@@ -857,6 +861,16 @@ +@@ -861,6 +865,16 @@ #define png_tRNS PNG_U32(116, 82, 78, 83) #define png_zTXt PNG_U32(122, 84, 88, 116) @@ -479,7 +468,7 @@ Index: pngpriv.h /* The following will work on (signed char*) strings, whereas the get_uint_32 * macro will fail on top-bit-set values because of the sign extension. */ -@@ -1653,6 +1667,49 @@ +@@ -1689,6 +1703,49 @@ #endif /* PROGRESSIVE_READ */ @@ -533,7 +522,7 @@ Index: pnginfo.h =================================================================== --- a/pnginfo.h +++ b/pnginfo.h -@@ -270,5 +270,18 @@ +@@ -288,5 +288,18 @@ png_bytepp row_pointers; /* the image bits */ #endif @@ -599,7 +588,7 @@ Index: pngwrite.c #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED /* Write unknown chunks first; PNG v3 establishes a precedence order * for colourspace chunks. It is certain therefore that new -@@ -399,6 +403,11 @@ +@@ -422,6 +426,11 @@ if ((png_ptr->mode & PNG_HAVE_IDAT) == 0) png_error(png_ptr, "No IDATs written into file"); @@ -611,7 +600,7 @@ Index: pngwrite.c #ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && png_ptr->num_palette_max >= png_ptr->num_palette) -@@ -2446,4 +2455,42 @@ +@@ -2469,4 +2478,42 @@ } #endif /* SIMPLIFIED_WRITE_STDIO */ #endif /* SIMPLIFIED_WRITE */ @@ -758,7 +747,7 @@ Index: pngpread.c png_ptr->idat_size = png_ptr->push_length; png_ptr->process_mode = PNG_READ_IDAT_MODE; png_push_have_info(png_ptr, info_ptr); -@@ -437,6 +523,20 @@ +@@ -453,6 +539,20 @@ } #endif @@ -779,7 +768,7 @@ Index: pngpread.c else { PNG_PUSH_SAVE_BUFFER_IF_FULL -@@ -569,7 +669,11 @@ +@@ -585,7 +685,11 @@ png_byte chunk_tag[4]; /* TODO: this code can be commoned up with the same code in push_read */ @@ -791,7 +780,7 @@ Index: pngpread.c png_push_fill_buffer(png_ptr, chunk_length, 4); png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length); png_reset_crc(png_ptr); -@@ -577,17 +681,60 @@ +@@ -593,17 +697,60 @@ png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag); png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; @@ -852,7 +841,7 @@ Index: pngpread.c } if (png_ptr->idat_size != 0 && png_ptr->save_buffer_size != 0) -@@ -661,6 +808,16 @@ +@@ -677,6 +824,16 @@ if (!(buffer_length > 0) || buffer == NULL) png_error(png_ptr, "No IDAT data (internal error)"); @@ -869,7 +858,7 @@ Index: pngpread.c /* This routine must process all the data it has been given * before returning, calling the row callback as required to * handle the uncompressed results. -@@ -1094,6 +1251,18 @@ +@@ -1110,6 +1267,18 @@ png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer); } @@ -892,7 +881,7 @@ Index: pngset.c =================================================================== --- a/pngset.c +++ b/pngset.c -@@ -305,6 +305,11 @@ +@@ -457,6 +457,11 @@ info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width); @@ -904,7 +893,7 @@ Index: pngset.c } #ifdef PNG_oFFs_SUPPORTED -@@ -1176,6 +1181,146 @@ +@@ -1328,6 +1333,146 @@ } #endif /* sPLT */ @@ -1067,7 +1056,7 @@ Index: pngrutil.c /* Set internal variables */ png_ptr->width = width; png_ptr->height = height; -@@ -2912,6 +2917,180 @@ +@@ -3017,6 +3022,180 @@ } #endif @@ -1248,7 +1237,7 @@ Index: pngrutil.c #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED /* Utility function for png_handle_unknown; set up png_ptr::unknown_chunk */ static int -@@ -3217,7 +3366,11 @@ +@@ -3322,7 +3501,11 @@ if (PNG_USER_CHUNK_MALLOC_MAX < limit) limit = PNG_USER_CHUNK_MALLOC_MAX; # endif @@ -1260,7 +1249,7 @@ Index: pngrutil.c { png_alloc_size_t idat_limit = PNG_UINT_31_MAX; size_t row_factor = -@@ -4217,6 +4400,38 @@ +@@ -4322,6 +4505,38 @@ uInt avail_in; png_bytep buffer; @@ -1299,7 +1288,7 @@ Index: pngrutil.c while (png_ptr->idat_size == 0) { png_crc_finish(png_ptr, 0); -@@ -4228,6 +4443,7 @@ +@@ -4333,6 +4548,7 @@ if (png_ptr->chunk_name != png_IDAT) png_error(png_ptr, "Not enough image data"); } @@ -1307,7 +1296,7 @@ Index: pngrutil.c avail_in = png_ptr->IDAT_read_size; -@@ -4291,6 +4507,9 @@ +@@ -4396,6 +4612,9 @@ png_ptr->mode |= PNG_AFTER_IDAT; png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; @@ -1317,7 +1306,7 @@ Index: pngrutil.c if (png_ptr->zstream.avail_in > 0 || png_ptr->idat_size > 0) png_chunk_benign_error(png_ptr, "Extra compressed data"); -@@ -4700,4 +4919,80 @@ +@@ -4805,4 +5024,80 @@ png_ptr->flags |= PNG_FLAG_ROW_INIT; } @@ -1450,7 +1439,7 @@ Index: pngwutil.c png_ptr->zstream.avail_out = 0; png_ptr->zstream.next_out = NULL; png_ptr->mode |= PNG_HAVE_IDAT | PNG_AFTER_IDAT; -@@ -1925,6 +1950,82 @@ +@@ -1969,6 +1994,82 @@ } #endif @@ -1533,7 +1522,7 @@ Index: pngwutil.c /* Initializes the row writing capability of libpng */ void /* PRIVATE */ png_write_start_row(png_structrp png_ptr) -@@ -2778,4 +2879,39 @@ +@@ -2822,4 +2923,39 @@ } #endif /* WRITE_FLUSH */ } diff --git a/contrib/libs/libpng/png.c b/contrib/libs/libpng/png.c index 466af7d992..cbd54e1af8 100644 --- a/contrib/libs/libpng/png.c +++ b/contrib/libs/libpng/png.c @@ -13,7 +13,7 @@ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_45 Your_png_h_is_not_version_1_6_45; +typedef png_libpng_version_1_6_46 Your_png_h_is_not_version_1_6_46; /* Tells libpng that we have already handled the first "num_bytes" bytes * of the PNG file signature. If the PNG data is embedded into another @@ -793,7 +793,7 @@ png_get_copyright(png_const_structrp png_ptr) return PNG_STRING_COPYRIGHT #else return PNG_STRING_NEWLINE \ - "libpng version 1.6.45" PNG_STRING_NEWLINE \ + "libpng version 1.6.46" PNG_STRING_NEWLINE \ "Copyright (c) 2018-2025 Cosmin Truta" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \ PNG_STRING_NEWLINE \ @@ -1544,56 +1544,59 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy) * Adobe Wide Gamut RGB * 0.258728243040113 0.724682314948566 0.016589442011321 */ - int error = 0; - - /* By the argument above overflow should be impossible here, however the - * code now simply returns a failure code. The xy subtracts in the arguments - * to png_muldiv are *not* checked for overflow because the checks at the - * start guarantee they are in the range 0..110000 and png_fixed_point is a - * 32-bit signed number. - */ - if (png_muldiv(&left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 8) == 0) - return 1; - if (png_muldiv(&right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 8) == 0) - return 1; - denominator = png_fp_sub(left, right, &error); - if (error) return 1; + { + int error = 0; - /* Now find the red numerator. */ - if (png_muldiv(&left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 8) == 0) - return 1; - if (png_muldiv(&right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 8) == 0) - return 1; + /* By the argument above overflow should be impossible here, however the + * code now simply returns a failure code. The xy subtracts in the + * arguments to png_muldiv are *not* checked for overflow because the + * checks at the start guarantee they are in the range 0..110000 and + * png_fixed_point is a 32-bit signed number. + */ + if (png_muldiv(&left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 8) == 0) + return 1; + if (png_muldiv(&right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 8) == + 0) + return 1; + denominator = png_fp_sub(left, right, &error); + if (error) return 1; - /* Overflow is possible here and it indicates an extreme set of PNG cHRM - * chunk values. This calculation actually returns the reciprocal of the - * scale value because this allows us to delay the multiplication of white-y - * into the denominator, which tends to produce a small number. - */ - if (png_muldiv(&red_inverse, xy->whitey, denominator, - png_fp_sub(left, right, &error)) == 0 || error || - red_inverse <= xy->whitey /* r+g+b scales = white scale */) - return 1; + /* Now find the red numerator. */ + if (png_muldiv(&left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 8) == 0) + return 1; + if (png_muldiv(&right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 8) == + 0) + return 1; - /* Similarly for green_inverse: */ - if (png_muldiv(&left, xy->redy-xy->bluey, xy->whitex-xy->bluex, 8) == 0) - return 1; - if (png_muldiv(&right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 8) == 0) - return 1; - if (png_muldiv(&green_inverse, xy->whitey, denominator, - png_fp_sub(left, right, &error)) == 0 || error || - green_inverse <= xy->whitey) - return 1; + /* Overflow is possible here and it indicates an extreme set of PNG cHRM + * chunk values. This calculation actually returns the reciprocal of the + * scale value because this allows us to delay the multiplication of + * white-y into the denominator, which tends to produce a small number. + */ + if (png_muldiv(&red_inverse, xy->whitey, denominator, + png_fp_sub(left, right, &error)) == 0 || error || + red_inverse <= xy->whitey /* r+g+b scales = white scale */) + return 1; - /* And the blue scale, the checks above guarantee this can't overflow but it - * can still produce 0 for extreme cHRM values. - */ - blue_scale = png_fp_sub(png_fp_sub(png_reciprocal(xy->whitey), - png_reciprocal(red_inverse), &error), - png_reciprocal(green_inverse), &error); - if (error || blue_scale <= 0) - return 1; + /* Similarly for green_inverse: */ + if (png_muldiv(&left, xy->redy-xy->bluey, xy->whitex-xy->bluex, 8) == 0) + return 1; + if (png_muldiv(&right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 8) == 0) + return 1; + if (png_muldiv(&green_inverse, xy->whitey, denominator, + png_fp_sub(left, right, &error)) == 0 || error || + green_inverse <= xy->whitey) + return 1; + /* And the blue scale, the checks above guarantee this can't overflow but + * it can still produce 0 for extreme cHRM values. + */ + blue_scale = png_fp_sub(png_fp_sub(png_reciprocal(xy->whitey), + png_reciprocal(red_inverse), &error), + png_reciprocal(green_inverse), &error); + if (error || blue_scale <= 0) + return 1; + } /* And fill in the png_XYZ. Again the subtracts are safe because of the * checks on the xy values at the start (the subtracts just calculate the @@ -3390,6 +3393,26 @@ png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text) } #endif +#if defined(PNG_FLOATING_POINT_SUPPORTED) && \ + !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \ + (defined(PNG_cLLI_SUPPORTED) || defined(PNG_mDCV_SUPPORTED)) +png_uint_32 +png_fixed_ITU(png_const_structrp png_ptr, double fp, png_const_charp text) +{ + double r = floor(10000 * fp + .5); + + if (r > 2147483647. || r < 0) + png_fixed_error(png_ptr, text); + +# ifndef PNG_ERROR_TEXT_SUPPORTED + PNG_UNUSED(text) +# endif + + return (png_uint_32)r; +} +#endif + + #if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_COLORSPACE_SUPPORTED) ||\ defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED) /* muldiv functions */ diff --git a/contrib/libs/libpng/png.h b/contrib/libs/libpng/png.h index 41e823bde5..0723af3f23 100644 --- a/contrib/libs/libpng/png.h +++ b/contrib/libs/libpng/png.h @@ -1,6 +1,6 @@ /* png.h - header file for PNG reference library * - * libpng version 1.6.45 + * libpng version 1.6.46 * * Copyright (c) 2018-2025 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson @@ -14,7 +14,7 @@ * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger * libpng versions 0.97, January 1998, through 1.6.35, July 2018: * Glenn Randers-Pehrson - * libpng versions 1.6.36, December 2018, through 1.6.45, January 2025: + * libpng versions 1.6.36, December 2018, through 1.6.46, January 2025: * Cosmin Truta * See also "Contributing Authors", below. */ @@ -244,7 +244,7 @@ * ... * 1.5.30 15 10530 15.so.15.30[.0] * ... - * 1.6.45 16 10645 16.so.16.45[.0] + * 1.6.46 16 10646 16.so.16.46[.0] * * Henceforth the source version will match the shared-library major and * minor numbers; the shared-library major version number will be used for @@ -280,7 +280,7 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.6.45" +#define PNG_LIBPNG_VER_STRING "1.6.46" #define PNG_HEADER_VERSION_STRING " libpng version " PNG_LIBPNG_VER_STRING "\n" /* The versions of shared library builds should stay in sync, going forward */ @@ -291,7 +291,7 @@ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MINOR 6 -#define PNG_LIBPNG_VER_RELEASE 45 +#define PNG_LIBPNG_VER_RELEASE 46 /* This should be zero for a public release, or non-zero for a * development version. @@ -322,7 +322,7 @@ * From version 1.0.1 it is: * XXYYZZ, where XX=major, YY=minor, ZZ=release */ -#define PNG_LIBPNG_VER 10645 /* 1.6.45 */ +#define PNG_LIBPNG_VER 10646 /* 1.6.46 */ /* Library configuration: these options cannot be changed after * the library has been built. @@ -447,7 +447,7 @@ extern "C" { /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -typedef char* png_libpng_version_1_6_45; +typedef char* png_libpng_version_1_6_46; /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. * @@ -765,11 +765,21 @@ typedef png_unknown_chunk * * png_unknown_chunkpp; #define PNG_INFO_sCAL 0x4000U /* ESR, 1.0.6 */ #define PNG_INFO_IDAT 0x8000U /* ESR, 1.0.6 */ #define PNG_INFO_eXIf 0x10000U /* GR-P, 1.6.31 */ -#define PNG_INFO_cICP 0x20000U -#ifdef PNG_APNG_SUPPORTED -#define PNG_INFO_acTL 0x40000U -#define PNG_INFO_fcTL 0x80000U -#endif +#define PNG_INFO_cICP 0x20000U /* PNGv3: 1.6.45 */ +#define PNG_INFO_cLLI 0x40000U /* PNGv3: 1.6.45 */ +#define PNG_INFO_mDCV 0x80000U /* PNGv3: 1.6.45 */ +/* APNG: these chunks are stored as unknown, these flags are never set + * however they are provided as a convenience for implementors of APNG and + * avoids any merge conflicts. + * + * Private chunks: these chunk names violate the chunk name recommendations + * because the chunk definitions have no signature and because the private + * chunks with these names have been reserved. Private definitions should + * avoid them. + */ +#define PNG_INFO_acTL 0x100000U /* PNGv3: 1.6.45: unknown */ +#define PNG_INFO_fcTL 0x200000U /* PNGv3: 1.6.45: unknown */ +#define PNG_INFO_fdAT 0x400000U /* PNGv3: 1.6.45: unknown */ /* This is used for the transformation routines, as some of them * change these values for the row. It also should enable using @@ -2005,15 +2015,44 @@ PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr, #ifdef PNG_cICP_SUPPORTED PNG_EXPORT(250, png_uint_32, png_get_cICP, (png_const_structrp png_ptr, - png_inforp info_ptr, png_bytep colour_primaries, + png_const_inforp info_ptr, png_bytep colour_primaries, png_bytep transfer_function, png_bytep matrix_coefficients, png_bytep video_full_range_flag)); +#endif + +#ifdef PNG_cICP_SUPPORTED PNG_EXPORT(251, void, png_set_cICP, (png_const_structrp png_ptr, png_inforp info_ptr, png_byte colour_primaries, png_byte transfer_function, png_byte matrix_coefficients, png_byte video_full_range_flag)); #endif +#ifdef PNG_cLLI_SUPPORTED +PNG_FP_EXPORT(252, png_uint_32, png_get_cLLI, (png_const_structrp png_ptr, + png_const_inforp info_ptr, double *maximum_content_light_level, + double *maximum_frame_average_light_level)) +PNG_FIXED_EXPORT(253, png_uint_32, png_get_cLLI_fixed, + (png_const_structrp png_ptr, png_const_inforp info_ptr, + /* The values below are in cd/m2 (nits) and are scaled by 10,000; not + * 100,000 as in the case of png_fixed_point. + */ + png_uint_32p maximum_content_light_level_scaled_by_10000, + png_uint_32p maximum_frame_average_light_level_scaled_by_10000)) +#endif + +#ifdef PNG_cLLI_SUPPORTED +PNG_FP_EXPORT(254, void, png_set_cLLI, (png_const_structrp png_ptr, + png_inforp info_ptr, double maximum_content_light_level, + double maximum_frame_average_light_level)) +PNG_FIXED_EXPORT(255, void, png_set_cLLI_fixed, (png_const_structrp png_ptr, + png_inforp info_ptr, + /* The values below are in cd/m2 (nits) and are scaled by 10,000; not + * 100,000 as in the case of png_fixed_point. + */ + png_uint_32 maximum_content_light_level_scaled_by_10000, + png_uint_32 maximum_frame_average_light_level_scaled_by_10000)) +#endif + #ifdef PNG_eXIf_SUPPORTED PNG_EXPORT(246, png_uint_32, png_get_eXIf, (png_const_structrp png_ptr, png_inforp info_ptr, png_bytep *exif)); @@ -2058,6 +2097,60 @@ PNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr, int color_type, int interlace_method, int compression_method, int filter_method)); +#ifdef PNG_mDCV_SUPPORTED +PNG_FP_EXPORT(256, png_uint_32, png_get_mDCV, (png_const_structrp png_ptr, + png_const_inforp info_ptr, + /* The chromaticities of the mastering display. As cHRM, but independent of + * the encoding endpoints in cHRM, or cICP, or iCCP. These values will + * always be in the range 0 to 1.3107. + */ + double *white_x, double *white_y, double *red_x, double *red_y, + double *green_x, double *green_y, double *blue_x, double *blue_y, + /* Mastering display luminance in cd/m2 (nits). */ + double *mastering_display_maximum_luminance, + double *mastering_display_minimum_luminance)) + +PNG_FIXED_EXPORT(257, png_uint_32, png_get_mDCV_fixed, + (png_const_structrp png_ptr, png_const_inforp info_ptr, + png_fixed_point *int_white_x, png_fixed_point *int_white_y, + png_fixed_point *int_red_x, png_fixed_point *int_red_y, + png_fixed_point *int_green_x, png_fixed_point *int_green_y, + png_fixed_point *int_blue_x, png_fixed_point *int_blue_y, + /* Mastering display luminance in cd/m2 (nits) multiplied (scaled) by + * 10,000. + */ + png_uint_32p mastering_display_maximum_luminance_scaled_by_10000, + png_uint_32p mastering_display_minimum_luminance_scaled_by_10000)) +#endif + +#ifdef PNG_mDCV_SUPPORTED +PNG_FP_EXPORT(258, void, png_set_mDCV, (png_const_structrp png_ptr, + png_inforp info_ptr, + /* The chromaticities of the mastering display. As cHRM, but independent of + * the encoding endpoints in cHRM, or cICP, or iCCP. + */ + double white_x, double white_y, double red_x, double red_y, double green_x, + double green_y, double blue_x, double blue_y, + /* Mastering display luminance in cd/m2 (nits). */ + double mastering_display_maximum_luminance, + double mastering_display_minimum_luminance)) + +PNG_FIXED_EXPORT(259, void, png_set_mDCV_fixed, (png_const_structrp png_ptr, + png_inforp info_ptr, + /* The admissible range of these values is not the full range of a PNG + * fixed point value. Negative values cannot be encoded and the maximum + * value is about 1.3 */ + png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, + png_fixed_point int_green_x, png_fixed_point int_green_y, + png_fixed_point int_blue_x, png_fixed_point int_blue_y, + /* These are PNG unsigned 4 byte values: 31-bit unsigned values. The MSB + * must be zero. + */ + png_uint_32 mastering_display_maximum_luminance_scaled_by_10000, + png_uint_32 mastering_display_minimum_luminance_scaled_by_10000)) +#endif + #ifdef PNG_oFFs_SUPPORTED PNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr, png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, @@ -3271,70 +3364,70 @@ PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option, ******************************************************************************/ #ifdef PNG_APNG_SUPPORTED -PNG_EXPORT(252, png_uint_32, png_get_acTL, (png_structp png_ptr, +PNG_EXPORT(260, png_uint_32, png_get_acTL, (png_structp png_ptr, png_infop info_ptr, png_uint_32 *num_frames, png_uint_32 *num_plays)); -PNG_EXPORT(253, png_uint_32, png_set_acTL, (png_structp png_ptr, +PNG_EXPORT(261, png_uint_32, png_set_acTL, (png_structp png_ptr, png_infop info_ptr, png_uint_32 num_frames, png_uint_32 num_plays)); -PNG_EXPORT(254, png_uint_32, png_get_num_frames, (png_structp png_ptr, +PNG_EXPORT(262, png_uint_32, png_get_num_frames, (png_structp png_ptr, png_infop info_ptr)); -PNG_EXPORT(255, png_uint_32, png_get_num_plays, (png_structp png_ptr, +PNG_EXPORT(263, png_uint_32, png_get_num_plays, (png_structp png_ptr, png_infop info_ptr)); -PNG_EXPORT(256, png_uint_32, png_get_next_frame_fcTL, +PNG_EXPORT(264, png_uint_32, png_get_next_frame_fcTL, (png_structp png_ptr, png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, png_uint_32 *x_offset, png_uint_32 *y_offset, png_uint_16 *delay_num, png_uint_16 *delay_den, png_byte *dispose_op, png_byte *blend_op)); -PNG_EXPORT(257, png_uint_32, png_set_next_frame_fcTL, +PNG_EXPORT(265, png_uint_32, png_set_next_frame_fcTL, (png_structp png_ptr, png_infop info_ptr, png_uint_32 width, png_uint_32 height, png_uint_32 x_offset, png_uint_32 y_offset, png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op, png_byte blend_op)); -PNG_EXPORT(258, png_uint_32, png_get_next_frame_width, +PNG_EXPORT(266, png_uint_32, png_get_next_frame_width, (png_structp png_ptr, png_infop info_ptr)); -PNG_EXPORT(259, png_uint_32, png_get_next_frame_height, +PNG_EXPORT(267, png_uint_32, png_get_next_frame_height, (png_structp png_ptr, png_infop info_ptr)); -PNG_EXPORT(260, png_uint_32, png_get_next_frame_x_offset, +PNG_EXPORT(268, png_uint_32, png_get_next_frame_x_offset, (png_structp png_ptr, png_infop info_ptr)); -PNG_EXPORT(261, png_uint_32, png_get_next_frame_y_offset, +PNG_EXPORT(269, png_uint_32, png_get_next_frame_y_offset, (png_structp png_ptr, png_infop info_ptr)); -PNG_EXPORT(262, png_uint_16, png_get_next_frame_delay_num, +PNG_EXPORT(270, png_uint_16, png_get_next_frame_delay_num, (png_structp png_ptr, png_infop info_ptr)); -PNG_EXPORT(263, png_uint_16, png_get_next_frame_delay_den, +PNG_EXPORT(271, png_uint_16, png_get_next_frame_delay_den, (png_structp png_ptr, png_infop info_ptr)); -PNG_EXPORT(264, png_byte, png_get_next_frame_dispose_op, +PNG_EXPORT(272, png_byte, png_get_next_frame_dispose_op, (png_structp png_ptr, png_infop info_ptr)); -PNG_EXPORT(265, png_byte, png_get_next_frame_blend_op, +PNG_EXPORT(273, png_byte, png_get_next_frame_blend_op, (png_structp png_ptr, png_infop info_ptr)); -PNG_EXPORT(266, png_byte, png_get_first_frame_is_hidden, +PNG_EXPORT(274, png_byte, png_get_first_frame_is_hidden, (png_structp png_ptr, png_infop info_ptr)); -PNG_EXPORT(267, png_uint_32, png_set_first_frame_is_hidden, +PNG_EXPORT(275, png_uint_32, png_set_first_frame_is_hidden, (png_structp png_ptr, png_infop info_ptr, png_byte is_hidden)); #ifdef PNG_READ_APNG_SUPPORTED -PNG_EXPORT(268, void, png_read_frame_head, (png_structp png_ptr, +PNG_EXPORT(276, void, png_read_frame_head, (png_structp png_ptr, png_infop info_ptr)); #ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_EXPORT(269, void, png_set_progressive_frame_fn, (png_structp png_ptr, +PNG_EXPORT(277, void, png_set_progressive_frame_fn, (png_structp png_ptr, png_progressive_frame_ptr frame_info_fn, png_progressive_frame_ptr frame_end_fn)); #endif /* PROGRESSIVE_READ */ #endif /* READ_APNG */ #ifdef PNG_WRITE_APNG_SUPPORTED -PNG_EXPORT(270, void, png_write_frame_head, (png_structp png_ptr, +PNG_EXPORT(278, void, png_write_frame_head, (png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers, png_uint_32 width, png_uint_32 height, png_uint_32 x_offset, png_uint_32 y_offset, png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op, png_byte blend_op)); -PNG_EXPORT(271, void, png_write_frame_tail, (png_structp png_ptr, +PNG_EXPORT(279, void, png_write_frame_tail, (png_structp png_ptr, png_infop info_ptr)); #endif /* WRITE_APNG */ #endif /* APNG */ @@ -3348,9 +3441,9 @@ PNG_EXPORT(271, void, png_write_frame_tail, (png_structp png_ptr, */ #ifdef PNG_EXPORT_LAST_ORDINAL #ifdef PNG_APNG_SUPPORTED - PNG_EXPORT_LAST_ORDINAL(271); + PNG_EXPORT_LAST_ORDINAL(279); #else - PNG_EXPORT_LAST_ORDINAL(251); + PNG_EXPORT_LAST_ORDINAL(259); #endif /* APNG */ #endif diff --git a/contrib/libs/libpng/pngconf.h b/contrib/libs/libpng/pngconf.h index 11a40b8d81..6bc46bcfc9 100644 --- a/contrib/libs/libpng/pngconf.h +++ b/contrib/libs/libpng/pngconf.h @@ -1,6 +1,6 @@ /* pngconf.h - machine-configurable file for libpng * - * libpng version 1.6.45 + * libpng version 1.6.46 * * Copyright (c) 2018-2025 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson diff --git a/contrib/libs/libpng/pngget.c b/contrib/libs/libpng/pngget.c index 5f668283d0..ee430a3643 100644 --- a/contrib/libs/libpng/pngget.c +++ b/contrib/libs/libpng/pngget.c @@ -787,7 +787,7 @@ png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr, #ifdef PNG_cICP_SUPPORTED png_uint_32 PNGAPI png_get_cICP(png_const_structrp png_ptr, - png_inforp info_ptr, png_bytep colour_primaries, + png_const_inforp info_ptr, png_bytep colour_primaries, png_bytep transfer_function, png_bytep matrix_coefficients, png_bytep video_full_range_flag) { @@ -805,10 +805,115 @@ png_get_cICP(png_const_structrp png_ptr, return (PNG_INFO_cICP); } - return (0); + return 0; } #endif +#ifdef PNG_cLLI_SUPPORTED +# ifdef PNG_FIXED_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_cLLI_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_uint_32p maxCLL, + png_uint_32p maxFALL) +{ + png_debug1(1, "in %s retrieval function", "cLLI"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_cLLI) != 0) + { + if (maxCLL != NULL) *maxCLL = info_ptr->maxCLL; + if (maxFALL != NULL) *maxFALL = info_ptr->maxFALL; + return PNG_INFO_cLLI; + } + + return 0; +} +# endif + +# ifdef PNG_FLOATING_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_cLLI(png_const_structrp png_ptr, png_const_inforp info_ptr, + double *maxCLL, double *maxFALL) +{ + png_debug1(1, "in %s retrieval function", "cLLI(float)"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_cLLI) != 0) + { + if (maxCLL != NULL) *maxCLL = info_ptr->maxCLL * .0001; + if (maxFALL != NULL) *maxFALL = info_ptr->maxFALL * .0001; + return PNG_INFO_cLLI; + } + + return 0; +} +# endif +#endif /* cLLI */ + +#ifdef PNG_mDCV_SUPPORTED +# ifdef PNG_FIXED_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_mDCV_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, + png_fixed_point *white_x, png_fixed_point *white_y, + png_fixed_point *red_x, png_fixed_point *red_y, + png_fixed_point *green_x, png_fixed_point *green_y, + png_fixed_point *blue_x, png_fixed_point *blue_y, + png_uint_32p mastering_maxDL, png_uint_32p mastering_minDL) +{ + png_debug1(1, "in %s retrieval function", "mDCV"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_mDCV) != 0) + { + if (white_x != NULL) *white_x = info_ptr->mastering_white_x * 2; + if (white_y != NULL) *white_y = info_ptr->mastering_white_y * 2; + if (red_x != NULL) *red_x = info_ptr->mastering_red_x * 2; + if (red_y != NULL) *red_y = info_ptr->mastering_red_y * 2; + if (green_x != NULL) *green_x = info_ptr->mastering_green_x * 2; + if (green_y != NULL) *green_y = info_ptr->mastering_green_y * 2; + if (blue_x != NULL) *blue_x = info_ptr->mastering_blue_x * 2; + if (blue_y != NULL) *blue_y = info_ptr->mastering_blue_y * 2; + if (mastering_maxDL != NULL) *mastering_maxDL = info_ptr->mastering_maxDL; + if (mastering_minDL != NULL) *mastering_minDL = info_ptr->mastering_minDL; + return PNG_INFO_mDCV; + } + + return 0; +} +# endif + +# ifdef PNG_FLOATING_POINT_SUPPORTED +png_uint_32 PNGAPI +png_get_mDCV(png_const_structrp png_ptr, png_const_inforp info_ptr, + double *white_x, double *white_y, double *red_x, double *red_y, + double *green_x, double *green_y, double *blue_x, double *blue_y, + double *mastering_maxDL, double *mastering_minDL) +{ + png_debug1(1, "in %s retrieval function", "mDCV(float)"); + + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_mDCV) != 0) + { + if (white_x != NULL) *white_x = info_ptr->mastering_white_x * .00002; + if (white_y != NULL) *white_y = info_ptr->mastering_white_y * .00002; + if (red_x != NULL) *red_x = info_ptr->mastering_red_x * .00002; + if (red_y != NULL) *red_y = info_ptr->mastering_red_y * .00002; + if (green_x != NULL) *green_x = info_ptr->mastering_green_x * .00002; + if (green_y != NULL) *green_y = info_ptr->mastering_green_y * .00002; + if (blue_x != NULL) *blue_x = info_ptr->mastering_blue_x * .00002; + if (blue_y != NULL) *blue_y = info_ptr->mastering_blue_y * .00002; + if (mastering_maxDL != NULL) + *mastering_maxDL = info_ptr->mastering_maxDL * .0001; + if (mastering_minDL != NULL) + *mastering_minDL = info_ptr->mastering_minDL * .0001; + return PNG_INFO_mDCV; + } + + return 0; +} +# endif /* FLOATING_POINT */ +#endif /* mDCV */ + #ifdef PNG_eXIf_SUPPORTED png_uint_32 PNGAPI png_get_eXIf(png_const_structrp png_ptr, png_inforp info_ptr, diff --git a/contrib/libs/libpng/pnginfo.h b/contrib/libs/libpng/pnginfo.h index 8249270873..642f79070a 100644 --- a/contrib/libs/libpng/pnginfo.h +++ b/contrib/libs/libpng/pnginfo.h @@ -115,6 +115,24 @@ struct png_info_def png_uint_32 iccp_proflen; /* ICC profile data length */ #endif +#ifdef PNG_cLLI_SUPPORTED + png_uint_32 maxCLL; /* cd/m2 (nits) * 10,000 */ + png_uint_32 maxFALL; +#endif + +#ifdef PNG_mDCV_SUPPORTED + png_uint_16 mastering_red_x; /* CIE (xy) x * 50,000 */ + png_uint_16 mastering_red_y; + png_uint_16 mastering_green_x; + png_uint_16 mastering_green_y; + png_uint_16 mastering_blue_x; + png_uint_16 mastering_blue_y; + png_uint_16 mastering_white_x; + png_uint_16 mastering_white_y; + png_uint_32 mastering_maxDL; /* cd/m2 (nits) * 10,000 */ + png_uint_32 mastering_minDL; +#endif + #ifdef PNG_TEXT_SUPPORTED /* The tEXt, and zTXt chunks contain human-readable textual data in * uncompressed, compressed, and optionally compressed forms, respectively. diff --git a/contrib/libs/libpng/pnglibconf.h b/contrib/libs/libpng/pnglibconf.h index dbf04d03a2..a8fb51d5c0 100644 --- a/contrib/libs/libpng/pnglibconf.h +++ b/contrib/libs/libpng/pnglibconf.h @@ -1,6 +1,6 @@ /* pnglibconf.h - library build configuration */ -/* libpng version 1.6.45 */ +/* libpng version 1.6.46 */ /* Copyright (c) 2018-2025 Cosmin Truta */ /* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */ @@ -89,11 +89,13 @@ #define PNG_READ_bKGD_SUPPORTED #define PNG_READ_cHRM_SUPPORTED #define PNG_READ_cICP_SUPPORTED +#define PNG_READ_cLLI_SUPPORTED #define PNG_READ_eXIf_SUPPORTED #define PNG_READ_gAMA_SUPPORTED #define PNG_READ_hIST_SUPPORTED #define PNG_READ_iCCP_SUPPORTED #define PNG_READ_iTXt_SUPPORTED +#define PNG_READ_mDCV_SUPPORTED #define PNG_READ_oFFs_SUPPORTED #define PNG_READ_pCAL_SUPPORTED #define PNG_READ_pHYs_SUPPORTED @@ -160,11 +162,13 @@ #define PNG_WRITE_bKGD_SUPPORTED #define PNG_WRITE_cHRM_SUPPORTED #define PNG_WRITE_cICP_SUPPORTED +#define PNG_WRITE_cLLI_SUPPORTED #define PNG_WRITE_eXIf_SUPPORTED #define PNG_WRITE_gAMA_SUPPORTED #define PNG_WRITE_hIST_SUPPORTED #define PNG_WRITE_iCCP_SUPPORTED #define PNG_WRITE_iTXt_SUPPORTED +#define PNG_WRITE_mDCV_SUPPORTED #define PNG_WRITE_oFFs_SUPPORTED #define PNG_WRITE_pCAL_SUPPORTED #define PNG_WRITE_pHYs_SUPPORTED @@ -179,11 +183,13 @@ #define PNG_bKGD_SUPPORTED #define PNG_cHRM_SUPPORTED #define PNG_cICP_SUPPORTED +#define PNG_cLLI_SUPPORTED #define PNG_eXIf_SUPPORTED #define PNG_gAMA_SUPPORTED #define PNG_hIST_SUPPORTED #define PNG_iCCP_SUPPORTED #define PNG_iTXt_SUPPORTED +#define PNG_mDCV_SUPPORTED #define PNG_oFFs_SUPPORTED #define PNG_pCAL_SUPPORTED #define PNG_pHYs_SUPPORTED diff --git a/contrib/libs/libpng/pngpread.c b/contrib/libs/libpng/pngpread.c index ff08dcbb2e..fa0ccda99b 100644 --- a/contrib/libs/libpng/pngpread.c +++ b/contrib/libs/libpng/pngpread.c @@ -403,6 +403,22 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) } #endif +#ifdef PNG_READ_cLLI_SUPPORTED + else if (png_ptr->chunk_name == png_cLLI) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_cLLI(png_ptr, info_ptr, png_ptr->push_length); + } + +#endif +#ifdef PNG_READ_mDCV_SUPPORTED + else if (png_ptr->chunk_name == png_mDCV) + { + PNG_PUSH_SAVE_BUFFER_IF_FULL + png_handle_mDCV(png_ptr, info_ptr, png_ptr->push_length); + } + +#endif #ifdef PNG_READ_eXIf_SUPPORTED else if (png_ptr->chunk_name == png_eXIf) { diff --git a/contrib/libs/libpng/pngpriv.h b/contrib/libs/libpng/pngpriv.h index 60a3a060d4..a74e0cecae 100644 --- a/contrib/libs/libpng/pngpriv.h +++ b/contrib/libs/libpng/pngpriv.h @@ -786,6 +786,8 @@ #ifdef PNG_FIXED_POINT_MACRO_SUPPORTED #define png_fixed(png_ptr, fp, s) ((fp) <= 21474 && (fp) >= -21474 ?\ ((png_fixed_point)(100000 * (fp))) : (png_fixed_error(png_ptr, s),0)) +#define png_fixed_ITU(png_ptr, fp, s) ((fp) <= 214748 && (fp) >= 0 ?\ + ((png_uint_32)(10000 * (fp))) : (png_fixed_error(png_ptr, s),0)) #endif /* else the corresponding function is defined below, inside the scope of the * cplusplus test. @@ -838,7 +840,8 @@ #define png_PLTE PNG_U32( 80, 76, 84, 69) #define png_bKGD PNG_U32( 98, 75, 71, 68) #define png_cHRM PNG_U32( 99, 72, 82, 77) -#define png_cICP PNG_U32( 99, 73, 67, 80) +#define png_cICP PNG_U32( 99, 73, 67, 80) /* PNGv3 */ +#define png_cLLI PNG_U32( 99, 76, 76, 73) /* PNGv3 */ #define png_eXIf PNG_U32(101, 88, 73, 102) /* registered July 2017 */ #define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */ #define png_gAMA PNG_U32(103, 65, 77, 65) @@ -848,6 +851,7 @@ #define png_hIST PNG_U32(104, 73, 83, 84) #define png_iCCP PNG_U32(105, 67, 67, 80) #define png_iTXt PNG_U32(105, 84, 88, 116) +#define png_mDCV PNG_U32(109, 68, 67, 86) /* PNGv3 */ #define png_oFFs PNG_U32(111, 70, 70, 115) #define png_pCAL PNG_U32(112, 67, 65, 76) #define png_pHYs PNG_U32(112, 72, 89, 115) @@ -985,6 +989,7 @@ PNG_INTERNAL_FUNCTION(void,png_free_buffer_list,(png_structrp png_ptr, !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \ (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \ defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \ + defined(PNG_mDCV_SUPPORTED) || \ defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \ (defined(PNG_sCAL_SUPPORTED) && \ defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)) @@ -992,6 +997,13 @@ PNG_INTERNAL_FUNCTION(png_fixed_point,png_fixed,(png_const_structrp png_ptr, double fp, png_const_charp text),PNG_EMPTY); #endif +#if defined(PNG_FLOATING_POINT_SUPPORTED) && \ + !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \ + (defined(PNG_cLLI_SUPPORTED) || defined(PNG_mDCV_SUPPORTED)) +PNG_INTERNAL_FUNCTION(png_uint_32,png_fixed_ITU,(png_const_structrp png_ptr, + double fp, png_const_charp text),PNG_EMPTY); +#endif + /* Check the user version string for compatibility, returns false if the version * numbers aren't compatible. */ @@ -1151,6 +1163,20 @@ PNG_INTERNAL_FUNCTION(void,png_write_cICP,(png_structrp png_ptr, png_byte matrix_coefficients, png_byte video_full_range_flag), PNG_EMPTY); #endif +#ifdef PNG_WRITE_cLLI_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_cLLI_fixed,(png_structrp png_ptr, + png_uint_32 maxCLL, png_uint_32 maxFALL), PNG_EMPTY); +#endif + +#ifdef PNG_WRITE_mDCV_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_write_mDCV_fixed,(png_structrp png_ptr, + png_uint_16 red_x, png_uint_16 red_y, + png_uint_16 green_x, png_uint_16 green_y, + png_uint_16 blue_x, png_uint_16 blue_y, + png_uint_16 white_x, png_uint_16 white_y, + png_uint_32 maxDL, png_uint_32 minDL), PNG_EMPTY); +#endif + #ifdef PNG_WRITE_sRGB_SUPPORTED PNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr, int intent),PNG_EMPTY); @@ -1499,6 +1525,11 @@ PNG_INTERNAL_FUNCTION(void,png_handle_cICP,(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); #endif +#ifdef PNG_READ_cLLI_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_cLLI,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + #ifdef PNG_READ_eXIf_SUPPORTED PNG_INTERNAL_FUNCTION(void,png_handle_eXIf,(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); @@ -1524,6 +1555,11 @@ PNG_INTERNAL_FUNCTION(void,png_handle_iTXt,(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); #endif +#ifdef PNG_READ_mDCV_SUPPORTED +PNG_INTERNAL_FUNCTION(void,png_handle_mDCV,(png_structrp png_ptr, + png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); +#endif + #ifdef PNG_READ_oFFs_SUPPORTED PNG_INTERNAL_FUNCTION(void,png_handle_oFFs,(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); diff --git a/contrib/libs/libpng/pngread.c b/contrib/libs/libpng/pngread.c index 4fb4009117..4fc80c73b2 100644 --- a/contrib/libs/libpng/pngread.c +++ b/contrib/libs/libpng/pngread.c @@ -182,6 +182,11 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr) png_handle_cICP(png_ptr, info_ptr, length); #endif +#ifdef PNG_READ_cLLI_SUPPORTED + else if (chunk_name == png_cLLI) + png_handle_cLLI(png_ptr, info_ptr, length); +#endif + #ifdef PNG_READ_eXIf_SUPPORTED else if (chunk_name == png_eXIf) png_handle_eXIf(png_ptr, info_ptr, length); @@ -197,6 +202,11 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr) png_handle_hIST(png_ptr, info_ptr, length); #endif +#ifdef PNG_READ_mDCV_SUPPORTED + else if (chunk_name == png_mDCV) + png_handle_mDCV(png_ptr, info_ptr, length); +#endif + #ifdef PNG_READ_oFFs_SUPPORTED else if (chunk_name == png_oFFs) png_handle_oFFs(png_ptr, info_ptr, length); @@ -941,6 +951,11 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) png_handle_cICP(png_ptr, info_ptr, length); #endif +#ifdef PNG_READ_cLLI_SUPPORTED + else if (chunk_name == png_cLLI) + png_handle_cLLI(png_ptr, info_ptr, length); +#endif + #ifdef PNG_READ_eXIf_SUPPORTED else if (chunk_name == png_eXIf) png_handle_eXIf(png_ptr, info_ptr, length); @@ -956,6 +971,11 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) png_handle_hIST(png_ptr, info_ptr, length); #endif +#ifdef PNG_READ_mDCV_SUPPORTED + else if (chunk_name == png_mDCV) + png_handle_mDCV(png_ptr, info_ptr, length); +#endif + #ifdef PNG_READ_oFFs_SUPPORTED else if (chunk_name == png_oFFs) png_handle_oFFs(png_ptr, info_ptr, length); diff --git a/contrib/libs/libpng/pngrutil.c b/contrib/libs/libpng/pngrutil.c index c1cc4b2533..f01c294963 100644 --- a/contrib/libs/libpng/pngrutil.c +++ b/contrib/libs/libpng/pngrutil.c @@ -2092,6 +2092,111 @@ png_handle_cICP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) } #endif +#ifdef PNG_READ_cLLI_SUPPORTED +void /* PRIVATE */ +png_handle_cLLI(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_byte buf[8]; + + png_debug(1, "in png_handle_cLLI"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } + + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cLLI) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); + return; + } + + else if (length != 8) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); + return; + } + + png_crc_read(png_ptr, buf, 8); + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + /* The error checking happens here, this puts it in just one place: */ + png_set_cLLI_fixed(png_ptr, info_ptr, png_get_uint_32(buf), + png_get_uint_32(buf+4)); +} +#endif + +#ifdef PNG_READ_mDCV_SUPPORTED +void /* PRIVATE */ +png_handle_mDCV(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) +{ + png_byte buf[24]; + + png_debug(1, "in png_handle_mDCV"); + + if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) + png_chunk_error(png_ptr, "missing IHDR"); + + else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "out of place"); + return; + } + + else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_mDCV) != 0) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "duplicate"); + return; + } + + else if (length != 24) + { + png_crc_finish(png_ptr, length); + png_chunk_benign_error(png_ptr, "invalid"); + return; + } + + png_crc_read(png_ptr, buf, 24); + + if (png_crc_finish(png_ptr, 0) != 0) + return; + + /* The error checking happens here, this puts it in just one place. The + * odd /50000 scaling factor makes it more difficult but the (x.y) values are + * only two bytes so a <<1 is safe. + * + * WARNING: the PNG specification defines the cHRM chunk to **start** with + * the white point (x,y). The W3C PNG v3 specification puts the white point + * **after* R,G,B. The x,y values in mDCV are also scaled by 50,000 and + * stored in just two bytes, whereas those in cHRM are scaled by 100,000 and + * stored in four bytes. This is very, very confusing. These APIs remove + * the confusion by copying the existing, well established, API. + */ + png_set_mDCV_fixed(png_ptr, info_ptr, + png_get_uint_16(buf+12U) << 1U, /* white x */ + png_get_uint_16(buf+14U) << 1U, /* white y */ + png_get_uint_16(buf+ 0U) << 1U, /* red x */ + png_get_uint_16(buf+ 2U) << 1U, /* red y */ + png_get_uint_16(buf+ 4U) << 1U, /* green x */ + png_get_uint_16(buf+ 6U) << 1U, /* green y */ + png_get_uint_16(buf+ 8U) << 1U, /* blue x */ + png_get_uint_16(buf+10U) << 1U, /* blue y */ + png_get_uint_32(buf+16U), /* peak luminance */ + png_get_uint_32(buf+20U));/* minimum perceivable luminance */ +} +#endif + #ifdef PNG_READ_eXIf_SUPPORTED void /* PRIVATE */ png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) diff --git a/contrib/libs/libpng/pngset.c b/contrib/libs/libpng/pngset.c index c4dfe7bbd2..b090bf71db 100644 --- a/contrib/libs/libpng/pngset.c +++ b/contrib/libs/libpng/pngset.c @@ -159,6 +159,158 @@ png_set_cICP(png_const_structrp png_ptr, png_inforp info_ptr, } #endif /* cICP */ +#ifdef PNG_cLLI_SUPPORTED +void PNGFAPI +png_set_cLLI_fixed(png_const_structrp png_ptr, png_inforp info_ptr, + /* The values below are in cd/m2 (nits) and are scaled by 10,000; not + * 100,000 as in the case of png_fixed_point. + */ + png_uint_32 maxCLL, png_uint_32 maxFALL) +{ + png_debug1(1, "in %s storage function", "cLLI"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + /* Check the light level range: */ + if (maxCLL > 0x7FFFFFFFU || maxFALL > 0x7FFFFFFFU) + { + /* The limit is 200kcd/m2; somewhat bright but not inconceivable because + * human vision is said to run up to 100Mcd/m2. The sun is about 2Gcd/m2. + * + * The reference sRGB monitor is 80cd/m2 and the limit of PQ encoding is + * 2kcd/m2. + */ + png_chunk_report(png_ptr, "cLLI light level exceeds PNG limit", + PNG_CHUNK_WRITE_ERROR); + return; + } + + info_ptr->maxCLL = maxCLL; + info_ptr->maxFALL = maxFALL; + info_ptr->valid |= PNG_INFO_cLLI; +} + +# ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_cLLI(png_const_structrp png_ptr, png_inforp info_ptr, + double maxCLL, double maxFALL) +{ + png_set_cLLI_fixed(png_ptr, info_ptr, + png_fixed_ITU(png_ptr, maxCLL, "png_set_cLLI(maxCLL)"), + png_fixed_ITU(png_ptr, maxFALL, "png_set_cLLI(maxFALL)")); +} +# endif /* FLOATING_POINT */ +#endif /* cLLI */ + +#ifdef PNG_mDCV_SUPPORTED +static png_uint_16 +png_ITU_fixed_16(png_const_structrp png_ptr, png_fixed_point v, + png_const_charp text) +{ + /* Return a safe uint16_t value scaled according to the ITU H273 rules for + * 16-bit display chromaticities. Functions like the corresponding + * png_fixed() internal function with regard to errors: it's an error on + * write, a chunk_benign_error on read: See the definition of + * png_chunk_report in pngpriv.h. + */ + v /= 2; /* rounds to 0 in C: avoids insignificant arithmetic errors */ + if (v > 65535 || v < 0) + png_fixed_error(png_ptr, text); + +# ifndef PNG_ERROR_TEXT_SUPPORTED + PNG_UNUSED(text) +# endif + + return (png_uint_16)/*SAFE*/v; +} + +void PNGAPI +png_set_mDCV_fixed(png_const_structrp png_ptr, png_inforp info_ptr, + png_fixed_point white_x, png_fixed_point white_y, + png_fixed_point red_x, png_fixed_point red_y, + png_fixed_point green_x, png_fixed_point green_y, + png_fixed_point blue_x, png_fixed_point blue_y, + png_uint_32 maxDL, + png_uint_32 minDL) +{ + png_uint_16 rx, ry, gx, gy, bx, by, wx, wy; + + png_debug1(1, "in %s storage function", "mDCV"); + + if (png_ptr == NULL || info_ptr == NULL) + return; + + /* Check the input values to ensure they are in the expected range: */ + rx = png_ITU_fixed_16(png_ptr, red_x, "png_set_mDCV(red(x))"); + ry = png_ITU_fixed_16(png_ptr, red_y, "png_set_mDCV(red(y))"); + gx = png_ITU_fixed_16(png_ptr, green_x, "png_set_mDCV(green(x))"); + gy = png_ITU_fixed_16(png_ptr, green_y, "png_set_mDCV(green(y))"); + bx = png_ITU_fixed_16(png_ptr, blue_x, "png_set_mDCV(blue(x))"); + by = png_ITU_fixed_16(png_ptr, blue_y, "png_set_mDCV(blue(y))"); + wx = png_ITU_fixed_16(png_ptr, white_x, "png_set_mDCV(white(x))"); + wy = png_ITU_fixed_16(png_ptr, white_y, "png_set_mDCV(white(y))"); + + /* Check the light level range: */ + if (maxDL > 0x7FFFFFFFU || minDL > 0x7FFFFFFFU) + { + /* The limit is 200kcd/m2; somewhat bright but not inconceivable because + * human vision is said to run up to 100Mcd/m2. The sun is about 2Gcd/m2. + * + * The reference sRGB monitor is 80cd/m2 and the limit of PQ encoding is + * 2kcd/m2. + */ + png_chunk_report(png_ptr, "mDCV display light level exceeds PNG limit", + PNG_CHUNK_WRITE_ERROR); + return; + } + + /* All values are safe, the settings are accepted. + * + * IMPLEMENTATION NOTE: in practice the values can be checked and assigned + * but the result is confusing if a writing app calls png_set_mDCV more than + * once, the second time with an invalid value. This approach is more + * obviously correct at the cost of typing and a very slight machine + * overhead. + */ + info_ptr->mastering_red_x = rx; + info_ptr->mastering_red_y = ry; + info_ptr->mastering_green_x = gx; + info_ptr->mastering_green_y = gy; + info_ptr->mastering_blue_x = bx; + info_ptr->mastering_blue_y = by; + info_ptr->mastering_white_x = wx; + info_ptr->mastering_white_y = wy; + info_ptr->mastering_maxDL = maxDL; + info_ptr->mastering_minDL = minDL; + info_ptr->valid |= PNG_INFO_mDCV; +} + +# ifdef PNG_FLOATING_POINT_SUPPORTED +void PNGAPI +png_set_mDCV(png_const_structrp png_ptr, png_inforp info_ptr, + double white_x, double white_y, double red_x, double red_y, double green_x, + double green_y, double blue_x, double blue_y, + double maxDL, double minDL) +{ + png_set_mDCV_fixed(png_ptr, info_ptr, + /* The ITU approach is to scale by 50,000, not 100,000 so just divide + * the input values by 2 and use png_fixed: + */ + png_fixed(png_ptr, white_x / 2, "png_set_mDCV(white(x))"), + png_fixed(png_ptr, white_y / 2, "png_set_mDCV(white(y))"), + png_fixed(png_ptr, red_x / 2, "png_set_mDCV(red(x))"), + png_fixed(png_ptr, red_y / 2, "png_set_mDCV(red(y))"), + png_fixed(png_ptr, green_x / 2, "png_set_mDCV(green(x))"), + png_fixed(png_ptr, green_y / 2, "png_set_mDCV(green(y))"), + png_fixed(png_ptr, blue_x / 2, "png_set_mDCV(blue(x))"), + png_fixed(png_ptr, blue_y / 2, "png_set_mDCV(blue(y))"), + png_fixed_ITU(png_ptr, maxDL, "png_set_mDCV(maxDL)"), + png_fixed_ITU(png_ptr, minDL, "png_set_mDCV(minDL)")); +} +# endif /* FLOATING_POINT */ +#endif /* mDCV */ + #ifdef PNG_eXIf_SUPPORTED void PNGAPI png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr, @@ -1566,11 +1718,13 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, 98, 75, 71, 68, '\0', /* bKGD */ 99, 72, 82, 77, '\0', /* cHRM */ 99, 73, 67, 80, '\0', /* cICP */ + 99, 76, 76, 73, '\0', /* cLLI */ 101, 88, 73, 102, '\0', /* eXIf */ 103, 65, 77, 65, '\0', /* gAMA */ 104, 73, 83, 84, '\0', /* hIST */ 105, 67, 67, 80, '\0', /* iCCP */ 105, 84, 88, 116, '\0', /* iTXt */ + 109, 68, 67, 86, '\0', /* mDCV */ 111, 70, 70, 115, '\0', /* oFFs */ 112, 67, 65, 76, '\0', /* pCAL */ 112, 72, 89, 115, '\0', /* pHYs */ diff --git a/contrib/libs/libpng/pngwrite.c b/contrib/libs/libpng/pngwrite.c index a9788a3902..c78d3d8fad 100644 --- a/contrib/libs/libpng/pngwrite.c +++ b/contrib/libs/libpng/pngwrite.c @@ -161,7 +161,30 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr) * space priority. As above it therefore behooves libpng to write the colour * space chunks in the priority order so that a streaming app need not buffer * them. + * + * PNG v3: Chunks mDCV and cLLI provide ancillary information for the + * interpretation of the colourspace chunkgs but do not require support for + * those chunks so are outside the "COLORSPACE" check but before the write of + * the colourspace chunks themselves. */ +#ifdef PNG_WRITE_cLLI_SUPPORTED + if ((info_ptr->valid & PNG_INFO_cLLI) != 0) + { + png_write_cLLI_fixed(png_ptr, info_ptr->maxCLL, info_ptr->maxFALL); + } +#endif +#ifdef PNG_WRITE_mDCV_SUPPORTED + if ((info_ptr->valid & PNG_INFO_mDCV) != 0) + { + png_write_mDCV_fixed(png_ptr, + info_ptr->mastering_red_x, info_ptr->mastering_red_y, + info_ptr->mastering_green_x, info_ptr->mastering_green_y, + info_ptr->mastering_blue_x, info_ptr->mastering_blue_y, + info_ptr->mastering_white_x, info_ptr->mastering_white_y, + info_ptr->mastering_maxDL, info_ptr->mastering_minDL); + } +#endif + #ifdef PNG_COLORSPACE_SUPPORTED # ifdef PNG_WRITE_cICP_SUPPORTED /* Priority 4 */ if ((info_ptr->valid & PNG_INFO_cICP) != 0) diff --git a/contrib/libs/libpng/pngwutil.c b/contrib/libs/libpng/pngwutil.c index e3db91bab4..4e82c12d9a 100644 --- a/contrib/libs/libpng/pngwutil.c +++ b/contrib/libs/libpng/pngwutil.c @@ -1536,6 +1536,50 @@ png_write_cICP(png_structrp png_ptr, } #endif +#ifdef PNG_WRITE_cLLI_SUPPORTED +void /* PRIVATE */ +png_write_cLLI_fixed(png_structrp png_ptr, png_uint_32 maxCLL, + png_uint_32 maxFALL) +{ + png_byte buf[8]; + + png_debug(1, "in png_write_cLLI_fixed"); + + png_save_uint_32(buf, maxCLL); + png_save_uint_32(buf + 4, maxFALL); + + png_write_complete_chunk(png_ptr, png_cLLI, buf, 8); +} +#endif + +#ifdef PNG_WRITE_mDCV_SUPPORTED +void /* PRIVATE */ +png_write_mDCV_fixed(png_structrp png_ptr, + png_uint_16 red_x, png_uint_16 red_y, + png_uint_16 green_x, png_uint_16 green_y, + png_uint_16 blue_x, png_uint_16 blue_y, + png_uint_16 white_x, png_uint_16 white_y, + png_uint_32 maxDL, png_uint_32 minDL) +{ + png_byte buf[24]; + + png_debug(1, "in png_write_mDCV_fixed"); + + png_save_uint_16(buf + 0, red_x); + png_save_uint_16(buf + 2, red_y); + png_save_uint_16(buf + 4, green_x); + png_save_uint_16(buf + 6, green_y); + png_save_uint_16(buf + 8, blue_x); + png_save_uint_16(buf + 10, blue_y); + png_save_uint_16(buf + 12, white_x); + png_save_uint_16(buf + 14, white_y); + png_save_uint_32(buf + 16, maxDL); + png_save_uint_32(buf + 20, minDL); + + png_write_complete_chunk(png_ptr, png_mDCV, buf, 24); +} +#endif + #ifdef PNG_WRITE_eXIf_SUPPORTED /* Write the Exif data */ void /* PRIVATE */ diff --git a/contrib/libs/libpng/ya.make b/contrib/libs/libpng/ya.make index 25b40692aa..c9fede46ba 100644 --- a/contrib/libs/libpng/ya.make +++ b/contrib/libs/libpng/ya.make @@ -10,9 +10,9 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(1.6.45) +VERSION(1.6.46) -ORIGINAL_SOURCE(https://github.com/pnggroup/libpng/archive/v1.6.45.tar.gz) +ORIGINAL_SOURCE(https://github.com/pnggroup/libpng/archive/v1.6.46.tar.gz) PEERDIR( contrib/libs/zlib diff --git a/contrib/libs/lzma/.yandex_meta/override.nix b/contrib/libs/lzma/.yandex_meta/override.nix index a0b15f6179..32dfe8f429 100644 --- a/contrib/libs/lzma/.yandex_meta/override.nix +++ b/contrib/libs/lzma/.yandex_meta/override.nix @@ -1,11 +1,11 @@ pkgs: attrs: with pkgs; with attrs; rec { - version = "5.6.3"; + version = "5.6.4"; src = fetchFromGitHub { owner = "tukaani-project"; repo = "xz"; rev = "v${version}"; - hash = "sha256-2bxTxgDGlA0zPlfFs69bkuBGL44Se1ktSZCJ1Pt75I0="; + hash = "sha256-Xp1uLtQIoOG/qVLpq5D/KFmTOJ0+mNkNclyuJsvlUbE="; }; nativeBuildInputs = [ autoreconfHook ]; diff --git a/contrib/libs/lzma/NEWS b/contrib/libs/lzma/NEWS index 478b24b26e..f260a332f7 100644 --- a/contrib/libs/lzma/NEWS +++ b/contrib/libs/lzma/NEWS @@ -2,10 +2,56 @@ XZ Utils Release Notes ====================== +5.6.4 (2025-01-23) + + * liblzma: Fix LZMA/LZMA2 encoder on big endian ARM64. + + * xz: + + - Fix --filters= and --filters1= ... --filters9= options + parsing. They require an argument, thus "xz --filters lzma2" + should work in addition to "xz --filters=lzma2". + + - On the man page, note in the --compress and --decompress + options that the default behavior is to delete the input + file unless writing to standard output. It was already + documented in the DESCRIPTION section but new users in + a hurry might miss it. + + * Windows (native builds, not Cygwin): Fix regressions introduced + in XZ Utils 5.6.3 which caused non-ASCII characters to display + incorrectly. Only builds with translation support were affected + (--enable-nls or ENABLE_NLS=ON). The following changes affect + builds that have translations enabled: + + - Require UCRT because MSVCRT doesn't support UTF-8 + locales and thus translations won't be readable on + Windows 10 version 1903 and later. (MSVCRT builds + are still possible with --disable-nls or ENABLE_NLS=OFF.) + + - Require gettext-runtime >= 0.23.1 because older versions + don't autodetect the use of the UTF-8 code page. This + resulted in garbled non-ASCII characters even with UCRT. + + - Partially fix alignment issues in xz --verbose --list + with translated messages. Chinese (simplified), + Chinese (traditional), and Korean column headings + are misaligned still because Windows and MinGW-w64 + don't provide wcwidth() and XZ Utils doesn't include + a replacement function either. + + * CMake: Explicitly disable unity builds. This prevents build + failures when another project uses XZ Utils via CMake's + FetchContent module, and that project enables unity builds. + + * Update Chinese (traditional) and Serbian translations. + + 5.6.3 (2024-10-01) IMPORTANT: This includes a Windows-specific security fix to - the command line tools. liblzma isn't affected by this issue. + the command line tools (CVE-2024-47611). liblzma isn't affected + by this issue. * liblzma: @@ -55,6 +101,7 @@ XZ Utils Release Notes which can be exploited with malicious filenames to do argument injection or directory traversal attacks. UTF-8 avoids best-fit mappings and thus fixes the issue. + (CVE-2024-47611) Forcing the process code page to UTF-8 is possible only on Windows 10 version 1903 and later. The command line diff --git a/contrib/libs/lzma/THANKS b/contrib/libs/lzma/THANKS index 5ed0743b50..3326e9712e 100644 --- a/contrib/libs/lzma/THANKS +++ b/contrib/libs/lzma/THANKS @@ -34,12 +34,14 @@ has been important. :-) In alphabetical order: - Vitaly Chikunov - Antoine Cœur - Felix Collin + - Marcus Comstedt - Gabi Davar - İhsan Doğan - Chris Donawa - Andrew Dudman - Markus Duft - İsmail Dönmez + - Dexter Castor Döpping - Paul Eggert - Robert Elz - Gilles Espinasse @@ -118,6 +120,7 @@ has been important. :-) In alphabetical order: - Alexander Neumann - Hongbo Ni - Jonathan Nieder + - Asgeir Storesund Nilsen - Andre Noll - Peter O'Gorman - Dimitri Papadopoulos Orfanos @@ -125,6 +128,7 @@ has been important. :-) In alphabetical order: - Filip Palian - Peter Pallinger - Kai Pastor + - Keith Patton - Rui Paulo - Igor Pavlov - Diego Elio Pettenò @@ -181,6 +185,7 @@ has been important. :-) In alphabetical order: - Christian Weisgerber - Dan Weiss - Bert Wesarg + - Mark Wielaard - Fredrik Wikstrom - Jim Wilcoxson - Ralf Wildenhues diff --git a/contrib/libs/lzma/common/sysdefs.h b/contrib/libs/lzma/common/sysdefs.h index 5f3785b513..1c2405dcd8 100644 --- a/contrib/libs/lzma/common/sysdefs.h +++ b/contrib/libs/lzma/common/sysdefs.h @@ -23,17 +23,29 @@ # include <config.h> #endif -// This #define ensures that C99 and POSIX compliant stdio functions are -// available with MinGW-w64 (both 32-bit and 64-bit). Modern MinGW-w64 adds -// this automatically, for example, when the compiler is in C99 (or later) -// mode when building against msvcrt.dll. It still doesn't hurt to be explicit -// that we always want this and #define this unconditionally. +// Choose if MinGW-w64's stdio replacement functions should be used. +// The default has varied slightly in the past so it's clearest to always +// set it explicitly. // -// With Universal CRT (UCRT) this is less important because UCRT contains -// C99-compatible stdio functions. It's still nice to #define this as UCRT -// doesn't support the POSIX thousand separator flag in printf (like "%'u"). -#ifdef __MINGW32__ +// Modern MinGW-w64 enables the replacement functions even with UCRT +// when _GNU_SOURCE is defined. That's good because UCRT doesn't support +// the POSIX thousand separator flag in printf (like "%'u"). Otherwise +// XZ Utils works with the UCRT stdio functions. +// +// The replacement functions add over 20 KiB to each executable. For +// size-optimized builds (HAVE_SMALL), disable the replacements. +// Then thousand separators aren't shown in xz's messages but this is +// a minor downside compare to the slower speed of the HAVE_SMALL builds. +// +// The legacy MSVCRT is pre-C99 and it's best to always use the stdio +// replacements functions from MinGW-w64. +#if defined(__MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO) # define __USE_MINGW_ANSI_STDIO 1 +# include <_mingw.h> +# if defined(_UCRT) && defined(HAVE_SMALL) +# undef __USE_MINGW_ANSI_STDIO +# define __USE_MINGW_ANSI_STDIO 0 +# endif #endif // size_t and NULL diff --git a/contrib/libs/lzma/liblzma/api/lzma/lzma12.h b/contrib/libs/lzma/liblzma/api/lzma/lzma12.h index 05f5b66eb5..fec3e0dadb 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/lzma12.h +++ b/contrib/libs/lzma/liblzma/api/lzma/lzma12.h @@ -461,7 +461,7 @@ typedef struct { * * ext_size_low holds the least significant 32 bits of the * uncompressed size. The most significant 32 bits must be set - * in ext_size_high. The macro lzma_ext_size_set(opt_lzma, u64size) + * in ext_size_high. The macro lzma_set_ext_size(opt_lzma, u64size) * can be used to set these members. * * The 64-bit uncompressed size is split into two uint32_t variables diff --git a/contrib/libs/lzma/liblzma/api/lzma/version.h b/contrib/libs/lzma/liblzma/api/lzma/version.h index e86c0ea4c3..86c8b199f5 100644 --- a/contrib/libs/lzma/liblzma/api/lzma/version.h +++ b/contrib/libs/lzma/liblzma/api/lzma/version.h @@ -22,7 +22,7 @@ #define LZMA_VERSION_MINOR 6 /** \brief Patch version number of the liblzma release. */ -#define LZMA_VERSION_PATCH 3 +#define LZMA_VERSION_PATCH 4 /** * \brief Version stability marker diff --git a/contrib/libs/lzma/liblzma/common/memcmplen.h b/contrib/libs/lzma/liblzma/common/memcmplen.h index 394a4856dd..86b5d6f37e 100644 --- a/contrib/libs/lzma/liblzma/common/memcmplen.h +++ b/contrib/libs/lzma/liblzma/common/memcmplen.h @@ -65,8 +65,7 @@ lzma_memcmplen(const uint8_t *buf1, const uint8_t *buf2, || (defined(_MSC_VER) && (defined(_M_X64) \ || defined(_M_ARM64) || defined(_M_ARM64EC)))) // This is only for x86-64 and ARM64 for now. This might be fine on - // other 64-bit processors too. On big endian one should use xor - // instead of subtraction and switch to __builtin_clzll(). + // other 64-bit processors too. // // Reasons to use subtraction instead of xor: // @@ -82,7 +81,11 @@ lzma_memcmplen(const uint8_t *buf1, const uint8_t *buf2, // version 2023-05-26. https://www.agner.org/optimize/ #define LZMA_MEMCMPLEN_EXTRA 8 while (len < limit) { +# ifdef WORDS_BIGENDIAN + const uint64_t x = read64ne(buf1 + len) ^ read64ne(buf2 + len); +# else const uint64_t x = read64ne(buf1 + len) - read64ne(buf2 + len); +# endif if (x != 0) { // MSVC or Intel C compiler on Windows # if defined(_MSC_VER) || defined(__INTEL_COMPILER) @@ -90,6 +93,8 @@ lzma_memcmplen(const uint8_t *buf1, const uint8_t *buf2, _BitScanForward64(&tmp, x); len += (uint32_t)tmp >> 3; // GCC, Clang, or Intel C compiler +# elif defined(WORDS_BIGENDIAN) + len += (uint32_t)__builtin_clzll(x) >> 3; # else len += (uint32_t)__builtin_ctzll(x) >> 3; # endif diff --git a/contrib/libs/lzma/liblzma/common/string_conversion.c b/contrib/libs/lzma/liblzma/common/string_conversion.c index c899783c64..3a08486a1f 100644 --- a/contrib/libs/lzma/liblzma/common/string_conversion.c +++ b/contrib/libs/lzma/liblzma/common/string_conversion.c @@ -317,6 +317,10 @@ parse_lzma12_preset(const char **const str, const char *str_end, uint32_t *preset) { assert(*str < str_end); + + if (!(**str >= '0' && **str <= '9')) + return "Unsupported preset"; + *preset = (uint32_t)(**str - '0'); // NOTE: Remember to update LZMA12_PRESET_STR if this is modified! diff --git a/contrib/libs/lzma/liblzma/lzma/lzma_decoder.c b/contrib/libs/lzma/liblzma/lzma/lzma_decoder.c index 0abed02b81..2088a2faa5 100644 --- a/contrib/libs/lzma/liblzma/lzma/lzma_decoder.c +++ b/contrib/libs/lzma/liblzma/lzma/lzma_decoder.c @@ -18,7 +18,7 @@ // The macros unroll loops with switch statements. // Silence warnings about missing fall-through comments. -#if TUKLIB_GNUC_REQ(7, 0) +#if TUKLIB_GNUC_REQ(7, 0) || defined(__clang__) # pragma GCC diagnostic ignored "-Wimplicit-fallthrough" #endif diff --git a/contrib/libs/lzma/ya.make b/contrib/libs/lzma/ya.make index 8d69e9753d..60d612bae1 100644 --- a/contrib/libs/lzma/ya.make +++ b/contrib/libs/lzma/ya.make @@ -11,9 +11,9 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(5.6.3) +VERSION(5.6.4) -ORIGINAL_SOURCE(https://github.com/tukaani-project/xz/archive/v5.6.3.tar.gz) +ORIGINAL_SOURCE(https://github.com/tukaani-project/xz/archive/v5.6.4.tar.gz) ADDINCL( GLOBAL contrib/libs/lzma/liblzma/api diff --git a/contrib/libs/rapidjson/include/rapidjson/rapidjson.h b/contrib/libs/rapidjson/include/rapidjson/rapidjson.h index 3b2551eeb0..3415da7a7e 100644 --- a/contrib/libs/rapidjson/include/rapidjson/rapidjson.h +++ b/contrib/libs/rapidjson/include/rapidjson/rapidjson.h @@ -126,7 +126,7 @@ #ifdef RAPIDJSON_DOXYGEN_RUNNING #define RAPIDJSON_HAS_STDSTRING 1 // force generation of documentation #else -#define RAPIDJSON_HAS_STDSTRING 0 // no std::string support by default +#define RAPIDJSON_HAS_STDSTRING 1 // arcadia-default: has std::string support by default #endif /*! \def RAPIDJSON_HAS_STDSTRING \ingroup RAPIDJSON_CONFIG diff --git a/contrib/libs/rapidjson/patches/RAPIDJSON_HAS_STDSTRING_CONTRIB-3819.patch b/contrib/libs/rapidjson/patches/RAPIDJSON_HAS_STDSTRING_CONTRIB-3819.patch new file mode 100644 index 0000000000..0cce53601b --- /dev/null +++ b/contrib/libs/rapidjson/patches/RAPIDJSON_HAS_STDSTRING_CONTRIB-3819.patch @@ -0,0 +1,12 @@ +diff --git a/include/rapidjson/rapidjson.h b/include/rapidjson/rapidjson.h +--- a/include/rapidjson/rapidjson.h ++++ b/include/rapidjson/rapidjson.h +@@ -126,7 +126,7 @@ + #ifdef RAPIDJSON_DOXYGEN_RUNNING + #define RAPIDJSON_HAS_STDSTRING 1 // force generation of documentation + #else +-#define RAPIDJSON_HAS_STDSTRING 0 // no std::string support by default ++#define RAPIDJSON_HAS_STDSTRING 1 // arcadia-default: has std::string support by default + #endif + /*! \def RAPIDJSON_HAS_STDSTRING + \ingroup RAPIDJSON_CONFIG |