cjpeg: Don't enable lossless until precision known

jpeg_enable_lossless() checks the point transform value against the data
precision, so we need to defer calling jpeg_enable_lossless() until
after all command-line options have been parsed.
This commit is contained in:
DRC
2024-06-19 17:27:01 -04:00
parent a8aaaf5d5b
commit bb3ab53157
2 changed files with 13 additions and 2 deletions

10
cjpeg.c
View File

@@ -290,7 +290,7 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
int argn;
char *arg;
#ifdef C_LOSSLESS_SUPPORTED
int psv, pt = 0;
int psv = 0, pt = 0;
#endif
boolean force_baseline;
boolean simple_progressive;
@@ -403,7 +403,8 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
string */
if (*ptr)
sscanf(ptr, "%d", &pt);
jpeg_enable_lossless(cinfo, psv, pt);
/* We must postpone execution until data_precision is known. */
#else
fprintf(stderr, "%s: sorry, lossless output was not compiled\n",
progname);
@@ -589,6 +590,11 @@ parse_switches(j_compress_ptr cinfo, int argc, char **argv,
jpeg_simple_progression(cinfo);
#endif
#ifdef C_LOSSLESS_SUPPORTED
if (psv != 0) /* process -lossless */
jpeg_enable_lossless(cinfo, psv, pt);
#endif
#ifdef C_MULTISCAN_FILES_SUPPORTED
if (scansarg != NULL) /* process -scans if it was present */
if (!read_scan_script(cinfo, scansarg))