Skip to content

Commit

Permalink
Merge pull request #1121 from rouault/fix_tnsot_zero
Browse files Browse the repository at this point in the history
Fix regression in reading files with TNsot == 0 (refs #1120)
  • Loading branch information
rouault authored Jun 20, 2018
2 parents fd205f4 + 4170681 commit d2205ba
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/lib/openjp2/j2k.c
Original file line number Diff line number Diff line change
Expand Up @@ -4094,7 +4094,12 @@ static OPJ_BOOL opj_j2k_merge_ppt(opj_tcp_t *p_tcp, opj_event_mgr_t * p_manager)
/* preconditions */
assert(p_tcp != 00);
assert(p_manager != 00);
assert(p_tcp->ppt_buffer == NULL);

if (p_tcp->ppt_buffer != NULL) {
opj_event_msg(p_manager, EVT_ERROR,
"opj_j2k_merge_ppt() has already been called\n");
return OPJ_FALSE;
}

if (p_tcp->ppt == 0U) {
return OPJ_TRUE;
Expand Down Expand Up @@ -8845,7 +8850,10 @@ OPJ_BOOL opj_j2k_read_tile_header(opj_j2k_t * p_j2k,

/* Current marker is the EOC marker ?*/
if (l_current_marker == J2K_MS_EOC) {
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_EOC;
if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_EOC) {
p_j2k->m_current_tile_number = 0;
p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_EOC;
}
}

/* FIXME DOC ???*/
Expand Down
3 changes: 2 additions & 1 deletion tests/nonregression/md5refs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,5 @@ ac8f6ab3acc9c692ed7c41bd62a0e1e8 file1.jp2-c0-r1.tif
fbfcf662b6f7549574b2885490fbcf12 file1.jp2-c0-d10_20_30_40.tif
fa7382fd8b2e788b28b807e200dd95b9 file1.jp2-c0-t0.tif
ac8f6ab3acc9c692ed7c41bd62a0e1e8 file1.jp2-c0-t0-r1.tif
f31bcb01c771f829054cdb013575e86a issue1043.png
f31bcb01c771f829054cdb013575e86a issue1043.png
62bc654c830efddf1b23d6e208447dab tnsot_zero.png
5 changes: 5 additions & 0 deletions tests/nonregression/test_suite.ctest.in
Original file line number Diff line number Diff line change
Expand Up @@ -625,3 +625,8 @@ opj_decompress -i @INPUT_CONF_PATH@/file1.jp2 -o @TEMP_PATH@/file1.jp2-c0-t0-r1.
!opj_decompress -i @INPUT_CONF_PATH@/file1.jp2 -o @TEMP_PATH@/file1.jp2-c10.tif -c 10

opj_decompress -i @INPUT_NR_PATH@/db11217111510058.jp2 -o @TEMP_PATH@/issue1043.png

opj_decompress -i @INPUT_NR_PATH@/tnsot_zero.jp2 -o @TEMP_PATH@/tnsot_zero.png

# try to decompress file with repeated PPT marker
!opj_decompress -i @INPUT_NR_PATH@/oss-fuzz2785.jp2 -o @TEMP_PATH@/oss-fuzz2785.png
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ NR-DEC-kodak_2layers_lrcp.j2c-31-decode-md5
NR-DEC-kodak_2layers_lrcp.j2c-32-decode-md5
NR-DEC-issue135.j2k-68-decode-md5
NR-DEC-db11217111510058.jp2-306-decode-md5
NR-DEC-tnsot_zero.jp2-307-decode-md5
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ NR-DEC-kodak_2layers_lrcp.j2c-31-decode-md5
NR-DEC-kodak_2layers_lrcp.j2c-32-decode-md5
NR-DEC-issue135.j2k-68-decode-md5
NR-DEC-db11217111510058.jp2-306-decode-md5
NR-DEC-tnsot_zero.jp2-307-decode-md5
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ NR-DEC-kodak_2layers_lrcp.j2c-31-decode-md5
NR-DEC-kodak_2layers_lrcp.j2c-32-decode-md5
NR-DEC-issue135.j2k-68-decode-md5
NR-DEC-db11217111510058.jp2-306-decode-md5
NR-DEC-tnsot_zero.jp2-307-decode-md5
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ NR-DEC-kodak_2layers_lrcp.j2c-31-decode-md5
NR-DEC-kodak_2layers_lrcp.j2c-32-decode-md5
NR-DEC-issue135.j2k-68-decode-md5
NR-DEC-db11217111510058.jp2-306-decode-md5
NR-DEC-tnsot_zero.jp2-307-decode-md5

0 comments on commit d2205ba

Please sign in to comment.