openjpeg: remove support for OpenJPEG 1.5

Also require OpenJPEG version >= 2.2
This commit is contained in:
Aaron Boxer 2019-07-28 14:19:36 -04:00
parent 1ddd13da24
commit 8af8e73573
5 changed files with 2 additions and 192 deletions

View file

@ -1820,18 +1820,7 @@ dnl *** OpenJPEG ***
translit(dnm, m, l) AM_CONDITIONAL(USE_OPENJPEG, true)
AG_GST_CHECK_FEATURE(OPENJPEG, [openjpeg library], openjpeg, [
HAVE_OPENJPEG="no"
AG_GST_PKG_CHECK_MODULES(OPENJPEG, libopenjp2 >= 2.1)
if test x"$HAVE_OPENJPEG" != x"yes"; then
# Fallback to v1.5
OPENJPEG_LIBS=""
PKG_CHECK_MODULES(OPENJPEG, libopenjpeg1,
HAVE_OPENJPEG="yes",
AG_GST_CHECK_LIBHEADER(OPENJPEG, openjpeg, opj_version, , openjpeg.h, OPENJPEG_LIBS="-lopenjpeg")
)
if test x"$HAVE_OPENJPEG" = x"yes"; then
AC_DEFINE([HAVE_OPENJPEG_1], 1, [Define if OpenJPEG 1 is used])
fi
fi
AG_GST_PKG_CHECK_MODULES(OPENJPEG, libopenjp2 >= 2.2)
AC_SUBST(OPENJPEG_CFLAGS)
AC_SUBST(OPENJPEG_LIBS)
])

View file

@ -23,20 +23,4 @@
#include <openjpeg.h>
#ifdef HAVE_OPENJPEG_1
#define OPJ_CLRSPC_UNKNOWN CLRSPC_UNKNOWN
#define OPJ_CLRSPC_SRGB CLRSPC_SRGB
#define OPJ_CLRSPC_GRAY CLRSPC_GRAY
#define OPJ_CLRSPC_SYCC CLRSPC_SYCC
#define OPJ_CODEC_J2K CODEC_J2K
#define OPJ_CODEC_JP2 CODEC_JP2
#define OPJ_LRCP LRCP
#define OPJ_RLCP RLCP
#define OPJ_RPCL RPCL
#define OPJ_PCRL PCRL
#define OPJ_CPRL CPRL
#endif
#endif /* __GST_OPENJPEG_H__ */

View file

