install.doc 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063
  1. INSTALLATION INSTRUCTIONS for the Independent JPEG Group's JPEG software
  2. Copyright (C) 1991-1998, Thomas G. Lane.
  3. This file is part of the Independent JPEG Group's software.
  4. For conditions of distribution and use, see the accompanying README file.
  5. This file explains how to configure and install the IJG software. We have
  6. tried to make this software extremely portable and flexible, so that it can be
  7. adapted to almost any environment. The downside of this decision is that the
  8. installation process is complicated. We have provided shortcuts to simplify
  9. the task on common systems. But in any case, you will need at least a little
  10. familiarity with C programming and program build procedures for your system.
  11. If you are only using this software as part of a larger program, the larger
  12. program's installation procedure may take care of configuring the IJG code.
  13. For example, Ghostscript's installation script will configure the IJG code.
  14. You don't need to read this file if you just want to compile Ghostscript.
  15. If you are on a Unix machine, you may not need to read this file at all.
  16. Try doing
  17. ./configure
  18. make
  19. make test
  20. If that doesn't complain, do
  21. make install
  22. (better do "make -n install" first to see if the makefile will put the files
  23. where you want them). Read further if you run into snags or want to customize
  24. the code for your system.
  25. TABLE OF CONTENTS
  26. -----------------
  27. Before you start
  28. Configuring the software:
  29. using the automatic "configure" script
  30. using one of the supplied jconfig and makefile files
  31. by hand
  32. Building the software
  33. Testing the software
  34. Installing the software
  35. Optional stuff
  36. Optimization
  37. Hints for specific systems
  38. BEFORE YOU START
  39. ================
  40. Before installing the software you must unpack the distributed source code.
  41. Since you are reading this file, you have probably already succeeded in this
  42. task. However, there is a potential for error if you needed to convert the
  43. files to the local standard text file format (for example, if you are on
  44. MS-DOS you may have converted LF end-of-line to CR/LF). You must apply
  45. such conversion to all the files EXCEPT those whose names begin with "test".
  46. The test files contain binary data; if you change them in any way then the
  47. self-test will give bad results.
  48. Please check the last section of this file to see if there are hints for the
  49. specific machine or compiler you are using.
  50. CONFIGURING THE SOFTWARE
  51. ========================
  52. To configure the IJG code for your system, you need to create two files:
  53. * jconfig.h: contains values for system-dependent #define symbols.
  54. * Makefile: controls the compilation process.
  55. (On a non-Unix machine, you may create "project files" or some other
  56. substitute for a Makefile. jconfig.h is needed in any environment.)
  57. We provide three different ways to generate these files:
  58. * On a Unix system, you can just run the "configure" script.
  59. * We provide sample jconfig files and makefiles for popular machines;
  60. if your machine matches one of the samples, just copy the right sample
  61. files to jconfig.h and Makefile.
  62. * If all else fails, read the instructions below and make your own files.
  63. Configuring the software using the automatic "configure" script
  64. ---------------------------------------------------------------
  65. If you are on a Unix machine, you can just type
  66. ./configure
  67. and let the configure script construct appropriate configuration files.
  68. If you're using "csh" on an old version of System V, you might need to type
  69. sh configure
  70. instead to prevent csh from trying to execute configure itself.
  71. Expect configure to run for a few minutes, particularly on slower machines;
  72. it works by compiling a series of test programs.
  73. Configure was created with GNU Autoconf and it follows the usual conventions
  74. for GNU configure scripts. It makes a few assumptions that you may want to
  75. override. You can do this by providing optional switches to configure:
  76. * If you want to build libjpeg as a shared library, say
  77. ./configure --enable-shared
  78. To get both shared and static libraries, say
  79. ./configure --enable-shared --enable-static
  80. Note that these switches invoke GNU libtool to take care of system-dependent
  81. shared library building methods. If things don't work this way, please try
  82. running configure without either switch; that should build a static library
  83. without using libtool. If that works, your problem is probably with libtool
  84. not with the IJG code. libtool is fairly new and doesn't support all flavors
  85. of Unix yet. (You might be able to find a newer version of libtool than the
  86. one included with libjpeg; see ftp.gnu.org. Report libtool problems to
  87. bug-libtool@gnu.org.)
  88. * Configure will use gcc (GNU C compiler) if it's available, otherwise cc.
  89. To force a particular compiler to be selected, use the CC option, for example
  90. ./configure CC='cc'
  91. The same method can be used to include any unusual compiler switches.
  92. For example, on HP-UX you probably want to say
  93. ./configure CC='cc -Aa'
  94. to get HP's compiler to run in ANSI mode.
  95. * The default CFLAGS setting is "-O" for non-gcc compilers, "-O2" for gcc.
  96. You can override this by saying, for example,
  97. ./configure CFLAGS='-g'
  98. if you want to compile with debugging support.
  99. * Configure will set up the makefile so that "make install" will install files
  100. into /usr/local/bin, /usr/local/man, etc. You can specify an installation
  101. prefix other than "/usr/local" by giving configure the option "--prefix=PATH".
  102. * If you don't have a lot of swap space, you may need to enable the IJG
  103. software's internal virtual memory mechanism. To do this, give the option
  104. "--enable-maxmem=N" where N is the default maxmemory limit in megabytes.
  105. This is discussed in more detail under "Selecting a memory manager", below.
  106. You probably don't need to worry about this on reasonably-sized Unix machines,
  107. unless you plan to process very large images.
  108. Configure has some other features that are useful if you are cross-compiling
  109. or working in a network of multiple machine types; but if you need those
  110. features, you probably already know how to use them.
  111. Configuring the software using one of the supplied jconfig and makefile files
  112. -----------------------------------------------------------------------------
  113. If you have one of these systems, you can just use the provided configuration
  114. files:
  115. Makefile jconfig file System and/or compiler
  116. makefile.manx jconfig.manx Amiga, Manx Aztec C
  117. makefile.sas jconfig.sas Amiga, SAS C
  118. makeproj.mac jconfig.mac Apple Macintosh, Metrowerks CodeWarrior
  119. mak*jpeg.st jconfig.st Atari ST/STE/TT, Pure C or Turbo C
  120. makefile.bcc jconfig.bcc MS-DOS or OS/2, Borland C
  121. makefile.dj jconfig.dj MS-DOS, DJGPP (Delorie's port of GNU C)
  122. makefile.mc6 jconfig.mc6 MS-DOS, Microsoft C (16-bit only)
  123. makefile.wat jconfig.wat MS-DOS, OS/2, or Windows NT, Watcom C
  124. makefile.vc jconfig.vc Windows NT/95, MS Visual C++
  125. make*.ds jconfig.vc Windows NT/95, MS Developer Studio
  126. makefile.mms jconfig.vms Digital VMS, with MMS software
  127. makefile.vms jconfig.vms Digital VMS, without MMS software
  128. Copy the proper jconfig file to jconfig.h and the makefile to Makefile (or
  129. whatever your system uses as the standard makefile name). For more info see
  130. the appropriate system-specific hints section near the end of this file.
  131. Configuring the software by hand
  132. --------------------------------
  133. First, generate a jconfig.h file. If you are moderately familiar with C,
  134. the comments in jconfig.doc should be enough information to do this; just
  135. copy jconfig.doc to jconfig.h and edit it appropriately. Otherwise, you may
  136. prefer to use the ckconfig.c program. You will need to compile and execute
  137. ckconfig.c by hand --- we hope you know at least enough to do that.
  138. ckconfig.c may not compile the first try (in fact, the whole idea is for it
  139. to fail if anything is going to). If you get compile errors, fix them by
  140. editing ckconfig.c according to the directions given in ckconfig.c. Once
  141. you get it to run, it will write a suitable jconfig.h file, and will also
  142. print out some advice about which makefile to use.
  143. You may also want to look at the canned jconfig files, if there is one for a
  144. system similar to yours.
  145. Second, select a makefile and copy it to Makefile (or whatever your system
  146. uses as the standard makefile name). The most generic makefiles we provide
  147. are
  148. makefile.ansi: if your C compiler supports function prototypes
  149. makefile.unix: if not.
  150. (You have function prototypes if ckconfig.c put "#define HAVE_PROTOTYPES"
  151. in jconfig.h.) You may want to start from one of the other makefiles if
  152. there is one for a system similar to yours.
  153. Look over the selected Makefile and adjust options as needed. In particular
  154. you may want to change the CC and CFLAGS definitions. For instance, if you
  155. are using GCC, set CC=gcc. If you had to use any compiler switches to get
  156. ckconfig.c to work, make sure the same switches are in CFLAGS.
  157. If you are on a system that doesn't use makefiles, you'll need to set up
  158. project files (or whatever you do use) to compile all the source files and
  159. link them into executable files cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom.
  160. See the file lists in any of the makefiles to find out which files go into
  161. each program. Note that the provided makefiles all make a "library" file
  162. libjpeg first, but you don't have to do that if you don't want to; the file
  163. lists identify which source files are actually needed for compression,
  164. decompression, or both. As a last resort, you can make a batch script that
  165. just compiles everything and links it all together; makefile.vms is an example
  166. of this (it's for VMS systems that have no make-like utility).
  167. Here are comments about some specific configuration decisions you'll
  168. need to make:
  169. Command line style
  170. ------------------
  171. These programs can use a Unix-like command line style which supports
  172. redirection and piping, like this:
  173. cjpeg inputfile >outputfile
  174. cjpeg <inputfile >outputfile
  175. source program | cjpeg >outputfile
  176. The simpler "two file" command line style is just
  177. cjpeg inputfile outputfile
  178. You may prefer the two-file style, particularly if you don't have pipes.
  179. You MUST use two-file style on any system that doesn't cope well with binary
  180. data fed through stdin/stdout; this is true for some MS-DOS compilers, for
  181. example. If you're not on a Unix system, it's safest to assume you need
  182. two-file style. (But if your compiler provides either the Posix-standard
  183. fdopen() library routine or a Microsoft-compatible setmode() routine, you
  184. can safely use the Unix command line style, by defining USE_FDOPEN or
  185. USE_SETMODE respectively.)
  186. To use the two-file style, make jconfig.h say "#define TWO_FILE_COMMANDLINE".
  187. Selecting a memory manager
  188. --------------------------
  189. The IJG code is capable of working on images that are too big to fit in main
  190. memory; data is swapped out to temporary files as necessary. However, the
  191. code to do this is rather system-dependent. We provide five different
  192. memory managers:
  193. * jmemansi.c This version uses the ANSI-standard library routine tmpfile(),
  194. which not all non-ANSI systems have. On some systems
  195. tmpfile() may put the temporary file in a non-optimal
  196. location; if you don't like what it does, use jmemname.c.
  197. * jmemname.c This version creates named temporary files. For anything
  198. except a Unix machine, you'll need to configure the
  199. select_file_name() routine appropriately; see the comments
  200. near the head of jmemname.c. If you use this version, define
  201. NEED_SIGNAL_CATCHER in jconfig.h to make sure the temp files
  202. are removed if the program is aborted.
  203. * jmemnobs.c (That stands for No Backing Store :-).) This will compile on
  204. almost any system, but it assumes you have enough main memory
  205. or virtual memory to hold the biggest images you work with.
  206. * jmemdos.c This should be used with most 16-bit MS-DOS compilers.
  207. See the system-specific notes about MS-DOS for more info.
  208. IMPORTANT: if you use this, define USE_MSDOS_MEMMGR in
  209. jconfig.h, and include the assembly file jmemdosa.asm in the
  210. programs. The supplied makefiles and jconfig files for
  211. 16-bit MS-DOS compilers already do both.
  212. * jmemmac.c Custom version for Apple Macintosh; see the system-specific
  213. notes for Macintosh for more info.
  214. To use a particular memory manager, change the SYSDEPMEM variable in your
  215. makefile to equal the corresponding object file name (for example, jmemansi.o
  216. or jmemansi.obj for jmemansi.c).
  217. If you have plenty of (real or virtual) main memory, just use jmemnobs.c.
  218. "Plenty" means about ten bytes for every pixel in the largest images
  219. you plan to process, so a lot of systems don't meet this criterion.
  220. If yours doesn't, try jmemansi.c first. If that doesn't compile, you'll have
  221. to use jmemname.c; be sure to adjust select_file_name() for local conditions.
  222. You may also need to change unlink() to remove() in close_backing_store().
  223. Except with jmemnobs.c or jmemmac.c, you need to adjust the DEFAULT_MAX_MEM
  224. setting to a reasonable value for your system (either by adding a #define for
  225. DEFAULT_MAX_MEM to jconfig.h, or by adding a -D switch to the Makefile).
  226. This value limits the amount of data space the program will attempt to
  227. allocate. Code and static data space isn't counted, so the actual memory
  228. needs for cjpeg or djpeg are typically 100 to 150Kb more than the max-memory
  229. setting. Larger max-memory settings reduce the amount of I/O needed to
  230. process a large image, but too large a value can result in "insufficient
  231. memory" failures. On most Unix machines (and other systems with virtual
  232. memory), just set DEFAULT_MAX_MEM to several million and forget it. At the
  233. other end of the spectrum, for MS-DOS machines you probably can't go much
  234. above 300K to 400K. (On MS-DOS the value refers to conventional memory only.
  235. Extended/expanded memory is handled separately by jmemdos.c.)
  236. BUILDING THE SOFTWARE
  237. =====================
  238. Now you should be able to compile the software. Just say "make" (or
  239. whatever's necessary to start the compilation). Have a cup of coffee.
  240. Here are some things that could go wrong:
  241. If your compiler complains about undefined structures, you should be able to
  242. shut it up by putting "#define INCOMPLETE_TYPES_BROKEN" in jconfig.h.
  243. If you have trouble with missing system include files or inclusion of the
  244. wrong ones, read jinclude.h. This shouldn't happen if you used configure
  245. or ckconfig.c to set up jconfig.h.
  246. There are a fair number of routines that do not use all of their parameters;
  247. some compilers will issue warnings about this, which you can ignore. There
  248. are also a few configuration checks that may give "unreachable code" warnings.
  249. Any other warning deserves investigation.
  250. If you don't have a getenv() library routine, define NO_GETENV.
  251. Also see the system-specific hints, below.
  252. TESTING THE SOFTWARE
  253. ====================
  254. As a quick test of functionality we've included a small sample image in
  255. several forms:
  256. testorig.jpg Starting point for the djpeg tests.
  257. testimg.ppm The output of djpeg testorig.jpg
  258. testimg.bmp The output of djpeg -bmp -colors 256 testorig.jpg
  259. testimg.jpg The output of cjpeg testimg.ppm
  260. testprog.jpg Progressive-mode equivalent of testorig.jpg.
  261. testimgp.jpg The output of cjpeg -progressive -optimize testimg.ppm
  262. (The first- and second-generation .jpg files aren't identical since JPEG is
  263. lossy.) If you can generate duplicates of the testimg* files then you
  264. probably have working programs.
  265. With most of the makefiles, "make test" will perform the necessary
  266. comparisons.
  267. If you're using a makefile that doesn't provide the test option, run djpeg
  268. and cjpeg by hand and compare the output files to testimg* with whatever
  269. binary file comparison tool you have. The files should be bit-for-bit
  270. identical.
  271. If the programs complain "MAX_ALLOC_CHUNK is wrong, please fix", then you
  272. need to reduce MAX_ALLOC_CHUNK to a value that fits in type size_t.
  273. Try adding "#define MAX_ALLOC_CHUNK 65520L" to jconfig.h. A less likely
  274. configuration error is "ALIGN_TYPE is wrong, please fix": defining ALIGN_TYPE
  275. as long should take care of that one.
  276. If the cjpeg test run fails with "Missing Huffman code table entry", it's a
  277. good bet that you needed to define RIGHT_SHIFT_IS_UNSIGNED. Go back to the
  278. configuration step and run ckconfig.c. (This is a good plan for any other
  279. test failure, too.)
  280. If you are using Unix (one-file) command line style on a non-Unix system,
  281. it's a good idea to check that binary I/O through stdin/stdout actually
  282. works. You should get the same results from "djpeg <testorig.jpg >out.ppm"
  283. as from "djpeg -outfile out.ppm testorig.jpg". Note that the makefiles all
  284. use the latter style and therefore do not exercise stdin/stdout! If this
  285. check fails, try recompiling with USE_SETMODE or USE_FDOPEN defined.
  286. If it still doesn't work, better use two-file style.
  287. If you chose a memory manager other than jmemnobs.c, you should test that
  288. temporary-file usage works. Try "djpeg -bmp -colors 256 -max 0 testorig.jpg"
  289. and make sure its output matches testimg.bmp. If you have any really large
  290. images handy, try compressing them with -optimize and/or decompressing with
  291. -colors 256 to make sure your DEFAULT_MAX_MEM setting is not too large.
  292. NOTE: this is far from an exhaustive test of the JPEG software; some modules,
  293. such as 1-pass color quantization, are not exercised at all. It's just a
  294. quick test to give you some confidence that you haven't missed something
  295. major.
  296. INSTALLING THE SOFTWARE
  297. =======================
  298. Once you're done with the above steps, you can install the software by
  299. copying the executable files (cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom)
  300. to wherever you normally install programs. On Unix systems, you'll also want
  301. to put the man pages (cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1)
  302. in the man-page directory. The pre-fab makefiles don't support this step
  303. since there's such a wide variety of installation procedures on different
  304. systems.
  305. If you generated a Makefile with the "configure" script, you can just say
  306. make install
  307. to install the programs and their man pages into the standard places.
  308. (You'll probably need to be root to do this.) We recommend first saying
  309. make -n install
  310. to see where configure thought the files should go. You may need to edit
  311. the Makefile, particularly if your system's conventions for man page
  312. filenames don't match what configure expects.
  313. If you want to install the IJG library itself, for use in compiling other
  314. programs besides ours, then you need to put the four include files
  315. jpeglib.h jerror.h jconfig.h jmorecfg.h
  316. into your include-file directory, and put the library file libjpeg.a
  317. (extension may vary depending on system) wherever library files go.
  318. If you generated a Makefile with "configure", it will do what it thinks
  319. is the right thing if you say
  320. make install-lib
  321. OPTIONAL STUFF
  322. ==============
  323. Progress monitor:
  324. If you like, you can #define PROGRESS_REPORT (in jconfig.h) to enable display
  325. of percent-done progress reports. The routine provided in cdjpeg.c merely
  326. prints percentages to stderr, but you can customize it to do something
  327. fancier.
  328. Utah RLE file format support:
  329. We distribute the software with support for RLE image files (Utah Raster
  330. Toolkit format) disabled, because the RLE support won't compile without the
  331. Utah library. If you have URT version 3.1 or later, you can enable RLE
  332. support as follows:
  333. 1. #define RLE_SUPPORTED in jconfig.h.
  334. 2. Add a -I option to CFLAGS in the Makefile for the directory
  335. containing the URT .h files (typically the "include"
  336. subdirectory of the URT distribution).
  337. 3. Add -L... -lrle to LDLIBS in the Makefile, where ... specifies
  338. the directory containing the URT "librle.a" file (typically the
  339. "lib" subdirectory of the URT distribution).
  340. Support for 12-bit-deep pixel data:
  341. The JPEG standard allows either 8-bit or 12-bit data precision. (For color,
  342. this means 8 or 12 bits per channel, of course.) If you need to work with
  343. deeper than 8-bit data, you can compile the IJG code for 12-bit operation.
  344. To do so:
  345. 1. In jmorecfg.h, define BITS_IN_JSAMPLE as 12 rather than 8.
  346. 2. In jconfig.h, undefine BMP_SUPPORTED, RLE_SUPPORTED, and TARGA_SUPPORTED,
  347. because the code for those formats doesn't handle 12-bit data and won't
  348. even compile. (The PPM code does work, as explained below. The GIF
  349. code works too; it scales 8-bit GIF data to and from 12-bit depth
  350. automatically.)
  351. 3. Compile. Don't expect "make test" to pass, since the supplied test
  352. files are for 8-bit data.
  353. Currently, 12-bit support does not work on 16-bit-int machines.
  354. Note that a 12-bit version will not read 8-bit JPEG files, nor vice versa;
  355. so you'll want to keep around a regular 8-bit compilation as well.
  356. (Run-time selection of data depth, to allow a single copy that does both,
  357. is possible but would probably slow things down considerably; it's very low
  358. on our to-do list.)
  359. The PPM reader (rdppm.c) can read 12-bit data from either text-format or
  360. binary-format PPM and PGM files. Binary-format PPM/PGM files which have a
  361. maxval greater than 255 are assumed to use 2 bytes per sample, LSB first
  362. (little-endian order). As of early 1995, 2-byte binary format is not
  363. officially supported by the PBMPLUS library, but it is expected that a
  364. future release of PBMPLUS will support it. Note that the PPM reader will
  365. read files of any maxval regardless of the BITS_IN_JSAMPLE setting; incoming
  366. data is automatically rescaled to either maxval=255 or maxval=4095 as
  367. appropriate for the cjpeg bit depth.
  368. The PPM writer (wrppm.c) will normally write 2-byte binary PPM or PGM
  369. format, maxval 4095, when compiled with BITS_IN_JSAMPLE=12. Since this
  370. format is not yet widely supported, you can disable it by compiling wrppm.c
  371. with PPM_NORAWWORD defined; then the data is scaled down to 8 bits to make a
  372. standard 1-byte/sample PPM or PGM file. (Yes, this means still another copy
  373. of djpeg to keep around. But hopefully you won't need it for very long.
  374. Poskanzer's supposed to get that new PBMPLUS release out Real Soon Now.)
  375. Of course, if you are working with 12-bit data, you probably have it stored
  376. in some other, nonstandard format. In that case you'll probably want to
  377. write your own I/O modules to read and write your format.
  378. Note that a 12-bit version of cjpeg always runs in "-optimize" mode, in
  379. order to generate valid Huffman tables. This is necessary because our
  380. default Huffman tables only cover 8-bit data.
  381. Removing code:
  382. If you need to make a smaller version of the JPEG software, some optional
  383. functions can be removed at compile time. See the xxx_SUPPORTED #defines in
  384. jconfig.h and jmorecfg.h. If at all possible, we recommend that you leave in
  385. decoder support for all valid JPEG files, to ensure that you can read anyone's
  386. output. Taking out support for image file formats that you don't use is the
  387. most painless way to make the programs smaller. Another possibility is to
  388. remove some of the DCT methods: in particular, the "IFAST" method may not be
  389. enough faster than the others to be worth keeping on your machine. (If you
  390. do remove ISLOW or IFAST, be sure to redefine JDCT_DEFAULT or JDCT_FASTEST
  391. to a supported method, by adding a #define in jconfig.h.)
  392. OPTIMIZATION
  393. ============
  394. Unless you own a Cray, you'll probably be interested in making the JPEG
  395. software go as fast as possible. This section covers some machine-dependent
  396. optimizations you may want to try. We suggest that before trying any of
  397. this, you first get the basic installation to pass the self-test step.
  398. Repeat the self-test after any optimization to make sure that you haven't
  399. broken anything.
  400. The integer DCT routines perform a lot of multiplications. These
  401. multiplications must yield 32-bit results, but none of their input values
  402. are more than 16 bits wide. On many machines, notably the 680x0 and 80x86
  403. CPUs, a 16x16=>32 bit multiply instruction is faster than a full 32x32=>32
  404. bit multiply. Unfortunately there is no portable way to specify such a
  405. multiplication in C, but some compilers can generate one when you use the
  406. right combination of casts. See the MULTIPLYxxx macro definitions in
  407. jdct.h. If your compiler makes "int" be 32 bits and "short" be 16 bits,
  408. defining SHORTxSHORT_32 is fairly likely to work. When experimenting with
  409. alternate definitions, be sure to test not only whether the code still works
  410. (use the self-test), but also whether it is actually faster --- on some
  411. compilers, alternate definitions may compute the right answer, yet be slower
  412. than the default. Timing cjpeg on a large PGM (grayscale) input file is the
  413. best way to check this, as the DCT will be the largest fraction of the runtime
  414. in that mode. (Note: some of the distributed compiler-specific jconfig files
  415. already contain #define switches to select appropriate MULTIPLYxxx
  416. definitions.)
  417. If your machine has sufficiently fast floating point hardware, you may find
  418. that the float DCT method is faster than the integer DCT methods, even
  419. after tweaking the integer multiply macros. In that case you may want to
  420. make the float DCT be the default method. (The only objection to this is
  421. that float DCT results may vary slightly across machines.) To do that, add
  422. "#define JDCT_DEFAULT JDCT_FLOAT" to jconfig.h. Even if you don't change
  423. the default, you should redefine JDCT_FASTEST, which is the method selected
  424. by djpeg's -fast switch. Don't forget to update the documentation files
  425. (usage.doc and/or cjpeg.1, djpeg.1) to agree with what you've done.
  426. If access to "short" arrays is slow on your machine, it may be a win to
  427. define type JCOEF as int rather than short. This will cost a good deal of
  428. memory though, particularly in some multi-pass modes, so don't do it unless
  429. you have memory to burn and short is REALLY slow.
  430. If your compiler can compile function calls in-line, make sure the INLINE
  431. macro in jmorecfg.h is defined as the keyword that marks a function
  432. inline-able. Some compilers have a switch that tells the compiler to inline
  433. any function it thinks is profitable (e.g., -finline-functions for gcc).
  434. Enabling such a switch is likely to make the compiled code bigger but faster.
  435. In general, it's worth trying the maximum optimization level of your compiler,
  436. and experimenting with any optional optimizations such as loop unrolling.
  437. (Unfortunately, far too many compilers have optimizer bugs ... be prepared to
  438. back off if the code fails self-test.) If you do any experimentation along
  439. these lines, please report the optimal settings to jpeg-info@uunet.uu.net so
  440. we can mention them in future releases. Be sure to specify your machine and
  441. compiler version.
  442. HINTS FOR SPECIFIC SYSTEMS
  443. ==========================
  444. We welcome reports on changes needed for systems not mentioned here. Submit
  445. 'em to jpeg-info@uunet.uu.net. Also, if configure or ckconfig.c is wrong
  446. about how to configure the JPEG software for your system, please let us know.
  447. Acorn RISC OS:
  448. (Thanks to Simon Middleton for these hints on compiling with Desktop C.)
  449. After renaming the files according to Acorn conventions, take a copy of
  450. makefile.ansi, change all occurrences of 'libjpeg.a' to 'libjpeg.o' and
  451. change these definitions as indicated:
  452. CFLAGS= -throwback -IC: -Wn
  453. LDLIBS=C:o.Stubs
  454. SYSDEPMEM=jmemansi.o
  455. LN=Link
  456. AR=LibFile -c -o
  457. Also add a new line '.c.o:; $(cc) $< $(cflags) -c -o $@'. Remove the
  458. lines '$(RM) libjpeg.o' and '$(AR2) libjpeg.o' and the 'jconfig.h'
  459. dependency section.
  460. Copy jconfig.doc to jconfig.h. Edit jconfig.h to define TWO_FILE_COMMANDLINE
  461. and CHAR_IS_UNSIGNED.
  462. Run the makefile using !AMU not !Make. If you want to use the 'clean' and
  463. 'test' makefile entries then you will have to fiddle with the syntax a bit
  464. and rename the test files.
  465. Amiga:
  466. SAS C 6.50 reportedly is too buggy to compile the IJG code properly.
  467. A patch to update to 6.51 is available from SAS or AmiNet FTP sites.
  468. The supplied config files are set up to use jmemname.c as the memory
  469. manager, with temporary files being created on the device named by
  470. "JPEGTMP:".
  471. Atari ST/STE/TT:
  472. Copy the project files makcjpeg.st, makdjpeg.st, maktjpeg.st, and makljpeg.st
  473. to cjpeg.prj, djpeg.prj, jpegtran.prj, and libjpeg.prj respectively. The
  474. project files should work as-is with Pure C. For Turbo C, change library
  475. filenames "pc..." to "tc..." in each project file. Note that libjpeg.prj
  476. selects jmemansi.c as the recommended memory manager. You'll probably want to
  477. adjust the DEFAULT_MAX_MEM setting --- you want it to be a couple hundred K
  478. less than your normal free memory. Put "#define DEFAULT_MAX_MEM nnnn" into
  479. jconfig.h to do this.
  480. To use the 68881/68882 coprocessor for the floating point DCT, add the
  481. compiler option "-8" to the project files and replace pcfltlib.lib with
  482. pc881lib.lib in cjpeg.prj and djpeg.prj. Or if you don't have a
  483. coprocessor, you may prefer to remove the float DCT code by undefining
  484. DCT_FLOAT_SUPPORTED in jmorecfg.h (since without a coprocessor, the float
  485. code will be too slow to be useful). In that case, you can delete
  486. pcfltlib.lib from the project files.
  487. Note that you must make libjpeg.lib before making cjpeg.ttp, djpeg.ttp,
  488. or jpegtran.ttp. You'll have to perform the self-test by hand.
  489. We haven't bothered to include project files for rdjpgcom and wrjpgcom.
  490. Those source files should just be compiled by themselves; they don't
  491. depend on the JPEG library.
  492. There is a bug in some older versions of the Turbo C library which causes the
  493. space used by temporary files created with "tmpfile()" not to be freed after
  494. an abnormal program exit. If you check your disk afterwards, you will find
  495. cluster chains that are allocated but not used by a file. This should not
  496. happen in cjpeg/djpeg/jpegtran, since we enable a signal catcher to explicitly
  497. close temp files before exiting. But if you use the JPEG library with your
  498. own code, be sure to supply a signal catcher, or else use a different
  499. system-dependent memory manager.
  500. Cray:
  501. Should you be so fortunate as to be running JPEG on a Cray YMP, there is a
  502. compiler bug in old versions of Cray's Standard C (prior to 3.1). If you
  503. still have an old compiler, you'll need to insert a line reading
  504. "#pragma novector" just before the loop
  505. for (i = 1; i <= (int) htbl->bits[l]; i++)
  506. huffsize[p++] = (char) l;
  507. in fix_huff_tbl (in V5beta1, line 204 of jchuff.c and line 176 of jdhuff.c).
  508. [This bug may or may not still occur with the current IJG code, but it's
  509. probably a dead issue anyway...]
  510. HP-UX:
  511. If you have HP-UX 7.05 or later with the "software development" C compiler,
  512. you should run the compiler in ANSI mode. If using the configure script,
  513. say
  514. ./configure CC='cc -Aa'
  515. (or -Ae if you prefer). If configuring by hand, use makefile.ansi and add
  516. "-Aa" to the CFLAGS line in the makefile.
  517. If you have a pre-7.05 system, or if you are using the non-ANSI C compiler
  518. delivered with a minimum HP-UX system, then you must use makefile.unix
  519. (and do NOT add -Aa); or just run configure without the CC option.
  520. On HP 9000 series 800 machines, the HP C compiler is buggy in revisions prior
  521. to A.08.07. If you get complaints about "not a typedef name", you'll have to
  522. use makefile.unix, or run configure without the CC option.
  523. Macintosh, generic comments:
  524. The supplied user-interface files (cjpeg.c, djpeg.c, etc) are set up to
  525. provide a Unix-style command line interface. You can use this interface on
  526. the Mac by means of the ccommand() library routine provided by Metrowerks
  527. CodeWarrior or Think C. This is only appropriate for testing the library,
  528. however; to make a user-friendly equivalent of cjpeg/djpeg you'd really want
  529. to develop a Mac-style user interface. There isn't a complete example
  530. available at the moment, but there are some helpful starting points:
  531. 1. Sam Bushell's free "To JPEG" applet provides drag-and-drop conversion to
  532. JPEG under System 7 and later. This only illustrates how to use the
  533. compression half of the library, but it does a very nice job of that part.
  534. The CodeWarrior source code is available from http://www.pobox.com/~jsam.
  535. 2. Jim Brunner prepared a Mac-style user interface for both compression and
  536. decompression. Unfortunately, it hasn't been updated since IJG v4, and
  537. the library's API has changed considerably since then. Still it may be of
  538. some help, particularly as a guide to compiling the IJG code under Think C.
  539. Jim's code is available from the Info-Mac archives, at sumex-aim.stanford.edu
  540. or mirrors thereof; see file /info-mac/dev/src/jpeg-convert-c.hqx.
  541. jmemmac.c is the recommended memory manager back end for Macintosh. It uses
  542. NewPtr/DisposePtr instead of malloc/free, and has a Mac-specific
  543. implementation of jpeg_mem_available(). It also creates temporary files that
  544. follow Mac conventions. (That part of the code relies on System-7-or-later OS
  545. functions. See the comments in jmemmac.c if you need to run it on System 6.)
  546. NOTE that USE_MAC_MEMMGR must be defined in jconfig.h to use jmemmac.c.
  547. You can also use jmemnobs.c, if you don't care about handling images larger
  548. than available memory. If you use any memory manager back end other than
  549. jmemmac.c, we recommend replacing "malloc" and "free" by "NewPtr" and
  550. "DisposePtr", because Mac C libraries often have peculiar implementations of
  551. malloc/free. (For instance, free() may not return the freed space to the
  552. Mac Memory Manager. This is undesirable for the IJG code because jmemmgr.c
  553. already clumps space requests.)
  554. Macintosh, Metrowerks CodeWarrior:
  555. The Unix-command-line-style interface can be used by defining USE_CCOMMAND.
  556. You'll also need to define TWO_FILE_COMMANDLINE to avoid stdin/stdout.
  557. This means that when using the cjpeg/djpeg programs, you'll have to type the
  558. input and output file names in the "Arguments" text-edit box, rather than
  559. using the file radio buttons. (Perhaps USE_FDOPEN or USE_SETMODE would
  560. eliminate the problem, but I haven't heard from anyone who's tried it.)
  561. On 680x0 Macs, Metrowerks defines type "double" as a 10-byte IEEE extended
  562. float. jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power
  563. of 2. Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint.
  564. The supplied configuration file jconfig.mac can be used for your jconfig.h;
  565. it includes all the recommended symbol definitions. If you have AppleScript
  566. installed, you can run the supplied script makeproj.mac to create CodeWarrior
  567. project files for the library and the testbed applications, then build the
  568. library and applications. (Thanks to Dan Sears and Don Agro for this nifty
  569. hack, which saves us from trying to maintain CodeWarrior project files as part
  570. of the IJG distribution...)
  571. Macintosh, Think C:
  572. The documentation in Jim Brunner's "JPEG Convert" source code (see above)
  573. includes detailed build instructions for Think C; it's probably somewhat
  574. out of date for the current release, but may be helpful.
  575. If you want to build the minimal command line version, proceed as follows.
  576. You'll have to prepare project files for the programs; we don't include any
  577. in the distribution since they are not text files. Use the file lists in
  578. any of the supplied makefiles as a guide. Also add the ANSI and Unix C
  579. libraries in a separate segment. You may need to divide the JPEG files into
  580. more than one segment; we recommend dividing compression and decompression
  581. modules. Define USE_CCOMMAND in jconfig.h so that the ccommand() routine is
  582. called. You must also define TWO_FILE_COMMANDLINE because stdin/stdout
  583. don't handle binary data correctly.
  584. On 680x0 Macs, Think C defines type "double" as a 12-byte IEEE extended float.
  585. jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power of 2.
  586. Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint.
  587. jconfig.mac should work as a jconfig.h configuration file for Think C,
  588. but the makeproj.mac AppleScript script is specific to CodeWarrior. Sorry.
  589. MIPS R3000:
  590. MIPS's cc version 1.31 has a rather nasty optimization bug. Don't use -O
  591. if you have that compiler version. (Use "cc -V" to check the version.)
  592. Note that the R3000 chip is found in workstations from DEC and others.
  593. MS-DOS, generic comments for 16-bit compilers:
  594. The IJG code is designed to work well in 80x86 "small" or "medium" memory
  595. models (i.e., data pointers are 16 bits unless explicitly declared "far";
  596. code pointers can be either size). You may be able to use small model to
  597. compile cjpeg or djpeg by itself, but you will probably have to use medium
  598. model for any larger application. This won't make much difference in
  599. performance. You *will* take a noticeable performance hit if you use a
  600. large-data memory model, and you should avoid "huge" model if at all
  601. possible. Be sure that NEED_FAR_POINTERS is defined in jconfig.h if you use
  602. a small-data memory model; be sure it is NOT defined if you use a large-data
  603. model. (The supplied makefiles and jconfig files for Borland and Microsoft C
  604. compile in medium model and define NEED_FAR_POINTERS.)
  605. The DOS-specific memory manager, jmemdos.c, should be used if possible.
  606. It needs some assembly-code routines which are in jmemdosa.asm; make sure
  607. your makefile assembles that file and includes it in the library. If you
  608. don't have a suitable assembler, you can get pre-assembled object files for
  609. jmemdosa by FTP from ftp.uu.net:/graphics/jpeg/jdosaobj.zip. (DOS-oriented
  610. distributions of the IJG source code often include these object files.)
  611. When using jmemdos.c, jconfig.h must define USE_MSDOS_MEMMGR and must set
  612. MAX_ALLOC_CHUNK to less than 64K (65520L is a typical value). If your
  613. C library's far-heap malloc() can't allocate blocks that large, reduce
  614. MAX_ALLOC_CHUNK to whatever it can handle.
  615. If you can't use jmemdos.c for some reason --- for example, because you
  616. don't have an assembler to assemble jmemdosa.asm --- you'll have to fall
  617. back to jmemansi.c or jmemname.c. You'll probably still need to set
  618. MAX_ALLOC_CHUNK in jconfig.h, because most DOS C libraries won't malloc()
  619. more than 64K at a time. IMPORTANT: if you use jmemansi.c or jmemname.c,
  620. you will have to compile in a large-data memory model in order to get the
  621. right stdio library. Too bad.
  622. wrjpgcom needs to be compiled in large model, because it malloc()s a 64KB
  623. work area to hold the comment text. If your C library's malloc can't
  624. handle that, reduce MAX_COM_LENGTH as necessary in wrjpgcom.c.
  625. Most MS-DOS compilers treat stdin/stdout as text files, so you must use
  626. two-file command line style. But if your compiler has either fdopen() or
  627. setmode(), you can use one-file style if you like. To do this, define
  628. USE_SETMODE or USE_FDOPEN so that stdin/stdout will be set to binary mode.
  629. (USE_SETMODE seems to work with more DOS compilers than USE_FDOPEN.) You
  630. should test that I/O through stdin/stdout produces the same results as I/O
  631. to explicitly named files... the "make test" procedures in the supplied
  632. makefiles do NOT use stdin/stdout.
  633. MS-DOS, generic comments for 32-bit compilers:
  634. None of the above comments about memory models apply if you are using a
  635. 32-bit flat-memory-space environment, such as DJGPP or Watcom C. (And you
  636. should use one if you have it, as performance will be much better than
  637. 8086-compatible code!) For flat-memory-space compilers, do NOT define
  638. NEED_FAR_POINTERS, and do NOT use jmemdos.c. Use jmemnobs.c if the
  639. environment supplies adequate virtual memory, otherwise use jmemansi.c or
  640. jmemname.c.
  641. You'll still need to be careful about binary I/O through stdin/stdout.
  642. See the last paragraph of the previous section.
  643. MS-DOS, Borland C:
  644. Be sure to convert all the source files to DOS text format (CR/LF newlines).
  645. Although Borland C will often work OK with unmodified Unix (LF newlines)
  646. source files, sometimes it will give bogus compile errors.
  647. "Illegal character '#'" is the most common such error. (This is true with
  648. Borland C 3.1, but perhaps is fixed in newer releases.)
  649. If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE.
  650. jconfig.bcc already includes #define USE_SETMODE to make this work.
  651. (fdopen does not work correctly.)
  652. MS-DOS, Microsoft C:
  653. makefile.mc6 works with Microsoft C, DOS Visual C++, etc. It should only
  654. be used if you want to build a 16-bit (small or medium memory model) program.
  655. If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE.
  656. jconfig.mc6 already includes #define USE_SETMODE to make this work.
  657. (fdopen does not work correctly.)
  658. Note that this makefile assumes that the working copy of itself is called
  659. "makefile". If you want to call it something else, say "makefile.mak",
  660. be sure to adjust the dependency line that reads "$(RFILE) : makefile".
  661. Otherwise the make will fail because it doesn't know how to create "makefile".
  662. Worse, some releases of Microsoft's make utilities give an incorrect error
  663. message in this situation.
  664. Old versions of MS C fail with an "out of macro expansion space" error
  665. because they can't cope with the macro TRACEMS8 (defined in jerror.h).
  666. If this happens to you, the easiest solution is to change TRACEMS8 to
  667. expand to nothing. You'll lose the ability to dump out JPEG coefficient
  668. tables with djpeg -debug -debug, but at least you can compile.
  669. Original MS C 6.0 is very buggy; it compiles incorrect code unless you turn
  670. off optimization entirely (remove -O from CFLAGS). 6.00A is better, but it
  671. still generates bad code if you enable loop optimizations (-Ol or -Ox).
  672. MS C 8.0 crashes when compiling jquant1.c with optimization switch /Oo ...
  673. which is on by default. To work around this bug, compile that one file
  674. with /Oo-.
  675. Microsoft Windows (all versions), generic comments:
  676. Some Windows system include files define typedef boolean as "unsigned char".
  677. The IJG code also defines typedef boolean, but we make it "int" by default.
  678. This doesn't affect the IJG programs because we don't import those Windows
  679. include files. But if you use the JPEG library in your own program, and some
  680. of your program's files import one definition of boolean while some import the
  681. other, you can get all sorts of mysterious problems. A good preventive step
  682. is to make the IJG library use "unsigned char" for boolean. To do that,
  683. add something like this to your jconfig.h file:
  684. /* Define "boolean" as unsigned char, not int, per Windows custom */
  685. #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
  686. typedef unsigned char boolean;
  687. #endif
  688. #define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
  689. (This is already in jconfig.vc, by the way.)
  690. windef.h contains the declarations
  691. #define far
  692. #define FAR far
  693. Since jmorecfg.h tries to define FAR as empty, you may get a compiler
  694. warning if you include both jpeglib.h and windef.h (which windows.h
  695. includes). To suppress the warning, you can put "#ifndef FAR"/"#endif"
  696. around the line "#define FAR" in jmorecfg.h.
  697. When using the library in a Windows application, you will almost certainly
  698. want to modify or replace the error handler module jerror.c, since our
  699. default error handler does a couple of inappropriate things:
  700. 1. it tries to write error and warning messages on stderr;
  701. 2. in event of a fatal error, it exits by calling exit().
  702. A simple stopgap solution for problem 1 is to replace the line
  703. fprintf(stderr, "%s\n", buffer);
  704. (in output_message in jerror.c) with
  705. MessageBox(GetActiveWindow(),buffer,"JPEG Error",MB_OK|MB_ICONERROR);
  706. It's highly recommended that you at least do that much, since otherwise
  707. error messages will disappear into nowhere. (Beginning with IJG v6b, this
  708. code is already present in jerror.c; just define USE_WINDOWS_MESSAGEBOX in
  709. jconfig.h to enable it.)
  710. The proper solution for problem 2 is to return control to your calling
  711. application after a library error. This can be done with the setjmp/longjmp
  712. technique discussed in libjpeg.doc and illustrated in example.c. (NOTE:
  713. some older Windows C compilers provide versions of setjmp/longjmp that
  714. don't actually work under Windows. You may need to use the Windows system
  715. functions Catch and Throw instead.)
  716. The recommended memory manager under Windows is jmemnobs.c; in other words,
  717. let Windows do any virtual memory management needed. You should NOT use
  718. jmemdos.c nor jmemdosa.asm under Windows.
  719. For Windows 3.1, we recommend compiling in medium or large memory model;
  720. for newer Windows versions, use a 32-bit flat memory model. (See the MS-DOS
  721. sections above for more info about memory models.) In the 16-bit memory
  722. models only, you'll need to put
  723. #define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */
  724. into jconfig.h to limit allocation chunks to 64Kb. (Without that, you'd
  725. have to use huge memory model, which slows things down unnecessarily.)
  726. jmemnobs.c works without modification in large or flat memory models, but to
  727. use medium model, you need to modify its jpeg_get_large and jpeg_free_large
  728. routines to allocate far memory. In any case, you might like to replace
  729. its calls to malloc and free with direct calls on Windows memory allocation
  730. functions.
  731. You may also want to modify jdatasrc.c and jdatadst.c to use Windows file
  732. operations rather than fread/fwrite. This is only necessary if your C
  733. compiler doesn't provide a competent implementation of C stdio functions.
  734. You might want to tweak the RGB_xxx macros in jmorecfg.h so that the library
  735. will accept or deliver color pixels in BGR sample order, not RGB; BGR order
  736. is usually more convenient under Windows. Note that this change will break
  737. the sample applications cjpeg/djpeg, but the library itself works fine.
  738. Many people want to convert the IJG library into a DLL. This is reasonably
  739. straightforward, but watch out for the following:
  740. 1. Don't try to compile as a DLL in small or medium memory model; use
  741. large model, or even better, 32-bit flat model. Many places in the IJG code
  742. assume the address of a local variable is an ordinary (not FAR) pointer;
  743. that isn't true in a medium-model DLL.
  744. 2. Microsoft C cannot pass file pointers between applications and DLLs.
  745. (See Microsoft Knowledge Base, PSS ID Number Q50336.) So jdatasrc.c and
  746. jdatadst.c don't work if you open a file in your application and then pass
  747. the pointer to the DLL. One workaround is to make jdatasrc.c/jdatadst.c
  748. part of your main application rather than part of the DLL.
  749. 3. You'll probably need to modify the macros GLOBAL() and EXTERN() to
  750. attach suitable linkage keywords to the exported routine names. Similarly,
  751. you'll want to modify METHODDEF() and JMETHOD() to ensure function pointers
  752. are declared in a way that lets application routines be called back through
  753. the function pointers. These macros are in jmorecfg.h. Typical definitions
  754. for a 16-bit DLL are:
  755. #define GLOBAL(type) type _far _pascal _loadds _export
  756. #define EXTERN(type) extern type _far _pascal _loadds
  757. #define METHODDEF(type) static type _far _pascal
  758. #define JMETHOD(type,methodname,arglist) \
  759. type (_far _pascal *methodname) arglist
  760. For a 32-bit DLL you may want something like
  761. #define GLOBAL(type) __declspec(dllexport) type
  762. #define EXTERN(type) extern __declspec(dllexport) type
  763. Although not all the GLOBAL routines are actually intended to be called by
  764. the application, the performance cost of making them all DLL entry points is
  765. negligible.
  766. The unmodified IJG library presents a very C-specific application interface,
  767. so the resulting DLL is only usable from C or C++ applications. There has
  768. been some talk of writing wrapper code that would present a simpler interface
  769. usable from other languages, such as Visual Basic. This is on our to-do list
  770. but hasn't been very high priority --- any volunteers out there?
  771. Microsoft Windows, Borland C:
  772. The provided jconfig.bcc should work OK in a 32-bit Windows environment,
  773. but you'll need to tweak it in a 16-bit environment (you'd need to define
  774. NEED_FAR_POINTERS and MAX_ALLOC_CHUNK). Beware that makefile.bcc will need
  775. alteration if you want to use it for Windows --- in particular, you should
  776. use jmemnobs.c not jmemdos.c under Windows.
  777. Borland C++ 4.5 fails with an internal compiler error when trying to compile
  778. jdmerge.c in 32-bit mode. If enough people complain, perhaps Borland will fix
  779. it. In the meantime, the simplest known workaround is to add a redundant
  780. definition of the variable range_limit in h2v1_merged_upsample(), at the head
  781. of the block that handles odd image width (about line 268 in v6 jdmerge.c):
  782. /* If image width is odd, do the last output column separately */
  783. if (cinfo->output_width & 1) {
  784. register JSAMPLE * range_limit = cinfo->sample_range_limit; /* ADD THIS */
  785. cb = GETJSAMPLE(*inptr1);
  786. Pretty bizarre, especially since the very similar routine h2v2_merged_upsample
  787. doesn't trigger the bug.
  788. Recent reports suggest that this bug does not occur with "bcc32a" (the
  789. Pentium-optimized version of the compiler).
  790. Another report from a user of Borland C 4.5 was that incorrect code (leading
  791. to a color shift in processed images) was produced if any of the following
  792. optimization switch combinations were used:
  793. -Ot -Og
  794. -Ot -Op
  795. -Ot -Om
  796. So try backing off on optimization if you see such a problem. (Are there
  797. several different releases all numbered "4.5"??)
  798. Microsoft Windows, Microsoft Visual C++:
  799. jconfig.vc should work OK with any Microsoft compiler for a 32-bit memory
  800. model. makefile.vc is intended for command-line use. (If you are using
  801. the Developer Studio environment, you may prefer the DevStudio project
  802. files; see below.)
  803. Some users feel that it's easier to call the library from C++ code if you
  804. force VC++ to treat the library as C++ code, which you can do by renaming
  805. all the *.c files to *.cpp (and adjusting the makefile to match). This
  806. avoids the need to put extern "C" { ... } around #include "jpeglib.h" in
  807. your C++ application.
  808. Microsoft Windows, Microsoft Developer Studio:
  809. We include makefiles that should work as project files in DevStudio 4.2 or
  810. later. There is a library makefile that builds the IJG library as a static
  811. Win32 library, and an application makefile that builds the sample applications
  812. as Win32 console applications. (Even if you only want the library, we
  813. recommend building the applications so that you can run the self-test.)
  814. To use:
  815. 1. Copy jconfig.vc to jconfig.h, makelib.ds to jpeg.mak, and
  816. makeapps.ds to apps.mak. (Note that the renaming is critical!)
  817. 2. Click on the .mak files to construct project workspaces.
  818. (If you are using DevStudio more recent than 4.2, you'll probably
  819. get a message saying that the makefiles are being updated.)
  820. 3. Build the library project, then the applications project.
  821. 4. Move the application .exe files from `app`\Release to an
  822. appropriate location on your path.
  823. 5. To perform the self-test, execute the command line
  824. NMAKE /f makefile.vc test
  825. OS/2, Borland C++:
  826. Watch out for optimization bugs in older Borland compilers; you may need
  827. to back off the optimization switch settings. See the comments in
  828. makefile.bcc.
  829. SGI:
  830. On some SGI systems, you may need to set "AR2= ar -ts" in the Makefile.
  831. If you are using configure, you can do this by saying
  832. ./configure RANLIB='ar -ts'
  833. This change is not needed on all SGIs. Use it only if the make fails at the
  834. stage of linking the completed programs.
  835. On the MIPS R4000 architecture (Indy, etc.), the compiler option "-mips2"
  836. reportedly speeds up the float DCT method substantially, enough to make it
  837. faster than the default int method (but still slower than the fast int
  838. method). If you use -mips2, you may want to alter the default DCT method to
  839. be float. To do this, put "#define JDCT_DEFAULT JDCT_FLOAT" in jconfig.h.
  840. VMS:
  841. On an Alpha/VMS system with MMS, be sure to use the "/Marco=Alpha=1"
  842. qualifier with MMS when building the JPEG package.
  843. VAX/VMS v5.5-1 may have problems with the test step of the build procedure
  844. reporting differences when it compares the original and test images. If the
  845. error points to the last block of the files, it is most likely bogus and may
  846. be safely ignored. It seems to be because the files are Stream_LF and
  847. Backup/Compare has difficulty with the (presumably) null padded files.
  848. This problem was not observed on VAX/VMS v6.1 or AXP/VMS v6.1.