}
/* -------------------------------------------------------------------------- */
-static void j2k_dump_image(FILE *fd, opj_image_t * img);
-static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp);
+static void j2k_dump_image(FILE *fd, opj_image_header_t * img);
+static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_v2_t * cp);
int get_num_images(char *imgdirpath){
DIR *dir;
}
/* -------------------------------------------------------------------------- */
-int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol, char *indexfilename) {
+int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,img_fol_t *img_fol) {
/* parse the command line */
int totlen, c;
opj_option_t long_option[]={
};
const char optlist[] = "i:o:h";
- OPJ_ARG_NOT_USED(indexfilename);
-
totlen=sizeof(long_option);
img_fol->set_out_format = 0;
do {
opj_dparameters_t parameters; /* decompression parameters */
img_fol_t img_fol;
opj_event_mgr_t event_mgr; /* event manager */
- opj_image_t *image = NULL;
+ opj_image_header_t* image = NULL;
FILE *fsrc = NULL, *fout = NULL;
opj_bool bResult;
int num_images;
dircnt_t *dirptr = NULL;
opj_codec_t* dinfo = NULL; /* handle to a decompressor */
opj_stream_t *cio = NULL;
- opj_codestream_info_t cstr_info; /* Codestream information structure */
- char indexfilename[OPJ_PATH_LEN]; /* index file name */
- OPJ_INT32 l_tile_x0,l_tile_y0;
- OPJ_UINT32 l_tile_width,l_tile_height,l_nb_tiles_x,l_nb_tiles_y;
+ opj_codestream_info_t* cstr_info =NULL; /* Codestream information structure */
+ //OPJ_INT32 l_tile_x0,l_tile_y0;
+ //OPJ_UINT32 l_tile_width,l_tile_height,l_nb_tiles_x,l_nb_tiles_y;
/* FIXME configure the event callbacks (not required) */
/* set decoding parameters to default values */
opj_set_default_decoder_parameters(¶meters);
- /* Initialize indexfilename and img_fol */
- *indexfilename = 0;
+ /* Initialize img_fol */
memset(&img_fol,0,sizeof(img_fol_t));
/* parse input and get user encoding parameters */
- if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol, indexfilename) == 1) {
+ if(parse_cmdline_decoder(argc, argv, ¶meters,&img_fol) == 1) {
return EXIT_FAILURE;
}
if(!dirptr->filename_buf){
return EXIT_FAILURE;
}
+
for(i=0;i<num_images;i++){
dirptr->filename[i] = dirptr->filename_buf + i*OPJ_PATH_LEN;
}
if(load_images(dirptr,img_fol.imgdirpath)==1){
return EXIT_FAILURE;
}
+
if (num_images==0){
fprintf(stdout,"Folder is empty\n");
return EXIT_FAILURE;
if (parameters.outfile[0] != 0){
fout = fopen(parameters.outfile,"w");
if (!fout){
- fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.outfile);
+ fprintf(stderr, "ERROR -> failed to open %s for writing\n", parameters.outfile);
return EXIT_FAILURE;
}
}
else
fout = stdout;
- /*Encoding image one by one*/
+ /*Read the header of each image one by one*/
for(imageno = 0; imageno < num_images ; imageno++){
image = NULL;
fprintf(stderr,"\n");
}
}
-/*NEW V2 STYLE*/
+ /*NEW V2 STYLE*/
/* read the input file and put it in memory */
/* ---------------------------------------- */
fsrc = fopen(parameters.infile, "rb");
return EXIT_FAILURE;
}
-
cio = opj_stream_create_default_file_stream(fsrc,1);
-
/* decode the code-stream */
/* ---------------------- */
continue;
}
- /* FIXME catch events using our callbacks and give a local context */
- //opj_set_event_mgr_v2(dinfo, &event_mgr, stderr);
-
-
-
/* setup the decoder decoding parameters using user parameters */
opj_setup_decoder_v2(dinfo, ¶meters, &event_mgr);
image = opj_decode_with_info(dinfo, cio, &cstr_info);
else
*/
- bResult = opj_read_header( dinfo,
+ //opj_codestream_info_t *cstr_info = NULL;
+
+ /*bResult = opj_read_header( dinfo,
&image,
&l_tile_x0,
&l_tile_y0,
&l_tile_height,
&l_nb_tiles_x,
&l_nb_tiles_y,
- cio);
+ cio);*/
+
+ bResult = opj_read_header(cio, dinfo, &image, &cstr_info);
if(!bResult){
fprintf(stderr, "ERROR -> j2k_to_image: failed to read header\n");
/* dump image */
j2k_dump_image(fout, image);
/* dump cp */
- //j2k_dump_cp(stdout, image, dinfo->m_codec);
+ //j2k_dump_cp(stdout, image, ((opj_codec_private_t)dinfo)->m_codec);
//j2k_dump_cp(fout, image, ((opj_j2k_t*)dinfo->j2k_handle)->cp);
}
else if (parameters.decod_format == JP2_CFMT){
fclose(fsrc);
/* Write the index to disk */
- if (*indexfilename) {
+ /*if (*indexfilename) {
char bSuccess;
bSuccess = write_index_file(&cstr_info, indexfilename);
if (bSuccess) {
else
ret = EXIT_SUCCESS;
}
- else
+ else*/
ret = EXIT_SUCCESS;
/* free remaining structures */
opj_destroy_codec(dinfo);
}
/* free codestream information structure */
- if (*indexfilename)
- opj_destroy_cstr_info(&cstr_info);
+ /*if (*indexfilename)
+ FIXME A GARDER opj_destroy_cstr_info(&cstr_info);*/
/* free image data structure */
- opj_image_destroy(image);
+ opj_image_header_destroy(image);
}
/*NEW V2 STYLE*/
}
-static void j2k_dump_image(FILE *fd, opj_image_t * img) {
+static void j2k_dump_image(FILE *fd, opj_image_header_t * img) {
int compno;
fprintf(fd, "image {\n");
fprintf(fd, " x0=%d, y0=%d, x1=%d, y1=%d\n", img->x0, img->y0, img->x1, img->y1);
fprintf(fd, " numcomps=%d\n", img->numcomps);
for (compno = 0; compno < img->numcomps; compno++) {
- opj_image_comp_t *comp = &img->comps[compno];
+ opj_image_comp_header_t *comp = &img->comps[compno];
fprintf(fd, " comp %d {\n", compno);
fprintf(fd, " dx=%d, dy=%d\n", comp->dx, comp->dy);
fprintf(fd, " prec=%d\n", comp->prec);
fprintf(fd, "}\n");
}
-static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_t * cp) {
+static void j2k_dump_cp(FILE *fd, opj_image_t * img, opj_cp_v2_t * cp) {
int tileno, compno, layno, bandno, resno, numbands;
fprintf(fd, "coding parameters {\n");
fprintf(fd, " tx0=%d, ty0=%d\n", cp->tx0, cp->ty0);
fprintf(fd, " tdx=%d, tdy=%d\n", cp->tdx, cp->tdy);
fprintf(fd, " tw=%d, th=%d\n", cp->tw, cp->th);
for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
- opj_tcp_t *tcp = &cp->tcps[tileno];
+ opj_tcp_v2_t *tcp = &cp->tcps[tileno];
fprintf(fd, " tile %d {\n", tileno);
fprintf(fd, " csty=%x\n", tcp->csty);
fprintf(fd, " prg=%d\n", tcp->prg);