[FFmpeg-devel] [PATCH] update ffmpeg to recognise and build with newest openjpeg available in its git, up from v2.2 to v2.3

hydra3333 at gmail.com hydra3333 at gmail.com
Thu Oct 5 19:36:21 EEST 2017


OK please ignore/cancel this thread, Michael Bradshaw already got in with a patch that looks functionally the same.
http://ffmpeg.org/pipermail/ffmpeg-devel/2017-October/217389.html 

From: 
Sent: Friday, October 6, 2017 2:49 AM
To: ffmpeg-devel at ffmpeg.org 
Subject: [PATCH] update ffmpeg to recognise and build with newest openjpeg available in its git, up from v2.2 to v2.3

I have attempted to post my first patch suggestion per https://trac.ffmpeg.org/ticket/6719#comment:1 
If I have done something wrong, please feel free to say so (and how to fix it, if possible).

Openjpeg git at ​https://github.com/uclouvain/openjpeg is up from v2.2 to v2.3, 
which means that ffmpeg no longer builds with the openjpeg dependency as built from its git.

The patch seems to fix ffmpeg so that it builds with openjpeg v2.3 as a dependency built from its git.


>From 80412c4b26d197e9627b097443e7032c106de4ff Mon Sep 17 00:00:00 2001
From: hydra3333 <hydra3333 at gmail.com>
Date: Fri, 6 Oct 2017 02:19:34 +1030
Subject: [PATCH] update ffmpeg to recognise and build with newest openjpeg
available in its git, up from v2.2 to v2.3

---
configure                   | 11 +++++++----
libavcodec/libopenjpegdec.c |  8 +++++---
libavcodec/libopenjpegenc.c | 10 ++++++----
3 files changed, 18 insertions(+), 11 deletions(-)
mode change 100755 => 100644 configure

diff --git a/configure b/configure
old mode 100755
new mode 100644
index 391c141e7a..3c8f84b0c8
--- a/configure
+++ b/configure
@@ -1930,6 +1930,7 @@ HEADERS_LIST="
     machine_ioctl_meteor_h
     malloc_h
     opencv2_core_core_c_h
+    openjpeg_2_3_openjpeg_h
     openjpeg_2_2_openjpeg_h
     openjpeg_2_1_openjpeg_h
     openjpeg_2_0_openjpeg_h
@@ -5910,7 +5911,7 @@ enabled libbs2b           && require_pkg_config libbs2b libbs2b bs2b.h bs2b_open
enabled libcelt           && require libcelt celt/celt.h celt_decode -lcelt0 &&
                              { check_lib libcelt celt/celt.h celt_decoder_create_custom -lcelt0 ||
                                die "ERROR: libcelt must be installed and version must be >= 0.11.0."; }
