Merge pull request #73 from pornel/master
Added few error messages in cjpeg
This commit is contained in:
34
cjpeg.c
34
cjpeg.c
@@ -282,8 +282,10 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
|
|
||||||
} else if (keymatch(arg, "dct", 2)) {
|
} else if (keymatch(arg, "dct", 2)) {
|
||||||
/* Select DCT algorithm. */
|
/* Select DCT algorithm. */
|
||||||
if (++argn >= argc) /* advance to next argument */
|
if (++argn >= argc) { /* advance to next argument */
|
||||||
|
fprintf(stderr, "%s: missing argument for dct\n", progname);
|
||||||
usage();
|
usage();
|
||||||
|
}
|
||||||
if (keymatch(argv[argn], "int", 1)) {
|
if (keymatch(argv[argn], "int", 1)) {
|
||||||
cinfo->dct_method = JDCT_ISLOW;
|
cinfo->dct_method = JDCT_ISLOW;
|
||||||
} else if (keymatch(argv[argn], "fast", 2)) {
|
} else if (keymatch(argv[argn], "fast", 2)) {
|
||||||
@@ -291,6 +293,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
} else if (keymatch(argv[argn], "float", 2)) {
|
} else if (keymatch(argv[argn], "float", 2)) {
|
||||||
cinfo->dct_method = JDCT_FLOAT;
|
cinfo->dct_method = JDCT_FLOAT;
|
||||||
} else
|
} else
|
||||||
|
fprintf(stderr, "%s: invalid argument for dct\n", progname);
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
} else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
|
} else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
|
||||||
@@ -314,7 +317,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
} else if (keymatch(arg, "flat", 4)) {
|
} else if (keymatch(arg, "flat", 4)) {
|
||||||
cinfo->use_flat_quant_tbl = TRUE;
|
cinfo->use_flat_quant_tbl = TRUE;
|
||||||
jpeg_set_quality(cinfo, 75, TRUE);
|
jpeg_set_quality(cinfo, 75, TRUE);
|
||||||
|
|
||||||
} else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) {
|
} else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) {
|
||||||
/* Force a monochrome JPEG file to be generated. */
|
/* Force a monochrome JPEG file to be generated. */
|
||||||
jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
|
jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
|
||||||
@@ -327,12 +330,12 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
if (++argn >= argc) /* advance to next argument */
|
if (++argn >= argc) /* advance to next argument */
|
||||||
usage();
|
usage();
|
||||||
cinfo->lambda_log_scale1 = atof(argv[argn]);
|
cinfo->lambda_log_scale1 = atof(argv[argn]);
|
||||||
|
|
||||||
} else if (keymatch(arg, "lambda2", 7)) {
|
} else if (keymatch(arg, "lambda2", 7)) {
|
||||||
if (++argn >= argc) /* advance to next argument */
|
if (++argn >= argc) /* advance to next argument */
|
||||||
usage();
|
usage();
|
||||||
cinfo->lambda_log_scale2 = atof(argv[argn]);
|
cinfo->lambda_log_scale2 = atof(argv[argn]);
|
||||||
|
|
||||||
} else if (keymatch(arg, "maxmemory", 3)) {
|
} else if (keymatch(arg, "maxmemory", 3)) {
|
||||||
/* Maximum memory in Kb (or Mb with 'm'). */
|
/* Maximum memory in Kb (or Mb with 'm'). */
|
||||||
long lval;
|
long lval;
|
||||||
@@ -348,7 +351,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
|
|
||||||
} else if (keymatch(arg, "multidcscan", 3)) {
|
} else if (keymatch(arg, "multidcscan", 3)) {
|
||||||
cinfo->one_dc_scan = FALSE;
|
cinfo->one_dc_scan = FALSE;
|
||||||
|
|
||||||
} else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) {
|
} else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) {
|
||||||
/* Enable entropy parm optimization. */
|
/* Enable entropy parm optimization. */
|
||||||
#ifdef ENTROPY_OPT_SUPPORTED
|
#ifdef ENTROPY_OPT_SUPPORTED
|
||||||
@@ -361,8 +364,10 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
|
|
||||||
} else if (keymatch(arg, "outfile", 4)) {
|
} else if (keymatch(arg, "outfile", 4)) {
|
||||||
/* Set output file name. */
|
/* Set output file name. */
|
||||||
if (++argn >= argc) /* advance to next argument */
|
if (++argn >= argc) { /* advance to next argument */
|
||||||
|
fprintf(stderr, "%s: missing argument for outfile\n", progname);
|
||||||
usage();
|
usage();
|
||||||
|
}
|
||||||
outfilename = argv[argn]; /* save it away for later use */
|
outfilename = argv[argn]; /* save it away for later use */
|
||||||
|
|
||||||
} else if (keymatch(arg, "progressive", 1)) {
|
} else if (keymatch(arg, "progressive", 1)) {
|
||||||
@@ -388,8 +393,10 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
|
|
||||||
} else if (keymatch(arg, "quality", 1)) {
|
} else if (keymatch(arg, "quality", 1)) {
|
||||||
/* Quality ratings (quantization table scaling factors). */
|
/* Quality ratings (quantization table scaling factors). */
|
||||||
if (++argn >= argc) /* advance to next argument */
|
if (++argn >= argc) { /* advance to next argument */
|
||||||
|
fprintf(stderr, "%s: missing argument for quality\n", progname);
|
||||||
usage();
|
usage();
|
||||||
|
}
|
||||||
qualityarg = argv[argn];
|
qualityarg = argv[argn];
|
||||||
|
|
||||||
} else if (keymatch(arg, "qslots", 2)) {
|
} else if (keymatch(arg, "qslots", 2)) {
|
||||||
@@ -505,6 +512,7 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
jpeg_set_quality(cinfo, 75, TRUE);
|
jpeg_set_quality(cinfo, 75, TRUE);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
fprintf(stderr, "%s: unknown option '%s'\n", progname, arg);
|
||||||
usage(); /* bogus switch */
|
usage(); /* bogus switch */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -516,20 +524,26 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
|
|||||||
/* Set quantization tables for selected quality. */
|
/* Set quantization tables for selected quality. */
|
||||||
/* Some or all may be overridden if -qtables is present. */
|
/* Some or all may be overridden if -qtables is present. */
|
||||||
if (qualityarg != NULL) /* process -quality if it was present */
|
if (qualityarg != NULL) /* process -quality if it was present */
|
||||||
if (! set_quality_ratings(cinfo, qualityarg, force_baseline))
|
if (! set_quality_ratings(cinfo, qualityarg, force_baseline)) {
|
||||||
|
fprintf(stderr, "%s: can't set quality ratings\n", progname);
|
||||||
usage();
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
if (qtablefile != NULL) /* process -qtables if it was present */
|
if (qtablefile != NULL) /* process -qtables if it was present */
|
||||||
if (! read_quant_tables(cinfo, qtablefile, force_baseline))
|
if (! read_quant_tables(cinfo, qtablefile, force_baseline)) {
|
||||||
|
fprintf(stderr, "%s: can't read qtable file\n", progname);
|
||||||
usage();
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
if (qslotsarg != NULL) /* process -qslots if it was present */
|
if (qslotsarg != NULL) /* process -qslots if it was present */
|
||||||
if (! set_quant_slots(cinfo, qslotsarg))
|
if (! set_quant_slots(cinfo, qslotsarg))
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
if (samplearg != NULL) /* process -sample if it was present */
|
if (samplearg != NULL) /* process -sample if it was present */
|
||||||
if (! set_sample_factors(cinfo, samplearg))
|
if (! set_sample_factors(cinfo, samplearg)) {
|
||||||
|
fprintf(stderr, "%s: can't set sample factors\n", progname);
|
||||||
usage();
|
usage();
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef C_PROGRESSIVE_SUPPORTED
|
#ifdef C_PROGRESSIVE_SUPPORTED
|
||||||
if (simple_progressive) /* process -progressive; -scans can override */
|
if (simple_progressive) /* process -progressive; -scans can override */
|
||||||
|
|||||||
Reference in New Issue
Block a user