From f9d76c0be97d64438164100616c5d273de4d85e6 Mon Sep 17 00:00:00 2001 From: Francois-Olivier Devaux Date: Mon, 4 Dec 2006 14:55:38 +0000 Subject: [PATCH] First integration of JPWL code --- codec/j2k_to_image.c | 101 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/codec/j2k_to_image.c b/codec/j2k_to_image.c index f86fdfb1..30790863 100644 --- a/codec/j2k_to_image.c +++ b/codec/j2k_to_image.c @@ -57,7 +57,13 @@ void decode_help_display() { fprintf(stdout,"HELP\n----\n\n"); fprintf(stdout,"- the -h option displays this help information on screen\n\n"); - fprintf(stdout,"List of parameters for the JPEG 2000 encoder:\n"); +/* UniPG>> */ + fprintf(stdout,"List of parameters for the JPEG 2000 " +#ifdef USE_JPWL + "+ JPWL " +#endif /* USE_JPWL */ + "decoder:\n"); +/* <\n"); fprintf(stdout," REQUIRED\n"); @@ -81,6 +87,16 @@ void decode_help_display() { fprintf(stdout," Set the maximum number of quality layers to decode. If there are\n"); fprintf(stdout," less quality layers than the specified number, all the quality layers\n"); fprintf(stdout," are decoded.\n"); +/* UniPG>> */ +#ifdef USE_JPWL + fprintf(stdout," -W \n"); + fprintf(stdout," Activates the JPWL correction capability, if the codestream complies.\n"); + fprintf(stdout," Options can be a comma separated list of tokens:\n"); + fprintf(stdout," c, c=numcomps\n"); + fprintf(stdout," numcomps is the number of expected components in the codestream\n"); + fprintf(stdout," (search of first EPB rely upon this, default is %d)\n", JPWL_EXPECTED_COMPONENTS); +#endif /* USE_JPWL */ +/* <> */ + const char optlist[] = "i:o:r:l:h" + +#ifdef USE_JPWL + "W:" +#endif /* USE_JPWL */ + ; +/* <>JPWL<< */ if (c == -1) break; switch (c) { @@ -174,6 +199,78 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters) decode_help_display(); return 1; +/* UniPG>> */ +#ifdef USE_JPWL + /* ----------------------------------------------------- */ + + case 'W': /* activate JPWL correction */ + { + char *token = NULL; + + token = strtok(optarg, ","); + while(token != NULL) { + + /* search expected number of components */ + if (*token == 'c') { + + static int compno; + + compno = JPWL_EXPECTED_COMPONENTS; /* predefined no. of components */ + + if(sscanf(token, "c=%d", &compno) == 1) { + /* Specified */ + if ((compno < 1) || (compno > 256)) { + fprintf(stderr, "ERROR -> invalid number of components c = %d\n", compno); + return 1; + } + parameters->jpwl_exp_comps = compno; + + } else if (!strcmp(token, "c")) { + /* default */ + parameters->jpwl_exp_comps = compno; /* auto for default size */ + + } else { + fprintf(stderr, "ERROR -> invalid components specified = %s\n", token); + return 1; + }; + } + + /* search maximum number of tiles */ + if (*token == 't') { + + static int tileno; + + tileno = JPWL_MAXIMUM_TILES; /* maximum no. of tiles */ + + if(sscanf(token, "t=%d", &tileno) == 1) { + /* Specified */ + if ((tileno < 1) || (tileno > JPWL_MAXIMUM_TILES)) { + fprintf(stderr, "ERROR -> invalid number of tiles t = %d\n", tileno); + return 1; + } + parameters->jpwl_max_tiles = tileno; + + } else if (!strcmp(token, "t")) { + /* default */ + parameters->jpwl_max_tiles = tileno; /* auto for default size */ + + } else { + fprintf(stderr, "ERROR -> invalid tiles specified = %s\n", token); + return 1; + }; + } + + /* next token or bust */ + token = strtok(NULL, ","); + }; + parameters->jpwl_correct = true; + fprintf(stdout, "JPWL correction capability activated\n"); + fprintf(stdout, "- expecting %d components\n", parameters->jpwl_exp_comps); + } + break; +#endif /* USE_JPWL */ +/* <