]> granicus.if.org Git - openjpeg/commitdiff
[trunk] WIP: correct mistake with JP2 files and manage correctly the text_GBR.jp2...
authorMickael Savinaud <savmickael@users.noreply.github.com>
Tue, 11 Oct 2011 07:49:16 +0000 (07:49 +0000)
committerMickael Savinaud <savmickael@users.noreply.github.com>
Tue, 11 Oct 2011 07:49:16 +0000 (07:49 +0000)
CHANGES
applications/codec/j2k_to_image.c
libopenjpeg/j2k.c
libopenjpeg/jp2.c
tests/nonregression/test_suite.ctest.in

diff --git a/CHANGES b/CHANGES
index b7519d34bfe28a179a61bf36caaa1ca1debd8707..eeccd3b49f6ab633f9a46477da0ee5de967bf461 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,9 @@ What's New for OpenJPEG
 ! : changed
 + : added
 
+October 11, 2011
+* [mickael] WIP: correct mistake with JP2 files and manage correctly the text_GBR.jp2 filecase.
+
 October 10, 2011
 * [vincent] fix 'distcheck' rule
 + [vincent] add libopenjpeg-jpwl.pc.in
index 65ba1e5afc36a43a26d468f169b00c1b6d93210c..cbc00606a4e6b5196e91dbd52710d29239e8642d 100644 (file)
@@ -579,8 +579,6 @@ int main(int argc, char **argv)
        opj_image_t image;
        opj_stream_t *cio = NULL;                               /* Stream */
        opj_codec_t* dinfo = NULL;                              /* Handle to a decompressor */
-       opj_bool bRes1, bRes2; 
-
 
        char indexfilename[OPJ_PATH_LEN];       /* index file name */
 
@@ -713,13 +711,8 @@ int main(int argc, char **argv)
                        return EXIT_FAILURE;
                }
 
-
                /* Get the decoded image */
-               bRes1 = opj_decode_v2(dinfo, cio, &image);
-               bRes2 = opj_end_decompress(dinfo,cio);
-
-               /*if ( !(opj_decode_v2(dinfo, cio, &image)) || !(opj_end_decompress(dinfo,cio)) ) {*/
-               if ( !bRes1  || !bRes2) {
+               if ( !( opj_decode_v2(dinfo, cio, &image) && opj_end_decompress(dinfo,cio) ) ) {
                        fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
                        opj_destroy_codec(dinfo);
                        opj_stream_destroy(cio);
index bc611609a4e3fed8e5b90c6b59b16f301e71349a..219bb0f7ed0a8d9d0de0b4eb19e82608a94f2021 100644 (file)
@@ -3362,6 +3362,15 @@ opj_bool j2k_read_sot_v2 (
        ++p_header_data;
 
        if (l_num_parts != 0) { /* Number of tile-part header is provided by this tile-part header */
+               /* Useful to manage the case of textGBR.jp2 file because two values of TNSot are allowed: the correct numbers of
+                * tile-parts for that tile and zero (A.4.2 of 15444-1 : 2002). */
+               if (l_tcp->m_nb_tile_parts) {
+                       if (l_current_part >= l_tcp->m_nb_tile_parts){
+                               opj_event_msg_v2(p_manager, EVT_ERROR, "In SOT marker, TPSot (%d) is not valid regards to the current "
+                                               "number of tile-part (%d), giving up\n", l_current_part, l_tcp->m_nb_tile_parts );
+                               return OPJ_FALSE;
+                       }
+               }
                l_tcp->m_nb_tile_parts = l_num_parts;
        }
 
@@ -5709,7 +5718,7 @@ opj_bool j2k_read_tile_header(    opj_j2k_v2_t * p_j2k,
 
                        /* Read the marker segment with the correct marker handler */
                        if (! (*(l_marker_handler->handler))(p_j2k,p_j2k->m_specific_param.m_decoder.m_header_data,l_marker_size,p_manager)) {
-                               opj_event_msg_v2(p_manager, EVT_ERROR, "Marker is not compliant with its position\n");
+                               opj_event_msg_v2(p_manager, EVT_ERROR, "Fail to read the current marker segment (%#x)\n", l_current_marker);
                                return OPJ_FALSE;
                        }
 
index 618f9ab4767339053bdb334266df75a2e580f156..d29e060a51ab64ad802e9718d60e851b3c3dde9d 100644 (file)
@@ -1490,8 +1490,8 @@ opj_bool opj_jp2_decode_v2(       opj_jp2_v2_t *jp2,
                                                        struct opj_event_mgr * p_manager)
 {
        /* J2K decoding */
-       if( j2k_decode_v2(jp2->j2k, cio, p_image, p_manager) ) {
-               opj_event_msg_v2(p_manager, EVT_ERROR, "Failed to decode J2K image\n");
+       if( j2k_decode_v2(jp2->j2k, cio, p_image, p_manager) ) {
+               opj_event_msg_v2(p_manager, EVT_ERROR, "Failed to decode the codestream in the JP2 file\n");
                return OPJ_FALSE;
        }
 
@@ -1521,6 +1521,7 @@ opj_bool opj_jp2_decode_v2(       opj_jp2_v2_t *jp2,
        if(jp2->color.icc_profile_buf) {
                p_image->icc_profile_buf = jp2->color.icc_profile_buf;
                p_image->icc_profile_len = jp2->color.icc_profile_len;
+               jp2->color.icc_profile_buf = NULL;
        }
 
        return OPJ_TRUE;
index ba89ef7c5582ccda529d2a7b45b1dca5c7b0d56b..b1cba12a9c4efd0d65996ada082f9e22c84da155 100644 (file)
@@ -10,7 +10,7 @@
 #     image to base)\r
 #\r
 # Line begin with ! should failed (should be used for bad jpeg2000 file which should be \r
-# gracefully rejected)\r
+# gracefully rejected). Please add a short resume about why this file should be rejected.\r
 #\r
 # You can use @INPUT_NR_PATH@ and @TEMP_PATH@ cmake variable which refers to OPJ_DATA_ROOT \r
 # repository. However you can use relative path or absolute path.\r
@@ -60,4 +60,5 @@ j2k_to_image -i  @INPUT_NR_PATH@/orb-blue10-win-j2k.j2k -o @TEMP_PATH@/orb-blue1
 j2k_to_image -i  @INPUT_NR_PATH@/orb-blue10-win-jp2.jp2 -o @TEMP_PATH@/orb-blue10-win-jp2.jp2.pgx\r
 j2k_to_image -i  @INPUT_NR_PATH@/relax.jp2 -o @TEMP_PATH@/relax.jp2.pgx\r
 j2k_to_image -i  @INPUT_NR_PATH@/test_lossless.j2k -o @TEMP_PATH@/test_lossless.j2k.pgx\r
-j2k_to_image -i  @INPUT_NR_PATH@/text_GBR.jp2 -o @TEMP_PATH@/text_GBR.jp2.pgx\r
+# text_GBR.jp2 file exhibt a error about a tile part with a index > of the number of tile-part in this tile.\r
+!j2k_to_image -i  @INPUT_NR_PATH@/text_GBR.jp2 -o @TEMP_PATH@/text_GBR.jp2.pgx\r