Calculate jpeg_simple_progression nscans correctly

This commit is contained in:
Daniel Hugenroth
2017-07-06 11:18:19 +01:00
parent a9bfef2a57
commit fb27709ab1

View File

@@ -864,16 +864,20 @@ jpeg_simple_progression (j_compress_ptr cinfo)
if (cinfo->global_state != CSTATE_START) if (cinfo->global_state != CSTATE_START)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
/* Figure space needed for script. Calculation must match code below! */ /* Figure space needed for script. Calculation must match code below! */
ncomps = cinfo->num_components; ncomps = cinfo->num_components;
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
/* Custom script for YCbCr color images. */ /* Custom script for YCbCr color images. */
if (cinfo->master->dc_scan_opt_mode == 0) { if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION) {
nscans = 8; /* 1 DC scan for all components */ if (cinfo->master->dc_scan_opt_mode == 0) {
} else if (cinfo->master->dc_scan_opt_mode == 1) { nscans = 9; /* 1 DC scan for all components */
nscans = 10; /* 1 DC scan for each component */ } else if (cinfo->master->dc_scan_opt_mode == 1) {
nscans = 11; /* 1 DC scan for each component */
} else {
nscans = 10; /* 1 DC scan for luminance and 1 DC scan for chroma */
}
} else { } else {
nscans = 9; /* 1 DC scan for luminance and 1 DC scan for chroma */ nscans = 10; /* 2 DC scans and 8 AC scans */
} }
} else { } else {
/* All-purpose script for other color spaces. */ /* All-purpose script for other color spaces. */