[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 */ /* Copy codestream image information to the output image */
opj_copy_image_header(p_j2k->m_private_image, *p_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; return OPJ_TRUE;
} }
@ -11260,6 +11264,15 @@ void j2k_dump_MH_index(opj_j2k_v2_t* p_j2k, FILE* out_stream)
if (cstr_index->tile_index){ if (cstr_index->tile_index){
/* 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;
}
if (l_acc_nb_of_tile_part)
{
fprintf(out_stream, "\t Tile index: {\n"); fprintf(out_stream, "\t Tile index: {\n");
for (it_tile=0; it_tile < cstr_index->nb_of_tiles ; it_tile++){ for (it_tile=0; it_tile < cstr_index->nb_of_tiles ; it_tile++){
@ -11288,6 +11301,7 @@ void j2k_dump_MH_index(opj_j2k_v2_t* p_j2k, FILE* out_stream)
} }
fprintf(out_stream,"\t }\n"); fprintf(out_stream,"\t }\n");
} }
}
fprintf(out_stream,"}\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; 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) { while (OPJ_TRUE) {
if (! j2k_read_tile_header( p_j2k, if (! j2k_read_tile_header( p_j2k,