Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API breakage in 2.5.1 / openjpeg version no longer detected (openjpeg.h no longer includes opj_config.h) #1514

Closed
0-wiz-0 opened this issue Feb 27, 2024 · 7 comments

Comments

@0-wiz-0
Copy link

0-wiz-0 commented Feb 27, 2024

Despite

No API/ABI break compared to v2.5.0

in the 2.5.1 release notes, an upgrade to 2.5.1 in pkgsrc broke some other software.

Two examples:
Pillow

src/libImaging/Jpeg2KDecode.c: In function 'j2k_decode_entry':
src/libImaging/Jpeg2KDecode.c:673:5: error: too few arguments to function 'opj_stream_set_user_data'
  673 |     opj_stream_set_user_data(stream, state);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from src/libImaging/Jpeg2K.h:11,
                 from src/libImaging/Jpeg2KDecode.c:21:
/home/pbulk/build/graphics/py-Pillow/work/.buildlink/include/openjpeg-2.5/openjpeg.h:1235:27: note: declared here
 1235 | OPJ_API void OPJ_CALLCONV opj_stream_set_user_data(opj_stream_t* p_stream,
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~

ghostscript

./base/sjpx_openjpeg.c: In function 's_opjd_process':
./base/sjpx_openjpeg.c:760:5: warning: "OPJ_VERSION_MAJOR" is not defined, evaluates to 0 [-Wundef]
  760 | #if OPJ_VERSION_MAJOR >= 2 && OPJ_VERSION_MINOR >= 1
      |     ^~~~~~~~~~~~~~~~~
./base/sjpx_openjpeg.c:763:13: error: too few arguments to function 'opj_stream_set_user_data'
  763 |             opj_stream_set_user_data(state->stream, &(state->sb));
      |             ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./base/sjpx_openjpeg.h:25,
                 from ./base/sjpx_openjpeg.c:24:
/home/pbulk/build/print/ghostscript-agpl/work/.buildlink/include/openjpeg-2.5/openjpeg.h:1235:27: note: declared here
 1235 | OPJ_API void OPJ_CALLCONV opj_stream_set_user_data(opj_stream_t* p_stream,
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~

I guess the software used some now invalid way to check for openjpeg versions, e.g. Pillow

/* OpenJPEG 2.0 doesn't have OPJ_VERSION_MAJOR */
#ifndef OPJ_VERSION_MAJOR
    opj_stream_set_user_data(stream, state);
#else
     opj_stream_set_user_data(stream, state, NULL);
...
@rouault
Copy link
Collaborator

rouault commented Feb 27, 2024

openjpeg.h didn't change apart from comment:

$ git diff v2.5.0..v2.5.1 src/lib/openjp2/openjpeg.h
diff --git a/src/lib/openjp2/openjpeg.h b/src/lib/openjp2/openjpeg.h
index ebce53db..a421143a 100644
--- a/src/lib/openjp2/openjpeg.h
+++ b/src/lib/openjp2/openjpeg.h
@@ -122,7 +122,7 @@ typedef float         OPJ_FLOAT32;
 typedef double        OPJ_FLOAT64;
 typedef unsigned char OPJ_BYTE;
 
-#include "opj_stdint.h"
+#include <stdint.h>
 
 typedef int8_t   OPJ_INT8;
 typedef uint8_t  OPJ_UINT8;
@@ -405,7 +405,7 @@ typedef struct opj_cparameters {
     int cp_disto_alloc;
     /** allocation by fixed layer */
     int cp_fixed_alloc;
-    /** add fixed_quality */
+    /** allocation by fixed quality (PSNR) */
     int cp_fixed_quality;
     /** fixed layer */
     int *cp_matrice;
@@ -829,9 +829,9 @@ typedef struct opj_tile_info {
     int pdy[33];
     /** information concerning packets inside tile */
     opj_packet_info_t *packet;
-    /** add fixed_quality */
+    /** number of pixels of the tile */
     int numpix;
-    /** add fixed_quality */
+    /** distortion of the tile */
     double distotile;
     /** number of markers */
     int marknum;

warning: "OPJ_VERSION_MAJOR" is not defined,

This one definitely explains the issue. Perhaps this could be related to the CMake changes? The installed include/openjpeg-2.5/opj_config.h file on my end looks fine

@rouault
Copy link
Collaborator

rouault commented Feb 27, 2024

Might be related to the comment #1424 (review)

@0-wiz-0
Copy link
Author

0-wiz-0 commented Feb 27, 2024

You found the problem.

-#include "opj_stdint.h"
+#include <stdint.h>

and obj_stdint.h included opj_config.h, which provided the now missing symbol.

@0-wiz-0
Copy link
Author

0-wiz-0 commented Feb 27, 2024

So one solution would be for openjpeg.h to include opj_config.h.

@rouault
Copy link
Collaborator

rouault commented Feb 27, 2024

So one solution would be for openjpeg.h to include opj_config.h.

It should definitely do that. I'll probably have to issue a bugfix release for that

@rouault rouault changed the title API breakage in 2.5.1 API breakage in 2.5.1 / openjpeg version no longer detected (openjpeg.h no longer includes opj_config.h) Feb 27, 2024
rouault added a commit that referenced this issue Feb 28, 2024
openjpeg.h: make sure to include opj_config.h (fixes #1514)
@rouault
Copy link
Collaborator

rouault commented Feb 28, 2024

Fixed in the just released 2.5.2 release

@0-wiz-0
Copy link
Author

0-wiz-0 commented Feb 28, 2024

Thank you for fixing this so quickly!

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Feb 28, 2024
## OpenJPEG 2.5.2 (Feb 2024)

No API/ABI break compared to v2.5.1

* Make sure openjpeg.h includes opj_config.h [\#1514](uclouvain/openjpeg#1514)
mtremer pushed a commit to ipfire/ipfire-2.x that referenced this issue Mar 12, 2024
- Update from version 2.5.0 to 2.5.2
- Update of rootfile
- Changelog
    2.5.2 (Feb 2024)
	No API/ABI break compared to v2.5.1
	* Make sure openjpeg.h includes opj_config.h [\#1514](uclouvain/openjpeg#1514)
    2.5.1 (Feb 2024)
	No API/ABI break compared to v2.5.0
	* CMake: drop support for cmake < 3.5
	* Several bugfixes, including [\#1509](uclouvain/openjpeg#1509) for CVE-2021-3575
	* Significant speed-up rate allocation by rate/distoratio ratio [\#1440](uclouvain/openjpeg#1440)

Signed-off-by: Adolf Belka <[email protected]>
Signed-off-by: Michael Tremer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants