Skip to content

Commit

Permalink
Calculate jpeg_simple_progression nscans correctly with respect to dc…
Browse files Browse the repository at this point in the history
…_scan_opt_mode
  • Loading branch information
Daniel Hugenroth committed Apr 21, 2017
1 parent 41dd774 commit 31d957d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions jcparam.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,13 @@ jpeg_simple_progression (j_compress_ptr cinfo)
ncomps = cinfo->num_components;
if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) {
/* Custom script for YCbCr color images. */
nscans = 10;
if (cinfo->master->dc_scan_opt_mode == 0) {
nscans = 8; /* 1 DC scan for all components */
} else if (cinfo->master->dc_scan_opt_mode == 1) {
nscans = 10; /* 1 DC scan for each component */
} else {
nscans = 9; /* 1 DC scan for luminance and 1 DC scan for chroma */
}
} else {
/* All-purpose script for other color spaces. */
if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION) {
Expand Down Expand Up @@ -906,14 +912,16 @@ jpeg_simple_progression (j_compress_ptr cinfo)
if (cinfo->master->compress_profile == JCP_MAX_COMPRESSION) {
/* scan defined in jpeg_scan_rgb.txt in jpgcrush */
/* Initial DC scan */
if (cinfo->master->dc_scan_opt_mode == 0)
if (cinfo->master->dc_scan_opt_mode == 0) {
/* 1 DC scan for all components */
scanptr = fill_dc_scans(scanptr, ncomps, 0, 0);
else if (cinfo->master->dc_scan_opt_mode == 1) {
} else if (cinfo->master->dc_scan_opt_mode == 1) {
/* 1 DC scan for each component */
scanptr = fill_a_scan(scanptr, 0, 0, 0, 0, 0);
scanptr = fill_a_scan(scanptr, 1, 0, 0, 0, 0);
scanptr = fill_a_scan(scanptr, 2, 0, 0, 0, 0);
}
else {
} else {
/* 1 DC scan for luminance and 1 DC scan for chroma */
scanptr = fill_dc_scans(scanptr, 1, 0, 0);
scanptr = fill_a_scan_pair(scanptr, 1, 0, 0, 0, 0);
}
Expand Down

0 comments on commit 31d957d

Please sign in to comment.