/* Try to read until the Start Of Data is detected */
while (l_current_marker != J2K_MS_SOD) {
+
+ if(opj_stream_get_number_byte_left(p_stream) == 0)
+ {
+ p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC;
+ break;
+ }
/* Try to read 2 bytes (the marker size) from stream and copy them into the buffer */
if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != 2) {
opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2);
}
}
+ if(opj_stream_get_number_byte_left(p_stream) == 0
+ && p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NEOC)
+ break;
/* If we didn't skip data before, we need to read the SOD marker*/
if (! p_j2k->m_specific_param.m_decoder.m_skip_data) {
p_j2k->m_specific_param.m_decoder.m_can_decode = 0;
p_j2k->m_specific_param.m_decoder.m_state &= (~ (0x0080));/* FIXME J2K_DEC_STATE_DATA);*/
+ if(opj_stream_get_number_byte_left(p_stream) == 0
+ && p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NEOC){
+ return OPJ_TRUE;
+ }
+
if (p_j2k->m_specific_param.m_decoder.m_state != 0x0100){ /*FIXME J2K_DEC_STATE_EOC)*/
if (opj_stream_read_data(p_stream,l_data,2,p_manager) != 2) {
opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n");
else if (l_current_marker != J2K_MS_SOT)
{
opj_event_msg(p_manager, EVT_ERROR, "Stream too short, expected SOT\n");
+
+ if(opj_stream_get_number_byte_left(p_stream) == 0) {
+ p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC;
+ return OPJ_TRUE;
+ }
return OPJ_FALSE;
}
}
OPJ_INT32 l_tile_x0,l_tile_y0,l_tile_x1,l_tile_y1;
OPJ_UINT32 l_nb_comps;
OPJ_BYTE * l_current_data;
+ OPJ_UINT32 nr_tiles = 0;
l_current_data = (OPJ_BYTE*)opj_malloc(1000);
if (! l_current_data) {
return OPJ_FALSE;
}
opj_event_msg(p_manager, EVT_INFO, "Image data has been updated with tile %d.\n\n", l_current_tile_no + 1);
-
+
+ if(opj_stream_get_number_byte_left(p_stream) == 0
+ && p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NEOC)
+ break;
+ if(++nr_tiles == p_j2k->m_cp.th * p_j2k->m_cp.tw)
+ break;
}
opj_free(l_current_data);
opj_decompress -i @INPUT_NR_PATH@/orb-blue10-win-jp2.jp2 -o @TEMP_PATH@/orb-blue10-win-jp2.jp2.pgx
opj_decompress -i @INPUT_NR_PATH@/relax.jp2 -o @TEMP_PATH@/relax.jp2.pgx
opj_decompress -i @INPUT_NR_PATH@/test_lossless.j2k -o @TEMP_PATH@/test_lossless.j2k.pgx
-# text_GBR.jp2 file exhibt a error about a tile part with a index > of the number of tile-part in this tile.
-!opj_decompress -i @INPUT_NR_PATH@/text_GBR.jp2 -o @TEMP_PATH@/text_GBR.jp2.pgx
+# text_GBR.jp2 file exhibt a error about a tile part with a index > of the number of tile-part in this tile (related to issue 202, 206, 208)
+opj_decompress -i @INPUT_NR_PATH@/text_GBR.jp2 -o @TEMP_PATH@/text_GBR.jp2.pgx
# pacs.ge file should throw an error but finally it seems work with v2
opj_decompress -i @INPUT_NR_PATH@/pacs.ge.j2k -o @TEMP_PATH@/pacs.ge.j2k.pgx
# related to issue 135
opj_decompress -i @INPUT_NR_PATH@/issue104_jpxstream.jp2 -o @TEMP_PATH@/issue104_jpxstream.jp2.pgx
# File not supported by kakadu (Malformed PCLR box) and not supoprter by openjpeg (problem with value of TPSot)
opj_decompress -i @INPUT_NR_PATH@/mem-b2ace68c-1381.jp2 -o @TEMP_PATH@/mem-b2ace68c-1381.jp2.pgx
-# File which produced weird output with kakadu and not supoprter by openjpeg (problem with value of TPSot)
+# File which produced weird output with kakadu and not supoprter by openjpeg (problem with value of TPSot, issue 202, 206, 208)
opj_decompress -i @INPUT_NR_PATH@/mem-b2b86b74-2753.jp2 -o @TEMP_PATH@/mem-b2b86b74-2753.jp2.pgx
# issue 191 raised by the gdal fuzzer test (should properly failed)
!opj_decompress -i @INPUT_NR_PATH@/gdal_fuzzer_unchecked_numresolutions.jp2 -o @TEMP_PATH@/gdal_fuzzer_unchecked_numresolutions.pgx
opj_decompress -i @INPUT_NR_PATH@/file409752.jp2 -o @TEMP_PATH@/file409752.png
# issue 188
opj_decompress -i @INPUT_NR_PATH@/issue188_beach_64bitsbox.jp2 -o @TEMP_PATH@/issue188_beach_64bitsbox.jp2.tif
+# issue 206
+opj_decompress -i @INPUT_NR_PATH@/issue206_image-000.jp2 -o @TEMP_PATH@/issue206_image-000.jp2.png
# decode with specific area
# prec=12; nb_c=1