Index: libopenjpeg/openjpeg.h =================================================================== --- libopenjpeg/openjpeg.h (revision 338) +++ libopenjpeg/openjpeg.h (working copy) @@ -311,6 +311,41 @@ } opj_cparameters_t; +/** Stop after tags. */ +typedef enum LIMIT_TAGS { + OPJ_TAG_SOC = 0x000001, /**< start of codestream */ + OPJ_TAG_SOT = 0x000002, /**< start of tile-part*/ + OPJ_TAG_SOD = 0x000004, /**< start of data */ + OPJ_TAG_EOC = 0x000008, /**< end of codestream */ + OPJ_TAG_SIZ = 0x000010, /**< image and tile size */ + OPJ_TAG_COD = 0x000020, /**< coding style default */ + OPJ_TAG_COC = 0x000040, /**< coding style component */ + OPJ_TAG_RGN = 0x000080, /**< region-of-interest */ + OPJ_TAG_QCD = 0x000100, /**< quantization default */ + OPJ_TAG_QCC = 0x000200, /**< quantization component */ + OPJ_TAG_POC = 0x000400, /**< progression order change */ + OPJ_TAG_TLM = 0x000800, /**< tile-part lengths */ + OPJ_TAG_PLM = 0x001000, /**< packet length, main header */ + OPJ_TAG_PLT = 0x002000, /**< packet length, tile-part header */ + OPJ_TAG_PPM = 0x004000, /**< packet packet headers, main header */ + OPJ_TAG_PPT = 0x008000, /**< packet packet headers, tile-part header */ + OPJ_TAG_SOP = 0x010000, /**< SOP marker value */ + OPJ_TAG_EPH = 0x020000, /**< EPH marker value */ + OPJ_TAG_CRG = 0x040000, /**< component registration */ + OPJ_TAG_COM = 0x080000, /**< comment */ +#ifdef USE_JPWL +/* UniPG>> */ + OPJ_TAG_EPC = 0x100000, /**< EPC marker value (Part11) */ + OPJ_TAG_EPB = 0x200000, /**< EPB marker value (Part11) */ + OPJ_TAG_ESD = 0x400000, /**< ESD marker value (Part11) */ + OPJ_TAG_RED = 0x800000, /**< RED marker value (Part11) */ +#endif /* USE_JPWL */ +/* <> */ #ifdef USE_JPWL - {J2K_MS_EPC, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_epc}, - {J2K_MS_EPB, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_epb}, - {J2K_MS_ESD, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_esd}, - {J2K_MS_RED, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_red}, + {J2K_MS_EPC, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_epc, OPJ_TAG_EPC}, + {J2K_MS_EPB, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_epb, OPJ_TAG_EPB}, + {J2K_MS_ESD, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_esd, OPJ_TAG_ESD}, + {J2K_MS_RED, J2K_STATE_MH | J2K_STATE_TPH, j2k_read_red, OPJ_TAG_RED}, #endif /* USE_JPWL */ /* <reduce = parameters->cp_reduce; cp->layer = parameters->cp_layer; + cp->limit_tags = parameters->cp_limit_tags; /* UniPG>> */ #ifdef USE_JPWL cp->correct = parameters->jpwl_correct; @@ -1599,6 +1602,12 @@ opj_event_msg(cinfo, EVT_ERROR, "%.8x: unexpected marker %x\n", cio_tell(cio) - 2, id); return 0; } + /* If a partial decode is requested, stop if the current tag + * isn't in the list. + */ + if (j2k->cp->limit_tags && !(j2k->cp->limit_tags & e->limit_tag)) { + return image; + } if (e->handler) { (*e->handler)(j2k); } Index: libopenjpeg/j2k.h =================================================================== --- libopenjpeg/j2k.h (revision 338) +++ libopenjpeg/j2k.h (working copy) @@ -197,6 +197,8 @@ int reduce; /** if != 0, then only the first "layer" layers are decoded; if == 0 or not used, all the quality layers are decoded */ int layer; + /** if != 0, then only decode specific tags, abort on any other; if == 0 decode all tags */ + OPJ_LIMIT_TAGS limit_tags; /** 0 = no index || 1 = index */ int index_on; /** XTOsiz */