[trunk] WIP: correct mistake with JP2 files and manage correctly the text_GBR.jp2 filecase

This commit is contained in:
Mickael Savinaud 2011-10-11 07:49:16 +00:00
parent 7c87bb35c4
commit c7d3b83164
5 changed files with 20 additions and 13 deletions

View File

@ -5,6 +5,9 @@ What's New for OpenJPEG
! : changed
+ : added
October 11, 2011
* [mickael] WIP: correct mistake with JP2 files and manage correctly the text_GBR.jp2 filecase.
October 10, 2011
* [vincent] fix 'distcheck' rule
+ [vincent] add libopenjpeg-jpwl.pc.in

View File

@ -579,8 +579,6 @@ int main(int argc, char **argv)
opj_image_t image;
opj_stream_t *cio = NULL; /* Stream */
opj_codec_t* dinfo = NULL; /* Handle to a decompressor */
opj_bool bRes1, bRes2;
char indexfilename[OPJ_PATH_LEN]; /* index file name */
@ -713,13 +711,8 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
/* Get the decoded image */
bRes1 = opj_decode_v2(dinfo, cio, &image);
bRes2 = opj_end_decompress(dinfo,cio);
/*if ( !(opj_decode_v2(dinfo, cio, &image)) || !(opj_end_decompress(dinfo,cio)) ) {*/
if ( !bRes1 || !bRes2) {
if ( !( opj_decode_v2(dinfo, cio, &image) && opj_end_decompress(dinfo,cio) ) ) {
fprintf(stderr, "ERROR -> j2k_to_image: failed to decode image!\n");
opj_destroy_codec(dinfo);
opj_stream_destroy(cio);

View File

@ -3362,6 +3362,15 @@ opj_bool j2k_read_sot_v2 (
++p_header_data;
if (l_num_parts != 0) { /* Number of tile-part header is provided by this tile-part header */
/* Useful to manage the case of textGBR.jp2 file because two values of TNSot are allowed: the correct numbers of
* tile-parts for that tile and zero (A.4.2 of 15444-1 : 2002). */
if (l_tcp->m_nb_tile_parts) {
if (l_current_part >= l_tcp->m_nb_tile_parts){
opj_event_msg_v2(p_manager, EVT_ERROR, "In SOT marker, TPSot (%d) is not valid regards to the current "
"number of tile-part (%d), giving up\n", l_current_part, l_tcp->m_nb_tile_parts );
return OPJ_FALSE;
}
}
l_tcp->m_nb_tile_parts = l_num_parts;
}
@ -5709,7 +5718,7 @@ opj_bool j2k_read_tile_header( opj_j2k_v2_t * p_j2k,
/* Read the marker segment with the correct marker handler */
if (! (*(l_marker_handler->handler))(p_j2k,p_j2k->m_specific_param.m_decoder.m_header_data,l_marker_size,p_manager)) {
opj_event_msg_v2(p_manager, EVT_ERROR, "Marker is not compliant with its position\n");
opj_event_msg_v2(p_manager, EVT_ERROR, "Fail to read the current marker segment (%#x)\n", l_current_marker);
return OPJ_FALSE;
}

View File

@ -1490,8 +1490,8 @@ opj_bool opj_jp2_decode_v2( opj_jp2_v2_t *jp2,
struct opj_event_mgr * p_manager)
{
/* J2K decoding */
if( j2k_decode_v2(jp2->j2k, cio, p_image, p_manager) ) {
opj_event_msg_v2(p_manager, EVT_ERROR, "Failed to decode J2K image\n");
if( ! j2k_decode_v2(jp2->j2k, cio, p_image, p_manager) ) {
opj_event_msg_v2(p_manager, EVT_ERROR, "Failed to decode the codestream in the JP2 file\n");
return OPJ_FALSE;
}
@ -1521,6 +1521,7 @@ opj_bool opj_jp2_decode_v2( opj_jp2_v2_t *jp2,
if(jp2->color.icc_profile_buf) {
p_image->icc_profile_buf = jp2->color.icc_profile_buf;
p_image->icc_profile_len = jp2->color.icc_profile_len;
jp2->color.icc_profile_buf = NULL;
}
return OPJ_TRUE;

View File

@ -10,7 +10,7 @@
# image to base)
#
# Line begin with ! should failed (should be used for bad jpeg2000 file which should be
# gracefully rejected)
# gracefully rejected). Please add a short resume about why this file should be rejected.
#
# You can use @INPUT_NR_PATH@ and @TEMP_PATH@ cmake variable which refers to OPJ_DATA_ROOT
# repository. However you can use relative path or absolute path.
@ -60,4 +60,5 @@ j2k_to_image -i @INPUT_NR_PATH@/orb-blue10-win-j2k.j2k -o @TEMP_PATH@/orb-blue1
j2k_to_image -i @INPUT_NR_PATH@/orb-blue10-win-jp2.jp2 -o @TEMP_PATH@/orb-blue10-win-jp2.jp2.pgx
j2k_to_image -i @INPUT_NR_PATH@/relax.jp2 -o @TEMP_PATH@/relax.jp2.pgx
j2k_to_image -i @INPUT_NR_PATH@/test_lossless.j2k -o @TEMP_PATH@/test_lossless.j2k.pgx
j2k_to_image -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.
!j2k_to_image -i @INPUT_NR_PATH@/text_GBR.jp2 -o @TEMP_PATH@/text_GBR.jp2.pgx