Fix 2.2.0 regression when reading codestream with reperated calls to opj_get_decoded_tile() where tile parts of a same tile are not consecutive

This check was introduced per #939, but relied on the incorrect assumption
we decode all the tile parts of all tiles.
This commit is contained in:
Even Rouault 2017-09-06 16:49:28 +02:00
parent 003759a482
commit 297f202104
1 changed files with 28 additions and 16 deletions

View File

@ -4304,6 +4304,10 @@ static OPJ_BOOL opj_j2k_read_sot(opj_j2k_t *p_j2k,
opj_event_msg(p_manager, EVT_ERROR, "Error reading SOT marker\n");
return OPJ_FALSE;
}
#ifdef DEBUG_VERBOSE
fprintf(stderr, "SOT %d %d %d %d\n",
p_j2k->m_current_tile_number, l_tot_len, l_current_part, l_num_parts);
#endif
l_cp = &(p_j2k->m_cp);
@ -4318,6 +4322,12 @@ static OPJ_BOOL opj_j2k_read_sot(opj_j2k_t *p_j2k,
l_tile_x = p_j2k->m_current_tile_number % l_cp->tw;
l_tile_y = p_j2k->m_current_tile_number / l_cp->tw;
if (p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec < 0 ||
p_j2k->m_current_tile_number == (OPJ_UINT32)
p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec) {
/* Do only this check if we decode all tile part headers, or if */
/* we decode one precise tile. Otherwise the m_current_tile_part_number */
/* might not be valid */
/* Fixes issue with id_000020,sig_06,src_001958,op_flip4,pos_149 */
/* of https://github.com/uclouvain/openjpeg/issues/939 */
/* We must avoid reading twice the same tile part number for a given tile */
@ -4334,7 +4344,9 @@ static OPJ_BOOL opj_j2k_read_sot(opj_j2k_t *p_j2k,
l_tcp->m_current_tile_part_number + 1);
return OPJ_FALSE;
}
++ l_tcp->m_current_tile_part_number;
}
l_tcp->m_current_tile_part_number = (OPJ_INT32) l_current_part;
#ifdef USE_JPWL
if (l_cp->correct) {