openjpeg: Fix build against openjpeg 2.2

OpenJPEG 2.2 has some API changes and thus ships its headers in a new
include path. Add a configure check (to both meson and autoconf) to
detect the newer version of OpenJPEG and add conditional includes.

Fix the autoconf test for OpenJPEG 2.1, which checked for HAVE_OPENJPEG,
which was always set even for 2.0.

https://bugzilla.gnome.org/show_bug.cgi?id=786250
This commit is contained in:
Clemens Lang 2017-08-13 21:17:18 +02:00 committed by Sebastian Dröge
parent 0b8f1f9e54
commit 15f24fef53
3 changed files with 22 additions and 10 deletions

View file

@ -2859,8 +2859,13 @@ AG_GST_CHECK_FEATURE(OPENJPEG, [openjpeg library], openjpeg, [
if test x"$HAVE_OPENJPEG" = x"yes"; then if test x"$HAVE_OPENJPEG" = x"yes"; then
dnl minor API changes in v2.1 dnl minor API changes in v2.1
AG_GST_PKG_CHECK_MODULES(OPENJPEG_2_1, libopenjp2 >= 2.1) AG_GST_PKG_CHECK_MODULES(OPENJPEG_2_1, libopenjp2 >= 2.1)
if test x"$HAVE_OPENJPEG" = x"yes"; then if test x"$HAVE_OPENJPEG_2_1" = x"yes"; then
AC_DEFINE([HAVE_OPENJPEG_2_1], 1, [Define if OpenJPEG 2.1 is used]) AC_DEFINE([HAVE_OPENJPEG_2_1], 1, [Define if OpenJPEG 2.1 is used])
dnl include paths changed for v2.2
AG_GST_PKG_CHECK_MODULES(OPENJPEG_2_2, libopenjp2 >= 2.2)
if test x"$HAVE_OPENJPEG_2_2" = x"yes"; then
AC_DEFINE([HAVE_OPENJPEG_2_2], 1, [Define if OpenJPEG 2.2 is used])
fi
fi fi
else else
# Fallback to v1.5 # Fallback to v1.5

View file

@ -38,7 +38,9 @@
#define OPJ_CPRL CPRL #define OPJ_CPRL CPRL
#else #else
#include <stdio.h> #include <stdio.h>
# ifdef HAVE_OPENJPEG_2_1 # if defined(HAVE_OPENJPEG_2_2)
# include <openjpeg-2.2/openjpeg.h>
# elif defined(HAVE_OPENJPEG_2_1)
# include <openjpeg-2.1/openjpeg.h> # include <openjpeg-2.1/openjpeg.h>
# else # else
# include <openjpeg-2.0/openjpeg.h> # include <openjpeg-2.0/openjpeg.h>

View file

@ -6,17 +6,22 @@ openjpeg_sources = [
openjpeg_cargs = [] openjpeg_cargs = []
# Check for 2.1, then 2.0 # Check for 2.2, 2.1, then 2.0
openjpeg_dep = dependency('libopenjp2', version : '>=2.1', required : false) openjpeg_dep = dependency('libopenjp2', version : '>=2.2', required : false)
if openjpeg_dep.found() if openjpeg_dep.found()
openjpeg_cargs += ['-DHAVE_OPENJPEG_2_1'] openjpeg_cargs += ['-DHAVE_OPENJPEG_2_2']
else else
openjpeg_dep = dependency('libopenjp2', version : '>=2.1', required : false)
if openjpeg_dep.found()
openjpeg_cargs += ['-DHAVE_OPENJPEG_2_1']
else
openjpeg_dep = dependency('libopenjp2', required : false) openjpeg_dep = dependency('libopenjp2', required : false)
# Fallback to 1.5 # Fallback to 1.5
if not openjpeg_dep.found() if not openjpeg_dep.found()
openjpeg_dep = dependency('libopenjpeg1', required : false) openjpeg_dep = dependency('libopenjpeg1', required : false)
openjpeg_cargs += ['-DHAVE_OPENJPEG_1'] openjpeg_cargs += ['-DHAVE_OPENJPEG_1']
endif endif
endif
endif endif
if openjpeg_dep.found() if openjpeg_dep.found()