disable threading for older openjpegs

This commit is contained in:
John Cupitt 2021-03-20 14:14:08 +00:00
parent 5f0be5d3dc
commit cedc3f1f1d
3 changed files with 17 additions and 1 deletions

View File

@ -787,6 +787,14 @@ if test x"$with_libopenjp2" != x"no"; then
with_libopenjp2=no
]
)
# 2.3 and earlier have threading problems
PKG_CHECK_MODULES(LIBOPENJP2_THREADING, libopenjp2 >= 2.4,
[AC_DEFINE(HAVE_LIBOPENJP2_THREADING,1,[define if your libopenjp2 threading works.])
],
[:
]
)
fi
VIPS_CFLAGS="$VIPS_CFLAGS $LIBOPENJP2_CFLAGS"

View File

@ -506,9 +506,12 @@ vips_foreign_load_jp2k_header( VipsForeignLoad *load )
if( !opj_setup_decoder( jp2k->codec, &jp2k->parameters ) )
return( -1 );
/* Use eg. VIPS_CONCURRENCY etc. to set n-cpus.
#ifdef HAVE_LIBOPENJP2_THREADING
/* Use eg. VIPS_CONCURRENCY etc. to set n-cpus, if this openjpeg has
* stable support.
*/
opj_codec_set_threads( jp2k->codec, vips_concurrency_get() );
#endif /*HAVE_LIBOPENJP2_THREADING*/
if( !opj_read_header( jp2k->stream, jp2k->codec, &jp2k->image ) )
return( -1 );

View File

@ -455,7 +455,12 @@ vips_foreign_save_jp2k_build( VipsObject *object )
if( !opj_setup_encoder( jp2k->codec, &jp2k->parameters, jp2k->image ) )
return( -1 );
#ifdef HAVE_LIBOPENJP2_THREADING
/* Use eg. VIPS_CONCURRENCY etc. to set n-cpus, if this openjpeg has
* stable support.
*/
opj_codec_set_threads( jp2k->codec, vips_concurrency_get() );
#endif /*HAVE_LIBOPENJP2_THREADING*/
if( !(jp2k->stream = vips_foreign_save_jp2k_target( jp2k->target )) )
return( -1 );