-enabled libcaca           && require_pkg_config libcaca caca caca.h caca_create_canvas
+enabled libcaca           && require_pkg_config libcaca caca caca.h caca_create_canvas -DCACA_STATIC && add_cppflags -DCACA_STATIC
enabled libdc1394         && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new
enabled libdrm            && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion
enabled libfdk_aac        && { use_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen ||
@@ -5937,7 +5938,7 @@ enabled libkvazaar        && require_pkg_config libkvazaar "kvazaar >= 0.8.1" kv
# can find the libraries and headers through other means.
enabled libmfx            && { use_pkg_config libmfx libmfx "mfx/mfxvideo.h" MFXInit ||
                                { require libmfx "mfx/mfxvideo.h" MFXInit -llibmfx && warn "using libmfx without pkg-config"; } }
-enabled libmodplug        && require_pkg_config libmodplug libmodplug libmodplug/modplug.h ModPlug_Load
+enabled libmodplug        && require_pkg_config libmodplug libmodplug libmodplug/modplug.h ModPlug_Load -DMODPLUG_STATIC && add_cppflags -DMODPLUG_STATIC
enabled libmp3lame        && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
enabled libmysofa         && require libmysofa "mysofa.h" mysofa_load -lmysofa
enabled libnpp            && { check_lib libnpp npp.h nppGetLibVersion -lnppig -lnppicc -lnppc ||
@@ -5950,7 +5951,9 @@ enabled libopencv         && { check_header opencv2/core/core_c.h &&
                                  require opencv opencv2/core/core_c.h cvCreateImageHeader -lopencv_core -lopencv_imgproc; } ||
                                require_pkg_config libopencv opencv opencv/cxcore.h cvCreateImageHeader; }
enabled libopenh264       && require_pkg_config libopenh264 openh264 wels/codec_api.h WelsGetCodecVersion
-enabled libopenjpeg       && { { check_lib libopenjpeg openjpeg-2.2/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } ||
+enabled libopenjpeg       && { { check_lib libopenjpeg openjpeg-2.3/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } ||
+                               check_lib libopenjpeg openjpeg-2.3/openjpeg.h opj_version -lopenjp2 ||
+                               { check_lib libopenjpeg openjpeg-2.2/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } ||
                                check_lib libopenjpeg openjpeg-2.2/openjpeg.h opj_version -lopenjp2 ||
                                { check_lib libopenjpeg openjpeg-2.1/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } ||
                                check_lib libopenjpeg openjpeg-2.1/openjpeg.h opj_version -lopenjp2 ||
@@ -5980,7 +5983,7 @@ enabled libssh            && require_pkg_config libssh libssh libssh/sftp.h sftp
enabled libspeex          && require_pkg_config libspeex speex speex/speex.h speex_decoder_init -lspeex
enabled libtesseract      && require_pkg_config libtesseract tesseract tesseract/capi.h TessBaseAPICreate
enabled libtheora         && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
-enabled libtwolame        && require libtwolame twolame.h twolame_init -ltwolame &&
+enabled libtwolame        && require libtwolame twolame.h twolame_init -ltwolame -DLIBTWOLAME_STATIC && add_cppflags -DLIBTWOLAME_STATIC &&
                              { check_lib libtwolame twolame.h twolame_encode_buffer_float32_interleaved -ltwolame ||
                                die "ERROR: libtwolame must be installed and version must be >= 0.3.10"; }
enabled libv4l2           && require_pkg_config libv4l2 libv4l2 libv4l2.h v4l2_ioctl
diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c
index 1210123265..67d47bd6a0 100644
--- a/libavcodec/libopenjpegdec.c
+++ b/libavcodec/libopenjpegdec.c
@@ -34,7 +34,9 @@
#include "internal.h"
#include "thread.h"

-#if HAVE_OPENJPEG_2_2_OPENJPEG_H
+#if HAVE_OPENJPEG_2_3_OPENJPEG_H
+#  include <openjpeg-2.3/openjpeg.h>
+#elif HAVE_OPENJPEG_2_2_OPENJPEG_H
#  include <openjpeg-2.2/openjpeg.h>
#elif HAVE_OPENJPEG_2_1_OPENJPEG_H
#  include <openjpeg-2.1/openjpeg.h>
@@ -46,7 +48,7 @@
#  include <openjpeg.h>
#endif

-#if HAVE_OPENJPEG_2_2_OPENJPEG_H || HAVE_OPENJPEG_2_1_OPENJPEG_H || HAVE_OPENJPEG_2_0_OPENJPEG_H
+#if HAVE_OPENJPEG_2_3_OPENJPEG_H || HAVE_OPENJPEG_2_2_OPENJPEG_H || HAVE_OPENJPEG_2_1_OPENJPEG_H || HAVE_OPENJPEG_2_0_OPENJPEG_H
#  define OPENJPEG_MAJOR_VERSION 2
#  define OPJ(x) OPJ_##x
#else
@@ -431,7 +433,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
     opj_stream_set_read_function(stream, stream_read);
     opj_stream_set_skip_function(stream, stream_skip);
     opj_stream_set_seek_function(stream, stream_seek);
-#if HAVE_OPENJPEG_2_2_OPENJPEG_H || HAVE_OPENJPEG_2_1_OPENJPEG_H
+#if HAVE_OPENJPEG_2_3_OPENJPEG_H || HAVE_OPENJPEG_2_2_OPENJPEG_H || HAVE_OPENJPEG_2_1_OPENJPEG_H
     opj_stream_set_user_data(stream, &reader, NULL);
#elif HAVE_OPENJPEG_2_0_OPENJPEG_H
     opj_stream_set_user_data(stream, &reader);
diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index b67e533d1d..92b4433b04 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -32,7 +32,9 @@
#include "avcodec.h"
#include "internal.h"

-#if HAVE_OPENJPEG_2_2_OPENJPEG_H
+#if HAVE_OPENJPEG_2_3_OPENJPEG_H
+#  include <openjpeg-2.3/openjpeg.h>
+#elif HAVE_OPENJPEG_2_2_OPENJPEG_H
#  include <openjpeg-2.2/openjpeg.h>
#elif HAVE_OPENJPEG_2_1_OPENJPEG_H
#  include <openjpeg-2.1/openjpeg.h>
@@ -44,7 +46,7 @@
#  include <openjpeg.h>
#endif

-#if HAVE_OPENJPEG_2_2_OPENJPEG_H || HAVE_OPENJPEG_2_1_OPENJPEG_H || HAVE_OPENJPEG_2_0_OPENJPEG_H
+#if HAVE_OPENJPEG_2_3_OPENJPEG_H || HAVE_OPENJPEG_2_2_OPENJPEG_H || HAVE_OPENJPEG_2_1_OPENJPEG_H || HAVE_OPENJPEG_2_0_OPENJPEG_H
#  define OPENJPEG_MAJOR_VERSION 2
#  define OPJ(x) OPJ_##x
#else
@@ -307,7 +309,7 @@ static av_cold int libopenjpeg_encode_init(AVCodecContext *avctx)

     opj_set_default_encoder_parameters(&ctx->enc_params);

-#if HAVE_OPENJPEG_2_2_OPENJPEG_H || HAVE_OPENJPEG_2_1_OPENJPEG_H
+#if HAVE_OPENJPEG_2_3_OPENJPEG_H || HAVE_OPENJPEG_2_2_OPENJPEG_H || HAVE_OPENJPEG_2_1_OPENJPEG_H
     switch (ctx->cinema_mode) {
     case OPJ_CINEMA2K_24:
         ctx->enc_params.rsiz = OPJ_PROFILE_CINEMA_2K;
@@ -771,7 +773,7 @@ static int libopenjpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     opj_stream_set_write_function(stream, stream_write);
     opj_stream_set_skip_function(stream, stream_skip);
     opj_stream_set_seek_function(stream, stream_seek);
-#if HAVE_OPENJPEG_2_2_OPENJPEG_H || HAVE_OPENJPEG_2_1_OPENJPEG_H
+#if HAVE_OPENJPEG_2_3_OPENJPEG_H || HAVE_OPENJPEG_2_2_OPENJPEG_H || HAVE_OPENJPEG_2_1_OPENJPEG_H
     opj_stream_set_user_data(stream, &writer, NULL);
#elif HAVE_OPENJPEG_2_0_OPENJPEG_H
     opj_stream_set_user_data(stream, &writer);
-- 
2.11.0


More information about the ffmpeg-devel mailing list