home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume29 / jpeg / part13 < prev    next >
Encoding:
Text File  |  1992-03-27  |  53.7 KB  |  1,632 lines

  1. Newsgroups: comp.sources.misc
  2. From: jpeg-info@uunet.uu.net (Independent JPEG Group)
  3. Subject:  v29i013:  jpeg - JPEG image compression, Part13/18
  4. Message-ID: <1992Mar25.145314.587@sparky.imd.sterling.com>
  5. X-Md4-Signature: dd9a990254c73b0a65c23d38b2fced8d
  6. Date: Wed, 25 Mar 1992 14:53:14 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: jpeg-info@uunet.uu.net (Independent JPEG Group)
  10. Posting-number: Volume 29, Issue 13
  11. Archive-name: jpeg/part13
  12. Environment: UNIX, VMS, MS-DOS, Mac, Amiga, Cray
  13.  
  14. #! /bin/sh
  15. # into a shell via "sh file" or similar.  To overwrite existing files,
  16. # type "sh file -c".
  17. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  18. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  19. # Contents:  USAGE jconfig.h jdcolor.c jdmain.c jrdrle.c
  20. # Wrapped by kent@sparky on Mon Mar 23 16:02:53 1992
  21. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  22. echo If this archive is complete, you will see the following message:
  23. echo '          "shar: End of archive 13 (of 18)."'
  24. if test -f 'USAGE' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'USAGE'\"
  26. else
  27.   echo shar: Extracting \"'USAGE'\" \(9783 characters\)
  28.   sed "s/^X//" >'USAGE' <<'END_OF_FILE'
  29. XUSAGE instructions for the Independent JPEG Group's JPEG software
  30. X=================================================================
  31. X
  32. XINTRODUCTION
  33. X
  34. XThis distribution contains software to implement JPEG image compression and
  35. Xdecompression.  JPEG (pronounced "jay-peg") is a standardized compression
  36. Xmethod for full-color and gray-scale images.  JPEG is designed to handle
  37. X"real-world" scenes, for example scanned photographs.  Cartoons, line
  38. Xdrawings, and other non-realistic images are not JPEG's strong suit; on this
  39. Xsort of material you may get poor image quality and/or little compression.
  40. X
  41. XJPEG is lossy, meaning that the output image is not necessarily identical to
  42. Xthe input image.  Hence you should not use JPEG if you have to have identical
  43. Xoutput bits.  However, on typical real-world images, very good compression
  44. Xlevels can be obtained with no visible change, and amazingly high compression
  45. Xis possible if you can tolerate a low-quality image.  You can trade off image
  46. Xquality against file size by adjusting the compressor's "quality" setting.
  47. X
  48. XThis file describes usage of the standard programs "cjpeg" and "djpeg" that
  49. Xcan be built directly from the distributed C code.  See the README file for
  50. Xhints on incorporating the JPEG software into other programs.
  51. X
  52. XIf you are on a Unix machine you may prefer to read the Unix-style manual
  53. Xpages in files cjpeg.1 and djpeg.1.
  54. X
  55. XNOTE: at some point we will probably redesign the user interface, so the
  56. Xcommand line switches described here will change.
  57. X
  58. X
  59. XGENERAL USAGE
  60. X
  61. XWe provide two programs, cjpeg to compress an image file into JPEG format,
  62. Xand djpeg to decompress a JPEG file back into a conventional image format.
  63. X
  64. XOn Unix-like systems, you say:
  65. X    cjpeg [switches] [imagefile] >jpegfile
  66. Xor
  67. X    djpeg [switches] [jpegfile]  >imagefile
  68. XThe programs read the specified input file, or standard input if none is
  69. Xnamed.  They always write to standard output (with trace/error messages to
  70. Xstandard error).  These conventions are handy for piping images between
  71. Xprograms.
  72. X
  73. XOn most non-Unix systems, you say:
  74. X    cjpeg [switches] imagefile jpegfile
  75. Xor
  76. X    djpeg [switches] jpegfile  imagefile
  77. Xi.e., both the input and output files are named on the command line.  This
  78. Xstyle is a little more foolproof, and it loses no functionality if you don't
  79. Xhave pipes.  (You can get this style on Unix too, if you prefer, by defining
  80. XTWO_FILE_COMMANDLINE when you compile the programs; see SETUP.)
  81. X
  82. XThe currently supported image file formats are: PPM (PBMPLUS color format),
  83. XPGM (PBMPLUS gray-scale format), GIF, Targa, and RLE (Utah Raster Toolkit
  84. Xformat).  (RLE is supported only if the URT library is available.)
  85. Xcjpeg recognizes the input image format automatically, with the exception
  86. Xof some Targa-format files.  You have to tell djpeg which format to generate.
  87. X
  88. XThe only JPEG file format currently supported is the JFIF format.  Support for
  89. Xthe TIFF/JPEG format will probably be added at some future date.
  90. X
  91. X
  92. XCJPEG DETAILS
  93. X
  94. XThe command line switches for cjpeg are:
  95. X
  96. X    -Q quality    Scale quantization tables to adjust image quality.
  97. X            Quality is 0 (worst) to 100 (best); default is 75.
  98. X            (See below for more info.)
  99. X
  100. X    -o        Perform optimization of entropy encoding parameters.
  101. X            Without this, default encoding parameters are used.
  102. X            -o usually makes the JPEG file a little smaller, but
  103. X            cjpeg runs somewhat slower and needs much more memory.
  104. X            Image quality and speed of decompression are unaffected
  105. X            by -o.
  106. X
  107. X    -T        Input file is Targa format.  Targa files that contain
  108. X            an "identification" field will not be automatically
  109. X            recognized by cjpeg; for such files you must specify
  110. X            -T to force cjpeg to treat the input as Targa format.
  111. X
  112. X    -I        Generate noninterleaved JPEG file (not yet supported).
  113. X
  114. X    -a        Use arithmetic coding rather than Huffman coding.
  115. X            (Not currently supported for legal reasons.)
  116. X
  117. X    -d        Enable debug printout.  More -d's give more printout.
  118. X            Also, version information is printed at startup.
  119. X
  120. X    -m memory    Set limit for amount of memory to use in processing
  121. X            large images.  Value is in thousands of bytes, or
  122. X            millions of bytes if "M" is attached to the number.
  123. X            For example, -m 4m selects 4000000 bytes.  If more
  124. X            space is needed, temporary files will be used.
  125. X
  126. XThe -Q switch lets you trade off compressed file size against quality of the
  127. Xreconstructed image: the higher the -Q setting, the larger the JPEG file, and
  128. Xthe closer the output image will be to the original input.  Normally you want
  129. Xto use the lowest -Q setting (smallest file) that decompresses into something
  130. Xvisually indistinguishable from the original image.  For this purpose the -Q
  131. Xsetting should be between 50 and 95; the default of 75 is often about right.
  132. XIf you see defects at -Q 75, then go up 5 or 10 counts at a time until you are
  133. Xhappy with the output image.  (The optimal setting will vary from one image to
  134. Xanother.)
  135. X
  136. X-Q 100 will generate a quantization table of all 1's, eliminating loss in the
  137. Xquantization step (but there is still information loss in subsampling, as well
  138. Xas roundoff error).  This setting is mainly of interest for experimental
  139. Xpurposes.  -Q values above about 95 are NOT recommended for normal use; the
  140. Xcompressed file size goes up dramatically for hardly any gain in output image
  141. Xquality.
  142. X
  143. XIn the other direction, -Q values below 50 will produce very small files of
  144. Xlow image quality.  Settings around 5 to 10 might be useful in preparing an
  145. Xindex of a large image library, for example.  Try -Q 2 (or so) for some
  146. Xamusing Cubist effects.  (Note: -Q values below about 25 generate 2-byte
  147. Xquantization tables, which are considered optional in the JPEG standard.
  148. Xcjpeg emits a warning message when you give such a -Q value, because some
  149. Xcommercial JPEG programs may be unable to decode the resulting file.)
  150. X
  151. X
  152. XDJPEG DETAILS
  153. X
  154. XThe command line switches for djpeg are:
  155. X
  156. X    -G        Select GIF output format (implies -q, with default
  157. X            of 256 colors).
  158. X
  159. X    -P        Select PPM or PGM output format (this is the default).
  160. X            PGM is emitted if the JPEG file is gray-scale or if -g
  161. X            is specified.
  162. X
  163. X    -R        Select RLE output format.  Requires URT library.
  164. X
  165. X    -T        Select Targa output format.  Gray-scale format is
  166. X            emitted if the JPEG file is gray-scale or if -g is
  167. X            specified; otherwise, colormapped format is emitted
  168. X            if -q is specified; otherwise, 24-bit full-color
  169. X            format is emitted.
  170. X
  171. X    -g        Force gray-scale output even if input is color.
  172. X
  173. X    -q N        Quantize to N colors.  This reduces the number of
  174. X            colors in the output image so that it can be displayed
  175. X            on a colormapped display or stored in a colormapped
  176. X            file format.  For example, if you have an 8-bit
  177. X            display, you'd need to quantize to 256 or fewer colors.
  178. X
  179. X    -D        Do not use dithering in color quantization.
  180. X            By default, Floyd-Steinberg dithering is applied when
  181. X            quantizing colors, but on some images dithering may
  182. X            result in objectionable "graininess".  If that
  183. X            happens, you can turn off dithering with -D.
  184. X            -D is ignored unless you also say -q or -G.
  185. X
  186. X    -1        Use one-pass instead of two-pass color quantization.
  187. X            The one-pass method is faster and needs less memory,
  188. X            but it produces a lower-quality image.
  189. X            -1 is ignored unless you also say -q or -G.  Also,
  190. X            the one-pass method is always used for gray-scale
  191. X            output (the two-pass method is no improvement then).
  192. X
  193. X    -b        Perform cross-block smoothing.  This is quite
  194. X            memory-intensive and only seems to improve the image
  195. X            at very low quality settings (-Q 10 to 20 or so).
  196. X            At normal -Q settings it may make the image worse.
  197. X
  198. X    -d        Enable debug printout.  More -d's give more printout.
  199. X            Also, version information is printed at startup.
  200. X
  201. X    -m memory    Set limit for amount of memory to use in processing
  202. X            large images.  Value is in thousands of bytes, or
  203. X            millions of bytes if "M" is attached to the number.
  204. X            For example, -m 4m selects 4000000 bytes.  If more
  205. X            space is needed, temporary files will be used.
  206. X
  207. X
  208. XHINTS
  209. X
  210. XAvoid running an image through a series of JPEG compression/decompression
  211. Xcycles.  Image quality loss will accumulate; after ten or so cycles the image
  212. Xmay be noticeably worse than it was after one cycle.  It's best to use a
  213. Xlossless format while manipulating an image, then convert to JPEG format when
  214. Xyou are ready to file the image away.
  215. X
  216. XThe -o option to cjpeg is worth using when you are making a "final" version
  217. Xfor posting or archiving.  It's also a win when you are using low -Q settings
  218. Xto make very small JPEG files; the percentage improvement is often a lot more
  219. Xthan it is on larger files.
  220. X
  221. XThe default memory usage limit (-m) is set when the software is compiled.
  222. XIf you get an "insufficient memory" error, try specifying a smaller -m value,
  223. Xeven -m 0 to use the absolute minimum space.  You may want to recompile with
  224. Xa smaller default value if this happens often.
  225. X
  226. Xdjpeg with two-pass color quantization requires a good deal of space; on
  227. XMS-DOS machines it may run out of memory even with -m 0.  In that case you
  228. Xcan still decompress, with some loss of image quality, by specifying -1
  229. Xfor one-pass quantization.
  230. X
  231. XIf more space is needed than will fit in the available main memory (as
  232. Xdetermined by -m), temporary files will be used.  (MS-DOS versions will try to
  233. Xget extended or expanded memory first.)  The temporary files are often rather
  234. Xlarge: in typical cases they occupy three bytes per pixel, for example
  235. X3*800*600 = 1.44Mb for an 800x600 image.  If you don't have enough free disk
  236. Xspace, leave out -o (for cjpeg) or specify -1 (for djpeg).  On MS-DOS, the
  237. Xtemporary files are created in the directory named by the TMP or TEMP
  238. Xenvironment variable, or in the current directory if neither of those exist.
  239. XAmiga implementations put the temp files in the directory named by JPEGTMP:,
  240. Xso be sure to assign JPEGTMP: to a disk partition with adequate free space.
  241. END_OF_FILE
  242.   if test 9783 -ne `wc -c <'USAGE'`; then
  243.     echo shar: \"'USAGE'\" unpacked with wrong size!
  244.   fi
  245.   # end of 'USAGE'
  246. fi
  247. if test -f 'jconfig.h' -a "${1}" != "-c" ; then 
  248.   echo shar: Will not clobber existing file \"'jconfig.h'\"
  249. else
  250.   echo shar: Extracting \"'jconfig.h'\" \(11361 characters\)
  251.   sed "s/^X//" >'jconfig.h' <<'END_OF_FILE'
  252. X/*
  253. X * jconfig.h
  254. X *
  255. X * Copyright (C) 1991, 1992, Thomas G. Lane.
  256. X * This file is part of the Independent JPEG Group's software.
  257. X * For conditions of distribution and use, see the accompanying README file.
  258. X *
  259. X * This file contains preprocessor declarations that help customize
  260. X * the JPEG software for a particular application, machine, or compiler.
  261. X * Edit these declarations as needed (or add -D flags to the Makefile).
  262. X */
  263. X
  264. X
  265. X/*
  266. X * These symbols indicate the properties of your machine or compiler.
  267. X * The conditional definitions given may do the right thing already,
  268. X * but you'd best look them over closely, especially if your compiler
  269. X * does not handle full ANSI C.  An ANSI-compliant C compiler should
  270. X * provide all the necessary features; __STDC__ is supposed to be
  271. X * predefined by such compilers.
  272. X */
  273. X
  274. X/*
  275. X * HAVE_STDC is tested below to see whether ANSI features are available.
  276. X * We avoid testing __STDC__ directly for arcane reasons of portability.
  277. X * (On some compilers, __STDC__ is only defined if a switch is given,
  278. X * but the switch also disables machine-specific features we need to get at.
  279. X * In that case, -DHAVE_STDC in the Makefile is a convenient solution.)
  280. X */
  281. X
  282. X#ifdef __STDC__            /* if compiler claims to be ANSI, believe it */
  283. X#define HAVE_STDC
  284. X#endif
  285. X
  286. X
  287. X/* Does your compiler support function prototypes? */
  288. X/* (If not, you also need to use ansi2knr, see SETUP) */
  289. X
  290. X#ifdef HAVE_STDC        /* ANSI C compilers always have prototypes */
  291. X#define PROTO
  292. X#else
  293. X#ifdef __cplusplus        /* So do C++ compilers */
  294. X#define PROTO
  295. X#endif
  296. X#endif
  297. X
  298. X/* Does your compiler support the declaration "unsigned char" ? */
  299. X/* How about "unsigned short" ? */
  300. X
  301. X#ifdef HAVE_STDC        /* ANSI C compilers must support both */
  302. X#define HAVE_UNSIGNED_CHAR
  303. X#define HAVE_UNSIGNED_SHORT
  304. X#endif
  305. X
  306. X/* Define this if an ordinary "char" type is unsigned.
  307. X * If you're not sure, leaving it undefined will work at some cost in speed.
  308. X * If you defined HAVE_UNSIGNED_CHAR then it doesn't matter very much.
  309. X */
  310. X
  311. X/* #define CHAR_IS_UNSIGNED */
  312. X
  313. X/* Define this if your compiler implements ">>" on signed values as a logical
  314. X * (unsigned) shift; leave it undefined if ">>" is a signed (arithmetic) shift,
  315. X * which is the normal and rational definition.
  316. X */
  317. X
  318. X/* #define RIGHT_SHIFT_IS_UNSIGNED */
  319. X
  320. X/* Define "void" as "char" if your compiler doesn't know about type void.
  321. X * NOTE: be sure to define void such that "void *" represents the most general
  322. X * pointer type, e.g., that returned by malloc().
  323. X */
  324. X
  325. X/* #define void char */
  326. X
  327. X/* Define const as empty if your compiler doesn't know the "const" keyword. */
  328. X/* (Even if it does, defining const as empty won't break anything.) */
  329. X
  330. X#ifndef HAVE_STDC        /* ANSI C and C++ compilers should know it. */
  331. X#ifndef __cplusplus
  332. X#define const
  333. X#endif
  334. X#endif
  335. X
  336. X/* For 80x86 machines, you need to define NEED_FAR_POINTERS,
  337. X * unless you are using a large-data memory model or 80386 flat-memory mode.
  338. X * On less brain-damaged CPUs this symbol must not be defined.
  339. X * (Defining this symbol causes large data structures to be referenced through
  340. X * "far" pointers and to be allocated with a special version of malloc.)
  341. X */
  342. X
  343. X#ifdef MSDOS
  344. X#define NEED_FAR_POINTERS
  345. X#endif
  346. X
  347. X
  348. X/* The next three symbols only affect the system-dependent user interface
  349. X * modules (jcmain.c, jdmain.c).  You can ignore these if you are supplying
  350. X * your own user interface code.
  351. X */
  352. X
  353. X/* Define this if you want to name both input and output files on the command
  354. X * line, rather than using stdout and optionally stdin.  You MUST do this if
  355. X * your system can't cope with binary I/O to stdin/stdout.  See comments at
  356. X * head of jcmain.c or jdmain.c.
  357. X */
  358. X
  359. X#ifdef MSDOS            /* two-file style is needed for PCs */
  360. X#define TWO_FILE_COMMANDLINE
  361. X#endif
  362. X#ifdef THINK_C            /* needed for Macintosh too */
  363. X#define TWO_FILE_COMMANDLINE
  364. X#endif
  365. X
  366. X/* Define this if your system needs explicit cleanup of temporary files.
  367. X * This is crucial under MS-DOS, where the temporary "files" may be areas
  368. X * of extended memory; on most other systems it's not as important.
  369. X */
  370. X
  371. X#ifdef MSDOS
  372. X#define NEED_SIGNAL_CATCHER
  373. X#endif
  374. X
  375. X/* By default, we open image files with fopen(...,"rb") or fopen(...,"wb").
  376. X * This is necessary on systems that distinguish text files from binary files,
  377. X * and is harmless on most systems that don't.  If you have one of the rare
  378. X * systems that complains about the "b" spec, define this symbol.
  379. X */
  380. X
  381. X/* #define DONT_USE_B_MODE */
  382. X
  383. X
  384. X/* If you're getting bored, that's the end of the symbols you HAVE to
  385. X * worry about.  Go fix the makefile and compile.
  386. X */
  387. X
  388. X
  389. X/* On a few systems, type boolean and/or macros FALSE, TRUE may appear
  390. X * in standard header files.  Or you may have conflicts with application-
  391. X * specific header files that you want to include together with these files.
  392. X * In that case you need only comment out these definitions.
  393. X */
  394. X
  395. Xtypedef int boolean;
  396. X#undef FALSE            /* in case these macros already exist */
  397. X#undef TRUE
  398. X#define FALSE    0        /* values of boolean */
  399. X#define TRUE    1
  400. X
  401. X/* This defines the size of the I/O buffers for entropy compression
  402. X * and decompression; you could reduce it if memory is tight.
  403. X */
  404. X
  405. X#define JPEG_BUF_SIZE    4096 /* bytes */
  406. X
  407. X
  408. X
  409. X/* These symbols determine the JPEG functionality supported. */
  410. X
  411. X/*
  412. X * These defines indicate whether to include various optional functions.
  413. X * Undefining some of these symbols will produce a smaller but less capable
  414. X * program file.  Note that you can leave certain source files out of the
  415. X * compilation/linking process if you've #undef'd the corresponding symbols.
  416. X * (You may HAVE to do that if your compiler doesn't like null source files.)
  417. X */
  418. X
  419. X/* Arithmetic coding is unsupported for legal reasons.  Complaints to IBM. */
  420. X#undef  ARITH_CODING_SUPPORTED    /* Arithmetic coding back end? */
  421. X#define MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
  422. X#define ENTROPY_OPT_SUPPORTED    /* Optimization of entropy coding parms? */
  423. X#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing during decoding? */
  424. X#define QUANT_1PASS_SUPPORTED    /* 1-pass color quantization? */
  425. X#define QUANT_2PASS_SUPPORTED    /* 2-pass color quantization? */
  426. X/* these defines indicate which JPEG file formats are allowed */
  427. X#define JFIF_SUPPORTED        /* JFIF or "raw JPEG" files */
  428. X#undef  JTIFF_SUPPORTED        /* JPEG-in-TIFF (not yet implemented) */
  429. X/* these defines indicate which image (non-JPEG) file formats are allowed */
  430. X#define GIF_SUPPORTED        /* GIF image file format */
  431. X/* #define RLE_SUPPORTED */    /* RLE image file format (by default, no) */
  432. X#define PPM_SUPPORTED        /* PPM/PGM image file format */
  433. X#define TARGA_SUPPORTED        /* Targa image file format */
  434. X#undef  TIFF_SUPPORTED        /* TIFF image file format (not yet impl.) */
  435. X
  436. X/* more capability options later, no doubt */
  437. X
  438. X
  439. X/*
  440. X * Define exactly one of these three symbols to indicate whether you want
  441. X * 8-bit, 12-bit, or 16-bit sample (pixel component) values.  8-bit is the
  442. X * default and is nearly always the right thing to use.  You can use 12-bit if
  443. X * you need to support image formats with more than 8 bits of resolution in a
  444. X * color value.  16-bit should only be used for the lossless JPEG mode (not
  445. X * currently supported).  Note that 12- and 16-bit values take up twice as
  446. X * much memory as 8-bit!
  447. X * Note: if you select 12- or 16-bit precision, it is dangerous to turn off
  448. X * ENTROPY_OPT_SUPPORTED.  The standard Huffman tables are only good for 8-bit
  449. X * precision, so jchuff.c normally uses entropy optimization to compute
  450. X * usable tables for higher precision.  If you don't want to do optimization,
  451. X * you'll have to supply different default Huffman tables.
  452. X */
  453. X
  454. X#define EIGHT_BIT_SAMPLES
  455. X#undef  TWELVE_BIT_SAMPLES
  456. X#undef  SIXTEEN_BIT_SAMPLES
  457. X
  458. X
  459. X
  460. X/*
  461. X * The remaining definitions don't need to be hand-edited in most cases.
  462. X * You may need to change these if you have a machine with unusual data
  463. X * types; for example, "char" not 8 bits, "short" not 16 bits,
  464. X * or "long" not 32 bits.  We don't care whether "int" is 16 or 32 bits,
  465. X * but it had better be at least 16.
  466. X */
  467. X
  468. X/* First define the representation of a single pixel element value. */
  469. X
  470. X#ifdef EIGHT_BIT_SAMPLES
  471. X/* JSAMPLE should be the smallest type that will hold the values 0..255.
  472. X * You can use a signed char by having GETJSAMPLE mask it with 0xFF.
  473. X * If you have only signed chars, and you are more worried about speed than
  474. X * memory usage, it might be a win to make JSAMPLE be short.
  475. X */
  476. X
  477. X#ifdef HAVE_UNSIGNED_CHAR
  478. X
  479. Xtypedef unsigned char JSAMPLE;
  480. X#define GETJSAMPLE(value)  (value)
  481. X
  482. X#else /* not HAVE_UNSIGNED_CHAR */
  483. X#ifdef CHAR_IS_UNSIGNED
  484. X
  485. Xtypedef char JSAMPLE;
  486. X#define GETJSAMPLE(value)  (value)
  487. X
  488. X#else /* not CHAR_IS_UNSIGNED */
  489. X
  490. Xtypedef char JSAMPLE;
  491. X#define GETJSAMPLE(value)  ((value) & 0xFF)
  492. X
  493. X#endif /* CHAR_IS_UNSIGNED */
  494. X#endif /* HAVE_UNSIGNED_CHAR */
  495. X
  496. X#define BITS_IN_JSAMPLE   8
  497. X#define MAXJSAMPLE    255
  498. X#define CENTERJSAMPLE    128
  499. X
  500. X#endif /* EIGHT_BIT_SAMPLES */
  501. X
  502. X
  503. X#ifdef TWELVE_BIT_SAMPLES
  504. X/* JSAMPLE should be the smallest type that will hold the values 0..4095. */
  505. X/* On nearly all machines "short" will do nicely. */
  506. X
  507. Xtypedef short JSAMPLE;
  508. X#define GETJSAMPLE(value)  (value)
  509. X
  510. X#define BITS_IN_JSAMPLE   12
  511. X#define MAXJSAMPLE    4095
  512. X#define CENTERJSAMPLE    2048
  513. X
  514. X#endif /* TWELVE_BIT_SAMPLES */
  515. X
  516. X
  517. X#ifdef SIXTEEN_BIT_SAMPLES
  518. X/* JSAMPLE should be the smallest type that will hold the values 0..65535. */
  519. X
  520. X#ifdef HAVE_UNSIGNED_SHORT
  521. X
  522. Xtypedef unsigned short JSAMPLE;
  523. X#define GETJSAMPLE(value)  (value)
  524. X
  525. X#else /* not HAVE_UNSIGNED_SHORT */
  526. X
  527. X/* If int is 32 bits this'll be horrendously inefficient storage-wise.
  528. X * But since we don't actually support 16-bit samples (ie lossless coding) yet,
  529. X * I'm not going to worry about making a smarter definition ...
  530. X */
  531. Xtypedef unsigned int JSAMPLE;
  532. X#define GETJSAMPLE(value)  (value)
  533. X
  534. X#endif /* HAVE_UNSIGNED_SHORT */
  535. X
  536. X#define BITS_IN_JSAMPLE    16
  537. X#define MAXJSAMPLE    65535
  538. X#define CENTERJSAMPLE    32768
  539. X
  540. X#endif /* SIXTEEN_BIT_SAMPLES */
  541. X
  542. X
  543. X/* Here we define the representation of a DCT frequency coefficient.
  544. X * This should be a signed 16-bit value; "short" is usually right.
  545. X * It's important that this be exactly 16 bits, no more and no less;
  546. X * more will cost you a BIG hit of memory, less will give wrong answers.
  547. X */
  548. X
  549. Xtypedef short JCOEF;
  550. X
  551. X
  552. X/* The remaining typedefs are used for various table entries and so forth.
  553. X * They must be at least as wide as specified; but making them too big
  554. X * won't cost a huge amount of memory, so we don't provide special
  555. X * extraction code like we did for JSAMPLE.  (In other words, these
  556. X * typedefs live at a different point on the speed/space tradeoff curve.)
  557. X */
  558. X
  559. X/* UINT8 must hold at least the values 0..255. */
  560. X
  561. X#ifdef HAVE_UNSIGNED_CHAR
  562. Xtypedef unsigned char UINT8;
  563. X#else /* not HAVE_UNSIGNED_CHAR */
  564. X#ifdef CHAR_IS_UNSIGNED
  565. Xtypedef char UINT8;
  566. X#else /* not CHAR_IS_UNSIGNED */
  567. Xtypedef short UINT8;
  568. X#endif /* CHAR_IS_UNSIGNED */
  569. X#endif /* HAVE_UNSIGNED_CHAR */
  570. X
  571. X/* UINT16 must hold at least the values 0..65535. */
  572. X
  573. X#ifdef HAVE_UNSIGNED_SHORT
  574. Xtypedef unsigned short UINT16;
  575. X#else /* not HAVE_UNSIGNED_SHORT */
  576. Xtypedef unsigned int UINT16;
  577. X#endif /* HAVE_UNSIGNED_SHORT */
  578. X
  579. X/* INT16 must hold at least the values -32768..32767. */
  580. X
  581. X#ifndef XMD_H            /* X11/xmd.h correctly defines INT16 */
  582. Xtypedef short INT16;
  583. X#endif
  584. X
  585. X/* INT32 must hold signed 32-bit values; if your machine happens */
  586. X/* to have 64-bit longs, you might want to change this. */
  587. X
  588. X#ifndef XMD_H            /* X11/xmd.h correctly defines INT32 */
  589. Xtypedef long INT32;
  590. X#endif
  591. END_OF_FILE
  592.   if test 11361 -ne `wc -c <'jconfig.h'`; then
  593.     echo shar: \"'jconfig.h'\" unpacked with wrong size!
  594.   fi
  595.   # end of 'jconfig.h'
  596. fi
  597. if test -f 'jdcolor.c' -a "${1}" != "-c" ; then 
  598.   echo shar: Will not clobber existing file \"'jdcolor.c'\"
  599. else
  600.   echo shar: Extracting \"'jdcolor.c'\" \(9030 characters\)
  601.   sed "s/^X//" >'jdcolor.c' <<'END_OF_FILE'
  602. X/*
  603. X * jdcolor.c
  604. X *
  605. X * Copyright (C) 1991, 1992, Thomas G. Lane.
  606. X * This file is part of the Independent JPEG Group's software.
  607. X * For conditions of distribution and use, see the accompanying README file.
  608. X *
  609. X * This file contains output colorspace conversion routines.
  610. X * These routines are invoked via the methods color_convert
  611. X * and colorout_init/term.
  612. X */
  613. X
  614. X#include "jinclude.h"
  615. X
  616. X
  617. X/**************** YCbCr -> RGB conversion: most common case **************/
  618. X
  619. X/*
  620. X * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
  621. X * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
  622. X * The conversion equations to be implemented are therefore
  623. X *    R = Y                + 1.40200 * Cr
  624. X *    G = Y - 0.34414 * Cb - 0.71414 * Cr
  625. X *    B = Y + 1.77200 * Cb
  626. X * where Cb and Cr represent the incoming values less MAXJSAMPLE/2.
  627. X * (These numbers are derived from TIFF Appendix O, draft of 4/10/91.)
  628. X *
  629. X * To avoid floating-point arithmetic, we represent the fractional constants
  630. X * as integers scaled up by 2^14 (about 4 digits precision); we have to divide
  631. X * the products by 2^14, with appropriate rounding, to get the correct answer.
  632. X * Notice that Y, being an integral input, does not contribute any fraction
  633. X * so it need not participate in the rounding.
  634. X *
  635. X * For even more speed, we avoid doing any multiplications in the inner loop
  636. X * by precalculating the constants times Cb and Cr for all possible values.
  637. X * For 8-bit JSAMPLEs this is very reasonable (only 256 table entries); for
  638. X * 12-bit samples it is still acceptable.  It's not very reasonable for 16-bit
  639. X * samples, but if you want lossless storage you shouldn't be changing
  640. X * colorspace anyway.
  641. X * The Cr=>R and Cb=>B values can be rounded to integers in advance; the
  642. X * values for the G calculation are left scaled up, since we must add them
  643. X * together before rounding.
  644. X */
  645. X
  646. X#define SCALEBITS    14
  647. X#define ONE_HALF    ((INT32) 1 << (SCALEBITS-1))
  648. X#define FIX(x)        ((INT32) ((x) * (1L<<SCALEBITS) + 0.5))
  649. X
  650. Xstatic INT16 * Cr_r_tab;    /* => table for Cr to R conversion */
  651. Xstatic INT16 * Cb_b_tab;    /* => table for Cb to B conversion */
  652. Xstatic INT32 * Cr_g_tab;    /* => table for Cr to G conversion */
  653. Xstatic INT32 * Cb_g_tab;    /* => table for Cb to G conversion */
  654. X
  655. X
  656. X/*
  657. X * Initialize for colorspace conversion.
  658. X */
  659. X
  660. XMETHODDEF void
  661. Xycc_rgb_init (decompress_info_ptr cinfo)
  662. X{
  663. X#ifdef SIXTEEN_BIT_SAMPLES
  664. X  INT32 i, x2;
  665. X#else
  666. X  int i, x2;            /* smart compiler may do 16x16=>32 multiply */
  667. X#endif
  668. X  SHIFT_TEMPS
  669. X
  670. X  Cr_r_tab = (INT16 *) (*cinfo->emethods->alloc_small)
  671. X                ((MAXJSAMPLE+1) * SIZEOF(INT16));
  672. X  Cb_b_tab = (INT16 *) (*cinfo->emethods->alloc_small)
  673. X                ((MAXJSAMPLE+1) * SIZEOF(INT16));
  674. X  Cr_g_tab = (INT32 *) (*cinfo->emethods->alloc_small)
  675. X                ((MAXJSAMPLE+1) * SIZEOF(INT32));
  676. X  Cb_g_tab = (INT32 *) (*cinfo->emethods->alloc_small)
  677. X                ((MAXJSAMPLE+1) * SIZEOF(INT32));
  678. X
  679. X  for (i = 0; i <= MAXJSAMPLE; i++) {
  680. X    /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */
  681. X    /* The Cb or Cr value we are thinking of is x = i - MAXJSAMPLE/2 */
  682. X    x2 = 2*i - MAXJSAMPLE;    /* twice x */
  683. X    /* Cr=>R value is nearest int to 1.40200 * x */
  684. X    Cr_r_tab[i] = (INT16)
  685. X            RIGHT_SHIFT(FIX(1.40200/2) * x2 + ONE_HALF, SCALEBITS);
  686. X    /* Cb=>B value is nearest int to 1.77200 * x */
  687. X    Cb_b_tab[i] = (INT16)
  688. X            RIGHT_SHIFT(FIX(1.77200/2) * x2 + ONE_HALF, SCALEBITS);
  689. X    /* Cr=>G value is scaled-up -0.71414 * x */
  690. X    Cr_g_tab[i] = (- FIX(0.71414/2)) * x2;
  691. X    /* Cb=>G value is scaled-up -0.34414 * x */
  692. X    /* We also add in ONE_HALF so that need not do it in inner loop */
  693. X    Cb_g_tab[i] = (- FIX(0.34414/2)) * x2 + ONE_HALF;
  694. X  }
  695. X}
  696. X
  697. X
  698. X/*
  699. X * Convert some rows of samples to the output colorspace.
  700. X */
  701. X
  702. XMETHODDEF void
  703. Xycc_rgb_convert (decompress_info_ptr cinfo, int num_rows, long num_cols,
  704. X         JSAMPIMAGE input_data, JSAMPIMAGE output_data)
  705. X{
  706. X#ifdef SIXTEEN_BIT_SAMPLES
  707. X  register UINT16 y, cb, cr;
  708. X  register INT32 x;
  709. X#else
  710. X  register int y, cb, cr;
  711. X  register int x;
  712. X#endif
  713. X  register JSAMPROW inptr0, inptr1, inptr2;
  714. X  register JSAMPROW outptr0, outptr1, outptr2;
  715. X  long col;
  716. X  int row;
  717. X  SHIFT_TEMPS
  718. X  
  719. X  for (row = 0; row < num_rows; row++) {
  720. X    inptr0 = input_data[0][row];
  721. X    inptr1 = input_data[1][row];
  722. X    inptr2 = input_data[2][row];
  723. X    outptr0 = output_data[0][row];
  724. X    outptr1 = output_data[1][row];
  725. X    outptr2 = output_data[2][row];
  726. X    for (col = num_cols; col > 0; col--) {
  727. X      y  = GETJSAMPLE(*inptr0++);
  728. X      cb = GETJSAMPLE(*inptr1++);
  729. X      cr = GETJSAMPLE(*inptr2++);
  730. X      /* Note: if the inputs were computed directly from RGB values,
  731. X       * range-limiting would be unnecessary here; but due to possible
  732. X       * noise in the DCT/IDCT phase, we do need to apply range limits.
  733. X       */
  734. X      x = y + Cr_r_tab[cr];    /* red */
  735. X      if (x < 0) x = 0;
  736. X      else if (x > MAXJSAMPLE) x = MAXJSAMPLE;
  737. X      *outptr0++ = (JSAMPLE) x;
  738. X      x = y + ((int) RIGHT_SHIFT(Cb_g_tab[cb] + Cr_g_tab[cr], SCALEBITS));
  739. X      if (x < 0) x = 0;
  740. X      else if (x > MAXJSAMPLE) x = MAXJSAMPLE;
  741. X      *outptr1++ = (JSAMPLE) x;
  742. X      x = y + Cb_b_tab[cb];    /* blue */
  743. X      if (x < 0) x = 0;
  744. X      else if (x > MAXJSAMPLE) x = MAXJSAMPLE;
  745. X      *outptr2++ = (JSAMPLE) x;
  746. X    }
  747. X  }
  748. X}
  749. X
  750. X
  751. X/*
  752. X * Finish up at the end of the file.
  753. X */
  754. X
  755. XMETHODDEF void
  756. Xycc_rgb_term (decompress_info_ptr cinfo)
  757. X{
  758. X  /* no work (we let free_all release the workspace) */
  759. X}
  760. X
  761. X
  762. X/**************** Cases other than YCbCr -> RGB **************/
  763. X
  764. X
  765. X/*
  766. X * Initialize for colorspace conversion.
  767. X */
  768. X
  769. XMETHODDEF void
  770. Xnull_init (decompress_info_ptr cinfo)
  771. X/* colorout_init for cases where no setup is needed */
  772. X{
  773. X  /* no work needed */
  774. X}
  775. X
  776. X
  777. X/*
  778. X * Color conversion for no colorspace change: just copy the data.
  779. X */
  780. X
  781. XMETHODDEF void
  782. Xnull_convert (decompress_info_ptr cinfo, int num_rows, long num_cols,
  783. X          JSAMPIMAGE input_data, JSAMPIMAGE output_data)
  784. X{
  785. X  short ci;
  786. X
  787. X  for (ci = 0; ci < cinfo->num_components; ci++) {
  788. X    jcopy_sample_rows(input_data[ci], 0, output_data[ci], 0,
  789. X              num_rows, num_cols);
  790. X  }
  791. X}
  792. X
  793. X
  794. X/*
  795. X * Color conversion for grayscale: just copy the data.
  796. X * This also works for YCbCr/YIQ -> grayscale conversion, in which
  797. X * we just copy the Y (luminance) component and ignore chrominance.
  798. X */
  799. X
  800. XMETHODDEF void
  801. Xgrayscale_convert (decompress_info_ptr cinfo, int num_rows, long num_cols,
  802. X           JSAMPIMAGE input_data, JSAMPIMAGE output_data)
  803. X{
  804. X  jcopy_sample_rows(input_data[0], 0, output_data[0], 0,
  805. X            num_rows, num_cols);
  806. X}
  807. X
  808. X
  809. X/*
  810. X * Finish up at the end of the file.
  811. X */
  812. X
  813. XMETHODDEF void
  814. Xnull_term (decompress_info_ptr cinfo)
  815. X/* colorout_term for cases where no teardown is needed */
  816. X{
  817. X  /* no work needed */
  818. X}
  819. X
  820. X
  821. X
  822. X/*
  823. X * The method selection routine for output colorspace conversion.
  824. X */
  825. X
  826. XGLOBAL void
  827. Xjseldcolor (decompress_info_ptr cinfo)
  828. X{
  829. X  /* Make sure num_components agrees with jpeg_color_space */
  830. X  switch (cinfo->jpeg_color_space) {
  831. X  case CS_GRAYSCALE:
  832. X    if (cinfo->num_components != 1)
  833. X      ERREXIT(cinfo->emethods, "Bogus JPEG colorspace");
  834. X    break;
  835. X
  836. X  case CS_RGB:
  837. X  case CS_YCbCr:
  838. X  case CS_YIQ:
  839. X    if (cinfo->num_components != 3)
  840. X      ERREXIT(cinfo->emethods, "Bogus JPEG colorspace");
  841. X    break;
  842. X
  843. X  case CS_CMYK:
  844. X    if (cinfo->num_components != 4)
  845. X      ERREXIT(cinfo->emethods, "Bogus JPEG colorspace");
  846. X    break;
  847. X
  848. X  default:
  849. X    ERREXIT(cinfo->emethods, "Unsupported JPEG colorspace");
  850. X    break;
  851. X  }
  852. X
  853. X  /* Set color_out_comps and conversion method based on requested space */
  854. X  switch (cinfo->out_color_space) {
  855. X  case CS_GRAYSCALE:
  856. X    cinfo->color_out_comps = 1;
  857. X    if (cinfo->jpeg_color_space == CS_GRAYSCALE ||
  858. X    cinfo->jpeg_color_space == CS_YCbCr ||
  859. X    cinfo->jpeg_color_space == CS_YIQ) {
  860. X      cinfo->methods->color_convert = grayscale_convert;
  861. X      cinfo->methods->colorout_init = null_init;
  862. X      cinfo->methods->colorout_term = null_term;
  863. X    } else
  864. X      ERREXIT(cinfo->emethods, "Unsupported color conversion request");
  865. X    break;
  866. X
  867. X  case CS_RGB:
  868. X    cinfo->color_out_comps = 3;
  869. X    if (cinfo->jpeg_color_space == CS_YCbCr) {
  870. X      cinfo->methods->color_convert = ycc_rgb_convert;
  871. X      cinfo->methods->colorout_init = ycc_rgb_init;
  872. X      cinfo->methods->colorout_term = ycc_rgb_term;
  873. X    } else if (cinfo->jpeg_color_space == CS_RGB) {
  874. X      cinfo->methods->color_convert = null_convert;
  875. X      cinfo->methods->colorout_init = null_init;
  876. X      cinfo->methods->colorout_term = null_term;
  877. X    } else
  878. X      ERREXIT(cinfo->emethods, "Unsupported color conversion request");
  879. X    break;
  880. X
  881. X  default:
  882. X    /* Permit null conversion from CMYK or YCbCr to same output space */
  883. X    if (cinfo->out_color_space == cinfo->jpeg_color_space) {
  884. X      cinfo->color_out_comps = cinfo->num_components;
  885. X      cinfo->methods->color_convert = null_convert;
  886. X      cinfo->methods->colorout_init = null_init;
  887. X      cinfo->methods->colorout_term = null_term;
  888. X    } else            /* unsupported non-null conversion */
  889. X      ERREXIT(cinfo->emethods, "Unsupported color conversion request");
  890. X    break;
  891. X  }
  892. X
  893. X  if (cinfo->quantize_colors)
  894. X    cinfo->final_out_comps = 1;    /* single colormapped output component */
  895. X  else
  896. X    cinfo->final_out_comps = cinfo->color_out_comps;
  897. X}
  898. END_OF_FILE
  899.   if test 9030 -ne `wc -c <'jdcolor.c'`; then
  900.     echo shar: \"'jdcolor.c'\" unpacked with wrong size!
  901.   fi
  902.   # end of 'jdcolor.c'
  903. fi
  904. if test -f 'jdmain.c' -a "${1}" != "-c" ; then 
  905.   echo shar: Will not clobber existing file \"'jdmain.c'\"
  906. else
  907.   echo shar: Extracting \"'jdmain.c'\" \(8658 characters\)
  908.   sed "s/^X//" >'jdmain.c' <<'END_OF_FILE'
  909. X/*
  910. X * jdmain.c
  911. X *
  912. X * Copyright (C) 1991, 1992, Thomas G. Lane.
  913. X * This file is part of the Independent JPEG Group's software.
  914. X * For conditions of distribution and use, see the accompanying README file.
  915. X *
  916. X * This file contains a trivial test user interface for the JPEG decompressor.
  917. X * It should work on any system with Unix- or MS-DOS-style command lines.
  918. X *
  919. X * Two different command line styles are permitted, depending on the
  920. X * compile-time switch TWO_FILE_COMMANDLINE:
  921. X *    djpeg [options]  inputfile outputfile
  922. X *    djpeg [options]  [inputfile]
  923. X * In the second style, output is always to standard output, which you'd
  924. X * normally redirect to a file or pipe to some other program.  Input is
  925. X * either from a named file or from standard input (typically redirected).
  926. X * The second style is convenient on Unix but is unhelpful on systems that
  927. X * don't support pipes.  Also, you MUST use the first style if your system
  928. X * doesn't do binary I/O to stdin/stdout.
  929. X */
  930. X
  931. X#include "jinclude.h"
  932. X#ifdef INCLUDES_ARE_ANSI
  933. X#include <stdlib.h>        /* to declare exit() */
  934. X#endif
  935. X#ifdef NEED_SIGNAL_CATCHER
  936. X#include <signal.h>        /* to declare signal() */
  937. X#endif
  938. X
  939. X#ifdef THINK_C
  940. X#include <console.h>        /* command-line reader for Macintosh */
  941. X#endif
  942. X
  943. X#ifdef DONT_USE_B_MODE        /* define mode parameters for fopen() */
  944. X#define READ_BINARY    "r"
  945. X#define WRITE_BINARY    "w"
  946. X#else
  947. X#define READ_BINARY    "rb"
  948. X#define WRITE_BINARY    "wb"
  949. X#endif
  950. X
  951. X#ifndef EXIT_FAILURE        /* define exit() codes if not provided */
  952. X#define EXIT_FAILURE  1
  953. X#endif
  954. X#ifndef EXIT_SUCCESS
  955. X#ifdef VMS
  956. X#define EXIT_SUCCESS  1        /* VMS is very nonstandard */
  957. X#else
  958. X#define EXIT_SUCCESS  0
  959. X#endif
  960. X#endif
  961. X
  962. X
  963. X#include "jversion.h"        /* for version message */
  964. X
  965. X
  966. X/*
  967. X * PD version of getopt(3).
  968. X */
  969. X
  970. X#include "egetopt.c"
  971. X
  972. X
  973. X/*
  974. X * This list defines the known output image formats
  975. X * (not all of which need be supported by a given version).
  976. X * You can change the default output format by defining DEFAULT_FMT;
  977. X * indeed, you had better do so if you undefine PPM_SUPPORTED.
  978. X */
  979. X
  980. Xtypedef enum {
  981. X    FMT_GIF,        /* GIF format */
  982. X    FMT_PPM,        /* PPM/PGM (PBMPLUS formats) */
  983. X    FMT_RLE,        /* RLE format */
  984. X    FMT_TARGA,        /* Targa format */
  985. X    FMT_TIFF        /* TIFF format */
  986. X} IMAGE_FORMATS;
  987. X
  988. X#ifndef DEFAULT_FMT        /* so can override from CFLAGS in Makefile */
  989. X#define DEFAULT_FMT    FMT_PPM
  990. X#endif
  991. X
  992. Xstatic IMAGE_FORMATS requested_fmt;
  993. X
  994. X
  995. X/*
  996. X * This routine gets control after the input file header has been read.
  997. X * It must determine what output file format is to be written,
  998. X * and make any other decompression parameter changes that are desirable.
  999. X */
  1000. X
  1001. XMETHODDEF void
  1002. Xd_ui_method_selection (decompress_info_ptr cinfo)
  1003. X{
  1004. X  /* if grayscale or CMYK input, force similar output; */
  1005. X  /* else leave the output colorspace as set by options. */
  1006. X  if (cinfo->jpeg_color_space == CS_GRAYSCALE)
  1007. X    cinfo->out_color_space = CS_GRAYSCALE;
  1008. X  else if (cinfo->jpeg_color_space == CS_CMYK)
  1009. X    cinfo->out_color_space = CS_CMYK;
  1010. X
  1011. X  /* select output file format */
  1012. X  /* Note: jselwxxx routine may make additional parameter changes,
  1013. X   * such as forcing color quantization if it's a colormapped format.
  1014. X   */
  1015. X  switch (requested_fmt) {
  1016. X#ifdef GIF_SUPPORTED
  1017. X  case FMT_GIF:
  1018. X    jselwgif(cinfo);
  1019. X    break;
  1020. X#endif
  1021. X#ifdef PPM_SUPPORTED
  1022. X  case FMT_PPM:
  1023. X    jselwppm(cinfo);
  1024. X    break;
  1025. X#endif
  1026. X#ifdef RLE_SUPPORTED
  1027. X  case FMT_RLE:
  1028. X    jselwrle(cinfo);
  1029. X    break;
  1030. X#endif
  1031. X#ifdef TARGA_SUPPORTED
  1032. X  case FMT_TARGA:
  1033. X    jselwtarga(cinfo);
  1034. X    break;
  1035. X#endif
  1036. X  default:
  1037. X    ERREXIT(cinfo->emethods, "Unsupported output file format");
  1038. X    break;
  1039. X  }
  1040. X}
  1041. X
  1042. X
  1043. X/*
  1044. X * Signal catcher to ensure that temporary files are removed before aborting.
  1045. X * NB: for Amiga Manx C this is actually a global routine named _abort();
  1046. X * see -Dsignal_catcher=_abort in CFLAGS.  Talk about bogus...
  1047. X */
  1048. X
  1049. X#ifdef NEED_SIGNAL_CATCHER
  1050. X
  1051. Xstatic external_methods_ptr emethods; /* for access to free_all */
  1052. X
  1053. XGLOBAL void
  1054. Xsignal_catcher (int signum)
  1055. X{
  1056. X  emethods->trace_level = 0;    /* turn off trace output */
  1057. X  (*emethods->free_all) ();    /* clean up memory allocation & temp files */
  1058. X  exit(EXIT_FAILURE);
  1059. X}
  1060. X
  1061. X#endif
  1062. X
  1063. X
  1064. XLOCAL void
  1065. Xusage (char * progname)
  1066. X/* complain about bad command line */
  1067. X{
  1068. X  fprintf(stderr, "usage: %s ", progname);
  1069. X  fprintf(stderr, "[-G] [-P] [-R] [-T] [-b] [-g] [-q colors] [-1] [-D] [-d] [-m mem]");
  1070. X#ifdef TWO_FILE_COMMANDLINE
  1071. X  fprintf(stderr, " inputfile outputfile\n");
  1072. X#else
  1073. X  fprintf(stderr, " [inputfile]\n");
  1074. X#endif
  1075. X  exit(EXIT_FAILURE);
  1076. X}
  1077. X
  1078. X
  1079. X/*
  1080. X * The main program.
  1081. X */
  1082. X
  1083. XGLOBAL int
  1084. Xmain (int argc, char **argv)
  1085. X{
  1086. X  struct decompress_info_struct cinfo;
  1087. X  struct decompress_methods_struct dc_methods;
  1088. X  struct external_methods_struct e_methods;
  1089. X  int c;
  1090. X
  1091. X  /* On Mac, fetch a command line. */
  1092. X#ifdef THINK_C
  1093. X  argc = ccommand(&argv);
  1094. X#endif
  1095. X
  1096. X  /* Initialize the system-dependent method pointers. */
  1097. X  cinfo.methods = &dc_methods;
  1098. X  cinfo.emethods = &e_methods;
  1099. X  jselerror(&e_methods);    /* error/trace message routines */
  1100. X  jselmemmgr(&e_methods);    /* memory allocation routines */
  1101. X  dc_methods.d_ui_method_selection = d_ui_method_selection;
  1102. X
  1103. X  /* Now OK to enable signal catcher. */
  1104. X#ifdef NEED_SIGNAL_CATCHER
  1105. X  emethods = &e_methods;
  1106. X  signal(SIGINT, signal_catcher);
  1107. X#ifdef SIGTERM            /* not all systems have SIGTERM */
  1108. X  signal(SIGTERM, signal_catcher);
  1109. X#endif
  1110. X#endif
  1111. X
  1112. X  /* Set up default JPEG parameters. */
  1113. X  j_d_defaults(&cinfo, TRUE);
  1114. X  requested_fmt = DEFAULT_FMT;    /* set default output file format */
  1115. X
  1116. X  /* Scan command line options, adjust parameters */
  1117. X  
  1118. X  while ((c = egetopt(argc, argv, "GPRTbgq:1Dm:d")) != EOF)
  1119. X    switch (c) {
  1120. X    case 'G':            /* GIF output format. */
  1121. X      requested_fmt = FMT_GIF;
  1122. X      break;
  1123. X    case 'P':            /* PPM output format. */
  1124. X      requested_fmt = FMT_PPM;
  1125. X      break;
  1126. X    case 'R':            /* RLE output format. */
  1127. X      requested_fmt = FMT_RLE;
  1128. X      break;
  1129. X    case 'T':            /* Targa output format. */
  1130. X      requested_fmt = FMT_TARGA;
  1131. X      break;
  1132. X    case 'b':            /* Enable cross-block smoothing. */
  1133. X      cinfo.do_block_smoothing = TRUE;
  1134. X      break;
  1135. X    case 'g':            /* Force grayscale output. */
  1136. X      cinfo.out_color_space = CS_GRAYSCALE;
  1137. X      break;
  1138. X    case 'q':            /* Do color quantization. */
  1139. X      { int val;
  1140. X    if (optarg == NULL)
  1141. X      usage(argv[0]);
  1142. X    if (sscanf(optarg, "%d", &val) != 1)
  1143. X      usage(argv[0]);
  1144. X    cinfo.desired_number_of_colors = val;
  1145. X      }
  1146. X      cinfo.quantize_colors = TRUE;
  1147. X      break;
  1148. X    case '1':            /* Use fast one-pass quantization. */
  1149. X      cinfo.two_pass_quantize = FALSE;
  1150. X      break;
  1151. X    case 'D':            /* Suppress dithering in color quantization. */
  1152. X      cinfo.use_dithering = FALSE;
  1153. X      break;
  1154. X    case 'm':            /* Maximum memory in Kb (or Mb with 'm'). */
  1155. X      { long lval;
  1156. X    char ch = 'x';
  1157. X
  1158. X    if (optarg == NULL)
  1159. X      usage(argv[0]);
  1160. X    if (sscanf(optarg, "%ld%c", &lval, &ch) < 1)
  1161. X      usage(argv[0]);
  1162. X    if (ch == 'm' || ch == 'M')
  1163. X      lval *= 1000L;
  1164. X    e_methods.max_memory_to_use = lval * 1000L;
  1165. X      }
  1166. X      break;
  1167. X    case 'd':            /* Debugging. */
  1168. X      e_methods.trace_level++;
  1169. X      break;
  1170. X    case '?':
  1171. X    default:
  1172. X      usage(argv[0]);
  1173. X      break;
  1174. X    }
  1175. X
  1176. X  /* If -d appeared, print version identification */
  1177. X  if (e_methods.trace_level > 0)
  1178. X    fprintf(stderr, "Independent JPEG Group's DJPEG, version %s\n%s\n",
  1179. X        JVERSION, JCOPYRIGHT);
  1180. X
  1181. X  /* Select the input and output files */
  1182. X
  1183. X#ifdef TWO_FILE_COMMANDLINE
  1184. X
  1185. X  if (optind != argc-2) {
  1186. X    fprintf(stderr, "%s: must name one input and one output file\n", argv[0]);
  1187. X    usage(argv[0]);
  1188. X  }
  1189. X  if ((cinfo.input_file = fopen(argv[optind], READ_BINARY)) == NULL) {
  1190. X    fprintf(stderr, "%s: can't open %s\n", argv[0], argv[optind]);
  1191. X    exit(EXIT_FAILURE);
  1192. X  }
  1193. X  if ((cinfo.output_file = fopen(argv[optind+1], WRITE_BINARY)) == NULL) {
  1194. X    fprintf(stderr, "%s: can't open %s\n", argv[0], argv[optind+1]);
  1195. X    exit(EXIT_FAILURE);
  1196. X  }
  1197. X
  1198. X#else /* not TWO_FILE_COMMANDLINE -- use Unix style */
  1199. X
  1200. X  cinfo.input_file = stdin;    /* default input file */
  1201. X  cinfo.output_file = stdout;    /* always the output file */
  1202. X
  1203. X  if (optind < argc-1) {
  1204. X    fprintf(stderr, "%s: only one input file\n", argv[0]);
  1205. X    usage(argv[0]);
  1206. X  }
  1207. X  if (optind < argc) {
  1208. X    if ((cinfo.input_file = fopen(argv[optind], READ_BINARY)) == NULL) {
  1209. X      fprintf(stderr, "%s: can't open %s\n", argv[0], argv[optind]);
  1210. X      exit(EXIT_FAILURE);
  1211. X    }
  1212. X  }
  1213. X
  1214. X#endif /* TWO_FILE_COMMANDLINE */
  1215. X  
  1216. X  /* Set up to read a JFIF or baseline-JPEG file. */
  1217. X  /* A smarter UI would inspect the first few bytes of the input file */
  1218. X  /* to determine its type. */
  1219. X#ifdef JFIF_SUPPORTED
  1220. X  jselrjfif(&cinfo);
  1221. X#else
  1222. X  You shoulda defined JFIF_SUPPORTED.   /* deliberate syntax error */
  1223. X#endif
  1224. X
  1225. X  /* Do it to it! */
  1226. X  jpeg_decompress(&cinfo);
  1227. X
  1228. X  /* All done. */
  1229. X  exit(EXIT_SUCCESS);
  1230. X  return 0;            /* suppress no-return-value warnings */
  1231. X}
  1232. END_OF_FILE
  1233.   if test 8658 -ne `wc -c <'jdmain.c'`; then
  1234.     echo shar: \"'jdmain.c'\" unpacked with wrong size!
  1235.   fi
  1236.   # end of 'jdmain.c'
  1237. fi
  1238. if test -f 'jrdrle.c' -a "${1}" != "-c" ; then 
  1239.   echo shar: Will not clobber existing file \"'jrdrle.c'\"
  1240. else
  1241.   echo shar: Extracting \"'jrdrle.c'\" \(11363 characters\)
  1242.   sed "s/^X//" >'jrdrle.c' <<'END_OF_FILE'
  1243. X/*
  1244. X * jrdrle.c
  1245. X *
  1246. X * Copyright (C) 1991, 1992, Thomas G. Lane.
  1247. X * This file is part of the Independent JPEG Group's software.
  1248. X * For conditions of distribution and use, see the accompanying README file.
  1249. X *
  1250. X * This file contains routines to read input images in Utah RLE format.
  1251. X * The Utah Raster Toolkit library is required (version 3.0).
  1252. X *
  1253. X * These routines may need modification for non-Unix environments or
  1254. X * specialized applications.  As they stand, they assume input from
  1255. X * an ordinary stdio stream.  They further assume that reading begins
  1256. X * at the start of the file; input_init may need work if the
  1257. X * user interface has already read some data (e.g., to determine that
  1258. X * the file is indeed RLE format).
  1259. X *
  1260. X * These routines are invoked via the methods get_input_row
  1261. X * and input_init/term.
  1262. X *
  1263. X * Based on code contributed by Mike Lijewski.
  1264. X */
  1265. X
  1266. X#include "jinclude.h"
  1267. X
  1268. X#ifdef RLE_SUPPORTED
  1269. X
  1270. X/* rle.h is provided by the Utah Raster Toolkit. */
  1271. X
  1272. X#include <rle.h>
  1273. X
  1274. X
  1275. X/*
  1276. X * load_image assumes that JSAMPLE has the same representation as rle_pixel,
  1277. X * to wit, "unsigned char".  Hence we can't cope with 12- or 16-bit samples.
  1278. X */
  1279. X
  1280. X#ifndef EIGHT_BIT_SAMPLES
  1281. X  Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */
  1282. X#endif
  1283. X
  1284. X
  1285. X/*
  1286. X * We support the following types of RLE files:
  1287. X *   
  1288. X *   GRAYSCALE   - 8 bits, no colormap
  1289. X *   PSEUDOCOLOR - 8 bits, colormap
  1290. X *   TRUECOLOR   - 24 bits, colormap
  1291. X *   DIRECTCOLOR - 24 bits, no colormap
  1292. X *
  1293. X * For now, we ignore any alpha channel in the image.
  1294. X */
  1295. X
  1296. Xtypedef enum { GRAYSCALE, PSEUDOCOLOR, TRUECOLOR, DIRECTCOLOR } rle_kind;
  1297. X
  1298. Xstatic rle_kind visual;        /* actual type of input file */
  1299. X
  1300. X/*
  1301. X * Since RLE stores scanlines bottom-to-top, we have to invert the image
  1302. X * to conform to JPEG's top-to-bottom order.  To do this, we read the
  1303. X * incoming image into a virtual array on the first get_input_row call,
  1304. X * then fetch the required row from the virtual array on subsequent calls.
  1305. X */
  1306. X
  1307. Xstatic big_sarray_ptr image;    /* single array for GRAYSCALE/PSEUDOCOLOR */
  1308. Xstatic big_sarray_ptr red_channel; /* three arrays for TRUECOLOR/DIRECTCOLOR */
  1309. Xstatic big_sarray_ptr green_channel;
  1310. Xstatic big_sarray_ptr blue_channel;
  1311. Xstatic long cur_row_number;    /* last row# read from virtual array */
  1312. X
  1313. Xstatic rle_hdr header;        /* Input file information */
  1314. Xstatic rle_map *colormap;    /* RLE colormap, if any */
  1315. X
  1316. X
  1317. X/*
  1318. X * Read the file header; return image size and component count.
  1319. X */
  1320. X
  1321. XMETHODDEF void
  1322. Xinput_init (compress_info_ptr cinfo)
  1323. X{
  1324. X  long width, height;
  1325. X
  1326. X  /* Use RLE library routine to get the header info */
  1327. X  header.rle_file = cinfo->input_file;
  1328. X  switch (rle_get_setup(&header)) {
  1329. X  case RLE_SUCCESS:
  1330. X    /* A-OK */
  1331. X    break;
  1332. X  case RLE_NOT_RLE:
  1333. X    ERREXIT(cinfo->emethods, "Not an RLE file");
  1334. X    break;
  1335. X  case RLE_NO_SPACE:
  1336. X    ERREXIT(cinfo->emethods, "Insufficient memory for RLE header");
  1337. X    break;
  1338. X  case RLE_EMPTY:
  1339. X    ERREXIT(cinfo->emethods, "Empty RLE file");
  1340. X    break;
  1341. X  case RLE_EOF:
  1342. X    ERREXIT(cinfo->emethods, "Premature EOF in RLE header");
  1343. X    break;
  1344. X  default:
  1345. X    ERREXIT(cinfo->emethods, "Bogus RLE error code");
  1346. X    break;
  1347. X  }
  1348. X
  1349. X  /* Figure out what we have, set private vars and return values accordingly */
  1350. X  
  1351. X  width  = header.xmax - header.xmin + 1;
  1352. X  height = header.ymax - header.ymin + 1;
  1353. X  header.xmin = 0;        /* realign horizontally */
  1354. X  header.xmax = width-1;
  1355. X
  1356. X  cinfo->image_width      = width;
  1357. X  cinfo->image_height     = height;
  1358. X  cinfo->data_precision   = 8;  /* we can only handle 8 bit data */
  1359. X
  1360. X  if (header.ncolors == 1 && header.ncmap == 0) {
  1361. X    visual     = GRAYSCALE;
  1362. X    TRACEMS(cinfo->emethods, 1, "Gray-scale RLE file");
  1363. X  } else if (header.ncolors == 1 && header.ncmap == 3) {
  1364. X    visual     = PSEUDOCOLOR;
  1365. X    colormap   = header.cmap;
  1366. X    TRACEMS1(cinfo->emethods, 1, "Colormapped RLE file with map of length %d",
  1367. X         1 << header.cmaplen);
  1368. X  } else if (header.ncolors == 3 && header.ncmap == 3) {
  1369. X    visual     = TRUECOLOR;
  1370. X    colormap   = header.cmap;
  1371. X    TRACEMS1(cinfo->emethods, 1, "Full-color RLE file with map of length %d",
  1372. X         1 << header.cmaplen);
  1373. X  } else if (header.ncolors == 3 && header.ncmap == 0) {
  1374. X    visual     = DIRECTCOLOR;
  1375. X    TRACEMS(cinfo->emethods, 1, "Full-color RLE file");
  1376. X  } else
  1377. X    ERREXIT(cinfo->emethods, "Can't handle this RLE setup");
  1378. X  
  1379. X  switch (visual) {
  1380. X  case GRAYSCALE:
  1381. X    /* request one big array to hold the grayscale image */
  1382. X    image = (*cinfo->emethods->request_big_sarray) (width, height, 1L);
  1383. X    cinfo->in_color_space   = CS_GRAYSCALE;
  1384. X    cinfo->input_components = 1;
  1385. X    break;
  1386. X  case PSEUDOCOLOR:
  1387. X    /* request one big array to hold the pseudocolor image */
  1388. X    image = (*cinfo->emethods->request_big_sarray) (width, height, 1L);
  1389. X    cinfo->in_color_space   = CS_RGB;
  1390. X    cinfo->input_components = 3;
  1391. X    break;
  1392. X  case TRUECOLOR:
  1393. X  case DIRECTCOLOR:
  1394. X    /* request three big arrays to hold the RGB channels */
  1395. X    red_channel   = (*cinfo->emethods->request_big_sarray) (width, height, 1L);
  1396. X    green_channel = (*cinfo->emethods->request_big_sarray) (width, height, 1L);
  1397. X    blue_channel  = (*cinfo->emethods->request_big_sarray) (width, height, 1L);
  1398. X    cinfo->in_color_space   = CS_RGB;
  1399. X    cinfo->input_components = 3;
  1400. X    break;
  1401. X  }
  1402. X
  1403. X  cinfo->total_passes++;    /* count file reading as separate pass */
  1404. X}
  1405. X
  1406. X
  1407. X/*
  1408. X * Read one row of pixels.
  1409. X * These are called only after load_image has read the image into
  1410. X * the virtual array(s).
  1411. X */
  1412. X
  1413. X
  1414. XMETHODDEF void
  1415. Xget_grayscale_row (compress_info_ptr cinfo, JSAMPARRAY pixel_row)
  1416. X/* This is used for GRAYSCALE images */
  1417. X{
  1418. X  JSAMPROW inputrows[1];    /* a pseudo JSAMPARRAY structure */
  1419. X
  1420. X  cur_row_number--;        /* work down in array */
  1421. X  
  1422. X  inputrows[0] = *((*cinfo->emethods->access_big_sarray)
  1423. X            (image, cur_row_number, FALSE));
  1424. X
  1425. X  jcopy_sample_rows(inputrows, 0, pixel_row, 0, 1, cinfo->image_width);
  1426. X}
  1427. X
  1428. X
  1429. XMETHODDEF void
  1430. Xget_pseudocolor_row (compress_info_ptr cinfo, JSAMPARRAY pixel_row)
  1431. X/* This is used for PSEUDOCOLOR images */
  1432. X{
  1433. X  long col;
  1434. X  JSAMPROW image_ptr, ptr0, ptr1, ptr2;
  1435. X  int val;
  1436. X
  1437. X  cur_row_number--;        /* work down in array */
  1438. X  
  1439. X  image_ptr = *((*cinfo->emethods->access_big_sarray)
  1440. X        (image, cur_row_number, FALSE));
  1441. X
  1442. X  ptr0 = pixel_row[0];
  1443. X  ptr1 = pixel_row[1];
  1444. X  ptr2 = pixel_row[2];
  1445. X  
  1446. X  for (col = cinfo->image_width; col > 0; col--) {
  1447. X    val = GETJSAMPLE(*image_ptr++);
  1448. X    *ptr0++ = colormap[val      ] >> 8;
  1449. X    *ptr1++ = colormap[val + 256] >> 8;
  1450. X    *ptr2++ = colormap[val + 512] >> 8;
  1451. X  }
  1452. X}
  1453. X
  1454. X
  1455. XMETHODDEF void
  1456. Xget_truecolor_row (compress_info_ptr cinfo, JSAMPARRAY pixel_row)
  1457. X/* This is used for TRUECOLOR images */
  1458. X/* The colormap consists of 3 independent lookup tables */
  1459. X{
  1460. X  long col;
  1461. X  JSAMPROW red_ptr, green_ptr, blue_ptr, ptr0, ptr1, ptr2;
  1462. X  
  1463. X  cur_row_number--;        /* work down in array */
  1464. X  
  1465. X  red_ptr   = *((*cinfo->emethods->access_big_sarray)
  1466. X        (red_channel, cur_row_number, FALSE));
  1467. X  green_ptr = *((*cinfo->emethods->access_big_sarray)
  1468. X        (green_channel, cur_row_number, FALSE));
  1469. X  blue_ptr  = *((*cinfo->emethods->access_big_sarray)
  1470. X        (blue_channel, cur_row_number, FALSE));
  1471. X  
  1472. X  ptr0 = pixel_row[0];
  1473. X  ptr1 = pixel_row[1];
  1474. X  ptr2 = pixel_row[2];
  1475. X  
  1476. X  for (col = cinfo->image_width; col > 0; col--) {
  1477. X    *ptr0++ = colormap[GETJSAMPLE(*red_ptr++)        ] >> 8;
  1478. X    *ptr1++ = colormap[GETJSAMPLE(*green_ptr++) + 256] >> 8;
  1479. X    *ptr2++ = colormap[GETJSAMPLE(*blue_ptr++)  + 512] >> 8;
  1480. X  }
  1481. X}
  1482. X
  1483. X
  1484. XMETHODDEF void
  1485. Xget_directcolor_row (compress_info_ptr cinfo, JSAMPARRAY pixel_row)
  1486. X/* This is used for DIRECTCOLOR images */
  1487. X{
  1488. X  JSAMPROW inputrows[3];    /* a pseudo JSAMPARRAY structure */
  1489. X
  1490. X  cur_row_number--;        /* work down in array */
  1491. X  
  1492. X  inputrows[0] = *((*cinfo->emethods->access_big_sarray)
  1493. X            (red_channel, cur_row_number, FALSE));
  1494. X  inputrows[1] = *((*cinfo->emethods->access_big_sarray)
  1495. X            (green_channel, cur_row_number, FALSE));
  1496. X  inputrows[2] = *((*cinfo->emethods->access_big_sarray)
  1497. X            (blue_channel, cur_row_number, FALSE));
  1498. X
  1499. X  jcopy_sample_rows(inputrows, 0, pixel_row, 0, 3, cinfo->image_width);
  1500. X}
  1501. X
  1502. X
  1503. X/*
  1504. X * Load the color channels into separate arrays.  We have to do
  1505. X * this because RLE files start at the lower left while the JPEG standard
  1506. X * has them starting in the upper left.  This is called the first time
  1507. X * we want to get a row of input.  What we do is load the RLE data into
  1508. X * big arrays and then call the appropriate routine to read one row from
  1509. X * the big arrays.  We also change cinfo->methods->get_input_row so that
  1510. X * subsequent calls go straight to the row-reading routine.
  1511. X */
  1512. X
  1513. XMETHODDEF void
  1514. Xload_image (compress_info_ptr cinfo, JSAMPARRAY pixel_row)
  1515. X{
  1516. X  long row;
  1517. X  rle_pixel *rle_row[3];
  1518. X  
  1519. X  /* Read the RLE data into our virtual array(s).
  1520. X   * We assume here that (a) rle_pixel is represented the same as JSAMPLE,
  1521. X   * and (b) we are not on a machine where FAR pointers differ from regular.
  1522. X   */
  1523. X  RLE_CLR_BIT(header, RLE_ALPHA); /* don't read the alpha channel */
  1524. X
  1525. X  switch (visual) {
  1526. X  case GRAYSCALE:
  1527. X  case PSEUDOCOLOR:
  1528. X    for (row = 0; row < cinfo->image_height; row++) {
  1529. X      (*cinfo->methods->progress_monitor) (cinfo, row, cinfo->image_height);
  1530. X      /*
  1531. X       * Read a row of the image directly into our big array.
  1532. X       * Too bad this doesn't seem to return any indication of errors :-(.
  1533. X       */
  1534. X      rle_row[0] = (rle_pixel *) *((*cinfo->emethods->access_big_sarray)
  1535. X                    (image, row, TRUE));
  1536. X      rle_getrow(&header, rle_row);
  1537. X    }
  1538. X    break;
  1539. X  case TRUECOLOR:
  1540. X  case DIRECTCOLOR:
  1541. X    for (row = 0; row < cinfo->image_height; row++) {
  1542. X      (*cinfo->methods->progress_monitor) (cinfo, row, cinfo->image_height);
  1543. X      /*
  1544. X       * Read a row of the image directly into our big arrays.
  1545. X       * Too bad this doesn't seem to return any indication of errors :-(.
  1546. X       */
  1547. X      rle_row[0] = (rle_pixel *) *((*cinfo->emethods->access_big_sarray)
  1548. X                    (red_channel, row, TRUE));
  1549. X      rle_row[1] = (rle_pixel *) *((*cinfo->emethods->access_big_sarray)
  1550. X                    (green_channel, row, TRUE));
  1551. X      rle_row[2] = (rle_pixel *) *((*cinfo->emethods->access_big_sarray)
  1552. X                    (blue_channel, row, TRUE));
  1553. X      rle_getrow(&header, rle_row);
  1554. X    }
  1555. X    break;
  1556. X  }
  1557. X  cinfo->completed_passes++;
  1558. X  
  1559. X  /* Set up to call proper row-extraction routine in future */
  1560. X  switch (visual) {
  1561. X  case GRAYSCALE:
  1562. X    cinfo->methods->get_input_row = get_grayscale_row;
  1563. X    break;
  1564. X  case PSEUDOCOLOR:
  1565. X    cinfo->methods->get_input_row = get_pseudocolor_row;
  1566. X    break;
  1567. X  case TRUECOLOR:
  1568. X    cinfo->methods->get_input_row = get_truecolor_row;
  1569. X    break;
  1570. X  case DIRECTCOLOR:
  1571. X    cinfo->methods->get_input_row = get_directcolor_row;
  1572. X    break;
  1573. X  }
  1574. X
  1575. X  /* And fetch the topmost (bottommost) row */
  1576. X  cur_row_number = cinfo->image_height;
  1577. X  (*cinfo->methods->get_input_row) (cinfo, pixel_row);   
  1578. X}
  1579. X
  1580. X
  1581. X/*
  1582. X * Finish up at the end of the file.
  1583. X */
  1584. X
  1585. XMETHODDEF void
  1586. Xinput_term (compress_info_ptr cinfo)
  1587. X{
  1588. X  /* no work (we let free_all release the workspace) */
  1589. X}
  1590. X
  1591. X
  1592. X/*
  1593. X * The method selection routine for RLE format input.
  1594. X * Note that this must be called by the user interface before calling
  1595. X * jpeg_compress.  If multiple input formats are supported, the
  1596. X * user interface is responsible for discovering the file format and
  1597. X * calling the appropriate method selection routine.
  1598. X */
  1599. X
  1600. XGLOBAL void
  1601. Xjselrrle (compress_info_ptr cinfo)
  1602. X{
  1603. X  cinfo->methods->input_init    = input_init;
  1604. X  cinfo->methods->get_input_row = load_image; /* until first call */
  1605. X  cinfo->methods->input_term    = input_term;
  1606. X}
  1607. X
  1608. X#endif /* RLE_SUPPORTED */
  1609. END_OF_FILE
  1610.   if test 11363 -ne `wc -c <'jrdrle.c'`; then
  1611.     echo shar: \"'jrdrle.c'\" unpacked with wrong size!
  1612.   fi
  1613.   # end of 'jrdrle.c'
  1614. fi
  1615. echo shar: End of archive 13 \(of 18\).
  1616. cp /dev/null ark13isdone
  1617. MISSING=""
  1618. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ; do
  1619.     if test ! -f ark${I}isdone ; then
  1620.     MISSING="${MISSING} ${I}"
  1621.     fi
  1622. done
  1623. if test "${MISSING}" = "" ; then
  1624.     echo You have unpacked all 18 archives.
  1625.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1626. else
  1627.     echo You still must unpack the following archives:
  1628.     echo "        " ${MISSING}
  1629. fi
  1630. exit 0
  1631. exit 0 # Just in case...
  1632.