diff --git a/configure.ac b/configure.ac index 23120c5157..0d6851b945 100644 --- a/configure.ac +++ b/configure.ac @@ -2739,20 +2739,15 @@ dnl *** OpenJPEG *** translit(dnm, m, l) AM_CONDITIONAL(USE_OPENJPEG, true) AG_GST_CHECK_FEATURE(OPENJPEG, [openjpeg library], openjpeg, [ HAVE_OPENJPEG="no" - - save_LIBS="$LIBS" - save_CFLAGS="$CFLAGS" - OPENJPEG_LIBS="-lopenjp2" - LIBS="$LIBS $OPENJPEG_LIBS" - CFLAGS="$CFLAGS $OPENJPEG_CFLAGS" - AC_LINK_IFELSE([ - AC_LANG_PROGRAM([#include ], - [return (int) *opj_version ();]) - ], [HAVE_OPENJPEG=yes], [HAVE_OPENJPEG=no]) - LIBS="$save_LIBS" - CFLAGS="$save_CFLAGS" - - if test x"$HAVE_OPENJPEG" = x"no"; then + AG_GST_PKG_CHECK_MODULES(OPENJPEG, libopenjp2 >= 2.0) + if test x"$HAVE_OPENJPEG" = x"yes"; then + dnl minor API changes in v2.1 + AG_GST_PKG_CHECK_MODULES(OPENJPEG_2_1, libopenjp2 >= 2.1) + if test x"$HAVE_OPENJPEG" = x"yes"; then + AC_DEFINE([HAVE_OPENJPEG_2_1], 1, [Define if OpenJPEG 2.1 is used]) + fi + else + # Fallback to v1.5 OPENJPEG_LIBS="" PKG_CHECK_MODULES(OPENJPEG, libopenjpeg1, HAVE_OPENJPEG="yes", diff --git a/ext/openjpeg/gstopenjpeg.h b/ext/openjpeg/gstopenjpeg.h index ac28ccea90..03ce52e476 100644 --- a/ext/openjpeg/gstopenjpeg.h +++ b/ext/openjpeg/gstopenjpeg.h @@ -38,7 +38,11 @@ #define OPJ_CPRL CPRL #else #include -#include +# ifdef HAVE_OPENJPEG_2_1 +# include +# else +# include +# endif #endif #endif /* __GST_OPENJPEG_H__ */ diff --git a/ext/openjpeg/gstopenjpegdec.c b/ext/openjpeg/gstopenjpegdec.c index fdccc51b09..aad81acb94 100644 --- a/ext/openjpeg/gstopenjpegdec.c +++ b/ext/openjpeg/gstopenjpegdec.c @@ -1039,7 +1039,11 @@ gst_openjpeg_dec_handle_frame (GstVideoDecoder * decoder, opj_stream_set_write_function (stream, write_fn); opj_stream_set_skip_function (stream, skip_fn); opj_stream_set_seek_function (stream, seek_fn); +#ifdef HAVE_OPENJPEG_2_1 + opj_stream_set_user_data (stream, &mstream, NULL); +#else opj_stream_set_user_data (stream, &mstream); +#endif opj_stream_set_user_data_length (stream, mstream.size); image = NULL; diff --git a/ext/openjpeg/gstopenjpegenc.c b/ext/openjpeg/gstopenjpegenc.c index fe5764dd2f..0c54f03202 100644 --- a/ext/openjpeg/gstopenjpegenc.c +++ b/ext/openjpeg/gstopenjpegenc.c @@ -901,7 +901,11 @@ gst_openjpeg_enc_handle_frame (GstVideoEncoder * encoder, opj_stream_set_write_function (stream, write_fn); opj_stream_set_skip_function (stream, skip_fn); opj_stream_set_seek_function (stream, seek_fn); +#ifdef HAVE_OPENJPEG_2_1 + opj_stream_set_user_data (stream, &mstream, NULL); +#else opj_stream_set_user_data (stream, &mstream); +#endif opj_stream_set_user_data_length (stream, mstream.size); if (!opj_start_compress (enc, image, stream))