install.txt 53 KB

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