diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2016-05-25 16:36:47 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2016-05-25 21:02:07 +0200 |
| commit | d4b7f03cfa4732132767188782683f3d957da912 (patch) | |
| tree | 47ae5bbd2694e2df24c80d3f4779a25f07345181 /src/lib/openjp2/openjpeg.c | |
| parent | 54179fe1d53156c6b440166fe71a10f238a6ea56 (diff) | |
Add opj_codec_set_threads() in public API and propagate resulting thread pool to tcd level
By default, only the main thread is used. If opj_codec_set_threads() is not used,
but the OPJ_NUM_THREADS environment variable is set, its value will be
used to initialize the number of threads. The value can be either an integer
number, or "ALL_CPUS". If OPJ_NUM_THREADS is set and this function is called,
this function will override the behaviour of the environment variable.
Diffstat (limited to 'src/lib/openjp2/openjpeg.c')
| -rw-r--r-- | src/lib/openjp2/openjpeg.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/openjp2/openjpeg.c b/src/lib/openjp2/openjpeg.c index 5114cc10..ee3e14b6 100644 --- a/src/lib/openjp2/openjpeg.c +++ b/src/lib/openjp2/openjpeg.c @@ -239,6 +239,9 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format) OPJ_UINT32 res_factor, struct opj_event_mgr * p_manager)) opj_j2k_set_decoded_resolution_factor; + l_codec->opj_set_threads = + (OPJ_BOOL (*) ( void * p_codec, OPJ_UINT32 num_threads )) opj_j2k_set_threads; + l_codec->m_codec = opj_j2k_create_decompress(); if (! l_codec->m_codec) { @@ -315,6 +318,9 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format) OPJ_UINT32 res_factor, opj_event_mgr_t * p_manager)) opj_jp2_set_decoded_resolution_factor; + l_codec->opj_set_threads = + (OPJ_BOOL (*) ( void * p_codec, OPJ_UINT32 num_threads )) opj_jp2_set_threads; + l_codec->m_codec = opj_jp2_create(OPJ_TRUE); if (! l_codec->m_codec) { @@ -354,6 +360,18 @@ void OPJ_CALLCONV opj_set_default_decoder_parameters(opj_dparameters_t *paramete } } + +OPJ_API OPJ_CALLCONV opj_codec_set_threads(opj_codec_t *p_codec, + int num_threads) +{ + if (p_codec ) { + opj_codec_private_t * l_codec = (opj_codec_private_t *) p_codec; + + return l_codec->opj_set_threads(l_codec->m_codec, num_threads); + } + return OPJ_FALSE; +} + OPJ_BOOL OPJ_CALLCONV opj_setup_decoder(opj_codec_t *p_codec, opj_dparameters_t *parameters ) |
