readme.txt 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. _____________________________________________________________________________
  2. PASJPEG 1.1 May 29th, 1999
  3. Based on the Independent JPEG Group's JPEG software release 6b
  4. Copyright (C) 1996,1998,1999 by NOMSSI NZALI Jacques H. C.
  5. [kn&n DES] See "Legal issues" for conditions of distribution and use.
  6. _____________________________________________________________________________
  7. Information in this file
  8. ========================
  9. o Introduction
  10. o Notes
  11. o File list
  12. o Translation
  13. o Legal issues
  14. o Archive Locations
  15. Introduction
  16. ============
  17. PASJPEG is a port of the sixth public release of the IJG C source (release
  18. 6b of 27-Mar-98) [3], that implements JPEG baseline, extended-sequential, and
  19. progressive compression processes to Turbo Pascal 7.0 for DOS (TP). The code
  20. has been tested under Delphi 3.0, it can be ported to other Pascal
  21. environments, since many compilers try to be compatible to TP.
  22. JPEG (pronounced "jay-peg") is a standardized familly of algorithms for
  23. compression of continous tone still images. Most JPEG processes are lossy,
  24. the output image is not exactly identical to the input image. However, on
  25. typical photographic images, very good compression levels can be obtained
  26. with no visible change, and remarkably high compression levels are possible
  27. if you can tolerate a low-quality image [1],[2]. The Independent JPEG Group
  28. (IJG) has created a free, portable C library for JPEG compression and
  29. decompression of JPEG images.
  30. The IJG documentation (system architecture, using the IJG JPEG library,
  31. usage and file list) is a must read. The files DEMO.PAS, TEST.PAS, CJPEG.PAS,
  32. DJPEG.PAS and EXAMPLE.PAS demonstrate the usage of the JPEG decompression
  33. and compression library. The RDJPGCOM application shows how to parse a JFIF
  34. file.
  35. Notes:
  36. ======
  37. * Please report any errors/problems you may find in code and in the
  38. documentation (e.g. this README.TXT file).
  39. * The sample applications (CJPEG, DJPEG) doesn't support all the options
  40. of the original C code. WRJPGCOM is not ported.
  41. * Environment variable JPEGMEM syntax changed;
  42. * You can modify the jpeg.pas unit from the Delphi 3 distribution to
  43. use PasJPEG.
  44. Change log
  45. ==========
  46. 1. bugs fixed:
  47. * in procedure read_gif_map(), unit RDCOLMAP.PAS (used by DJPEG sample
  48. application). Davie Lee Reed <[email protected]>
  49. * -dct int and -dct fast now bytewise equal to the IJG output.
  50. * -dct float produced large files
  51. 2. Support for scripts
  52. 3. BASM version of JIDCTINT.PAS for Delphi 2 and 3.
  53. 4. images with integral sampling ratios were not decoded correctly.
  54. Create a jpeg file with cjpeg and the option "-sample 4x1" and try to decode
  55. it with any software that uses PasJpeg. Thanks to Jannie Gerber for reporting
  56. this with a fix: In JDSAMPLE.PAS, procedure int_upsample(),
  57. for h := pred(h_expand) downto 0 do
  58. begin
  59. outptr^ := invalue;
  60. +=> inc(outptr); { this is the culprit that was left out!!! }
  61. Dec(outcount);
  62. end;
  63. File list
  64. =========
  65. Here is a road map to the files in the PasJPEG distribution. The
  66. distribution includes the JPEG library proper, plus two application
  67. programs ("cjpeg" and "djpeg") which use the library to convert JPEG
  68. files to and from some other popular image formats. A third application
  69. "jpegtran" uses the library to do lossless conversion between different
  70. variants of JPEG. There is also the stand-alone applications "rdjpgcom".
  71. Documentation(see README for a guide to the documentation files):
  72. readme.txt Introduction, Documentation
  73. Additional files
  74. demo.pas Demo program, uses example.pas
  75. example.pas Sample code for calling JPEG library.
  76. test.pas Sample application code for demo.pas
  77. Configuration/installation files and programs (see install.doc for more info):
  78. jconfig.inc Configuration declarations.
  79. *.ijg script files
  80. Pascal source code files:
  81. jinclude.pas Central include file used by all IJG .c files to reference
  82. system include files.
  83. jpeglib.pas JPEG library's internal data structures, exported data
  84. and function declarations.
  85. jmorecfg.pas Additional configuration declarations; need not be changed
  86. for a standard installation.
  87. jdeferr.pas defines the error and message text.
  88. jerror.pas Declares JPEG library's error and trace message codes.
  89. jinclude.pas the place to specify system depedent input/output code.
  90. jdct.pas Private declarations for forward & reverse DCT subsystems.
  91. These files contain most of the functions intended to be called directly by
  92. an application program:
  93. jcapimin.pas Application program interface: core routines for compression.
  94. jcapistd.pas Application program interface: standard compression.
  95. jdapimin.pas Application program interface: core routines for decompression.
  96. jdapistd.pas Application program interface: standard decompression.
  97. jcomapi.pas Application program interface routines common to compression
  98. and decompression.
  99. jcparam.pas Compression parameter setting helper routines.
  100. jctrans.pas API and library routines for transcoding compression.
  101. jdtrans.pas API and library routines for transcoding decompression.
  102. Compression side of the library:
  103. jcinit.pas Initialization: determines which other modules to use.
  104. jcmaster.pas Master control: setup and inter-pass sequencing logic.
  105. jcmainct.pas Main buffer controller (preprocessor => JPEG compressor).
  106. jcprepct.pas Preprocessor buffer controller.
  107. jccoefct.pas Buffer controller for DCT coefficient buffer.
  108. jccolor.pas Color space conversion.
  109. jcsample.pas Downsampling.
  110. jcdctmgr.pas DCT manager (DCT implementation selection & control).
  111. jfdctint.pas Forward DCT using slow-but-accurate integer method.
  112. jfdctfst.pas Forward DCT using faster, less accurate integer method.
  113. jfdctflt.pas Forward DCT using floating-point arithmetic.
  114. jchuff.pas Huffman entropy coding for sequential JPEG.
  115. jcphuff.pas Huffman entropy coding for progressive JPEG.
  116. jcmarker.pas JPEG marker writing.
  117. jdatadst.pas Data destination manager for stdio output.
  118. Decompression side of the library:
  119. jdmaster.pas Master control: determines which other modules to use.
  120. jdinput.pas Input controller: controls input processing modules.
  121. jdmainct.pas Main buffer controller (JPEG decompressor => postprocessor).
  122. jdcoefct.pas Buffer controller for DCT coefficient buffer.
  123. jdpostct.pas Postprocessor buffer controller.
  124. jdmarker.pas JPEG marker reading.
  125. jdhuff.pas Huffman entropy decoding for sequential JPEG.
  126. jdphuff.pas Huffman entropy decoding for progressive JPEG.
  127. jddctmgr.pas IDCT manager (IDCT implementation selection & control).
  128. jidctint.pas Inverse DCT using slow-but-accurate integer method.
  129. jidctasm.pas BASM specific version of jidctint.pas for 32bit Delphi.
  130. jidctfst.pas Inverse DCT using faster, less accurate integer method.
  131. jidctflt.pas Inverse DCT using floating-point arithmetic.
  132. jidctred.pas Inverse DCTs with reduced-size outputs.
  133. jidct2d.pas How to for a direct 2D Inverse DCT - not used
  134. jdsample.pas Upsampling.
  135. jdcolor.pas Color space conversion.
  136. jdmerge.pas Merged upsampling/color conversion (faster, lower quality).
  137. jquant1.pas One-pass color quantization using a fixed-spacing colormap.
  138. jquant2.pas Two-pass color quantization using a custom-generated colormap.
  139. Also handles one-pass quantization to an externally given map.
  140. jdatasrc.pas Data source manager for stdio input.
  141. Support files for both compression and decompression:
  142. jerror.pas Standard error handling routines (application replaceable).
  143. jmemmgr.pas System-independent (more or less) memory management code.
  144. jutils.pas Miscellaneous utility routines.
  145. jmemmgr.pas relies on a system-dependent memory management module. The
  146. PASJPEG distribution includes the following implementations of the system-
  147. dependent module:
  148. jmemnobs.pas "No backing store": assumes adequate virtual memory exists.
  149. jmemdos.pas Custom implementation for MS-DOS (16-bit environment only):
  150. can use extended and expanded memory as well as temporary
  151. files.
  152. jmemsys.pas A skeleton with all the declaration you need to create a
  153. working system-dependent JPEG memory manager on unusual
  154. systems.
  155. Exactly one of the system-dependent units should be used in jmemmgr.pas.
  156. jmemdosa.pas BASM 80x86 assembly code support for jmemdos.pas; used only
  157. in MS-DOS-specific configurations of the JPEG library.
  158. Applications using the library should use jmorecfg, jerror, jpeglib, and
  159. include jconfig.inc.
  160. CJPEG/DJPEG/JPEGTRAN
  161. Pascal source code files:
  162. cderror.pas Additional error and trace message codes for cjpeg/djpeg.
  163. Not used, Those errors have been added to jdeferr.
  164. cjpeg.pas Main program for cjpeg.
  165. djpeg.pas Main program for djpeg.
  166. jpegtran.pas Main program for jpegtran.
  167. cdjpeg.pas Utility routines used by all three programs.
  168. rdcolmap.pas Code to read a colormap file for djpeg's "-map" switch.
  169. rdswitch.pas Code to process some of cjpeg's more complex switches.
  170. Also used by jpegtran.
  171. transupp.pas Support code for jpegtran: lossless image manipulations.
  172. fcache.pas
  173. rdswitch.pas Code to process some of cjpeg's more complex switches.
  174. Also used by jpegtran.
  175. Image file writer modules for djpeg:
  176. wrbmp.pas BMP file output.
  177. wrppm.pas PPM/PGM file output.
  178. wrtarga.pas Targa file output.
  179. Image file reader modules for cjpeg:
  180. rdbmp.pas BMP file input.
  181. rdppm.pas PPM/PGM file input.
  182. rdtarga.pas Targa file input. - NOT READY YET
  183. This program does not depend on the JPEG library
  184. rdjpgcom.pas Stand-alone rdjpgcom application.
  185. Translation
  186. ===========
  187. TP is unit-centric, exported type definitions and routines are declared
  188. in the "interface" part of the unit, "make" files are not needed.
  189. Macros are not supported, they were either copied as needed or translated
  190. to Pascal routines (procedure). The procedures will be replaced by code in
  191. later releases.
  192. Conditional defines that indicate whether to include various optional
  193. functions are defined in the file JCONFIG.INC. This file is included first
  194. in all source files.
  195. The base type definitions are in the unit JMORECFG.PAS. The error handling
  196. macros have been converted to procedures in JERROR.PAS. The error codes are
  197. in JDEFERR.PAS. jpegint.h and jpeglib.h were merged into one large unit
  198. JPEGLIB.PAS containing type definitions with global scope.
  199. The translation of the header file is the most sophisticated work, a good
  200. understanding of the syntax is required. Once the header files are done,
  201. the translation turns into a lot of editing work. Each C source file was
  202. converted to a unit by editing the syntax (separate variable definition
  203. and usage, define labels, group variable definitions, expanding macros, etc).
  204. The IJG source labels routines GLOBAL, METHODDEF and LOCAL. All globals
  205. routines are in the interface section of the units. The "far" directive is
  206. used for methods (METHODDEF).
  207. Some C -> Pascal examples.
  208. * "{" -> "begin" "->" -> "^." " = " -> " := " "<<" -> " shl "
  209. "}" -> "end;" "!=" -> "<>" " == " -> " = " ">>" -> " shr "
  210. "/*" -> "{" routine -> function "0x" -> "$"
  211. "*/" -> "}" (void) procedure "NULL" -> "NIL"
  212. * structs are records, Unions are variable records, pointers are always far,
  213. the operators && and || (and/or) have not the same priority in both
  214. languages, so parenthesis are important. The Pascal "case" doesn't have the
  215. falltrough option of the C "switch" statement, my work around is to split
  216. one "switch" statement into many case statements.
  217. * The pointer type in C is not readily interchangeable. It is used to address
  218. an array (Pascal pointer to an array) or in pointer arithmetic a pointer to
  219. a single element. I've used the Inc() statement with type casting to
  220. translate pointer arithmetic most of the time.
  221. C example:
  222. typedef JSAMPLE* JSAMPROW; /* ptr to one image row of pixel samples. */
  223. Pascal
  224. type
  225. JSAMPLE_PTR = ^JSAMPLE; { ptr to a single pixel sample. }
  226. jTSample = 0..(MaxInt div SIZEOF(JSAMPLE))-1;
  227. JSAMPLE_ARRAY = Array[jTSample] of JSAMPLE; {far}
  228. JSAMPROW = ^JSAMPLE_ARRAY; { ptr to one image row of pixel samples. }
  229. The following code
  230. JSAMPROW buffer0, buffer1; /* ptr to a JSAMPLE buffer. */
  231. ...
  232. buffer1 = buffer0 + i;
  233. can be translated to
  234. var
  235. buffer0, buffer1 : JSAMPROW;
  236. ...
  237. buffer1 := buffer0;
  238. Inc(JSAMPLE_PTR(buffer1), i);
  239. or
  240. buffer1 := JSAMPROW(@ buffer0^[i]);
  241. Declaring the variables as JSAMPLE_PTR may reduce type casting in some
  242. places. I use help pointers to handle negative array offsets.
  243. While translating the type of function parameter from C to Pascal, one can
  244. often use "var", "const", or "array of" parameters instead of pointers.
  245. While translating for(;;)-loops with more than one induction variable to
  246. Pascal "for to/downto do"-loops, the extra induction variables have to be
  247. manually updated at the end of the loop and before "continue"-statements.
  248. Legal issues
  249. ============
  250. Copyright (C) 1996,1998 by Jacques Nomssi Nzali
  251. This software is provided 'as-is', without any express or implied
  252. warranty. In no event will the author be held liable for any damages
  253. arising from the use of this software.
  254. Permission is granted to anyone to use this software for any purpose,
  255. including commercial applications, and to alter it and redistribute it
  256. freely, subject to the following restrictions:
  257. 1. The origin of this software must not be misrepresented; you must not
  258. claim that you wrote the original software. If you use this software
  259. in a product, an acknowledgment in the product documentation would be
  260. appreciated but is not required.
  261. 2. Altered source versions must be plainly marked as such, and must not be
  262. misrepresented as being the original software.
  263. 3. This notice may not be removed or altered from any source distribution.
  264. Archive Locations:
  265. ==================
  266. [1] Thomas G. Lane, JPEG FAQ
  267. in comp.graphics.misc and related newsgroups
  268. [2] Wallace, Gregory K.: The JPEG Still Picture Compression Standard
  269. ftp.uu.net, graphics/jpeg/wallace.ps.Z
  270. [3] The Independent JPEG Group C library for JPEG encoding and decoding,
  271. rev 6b.
  272. ftp://ftp.uu.net/graphics/jpeg/
  273. or SimTel in msdos/graphics/
  274. [4] JPEG implementation, written by the PVRG group at Stanford,
  275. ftp havefun.stanford.edu:/pub/jpeg/JPEGv1.2.tar.Z.
  276. [5] PASJPEG.ZIP at NView ftp site
  277. ftp://druckfix.physik.tu-chemnitz.de/pub/nv/
  278. http://www.tu-chemnitz.de/~nomssi/pub/pasjpeg.zip
  279. [6] The PasJPEG home page with links
  280. http://www.tu-chemnitz.de/~nomssi/pasjpeg.html
  281. _____________________________________________________________________________