};
#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;
}
++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 );
+ p_j2k->m_specific_param.m_decoder.m_last_tile_part = 1;
+ return OPJ_FALSE;
+ }
+ }
l_tcp->m_nb_tile_parts = l_num_parts;
}
}
}
- /* 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)*/
/* 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;
}
if (p_end_y < l_cp->ty0) {
opj_event_msg_v2(p_manager, EVT_ERROR,
"Right position of the decoded area (ROI_y1=%d) is outside the tile area (YTOsiz=%d).\n",
- p_end_x, l_cp->ty0);
+ p_end_y, l_cp->ty0);
return OPJ_FALSE;
}
if (p_end_y > l_cp->ty0 + l_cp->th * l_cp->tdy){