[trunk] move allocation of cstr_index->tile_index to the end of the header reading

This commit is contained in:
Mickael Savinaud 2012-08-09 11:12:28 +00:00
parent c38b5d5eb9
commit 28ac2f49dc
1 changed files with 38 additions and 28 deletions

View File

@ -8951,6 +8951,10 @@ opj_bool j2k_read_header( struct opj_stream_private *p_stream,
/* Copy codestream image information to the output image */
opj_copy_image_header(p_j2k->m_private_image, *p_image);
/*Allocate and initialize some elements of codestrem index*/
if (!j2k_allocate_tile_element_cstr_index(p_j2k)){
return OPJ_FALSE;
}
return OPJ_TRUE;
}
@ -11260,33 +11264,43 @@ void j2k_dump_MH_index(opj_j2k_v2_t* p_j2k, FILE* out_stream)
if (cstr_index->tile_index){
fprintf(out_stream, "\t Tile index: {\n");
for (it_tile=0; it_tile < cstr_index->nb_of_tiles ; it_tile++){
OPJ_UINT32 nb_of_tile_part = cstr_index->tile_index[it_tile].nb_tps;
/* Simple test to avoid to write empty information*/
OPJ_UINT32 l_acc_nb_of_tile_part = 0;
for (it_tile=0; it_tile < cstr_index->nb_of_tiles ; it_tile++){
l_acc_nb_of_tile_part += cstr_index->tile_index[it_tile].nb_tps;
}
fprintf(out_stream, "\t\t nb of tile-part in tile [%d]=%d\n", it_tile, nb_of_tile_part);
if (l_acc_nb_of_tile_part)
{
fprintf(out_stream, "\t Tile index: {\n");
for (it_tile=0; it_tile < cstr_index->nb_of_tiles ; it_tile++){
OPJ_UINT32 nb_of_tile_part = cstr_index->tile_index[it_tile].nb_tps;
if (cstr_index->tile_index[it_tile].tp_index){
for (it_tile_part =0; it_tile_part < nb_of_tile_part; it_tile_part++){
fprintf(out_stream, "\t\t\t tile-part[%d]: star_pos=%" PRIi64 ", end_header=%" PRIi64 ", end_pos=%" PRIi64 ".\n",
it_tile_part,
cstr_index->tile_index[it_tile].tp_index[it_tile_part].start_pos,
cstr_index->tile_index[it_tile].tp_index[it_tile_part].end_header,
cstr_index->tile_index[it_tile].tp_index[it_tile_part].end_pos);
}
}
fprintf(out_stream, "\t\t nb of tile-part in tile [%d]=%d\n", it_tile, nb_of_tile_part);
if (cstr_index->tile_index[it_tile].marker){
for (it_marker=0; it_marker < cstr_index->tile_index[it_tile].marknum ; it_marker++){
fprintf(out_stream, "\t\t type=%#x, pos=%" PRIi64 ", len=%d\n",
cstr_index->tile_index[it_tile].marker[it_marker].type,
cstr_index->tile_index[it_tile].marker[it_marker].pos,
cstr_index->tile_index[it_tile].marker[it_marker].len );
}
}
}
fprintf(out_stream,"\t }\n");
if (cstr_index->tile_index[it_tile].tp_index){
for (it_tile_part =0; it_tile_part < nb_of_tile_part; it_tile_part++){
fprintf(out_stream, "\t\t\t tile-part[%d]: star_pos=%" PRIi64 ", end_header=%" PRIi64 ", end_pos=%" PRIi64 ".\n",
it_tile_part,
cstr_index->tile_index[it_tile].tp_index[it_tile_part].start_pos,
cstr_index->tile_index[it_tile].tp_index[it_tile_part].end_header,
cstr_index->tile_index[it_tile].tp_index[it_tile_part].end_pos);
}
}
if (cstr_index->tile_index[it_tile].marker){
for (it_marker=0; it_marker < cstr_index->tile_index[it_tile].marknum ; it_marker++){
fprintf(out_stream, "\t\t type=%#x, pos=%" PRIi64 ", len=%d\n",
cstr_index->tile_index[it_tile].marker[it_marker].type,
cstr_index->tile_index[it_tile].marker[it_marker].pos,
cstr_index->tile_index[it_tile].marker[it_marker].len );
}
}
}
fprintf(out_stream,"\t }\n");
}
}
fprintf(out_stream,"}\n");
@ -11658,11 +11672,7 @@ opj_bool j2k_decode_tiles ( opj_j2k_v2_t *p_j2k,
}
l_max_data_size = 1000;
/*Allocate and initialize some elements of codestrem index*/
if (!j2k_allocate_tile_element_cstr_index(p_j2k)){
opj_free(l_current_data);
return OPJ_FALSE;
}
while (OPJ_TRUE) {
if (! j2k_read_tile_header( p_j2k,