From 32b04ad49d1fc17bf8e9b6a1725a465f57b7adfb Mon Sep 17 00:00:00 2001 From: Antonin Descampe Date: Wed, 23 Sep 2015 17:48:30 +0200 Subject: [PATCH] Makes j2k_dump focus on parsing j2k codestreams, nothing else. Avoid processing JP2 PCLR, CMAP, CDEF boxes and J2K packets in j2k_dump. Fixes #595 --- applications/codec/j2k_dump.c | 9 +++++++-- libopenjpeg/j2k.c | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/applications/codec/j2k_dump.c b/applications/codec/j2k_dump.c index 3b321a45..3af5708c 100644 --- a/applications/codec/j2k_dump.c +++ b/applications/codec/j2k_dump.c @@ -359,6 +359,11 @@ int main(int argc, char *argv[]) return 1; } + /* j2k_dump focuses on j2k codestream and skips JP2 boxes */ + parameters.flags = 1; + /* j2k_dump shall not actually decode packets (parsing codestream is enough). */ + parameters.cp_limit_decoding = DECODE_ALL_BUT_PACKETS; + /* Initialize reading of directory */ if(img_fol.set_imgdir==1){ num_images=get_num_images(img_fol.imgdirpath); @@ -454,7 +459,7 @@ int main(int argc, char *argv[]) cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length); /* decode the stream and fill the image structure */ - if (*indexfilename) /* If need to extract codestream information*/ + if (*indexfilename) /* If need to extract codestream information*/ image = opj_decode_with_info(dinfo, cio, &cstr_info); else image = opj_decode(dinfo, cio); @@ -503,7 +508,7 @@ int main(int argc, char *argv[]) cio = opj_cio_open((opj_common_ptr)dinfo, src, file_length); /* decode the stream and fill the image structure */ - if (*indexfilename) /* If need to extract codestream information*/ + if (*indexfilename) /* If need to extract codestream information*/ image = opj_decode_with_info(dinfo, cio, &cstr_info); else image = opj_decode(dinfo, cio); diff --git a/libopenjpeg/j2k.c b/libopenjpeg/j2k.c index 06e7b061..2bca97ac 100644 --- a/libopenjpeg/j2k.c +++ b/libopenjpeg/j2k.c @@ -1726,6 +1726,8 @@ static void j2k_read_eoc(opj_j2k_t *j2k) { } /* if packets should not be decoded */ else { + opj_event_msg(j2k->cinfo, EVT_INFO, "Codestream parsing complete.\n"); + opj_event_msg(j2k->cinfo, EVT_INFO, "Skipped actual packet decoding.\n"); for (i = 0; i < j2k->cp->tileno_size; i++) { tileno = j2k->cp->tileno[i]; opj_free(j2k->tile_data[tileno]);