simplify the formula so that it returns a slightly lower estimated quality

2007-07-27  Raphael Quinet  <raphael@gimp.org>

	* plug-ins/jpeg/jpeg-quality.c (jpeg_detect_quality): simplify the
	formula so that it returns a slightly lower estimated quality when
	there is no exact match with the IJG quantization tables.

svn path=/trunk/; revision=23041
This commit is contained in:
Raphael Quinet 2007-07-27 13:08:17 +00:00 committed by Raphaël Quinet
parent b62ac32a51
commit d764ce83e6
2 changed files with 14 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2007-07-27 Raphaël Quinet <raphael@gimp.org>
* plug-ins/jpeg/jpeg-quality.c (jpeg_detect_quality): simplify the
formula so that it returns a slightly lower estimated quality when
there is no exact match with the IJG quantization tables.
2007-07-27 Michael Natterer <mitch@gimp.org>
* app/display/gimpdisplayshell-callbacks.c: factored out utility

View File

@ -112,15 +112,19 @@ jpeg_detect_quality (struct jpeg_decompress_struct *cinfo)
if (cinfo->output_components > 1)
{
gint sums;
if (sum[0] < 64 || sum[1] < 64)
return 0;
/* use the chrominance table having the lowest sum (best quality) */
if (sum[2] > 0 && sum[2] < sum[1])
sum[1] = sum[2];
/* compare with the chrominance table having the lowest sum */
if (sum[1] < sum[2] || sum[2] <= 0)
sums = sum[0] + sum[1];
else
sums = sum[0] + sum[2];
q = 100;
while (sum[0] > std_luminance_sum[q] && sum[1] > std_chrominance_sum[q])
while (sums > std_luminance_sum[q] + std_chrominance_sum[q])
q--;
if (sum[0] == std_luminance_sum[q] && sum[1] == std_chrominance_sum[q])