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:
parent
003759a482
commit
297f202104
|
@ -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");
|
opj_event_msg(p_manager, EVT_ERROR, "Error reading SOT marker\n");
|
||||||
return OPJ_FALSE;
|
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);
|
l_cp = &(p_j2k->m_cp);
|
||||||
|
|
||||||
|
@ -4318,23 +4322,31 @@ 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_x = p_j2k->m_current_tile_number % l_cp->tw;
|
||||||
l_tile_y = p_j2k->m_current_tile_number / l_cp->tw;
|
l_tile_y = p_j2k->m_current_tile_number / l_cp->tw;
|
||||||
|
|
||||||
/* Fixes issue with id_000020,sig_06,src_001958,op_flip4,pos_149 */
|
if (p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec < 0 ||
|
||||||
/* of https://github.com/uclouvain/openjpeg/issues/939 */
|
p_j2k->m_current_tile_number == (OPJ_UINT32)
|
||||||
/* We must avoid reading twice the same tile part number for a given tile */
|
p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec) {
|
||||||
/* so as to avoid various issues, like opj_j2k_merge_ppt being called */
|
/* Do only this check if we decode all tile part headers, or if */
|
||||||
/* several times. */
|
/* we decode one precise tile. Otherwise the m_current_tile_part_number */
|
||||||
/* ISO 15444-1 A.4.2 Start of tile-part (SOT) mandates that tile parts */
|
/* might not be valid */
|
||||||
/* should appear in increasing order. */
|
/* Fixes issue with id_000020,sig_06,src_001958,op_flip4,pos_149 */
|
||||||
if (l_tcp->m_current_tile_part_number + 1 != (OPJ_INT32)l_current_part) {
|
/* of https://github.com/uclouvain/openjpeg/issues/939 */
|
||||||
opj_event_msg(p_manager, EVT_ERROR,
|
/* We must avoid reading twice the same tile part number for a given tile */
|
||||||
"Invalid tile part index for tile number %d. "
|
/* so as to avoid various issues, like opj_j2k_merge_ppt being called */
|
||||||
"Got %d, expected %d\n",
|
/* several times. */
|
||||||
p_j2k->m_current_tile_number,
|
/* ISO 15444-1 A.4.2 Start of tile-part (SOT) mandates that tile parts */
|
||||||
l_current_part,
|
/* should appear in increasing order. */
|
||||||
l_tcp->m_current_tile_part_number + 1);
|
if (l_tcp->m_current_tile_part_number + 1 != (OPJ_INT32)l_current_part) {
|
||||||
return OPJ_FALSE;
|
opj_event_msg(p_manager, EVT_ERROR,
|
||||||
|
"Invalid tile part index for tile number %d. "
|
||||||
|
"Got %d, expected %d\n",
|
||||||
|
p_j2k->m_current_tile_number,
|
||||||
|
l_current_part,
|
||||||
|
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
|
#ifdef USE_JPWL
|
||||||
if (l_cp->correct) {
|
if (l_cp->correct) {
|
||||||
|
|
Loading…
Reference in New Issue