openjpeg: Port to 2.1 and require a pkg-config file for 2.0 and 2.1
authorNirbheek Chauhan <nirbheek@centricular.com>
Tue, 10 May 2016 10:54:08 +0000 (16:24 +0530)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 10 May 2016 11:03:33 +0000 (14:03 +0300)
The port was trivial, and according to the NEWS file nothing else has changed,
but it is possible that other API was changed without proper notification.

OpenJPEG upstream has shipped a pkg-config file for the past 4 years, and all
distros should be shipping it by now.

https://bugzilla.gnome.org/show_bug.cgi?id=766213

configure.ac
ext/openjpeg/gstopenjpeg.h
ext/openjpeg/gstopenjpegdec.c
ext/openjpeg/gstopenjpegenc.c

index 23120c5..0d6851b 100644 (file)
@@ -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 <openjpeg-2.0/openjpeg.h>],
-                    [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",
index ac28cce..03ce52e 100644 (file)
 #define OPJ_CPRL CPRL
 #else
 #include <stdio.h>
-#include <openjpeg-2.0/openjpeg.h>
+# ifdef HAVE_OPENJPEG_2_1
+#  include <openjpeg-2.1/openjpeg.h>
+# else
+#  include <openjpeg-2.0/openjpeg.h>
+# endif
 #endif
 
 #endif /* __GST_OPENJPEG_H__ */
index fdccc51..aad81ac 100644 (file)
@@ -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;
index fe5764d..0c54f03 100644 (file)
@@ -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))