Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guess default chroma subsampling setting from the quality setting #243

Merged
merged 1 commit into from Apr 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions cjpeg.c
Expand Up @@ -608,6 +608,8 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
if (! set_quant_slots(cinfo, qslotsarg))
usage();

/* set_quality_ratings sets default subsampling, so the explicit
subsampling must be set after it */
if (samplearg != NULL) /* process -sample if it was present */
if (! set_sample_factors(cinfo, samplearg)) {
fprintf(stderr, "%s: can't set sample factors\n", progname);
Expand Down
11 changes: 11 additions & 0 deletions rdswitch.c
Expand Up @@ -553,6 +553,17 @@ set_quality_ratings (j_compress_ptr cinfo, char *arg, boolean force_baseline)
}
}
jpeg_default_qtables(cinfo, force_baseline);

/* For some images chroma subsampling significantly degrades color quality,
making it impossible to achieve high visual quality regardless of quality setting.
To make the quality setting more intuitive, disable subsampling when high-quality
color is desired. */
if (val >= 90) {
set_sample_factors(cinfo, "1x1");
} else if (val >= 80) {
set_sample_factors(cinfo, "2x1");
}

return TRUE;
}

Expand Down