[FFmpeg-devel] Support master branch of OpenJPEG and Grok J2K codecs

Michael Bradshaw mjbshaw at gmail.com
Mon Apr 4 01:02:37 CEST 2016


Tested with OpenJPEG 1.5, 2.0, and 2.1 on OS X with clang. Correctly
decoded and re-encoded the balloon.jp2 sample.

On Sun, Apr 3, 2016 at 2:34 PM, Aaron Boxer <boxerab at gmail.com> wrote:
> From d12c685578f21b403f6c03505edd84db367306c5 Mon Sep 17 00:00:00 2001
> From: Aaron Boxer <boxerab at gmail.com>
> Date: Sun, 27 Mar 2016 00:15:20 -0400
> Subject: [PATCH] Support the following jpeg 2000 codecs:
>
> a) latest release of openjpeg (2.1)
> b) master branch of openjpeg
> c) grok (https://github.com/GrokImageCompression/grok)

I'm curious what others think: if Grok requires FFmpeg to use GPLv3,
should an explicit check be added in ./configure to require
--enable-gpl --enable-version3? Or should the check not be added,
since FFmpeg is expecting the OpenJPEG library and the user is
replacing it with something else, so the onus is on them to remember
to add those flags when configuring?

>
> The following changes were made:
>
> 1. Removed bpp (redundant as this information is already stored in precision)
> 2. Removed OPJ_STATIC flag in configure: in master branch of openjpeg and in grok, this flag indicates a static build, so codec API functions are marked as hidden. This prevents FFmpeg from using a dynamic build of these codecs.
> 3. link to libdl. This is needed by grok, as it supports a plugin architecture that allows plugins to be dynamically loaded at runtime.
>
> I have tested these changes with openjpeg 2.1, openjpeg master, and grok master.Test was to make sure ./configure and make showed no errors, and then to decompress a J2K file.  Everything worked for all three configurations, with no errors.
> ---
>  configure                   | 2 +-
>  libavcodec/libopenjpegdec.c | 2 +-
>  libavcodec/libopenjpegenc.c | 3 +--
>  3 files changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/configure b/configure
> index 94a66d8..4e81385 100755
> --- a/configure
> +++ b/configure
> @@ -5561,7 +5561,7 @@ enabled libopencv         && { check_header opencv2/core/core_c.h &&
>                                   require opencv opencv2/core/core_c.h cvCreateImageHeader -lopencv_core -lopencv_imgproc; } ||
>                                 require_pkg_config opencv opencv/cxcore.h cvCreateImageHeader; }
>  enabled libopenh264       && require_pkg_config openh264 wels/codec_api.h WelsGetCodecVersion
> -enabled libopenjpeg       && { check_lib openjpeg-2.1/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC ||
> +enabled libopenjpeg       && { check_lib openjpeg-2.1/openjpeg.h opj_version -lopenjp2 -ldl ||
>                                 check_lib openjpeg-2.0/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC ||
>                                 check_lib openjpeg-1.5/openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC ||
>                                 check_lib openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC ||
> diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c
> index 65167e6..f116c8b 100644
> --- a/libavcodec/libopenjpegdec.c
> +++ b/libavcodec/libopenjpegdec.c
> @@ -24,7 +24,7 @@
>   * JPEG 2000 decoder using libopenjpeg
>   */
>
> -#define  OPJ_STATIC
> +
>
>  #include "libavutil/common.h"
>  #include "libavutil/imgutils.h"
> diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
> index 56c8219..720eda0 100644
> --- a/libavcodec/libopenjpegenc.c
> +++ b/libavcodec/libopenjpegenc.c
> @@ -24,7 +24,7 @@
>   * JPEG 2000 encoder using libopenjpeg
>   */
>
> -#define  OPJ_STATIC
> +
>
>  #include "libavutil/avassert.h"
>  #include "libavutil/common.h"
> @@ -276,7 +276,6 @@ static opj_image_t *mj2_create_image(AVCodecContext *avctx, opj_cparameters_t *p
>
>      for (i = 0; i < numcomps; i++) {
>          cmptparm[i].prec = desc->comp[i].depth;
> -        cmptparm[i].bpp  = desc->comp[i].depth;

bpp is needed by opj_j2k_is_cinema_compliant in OpenJPEG 2.1. I'd
rather not remove this line.

>          cmptparm[i].sgnd = 0;
>          cmptparm[i].dx = sub_dx[i];
>          cmptparm[i].dy = sub_dy[i];
> --
> 2.5.0


More information about the ffmpeg-devel mailing list