From 08c09b74cf08975c018ad9e735afbdb7f63afb58 Mon Sep 17 00:00:00 2001 From: Antonin Descampe Date: Wed, 23 Apr 2014 09:12:30 +0000 Subject: [PATCH] [trunk]formatted some messages. Removed -version option to disambiguate with -v(erbose) option, added version info in help display --- src/bin/jp2/opj_compress.c | 16 +++++---------- src/bin/jp2/opj_decompress.c | 28 ++++++++++--------------- src/bin/jp2/opj_dump.c | 40 ++++++++++++++++++++---------------- src/lib/openjp2/j2k.c | 2 +- 4 files changed, 39 insertions(+), 47 deletions(-) diff --git a/src/bin/jp2/opj_compress.c b/src/bin/jp2/opj_compress.c index 4da8eaee..dc27fb62 100644 --- a/src/bin/jp2/opj_compress.c +++ b/src/bin/jp2/opj_compress.c @@ -86,7 +86,9 @@ typedef struct img_folder{ }img_fol_t; static void encode_help_display(void) { - fprintf(stdout,"HELP for opj_compress\n----\n\n"); + fprintf(stdout,"This is the opj_compress utility from the OpenJPEG project.\n" + "It has been compiled against openjp2 library v%s.\n\n",opj_version()); + fprintf(stdout,"HELP\n----\n\n"); fprintf(stdout,"- the -h option displays this help information on screen\n\n"); /* UniPG>> */ @@ -467,8 +469,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param {"POC",REQ_ARG, NULL ,'P'}, {"ROI",REQ_ARG, NULL ,'R'}, {"jpip",NO_ARG, NULL, 'J'}, - {"mct",REQ_ARG, NULL, 'Y'}, - {"version",NO_ARG, NULL, 'v'} + {"mct",REQ_ARG, NULL, 'Y'} }; /* parse the command line */ @@ -476,7 +477,7 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param #ifdef USE_JPWL "W:" #endif /* USE_JPWL */ - "hv"; + "h"; totlen=sizeof(long_option); img_fol->set_out_format=0; @@ -843,13 +844,6 @@ static int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *param /* ----------------------------------------------------- */ - case 'v': /* display the openjpeg library version in use */ - fprintf(stdout,"This is the opj_compress utility from the OpenJPEG project.\n" - "It has been compiled against openjp2 library v%s.\n",opj_version()); - return 1; - - /* ----------------------------------------------------- */ - case 'P': /* POC */ { int numpocs = 0; /* number of progression order change (POC) default 0 */ diff --git a/src/bin/jp2/opj_decompress.c b/src/bin/jp2/opj_decompress.c index 78957e85..4e4967df 100644 --- a/src/bin/jp2/opj_decompress.c +++ b/src/bin/jp2/opj_decompress.c @@ -106,9 +106,10 @@ int parse_DA_values( char* inArg, unsigned int *DA_x0, unsigned int *DA_y0, unsi /* -------------------------------------------------------------------------- */ static void decode_help_display(void) { - fprintf(stdout,"HELP for opj_decompress\n----\n\n"); + fprintf(stdout,"This is the opj_decompress utility from the OpenJPEG project.\n" + "It has been compiled against openjp2 library v%s.\n\n",opj_version()); + fprintf(stdout,"HELP\n----\n\n"); fprintf(stdout,"- the -h option displays this help information on screen\n\n"); - /* UniPG>> */ fprintf(stdout,"List of parameters for the JPEG 2000 " #ifdef USE_JPWL @@ -331,8 +332,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i int totlen, c; opj_option_t long_option[]={ {"ImgDir",REQ_ARG, NULL ,'y'}, - {"OutFor",REQ_ARG, NULL ,'O'}, - {"version",NO_ARG, NULL ,'v'} + {"OutFor",REQ_ARG, NULL ,'O'} }; const char optlist[] = "i:o:r:l:x:d:t:" @@ -342,7 +342,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i "W:" #endif /* USE_JPWL */ /* <set_out_format = 0; do { @@ -474,13 +474,6 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i decode_help_display(); return 1; - /* ------------------------------------------------------ */ - - case 'v': /* display the openjpeg library version in use */ - fprintf(stdout,"This is the opj_decompress utility from the OpenJPEG project.\n" - "It has been compiled against openjp2 library v%s.\n",opj_version()); - return 1; - /* ----------------------------------------------------- */ case 'y': /* Image Directory path */ @@ -599,7 +592,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i /* ----------------------------------------------------- */ default: - fprintf(stderr, "[WARNING] An invalid option has been ignored\n"); + fprintf(stderr, "[WARNING] An invalid option has been ignored.\n"); break; } }while(c != -1); @@ -607,16 +600,17 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i /* check for possible errors */ if(img_fol->set_imgdir==1){ if(!(parameters->infile[0]==0)){ - fprintf(stderr, "[ERROR] options -ImgDir and -i cannot be used together !!\n"); + fprintf(stderr, "[ERROR] options -ImgDir and -i cannot be used together.\n"); return 1; } if(img_fol->set_out_format == 0){ - fprintf(stderr, "[ERROR] When -ImgDir is used, -OutFor must be used !!\n"); - fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n"); + fprintf(stderr, "[ERROR] When -ImgDir is used, -OutFor must be used.\n"); + fprintf(stderr, "Only one format allowed.\n" + "Valid format are PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA.\n"); return 1; } if(!((parameters->outfile[0] == 0))){ - fprintf(stderr, "[ERROR] options -ImgDir and -o cannot be used together !!\n"); + fprintf(stderr, "[ERROR] options -ImgDir and -o cannot be used together.\n"); return 1; } }else{ diff --git a/src/bin/jp2/opj_dump.c b/src/bin/jp2/opj_dump.c index 7a841d53..c40f3686 100644 --- a/src/bin/jp2/opj_dump.c +++ b/src/bin/jp2/opj_dump.c @@ -91,7 +91,9 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param /* -------------------------------------------------------------------------- */ static void decode_help_display(void) { - fprintf(stdout,"HELP for opj_dump\n----\n\n"); + fprintf(stdout,"This is the opj_dump utility from the OpenJPEG project.\n" + "It has been compiled against openjp2 library v%s.\n\n",opj_version()); + fprintf(stdout,"HELP\n----\n\n"); fprintf(stdout,"- the -h option displays this help information on screen\n\n"); /* UniPG>> */ @@ -99,7 +101,7 @@ static void decode_help_display(void) { #ifdef USE_JPWL "+ JPWL " #endif /* USE_JPWL */ - "decoder:\n"); + "dump utility:\n"); /* <set_out_format = 0; @@ -341,38 +343,40 @@ static int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *param /* ----------------------------------------------------- */ - case 'v': /* Verbose mode */ + case 'v': /* Verbose mode */ { - parameters->m_verbose = 1; + parameters->m_verbose = 1; } break; /* ----------------------------------------------------- */ - default: - fprintf(stderr,"WARNING -> this option is not valid \"-%c %s\"\n",c, opj_optarg); - break; - } + default: + fprintf(stderr, "[WARNING] An invalid option has been ignored.\n"); + break; + } }while(c != -1); /* check for possible errors */ if(img_fol->set_imgdir==1){ if(!(parameters->infile[0]==0)){ - fprintf(stderr, "Error: options -ImgDir and -i cannot be used together !!\n"); + fprintf(stderr, "[ERROR] options -ImgDir and -i cannot be used together.\n"); return 1; } if(img_fol->set_out_format == 0){ - fprintf(stderr, "Error: When -ImgDir is used, -OutFor must be used !!\n"); - fprintf(stderr, "Only one format allowed! Valid format PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA!!\n"); + fprintf(stderr, "[ERROR] When -ImgDir is used, -OutFor must be used.\n"); + fprintf(stderr, "Only one format allowed.\n" + "Valid format are PGM, PPM, PNM, PGX, BMP, TIF, RAW and TGA.\n"); return 1; } if(!(parameters->outfile[0] == 0)){ - fprintf(stderr, "Error: options -ImgDir and -o cannot be used together !!\n"); + fprintf(stderr, "[ERROR] options -ImgDir and -o cannot be used together\n"); return 1; } }else{ if(parameters->infile[0] == 0) { + fprintf(stderr, "[ERROR] Required parameter is missing\n"); fprintf(stderr, "Example: %s -i image.j2k\n",argv[0]); - fprintf(stderr, " Try: %s -h\n",argv[0]); + fprintf(stderr, " Help: %s -h\n",argv[0]); return 1; } } diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index 677a0b61..858bb39f 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -6039,7 +6039,7 @@ void opj_j2k_set_cinema_parameters(opj_cparameters_t *parameters, opj_image_t *i } parameters->tcp_rates[0] = (OPJ_FLOAT32) (image->numcomps * image->comps[0].w * image->comps[0].h * image->comps[0].prec)/ - (OPJ_FLOAT32)(parameters->max_cs_size * 8 * image->comps[0].dx * image->comps[0].dy); + (OPJ_FLOAT32)(((OPJ_UINT32)parameters->max_cs_size) * 8 * image->comps[0].dx * image->comps[0].dy); }