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

  1. Newsgroups: comp.sources.misc
  2. From: jpeg-info@uunet.uu.net (Independent JPEG Group)
  3. Subject:  v29i004:  jpeg - JPEG image compression, Part04/18
  4. Message-ID: <1992Mar24.144329.18084@sparky.imd.sterling.com>
  5. X-Md4-Signature: ceaf659f06ce5914d57baf5307e882bd
  6. Date: Tue, 24 Mar 1992 14:43:29 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 4
  11. Archive-name: jpeg/part04
  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:  jpegdata.h jwrgif.c makcjpeg.lnk
  20. # Wrapped by kent@sparky on Mon Mar 23 16:02:42 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 4 (of 18)."'
  24. if test -f 'jpegdata.h' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'jpegdata.h'\"
  26. else
  27.   echo shar: Extracting \"'jpegdata.h'\" \(37381 characters\)
  28.   sed "s/^X//" >'jpegdata.h' <<'END_OF_FILE'
  29. X/*
  30. X * jpegdata.h
  31. X *
  32. X * Copyright (C) 1991, 1992, Thomas G. Lane.
  33. X * This file is part of the Independent JPEG Group's software.
  34. X * For conditions of distribution and use, see the accompanying README file.
  35. X *
  36. X * This file defines shared data structures for the various JPEG modules.
  37. X */
  38. X
  39. X
  40. X/*
  41. X * You might need to change some of the following declarations if you are
  42. X * using the JPEG software within a surrounding application program
  43. X * or porting it to an unusual system.
  44. X */
  45. X
  46. X
  47. X/* If the source or destination of image data is not to be stdio streams,
  48. X * these types may need work.  You can replace them with some kind of
  49. X * pointer or indicator that is useful to you, or just ignore 'em.
  50. X * Note that the user interface and the various jrdxxx/jwrxxx modules
  51. X * will also need work for non-stdio input/output.
  52. X */
  53. X
  54. Xtypedef FILE * JFILEREF;    /* source or dest of JPEG-compressed data */
  55. X
  56. Xtypedef FILE * IFILEREF;    /* source or dest of non-JPEG image data */
  57. X
  58. X
  59. X/* These defines are used in all function definitions and extern declarations.
  60. X * You could modify them if you need to change function linkage conventions,
  61. X * as is shown below for use with C++.  Another application would be to make
  62. X * all functions global for use with code profilers that require it.
  63. X * NOTE: the C++ test does the right thing if you are reading this include
  64. X * file in a C++ application to link to JPEG code that's been compiled with a
  65. X * regular C compiler.  I'm not sure it works if you try to compile the JPEG
  66. X * code with C++.
  67. X */
  68. X
  69. X#define METHODDEF static    /* a function called through method pointers */
  70. X#define LOCAL      static    /* a function used only in its module */
  71. X#define GLOBAL            /* a function referenced thru EXTERNs */
  72. X#ifdef __cplusplus
  73. X#define EXTERN      extern "C"    /* a reference to a GLOBAL function */
  74. X#else
  75. X#define EXTERN      extern    /* a reference to a GLOBAL function */
  76. X#endif
  77. X
  78. X
  79. X/* Here is the pseudo-keyword for declaring pointers that must be "far"
  80. X * on 80x86 machines.  Most of the specialized coding for 80x86 is handled
  81. X * by just saying "FAR *" where such a pointer is needed.  In a few places
  82. X * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.
  83. X */
  84. X
  85. X#ifdef NEED_FAR_POINTERS
  86. X#define FAR  far
  87. X#else
  88. X#define FAR
  89. X#endif
  90. X
  91. X
  92. X
  93. X/* The remaining declarations are not system-dependent, we hope. */
  94. X
  95. X
  96. X/*
  97. X * NOTE: if you have an ancient, strict-K&R C compiler, it may choke on the
  98. X * similarly-named fields in compress_info_struct and decompress_info_struct.
  99. X * If this happens, you can get around it by rearranging the two structs so
  100. X * that the similarly-named fields appear first and in the same order in
  101. X * each struct.  Since such compilers are now pretty rare, we haven't done
  102. X * this in the portable code, preferring to maintain a logical ordering.
  103. X */
  104. X
  105. X
  106. X
  107. X/* This macro is used to declare a "method", that is, a function pointer. */
  108. X/* We want to supply prototype parameters if the compiler can cope. */
  109. X/* Note that the arglist parameter must be parenthesized! */
  110. X
  111. X#ifdef PROTO
  112. X#define METHOD(type,methodname,arglist)  type (*methodname) arglist
  113. X#else
  114. X#define METHOD(type,methodname,arglist)  type (*methodname) ()
  115. X#endif
  116. X
  117. X/* Forward references to lists of method pointers */
  118. Xtypedef struct external_methods_struct * external_methods_ptr;
  119. Xtypedef struct compress_methods_struct * compress_methods_ptr;
  120. Xtypedef struct decompress_methods_struct * decompress_methods_ptr;
  121. X
  122. X
  123. X/* Data structures for images containing either samples or coefficients. */
  124. X/* Note that the topmost (leftmost) index is always color component. */
  125. X/* On 80x86 machines, the image arrays are too big for near pointers, */
  126. X/* but the pointer arrays can fit in near memory. */
  127. X
  128. Xtypedef JSAMPLE FAR *JSAMPROW;    /* ptr to one image row of pixel samples. */
  129. Xtypedef JSAMPROW *JSAMPARRAY;    /* ptr to some rows (a 2-D sample array) */
  130. Xtypedef JSAMPARRAY *JSAMPIMAGE;    /* a 3-D sample array: top index is color */
  131. X
  132. X
  133. X#define DCTSIZE        8    /* The basic DCT block is 8x8 samples */
  134. X#define DCTSIZE2    64    /* DCTSIZE squared; # of elements in a block */
  135. X
  136. Xtypedef JCOEF JBLOCK[DCTSIZE2];    /* one block of coefficients */
  137. Xtypedef JBLOCK FAR *JBLOCKROW;    /* pointer to one row of coefficient blocks */
  138. Xtypedef JBLOCKROW *JBLOCKARRAY;        /* a 2-D array of coefficient blocks */
  139. Xtypedef JBLOCKARRAY *JBLOCKIMAGE;    /* a 3-D array of coefficient blocks */
  140. X
  141. Xtypedef JCOEF FAR *JCOEFPTR;    /* useful in a couple of places */
  142. X
  143. X
  144. X/* The input and output data of the DCT transform subroutines are of
  145. X * the following type, which need not be the same as JCOEF.
  146. X * For example, on a machine with fast floating point, it might make sense
  147. X * to recode the DCT routines to use floating point; then DCTELEM would be
  148. X * 'float' or 'double'.
  149. X */
  150. X
  151. Xtypedef JCOEF DCTELEM;
  152. Xtypedef DCTELEM DCTBLOCK[DCTSIZE2];
  153. X
  154. X
  155. X/* Types for JPEG compression parameters and working tables. */
  156. X
  157. X
  158. Xtypedef enum {            /* defines known color spaces */
  159. X    CS_UNKNOWN,        /* error/unspecified */
  160. X    CS_GRAYSCALE,        /* monochrome (only 1 component) */
  161. X    CS_RGB,            /* red/green/blue */
  162. X    CS_YCbCr,        /* Y/Cb/Cr (also known as YUV) */
  163. X    CS_YIQ,            /* Y/I/Q */
  164. X    CS_CMYK            /* C/M/Y/K */
  165. X} COLOR_SPACE;
  166. X
  167. X
  168. Xtypedef struct {        /* Basic info about one component */
  169. X  /* These values are fixed over the whole image */
  170. X  /* For compression, they must be supplied by the user interface; */
  171. X  /* for decompression, they are read from the SOF marker. */
  172. X    short component_id;    /* identifier for this component (0..255) */
  173. X    short component_index;    /* its index in SOF or cinfo->comp_info[] */
  174. X    short h_samp_factor;    /* horizontal sampling factor (1..4) */
  175. X    short v_samp_factor;    /* vertical sampling factor (1..4) */
  176. X    short quant_tbl_no;    /* quantization table selector (0..3) */
  177. X  /* These values may vary between scans */
  178. X  /* For compression, they must be supplied by the user interface; */
  179. X  /* for decompression, they are read from the SOS marker. */
  180. X    short dc_tbl_no;    /* DC entropy table selector (0..3) */
  181. X    short ac_tbl_no;    /* AC entropy table selector (0..3) */
  182. X  /* These values are computed during compression or decompression startup */
  183. X    long true_comp_width;    /* component's image width in samples */
  184. X    long true_comp_height;    /* component's image height in samples */
  185. X    /* the above are the logical dimensions of the subsampled image */
  186. X  /* These values are computed before starting a scan of the component */
  187. X    short MCU_width;    /* number of blocks per MCU, horizontally */
  188. X    short MCU_height;    /* number of blocks per MCU, vertically */
  189. X    short MCU_blocks;    /* MCU_width * MCU_height */
  190. X    long subsampled_width;    /* image width in samples, after expansion */
  191. X    long subsampled_height;    /* image height in samples, after expansion */
  192. X    /* the above are the true_comp_xxx values rounded up to multiples of */
  193. X    /* the MCU dimensions; these are the working dimensions of the array */
  194. X    /* as it is passed through the DCT or IDCT step.  NOTE: these values */
  195. X    /* differ depending on whether the component is interleaved or not!! */
  196. X} jpeg_component_info;
  197. X
  198. X
  199. X/* DCT coefficient quantization tables.
  200. X * For 8-bit precision, 'INT16' should be good enough for quantization values;
  201. X * for more precision, we go for the full 16 bits.  'INT16' provides a useful
  202. X * speedup on many machines (multiplication & division of JCOEFs by
  203. X * quantization values is a significant chunk of the runtime).
  204. X * Note: the values in a QUANT_TBL are always given in zigzag order.
  205. X */
  206. X#ifdef EIGHT_BIT_SAMPLES
  207. Xtypedef INT16 QUANT_VAL;    /* element of a quantization table */
  208. X#else
  209. Xtypedef UINT16 QUANT_VAL;    /* element of a quantization table */
  210. X#endif
  211. Xtypedef QUANT_VAL QUANT_TBL[DCTSIZE2];    /* A quantization table */
  212. Xtypedef QUANT_VAL * QUANT_TBL_PTR;    /* pointer to same */
  213. X
  214. X
  215. Xtypedef struct {        /* A Huffman coding table */
  216. X  /* These two fields directly represent the contents of a JPEG DHT marker */
  217. X    UINT8 bits[17];        /* bits[k] = # of symbols with codes of */
  218. X                /* length k bits; bits[0] is unused */
  219. X    UINT8 huffval[256];    /* The symbols, in order of incr code length */
  220. X  /* This field is used only during compression.  It's initialized FALSE when
  221. X   * the table is created, and set TRUE when it's been output to the file.
  222. X   */
  223. X    boolean sent_table;    /* TRUE when table has been output */
  224. X  /* The remaining fields are computed from the above to allow more efficient
  225. X   * coding and decoding.  These fields should be considered private to the
  226. X   * Huffman compression & decompression modules.
  227. X   */
  228. X    /* encoding tables: */
  229. X    UINT16 ehufco[256];    /* code for each symbol */
  230. X    char ehufsi[256];    /* length of code for each symbol */
  231. X    /* decoding tables: (element [0] of each array is unused) */
  232. X    UINT16 mincode[17];    /* smallest code of length k */
  233. X    INT32 maxcode[18];    /* largest code of length k (-1 if none) */
  234. X    /* (maxcode[17] is a sentinel to ensure huff_DECODE terminates) */
  235. X    short valptr[17];    /* huffval[] index of 1st symbol of length k */
  236. X} HUFF_TBL;
  237. X
  238. X
  239. X#define NUM_QUANT_TBLS      4    /* quantization tables are numbered 0..3 */
  240. X#define NUM_HUFF_TBLS       4    /* Huffman tables are numbered 0..3 */
  241. X#define NUM_ARITH_TBLS      16    /* arith-coding tables are numbered 0..15 */
  242. X#define MAX_COMPS_IN_SCAN   4    /* JPEG limit on # of components in one scan */
  243. X#define MAX_SAMP_FACTOR     4    /* JPEG limit on sampling factors */
  244. X#define MAX_BLOCKS_IN_MCU   10    /* JPEG limit on # of blocks in an MCU */
  245. X
  246. X
  247. X/* Working data for compression */
  248. X
  249. Xstruct compress_info_struct {
  250. X/*
  251. X * All of these fields shall be established by the user interface before
  252. X * calling jpeg_compress, or by the input_init or c_ui_method_selection
  253. X * methods.
  254. X * Most parameters can be set to reasonable defaults by j_c_defaults.
  255. X * Note that the UI must supply the storage for the main methods struct,
  256. X * though it sets only a few of the methods there.
  257. X */
  258. X    compress_methods_ptr methods; /* Points to list of methods to use */
  259. X
  260. X    external_methods_ptr emethods; /* Points to list of methods to use */
  261. X
  262. X    IFILEREF input_file;    /* tells input routines where to read image */
  263. X    JFILEREF output_file;    /* tells output routines where to write JPEG */
  264. X
  265. X    long image_width;    /* input image width */
  266. X    long image_height;    /* input image height */
  267. X    short input_components;    /* # of color components in input image */
  268. X
  269. X    short data_precision;    /* bits of precision in image data */
  270. X
  271. X    COLOR_SPACE in_color_space; /* colorspace of input file */
  272. X    COLOR_SPACE jpeg_color_space; /* colorspace of JPEG file */
  273. X
  274. X    double input_gamma;    /* image gamma of input file */
  275. X
  276. X    boolean write_JFIF_header; /* should a JFIF marker be written? */
  277. X    /* These three values are not used by the JPEG code, only copied */
  278. X    /* into the JFIF APP0 marker.  density_unit can be 0 for unknown, */
  279. X    /* 1 for dots/inch, or 2 for dots/cm.  Note that the pixel aspect */
  280. X    /* ratio is defined by X_density/Y_density even when density_unit=0. */
  281. X    UINT8 density_unit;    /* JFIF code for pixel size units */
  282. X    UINT16 X_density;    /* Horizontal pixel density */
  283. X    UINT16 Y_density;    /* Vertical pixel density */
  284. X
  285. X    short num_components;    /* # of color components in JPEG image */
  286. X    jpeg_component_info * comp_info;
  287. X    /* comp_info[i] describes component that appears i'th in SOF */
  288. X
  289. X    QUANT_TBL_PTR quant_tbl_ptrs[NUM_QUANT_TBLS];
  290. X    /* ptrs to coefficient quantization tables, or NULL if not defined */
  291. X
  292. X    HUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
  293. X    HUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
  294. X    /* ptrs to Huffman coding tables, or NULL if not defined */
  295. X
  296. X    UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arithmetic-coding tables */
  297. X    UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arithmetic-coding tables */
  298. X    UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arithmetic-coding tables */
  299. X
  300. X    boolean arith_code;    /* TRUE=arithmetic coding, FALSE=Huffman */
  301. X    boolean interleave;    /* TRUE=interleaved output, FALSE=not */
  302. X    boolean optimize_coding; /* TRUE=optimize entropy encoding parms */
  303. X    boolean CCIR601_sampling; /* TRUE=first samples are cosited */
  304. X
  305. X    UINT16 restart_interval;/* MDUs per restart interval, or 0 for no restart */
  306. X
  307. X/*
  308. X * These fields are computed during jpeg_compress startup
  309. X */
  310. X    short max_h_samp_factor; /* largest h_samp_factor */
  311. X    short max_v_samp_factor; /* largest v_samp_factor */
  312. X
  313. X/*
  314. X * These fields may be useful for progress monitoring
  315. X */
  316. X
  317. X    int total_passes;    /* number of passes expected */
  318. X    int completed_passes;    /* number of passes completed so far */
  319. X
  320. X/*
  321. X * These fields are valid during any one scan
  322. X */
  323. X    short comps_in_scan;    /* # of JPEG components output this time */
  324. X    jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
  325. X    /* *cur_comp_info[i] describes component that appears i'th in SOS */
  326. X
  327. X    long MCUs_per_row;    /* # of MCUs across the image */
  328. X    long MCU_rows_in_scan;    /* # of MCU rows in the image */
  329. X
  330. X    short blocks_in_MCU;    /* # of DCT blocks per MCU */
  331. X    short MCU_membership[MAX_BLOCKS_IN_MCU];
  332. X    /* MCU_membership[i] is index in cur_comp_info of component owning */
  333. X    /* i'th block in an MCU */
  334. X
  335. X    /* these fields are private data for the entropy encoder */
  336. X    JCOEF last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each comp */
  337. X    JCOEF last_dc_diff[MAX_COMPS_IN_SCAN]; /* last DC diff for each comp */
  338. X    UINT16 restarts_to_go;    /* MDUs left in this restart interval */
  339. X    short next_restart_num;    /* # of next RSTn marker (0..7) */
  340. X};
  341. X
  342. Xtypedef struct compress_info_struct * compress_info_ptr;
  343. X
  344. X
  345. X/* Working data for decompression */
  346. X
  347. Xstruct decompress_info_struct {
  348. X/*
  349. X * These fields shall be established by the user interface before
  350. X * calling jpeg_decompress.
  351. X * Most parameters can be set to reasonable defaults by j_d_defaults.
  352. X * Note that the UI must supply the storage for the main methods struct,
  353. X * though it sets only a few of the methods there.
  354. X */
  355. X    decompress_methods_ptr methods; /* Points to list of methods to use */
  356. X
  357. X    external_methods_ptr emethods; /* Points to list of methods to use */
  358. X
  359. X    JFILEREF input_file;    /* tells input routines where to read JPEG */
  360. X    IFILEREF output_file;    /* tells output routines where to write image */
  361. X
  362. X    /* these can be set at d_ui_method_selection time: */
  363. X
  364. X    COLOR_SPACE out_color_space; /* colorspace of output */
  365. X
  366. X    double output_gamma;    /* image gamma wanted in output */
  367. X
  368. X    boolean quantize_colors; /* T if output is a colormapped format */
  369. X    /* the following are ignored if not quantize_colors: */
  370. X    boolean two_pass_quantize;    /* use two-pass color quantization? */
  371. X    boolean use_dithering;        /* want color dithering? */
  372. X    int desired_number_of_colors;    /* max number of colors to use */
  373. X
  374. X    boolean do_block_smoothing; /* T = apply cross-block smoothing */
  375. X    boolean do_pixel_smoothing; /* T = apply post-subsampling smoothing */
  376. X
  377. X/*
  378. X * These fields are used for efficient buffering of data between read_jpeg_data
  379. X * and the entropy decoding object.  By using a shared buffer, we avoid copying
  380. X * data and eliminate the need for an "unget" operation at the end of a scan.
  381. X * The actual source of the data is known only to read_jpeg_data; see the
  382. X * JGETC macro, below.
  383. X * Note: the user interface is expected to allocate the input_buffer and
  384. X * initialize bytes_in_buffer to 0.  Also, for JFIF/raw-JPEG input, the UI
  385. X * actually supplies the read_jpeg_data method.  This is all handled by
  386. X * j_d_defaults in a typical implementation.
  387. X */
  388. X    char * input_buffer;    /* start of buffer (private to input code) */
  389. X    char * next_input_byte;    /* => next byte to read from buffer */
  390. X    int bytes_in_buffer;    /* # of bytes remaining in buffer */
  391. X
  392. X/*
  393. X * These fields are set by read_file_header or read_scan_header
  394. X */
  395. X    long image_width;    /* overall image width */
  396. X    long image_height;    /* overall image height */
  397. X
  398. X    short data_precision;    /* bits of precision in image data */
  399. X
  400. X    COLOR_SPACE jpeg_color_space; /* colorspace of JPEG file */
  401. X
  402. X        /* These three values are not used by the JPEG code, merely copied */
  403. X    /* from the JFIF APP0 marker (if any). */
  404. X    UINT8 density_unit;    /* JFIF code for pixel size units */
  405. X    UINT16 X_density;    /* Horizontal pixel density */
  406. X    UINT16 Y_density;    /* Vertical pixel density */
  407. X
  408. X    short num_components;    /* # of color components in JPEG image */
  409. X    jpeg_component_info * comp_info;
  410. X    /* comp_info[i] describes component that appears i'th in SOF */
  411. X
  412. X    QUANT_TBL_PTR quant_tbl_ptrs[NUM_QUANT_TBLS];
  413. X    /* ptrs to coefficient quantization tables, or NULL if not defined */
  414. X
  415. X    HUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
  416. X    HUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
  417. X    /* ptrs to Huffman coding tables, or NULL if not defined */
  418. X
  419. X    UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */
  420. X    UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */
  421. X    UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */
  422. X
  423. X    boolean arith_code;    /* TRUE=arithmetic coding, FALSE=Huffman */
  424. X    boolean CCIR601_sampling; /* TRUE=first samples are cosited */
  425. X
  426. X    UINT16 restart_interval;/* MDUs per restart interval, or 0 for no restart */
  427. X
  428. X/*
  429. X * These fields are computed during jpeg_decompress startup
  430. X */
  431. X    short max_h_samp_factor; /* largest h_samp_factor */
  432. X    short max_v_samp_factor; /* largest v_samp_factor */
  433. X
  434. X    short color_out_comps;    /* # of color components output by color_convert */
  435. X                /* (need not match num_components) */
  436. X    short final_out_comps;    /* # of color components sent to put_pixel_rows */
  437. X    /* (1 when quantizing colors, else same as color_out_comps) */
  438. X
  439. X/*
  440. X * When quantizing colors, the color quantizer leaves a pointer to the output
  441. X * colormap in these fields.  The colormap is valid from the time put_color_map
  442. X * is called (must be before any put_pixel_rows calls) until shutdown (more
  443. X * specifically, until free_all is called to release memory).
  444. X */
  445. X    int actual_number_of_colors; /* actual number of entries */
  446. X    JSAMPARRAY colormap;    /* NULL if not valid */
  447. X    /* map has color_out_comps rows * actual_number_of_colors columns */
  448. X
  449. X/*
  450. X * These fields may be useful for progress monitoring
  451. X */
  452. X
  453. X    int total_passes;    /* number of passes expected */
  454. X    int completed_passes;    /* number of passes completed so far */
  455. X
  456. X/*
  457. X * These fields are valid during any one scan
  458. X */
  459. X    short comps_in_scan;    /* # of JPEG components input this time */
  460. X    jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN];
  461. X    /* *cur_comp_info[i] describes component that appears i'th in SOS */
  462. X
  463. X    long MCUs_per_row;    /* # of MCUs across the image */
  464. X    long MCU_rows_in_scan;    /* # of MCU rows in the image */
  465. X
  466. X    short blocks_in_MCU;    /* # of DCT blocks per MCU */
  467. X    short MCU_membership[MAX_BLOCKS_IN_MCU];
  468. X    /* MCU_membership[i] is index in cur_comp_info of component owning */
  469. X    /* i'th block in an MCU */
  470. X
  471. X    /* these fields are private data for the entropy encoder */
  472. X    JCOEF last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each comp */
  473. X    JCOEF last_dc_diff[MAX_COMPS_IN_SCAN]; /* last DC diff for each comp */
  474. X    UINT16 restarts_to_go;    /* MDUs left in this restart interval */
  475. X    short next_restart_num;    /* # of next RSTn marker (0..7) */
  476. X};
  477. X
  478. Xtypedef struct decompress_info_struct * decompress_info_ptr;
  479. X
  480. X
  481. X/* Macros for reading data from the decompression input buffer */
  482. X
  483. X#ifdef CHAR_IS_UNSIGNED
  484. X#define JGETC(cinfo)    ( --(cinfo)->bytes_in_buffer < 0 ? \
  485. X             (*(cinfo)->methods->read_jpeg_data) (cinfo) : \
  486. X             (int) (*(cinfo)->next_input_byte++) )
  487. X#else
  488. X#define JGETC(cinfo)    ( --(cinfo)->bytes_in_buffer < 0 ? \
  489. X             (*(cinfo)->methods->read_jpeg_data) (cinfo) : \
  490. X             (int) (*(cinfo)->next_input_byte++) & 0xFF )
  491. X#endif
  492. X
  493. X#define JUNGETC(ch,cinfo)  ((cinfo)->bytes_in_buffer++, \
  494. X                *(--((cinfo)->next_input_byte)) = (ch))
  495. X
  496. X#define MIN_UNGET    4    /* may always do at least 4 JUNGETCs */
  497. X
  498. X
  499. X/* A virtual image has a control block whose contents are private to the
  500. X * memory manager module (and may differ between managers).  The rest of the
  501. X * code only refers to virtual images by these pointer types, and never
  502. X * dereferences the pointer.
  503. X */
  504. X
  505. Xtypedef struct big_sarray_control * big_sarray_ptr;
  506. Xtypedef struct big_barray_control * big_barray_ptr;
  507. X
  508. X/* Although a real ANSI C compiler can deal perfectly well with pointers to
  509. X * unspecified structures (see "incomplete types" in the spec), a few pre-ANSI
  510. X * and pseudo-ANSI compilers get confused.  To keep one of these bozos happy,
  511. X * add -DINCOMPLETE_TYPES_BROKEN to CFLAGS in your Makefile.  Then we will
  512. X * pseudo-define the structs as containing a single "dummy" field.
  513. X * The memory managers #define AM_MEMORY_MANAGER before including this file,
  514. X * so that they can make their own definitions of the structs.
  515. X */
  516. X
  517. X#ifdef INCOMPLETE_TYPES_BROKEN
  518. X#ifndef AM_MEMORY_MANAGER
  519. Xstruct big_sarray_control { long dummy; };
  520. Xstruct big_barray_control { long dummy; };
  521. X#endif
  522. X#endif
  523. X
  524. X
  525. X/* Method types that need typedefs */
  526. X
  527. Xtypedef METHOD(void, MCU_output_method_ptr, (compress_info_ptr cinfo,
  528. X                         JBLOCK *MCU_data));
  529. Xtypedef METHOD(void, MCU_output_caller_ptr, (compress_info_ptr cinfo,
  530. X                         MCU_output_method_ptr output_method));
  531. Xtypedef METHOD(void, subsample_ptr, (compress_info_ptr cinfo,
  532. X                     int which_component,
  533. X                     long input_cols, int input_rows,
  534. X                     long output_cols, int output_rows,
  535. X                     JSAMPARRAY above,
  536. X                     JSAMPARRAY input_data,
  537. X                     JSAMPARRAY below,
  538. X                     JSAMPARRAY output_data));
  539. Xtypedef METHOD(void, unsubsample_ptr, (decompress_info_ptr cinfo,
  540. X                       int which_component,
  541. X                       long input_cols, int input_rows,
  542. X                       long output_cols, int output_rows,
  543. X                       JSAMPARRAY above,
  544. X                       JSAMPARRAY input_data,
  545. X                       JSAMPARRAY below,
  546. X                       JSAMPARRAY output_data));
  547. Xtypedef METHOD(void, quantize_method_ptr, (decompress_info_ptr cinfo,
  548. X                       int num_rows,
  549. X                       JSAMPIMAGE input_data,
  550. X                       JSAMPARRAY output_workspace));
  551. Xtypedef METHOD(void, quantize_caller_ptr, (decompress_info_ptr cinfo,
  552. X                       quantize_method_ptr quantize_method));
  553. X
  554. X
  555. X/* These structs contain function pointers for the various JPEG methods. */
  556. X
  557. X/* Routines to be provided by the surrounding application, rather than the
  558. X * portable JPEG code proper.  These are the same for compression and
  559. X * decompression.
  560. X */
  561. X
  562. Xstruct external_methods_struct {
  563. X    /* User interface: error exit and trace message routines */
  564. X    /* NOTE: the string msgtext parameters will eventually be replaced */
  565. X    /* by an enumerated-type code so that non-English error messages */
  566. X    /* can be substituted easily.  This will not be done until all the */
  567. X    /* code is in place, so that we know what messages are needed. */
  568. X    METHOD(void, error_exit, (const char *msgtext));
  569. X    METHOD(void, trace_message, (const char *msgtext));
  570. X
  571. X    /* Working data for error/trace facility */
  572. X    /* See macros below for the usage of these variables */
  573. X    int trace_level;    /* level of detail of tracing messages */
  574. X    /* Use level 0 for unsuppressable messages (nonfatal errors) */
  575. X    /* Use levels 1, 2, 3 for successively more detailed trace options */
  576. X
  577. X    int message_parm[8];    /* store numeric parms for messages here */
  578. X
  579. X    /* Memory management */
  580. X    /* NB: alloc routines never return NULL. They exit to */
  581. X    /* error_exit if not successful. */
  582. X    METHOD(void *, alloc_small, (size_t sizeofobject));
  583. X    METHOD(void, free_small, (void *ptr));
  584. X    METHOD(void FAR *, alloc_medium, (size_t sizeofobject));
  585. X    METHOD(void, free_medium, (void FAR *ptr));
  586. X    METHOD(JSAMPARRAY, alloc_small_sarray, (long samplesperrow,
  587. X                        long numrows));
  588. X    METHOD(void, free_small_sarray, (JSAMPARRAY ptr));
  589. X    METHOD(JBLOCKARRAY, alloc_small_barray, (long blocksperrow,
  590. X                         long numrows));
  591. X    METHOD(void, free_small_barray, (JBLOCKARRAY ptr));
  592. X    METHOD(big_sarray_ptr, request_big_sarray, (long samplesperrow,
  593. X                            long numrows,
  594. X                            long unitheight));
  595. X    METHOD(big_barray_ptr, request_big_barray, (long blocksperrow,
  596. X                            long numrows,
  597. X                            long unitheight));
  598. X    METHOD(void, alloc_big_arrays, (long extra_small_samples,
  599. X                    long extra_small_blocks,
  600. X                    long extra_medium_space));
  601. X    METHOD(JSAMPARRAY, access_big_sarray, (big_sarray_ptr ptr,
  602. X                           long start_row,
  603. X                           boolean writable));
  604. X    METHOD(JBLOCKARRAY, access_big_barray, (big_barray_ptr ptr,
  605. X                        long start_row,
  606. X                        boolean writable));
  607. X    METHOD(void, free_big_sarray, (big_sarray_ptr ptr));
  608. X    METHOD(void, free_big_barray, (big_barray_ptr ptr));
  609. X    METHOD(void, free_all, (void));
  610. X
  611. X    long max_memory_to_use;    /* maximum amount of memory to use */
  612. X};
  613. X
  614. X/* Macros to simplify using the error and trace message stuff */
  615. X/* The first parameter is generally cinfo->emethods */
  616. X
  617. X#define ERREXIT(emeth,msg)        ((*(emeth)->error_exit) (msg))
  618. X#define ERREXIT1(emeth,msg,p1)        ((emeth)->message_parm[0] = (p1), \
  619. X                     (*(emeth)->error_exit) (msg))
  620. X#define ERREXIT2(emeth,msg,p1,p2)    ((emeth)->message_parm[0] = (p1), \
  621. X                     (emeth)->message_parm[1] = (p2), \
  622. X                     (*(emeth)->error_exit) (msg))
  623. X#define ERREXIT3(emeth,msg,p1,p2,p3)    ((emeth)->message_parm[0] = (p1), \
  624. X                     (emeth)->message_parm[1] = (p2), \
  625. X                     (emeth)->message_parm[2] = (p3), \
  626. X                     (*(emeth)->error_exit) (msg))
  627. X#define ERREXIT4(emeth,msg,p1,p2,p3,p4) ((emeth)->message_parm[0] = (p1), \
  628. X                     (emeth)->message_parm[1] = (p2), \
  629. X                     (emeth)->message_parm[2] = (p3), \
  630. X                     (emeth)->message_parm[3] = (p4), \
  631. X                     (*(emeth)->error_exit) (msg))
  632. X
  633. X#define MAKESTMT(stuff)        do { stuff } while (0)
  634. X
  635. X#define TRACEMS(emeth,lvl,msg)    \
  636. X  MAKESTMT( if ((emeth)->trace_level >= (lvl)) { \
  637. X        (*(emeth)->trace_message) (msg); } )
  638. X#define TRACEMS1(emeth,lvl,msg,p1)    \
  639. X  MAKESTMT( if ((emeth)->trace_level >= (lvl)) { \
  640. X        (emeth)->message_parm[0] = (p1); \
  641. X        (*(emeth)->trace_message) (msg); } )
  642. X#define TRACEMS2(emeth,lvl,msg,p1,p2)    \
  643. X  MAKESTMT( if ((emeth)->trace_level >= (lvl)) { \
  644. X        (emeth)->message_parm[0] = (p1); \
  645. X        (emeth)->message_parm[1] = (p2); \
  646. X        (*(emeth)->trace_message) (msg); } )
  647. X#define TRACEMS3(emeth,lvl,msg,p1,p2,p3)    \
  648. X  MAKESTMT( if ((emeth)->trace_level >= (lvl)) { \
  649. X        int * _mp = (emeth)->message_parm; \
  650. X        *_mp++ = (p1); *_mp++ = (p2); *_mp = (p3); \
  651. X        (*(emeth)->trace_message) (msg); } )
  652. X#define TRACEMS4(emeth,lvl,msg,p1,p2,p3,p4)    \
  653. X  MAKESTMT( if ((emeth)->trace_level >= (lvl)) { \
  654. X        int * _mp = (emeth)->message_parm; \
  655. X        *_mp++ = (p1); *_mp++ = (p2); *_mp++ = (p3); *_mp = (p4); \
  656. X        (*(emeth)->trace_message) (msg); } )
  657. X#define TRACEMS8(emeth,lvl,msg,p1,p2,p3,p4,p5,p6,p7,p8)    \
  658. X  MAKESTMT( if ((emeth)->trace_level >= (lvl)) { \
  659. X        int * _mp = (emeth)->message_parm; \
  660. X        *_mp++ = (p1); *_mp++ = (p2); *_mp++ = (p3); *_mp++ = (p4); \
  661. X        *_mp++ = (p5); *_mp++ = (p6); *_mp++ = (p7); *_mp = (p8); \
  662. X        (*(emeth)->trace_message) (msg); } )
  663. X
  664. X
  665. X/* Methods used during JPEG compression. */
  666. X
  667. Xstruct compress_methods_struct {
  668. X    /* Hook for user interface to get control after input_init */
  669. X    METHOD(void, c_ui_method_selection, (compress_info_ptr cinfo));
  670. X    /* Hook for user interface to do progress monitoring */
  671. X    METHOD(void, progress_monitor, (compress_info_ptr cinfo,
  672. X                    long loopcounter, long looplimit));
  673. X    /* Input image reading & conversion to standard form */
  674. X    METHOD(void, input_init, (compress_info_ptr cinfo));
  675. X    METHOD(void, get_input_row, (compress_info_ptr cinfo,
  676. X                     JSAMPARRAY pixel_row));
  677. X    METHOD(void, input_term, (compress_info_ptr cinfo));
  678. X    /* Color space and gamma conversion */
  679. X    METHOD(void, colorin_init, (compress_info_ptr cinfo));
  680. X    METHOD(void, get_sample_rows, (compress_info_ptr cinfo,
  681. X                       int rows_to_read,
  682. X                       JSAMPIMAGE image_data));
  683. X    METHOD(void, colorin_term, (compress_info_ptr cinfo));
  684. X    /* Expand picture data at edges */
  685. X    METHOD(void, edge_expand, (compress_info_ptr cinfo,
  686. X                   long input_cols, int input_rows,
  687. X                   long output_cols, int output_rows,
  688. X                   JSAMPIMAGE image_data));
  689. X    /* Subsample pixel values of a single component */
  690. X    /* There can be a different subsample method for each component */
  691. X    METHOD(void, subsample_init, (compress_info_ptr cinfo));
  692. X    subsample_ptr subsample[MAX_COMPS_IN_SCAN];
  693. X    METHOD(void, subsample_term, (compress_info_ptr cinfo));
  694. X    /* Extract samples in MCU order, process & hand off to output_method */
  695. X    /* The input is always exactly N MCU rows worth of data */
  696. X    METHOD(void, extract_init, (compress_info_ptr cinfo));
  697. X    METHOD(void, extract_MCUs, (compress_info_ptr cinfo,
  698. X                    JSAMPIMAGE image_data,
  699. X                    int num_mcu_rows,
  700. X                    MCU_output_method_ptr output_method));
  701. X    METHOD(void, extract_term, (compress_info_ptr cinfo));
  702. X    /* Entropy encoding parameter optimization */
  703. X    METHOD(void, entropy_optimize, (compress_info_ptr cinfo,
  704. X                    MCU_output_caller_ptr source_method));
  705. X    /* Entropy encoding */
  706. X    METHOD(void, entropy_encoder_init, (compress_info_ptr cinfo));
  707. X    METHOD(void, entropy_encode, (compress_info_ptr cinfo,
  708. X                      JBLOCK *MCU_data));
  709. X    METHOD(void, entropy_encoder_term, (compress_info_ptr cinfo));
  710. X    /* JPEG file header construction */
  711. X    METHOD(void, write_file_header, (compress_info_ptr cinfo));
  712. X    METHOD(void, write_scan_header, (compress_info_ptr cinfo));
  713. X    METHOD(void, write_jpeg_data, (compress_info_ptr cinfo,
  714. X                       char *dataptr,
  715. X                       int datacount));
  716. X    METHOD(void, write_scan_trailer, (compress_info_ptr cinfo));
  717. X    METHOD(void, write_file_trailer, (compress_info_ptr cinfo));
  718. X    /* Pipeline control */
  719. X    METHOD(void, c_pipeline_controller, (compress_info_ptr cinfo));
  720. X    METHOD(void, entropy_output, (compress_info_ptr cinfo,
  721. X                      char *dataptr,
  722. X                      int datacount));
  723. X    /* Overall control */
  724. X    METHOD(void, c_per_scan_method_selection, (compress_info_ptr cinfo));
  725. X};
  726. X
  727. X/* Methods used during JPEG decompression. */
  728. X
  729. Xstruct decompress_methods_struct {
  730. X    /* Hook for user interface to get control after reading file header */
  731. X    METHOD(void, d_ui_method_selection, (decompress_info_ptr cinfo));
  732. X    /* Hook for user interface to do progress monitoring */
  733. X    METHOD(void, progress_monitor, (decompress_info_ptr cinfo,
  734. X                    long loopcounter, long looplimit));
  735. X    /* JPEG file scanning */
  736. X    METHOD(void, read_file_header, (decompress_info_ptr cinfo));
  737. X    METHOD(boolean, read_scan_header, (decompress_info_ptr cinfo));
  738. X    METHOD(int, read_jpeg_data, (decompress_info_ptr cinfo));
  739. X    METHOD(void, read_scan_trailer, (decompress_info_ptr cinfo));
  740. X    METHOD(void, read_file_trailer, (decompress_info_ptr cinfo));
  741. X    /* Entropy decoding */
  742. X    METHOD(void, entropy_decoder_init, (decompress_info_ptr cinfo));
  743. X    METHOD(void, entropy_decode, (decompress_info_ptr cinfo,
  744. X                      JBLOCK *MCU_data));
  745. X    METHOD(void, entropy_decoder_term, (decompress_info_ptr cinfo));
  746. X    /* MCU disassembly: fetch MCUs from entropy_decode, build coef array */
  747. X    /* The reverse_DCT step is in the same module for symmetry reasons */
  748. X    METHOD(void, disassemble_init, (decompress_info_ptr cinfo));
  749. X    METHOD(void, disassemble_MCU, (decompress_info_ptr cinfo,
  750. X                       JBLOCKIMAGE image_data));
  751. X    METHOD(void, reverse_DCT, (decompress_info_ptr cinfo,
  752. X                   JBLOCKIMAGE coeff_data,
  753. X                   JSAMPIMAGE output_data, int start_row));
  754. X    METHOD(void, disassemble_term, (decompress_info_ptr cinfo));
  755. X    /* Cross-block smoothing */
  756. X    METHOD(void, smooth_coefficients, (decompress_info_ptr cinfo,
  757. X                       jpeg_component_info *compptr,
  758. X                       JBLOCKROW above,
  759. X                       JBLOCKROW currow,
  760. X                       JBLOCKROW below,
  761. X                       JBLOCKROW output));
  762. X    /* Un-subsample pixel values of a single component */
  763. X    /* There can be a different unsubsample method for each component */
  764. X    METHOD(void, unsubsample_init, (decompress_info_ptr cinfo));
  765. X    unsubsample_ptr unsubsample[MAX_COMPS_IN_SCAN];
  766. X    METHOD(void, unsubsample_term, (decompress_info_ptr cinfo));
  767. X    /* Color space and gamma conversion */
  768. X    METHOD(void, colorout_init, (decompress_info_ptr cinfo));
  769. X    METHOD(void, color_convert, (decompress_info_ptr cinfo,
  770. X                     int num_rows, long num_cols,
  771. X                     JSAMPIMAGE input_data,
  772. X                     JSAMPIMAGE output_data));
  773. X    METHOD(void, colorout_term, (decompress_info_ptr cinfo));
  774. X    /* Color quantization */
  775. X    METHOD(void, color_quant_init, (decompress_info_ptr cinfo));
  776. X    METHOD(void, color_quantize, (decompress_info_ptr cinfo,
  777. X                      int num_rows,
  778. X                      JSAMPIMAGE input_data,
  779. X                      JSAMPARRAY output_data));
  780. X    METHOD(void, color_quant_prescan, (decompress_info_ptr cinfo,
  781. X                       int num_rows,
  782. X                       JSAMPIMAGE image_data,
  783. X                       JSAMPARRAY workspace));
  784. X    METHOD(void, color_quant_doit, (decompress_info_ptr cinfo,
  785. X                    quantize_caller_ptr source_method));
  786. X    METHOD(void, color_quant_term, (decompress_info_ptr cinfo));
  787. X    /* Output image writing */
  788. X    METHOD(void, output_init, (decompress_info_ptr cinfo));
  789. X    METHOD(void, put_color_map, (decompress_info_ptr cinfo,
  790. X                     int num_colors, JSAMPARRAY colormap));
  791. X    METHOD(void, put_pixel_rows, (decompress_info_ptr cinfo,
  792. X                      int num_rows,
  793. X                      JSAMPIMAGE pixel_data));
  794. X    METHOD(void, output_term, (decompress_info_ptr cinfo));
  795. X    /* Pipeline control */
  796. X    METHOD(void, d_pipeline_controller, (decompress_info_ptr cinfo));
  797. X    /* Overall control */
  798. X    METHOD(void, d_per_scan_method_selection, (decompress_info_ptr cinfo));
  799. X};
  800. X
  801. X
  802. X/* External declarations for routines that aren't called via method ptrs. */
  803. X/* Note: use "j" as first char of names to minimize namespace pollution. */
  804. X/* The PP macro hides prototype parameters from compilers that can't cope. */
  805. X
  806. X#ifdef PROTO
  807. X#define PP(arglist)    arglist
  808. X#else
  809. X#define PP(arglist)    ()
  810. X#endif
  811. X
  812. X
  813. X/* main entry for compression */
  814. XEXTERN void jpeg_compress PP((compress_info_ptr cinfo));
  815. X
  816. X/* default parameter setup for compression */
  817. XEXTERN void j_c_defaults PP((compress_info_ptr cinfo, int quality,
  818. X                 boolean force_baseline));
  819. XEXTERN void j_monochrome_default PP((compress_info_ptr cinfo));
  820. XEXTERN void j_set_quality PP((compress_info_ptr cinfo, int quality,
  821. X                  boolean force_baseline));
  822. X
  823. X/* main entry for decompression */
  824. XEXTERN void jpeg_decompress PP((decompress_info_ptr cinfo));
  825. X
  826. X/* default parameter setup for decompression */
  827. XEXTERN void j_d_defaults PP((decompress_info_ptr cinfo,
  828. X                 boolean standard_buffering));
  829. X
  830. X/* forward DCT */
  831. XEXTERN void j_fwd_dct PP((DCTBLOCK data));
  832. X/* inverse DCT */
  833. XEXTERN void j_rev_dct PP((DCTBLOCK data));
  834. X
  835. X/* utility routines in jutils.c */
  836. XEXTERN long jround_up PP((long a, long b));
  837. XEXTERN void jcopy_sample_rows PP((JSAMPARRAY input_array, int source_row,
  838. X                  JSAMPARRAY output_array, int dest_row,
  839. X                  int num_rows, long num_cols));
  840. XEXTERN void jcopy_block_row PP((JBLOCKROW input_row, JBLOCKROW output_row,
  841. X                long num_blocks));
  842. XEXTERN void jzero_far PP((void FAR * target, size_t bytestozero));
  843. X
  844. X/* method selection routines for compression modules */
  845. XEXTERN void jselcpipeline PP((compress_info_ptr cinfo)); /* jcpipe.c */
  846. XEXTERN void jselchuffman PP((compress_info_ptr cinfo)); /* jchuff.c */
  847. XEXTERN void jselcarithmetic PP((compress_info_ptr cinfo)); /* jcarith.c */
  848. XEXTERN void jselexpand PP((compress_info_ptr cinfo)); /* jcexpand.c */
  849. XEXTERN void jselsubsample PP((compress_info_ptr cinfo)); /* jcsample.c */
  850. XEXTERN void jselcmcu PP((compress_info_ptr cinfo)); /* jcmcu.c */
  851. XEXTERN void jselccolor PP((compress_info_ptr cinfo));    /* jccolor.c */
  852. X/* The user interface should call one of these to select input format: */
  853. XEXTERN void jselrgif PP((compress_info_ptr cinfo)); /* jrdgif.c */
  854. XEXTERN void jselrppm PP((compress_info_ptr cinfo)); /* jrdppm.c */
  855. XEXTERN void jselrrle PP((compress_info_ptr cinfo)); /* jrdrle.c */
  856. XEXTERN void jselrtarga PP((compress_info_ptr cinfo)); /* jrdtarga.c */
  857. X/* and one of these to select output header format: */
  858. XEXTERN void jselwjfif PP((compress_info_ptr cinfo)); /* jwrjfif.c */
  859. X
  860. X/* method selection routines for decompression modules */
  861. XEXTERN void jseldpipeline PP((decompress_info_ptr cinfo)); /* jdpipe.c */
  862. XEXTERN void jseldhuffman PP((decompress_info_ptr cinfo)); /* jdhuff.c */
  863. XEXTERN void jseldarithmetic PP((decompress_info_ptr cinfo)); /* jdarith.c */
  864. XEXTERN void jseldmcu PP((decompress_info_ptr cinfo)); /* jdmcu.c */
  865. XEXTERN void jselbsmooth PP((decompress_info_ptr cinfo)); /* jbsmooth.c */
  866. XEXTERN void jselunsubsample PP((decompress_info_ptr cinfo)); /* jdsample.c */
  867. XEXTERN void jseldcolor PP((decompress_info_ptr cinfo));    /* jdcolor.c */
  868. XEXTERN void jsel1quantize PP((decompress_info_ptr cinfo)); /* jquant1.c */
  869. XEXTERN void jsel2quantize PP((decompress_info_ptr cinfo)); /* jquant2.c */
  870. X/* The user interface should call one of these to select input format: */
  871. XEXTERN void jselrjfif PP((decompress_info_ptr cinfo)); /* jrdjfif.c */
  872. X/* and one of these to select output image format: */
  873. XEXTERN void jselwgif PP((decompress_info_ptr cinfo)); /* jwrgif.c */
  874. XEXTERN void jselwppm PP((decompress_info_ptr cinfo)); /* jwrppm.c */
  875. XEXTERN void jselwrle PP((decompress_info_ptr cinfo)); /* jwrrle.c */
  876. XEXTERN void jselwtarga PP((decompress_info_ptr cinfo)); /* jwrtarga.c */
  877. X
  878. X/* method selection routines for system-dependent modules */
  879. XEXTERN void jselerror PP((external_methods_ptr emethods)); /* jerror.c */
  880. XEXTERN void jselmemmgr PP((external_methods_ptr emethods)); /* jmemmgr.c */
  881. X
  882. X
  883. X/* We assume that right shift corresponds to signed division by 2 with
  884. X * rounding towards minus infinity.  This is correct for typical "arithmetic
  885. X * shift" instructions that shift in copies of the sign bit.  But some
  886. X * C compilers implement >> with an unsigned shift.  For these machines you
  887. X * must define RIGHT_SHIFT_IS_UNSIGNED.
  888. X * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity.
  889. X * It is only applied with constant shift counts.  SHIFT_TEMPS must be
  890. X * included in the variables of any routine using RIGHT_SHIFT.
  891. X */
  892. X
  893. X#ifdef RIGHT_SHIFT_IS_UNSIGNED
  894. X#define SHIFT_TEMPS    INT32 shift_temp;
  895. X#define RIGHT_SHIFT(x,shft)  \
  896. X    ((shift_temp = (x)) < 0 ? \
  897. X     (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \
  898. X     (shift_temp >> (shft)))
  899. X#else
  900. X#define SHIFT_TEMPS
  901. X#define RIGHT_SHIFT(x,shft)    ((x) >> (shft))
  902. X#endif
  903. X
  904. X
  905. X/* Miscellaneous useful macros */
  906. X
  907. X#undef MAX
  908. X#define MAX(a,b)    ((a) > (b) ? (a) : (b))
  909. X#undef MIN
  910. X#define MIN(a,b)    ((a) < (b) ? (a) : (b))
  911. X
  912. X
  913. X#define RST0    0xD0        /* RST0 marker code */
  914. END_OF_FILE
  915.   if test 37381 -ne `wc -c <'jpegdata.h'`; then
  916.     echo shar: \"'jpegdata.h'\" unpacked with wrong size!
  917.   fi
  918.   # end of 'jpegdata.h'
  919. fi
  920. if test -f 'jwrgif.c' -a "${1}" != "-c" ; then 
  921.   echo shar: Will not clobber existing file \"'jwrgif.c'\"
  922. else
  923.   echo shar: Extracting \"'jwrgif.c'\" \(13893 characters\)
  924.   sed "s/^X//" >'jwrgif.c' <<'END_OF_FILE'
  925. X/*
  926. X * jwrgif.c
  927. X *
  928. X * Copyright (C) 1991, 1992, Thomas G. Lane.
  929. X * This file is part of the Independent JPEG Group's software.
  930. X * For conditions of distribution and use, see the accompanying README file.
  931. X *
  932. X * This file contains routines to write output images in GIF format.
  933. X *
  934. X * These routines may need modification for non-Unix environments or
  935. X * specialized applications.  As they stand, they assume output to
  936. X * an ordinary stdio stream.
  937. X *
  938. X * These routines are invoked via the methods put_pixel_rows, put_color_map,
  939. X * and output_init/term.
  940. X */
  941. X
  942. X/*
  943. X * This code is loosely based on ppmtogif from the PBMPLUS distribution
  944. X * of Feb. 1991.  That file contains the following copyright notice:
  945. X *    Based on GIFENCODE by David Rowley <mgardi@watdscu.waterloo.edu>.
  946. X *    Lempel-Ziv compression based on "compress" by Spencer W. Thomas et al.
  947. X *    Copyright (C) 1989 by Jef Poskanzer.
  948. X *    Permission to use, copy, modify, and distribute this software and its
  949. X *    documentation for any purpose and without fee is hereby granted, provided
  950. X *    that the above copyright notice appear in all copies and that both that
  951. X *    copyright notice and this permission notice appear in supporting
  952. X *    documentation.  This software is provided "as is" without express or
  953. X *    implied warranty.
  954. X *
  955. X * We are also required to state that
  956. X *    "The Graphics Interchange Format(c) is the Copyright property of
  957. X *    CompuServe Incorporated. GIF(sm) is a Service Mark property of
  958. X *    CompuServe Incorporated."
  959. X */
  960. X
  961. X#include "jinclude.h"
  962. X
  963. X#ifdef GIF_SUPPORTED
  964. X
  965. X
  966. Xstatic decompress_info_ptr dcinfo; /* to avoid passing to all functions */
  967. X
  968. X#define    MAX_LZW_BITS    12    /* maximum LZW code size (4096 symbols) */
  969. X
  970. Xtypedef INT16 code_int;        /* must hold -1 .. 2**MAX_LZW_BITS */
  971. X
  972. X#define LZW_TABLE_SIZE    ((code_int) 1 << MAX_LZW_BITS)
  973. X
  974. X#define HSIZE        5003    /* hash table size for 80% occupancy */
  975. X
  976. Xtypedef int hash_int;        /* must hold -2*HSIZE..2*HSIZE */
  977. X
  978. Xstatic int n_bits;        /* current number of bits/code */
  979. Xstatic code_int maxcode;    /* maximum code, given n_bits */
  980. X#define MAXCODE(n_bits)    (((code_int) 1 << (n_bits)) - 1)
  981. X
  982. Xstatic int init_bits;        /* initial n_bits ... restored after clear */
  983. X
  984. Xstatic code_int ClearCode;    /* clear code (doesn't change) */
  985. Xstatic code_int EOFCode;    /* EOF code (ditto) */
  986. X
  987. Xstatic code_int free_code;    /* first not-yet-used symbol code */
  988. X
  989. X/*
  990. X * The LZW hash table consists of three parallel arrays:
  991. X *   hash_code[i]    code of symbol in slot i, or 0 if empty slot
  992. X *   hash_prefix[i]    symbol's prefix code; undefined if empty slot
  993. X *   hash_suffix[i]    symbol's suffix character; undefined if empty slot
  994. X * where slot values (i) range from 0 to HSIZE-1.
  995. X *
  996. X * Algorithm:  use open addressing double hashing (no chaining) on the
  997. X * prefix code / suffix character combination.  We do a variant of Knuth's
  998. X * algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
  999. X * secondary probe.
  1000. X *
  1001. X * The hash tables are allocated from FAR heap space since they would use up
  1002. X * rather a lot of the near data space in a PC.
  1003. X */
  1004. X
  1005. Xstatic code_int FAR *hash_code;    /* => hash table of symbol codes */
  1006. Xstatic code_int FAR *hash_prefix; /* => hash table of prefix symbols */
  1007. Xstatic UINT8 FAR *hash_suffix;    /* => hash table of suffix bytes */
  1008. X
  1009. X
  1010. X/*
  1011. X * Routines to package compressed data bytes into GIF data blocks.
  1012. X * A data block consists of a count byte (1..255) and that many data bytes.
  1013. X */
  1014. X
  1015. Xstatic int bytesinpkt;        /* # of bytes in current packet */
  1016. Xstatic char packetbuf[256];    /* workspace for accumulating packet */
  1017. X
  1018. X
  1019. XLOCAL void
  1020. Xflush_packet (void)
  1021. X/* flush any accumulated data */
  1022. X{
  1023. X  if (bytesinpkt > 0) {        /* never write zero-length packet */
  1024. X    packetbuf[0] = (char) bytesinpkt++;
  1025. X    if (JFWRITE(dcinfo->output_file, packetbuf, bytesinpkt)
  1026. X    != (size_t) bytesinpkt)
  1027. X      ERREXIT(dcinfo->emethods, "Output file write error");
  1028. X    bytesinpkt = 0;
  1029. X  }
  1030. X}
  1031. X
  1032. X
  1033. X/* Add a character to current packet; flush to disk if necessary */
  1034. X#define CHAR_OUT(c)  \
  1035. X    { packetbuf[++bytesinpkt] = (char) (c);  \
  1036. X        if (bytesinpkt >= 255)  \
  1037. X          flush_packet();  \
  1038. X    }
  1039. X
  1040. X
  1041. X/* Routine to convert variable-width codes into a byte stream */
  1042. X
  1043. Xstatic INT32 cur_accum;        /* holds bits not yet output */
  1044. Xstatic int cur_bits;        /* # of bits in cur_accum */
  1045. X
  1046. X
  1047. XLOCAL void
  1048. Xoutput (code_int code)
  1049. X/* Emit a code of n_bits bits */
  1050. X/* Uses cur_accum and cur_bits to reblock into 8-bit bytes */
  1051. X{
  1052. X  cur_accum |= ((INT32) code) << cur_bits;
  1053. X  cur_bits += n_bits;
  1054. X
  1055. X  while (cur_bits >= 8) {
  1056. X    CHAR_OUT(cur_accum & 0xFF);
  1057. X    cur_accum >>= 8;
  1058. X    cur_bits -= 8;
  1059. X  }
  1060. X
  1061. X  /*
  1062. X   * If the next entry is going to be too big for the code size,
  1063. X   * then increase it, if possible.  We do this here to ensure
  1064. X   * that it's done in sync with the decoder's codesize increases.
  1065. X   */
  1066. X  if (free_code > maxcode) {
  1067. X    n_bits++;
  1068. X    if (n_bits == MAX_LZW_BITS)
  1069. X      maxcode = LZW_TABLE_SIZE;    /* free_code will never exceed this */
  1070. X    else
  1071. X      maxcode = MAXCODE(n_bits);
  1072. X  }
  1073. X}
  1074. X
  1075. X
  1076. X/* The LZW algorithm proper */
  1077. X
  1078. Xstatic code_int waiting_code;    /* symbol not yet output; may be extendable */
  1079. Xstatic boolean first_byte;    /* if TRUE, waiting_code is not valid */
  1080. X
  1081. X
  1082. XLOCAL void
  1083. Xclear_hash (void)
  1084. X/* Fill the hash table with empty entries */
  1085. X{
  1086. X  /* It's sufficient to zero hash_code[] */
  1087. X  jzero_far((void FAR *) hash_code, HSIZE * SIZEOF(code_int));
  1088. X}
  1089. X
  1090. X
  1091. XLOCAL void
  1092. Xclear_block (void)
  1093. X/* Reset compressor and issue a Clear code */
  1094. X{
  1095. X  clear_hash();            /* delete all the symbols */
  1096. X  free_code = ClearCode + 2;
  1097. X  output(ClearCode);        /* inform decoder */
  1098. X  n_bits = init_bits;        /* reset code size */
  1099. X  maxcode = MAXCODE(n_bits);
  1100. X}
  1101. X
  1102. X
  1103. XLOCAL void
  1104. Xcompress_init (int i_bits)
  1105. X/* Initialize LZW compressor */
  1106. X{
  1107. X  /* init all the static variables */
  1108. X  n_bits = init_bits = i_bits;
  1109. X  maxcode = MAXCODE(n_bits);
  1110. X  ClearCode = ((code_int) 1 << (init_bits - 1));
  1111. X  EOFCode = ClearCode + 1;
  1112. X  free_code = ClearCode + 2;
  1113. X  first_byte = TRUE;        /* no waiting symbol yet */
  1114. X  /* init output buffering vars */
  1115. X  bytesinpkt = 0;
  1116. X  cur_accum = 0;
  1117. X  cur_bits = 0;
  1118. X  /* clear hash table */
  1119. X  clear_hash();
  1120. X  /* GIF specifies an initial Clear code */
  1121. X  output(ClearCode);
  1122. X}
  1123. X
  1124. X
  1125. XLOCAL void
  1126. Xcompress_byte (int c)
  1127. X/* Accept and compress one 8-bit byte */
  1128. X{
  1129. X  register hash_int i;
  1130. X  register hash_int disp;
  1131. X
  1132. X  if (first_byte) {        /* need to initialize waiting_code */
  1133. X    waiting_code = c;
  1134. X    first_byte = FALSE;
  1135. X    return;
  1136. X  }
  1137. X
  1138. X  /* Probe hash table to see if a symbol exists for
  1139. X   * waiting_code followed by c.
  1140. X   * If so, replace waiting_code by that symbol and return.
  1141. X   */
  1142. X  i = ((hash_int) c << (MAX_LZW_BITS-8)) + waiting_code;
  1143. X  /* i is less than twice 2**MAX_LZW_BITS, therefore less than twice HSIZE */
  1144. X  if (i >= HSIZE)
  1145. X    i -= HSIZE;
  1146. X  
  1147. X  if (hash_code[i] != 0) {    /* is first probed slot empty? */
  1148. X    if (hash_prefix[i] == waiting_code && hash_suffix[i] == (UINT8) c) {
  1149. X      waiting_code = hash_code[i];
  1150. X      return;
  1151. X    }
  1152. X    if (i == 0)            /* secondary hash (after G. Knott) */
  1153. X      disp = 1;
  1154. X    else
  1155. X      disp = HSIZE - i;
  1156. X    while (1) {
  1157. X      i -= disp;
  1158. X      if (i < 0)
  1159. X    i += HSIZE;
  1160. X      if (hash_code[i] == 0)
  1161. X    break;            /* hit empty slot */
  1162. X      if (hash_prefix[i] == waiting_code && hash_suffix[i] == (UINT8) c) {
  1163. X    waiting_code = hash_code[i];
  1164. X    return;
  1165. X      }
  1166. X    }
  1167. X  }
  1168. X
  1169. X  /* here when hashtable[i] is an empty slot; desired symbol not in table */
  1170. X  output(waiting_code);
  1171. X  if (free_code < LZW_TABLE_SIZE) {
  1172. X    hash_code[i] = free_code++;    /* add symbol to hashtable */
  1173. X    hash_prefix[i] = waiting_code;
  1174. X    hash_suffix[i] = (UINT8) c;
  1175. X  } else
  1176. X    clear_block();
  1177. X  waiting_code = c;
  1178. X}
  1179. X
  1180. X
  1181. XLOCAL void
  1182. Xcompress_term (void)
  1183. X/* Clean up at end */
  1184. X{
  1185. X  /* Flush out the buffered code */
  1186. X  if (! first_byte)
  1187. X    output(waiting_code);
  1188. X  /* Send an EOF code */
  1189. X  output(EOFCode);
  1190. X  /* Flush the bit-packing buffer */
  1191. X  if (cur_bits > 0) {
  1192. X    CHAR_OUT(cur_accum & 0xFF);
  1193. X  }
  1194. X  /* Flush the packet buffer */
  1195. X  flush_packet();
  1196. X}
  1197. X
  1198. X
  1199. X/* GIF header construction */
  1200. X
  1201. X
  1202. XLOCAL void
  1203. Xput_word (UINT16 w)
  1204. X/* Emit a 16-bit word, LSB first */
  1205. X{
  1206. X  putc(w & 0xFF, dcinfo->output_file);
  1207. X  putc((w >> 8) & 0xFF, dcinfo->output_file);
  1208. X}
  1209. X
  1210. X
  1211. XLOCAL void
  1212. Xput_3bytes (int val)
  1213. X/* Emit 3 copies of same byte value --- handy subr for colormap construction */
  1214. X{
  1215. X  putc(val, dcinfo->output_file);
  1216. X  putc(val, dcinfo->output_file);
  1217. X  putc(val, dcinfo->output_file);
  1218. X}
  1219. X
  1220. X
  1221. XLOCAL void
  1222. Xemit_header (int num_colors, JSAMPARRAY colormap)
  1223. X/* Output the GIF file header, including color map */
  1224. X/* If colormap==NULL, synthesize a gray-scale colormap */
  1225. X{
  1226. X  int BitsPerPixel, ColorMapSize, InitCodeSize, FlagByte;
  1227. X  int cshift = dcinfo->data_precision - 8;
  1228. X  int i;
  1229. X
  1230. X  if (num_colors > 256)
  1231. X    ERREXIT(dcinfo->emethods, "GIF can only handle 256 colors");
  1232. X  /* Compute bits/pixel and related values */
  1233. X  BitsPerPixel = 1;
  1234. X  while (num_colors > (1 << BitsPerPixel))
  1235. X    BitsPerPixel++;
  1236. X  ColorMapSize = 1 << BitsPerPixel;
  1237. X  if (BitsPerPixel <= 1)
  1238. X    InitCodeSize = 2;
  1239. X  else
  1240. X    InitCodeSize = BitsPerPixel;
  1241. X  /*
  1242. X   * Write the GIF header.
  1243. X   * Note that we generate a plain GIF87 header for maximum compatibility.
  1244. X   */
  1245. X  (void) JFWRITE(dcinfo->output_file, "GIF87a", 6);
  1246. X  /* Write the Logical Screen Descriptor */
  1247. X  put_word((UINT16) dcinfo->image_width);
  1248. X  put_word((UINT16) dcinfo->image_height);
  1249. X  FlagByte = 0x80;        /* Yes, there is a global color table */
  1250. X  FlagByte |= (BitsPerPixel-1) << 4; /* color resolution */
  1251. X  FlagByte |= (BitsPerPixel-1);    /* size of global color table */
  1252. X  putc(FlagByte, dcinfo->output_file);
  1253. X  putc(0, dcinfo->output_file);    /* Background color index */
  1254. X  putc(0, dcinfo->output_file);    /* Reserved in GIF87 (aspect ratio in GIF89) */
  1255. X  /* Write the Global Color Map */
  1256. X  /* If the color map is more than 8 bits precision, */
  1257. X  /* we reduce it to 8 bits by shifting */
  1258. X  for (i=0; i < ColorMapSize; i++) {
  1259. X    if (i < num_colors) {
  1260. X      if (colormap != NULL) {
  1261. X    if (dcinfo->out_color_space == CS_RGB) {
  1262. X      /* Normal case: RGB color map */
  1263. X      putc(GETJSAMPLE(colormap[0][i]) >> cshift, dcinfo->output_file);
  1264. X      putc(GETJSAMPLE(colormap[1][i]) >> cshift, dcinfo->output_file);
  1265. X      putc(GETJSAMPLE(colormap[2][i]) >> cshift, dcinfo->output_file);
  1266. X    } else {
  1267. X      /* Grayscale "color map": possible if quantizing grayscale image */
  1268. X      put_3bytes(GETJSAMPLE(colormap[0][i]) >> cshift);
  1269. X    }
  1270. X      } else {
  1271. X    /* Create a gray-scale map of num_colors values, range 0..255 */
  1272. X    put_3bytes((i * 255 + (num_colors-1)/2) / (num_colors-1));
  1273. X      }
  1274. X    } else {
  1275. X      /* fill out the map to a power of 2 */
  1276. X      put_3bytes(0);
  1277. X    }
  1278. X  }
  1279. X  /* Write image separator and Image Descriptor */
  1280. X  putc(',', dcinfo->output_file); /* separator */
  1281. X  put_word((UINT16) 0);        /* left/top offset */
  1282. X  put_word((UINT16) 0);
  1283. X  put_word((UINT16) dcinfo->image_width); /* image size */
  1284. X  put_word((UINT16) dcinfo->image_height);
  1285. X  /* flag byte: not interlaced, no local color map */
  1286. X  putc(0x00, dcinfo->output_file);
  1287. X  /* Write Initial Code Size byte */
  1288. X  putc(InitCodeSize, dcinfo->output_file);
  1289. X
  1290. X  /* Initialize for LZW compression of image data */
  1291. X  compress_init(InitCodeSize+1);
  1292. X}
  1293. X
  1294. X
  1295. X
  1296. X/*
  1297. X * Initialize for GIF output.
  1298. X */
  1299. X
  1300. XMETHODDEF void
  1301. Xoutput_init (decompress_info_ptr cinfo)
  1302. X{
  1303. X  dcinfo = cinfo;        /* save for use by local routines */
  1304. X  if (cinfo->final_out_comps != 1) /* safety check */
  1305. X    ERREXIT(cinfo->emethods, "GIF output got confused");
  1306. X  /* Allocate space for hash table */
  1307. X  hash_code = (code_int FAR *) (*cinfo->emethods->alloc_medium)
  1308. X                (HSIZE * SIZEOF(code_int));
  1309. X  hash_prefix = (code_int FAR *) (*cinfo->emethods->alloc_medium)
  1310. X                (HSIZE * SIZEOF(code_int));
  1311. X  hash_suffix = (UINT8 FAR *) (*cinfo->emethods->alloc_medium)
  1312. X                (HSIZE * SIZEOF(UINT8));
  1313. X  /*
  1314. X   * If we aren't quantizing, put_color_map won't be called,
  1315. X   * so emit the header now.  This only happens with gray scale output.
  1316. X   * (If we are quantizing, wait for the color map to be provided.)
  1317. X   */
  1318. X  if (! cinfo->quantize_colors)
  1319. X    emit_header(256, (JSAMPARRAY) NULL);
  1320. X}
  1321. X
  1322. X
  1323. X/*
  1324. X * Write the color map.
  1325. X */
  1326. X
  1327. XMETHODDEF void
  1328. Xput_color_map (decompress_info_ptr cinfo, int num_colors, JSAMPARRAY colormap)
  1329. X{
  1330. X  emit_header(num_colors, colormap);
  1331. X}
  1332. X
  1333. X
  1334. X/*
  1335. X * Write some pixel data.
  1336. X */
  1337. X
  1338. XMETHODDEF void
  1339. Xput_pixel_rows (decompress_info_ptr cinfo, int num_rows,
  1340. X        JSAMPIMAGE pixel_data)
  1341. X{
  1342. X  register JSAMPROW ptr;
  1343. X  register long col;
  1344. X  register long width = cinfo->image_width;
  1345. X  register int row;
  1346. X  
  1347. X  for (row = 0; row < num_rows; row++) {
  1348. X    ptr = pixel_data[0][row];
  1349. X    for (col = width; col > 0; col--) {
  1350. X      compress_byte(GETJSAMPLE(*ptr));
  1351. X      ptr++;
  1352. X    }
  1353. X  }
  1354. X}
  1355. X
  1356. X
  1357. X/*
  1358. X * Finish up at the end of the file.
  1359. X */
  1360. X
  1361. XMETHODDEF void
  1362. Xoutput_term (decompress_info_ptr cinfo)
  1363. X{
  1364. X  /* Flush LZW mechanism */
  1365. X  compress_term();
  1366. X  /* Write a zero-length data block to end the series */
  1367. X  putc(0, cinfo->output_file);
  1368. X  /* Write the GIF terminator mark */
  1369. X  putc(';', cinfo->output_file);
  1370. X  /* Make sure we wrote the output file OK */
  1371. X  fflush(cinfo->output_file);
  1372. X  if (ferror(cinfo->output_file))
  1373. X    ERREXIT(cinfo->emethods, "Output file write error");
  1374. X  /* Free space */
  1375. X  /* no work (we let free_all release the workspace) */
  1376. X}
  1377. X
  1378. X
  1379. X/*
  1380. X * The method selection routine for GIF format output.
  1381. X * This should be called from d_ui_method_selection if GIF output is wanted.
  1382. X */
  1383. X
  1384. XGLOBAL void
  1385. Xjselwgif (decompress_info_ptr cinfo)
  1386. X{
  1387. X  cinfo->methods->output_init = output_init;
  1388. X  cinfo->methods->put_color_map = put_color_map;
  1389. X  cinfo->methods->put_pixel_rows = put_pixel_rows;
  1390. X  cinfo->methods->output_term = output_term;
  1391. X
  1392. X  if (cinfo->out_color_space != CS_GRAYSCALE &&
  1393. X      cinfo->out_color_space != CS_RGB)
  1394. X    ERREXIT(cinfo->emethods, "GIF output must be grayscale or RGB");
  1395. X
  1396. X  /* Force quantization if color or if > 8 bits input */
  1397. X  if (cinfo->out_color_space == CS_RGB || cinfo->data_precision > 8) {
  1398. X    /* Force quantization to at most 256 colors */
  1399. X    cinfo->quantize_colors = TRUE;
  1400. X    if (cinfo->desired_number_of_colors > 256)
  1401. X      cinfo->desired_number_of_colors = 256;
  1402. X  }
  1403. X}
  1404. X
  1405. X#endif /* GIF_SUPPORTED */
  1406. END_OF_FILE
  1407.   if test 13893 -ne `wc -c <'jwrgif.c'`; then
  1408.     echo shar: \"'jwrgif.c'\" unpacked with wrong size!
  1409.   fi
  1410.   # end of 'jwrgif.c'
  1411. fi
  1412. if test -f 'makcjpeg.lnk' -a "${1}" != "-c" ; then 
  1413.   echo shar: Will not clobber existing file \"'makcjpeg.lnk'\"
  1414. else
  1415.   echo shar: Extracting \"'makcjpeg.lnk'\" \(320 characters\)
  1416.   sed "s/^X//" >'makcjpeg.lnk' <<'END_OF_FILE'
  1417. Xjcmain.obj +
  1418. Xjcmaster.obj +
  1419. Xjcdeflts.obj +
  1420. Xjcarith.obj +
  1421. Xjccolor.obj +
  1422. Xjcexpand.obj +
  1423. Xjchuff.obj +
  1424. Xjcmcu.obj +
  1425. Xjcpipe.obj +
  1426. Xjcsample.obj +
  1427. Xjfwddct.obj +
  1428. Xjwrjfif.obj +
  1429. Xjrdgif.obj +
  1430. Xjrdppm.obj +
  1431. Xjrdrle.obj +
  1432. Xjrdtarga.obj +
  1433. Xjutils.obj +
  1434. Xjerror.obj +
  1435. Xjmemmgr.obj +
  1436. Xjmemsys.obj +
  1437. Xjmemdosa.obj
  1438. Xcjpeg.exe /NOI
  1439. Xnul.map
  1440. X
  1441. Xnul.def
  1442. END_OF_FILE
  1443.   if test 320 -ne `wc -c <'makcjpeg.lnk'`; then
  1444.     echo shar: \"'makcjpeg.lnk'\" unpacked with wrong size!
  1445.   fi
  1446.   # end of 'makcjpeg.lnk'
  1447. fi
  1448. echo shar: End of archive 4 \(of 18\).
  1449. cp /dev/null ark4isdone
  1450. MISSING=""
  1451. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ; do
  1452.     if test ! -f ark${I}isdone ; then
  1453.     MISSING="${MISSING} ${I}"
  1454.     fi
  1455. done
  1456. if test "${MISSING}" = "" ; then
  1457.     echo You have unpacked all 18 archives.
  1458.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1459. else
  1460.     echo You still must unpack the following archives:
  1461.     echo "        " ${MISSING}
  1462. fi
  1463. exit 0
  1464. exit 0 # Just in case...
  1465.