]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/libjpeg/lib/contrib/cjpeg.c
update
[l4.git] / l4 / pkg / libjpeg / lib / contrib / cjpeg.c
1 /*
2  * cjpeg.c
3  *
4  * Copyright (C) 1991-1998, Thomas G. Lane.
5  * Modified 2003-2010 by Guido Vollbeding.
6  * This file is part of the Independent JPEG Group's software.
7  * For conditions of distribution and use, see the accompanying README file.
8  *
9  * This file contains a command-line user interface for the JPEG compressor.
10  * It should work on any system with Unix- or MS-DOS-style command lines.
11  *
12  * Two different command line styles are permitted, depending on the
13  * compile-time switch TWO_FILE_COMMANDLINE:
14  *      cjpeg [options]  inputfile outputfile
15  *      cjpeg [options]  [inputfile]
16  * In the second style, output is always to standard output, which you'd
17  * normally redirect to a file or pipe to some other program.  Input is
18  * either from a named file or from standard input (typically redirected).
19  * The second style is convenient on Unix but is unhelpful on systems that
20  * don't support pipes.  Also, you MUST use the first style if your system
21  * doesn't do binary I/O to stdin/stdout.
22  * To simplify script writing, the "-outfile" switch is provided.  The syntax
23  *      cjpeg [options]  -outfile outputfile  inputfile
24  * works regardless of which command line style is used.
25  */
26
27 #include "cdjpeg.h"             /* Common decls for cjpeg/djpeg applications */
28 #include "jversion.h"           /* for version message */
29
30 #ifdef USE_CCOMMAND             /* command-line reader for Macintosh */
31 #ifdef __MWERKS__
32 #include <SIOUX.h>              /* Metrowerks needs this */
33 #include <console.h>            /* ... and this */
34 #endif
35 #ifdef THINK_C
36 #include <console.h>            /* Think declares it here */
37 #endif
38 #endif
39
40
41 /* Create the add-on message string table. */
42
43 #define JMESSAGE(code,string)   string ,
44
45 static const char * const cdjpeg_message_table[] = {
46 #include "cderror.h"
47   NULL
48 };
49
50
51 /*
52  * This routine determines what format the input file is,
53  * and selects the appropriate input-reading module.
54  *
55  * To determine which family of input formats the file belongs to,
56  * we may look only at the first byte of the file, since C does not
57  * guarantee that more than one character can be pushed back with ungetc.
58  * Looking at additional bytes would require one of these approaches:
59  *     1) assume we can fseek() the input file (fails for piped input);
60  *     2) assume we can push back more than one character (works in
61  *        some C implementations, but unportable);
62  *     3) provide our own buffering (breaks input readers that want to use
63  *        stdio directly, such as the RLE library);
64  * or  4) don't put back the data, and modify the input_init methods to assume
65  *        they start reading after the start of file (also breaks RLE library).
66  * #1 is attractive for MS-DOS but is untenable on Unix.
67  *
68  * The most portable solution for file types that can't be identified by their
69  * first byte is to make the user tell us what they are.  This is also the
70  * only approach for "raw" file types that contain only arbitrary values.
71  * We presently apply this method for Targa files.  Most of the time Targa
72  * files start with 0x00, so we recognize that case.  Potentially, however,
73  * a Targa file could start with any byte value (byte 0 is the length of the
74  * seldom-used ID field), so we provide a switch to force Targa input mode.
75  */
76
77 static boolean is_targa;        /* records user -targa switch */
78
79
80 LOCAL(cjpeg_source_ptr)
81 select_file_type (j_compress_ptr cinfo, FILE * infile)
82 {
83   int c;
84
85   if (is_targa) {
86 #ifdef TARGA_SUPPORTED
87     return jinit_read_targa(cinfo);
88 #else
89     ERREXIT(cinfo, JERR_TGA_NOTCOMP);
90 #endif
91   }
92
93   if ((c = getc(infile)) == EOF)
94     ERREXIT(cinfo, JERR_INPUT_EMPTY);
95   if (ungetc(c, infile) == EOF)
96     ERREXIT(cinfo, JERR_UNGETC_FAILED);
97
98   switch (c) {
99 #ifdef BMP_SUPPORTED
100   case 'B':
101     return jinit_read_bmp(cinfo);
102 #endif
103 #ifdef GIF_SUPPORTED
104   case 'G':
105     return jinit_read_gif(cinfo);
106 #endif
107 #ifdef PPM_SUPPORTED
108   case 'P':
109     return jinit_read_ppm(cinfo);
110 #endif
111 #ifdef RLE_SUPPORTED
112   case 'R':
113     return jinit_read_rle(cinfo);
114 #endif
115 #ifdef TARGA_SUPPORTED
116   case 0x00:
117     return jinit_read_targa(cinfo);
118 #endif
119   default:
120     ERREXIT(cinfo, JERR_UNKNOWN_FORMAT);
121     break;
122   }
123
124   return NULL;                  /* suppress compiler warnings */
125 }
126
127
128 /*
129  * Argument-parsing code.
130  * The switch parser is designed to be useful with DOS-style command line
131  * syntax, ie, intermixed switches and file names, where only the switches
132  * to the left of a given file name affect processing of that file.
133  * The main program in this file doesn't actually use this capability...
134  */
135
136
137 static const char * progname;   /* program name for error messages */
138 static char * outfilename;      /* for -outfile switch */
139
140
141 LOCAL(void)
142 usage (void)
143 /* complain about bad command line */
144 {
145   fprintf(stderr, "usage: %s [switches] ", progname);
146 #ifdef TWO_FILE_COMMANDLINE
147   fprintf(stderr, "inputfile outputfile\n");
148 #else
149   fprintf(stderr, "[inputfile]\n");
150 #endif
151
152   fprintf(stderr, "Switches (names may be abbreviated):\n");
153   fprintf(stderr, "  -quality N[,...]   Compression quality (0..100; 5-95 is useful range)\n");
154   fprintf(stderr, "  -grayscale     Create monochrome JPEG file\n");
155 #ifdef ENTROPY_OPT_SUPPORTED
156   fprintf(stderr, "  -optimize      Optimize Huffman table (smaller file, but slow compression)\n");
157 #endif
158 #ifdef C_PROGRESSIVE_SUPPORTED
159   fprintf(stderr, "  -progressive   Create progressive JPEG file\n");
160 #endif
161 #ifdef DCT_SCALING_SUPPORTED
162   fprintf(stderr, "  -scale M/N     Scale image by fraction M/N, eg, 1/2\n");
163 #endif
164 #ifdef TARGA_SUPPORTED
165   fprintf(stderr, "  -targa         Input file is Targa format (usually not needed)\n");
166 #endif
167   fprintf(stderr, "Switches for advanced users:\n");
168 #ifdef DCT_SCALING_SUPPORTED
169   fprintf(stderr, "  -block N       DCT block size (1..16; default is 8)\n");
170 #endif
171 #ifdef DCT_ISLOW_SUPPORTED
172   fprintf(stderr, "  -dct int       Use integer DCT method%s\n",
173           (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : ""));
174 #endif
175 #ifdef DCT_IFAST_SUPPORTED
176   fprintf(stderr, "  -dct fast      Use fast integer DCT (less accurate)%s\n",
177           (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : ""));
178 #endif
179 #ifdef DCT_FLOAT_SUPPORTED
180   fprintf(stderr, "  -dct float     Use floating-point DCT method%s\n",
181           (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : ""));
182 #endif
183   fprintf(stderr, "  -nosmooth      Don't use high-quality downsampling\n");
184   fprintf(stderr, "  -restart N     Set restart interval in rows, or in blocks with B\n");
185 #ifdef INPUT_SMOOTHING_SUPPORTED
186   fprintf(stderr, "  -smooth N      Smooth dithered input (N=1..100 is strength)\n");
187 #endif
188   fprintf(stderr, "  -maxmemory N   Maximum memory to use (in kbytes)\n");
189   fprintf(stderr, "  -outfile name  Specify name for output file\n");
190   fprintf(stderr, "  -verbose  or  -debug   Emit debug output\n");
191   fprintf(stderr, "Switches for wizards:\n");
192 #ifdef C_ARITH_CODING_SUPPORTED
193   fprintf(stderr, "  -arithmetic    Use arithmetic coding\n");
194 #endif
195   fprintf(stderr, "  -baseline      Force baseline quantization tables\n");
196   fprintf(stderr, "  -qtables file  Use quantization tables given in file\n");
197   fprintf(stderr, "  -qslots N[,...]    Set component quantization tables\n");
198   fprintf(stderr, "  -sample HxV[,...]  Set component sampling factors\n");
199 #ifdef C_MULTISCAN_FILES_SUPPORTED
200   fprintf(stderr, "  -scans file    Create multi-scan JPEG per script file\n");
201 #endif
202   exit(EXIT_FAILURE);
203 }
204
205
206 LOCAL(int)
207 parse_switches (j_compress_ptr cinfo, int argc, char **argv,
208                 int last_file_arg_seen, boolean for_real)
209 /* Parse optional switches.
210  * Returns argv[] index of first file-name argument (== argc if none).
211  * Any file names with indexes <= last_file_arg_seen are ignored;
212  * they have presumably been processed in a previous iteration.
213  * (Pass 0 for last_file_arg_seen on the first or only iteration.)
214  * for_real is FALSE on the first (dummy) pass; we may skip any expensive
215  * processing.
216  */
217 {
218   int argn;
219   char * arg;
220   boolean force_baseline;
221   boolean simple_progressive;
222   char * qualityarg = NULL;     /* saves -quality parm if any */
223   char * qtablefile = NULL;     /* saves -qtables filename if any */
224   char * qslotsarg = NULL;      /* saves -qslots parm if any */
225   char * samplearg = NULL;      /* saves -sample parm if any */
226   char * scansarg = NULL;       /* saves -scans parm if any */
227
228   /* Set up default JPEG parameters. */
229
230   force_baseline = FALSE;       /* by default, allow 16-bit quantizers */
231   simple_progressive = FALSE;
232   is_targa = FALSE;
233   outfilename = NULL;
234   cinfo->err->trace_level = 0;
235
236   /* Scan command line options, adjust parameters */
237
238   for (argn = 1; argn < argc; argn++) {
239     arg = argv[argn];
240     if (*arg != '-') {
241       /* Not a switch, must be a file name argument */
242       if (argn <= last_file_arg_seen) {
243         outfilename = NULL;     /* -outfile applies to just one input file */
244         continue;               /* ignore this name if previously processed */
245       }
246       break;                    /* else done parsing switches */
247     }
248     arg++;                      /* advance past switch marker character */
249
250     if (keymatch(arg, "arithmetic", 1)) {
251       /* Use arithmetic coding. */
252 #ifdef C_ARITH_CODING_SUPPORTED
253       cinfo->arith_code = TRUE;
254 #else
255       fprintf(stderr, "%s: sorry, arithmetic coding not supported\n",
256               progname);
257       exit(EXIT_FAILURE);
258 #endif
259
260     } else if (keymatch(arg, "baseline", 2)) {
261       /* Force baseline-compatible output (8-bit quantizer values). */
262       force_baseline = TRUE;
263
264     } else if (keymatch(arg, "block", 2)) {
265       /* Set DCT block size. */
266 #if defined(DCT_SCALING_SUPPORTED) && defined(JPEG_LIB_VERSION_MAJOR) && \
267     (JPEG_LIB_VERSION_MAJOR > 8 || (JPEG_LIB_VERSION_MAJOR == 8 && \
268      defined(JPEG_LIB_VERSION_MINOR) && JPEG_LIB_VERSION_MINOR >= 3))
269       int val;
270
271       if (++argn >= argc)       /* advance to next argument */
272         usage();
273       if (sscanf(argv[argn], "%d", &val) != 1)
274         usage();
275       if (val < 1 || val > 16)
276         usage();
277       cinfo->block_size = val;
278 #else
279       fprintf(stderr, "%s: sorry, block size setting not supported\n",
280               progname);
281       exit(EXIT_FAILURE);
282 #endif
283
284     } else if (keymatch(arg, "dct", 2)) {
285       /* Select DCT algorithm. */
286       if (++argn >= argc)       /* advance to next argument */
287         usage();
288       if (keymatch(argv[argn], "int", 1)) {
289         cinfo->dct_method = JDCT_ISLOW;
290       } else if (keymatch(argv[argn], "fast", 2)) {
291         cinfo->dct_method = JDCT_IFAST;
292       } else if (keymatch(argv[argn], "float", 2)) {
293         cinfo->dct_method = JDCT_FLOAT;
294       } else
295         usage();
296
297     } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
298       /* Enable debug printouts. */
299       /* On first -d, print version identification */
300       static boolean printed_version = FALSE;
301
302       if (! printed_version) {
303         fprintf(stderr, "Independent JPEG Group's CJPEG, version %s\n%s\n",
304                 JVERSION, JCOPYRIGHT);
305         printed_version = TRUE;
306       }
307       cinfo->err->trace_level++;
308
309     } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) {
310       /* Force a monochrome JPEG file to be generated. */
311       jpeg_set_colorspace(cinfo, JCS_GRAYSCALE);
312
313     } else if (keymatch(arg, "maxmemory", 3)) {
314       /* Maximum memory in Kb (or Mb with 'm'). */
315       long lval;
316       char ch = 'x';
317
318       if (++argn >= argc)       /* advance to next argument */
319         usage();
320       if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1)
321         usage();
322       if (ch == 'm' || ch == 'M')
323         lval *= 1000L;
324       cinfo->mem->max_memory_to_use = lval * 1000L;
325
326     } else if (keymatch(arg, "nosmooth", 3)) {
327       /* Suppress fancy downsampling */
328       cinfo->do_fancy_downsampling = FALSE;
329
330     } else if (keymatch(arg, "optimize", 1) || keymatch(arg, "optimise", 1)) {
331       /* Enable entropy parm optimization. */
332 #ifdef ENTROPY_OPT_SUPPORTED
333       cinfo->optimize_coding = TRUE;
334 #else
335       fprintf(stderr, "%s: sorry, entropy optimization was not compiled\n",
336               progname);
337       exit(EXIT_FAILURE);
338 #endif
339
340     } else if (keymatch(arg, "outfile", 4)) {
341       /* Set output file name. */
342       if (++argn >= argc)       /* advance to next argument */
343         usage();
344       outfilename = argv[argn]; /* save it away for later use */
345
346     } else if (keymatch(arg, "progressive", 1)) {
347       /* Select simple progressive mode. */
348 #ifdef C_PROGRESSIVE_SUPPORTED
349       simple_progressive = TRUE;
350       /* We must postpone execution until num_components is known. */
351 #else
352       fprintf(stderr, "%s: sorry, progressive output was not compiled\n",
353               progname);
354       exit(EXIT_FAILURE);
355 #endif
356
357     } else if (keymatch(arg, "quality", 1)) {
358       /* Quality ratings (quantization table scaling factors). */
359       if (++argn >= argc)       /* advance to next argument */
360         usage();
361       qualityarg = argv[argn];
362
363     } else if (keymatch(arg, "qslots", 2)) {
364       /* Quantization table slot numbers. */
365       if (++argn >= argc)       /* advance to next argument */
366         usage();
367       qslotsarg = argv[argn];
368       /* Must delay setting qslots until after we have processed any
369        * colorspace-determining switches, since jpeg_set_colorspace sets
370        * default quant table numbers.
371        */
372
373     } else if (keymatch(arg, "qtables", 2)) {
374       /* Quantization tables fetched from file. */
375       if (++argn >= argc)       /* advance to next argument */
376         usage();
377       qtablefile = argv[argn];
378       /* We postpone actually reading the file in case -quality comes later. */
379
380     } else if (keymatch(arg, "restart", 1)) {
381       /* Restart interval in MCU rows (or in MCUs with 'b'). */
382       long lval;
383       char ch = 'x';
384
385       if (++argn >= argc)       /* advance to next argument */
386         usage();
387       if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1)
388         usage();
389       if (lval < 0 || lval > 65535L)
390         usage();
391       if (ch == 'b' || ch == 'B') {
392         cinfo->restart_interval = (unsigned int) lval;
393         cinfo->restart_in_rows = 0; /* else prior '-restart n' overrides me */
394       } else {
395         cinfo->restart_in_rows = (int) lval;
396         /* restart_interval will be computed during startup */
397       }
398
399     } else if (keymatch(arg, "sample", 2)) {
400       /* Set sampling factors. */
401       if (++argn >= argc)       /* advance to next argument */
402         usage();
403       samplearg = argv[argn];
404       /* Must delay setting sample factors until after we have processed any
405        * colorspace-determining switches, since jpeg_set_colorspace sets
406        * default sampling factors.
407        */
408
409     } else if (keymatch(arg, "scale", 4)) {
410       /* Scale the image by a fraction M/N. */
411       if (++argn >= argc)       /* advance to next argument */
412         usage();
413       if (sscanf(argv[argn], "%d/%d",
414                  &cinfo->scale_num, &cinfo->scale_denom) != 2)
415         usage();
416
417     } else if (keymatch(arg, "scans", 4)) {
418       /* Set scan script. */
419 #ifdef C_MULTISCAN_FILES_SUPPORTED
420       if (++argn >= argc)       /* advance to next argument */
421         usage();
422       scansarg = argv[argn];
423       /* We must postpone reading the file in case -progressive appears. */
424 #else
425       fprintf(stderr, "%s: sorry, multi-scan output was not compiled\n",
426               progname);
427       exit(EXIT_FAILURE);
428 #endif
429
430     } else if (keymatch(arg, "smooth", 2)) {
431       /* Set input smoothing factor. */
432       int val;
433
434       if (++argn >= argc)       /* advance to next argument */
435         usage();
436       if (sscanf(argv[argn], "%d", &val) != 1)
437         usage();
438       if (val < 0 || val > 100)
439         usage();
440       cinfo->smoothing_factor = val;
441
442     } else if (keymatch(arg, "targa", 1)) {
443       /* Input file is Targa format. */
444       is_targa = TRUE;
445
446     } else {
447       usage();                  /* bogus switch */
448     }
449   }
450
451   /* Post-switch-scanning cleanup */
452
453   if (for_real) {
454
455     /* Set quantization tables for selected quality. */
456     /* Some or all may be overridden if -qtables is present. */
457     if (qualityarg != NULL)     /* process -quality if it was present */
458       if (! set_quality_ratings(cinfo, qualityarg, force_baseline))
459         usage();
460
461     if (qtablefile != NULL)     /* process -qtables if it was present */
462       if (! read_quant_tables(cinfo, qtablefile, force_baseline))
463         usage();
464
465     if (qslotsarg != NULL)      /* process -qslots if it was present */
466       if (! set_quant_slots(cinfo, qslotsarg))
467         usage();
468
469     if (samplearg != NULL)      /* process -sample if it was present */
470       if (! set_sample_factors(cinfo, samplearg))
471         usage();
472
473 #ifdef C_PROGRESSIVE_SUPPORTED
474     if (simple_progressive)     /* process -progressive; -scans can override */
475       jpeg_simple_progression(cinfo);
476 #endif
477
478 #ifdef C_MULTISCAN_FILES_SUPPORTED
479     if (scansarg != NULL)       /* process -scans if it was present */
480       if (! read_scan_script(cinfo, scansarg))
481         usage();
482 #endif
483   }
484
485   return argn;                  /* return index of next arg (file name) */
486 }
487
488
489 /*
490  * The main program.
491  */
492
493 int
494 main (int argc, char **argv)
495 {
496   struct jpeg_compress_struct cinfo;
497   struct jpeg_error_mgr jerr;
498 #ifdef PROGRESS_REPORT
499   struct cdjpeg_progress_mgr progress;
500 #endif
501   int file_index;
502   cjpeg_source_ptr src_mgr;
503   FILE * input_file;
504   FILE * output_file;
505   JDIMENSION num_scanlines;
506
507   /* On Mac, fetch a command line. */
508 #ifdef USE_CCOMMAND
509   argc = ccommand(&argv);
510 #endif
511
512   progname = argv[0];
513   if (progname == NULL || progname[0] == 0)
514     progname = "cjpeg";         /* in case C library doesn't provide it */
515
516   /* Initialize the JPEG compression object with default error handling. */
517   cinfo.err = jpeg_std_error(&jerr);
518   jpeg_create_compress(&cinfo);
519   /* Add some application-specific error messages (from cderror.h) */
520   jerr.addon_message_table = cdjpeg_message_table;
521   jerr.first_addon_message = JMSG_FIRSTADDONCODE;
522   jerr.last_addon_message = JMSG_LASTADDONCODE;
523
524   /* Now safe to enable signal catcher. */
525 #ifdef NEED_SIGNAL_CATCHER
526   enable_signal_catcher((j_common_ptr) &cinfo);
527 #endif
528
529   /* Initialize JPEG parameters.
530    * Much of this may be overridden later.
531    * In particular, we don't yet know the input file's color space,
532    * but we need to provide some value for jpeg_set_defaults() to work.
533    */
534
535   cinfo.in_color_space = JCS_RGB; /* arbitrary guess */
536   jpeg_set_defaults(&cinfo);
537
538   /* Scan command line to find file names.
539    * It is convenient to use just one switch-parsing routine, but the switch
540    * values read here are ignored; we will rescan the switches after opening
541    * the input file.
542    */
543
544   file_index = parse_switches(&cinfo, argc, argv, 0, FALSE);
545
546 #ifdef TWO_FILE_COMMANDLINE
547   /* Must have either -outfile switch or explicit output file name */
548   if (outfilename == NULL) {
549     if (file_index != argc-2) {
550       fprintf(stderr, "%s: must name one input and one output file\n",
551               progname);
552       usage();
553     }
554     outfilename = argv[file_index+1];
555   } else {
556     if (file_index != argc-1) {
557       fprintf(stderr, "%s: must name one input and one output file\n",
558               progname);
559       usage();
560     }
561   }
562 #else
563   /* Unix style: expect zero or one file name */
564   if (file_index < argc-1) {
565     fprintf(stderr, "%s: only one input file\n", progname);
566     usage();
567   }
568 #endif /* TWO_FILE_COMMANDLINE */
569
570   /* Open the input file. */
571   if (file_index < argc) {
572     if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {
573       fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]);
574       exit(EXIT_FAILURE);
575     }
576   } else {
577     /* default input file is stdin */
578     input_file = read_stdin();
579   }
580
581   /* Open the output file. */
582   if (outfilename != NULL) {
583     if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {
584       fprintf(stderr, "%s: can't open %s\n", progname, outfilename);
585       exit(EXIT_FAILURE);
586     }
587   } else {
588     /* default output file is stdout */
589     output_file = write_stdout();
590   }
591
592 #ifdef PROGRESS_REPORT
593   start_progress_monitor((j_common_ptr) &cinfo, &progress);
594 #endif
595
596   /* Figure out the input file format, and set up to read it. */
597   src_mgr = select_file_type(&cinfo, input_file);
598   src_mgr->input_file = input_file;
599
600   /* Read the input file header to obtain file size & colorspace. */
601   (*src_mgr->start_input) (&cinfo, src_mgr);
602
603   /* Now that we know input colorspace, fix colorspace-dependent defaults */
604   jpeg_default_colorspace(&cinfo);
605
606   /* Adjust default compression parameters by re-parsing the options */
607   file_index = parse_switches(&cinfo, argc, argv, 0, TRUE);
608
609   /* Specify data destination for compression */
610   jpeg_stdio_dest(&cinfo, output_file);
611
612   /* Start compressor */
613   jpeg_start_compress(&cinfo, TRUE);
614
615   /* Process data */
616   while (cinfo.next_scanline < cinfo.image_height) {
617     num_scanlines = (*src_mgr->get_pixel_rows) (&cinfo, src_mgr);
618     (void) jpeg_write_scanlines(&cinfo, src_mgr->buffer, num_scanlines);
619   }
620
621   /* Finish compression and release memory */
622   (*src_mgr->finish_input) (&cinfo, src_mgr);
623   jpeg_finish_compress(&cinfo);
624   jpeg_destroy_compress(&cinfo);
625
626   /* Close files, if we opened them */
627   if (input_file != stdin)
628     fclose(input_file);
629   if (output_file != stdout)
630     fclose(output_file);
631
632 #ifdef PROGRESS_REPORT
633   end_progress_monitor((j_common_ptr) &cinfo);
634 #endif
635
636   /* All done. */
637   exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS);
638   return 0;                     /* suppress no-return-value warnings */
639 }