cjpeg.c
上传用户:zlh9724
上传日期:2007-01-04
资源大小:1991k
文件大小:19k
源码类别:

浏览器

开发平台:

Unix_Linux

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