From ff6d246efdc410d89116ffd1b4015aa81fd46d33 Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Mon, 25 Jul 2011 16:27:07 +0000 Subject: [PATCH] modify j2k_dump to support output file, needed for non-regression tests --- CHANGES | 7 +++--- applications/codec/j2k_dump.c | 40 +++++++++++++++++++++++++++++------ 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index 867e3532..e3a62dc2 100644 --- a/CHANGES +++ b/CHANGES @@ -5,12 +5,13 @@ What's New for OpenJPEG ! : changed + : added +July 25, 2011 +* [mickael] fixed issue 74 for trunk +! [mickael] modify j2k_dump to support output file, needed for non-regression tests + July 22, 2011 ! [mickael] correct some troubles about thirdparty when they are used -July 25, 2011 -* fixed issue 74 for trunk - July 21, 2011 ! [mickael] correct a compil error linked to getopt with win platform !+ [mickael] add new decode tests based on conformance data and tolerance. Non regression is also added on the decoder output. Deactivate old tests. diff --git a/applications/codec/j2k_dump.c b/applications/codec/j2k_dump.c index 543a7d79..a7292968 100644 --- a/applications/codec/j2k_dump.c +++ b/applications/codec/j2k_dump.c @@ -92,6 +92,10 @@ void decode_help_display() { fprintf(stdout," REQUIRED only if an Input image directory not specified\n"); fprintf(stdout," Currently accepts J2K-files, JP2-files and JPT-files. The file type\n"); fprintf(stdout," is identified based on its suffix.\n"); + fprintf(stdout," -o \n"); + fprintf(stdout," OPTIONAL\n"); + fprintf(stdout," Output file where file info will be dump.\n"); + fprintf(stdout," By default it will be in the stdout.\n"); fprintf(stdout,"\n"); } @@ -197,7 +201,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i {"ImgDir",REQ_ARG, NULL ,'y'}, }; - const char optlist[] = "i:h"; + const char optlist[] = "i:o:h"; totlen=sizeof(long_option); img_fol->set_out_format = 0; while (1) { @@ -222,6 +226,15 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i } strncpy(parameters->infile, infile, sizeof(parameters->infile)-1); } + break; + + /* ------------------------------------------------------ */ + + case 'o': /* output file */ + { + char *outfile = optarg; + strncpy(parameters->outfile, outfile, sizeof(parameters->outfile)-1); + } break; /* ----------------------------------------------------- */ @@ -306,7 +319,7 @@ int main(int argc, char *argv[]) img_fol_t img_fol; opj_event_mgr_t event_mgr; /* event manager */ opj_image_t *image = NULL; - FILE *fsrc = NULL; + FILE *fsrc = NULL, *fout = NULL;; unsigned char *src = NULL; int file_length; int num_images; @@ -362,6 +375,19 @@ int main(int argc, char *argv[]) num_images=1; } + // + if (parameters.outfile[0] != 0) + { + fout = fopen(parameters.outfile,"w"); + if (!fout) + { + fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.outfile); + return 1; + } + } + else + fout = stdout; + /*Encoding image one by one*/ for(imageno = 0; imageno < num_images ; imageno++) { @@ -421,10 +447,10 @@ int main(int argc, char *argv[]) return 1; } /* dump image */ - j2k_dump_image(stdout, image); + j2k_dump_image(fout, image); /* dump cp */ - j2k_dump_cp(stdout, image, ((opj_j2k_t*)dinfo->j2k_handle)->cp); + j2k_dump_cp(fout, image, ((opj_j2k_t*)dinfo->j2k_handle)->cp); /* close the byte stream */ opj_cio_close(cio); @@ -472,10 +498,10 @@ int main(int argc, char *argv[]) { free(image->icc_profile_buf); image->icc_profile_buf = NULL; } - j2k_dump_image(stdout, image); + j2k_dump_image(fout, image); /* dump cp */ - j2k_dump_cp(stdout, image, ((opj_jp2_t*)dinfo->jp2_handle)->j2k->cp); + j2k_dump_cp(fout, image, ((opj_jp2_t*)dinfo->jp2_handle)->j2k->cp); /* close the byte stream */ opj_cio_close(cio); @@ -554,6 +580,8 @@ int main(int argc, char *argv[]) } + fclose(fout); + return EXIT_SUCCESS; }