@ -113,9 +113,6 @@ gst_openjpeg_dec_init (GstOpenJPEGDec * self)
(self), TRUE);
GST_PAD_SET_ACCEPT_TEMPLATE (GST_VIDEO_DECODER_SINK_PAD (self));
opj_set_default_decoder_parameters (&self->params);
#ifdef HAVE_OPENJPEG_1
self->params.cp_limit_decoding = NO_LIMITATION;
#endif
self->sampling = GST_JPEG2000_SAMPLING_NONE;
}
@ -983,7 +980,6 @@ gst_openjpeg_dec_opj_info (const char *msg, void *userdata)
g_free (trimmed);
}
#ifndef HAVE_OPENJPEG_1
typedef struct
{
guint8 *data;
@ -1044,7 +1040,6 @@ seek_fn (OPJ_OFF_T p_nb_bytes, void *p_user_data)
return OPJ_TRUE;
}
#endif
static GstFlowReturn
gst_openjpeg_dec_handle_frame (GstVideoDecoder * decoder,
@ -1054,14 +1049,9 @@ gst_openjpeg_dec_handle_frame (GstVideoDecoder * decoder,
GstFlowReturn ret = GST_FLOW_OK;
gint64 deadline;
GstMapInfo map;
#ifdef HAVE_OPENJPEG_1
opj_dinfo_t *dec;
opj_cio_t *io;
#else
opj_codec_t *dec;
opj_stream_t *stream;
MemStream mstream;
#endif
opj_image_t *image;
GstVideoFrame vframe;
opj_dparameters_t params;
@ -1080,19 +1070,6 @@ gst_openjpeg_dec_handle_frame (GstVideoDecoder * decoder,
if (!dec)
goto initialization_error;
#ifdef HAVE_OPENJPEG_1
if (G_UNLIKELY (gst_debug_category_get_threshold (GST_CAT_DEFAULT) >=
GST_LEVEL_TRACE)) {
opj_event_mgr_t callbacks;
callbacks.error_handler = gst_openjpeg_dec_opj_error;
callbacks.warning_handler = gst_openjpeg_dec_opj_warning;
callbacks.info_handler = gst_openjpeg_dec_opj_info;
opj_set_event_mgr ((opj_common_ptr) dec, &callbacks, self);
} else {
opj_set_event_mgr ((opj_common_ptr) dec, NULL, NULL);
}
#else
if (G_UNLIKELY (gst_debug_category_get_threshold (GST_CAT_DEFAULT) >=
GST_LEVEL_TRACE)) {
opj_set_info_handler (dec, gst_openjpeg_dec_opj_info, self);
@ -1103,7 +1080,6 @@ gst_openjpeg_dec_handle_frame (GstVideoDecoder * decoder,
opj_set_warning_handler (dec, NULL, NULL);
opj_set_error_handler (dec, NULL, NULL);
}
#endif
params = self->params;
if (self->ncomps)
@ -1116,16 +1092,6 @@ gst_openjpeg_dec_handle_frame (GstVideoDecoder * decoder,
if (self->is_jp2c && map.size < 8)
goto open_error;
#ifdef HAVE_OPENJPEG_1
io = opj_cio_open ((opj_common_ptr) dec, map.data + (self->is_jp2c ? 8 : 0),
map.size - (self->is_jp2c ? 8 : 0));
if (!io)
goto open_error;
image = opj_decode (dec, io);
if (!image)
goto decode_error;
#else
stream = opj_stream_create (4096, OPJ_TRUE);
if (!stream)
goto open_error;
@ -1147,7 +1113,6 @@ gst_openjpeg_dec_handle_frame (GstVideoDecoder * decoder,
if (!opj_decode (dec, stream, image))
goto decode_error;
#endif
{
gint i;
@ -1176,16 +1141,10 @@ gst_openjpeg_dec_handle_frame (GstVideoDecoder * decoder,
gst_video_frame_unmap (&vframe);
#ifdef HAVE_OPENJPEG_1
opj_cio_close (io);
opj_image_destroy (image);
opj_destroy_decompress (dec);
#else
opj_end_decompress (dec, stream);
opj_stream_destroy (stream);
opj_image_destroy (image);
opj_destroy_codec (dec);
#endif
ret = gst_video_decoder_finish_frame (decoder, frame);
@ -1200,11 +1159,7 @@ initialization_error:
}
map_read_error:
{
#ifdef HAVE_OPENJPEG_1
opj_destroy_decompress (dec);
#else
opj_destroy_codec (dec);
#endif
gst_video_codec_frame_unref (frame);
GST_ELEMENT_ERROR (self, CORE, FAILED,
@ -1213,11 +1168,7 @@ map_read_error:
}
open_error:
{
#ifdef HAVE_OPENJPEG_1
opj_destroy_decompress (dec);
#else
opj_destroy_codec (dec);
#endif
gst_buffer_unmap (frame->input_buffer, &map);
gst_video_codec_frame_unref (frame);
@ -1229,13 +1180,8 @@ decode_error:
{
if (image)
opj_image_destroy (image);
#ifdef HAVE_OPENJPEG_1
opj_cio_close (io);
opj_destroy_decompress (dec);
#else
opj_stream_destroy (stream);
opj_destroy_codec (dec);
#endif
gst_buffer_unmap (frame->input_buffer, &map);
gst_video_codec_frame_unref (frame);
@ -1246,13 +1192,8 @@ decode_error:
negotiate_error:
{
opj_image_destroy (image);
#ifdef HAVE_OPENJPEG_1
opj_cio_close (io);
opj_destroy_decompress (dec);
#else
opj_stream_destroy (stream);
opj_destroy_codec (dec);
#endif
gst_video_codec_frame_unref (frame);
GST_ELEMENT_ERROR (self, CORE, NEGOTIATION,
@ -1262,13 +1203,8 @@ negotiate_error:
allocate_error:
{
opj_image_destroy (image);
#ifdef HAVE_OPENJPEG_1
opj_cio_close (io);
opj_destroy_decompress (dec);
#else
opj_stream_destroy (stream);
opj_destroy_codec (dec);
#endif
gst_video_codec_frame_unref (frame);
GST_ELEMENT_ERROR (self, CORE, FAILED,
@ -1278,13 +1214,8 @@ allocate_error:
map_write_error:
{
opj_image_destroy (image);
#ifdef HAVE_OPENJPEG_1
opj_cio_close (io);
opj_destroy_decompress (dec);
#else
opj_stream_destroy (stream);
opj_destroy_codec (dec);
#endif
gst_video_codec_frame_unref (frame);
GST_ELEMENT_ERROR (self, CORE, FAILED,

View file

@ -782,8 +782,6 @@ gst_openjpeg_enc_opj_info (const char *msg, void *userdata)
g_free (trimmed);
}
#ifndef HAVE_OPENJPEG_1
typedef struct
{
guint8 *data;
@ -849,7 +847,6 @@ seek_fn (OPJ_OFF_T p_nb_bytes, void *p_user_data)
return OPJ_TRUE;
}
#endif
static GstFlowReturn
gst_openjpeg_enc_handle_frame (GstVideoEncoder * encoder,
@ -857,16 +854,9 @@ gst_openjpeg_enc_handle_frame (GstVideoEncoder * encoder,
{
GstOpenJPEGEnc *self = GST_OPENJPEG_ENC (encoder);
GstFlowReturn ret = GST_FLOW_OK;
#ifdef HAVE_OPENJPEG_1
opj_cinfo_t *enc;
GstMapInfo map;
guint length;
opj_cio_t *io;
#else
opj_codec_t *enc;
opj_stream_t *stream;
MemStream mstream;
#endif
opj_image_t *image;
GstVideoFrame vframe;
@ -876,19 +866,6 @@ gst_openjpeg_enc_handle_frame (GstVideoEncoder * encoder,
if (!enc)
goto initialization_error;
#ifdef HAVE_OPENJPEG_1
if (G_UNLIKELY (gst_debug_category_get_threshold (GST_CAT_DEFAULT) >=
GST_LEVEL_TRACE)) {
opj_event_mgr_t callbacks;
callbacks.error_handler = gst_openjpeg_enc_opj_error;
callbacks.warning_handler = gst_openjpeg_enc_opj_warning;
callbacks.info_handler = gst_openjpeg_enc_opj_info;
opj_set_event_mgr ((opj_common_ptr) enc, &callbacks, self);
} else {
opj_set_event_mgr ((opj_common_ptr) enc, NULL, NULL);
}
#else
if (G_UNLIKELY (gst_debug_category_get_threshold (GST_CAT_DEFAULT) >=
GST_LEVEL_TRACE)) {
opj_set_info_handler (enc, gst_openjpeg_enc_opj_info, self);
@ -899,7 +876,6 @@ gst_openjpeg_enc_handle_frame (GstVideoEncoder * encoder,
opj_set_warning_handler (enc, NULL, NULL);
opj_set_error_handler (enc, NULL, NULL);
}
#endif
if (!gst_video_frame_map (&vframe, &self->input_state->info,
frame->input_buffer, GST_MAP_READ))
@ -914,37 +890,6 @@ gst_openjpeg_enc_handle_frame (GstVideoEncoder * encoder,
self->params.tcp_mct = 1;
}
opj_setup_encoder (enc, &self->params, image);
#ifdef HAVE_OPENJPEG_1
io = opj_cio_open ((opj_common_ptr) enc, NULL, 0);
if (!io)
goto open_error;
if (!opj_encode (enc, io, image, NULL))
goto encode_error;
opj_image_destroy (image);
length = cio_tell (io);
ret =
gst_video_encoder_allocate_output_frame (encoder, frame,
length + (self->is_jp2c ? 8 : 0));
if (ret != GST_FLOW_OK)
goto allocate_error;
gst_buffer_fill (frame->output_buffer, self->is_jp2c ? 8 : 0, io->buffer,
length);
if (self->is_jp2c) {
gst_buffer_map (frame->output_buffer, &map, GST_MAP_WRITE);
GST_WRITE_UINT32_BE (map.data, length + 8);
GST_WRITE_UINT32_BE (map.data + 4, GST_MAKE_FOURCC ('j', 'p', '2', 'c'));
gst_buffer_unmap (frame->output_buffer, &map);
}
opj_cio_close (io);
opj_destroy_compress (enc);
#else
stream = opj_stream_create (4096, OPJ_FALSE);
if (!stream)
goto open_error;
@ -991,7 +936,6 @@ gst_openjpeg_enc_handle_frame (GstVideoEncoder * encoder,
gst_buffer_append_memory (frame->output_buffer,
gst_memory_new_wrapped (0, mstream.data, mstream.allocsize, 0,
mstream.size, NULL, (GDestroyNotify) g_free));
#endif
GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (frame);
ret = gst_video_encoder_finish_frame (encoder, frame);
@ -1007,11 +951,7 @@ initialization_error:
}
map_read_error:
{
#ifdef HAVE_OPENJPEG_1
opj_destroy_compress (enc);
#else
opj_destroy_codec (enc);
#endif
gst_video_codec_frame_unref (frame);
GST_ELEMENT_ERROR (self, CORE, FAILED,
@ -1020,11 +960,7 @@ map_read_error:
}
fill_image_error:
{
#ifdef HAVE_OPENJPEG_1
opj_destroy_compress (enc);
#else
opj_destroy_codec (enc);
#endif
gst_video_frame_unmap (&vframe);
gst_video_codec_frame_unref (frame);
@ -1035,11 +971,7 @@ fill_image_error:
open_error:
{
opj_image_destroy (image);
#ifdef HAVE_OPENJPEG_1
opj_destroy_compress (enc);
#else
opj_destroy_codec (enc);
#endif
gst_video_codec_frame_unref (frame);
GST_ELEMENT_ERROR (self, LIBRARY, INIT,
@ -1048,34 +980,16 @@ open_error:
}
encode_error:
{
#ifdef HAVE_OPENJPEG_1
opj_cio_close (io);
opj_image_destroy (image);
opj_destroy_compress (enc);
#else
opj_stream_destroy (stream);
g_free (mstream.data);
opj_image_destroy (image);
opj_destroy_codec (enc);
#endif
gst_video_codec_frame_unref (frame);
GST_ELEMENT_ERROR (self, STREAM, ENCODE,
("Failed to encode OpenJPEG stream"), (NULL));
return GST_FLOW_ERROR;
}
#ifdef HAVE_OPENJPEG_1
allocate_error:
{
opj_cio_close (io);
opj_destroy_compress (enc);
gst_video_codec_frame_unref (frame);
GST_ELEMENT_ERROR (self, CORE, FAILED,
("Failed to allocate output buffer"), (NULL));
return ret;
}
#endif
}
static gboolean

View file

@ -10,15 +10,7 @@ if get_option('openjpeg').disabled()
subdir_done()
endif
openjpeg_dep = dependency('libopenjp2', version : '>=2.1', required : false)
if not openjpeg_dep.found()
# Fallback to v1.5
openjpeg_dep = dependency('libopenjpeg1', required : false)
openjpeg_cargs += ['-DHAVE_OPENJPEG_1']
endif
if not openjpeg_dep.found() and get_option('openjpeg').enabled()
error('openjpeg plugin enabled, but neither libopenjp2 nor libopenjpeg1 not found')
endif
openjpeg_dep = dependency('libopenjp2', version : '>=2.2', required : get_option('openjpeg'))
if openjpeg_dep.found()
gstopenjpeg = library('gstopenjpeg',