From: DRC Date: Sun, 10 Oct 2010 07:21:55 +0000 (+0000) Subject: Add option for setting luminance & chrominance quality independently (currently only... X-Git-Tag: 1.0.90~68 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=294079cbe090416bc221e2a446d951c590cc4b38;p=libjpeg-turbo Add option for setting luminance & chrominance quality independently (currently only works if using libjpeg v7 or v8 code base) git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@248 632fc199-4ca6-4c93-a231-07263d6284db --- 294079cbe090416bc221e2a446d951c590cc4b38 diff --cc cjpeg.1 index d175a96,01bfa25..3aee807 --- a/cjpeg.1 +++ b/cjpeg.1 @@@ -276,11 -314,8 +301,10 @@@ Communications of the ACM, April 1991 ( .SH AUTHOR Independent JPEG Group .SH BUGS +Arithmetic coding is not supported for legal reasons. +.PP GIF input files are no longer supported, to avoid the Unisys LZW patent. - Use a Unisys-licensed program if you need to read a GIF file. (Conversion - of GIF files to JPEG is usually a bad idea anyway.) + (Conversion of GIF files to JPEG is usually a bad idea anyway.) .PP Not all variants of BMP and Targa file formats are supported. .PP diff --cc cjpeg.c index 648abf2,b9d57eb..3daa259 --- a/cjpeg.c +++ b/cjpeg.c @@@ -2,7 -2,7 +2,8 @@@ * cjpeg.c * * Copyright (C) 1991-1998, Thomas G. Lane. + * Modified 2003-2008 by Guido Vollbeding. + * Copyright (C) 2010, D. R. Commander. * This file is part of the Independent JPEG Group's software. * For conditions of distribution and use, see the accompanying README file. * @@@ -387,7 -383,15 +380,7 @@@ parse_switches (j_compress_ptr cinfo, i * default sampling factors. */ - } else if (keymatch(arg, "scans", 2)) { - } else if (keymatch(arg, "scale", 4)) { - /* Scale the image by a fraction M/N. */ - if (++argn >= argc) /* advance to next argument */ - usage(); - if (sscanf(argv[argn], "%d/%d", - &cinfo->scale_num, &cinfo->scale_denom) != 2) - usage(); - + } else if (keymatch(arg, "scans", 4)) { /* Set scan script. */ #ifdef C_MULTISCAN_FILES_SUPPORTED if (++argn >= argc) /* advance to next argument */ diff --cc rdswitch.c index 4f4bb4f,7a839af..d34b400 --- a/rdswitch.c +++ b/rdswitch.c @@@ -69,9 -70,8 +70,12 @@@ read_text_integer (FILE * file, long * } ++#if JPEG_LIB_VERSION < 70 ++static int q_scale_factor = 100; ++#endif ++ GLOBAL(boolean) - read_quant_tables (j_compress_ptr cinfo, char * filename, - int scale_factor, boolean force_baseline) + read_quant_tables (j_compress_ptr cinfo, char * filename, boolean force_baseline) /* Read a set of quantization tables from the specified file. * The file is plain ASCII text: decimal numbers with whitespace between. * Comments preceded by '#' may be included in the file. @@@ -108,7 -108,8 +112,12 @@@ } table[i] = (unsigned int) val; } - jpeg_add_quant_table(cinfo, tblno, table, scale_factor, force_baseline); ++#if JPEG_LIB_VERSION >= 70 + jpeg_add_quant_table(cinfo, tblno, table, cinfo->q_scale_factor[tblno], + force_baseline); ++#else ++ jpeg_add_quant_table(cinfo, tblno, table, q_scale_factor, force_baseline); ++#endif tblno++; } @@@ -262,6 -263,38 +271,46 @@@ bogus #endif /* C_MULTISCAN_FILES_SUPPORTED */ + GLOBAL(boolean) + set_quality_ratings (j_compress_ptr cinfo, char *arg, boolean force_baseline) + /* Process a quality-ratings parameter string, of the form + * N[,N,...] + * If there are more q-table slots than parameters, the last value is replicated. + */ + { + int val = 75; /* default value */ + int tblno; + char ch; + + for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { + if (*arg) { + ch = ','; /* if not set by sscanf, will be ',' */ + if (sscanf(arg, "%d%c", &val, &ch) < 1) + return FALSE; + if (ch != ',') /* syntax check */ + return FALSE; + /* Convert user 0-100 rating to percentage scaling */ ++#if JPEG_LIB_VERSION >= 70 + cinfo->q_scale_factor[tblno] = jpeg_quality_scaling(val); ++#endif + while (*arg && *arg++ != ',') /* advance to next segment of arg string */ + ; + } else { + /* reached end of parameter, set remaining factors to last value */ ++#if JPEG_LIB_VERSION >= 70 + cinfo->q_scale_factor[tblno] = jpeg_quality_scaling(val); ++#endif + } + } ++#if JPEG_LIB_VERSION >= 70 + jpeg_default_qtables(cinfo, force_baseline); ++#else ++ jpeg_set_quality(cinfo, val, force_baseline); ++#endif + return TRUE; + } + + GLOBAL(boolean) set_quant_slots (j_compress_ptr cinfo, char *arg) /* Process a quantization-table-selectors parameter string, of the form