Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(432)

Side by Side Diff: third_party/libjpeg_turbo/cjpeg.c

Issue 7554002: Updates libjpeg-turbo to 1.1.90 (r677) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/libjpeg_turbo/change.log ('k') | third_party/libjpeg_turbo/djpeg.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * cjpeg.c 2 * cjpeg.c
3 * 3 *
4 * Copyright (C) 1991-1998, Thomas G. Lane. 4 * Copyright (C) 1991-1998, Thomas G. Lane.
5 * Modified 2003-2008 by Guido Vollbeding.
6 * Copyright (C) 2010, D. R. Commander.
5 * This file is part of the Independent JPEG Group's software. 7 * This file is part of the Independent JPEG Group's software.
6 * For conditions of distribution and use, see the accompanying README file. 8 * For conditions of distribution and use, see the accompanying README file.
7 * 9 *
8 * This file contains a command-line user interface for the JPEG compressor. 10 * This file contains a command-line user interface for the JPEG compressor.
9 * It should work on any system with Unix- or MS-DOS-style command lines. 11 * It should work on any system with Unix- or MS-DOS-style command lines.
10 * 12 *
11 * Two different command line styles are permitted, depending on the 13 * Two different command line styles are permitted, depending on the
12 * compile-time switch TWO_FILE_COMMANDLINE: 14 * compile-time switch TWO_FILE_COMMANDLINE:
13 * cjpeg [options] inputfile outputfile 15 * cjpeg [options] inputfile outputfile
14 * cjpeg [options] [inputfile] 16 * cjpeg [options] [inputfile]
15 * In the second style, output is always to standard output, which you'd 17 * In the second style, output is always to standard output, which you'd
16 * normally redirect to a file or pipe to some other program. Input is 18 * normally redirect to a file or pipe to some other program. Input is
17 * either from a named file or from standard input (typically redirected). 19 * either from a named file or from standard input (typically redirected).
18 * The second style is convenient on Unix but is unhelpful on systems that 20 * The second style is convenient on Unix but is unhelpful on systems that
19 * don't support pipes. Also, you MUST use the first style if your system 21 * don't support pipes. Also, you MUST use the first style if your system
20 * doesn't do binary I/O to stdin/stdout. 22 * doesn't do binary I/O to stdin/stdout.
21 * To simplify script writing, the "-outfile" switch is provided. The syntax 23 * To simplify script writing, the "-outfile" switch is provided. The syntax
22 * cjpeg [options] -outfile outputfile inputfile 24 * cjpeg [options] -outfile outputfile inputfile
23 * works regardless of which command line style is used. 25 * works regardless of which command line style is used.
24 */ 26 */
25 27
26 #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */ 28 #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
27 #include "jversion.h" /* for version message */ 29 #include "jversion.h" /* for version message */
30 #include "config.h"
28 31
29 #ifdef USE_CCOMMAND /* command-line reader for Macintosh */ 32 #ifdef USE_CCOMMAND /* command-line reader for Macintosh */
30 #ifdef __MWERKS__ 33 #ifdef __MWERKS__
31 #include <SIOUX.h> /* Metrowerks needs this */ 34 #include <SIOUX.h> /* Metrowerks needs this */
32 #include <console.h> /* ... and this */ 35 #include <console.h> /* ... and this */
33 #endif 36 #endif
34 #ifdef THINK_C 37 #ifdef THINK_C
35 #include <console.h> /* Think declares it here */ 38 #include <console.h> /* Think declares it here */
36 #endif 39 #endif
37 #endif 40 #endif
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 /* complain about bad command line */ 145 /* complain about bad command line */
143 { 146 {
144 fprintf(stderr, "usage: %s [switches] ", progname); 147 fprintf(stderr, "usage: %s [switches] ", progname);
145 #ifdef TWO_FILE_COMMANDLINE 148 #ifdef TWO_FILE_COMMANDLINE
146 fprintf(stderr, "inputfile outputfile\n"); 149 fprintf(stderr, "inputfile outputfile\n");
147 #else 150 #else
148 fprintf(stderr, "[inputfile]\n"); 151 fprintf(stderr, "[inputfile]\n");
149 #endif 152 #endif
150 153
151 fprintf(stderr, "Switches (names may be abbreviated):\n"); 154 fprintf(stderr, "Switches (names may be abbreviated):\n");
152 fprintf(stderr, " -quality N Compression quality (0..100; 5-95 is useful range)\n"); 155 fprintf(stderr, " -quality N[,...] Compression quality (0..100; 5-95 is use ful range)\n");
153 fprintf(stderr, " -grayscale Create monochrome JPEG file\n"); 156 fprintf(stderr, " -grayscale Create monochrome JPEG file\n");
154 #ifdef ENTROPY_OPT_SUPPORTED 157 #ifdef ENTROPY_OPT_SUPPORTED
155 fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but sl ow compression)\n"); 158 fprintf(stderr, " -optimize Optimize Huffman table (smaller file, but sl ow compression)\n");
156 #endif 159 #endif
157 #ifdef C_PROGRESSIVE_SUPPORTED 160 #ifdef C_PROGRESSIVE_SUPPORTED
158 fprintf(stderr, " -progressive Create progressive JPEG file\n"); 161 fprintf(stderr, " -progressive Create progressive JPEG file\n");
159 #endif 162 #endif
160 #ifdef TARGA_SUPPORTED 163 #ifdef TARGA_SUPPORTED
161 fprintf(stderr, " -targa Input file is Targa format (usually not need ed)\n"); 164 fprintf(stderr, " -targa Input file is Targa format (usually not need ed)\n");
162 #endif 165 #endif
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 * Returns argv[] index of first file-name argument (== argc if none). 205 * Returns argv[] index of first file-name argument (== argc if none).
203 * Any file names with indexes <= last_file_arg_seen are ignored; 206 * Any file names with indexes <= last_file_arg_seen are ignored;
204 * they have presumably been processed in a previous iteration. 207 * they have presumably been processed in a previous iteration.
205 * (Pass 0 for last_file_arg_seen on the first or only iteration.) 208 * (Pass 0 for last_file_arg_seen on the first or only iteration.)
206 * for_real is FALSE on the first (dummy) pass; we may skip any expensive 209 * for_real is FALSE on the first (dummy) pass; we may skip any expensive
207 * processing. 210 * processing.
208 */ 211 */
209 { 212 {
210 int argn; 213 int argn;
211 char * arg; 214 char * arg;
212 int quality; /* -quality parameter */
213 int q_scale_factor; /* scaling percentage for -qtables */
214 boolean force_baseline; 215 boolean force_baseline;
215 boolean simple_progressive; 216 boolean simple_progressive;
217 char * qualityarg = NULL; /* saves -quality parm if any */
216 char * qtablefile = NULL; /* saves -qtables filename if any */ 218 char * qtablefile = NULL; /* saves -qtables filename if any */
217 char * qslotsarg = NULL; /* saves -qslots parm if any */ 219 char * qslotsarg = NULL; /* saves -qslots parm if any */
218 char * samplearg = NULL; /* saves -sample parm if any */ 220 char * samplearg = NULL; /* saves -sample parm if any */
219 char * scansarg = NULL; /* saves -scans parm if any */ 221 char * scansarg = NULL; /* saves -scans parm if any */
220 222
221 /* Set up default JPEG parameters. */ 223 /* Set up default JPEG parameters. */
222 /* Note that default -quality level need not, and does not, 224
223 * match the default scaling for an explicit -qtables argument.
224 */
225 quality = 75;»» » /* default -quality value */
226 q_scale_factor = 100;»» /* default to no scaling for -qtables */
227 force_baseline = FALSE; /* by default, allow 16-bit quantizers */ 225 force_baseline = FALSE; /* by default, allow 16-bit quantizers */
228 simple_progressive = FALSE; 226 simple_progressive = FALSE;
229 is_targa = FALSE; 227 is_targa = FALSE;
230 outfilename = NULL; 228 outfilename = NULL;
231 cinfo->err->trace_level = 0; 229 cinfo->err->trace_level = 0;
232 230
233 /* Scan command line options, adjust parameters */ 231 /* Scan command line options, adjust parameters */
234 232
235 for (argn = 1; argn < argc; argn++) { 233 for (argn = 1; argn < argc; argn++) {
236 arg = argv[argn]; 234 arg = argv[argn];
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 cinfo->dct_method = JDCT_FLOAT; 268 cinfo->dct_method = JDCT_FLOAT;
271 } else 269 } else
272 usage(); 270 usage();
273 271
274 } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) { 272 } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
275 /* Enable debug printouts. */ 273 /* Enable debug printouts. */
276 /* On first -d, print version identification */ 274 /* On first -d, print version identification */
277 static boolean printed_version = FALSE; 275 static boolean printed_version = FALSE;
278 276
279 if (! printed_version) { 277 if (! printed_version) {
280 » fprintf(stderr, "Independent JPEG Group's CJPEG, version %s\n%s\n", 278 » fprintf(stderr, "%s version %s (build %s)\n",
279 » » PACKAGE_NAME, VERSION, BUILD);
280 » fprintf(stderr, "%s\n\n", LJTCOPYRIGHT);
281 » fprintf(stderr, "Based on Independent JPEG Group's libjpeg, version %s\n %s\n\n",
281 JVERSION, JCOPYRIGHT); 282 JVERSION, JCOPYRIGHT);
282 printed_version = TRUE; 283 printed_version = TRUE;
283 } 284 }
284 cinfo->err->trace_level++; 285 cinfo->err->trace_level++;
285 286
286 } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) { 287 } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) {
287 /* Force a monochrome JPEG file to be generated. */ 288 /* Force a monochrome JPEG file to be generated. */
288 jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); 289 jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
289 290
290 } else if (keymatch(arg, "maxmemory", 3)) { 291 } else if (keymatch(arg, "maxmemory", 3)) {
(...skipping 30 matching lines...) Expand all
321 #ifdef C_PROGRESSIVE_SUPPORTED 322 #ifdef C_PROGRESSIVE_SUPPORTED
322 simple_progressive = TRUE; 323 simple_progressive = TRUE;
323 /* We must postpone execution until num_components is known. */ 324 /* We must postpone execution until num_components is known. */
324 #else 325 #else
325 fprintf(stderr, "%s: sorry, progressive output was not compiled\n", 326 fprintf(stderr, "%s: sorry, progressive output was not compiled\n",
326 progname); 327 progname);
327 exit(EXIT_FAILURE); 328 exit(EXIT_FAILURE);
328 #endif 329 #endif
329 330
330 } else if (keymatch(arg, "quality", 1)) { 331 } else if (keymatch(arg, "quality", 1)) {
331 /* Quality factor (quantization table scaling factor). */ 332 /* Quality ratings (quantization table scaling factors). */
332 if (++argn >= argc) /* advance to next argument */ 333 if (++argn >= argc) /* advance to next argument */
333 usage(); 334 usage();
334 if (sscanf(argv[argn], "%d", &quality) != 1) 335 qualityarg = argv[argn];
335 » usage();
336 /* Change scale factor in case -qtables is present. */
337 q_scale_factor = jpeg_quality_scaling(quality);
338 336
339 } else if (keymatch(arg, "qslots", 2)) { 337 } else if (keymatch(arg, "qslots", 2)) {
340 /* Quantization table slot numbers. */ 338 /* Quantization table slot numbers. */
341 if (++argn >= argc) /* advance to next argument */ 339 if (++argn >= argc) /* advance to next argument */
342 usage(); 340 usage();
343 qslotsarg = argv[argn]; 341 qslotsarg = argv[argn];
344 /* Must delay setting qslots until after we have processed any 342 /* Must delay setting qslots until after we have processed any
345 * colorspace-determining switches, since jpeg_set_colorspace sets 343 * colorspace-determining switches, since jpeg_set_colorspace sets
346 * default quant table numbers. 344 * default quant table numbers.
347 */ 345 */
(...skipping 27 matching lines...) Expand all
375 } else if (keymatch(arg, "sample", 2)) { 373 } else if (keymatch(arg, "sample", 2)) {
376 /* Set sampling factors. */ 374 /* Set sampling factors. */
377 if (++argn >= argc) /* advance to next argument */ 375 if (++argn >= argc) /* advance to next argument */
378 usage(); 376 usage();
379 samplearg = argv[argn]; 377 samplearg = argv[argn];
380 /* Must delay setting sample factors until after we have processed any 378 /* Must delay setting sample factors until after we have processed any
381 * colorspace-determining switches, since jpeg_set_colorspace sets 379 * colorspace-determining switches, since jpeg_set_colorspace sets
382 * default sampling factors. 380 * default sampling factors.
383 */ 381 */
384 382
385 } else if (keymatch(arg, "scans", 2)) { 383 } else if (keymatch(arg, "scans", 4)) {
386 /* Set scan script. */ 384 /* Set scan script. */
387 #ifdef C_MULTISCAN_FILES_SUPPORTED 385 #ifdef C_MULTISCAN_FILES_SUPPORTED
388 if (++argn >= argc) /* advance to next argument */ 386 if (++argn >= argc) /* advance to next argument */
389 usage(); 387 usage();
390 scansarg = argv[argn]; 388 scansarg = argv[argn];
391 /* We must postpone reading the file in case -progressive appears. */ 389 /* We must postpone reading the file in case -progressive appears. */
392 #else 390 #else
393 fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n", 391 fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n",
394 progname); 392 progname);
395 exit(EXIT_FAILURE); 393 exit(EXIT_FAILURE);
(...skipping 19 matching lines...) Expand all
415 usage(); /* bogus switch */ 413 usage(); /* bogus switch */
416 } 414 }
417 } 415 }
418 416
419 /* Post-switch-scanning cleanup */ 417 /* Post-switch-scanning cleanup */
420 418
421 if (for_real) { 419 if (for_real) {
422 420
423 /* Set quantization tables for selected quality. */ 421 /* Set quantization tables for selected quality. */
424 /* Some or all may be overridden if -qtables is present. */ 422 /* Some or all may be overridden if -qtables is present. */
425 jpeg_set_quality(cinfo, quality, force_baseline); 423 if (qualityarg != NULL)» /* process -quality if it was present */
424 if (! set_quality_ratings(cinfo, qualityarg, force_baseline))
425 » usage();
426 426
427 if (qtablefile != NULL) /* process -qtables if it was present */ 427 if (qtablefile != NULL) /* process -qtables if it was present */
428 if (! read_quant_tables(cinfo, qtablefile, 428 if (! read_quant_tables(cinfo, qtablefile, force_baseline))
429 » » » q_scale_factor, force_baseline))
430 usage(); 429 usage();
431 430
432 if (qslotsarg != NULL) /* process -qslots if it was present */ 431 if (qslotsarg != NULL) /* process -qslots if it was present */
433 if (! set_quant_slots(cinfo, qslotsarg)) 432 if (! set_quant_slots(cinfo, qslotsarg))
434 usage(); 433 usage();
435 434
436 if (samplearg != NULL) /* process -sample if it was present */ 435 if (samplearg != NULL) /* process -sample if it was present */
437 if (! set_sample_factors(cinfo, samplearg)) 436 if (! set_sample_factors(cinfo, samplearg))
438 usage(); 437 usage();
439 438
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 fclose(output_file); 596 fclose(output_file);
598 597
599 #ifdef PROGRESS_REPORT 598 #ifdef PROGRESS_REPORT
600 end_progress_monitor((j_common_ptr) &cinfo); 599 end_progress_monitor((j_common_ptr) &cinfo);
601 #endif 600 #endif
602 601
603 /* All done. */ 602 /* All done. */
604 exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS); 603 exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS);
605 return 0; /* suppress no-return-value warnings */ 604 return 0; /* suppress no-return-value warnings */
606 } 605 }
OLDNEW
« no previous file with comments | « third_party/libjpeg_turbo/change.log ('k') | third_party/libjpeg_turbo/djpeg.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698