From bd54424f03ac541be7ec54aed89b85a007838f6d Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov <2536374+asmorkalov@users.noreply.github.com> Date: Mon, 8 Dec 2025 08:59:51 +0300 Subject: [PATCH] Merge pull request #28140 from asmorkalov:as/openjpeg_2.5.4 OpenJPEG update to 2.5.4 #28140 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake --- 3rdparty/openjpeg/openjp2/jp2.c | 6 ++++++ 3rdparty/openjpeg/openjp2/libopenjp2.pc.cmake.in | 2 +- 3rdparty/openjpeg/openjp2/openjpeg.h | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/3rdparty/openjpeg/openjp2/jp2.c b/3rdparty/openjpeg/openjp2/jp2.c index da5063186c..3d16d1075f 100644 --- a/3rdparty/openjpeg/openjp2/jp2.c +++ b/3rdparty/openjpeg/openjp2/jp2.c @@ -1987,6 +1987,12 @@ OPJ_BOOL opj_jp2_setup_encoder(opj_jp2_t *jp2, if (image->icc_profile_len) { jp2->meth = 2; jp2->enumcs = 0; + jp2->color.icc_profile_buf = (OPJ_BYTE *)opj_malloc(image->icc_profile_len); + if (jp2->color.icc_profile_buf) { + jp2->color.icc_profile_len = image->icc_profile_len; + memcpy(jp2->color.icc_profile_buf, image->icc_profile_buf, + image->icc_profile_len); + } } else { jp2->meth = 1; if (image->color_space == OPJ_CLRSPC_SRGB) { diff --git a/3rdparty/openjpeg/openjp2/libopenjp2.pc.cmake.in b/3rdparty/openjpeg/openjp2/libopenjp2.pc.cmake.in index 2ade312b29..ac33f1447e 100644 --- a/3rdparty/openjpeg/openjp2/libopenjp2.pc.cmake.in +++ b/3rdparty/openjpeg/openjp2/libopenjp2.pc.cmake.in @@ -10,6 +10,6 @@ Description: JPEG2000 library (Part 1 and 2) URL: http://www.openjpeg.org/ Version: @OPENJPEG_VERSION@ Libs: -L${libdir} -lopenjp2 -Libs.private: -lm +Libs.private: @deps@ Cflags: -I${includedir} Cflags.private: -DOPJ_STATIC diff --git a/3rdparty/openjpeg/openjp2/openjpeg.h b/3rdparty/openjpeg/openjp2/openjpeg.h index 59abd323ae..fe2f1ee0c4 100644 --- a/3rdparty/openjpeg/openjp2/openjpeg.h +++ b/3rdparty/openjpeg/openjp2/openjpeg.h @@ -635,6 +635,8 @@ typedef void * opj_codec_t; /* * Callback function prototype for read function + * @return returns The number of bytes delivered into + * \a p_buffer. -1 signals end of stream. */ typedef OPJ_SIZE_T(* opj_stream_read_fn)(void * p_buffer, OPJ_SIZE_T p_nb_bytes, void * p_user_data) ; @@ -1239,7 +1241,6 @@ OPJ_API void OPJ_CALLCONV opj_stream_set_user_data(opj_stream_t* p_stream, /** * Sets the length of the user data for the stream. - * * @param p_stream the stream to modify * @param data_length length of the user_data. */ @@ -1437,6 +1438,8 @@ OPJ_API OPJ_BOOL OPJ_CALLCONV opj_set_decoded_components(opj_codec_t *p_codec, * that is to say at the highest resolution level, even if requesting the image at lower * resolution levels. * + * Note: If p_start_x, p_start_y, p_end_x, p_end_y are all 0, then the whole image is decoded. + * * Generally opj_set_decode_area() should be followed by opj_decode(), and the * codec cannot be re-used. * In the particular case of an image made of a single tile, several sequences of