[trunk] WIP: add get_decoded_tile functionality

This commit is contained in:
Mickael Savinaud
2011-11-08 13:21:17 +00:00
parent 9110aa09a4
commit bd8bca87b2
9 changed files with 427 additions and 134 deletions

View File

@@ -525,77 +525,6 @@ int main(int argc, char *argv[])
cstr_index = opj_get_cstr_index(dinfo);
#ifdef MSD
fprintf(stdout,"Setting decoding area to %d,%d,%d,%d\n",
parameters.DA_x0, parameters.DA_y0, parameters.DA_x1, parameters.DA_y1);
/* FIXME WIP_MSD <*/
if (! opj_set_decode_area( dinfo,
parameters.DA_x0, parameters.DA_y0,
parameters.DA_x1, parameters.DA_y1)){
fprintf(stderr, "ERROR -> j2k_dump: failed to set the decoded area\n");
opj_stream_destroy(cio);
opj_destroy_codec(dinfo);
fclose(fsrc);
fclose(fout);
return EXIT_FAILURE;
}
while (l_go_on) {
OPJ_INT32 l_current_tile_x0,l_current_tile_y0,l_current_tile_x1,l_current_tile_y1;
OPJ_UINT32 l_nb_comps, l_tile_index, l_data_size;
if (! opj_read_tile_header( dinfo,
cio,
&l_tile_index,
&l_data_size,
&l_current_tile_x0,
&l_current_tile_y0,
&l_current_tile_x1,
&l_current_tile_y1,
&l_nb_comps,
&l_go_on
)) {
fprintf(stderr, "ERROR -> j2k_dump: failed read the tile header\n");
opj_stream_destroy(cio);
fclose(fsrc);
opj_destroy_codec(dinfo);
return EXIT_FAILURE;
}
if (l_go_on) {
if (l_data_size > l_max_data_size) {
l_data = (OPJ_BYTE *) realloc(l_data,l_data_size);
if (! l_data) {
opj_stream_destroy(cio);
opj_destroy_codec(dinfo);
fclose(fsrc);
fclose(fout);
return EXIT_FAILURE;
}
l_max_data_size = l_data_size;
}
if (! opj_decode_tile_data(dinfo,l_tile_index,l_data,l_data_size,cio))
{
free(l_data);
opj_stream_destroy(cio);
opj_destroy_codec(dinfo);
fclose(fsrc);
fclose(fout);
return EXIT_FAILURE;
}
/** now should inspect image to know the reduction factor and then how to behave with data */
}
}
/* FIXME WIP_MSD >*/
#endif
/* close the byte stream */
opj_stream_destroy(cio);
fclose(fsrc);