Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/lib/openjp2/j2k.c
Original file line number Diff line number Diff line change
Expand Up @@ -12185,10 +12185,17 @@ static OPJ_BOOL opj_j2k_decode_one_tile(opj_j2k_t *p_j2k,
if (p_j2k->cstr_index->tile_index)
if (p_j2k->cstr_index->tile_index->tp_index) {
if (! p_j2k->cstr_index->tile_index[l_tile_no_to_dec].nb_tps) {
/* the index for this tile has not been built,
* so move to the last SOT read */
/* The index for this tile has not been built. This happens */
/* when the tile's tile-parts are interleaved with other */
/* tiles' tile-parts and the number of tile-parts (TNsot) was */
/* only declared in a tile-part not reached while decoding a */
/* previous tile. In that case we cannot rely on the recorded */
/* SOT positions, nor on m_last_sot_read_pos (which may point */
/* past the first tile-part of the requested tile), so seek */
/* back to the start of the codestream and read the tile-part */
/* headers in order. See issue #1558. */
if (!(opj_stream_read_seek(p_stream,
p_j2k->m_specific_param.m_decoder.m_last_sot_read_pos + 2, p_manager))) {
p_j2k->cstr_index->main_head_end + 2, p_manager))) {
opj_event_msg(p_manager, EVT_ERROR, "Problem with seek function\n");
return OPJ_FALSE;
}
Expand Down
7 changes: 7 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ add_executable(compare_dump_files ${compare_dump_files_SRCS})
add_executable(j2k_random_tile_access j2k_random_tile_access.c)
target_link_libraries(j2k_random_tile_access ${OPENJPEG_LIBRARY_NAME})

add_executable(test_tile_part_interleaved test_tile_part_interleaved.c)
target_link_libraries(test_tile_part_interleaved ${OPENJPEG_LIBRARY_NAME})

add_executable(compare_raw_files ${compare_raw_files_SRCS})

add_executable(test_tile_encoder test_tile_encoder.c)
Expand Down Expand Up @@ -83,6 +86,10 @@ set_property(TEST rta4 APPEND PROPERTY DEPENDS tte4)
add_test(NAME rta5 COMMAND j2k_random_tile_access tte5.j2k)
set_property(TEST rta5 APPEND PROPERTY DEPENDS tte5)

# Non-regression test for issue #1558: tile-by-tile decoding of a codestream
# whose tile-parts are interleaved across tiles (self-contained, no test data).
add_test(NAME rta_interleaved_tile_parts COMMAND test_tile_part_interleaved)

add_test(NAME tda_prep_reversible_no_precinct COMMAND test_tile_encoder 1 256 256 32 32 8 0 reversible_no_precinct.j2k 4 4 3 0 0 1)
add_test(NAME tda_reversible_no_precinct COMMAND test_decode_area -q reversible_no_precinct.j2k)
set_property(TEST tda_reversible_no_precinct APPEND PROPERTY DEPENDS tda_prep_reversible_no_precinct)
Expand Down
Loading
Loading