From 7e2b6bebff12eab8bdc17fc9af017e8c11652f4f Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 19 Sep 2017 16:52:07 +0200 Subject: Add capability to decode only a subset of all components of an image. This adds a opj_set_decoded_components(opj_codec_t *p_codec, OPJ_UINT32 numcomps, const OPJ_UINT32* comps_indices) function, and equivalent "opj_decompress -c compno[,compno]*" option. When specified, neither the MCT transform nor JP2 channel transformations will be applied. Tests added for various combinations of whole image vs tiled-based decoding, full or reduced resolution, use of decode area or not. --- src/lib/openjp2/jp2.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/lib/openjp2/jp2.c') diff --git a/src/lib/openjp2/jp2.c b/src/lib/openjp2/jp2.c index 84d39327..81d03480 100644 --- a/src/lib/openjp2/jp2.c +++ b/src/lib/openjp2/jp2.c @@ -1607,6 +1607,11 @@ OPJ_BOOL opj_jp2_decode(opj_jp2_t *jp2, return OPJ_FALSE; } + if (jp2->j2k->m_specific_param.m_decoder.m_numcomps_to_decode) { + /* Bypass all JP2 component transforms */ + return OPJ_TRUE; + } + if (!jp2->ignore_pclr_cmap_cdef) { if (!opj_jp2_check_color(p_image, &(jp2->color), p_manager)) { return OPJ_FALSE; @@ -3069,6 +3074,16 @@ void opj_jp2_destroy(opj_jp2_t *jp2) } } +OPJ_BOOL opj_jp2_set_decoded_components(opj_jp2_t *p_jp2, + OPJ_UINT32 numcomps, + const OPJ_UINT32* comps_indices, + opj_event_mgr_t * p_manager) +{ + return opj_j2k_set_decoded_components(p_jp2->j2k, + numcomps, comps_indices, + p_manager); +} + OPJ_BOOL opj_jp2_set_decode_area(opj_jp2_t *p_jp2, opj_image_t* p_image, OPJ_INT32 p_start_x, OPJ_INT32 p_start_y, @@ -3100,6 +3115,11 @@ OPJ_BOOL opj_jp2_get_tile(opj_jp2_t *p_jp2, return OPJ_FALSE; } + if (p_jp2->j2k->m_specific_param.m_decoder.m_numcomps_to_decode) { + /* Bypass all JP2 component transforms */ + return OPJ_TRUE; + } + if (!opj_jp2_check_color(p_image, &(p_jp2->color), p_manager)) { return OPJ_FALSE; } -- cgit v1.2.3