djpeg.c
Go to the documentation of this file.
00001 /*
00002  * djpeg.c
00003  *
00004  * Copyright (C) 1991-1997, Thomas G. Lane.
00005  * This file is part of the Independent JPEG Group's software.
00006  * For conditions of distribution and use, see the accompanying README file.
00007  *
00008  * This file contains a command-line user interface for the JPEG decompressor.
00009  * It should work on any system with Unix- or MS-DOS-style command lines.
00010  *
00011  * Two different command line styles are permitted, depending on the
00012  * compile-time switch TWO_FILE_COMMANDLINE:
00013  *      djpeg [options]  inputfile outputfile
00014  *      djpeg [options]  [inputfile]
00015  * In the second style, output is always to standard output, which you'd
00016  * normally redirect to a file or pipe to some other program.  Input is
00017  * either from a named file or from standard input (typically redirected).
00018  * The second style is convenient on Unix but is unhelpful on systems that
00019  * don't support pipes.  Also, you MUST use the first style if your system
00020  * doesn't do binary I/O to stdin/stdout.
00021  * To simplify script writing, the "-outfile" switch is provided.  The syntax
00022  *      djpeg [options]  -outfile outputfile  inputfile
00023  * works regardless of which command line style is used.
00024  */
00025 
00026 #include "cdjpeg.h"             /* Common decls for cjpeg/djpeg applications */
00027 #include "jversion.h"           /* for version message */
00028 
00029 #include <ctype.h>              /* to declare isprint() */
00030 
00031 #ifdef USE_CCOMMAND             /* command-line reader for Macintosh */
00032 #ifdef __MWERKS__
00033 #include <SIOUX.h>              /* Metrowerks needs this */
00034 #include <console.h>            /* ... and this */
00035 #endif
00036 #ifdef THINK_C
00037 #include <console.h>            /* Think declares it here */
00038 #endif
00039 #endif
00040 
00041 
00042 /* Create the add-on message string table. */
00043 
00044 #define JMESSAGE(code,string)   string ,
00045 
00046 static const char * const cdjpeg_message_table[] = {
00047 #include "cderror.h"
00048   NULL
00049 };
00050 
00051 
00052 /*
00053  * This list defines the known output image formats
00054  * (not all of which need be supported by a given version).
00055  * You can change the default output format by defining DEFAULT_FMT;
00056  * indeed, you had better do so if you undefine PPM_SUPPORTED.
00057  */
00058 
00059 typedef enum {
00060         FMT_BMP,                /* BMP format (Windows flavor) */
00061         FMT_GIF,                /* GIF format */
00062         FMT_OS2,                /* BMP format (OS/2 flavor) */
00063         FMT_PPM,                /* PPM/PGM (PBMPLUS formats) */
00064         FMT_RLE,                /* RLE format */
00065         FMT_TARGA,              /* Targa format */
00066         FMT_TIFF                /* TIFF format */
00067 } IMAGE_FORMATS;
00068 
00069 #ifndef DEFAULT_FMT             /* so can override from CFLAGS in Makefile */
00070 #define DEFAULT_FMT     FMT_PPM
00071 #endif
00072 
00073 static IMAGE_FORMATS requested_fmt;
00074 
00075 
00076 /*
00077  * Argument-parsing code.
00078  * The switch parser is designed to be useful with DOS-style command line
00079  * syntax, ie, intermixed switches and file names, where only the switches
00080  * to the left of a given file name affect processing of that file.
00081  * The main program in this file doesn't actually use this capability...
00082  */
00083 
00084 
00085 static const char * progname;   /* program name for error messages */
00086 static char * outfilename;      /* for -outfile switch */
00087 
00088 
00089 LOCAL(void)
00090 usage (void)
00091 /* complain about bad command line */
00092 {
00093   fprintf(stderr, "usage: %s [switches] ", progname);
00094 #ifdef TWO_FILE_COMMANDLINE
00095   fprintf(stderr, "inputfile outputfile\n");
00096 #else
00097   fprintf(stderr, "[inputfile]\n");
00098 #endif
00099 
00100   fprintf(stderr, "Switches (names may be abbreviated):\n");
00101   fprintf(stderr, "  -colors N      Reduce image to no more than N colors\n");
00102   fprintf(stderr, "  -fast          Fast, low-quality processing\n");
00103   fprintf(stderr, "  -grayscale     Force grayscale output\n");
00104 #ifdef IDCT_SCALING_SUPPORTED
00105   fprintf(stderr, "  -scale M/N     Scale output image by fraction M/N, eg, 1/8\n");
00106 #endif
00107 #ifdef BMP_SUPPORTED
00108   fprintf(stderr, "  -bmp           Select BMP output format (Windows style)%s\n",
00109           (DEFAULT_FMT == FMT_BMP ? " (default)" : ""));
00110 #endif
00111 #ifdef GIF_SUPPORTED
00112   fprintf(stderr, "  -gif           Select GIF output format%s\n",
00113           (DEFAULT_FMT == FMT_GIF ? " (default)" : ""));
00114 #endif
00115 #ifdef BMP_SUPPORTED
00116   fprintf(stderr, "  -os2           Select BMP output format (OS/2 style)%s\n",
00117           (DEFAULT_FMT == FMT_OS2 ? " (default)" : ""));
00118 #endif
00119 #ifdef PPM_SUPPORTED
00120   fprintf(stderr, "  -pnm           Select PBMPLUS (PPM/PGM) output format%s\n",
00121           (DEFAULT_FMT == FMT_PPM ? " (default)" : ""));
00122 #endif
00123 #ifdef RLE_SUPPORTED
00124   fprintf(stderr, "  -rle           Select Utah RLE output format%s\n",
00125           (DEFAULT_FMT == FMT_RLE ? " (default)" : ""));
00126 #endif
00127 #ifdef TARGA_SUPPORTED
00128   fprintf(stderr, "  -targa         Select Targa output format%s\n",
00129           (DEFAULT_FMT == FMT_TARGA ? " (default)" : ""));
00130 #endif
00131   fprintf(stderr, "Switches for advanced users:\n");
00132 #ifdef DCT_ISLOW_SUPPORTED
00133   fprintf(stderr, "  -dct int       Use integer DCT method%s\n",
00134           (JDCT_DEFAULT == JDCT_ISLOW ? " (default)" : ""));
00135 #endif
00136 #ifdef DCT_IFAST_SUPPORTED
00137   fprintf(stderr, "  -dct fast      Use fast integer DCT (less accurate)%s\n",
00138           (JDCT_DEFAULT == JDCT_IFAST ? " (default)" : ""));
00139 #endif
00140 #ifdef DCT_FLOAT_SUPPORTED
00141   fprintf(stderr, "  -dct float     Use floating-point DCT method%s\n",
00142           (JDCT_DEFAULT == JDCT_FLOAT ? " (default)" : ""));
00143 #endif
00144   fprintf(stderr, "  -dither fs     Use F-S dithering (default)\n");
00145   fprintf(stderr, "  -dither none   Don't use dithering in quantization\n");
00146   fprintf(stderr, "  -dither ordered  Use ordered dither (medium speed, quality)\n");
00147 #ifdef QUANT_2PASS_SUPPORTED
00148   fprintf(stderr, "  -map FILE      Map to colors used in named image file\n");
00149 #endif
00150   fprintf(stderr, "  -nosmooth      Don't use high-quality upsampling\n");
00151 #ifdef QUANT_1PASS_SUPPORTED
00152   fprintf(stderr, "  -onepass       Use 1-pass quantization (fast, low quality)\n");
00153 #endif
00154   fprintf(stderr, "  -maxmemory N   Maximum memory to use (in kbytes)\n");
00155   fprintf(stderr, "  -outfile name  Specify name for output file\n");
00156   fprintf(stderr, "  -verbose  or  -debug   Emit debug output\n");
00157   exit(EXIT_FAILURE);
00158 }
00159 
00160 
00161 LOCAL(int)
00162 parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
00163                 int last_file_arg_seen, boolean for_real)
00164 /* Parse optional switches.
00165  * Returns argv[] index of first file-name argument (== argc if none).
00166  * Any file names with indexes <= last_file_arg_seen are ignored;
00167  * they have presumably been processed in a previous iteration.
00168  * (Pass 0 for last_file_arg_seen on the first or only iteration.)
00169  * for_real is FALSE on the first (dummy) pass; we may skip any expensive
00170  * processing.
00171  */
00172 {
00173   int argn;
00174   char * arg;
00175 
00176   /* Set up default JPEG parameters. */
00177   requested_fmt = DEFAULT_FMT;  /* set default output file format */
00178   outfilename = NULL;
00179   cinfo->err->trace_level = 0;
00180 
00181   /* Scan command line options, adjust parameters */
00182 
00183   for (argn = 1; argn < argc; argn++) {
00184     arg = argv[argn];
00185     if (*arg != '-') {
00186       /* Not a switch, must be a file name argument */
00187       if (argn <= last_file_arg_seen) {
00188         outfilename = NULL;     /* -outfile applies to just one input file */
00189         continue;               /* ignore this name if previously processed */
00190       }
00191       break;                    /* else done parsing switches */
00192     }
00193     arg++;                      /* advance past switch marker character */
00194 
00195     if (keymatch(arg, "bmp", 1)) {
00196       /* BMP output format. */
00197       requested_fmt = FMT_BMP;
00198 
00199     } else if (keymatch(arg, "colors", 1) || keymatch(arg, "colours", 1) ||
00200                keymatch(arg, "quantize", 1) || keymatch(arg, "quantise", 1)) {
00201       /* Do color quantization. */
00202       int val;
00203 
00204       if (++argn >= argc)       /* advance to next argument */
00205         usage();
00206       if (sscanf(argv[argn], "%d", &val) != 1)
00207         usage();
00208       cinfo->desired_number_of_colors = val;
00209       cinfo->quantize_colors = TRUE;
00210 
00211     } else if (keymatch(arg, "dct", 2)) {
00212       /* Select IDCT algorithm. */
00213       if (++argn >= argc)       /* advance to next argument */
00214         usage();
00215       if (keymatch(argv[argn], "int", 1)) {
00216         cinfo->dct_method = JDCT_ISLOW;
00217       } else if (keymatch(argv[argn], "fast", 2)) {
00218         cinfo->dct_method = JDCT_IFAST;
00219       } else if (keymatch(argv[argn], "float", 2)) {
00220         cinfo->dct_method = JDCT_FLOAT;
00221       } else
00222         usage();
00223 
00224     } else if (keymatch(arg, "dither", 2)) {
00225       /* Select dithering algorithm. */
00226       if (++argn >= argc)       /* advance to next argument */
00227         usage();
00228       if (keymatch(argv[argn], "fs", 2)) {
00229         cinfo->dither_mode = JDITHER_FS;
00230       } else if (keymatch(argv[argn], "none", 2)) {
00231         cinfo->dither_mode = JDITHER_NONE;
00232       } else if (keymatch(argv[argn], "ordered", 2)) {
00233         cinfo->dither_mode = JDITHER_ORDERED;
00234       } else
00235         usage();
00236 
00237     } else if (keymatch(arg, "debug", 1) || keymatch(arg, "verbose", 1)) {
00238       /* Enable debug printouts. */
00239       /* On first -d, print version identification */
00240       static boolean printed_version = FALSE;
00241 
00242       if (! printed_version) {
00243         fprintf(stderr, "Independent JPEG Group's DJPEG, version %s\n%s\n",
00244                 JVERSION, JCOPYRIGHT);
00245         printed_version = TRUE;
00246       }
00247       cinfo->err->trace_level++;
00248 
00249     } else if (keymatch(arg, "fast", 1)) {
00250       /* Select recommended processing options for quick-and-dirty output. */
00251       cinfo->two_pass_quantize = FALSE;
00252       cinfo->dither_mode = JDITHER_ORDERED;
00253       if (! cinfo->quantize_colors) /* don't override an earlier -colors */
00254         cinfo->desired_number_of_colors = 216;
00255       cinfo->dct_method = JDCT_FASTEST;
00256       cinfo->do_fancy_upsampling = FALSE;
00257 
00258     } else if (keymatch(arg, "gif", 1)) {
00259       /* GIF output format. */
00260       requested_fmt = FMT_GIF;
00261 
00262     } else if (keymatch(arg, "grayscale", 2) || keymatch(arg, "greyscale",2)) {
00263       /* Force monochrome output. */
00264       cinfo->out_color_space = JCS_GRAYSCALE;
00265 
00266     } else if (keymatch(arg, "map", 3)) {
00267       /* Quantize to a color map taken from an input file. */
00268       if (++argn >= argc)       /* advance to next argument */
00269         usage();
00270       if (for_real) {           /* too expensive to do twice! */
00271 #ifdef QUANT_2PASS_SUPPORTED    /* otherwise can't quantize to supplied map */
00272         FILE * mapfile;
00273 
00274         if ((mapfile = fopen(argv[argn], READ_BINARY)) == NULL) {
00275           fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]);
00276           exit(EXIT_FAILURE);
00277         }
00278         read_color_map(cinfo, mapfile);
00279         fclose(mapfile);
00280         cinfo->quantize_colors = TRUE;
00281 #else
00282         ERREXIT(cinfo, JERR_NOT_COMPILED);
00283 #endif
00284       }
00285 
00286     } else if (keymatch(arg, "maxmemory", 3)) {
00287       /* Maximum memory in Kb (or Mb with 'm'). */
00288       long lval;
00289       char ch = 'x';
00290 
00291       if (++argn >= argc)       /* advance to next argument */
00292         usage();
00293       if (sscanf(argv[argn], "%ld%c", &lval, &ch) < 1)
00294         usage();
00295       if (ch == 'm' || ch == 'M')
00296         lval *= 1000L;
00297       cinfo->mem->max_memory_to_use = lval * 1000L;
00298 
00299     } else if (keymatch(arg, "nosmooth", 3)) {
00300       /* Suppress fancy upsampling */
00301       cinfo->do_fancy_upsampling = FALSE;
00302 
00303     } else if (keymatch(arg, "onepass", 3)) {
00304       /* Use fast one-pass quantization. */
00305       cinfo->two_pass_quantize = FALSE;
00306 
00307     } else if (keymatch(arg, "os2", 3)) {
00308       /* BMP output format (OS/2 flavor). */
00309       requested_fmt = FMT_OS2;
00310 
00311     } else if (keymatch(arg, "outfile", 4)) {
00312       /* Set output file name. */
00313       if (++argn >= argc)       /* advance to next argument */
00314         usage();
00315       outfilename = argv[argn]; /* save it away for later use */
00316 
00317     } else if (keymatch(arg, "pnm", 1) || keymatch(arg, "ppm", 1)) {
00318       /* PPM/PGM output format. */
00319       requested_fmt = FMT_PPM;
00320 
00321     } else if (keymatch(arg, "rle", 1)) {
00322       /* RLE output format. */
00323       requested_fmt = FMT_RLE;
00324 
00325     } else if (keymatch(arg, "scale", 1)) {
00326       /* Scale the output image by a fraction M/N. */
00327       if (++argn >= argc)       /* advance to next argument */
00328         usage();
00329       if (sscanf(argv[argn], "%d/%d",
00330                  &cinfo->scale_num, &cinfo->scale_denom) != 2)
00331         usage();
00332 
00333     } else if (keymatch(arg, "targa", 1)) {
00334       /* Targa output format. */
00335       requested_fmt = FMT_TARGA;
00336 
00337     } else {
00338       usage();                  /* bogus switch */
00339     }
00340   }
00341 
00342   return argn;                  /* return index of next arg (file name) */
00343 }
00344 
00345 
00346 /*
00347  * Marker processor for COM and interesting APPn markers.
00348  * This replaces the library's built-in processor, which just skips the marker.
00349  * We want to print out the marker as text, to the extent possible.
00350  * Note this code relies on a non-suspending data source.
00351  */
00352 
00353 LOCAL(unsigned int)
00354 jpeg_getc (j_decompress_ptr cinfo)
00355 /* Read next byte */
00356 {
00357   struct jpeg_source_mgr * datasrc = cinfo->src;
00358 
00359   if (datasrc->bytes_in_buffer == 0) {
00360     if (! (*datasrc->fill_input_buffer) (cinfo))
00361       ERREXIT(cinfo, JERR_CANT_SUSPEND);
00362   }
00363   datasrc->bytes_in_buffer--;
00364   return GETJOCTET(*datasrc->next_input_byte++);
00365 }
00366 
00367 
00368 METHODDEF(boolean)
00369 print_text_marker (j_decompress_ptr cinfo)
00370 {
00371   boolean traceit = (cinfo->err->trace_level >= 1);
00372   INT32 length;
00373   unsigned int ch;
00374   unsigned int lastch = 0;
00375 
00376   length = jpeg_getc(cinfo) << 8;
00377   length += jpeg_getc(cinfo);
00378   length -= 2;                  /* discount the length word itself */
00379 
00380   if (traceit) {
00381     if (cinfo->unread_marker == JPEG_COM)
00382       fprintf(stderr, "Comment, length %ld:\n", (long) length);
00383     else                        /* assume it is an APPn otherwise */
00384       fprintf(stderr, "APP%d, length %ld:\n",
00385               cinfo->unread_marker - JPEG_APP0, (long) length);
00386   }
00387 
00388   while (--length >= 0) {
00389     ch = jpeg_getc(cinfo);
00390     if (traceit) {
00391       /* Emit the character in a readable form.
00392        * Nonprintables are converted to \nnn form,
00393        * while \ is converted to \\.
00394        * Newlines in CR, CR/LF, or LF form will be printed as one newline.
00395        */
00396       if (ch == '\r') {
00397         fprintf(stderr, "\n");
00398       } else if (ch == '\n') {
00399         if (lastch != '\r')
00400           fprintf(stderr, "\n");
00401       } else if (ch == '\\') {
00402         fprintf(stderr, "\\\\");
00403       } else if (isprint(ch)) {
00404         putc(ch, stderr);
00405       } else {
00406         fprintf(stderr, "\\%03o", ch);
00407       }
00408       lastch = ch;
00409     }
00410   }
00411 
00412   if (traceit)
00413     fprintf(stderr, "\n");
00414 
00415   return TRUE;
00416 }
00417 
00418 
00419 /*
00420  * The main program.
00421  */
00422 
00423 int
00424 main (int argc, char **argv)
00425 {
00426   struct jpeg_decompress_struct cinfo;
00427   struct jpeg_error_mgr jerr;
00428 #ifdef PROGRESS_REPORT
00429   struct cdjpeg_progress_mgr progress;
00430 #endif
00431   int file_index;
00432   djpeg_dest_ptr dest_mgr = NULL;
00433   FILE * input_file;
00434   FILE * output_file;
00435   JDIMENSION num_scanlines;
00436 
00437   /* On Mac, fetch a command line. */
00438 #ifdef USE_CCOMMAND
00439   argc = ccommand(&argv);
00440 #endif
00441 
00442   progname = argv[0];
00443   if (progname == NULL || progname[0] == 0)
00444     progname = "djpeg";         /* in case C library doesn't provide it */
00445 
00446   /* Initialize the JPEG decompression object with default error handling. */
00447   cinfo.err = jpeg_std_error(&jerr);
00448   jpeg_create_decompress(&cinfo);
00449   /* Add some application-specific error messages (from cderror.h) */
00450   jerr.addon_message_table = cdjpeg_message_table;
00451   jerr.first_addon_message = JMSG_FIRSTADDONCODE;
00452   jerr.last_addon_message = JMSG_LASTADDONCODE;
00453 
00454   /* Insert custom marker processor for COM and APP12.
00455    * APP12 is used by some digital camera makers for textual info,
00456    * so we provide the ability to display it as text.
00457    * If you like, additional APPn marker types can be selected for display,
00458    * but don't try to override APP0 or APP14 this way (see libjpeg.doc).
00459    */
00460   jpeg_set_marker_processor(&cinfo, JPEG_COM, print_text_marker);
00461   jpeg_set_marker_processor(&cinfo, JPEG_APP0+12, print_text_marker);
00462 
00463   /* Now safe to enable signal catcher. */
00464 #ifdef NEED_SIGNAL_CATCHER
00465   enable_signal_catcher((j_common_ptr) &cinfo);
00466 #endif
00467 
00468   /* Scan command line to find file names. */
00469   /* It is convenient to use just one switch-parsing routine, but the switch
00470    * values read here are ignored; we will rescan the switches after opening
00471    * the input file.
00472    * (Exception: tracing level set here controls verbosity for COM markers
00473    * found during jpeg_read_header...)
00474    */
00475 
00476   file_index = parse_switches(&cinfo, argc, argv, 0, FALSE);
00477 
00478 #ifdef TWO_FILE_COMMANDLINE
00479   /* Must have either -outfile switch or explicit output file name */
00480   if (outfilename == NULL) {
00481     if (file_index != argc-2) {
00482       fprintf(stderr, "%s: must name one input and one output file\n",
00483               progname);
00484       usage();
00485     }
00486     outfilename = argv[file_index+1];
00487   } else {
00488     if (file_index != argc-1) {
00489       fprintf(stderr, "%s: must name one input and one output file\n",
00490               progname);
00491       usage();
00492     }
00493   }
00494 #else
00495   /* Unix style: expect zero or one file name */
00496   if (file_index < argc-1) {
00497     fprintf(stderr, "%s: only one input file\n", progname);
00498     usage();
00499   }
00500 #endif /* TWO_FILE_COMMANDLINE */
00501 
00502   /* Open the input file. */
00503   if (file_index < argc) {
00504     if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {
00505       fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]);
00506       exit(EXIT_FAILURE);
00507     }
00508   } else {
00509     /* default input file is stdin */
00510     input_file = read_stdin();
00511   }
00512 
00513   /* Open the output file. */
00514   if (outfilename != NULL) {
00515     if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {
00516       fprintf(stderr, "%s: can't open %s\n", progname, outfilename);
00517       exit(EXIT_FAILURE);
00518     }
00519   } else {
00520     /* default output file is stdout */
00521     output_file = write_stdout();
00522   }
00523 
00524 #ifdef PROGRESS_REPORT
00525   start_progress_monitor((j_common_ptr) &cinfo, &progress);
00526 #endif
00527 
00528   /* Specify data source for decompression */
00529   jpeg_stdio_src(&cinfo, input_file);
00530 
00531   /* Read file header, set default decompression parameters */
00532   (void) jpeg_read_header(&cinfo, TRUE);
00533 
00534   /* Adjust default decompression parameters by re-parsing the options */
00535   file_index = parse_switches(&cinfo, argc, argv, 0, TRUE);
00536 
00537   /* Initialize the output module now to let it override any crucial
00538    * option settings (for instance, GIF wants to force color quantization).
00539    */
00540   switch (requested_fmt) {
00541 #ifdef BMP_SUPPORTED
00542   case FMT_BMP:
00543     dest_mgr = jinit_write_bmp(&cinfo, FALSE);
00544     break;
00545   case FMT_OS2:
00546     dest_mgr = jinit_write_bmp(&cinfo, TRUE);
00547     break;
00548 #endif
00549 #ifdef GIF_SUPPORTED
00550   case FMT_GIF:
00551     dest_mgr = jinit_write_gif(&cinfo);
00552     break;
00553 #endif
00554 #ifdef PPM_SUPPORTED
00555   case FMT_PPM:
00556     dest_mgr = jinit_write_ppm(&cinfo);
00557     break;
00558 #endif
00559 #ifdef RLE_SUPPORTED
00560   case FMT_RLE:
00561     dest_mgr = jinit_write_rle(&cinfo);
00562     break;
00563 #endif
00564 #ifdef TARGA_SUPPORTED
00565   case FMT_TARGA:
00566     dest_mgr = jinit_write_targa(&cinfo);
00567     break;
00568 #endif
00569   default:
00570     ERREXIT(&cinfo, JERR_UNSUPPORTED_FORMAT);
00571     break;
00572   }
00573   dest_mgr->output_file = output_file;
00574 
00575   /* Start decompressor */
00576   (void) jpeg_start_decompress(&cinfo);
00577 
00578   /* Write output file header */
00579   (*dest_mgr->start_output) (&cinfo, dest_mgr);
00580 
00581   /* Process data */
00582   while (cinfo.output_scanline < cinfo.output_height) {
00583     num_scanlines = jpeg_read_scanlines(&cinfo, dest_mgr->buffer,
00584                                         dest_mgr->buffer_height);
00585     (*dest_mgr->put_pixel_rows) (&cinfo, dest_mgr, num_scanlines);
00586   }
00587 
00588 #ifdef PROGRESS_REPORT
00589   /* Hack: count final pass as done in case finish_output does an extra pass.
00590    * The library won't have updated completed_passes.
00591    */
00592   progress.pub.completed_passes = progress.pub.total_passes;
00593 #endif
00594 
00595   /* Finish decompression and release memory.
00596    * I must do it in this order because output module has allocated memory
00597    * of lifespan JPOOL_IMAGE; it needs to finish before releasing memory.
00598    */
00599   (*dest_mgr->finish_output) (&cinfo, dest_mgr);
00600   (void) jpeg_finish_decompress(&cinfo);
00601   jpeg_destroy_decompress(&cinfo);
00602 
00603   /* Close files, if we opened them */
00604   if (input_file != stdin)
00605     fclose(input_file);
00606   if (output_file != stdout)
00607     fclose(output_file);
00608 
00609 #ifdef PROGRESS_REPORT
00610   end_progress_monitor((j_common_ptr) &cinfo);
00611 #endif
00612 
00613   /* All done. */
00614   exit(jerr.num_warnings ? EXIT_WARNING : EXIT_SUCCESS);
00615   return 0;                     /* suppress no-return-value warnings */
00616 }


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Apr 11 2019 03:30:16