djpeg.c
Upload User: zlh9724
Upload Date: 2007-01-04
Package Size: 1991k
Code Size: 18k
Category:

Browser Client

Development Platform:

Unix_Linux

  1. /*
  2.  * djpeg.c
  3.  *
  4.  * Copyright (C) 1991-1995, Thomas G. Lane.
  5.  * This file is part of the Independent JPEG Group's software.
  6.  * For conditions of distribution and use, see the accompanying README file.
  7.  *
  8.  * This file contains a command-line user interface for the JPEG decompressor.
  9.  * It should work on any system with Unix- or MS-DOS-style command lines.
  10.  *
  11.  * Two different command line styles are permitted, depending on the
  12.  * compile-time switch TWO_FILE_COMMANDLINE:
  13.  * djpeg [options]  inputfile outputfile
  14.  * djpeg [options]  [inputfile]
  15.  * 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
  17.  * 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
  19.  * don't support pipes.  Also, you MUST use the first style if your system
  20.  * doesn't do binary I/O to stdin/stdout.
  21.  * To simplify script writing, the "-outfile" switch is provided.  The syntax
  22.  * djpeg [options]  -outfile outputfile  inputfile
  23.  * works regardless of which command line style is used.
  24.  */
  25. #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
  26. #include "jversion.h" /* for version message */
  27. #include <ctype.h> /* to declare isprint() */
  28. #ifdef USE_CCOMMAND /* command-line reader for Macintosh */
  29. #ifdef __MWERKS__
  30. #include <SIOUX.h>              /* Metrowerks declares it here */
  31. #endif
  32. #ifdef THINK_C
  33. #include <console.h> /* Think declares it here */
  34. #endif
  35. #endif
  36. /* Create the add-on message string table. */
  37. #define JMESSAGE(code,string) string ,
  38. static const char * const cdjpeg_message_table[] = {
  39. #include "cderror.h"
  40.   NULL
  41. };
  42. /*
  43.  * This list defines the known output image formats
  44.  * (not all of which need be supported by a given version).
  45.  * You can change the default output format by defining DEFAULT_FMT;
  46.  * indeed, you had better do so if you undefine PPM_SUPPORTED.
  47.  */
  48. typedef enum {
  49. FMT_BMP, /* BMP format (Windows flavor) */
  50. FMT_GIF, /* GIF format */
  51. FMT_OS2, /* BMP format (OS/2 flavor) */
  52. FMT_PPM, /* PPM/PGM (PBMPLUS formats) */
  53. FMT_RLE, /* RLE format */
  54. FMT_TARGA, /* Targa format */
  55. FMT_TIFF /* TIFF format */
  56. } IMAGE_FORMATS;
  57. #ifndef DEFAULT_FMT /* so can override from CFLAGS in Makefile */
  58. #define DEFAULT_FMT FMT_PPM
  59. #endif
  60. static IMAGE_FORMATS requested_fmt;
  61. /*
  62.  * Argument-parsing code.
  63.  * The switch parser is designed to be useful with DOS-style command line
  64.  * syntax, ie, intermixed switches and file names, where only the switches
  65.  * to the left of a given file name affect processing of that file.
  66.  * The main program in this file doesn't actually use this capability...
  67.  */
  68. static const char * progname; /* program name for error messages */
  69. static char * outfilename; /* for -outfile switch */
  70. LOCAL void
  71. usage (void)
  72. /* complain about bad command line */
  73. {
  74.   fprintf(stderr, "usage: %s [switches] ", progname);
  75. #ifdef TWO_FILE_COMMANDLINE
  76.   fprintf(stderr, "inputfile outputfilen");
  77. #else
  78.   fprintf(stderr, "[inputfile]n");
  79. #endif
  80.   fprintf(stderr, "Switches (names may be abbreviated):n");
  81.   fprintf(stderr, "  -colors N      Reduce image to no more than N colorsn");
  82.   fprintf(stderr, "  -fast          Fast, low-quality processingn");
  83.   fprintf(stderr, "  -grayscale     Force grayscale outputn");
  84. #ifdef IDCT_SCALING_SUPPORTED
  85.   fprintf(stderr, "  -scale M/N     Scale output image by fraction M/N, eg, 1/8n");
  86. #endif
  87. #ifdef BMP_SUPPORTED
  88.   fprintf(stderr, "  -bmp           Select BMP output format (Windows style)%sn",
  89.   (DEFAULT_FMT == FMT_BMP ? " (default)" : ""));
  90. #endif
  91. #ifdef GIF_SUPPORTED
  92.   fprintf(stderr, "  -gif           Select GIF output format%sn",
  93.   (DEFAULT_FMT == FMT_GIF ? " (default)" : ""));
  94. #endif
  95. #ifdef BMP_SUPPORTED
  96.   fprintf(stderr, "  -os2           Select BMP output format (OS/2 style)%sn",
  97.   (DEFAULT_FMT == FMT_OS2 ? " (default)" : ""));
  98. #endif
  99. #ifdef PPM_SUPPORTED
  100.   fprintf(stderr, "  -pnm           Select PBMPLUS (PPM/PGM) output format%sn",
  101.   (DEFAULT_FMT == FMT_PPM ? " (default)" : ""));
  102. #endif
  103. #ifdef RLE_SUPPORTED
  104.   fprintf(stderr, "  -rle           Select Utah RLE output format%sn",
  105.   (DEFAULT_FMT == FMT_RLE ? " (default)" : ""));
  106. #endif
  107. #ifdef TARGA_SUPPORTED
  108.   fprintf(stderr, "  -targa         Select Targa output format%sn",
  109.   (DEFAULT_FMT == FMT_TARGA ? " (default)" : ""));
  110. #endif
  111.   fprintf(stderr, "Switches for advanced users:n");
  112. #ifdef DCT_ISLOW_SUPPORTED
  113.   fprintf(stderr, "  -dct int       Use integer DCT method%sn",
  114.   (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : ""));
  115. #endif
  116. #ifdef DCT_IFAST_SUPPORTED
  117.   fprintf(stderr, "  -dct fast      Use fast integer DCT (less accurate)%sn",
  118.   (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : ""));
  119. #endif
  120. #ifdef DCT_FLOAT_SUPPORTED
  121.   fprintf(stderr, "  -dct float     Use floating-point DCT method%sn",
  122.   (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : ""));
  123. #endif
  124.   fprintf(stderr, "  -dither fs     Use F-S dithering (default)n");
  125.   fprintf(stderr, "  -dither none   Don't use dithering in quantizationn");
  126.   fprintf(stderr, "  -dither ordered  Use ordered dither (medium speed, quality)n");
  127. #ifdef QUANT_2PASS_SUPPORTED
  128.   fprintf(stderr, "  -map FILE      Map to colors used in named image filen");
  129. #endif
  130.   fprintf(stderr, "  -nosmooth      Don't use high-quality upsamplingn");
  131. #ifdef QUANT_1PASS_SUPPORTED
  132.   fprintf(stderr, "  -onepass       Use 1-pass quantization (fast, low quality)n");
  133. #endif
  134.   fprintf(stderr, "  -maxmemory N   Maximum memory to use (in kbytes)n");
  135.   fprintf(stderr, "  -outfile name  Specify name for output filen");
  136.   fprintf(stderr, "  -verbose  or  -debug   Emit debug outputn");
  137.   exit(EXIT_FAILURE);
  138. }
  139. LOCAL int
  140. parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
  141. int last_file_arg_seen, boolean for_real)
  142. /* Parse optional switches.
  143.  * Returns argv[] index of first file-name argument (== argc if none).
  144.  * Any file names with indexes <= last_file_arg_seen are ignored;
  145.  * they have presumably been processed in a previous iteration.
  146.  * (Pass 0 for last_file_arg_seen on the first or only iteration.)
  147.  * for_real is FALSE on the first (dummy) pass; we may skip any expensive
  148.  * processing.
  149.  */
  150. {
  151.   int argn;
  152.   char * arg;
  153.   /* Set up default JPEG parameters. */
  154.   requested_fmt = DEFAULT_FMT; /* set default output file format */
  155.   outfilename = NULL;
  156.   cinfo->err->trace_level = 0;
  157.   /* Scan command line options, adjust parameters */
  158.   for (argn = 1; argn < argc; argn++) {
  159.     arg = argv[argn];
  160.     if (*arg != '-') {
  161.       /* Not a switch, must be a file name argument */
  162.       if (argn <= last_file_arg_seen) {
  163. outfilename = NULL; /* -outfile applies to just one input file */
  164. continue; /* ignore this name if previously processed */
  165.       }
  166.       break; /* else done parsing switches */
  167.     }
  168.     arg++; /* advance past switch marker character */
  169.     if (keymatch(arg, "bmp", 1)) {
  170.       /* BMP output format. */
  171.       requested_fmt = FMT_BMP;
  172.     } else if (keymatch(arg, "colors", 1) || keymatch(arg, "colours", 1) ||
  173.        keymatch(arg, "quantize", 1) || keymatch(arg, "quantise", 1)) {
  174.       /* Do color quantization. */
  175.       int val;
  176.       if (++argn >= argc) /* advance to next argument */
  177. usage();
  178.       if (sscanf(argv[argn], "%d", &val) != 1)
  179. usage();
  180.       cinfo->desired_number_of_colors = val;
  181.       cinfo->quantize_colors = TRUE;
  182.     } else if (keymatch(arg, "dct", 2)) {
  183.       /* Select IDCT algorithm. */
  184.       if (++argn >= argc) /* advance to next argument */
  185. usage();
  186.       if (keymatch(argv[argn], "int", 1)) {
  187. cinfo->dct_method = JDCT_ISLOW;
  188.       } else if (keymatch(argv[argn], "fast", 2)) {
  189. cinfo->dct_method = JDCT_IFAST;
  190.       } else if (keymatch(argv[argn], "float", 2)) {
  191. cinfo->dct_method = JDCT_FLOAT;
  192.       } else
  193. usage();
  194.     } else if (keymatch(arg, "dither", 2)) {
  195.       /* Select dithering algorithm. */
  196.       if (++argn >= argc) /* advance to next argument */
  197. usage();
  198.       if (keymatch(argv[argn], "fs", 2)) {
  199. cinfo->dither_mode = JDITHER_FS;
  200.       } else if (keymatch(argv[argn], "none", 2)) {
  201. cinfo->dither_mode = JDITHER_NONE;
  202.       } else if (keymatch(argv[argn], "ordered", 2)) {
  203. cinfo->dither_mode = JDITHER_ORDERED;
  204.       } else
  205. usage();
  206.     } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
  207.       /* Enable debug printouts. */
  208.       /* On first -d, print version identification */
  209.       static boolean printed_version = FALSE;
  210.       if (! printed_version) {
  211. fprintf(stderr, "Independent JPEG Group's DJPEG, version %sn%sn",
  212. JVERSION, JCOPYRIGHT);
  213. printed_version = TRUE;
  214.       }
  215.       cinfo->err->trace_level++;
  216.     } else if (keymatch(arg, "fast", 1)) {
  217.       /* Select recommended processing options for quick-and-dirty output. */
  218.       cinfo->two_pass_quantize = FALSE;
  219.       cinfo->dither_mode = JDITHER_ORDERED;
  220.       if (! cinfo->quantize_colors) /* don't override an earlier -colors */
  221. cinfo->desired_number_of_colors = 216;
  222.       cinfo->dct_method = JDCT_FASTEST;
  223.       cinfo->do_fancy_upsampling = FALSE;
  224.     } else if (keymatch(arg, "gif", 1)) {
  225.       /* GIF output format. */
  226.       requested_fmt = FMT_GIF;
  227.     } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) {
  228.       /* Force monochrome output. */
  229.       cinfo->out_color_space = JCS_GRAYSCALE;
  230.     } else if (keymatch(arg, "map", 3)) {
  231.       /* Quantize to a color map taken from an input file. */
  232.       if (++argn >= argc) /* advance to next argument */
  233. usage();
  234.       if (for_real) { /* too expensive to do twice! */
  235. #ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */
  236. FILE * mapfile;
  237. if ((mapfile = fopen(argv[argn], READ_BINARY)) == NULL) {
  238.   fprintf(stderr, "%s: can't open %sn", progname, argv[argn]);
  239.   exit(EXIT_FAILURE);
  240. }
  241. read_color_map(cinfo, mapfile);
  242. fclose(mapfile);
  243. cinfo->quantize_colors = TRUE;
  244. #else
  245. ERREXIT(cinfo, JERR_NOT_COMPILED);
  246. #endif
  247.       }
  248.     } else if (keymatch(arg, "maxmemory", 3)) {
  249.       /* Maximum memory in Kb (or Mb with 'm'). */
  250.       long lval;
  251.       char ch = 'x';
  252.       if (++argn >= argc) /* advance to next argument */
  253. usage();
  254.       if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1)
  255. usage();
  256.       if (ch == 'm' || ch == 'M')
  257. lval *= 1000L;
  258.       cinfo->mem->max_memory_to_use = lval * 1000L;
  259.     } else if (keymatch(arg, "nosmooth", 3)) {
  260.       /* Suppress fancy upsampling */
  261.       cinfo->do_fancy_upsampling = FALSE;
  262.     } else if (keymatch(arg, "onepass", 3)) {
  263.       /* Use fast one-pass quantization. */
  264.       cinfo->two_pass_quantize = FALSE;
  265.     } else if (keymatch(arg, "os2", 3)) {
  266.       /* BMP output format (OS/2 flavor). */
  267.       requested_fmt = FMT_OS2;
  268.     } else if (keymatch(arg, "outfile", 4)) {
  269.       /* Set output file name. */
  270.       if (++argn >= argc) /* advance to next argument */
  271. usage();
  272.       outfilename = argv[argn]; /* save it away for later use */
  273.     } else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) {
  274.       /* PPM/PGM output format. */
  275.       requested_fmt = FMT_PPM;
  276.     } else if (keymatch(arg, "rle", 1)) {
  277.       /* RLE output format. */
  278.       requested_fmt = FMT_RLE;
  279.     } else if (keymatch(arg, "scale", 1)) {
  280.       /* Scale the output image by a fraction M/N. */
  281.       if (++argn >= argc) /* advance to next argument */
  282. usage();
  283.       if (sscanf(argv[argn], "%d/%d",
  284.  &cinfo->scale_num, &cinfo->scale_denom) != 2)
  285. usage();
  286.     } else if (keymatch(arg, "targa", 1)) {
  287.       /* Targa output format. */
  288.       requested_fmt = FMT_TARGA;
  289.     } else {
  290.       usage(); /* bogus switch */
  291.     }
  292.   }
  293.   return argn; /* return index of next arg (file name) */
  294. }
  295. /*
  296.  * Marker processor for COM markers.
  297.  * This replaces the library's built-in processor, which just skips the marker.
  298.  * We want to print out the marker as text, if possible.
  299.  * Note this code relies on a non-suspending data source.
  300.  */
  301. LOCAL unsigned int
  302. jpeg_getc (j_decompress_ptr cinfo)
  303. /* Read next byte */
  304. {
  305.   struct jpeg_source_mgr * datasrc = cinfo->src;
  306.   if (datasrc->bytes_in_buffer == 0) {
  307.     if (! (*datasrc->fill_input_buffer) (cinfo))
  308.       ERREXIT(cinfo, JERR_CANT_SUSPEND);
  309.   }
  310.   datasrc->bytes_in_buffer--;
  311.   return GETJOCTET(*datasrc->next_input_byte++);
  312. }
  313. METHODDEF boolean
  314. COM_handler (j_decompress_ptr cinfo)
  315. {
  316.   boolean traceit = (cinfo->err->trace_level >= 1);
  317.   INT32 length;
  318.   unsigned int ch;
  319.   unsigned int lastch = 0;
  320.   length = jpeg_getc(cinfo) << 8;
  321.   length += jpeg_getc(cinfo);
  322.   length -= 2; /* discount the length word itself */
  323.   if (traceit)
  324.     fprintf(stderr, "Comment, length %ld:n", (long) length);
  325.   while (--length >= 0) {
  326.     ch = jpeg_getc(cinfo);
  327.     if (traceit) {
  328.       /* Emit the character in a readable form.
  329.        * Nonprintables are converted to nnn form,
  330.        * while  is converted to \.
  331.        * Newlines in CR, CR/LF, or LF form will be printed as one newline.
  332.        */
  333.       if (ch == 'r') {
  334. fprintf(stderr, "n");
  335.       } else if (ch == 'n') {
  336. if (lastch != 'r')
  337.   fprintf(stderr, "n");
  338.       } else if (ch == '\') {
  339. fprintf(stderr, "\\");
  340.       } else if (isprint(ch)) {
  341. putc(ch, stderr);
  342.       } else {
  343. fprintf(stderr, "\%03o", ch);
  344.       }
  345.       lastch = ch;
  346.     }
  347.   }
  348.   if (traceit)
  349.     fprintf(stderr, "n");
  350.   return TRUE;
  351. }
  352. /*
  353.  * The main program.
  354.  */
  355. GLOBAL int
  356. main (int argc, char **argv)
  357. {
  358.   struct jpeg_decompress_struct cinfo;
  359.   struct jpeg_error_mgr jerr;
  360. #ifdef PROGRESS_REPORT
  361.   struct cdjpeg_progress_mgr progress;
  362. #endif
  363.   int file_index;
  364.   djpeg_dest_ptr dest_mgr = NULL;
  365.   FILE * input_file;
  366.   FILE * output_file;
  367.   JDIMENSION num_scanlines;
  368.   /* On Mac, fetch a command line. */
  369. #ifdef USE_CCOMMAND
  370.   argc = ccommand(&argv);
  371. #endif
  372.   progname = argv[0];
  373.   if (progname == NULL || progname[0] == 0)
  374.     progname = "djpeg"; /* in case C library doesn't provide it */
  375.   /* Initialize the JPEG decompression object with default error handling. */
  376.   cinfo.err = jpeg_std_error(&jerr);
  377.   jpeg_create_decompress(&cinfo);
  378.   /* Add some application-specific error messages (from cderror.h) */
  379.   jerr.addon_message_table = cdjpeg_message_table;
  380.   jerr.first_addon_message = JMSG_FIRSTADDONCODE;
  381.   jerr.last_addon_message = JMSG_LASTADDONCODE;
  382.   /* Insert custom COM marker processor. */
  383.   jpeg_set_marker_processor(&cinfo, JPEG_COM, COM_handler);
  384.   /* Now safe to enable signal catcher. */
  385. #ifdef NEED_SIGNAL_CATCHER
  386.   enable_signal_catcher((j_common_ptr) &cinfo);
  387. #endif
  388.   /* Scan command line to find file names. */
  389.   /* It is convenient to use just one switch-parsing routine, but the switch
  390.    * values read here are ignored; we will rescan the switches after opening
  391.    * the input file.
  392.    * (Exception: tracing level set here controls verbosity for COM markers
  393.    * found during jpeg_read_header...)
  394.    */
  395.   file_index = parse_switches(&cinfo, argc, argv, 0, FALSE);
  396. #ifdef TWO_FILE_COMMANDLINE
  397.   /* Must have either -outfile switch or explicit output file name */
  398.   if (outfilename == NULL) {
  399.     if (file_index != argc-2) {
  400.       fprintf(stderr, "%s: must name one input and one output filen",
  401.       progname);
  402.       usage();
  403.     }
  404.     outfilename = argv[file_index+1];
  405.   } else {
  406.     if (file_index != argc-1) {
  407.       fprintf(stderr, "%s: must name one input and one output filen",
  408.       progname);
  409.       usage();
  410.     }
  411.   }
  412. #else
  413.   /* Unix style: expect zero or one file name */
  414.   if (file_index < argc-1) {
  415.     fprintf(stderr, "%s: only one input filen", progname);
  416.     usage();
  417.   }
  418. #endif /* TWO_FILE_COMMANDLINE */
  419.   /* Open the input file. */
  420.   if (file_index < argc) {
  421.     if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {
  422.       fprintf(stderr, "%s: can't open %sn", progname, argv[file_index]);
  423.       exit(EXIT_FAILURE);
  424.     }
  425.   } else {
  426.     /* default input file is stdin */
  427.     input_file = read_stdin();
  428.   }
  429.   /* Open the output file. */
  430.   if (outfilename != NULL) {
  431.     if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {
  432.       fprintf(stderr, "%s: can't open %sn", progname, outfilename);
  433.       exit(EXIT_FAILURE);
  434.     }
  435.   } else {
  436.     /* default output file is stdout */
  437.     output_file = write_stdout();
  438.   }
  439. #ifdef PROGRESS_REPORT
  440.   start_progress_monitor((j_common_ptr) &cinfo, &progress);
  441. #endif
  442.   /* Specify data source for decompression */
  443.   jpeg_stdio_src(&cinfo, input_file);
  444.   /* Read file header, set default decompression parameters */
  445.   (void) jpeg_read_header(&cinfo, TRUE);
  446.   /* Adjust default decompression parameters by re-parsing the options */
  447.   file_index = parse_switches(&cinfo, argc, argv, 0, TRUE);
  448.   /* Initialize the output module now to let it override any crucial
  449.    * option settings (for instance, GIF wants to force color quantization).
  450.    */
  451.   switch (requested_fmt) {
  452. #ifdef BMP_SUPPORTED
  453.   case FMT_BMP:
  454.     dest_mgr = jinit_write_bmp(&cinfo, FALSE);
  455.     break;
  456.   case FMT_OS2:
  457.     dest_mgr = jinit_write_bmp(&cinfo, TRUE);
  458.     break;
  459. #endif
  460. #ifdef GIF_SUPPORTED
  461.   case FMT_GIF:
  462.     dest_mgr = jinit_write_gif(&cinfo);
  463.     break;
  464. #endif
  465. #ifdef PPM_SUPPORTED
  466.   case FMT_PPM:
  467.     dest_mgr = jinit_write_ppm(&cinfo);
  468.     break;
  469. #endif
  470. #ifdef RLE_SUPPORTED
  471.   case FMT_RLE:
  472.     dest_mgr = jinit_write_rle(&cinfo);
  473.     break;
  474. #endif
  475. #ifdef TARGA_SUPPORTED
  476.   case FMT_TARGA:
  477.     dest_mgr = jinit_write_targa(&cinfo);
  478.     break;
  479. #endif
  480.   default:
  481.     ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT);
  482.     break;
  483.   }
  484.   dest_mgr->output_file = output_file;
  485.   /* Start decompressor */
  486.   (void) jpeg_start_decompress(&cinfo);
  487.   /* Write output file header */
  488.   (*dest_mgr->start_output) (&cinfo, dest_mgr);
  489.   /* Process data */
  490.   while (cinfo.output_scanline < cinfo.output_height) {
  491.     num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
  492. dest_mgr->buffer_height);
  493.     (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
  494.   }
  495. #ifdef PROGRESS_REPORT
  496.   /* Hack: count final pass as done in case finish_output does an extra pass.
  497.    * The library won't have updated completed_passes.
  498.    */
  499.   progress.pub.completed_passes = progress.pub.total_passes;
  500. #endif
  501.   /* Finish decompression and release memory.
  502.    * I must do it in this order because output module has allocated memory
  503.    * of lifespan JPOOL_IMAGE; it needs to finish before releasing memory.
  504.    */
  505.   (*dest_mgr->finish_output) (&cinfo, dest_mgr);
  506.   (void) jpeg_finish_decompress(&cinfo);
  507.   jpeg_destroy_decompress(&cinfo);
  508.   /* Close files, if we opened them */
  509.   if (input_file != stdin)
  510.     fclose(input_file);
  511.   if (output_file != stdout)
  512.     fclose(output_file);
  513. #ifdef PROGRESS_REPORT
  514.   end_progress_monitor((j_common_ptr) &cinfo);
  515. #endif
  516.   /* All done. */
  517.   exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS);
  518.   return 0; /* suppress no-return-value warnings */
  519. }