[trunk] WIP: add output elements about decoding of jp2 files with last tile part...
authorMickael Savinaud <savmickael@users.noreply.github.com>
Tue, 11 Oct 2011 07:54:27 +0000 (07:54 +0000)
committerMickael Savinaud <savmickael@users.noreply.github.com>
Tue, 11 Oct 2011 07:54:27 +0000 (07:54 +0000)
CHANGES
libopenjpeg/j2k.c
libopenjpeg/j2k.h

diff --git a/CHANGES b/CHANGES
index eeccd3b49f6ab633f9a46477da0ee5de967bf461..e1f2f5333ed3e4795c7f58b88720f164d464fe08 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,7 +6,8 @@ What's New for OpenJPEG
 + : added
 
 October 11, 2011
-* [mickael] WIP: correct mistake with JP2 files and manage correctly the text_GBR.jp2 filecase.
+* [mickael] WIP: add output elements about decoding of jp2 files with last tile part lenght equal zero
+* [mickael] WIP: correct mistake with JP2 files and manage correctly the text_GBR.jp2 filecase
 
 October 10, 2011
 * [vincent] fix 'distcheck' rule
index 219bb0f7ed0a8d9d0de0b4eb19e82608a94f2021..4bd37eac4ed55fda4fa06f88ed73e52f76747861 100644 (file)
@@ -3350,8 +3350,11 @@ opj_bool j2k_read_sot_v2 (
        };
 #endif /* USE_JPWL */
 
+       /* Ref A.4.2: Psot could be equal zero if it is the last tile-part of the codestream.*/
        if (!l_tot_len) {
-               opj_event_msg_v2(p_manager, EVT_ERROR, "Cannot read data with no size known, giving up\n");
+               opj_event_msg_v2(p_manager, EVT_ERROR, "Psot value of the current tile-part is equal to zero, "
+                               "for the moment we couldn't manage this case (need to compute the number of byte left"
+                               " in the codestream).\n");
                return OPJ_FALSE;
        }
 
@@ -3368,6 +3371,7 @@ opj_bool j2k_read_sot_v2 (
                        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 );
+                               p_j2k->m_specific_param.m_decoder.m_last_tile_part = 1;
                                return OPJ_FALSE;
                        }
                }
@@ -3381,8 +3385,15 @@ opj_bool j2k_read_sot_v2 (
                }
        }
 
-       /* Keep the size of data to skip after this marker */
-       p_j2k->m_specific_param.m_decoder.m_sot_length = l_tot_len - 12; /* SOT_marker_size = 12 */
+       if (!p_j2k->m_specific_param.m_decoder.m_last_tile_part){
+               /* Keep the size of data to skip after this marker */
+               p_j2k->m_specific_param.m_decoder.m_sot_length = l_tot_len - 12; /* SOT_marker_size = 12 */
+       }
+       else {
+               /* FIXME: need to be computed from the number of bytes remaining in the codestream */
+               p_j2k->m_specific_param.m_decoder.m_sot_length = 0;
+       }
+
        p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPH;
 
        /* Check if the current tile is outside the area we want decode (in tile index)*/
index 6b63222fe2d2a9132b3c87227851fdf9d2f658e8..270232aa0407fbb49fd58dd4820348349e7a2c6c 100644 (file)
@@ -632,6 +632,12 @@ typedef struct opj_j2k_dec
        OPJ_UINT32 m_start_tile_y;
        OPJ_UINT32 m_end_tile_x;
        OPJ_UINT32 m_end_tile_y;
+       /**
+        * Indicate that the current tile-part is assume as the last tile part of the codestream.
+        * It is useful in the case of PSot is equal to zero. The sot length will be compute in the
+        * SOD reader function. FIXME NOT USED for the moment
+        */
+       opj_bool   m_last_tile_part;
        /** to tell that a tile can be decoded. */
        OPJ_UINT32 m_can_decode                 : 1;
        OPJ_UINT32 m_discard_tiles              : 1;