📄 install.doc
字号:
If you have a pre-7.05 system, or if you are using the non-ANSI C compilerdelivered with a minimum HP-UX system, then you must use makefile.unix(and do NOT add -Aa); or just run configure without the CC option.On HP 9000 series 800 machines, the HP C compiler is buggy in revisions priorto A.08.07. If you get complaints about "not a typedef name", you'll have touse makefile.unix, or run configure without the CC option.Macintosh, generic comments:The supplied user-interface files (cjpeg.c, djpeg.c, etc) are set up toprovide a Unix-style command line interface. You can use this interface onthe Mac by means of the ccommand() library routine provided by MetrowerksCodeWarrior or Think C. This is only appropriate for testing the library,however; to make a user-friendly equivalent of cjpeg/djpeg you'd really wantto develop a Mac-style user interface. Such an interface exists for pre-v5IJG libraries (see the Think C entry, below) but at this writing it has notbeen updated to work with the current release.We recommend replacing "malloc" and "free" by "NewPtr" and "DisposePtr" inwhichever memory manager back end you use, because Mac C libraries oftenhave inferior implementations of malloc/free. jmemmac.c is recommended;it is a customized version of jmemansi.c with this change and a Mac-specificimplementation of jpeg_mem_available(). You can also use jmemnobs.c if youdon't care about handling images larger than available memory.Macintosh, MPW:We don't directly support MPW in the current release, but Larry Rosensteinported an earlier version of the IJG code without very much trouble. There'suseful notes and conversion scripts in his kit for porting PBMPLUS to MPW.You can obtain the kit by FTP to ftp.apple.com, files /pub/lsr/pbmplus-port*.Macintosh, Metrowerks CodeWarrior:Metrowerks release DR2 has problems with the IJG code; don't use it. ReleaseDR3.5 or later should be OK.The Unix-command-line-style interface can be used by defining USE_CCOMMAND.You'll also need to define either TWO_FILE_COMMANDLINE (to avoid stdin/stdout)or USE_FDOPEN (to make stdin/stdout work in binary mode). See the Think Centry for more details.On 680x0 Macs, Metrowerks defines type "double" as a 10-byte IEEE extendedfloat. jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a powerof 2. Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint.Macintosh, Think C:Jim Brunner has prepared a Mac-style user interface for the IJG library.Unfortunately, the released version of it only works with pre-v5 libraries;still, it may be a useful starting point. You can obtain Jim's additionalsource code from the Info-Mac archives, at sumex-aim.stanford.edu or mirrorsthereof; see file /info-mac/dev/src/jpeg-convert-c.hqx. Jim's documentationalso includes more detailed build instructions for Think C.If you want to build the minimal command line version, proceed as follows.You'll have to prepare project files for the programs; we don't include anyin the distribution since they are not text files. Use the file lists inany of the supplied makefiles as a guide. Also add the ANSI and Unix Clibraries in a separate segment. You may need to divide the JPEG files intomore than one segment; we recommend dividing compression and decompressionmodules. Define USE_CCOMMAND in jconfig.h so that the ccommand() routine iscalled. You must also define TWO_FILE_COMMANDLINE because stdin/stdoutdon't handle binary data correctly.On 680x0 Macs, Think C defines type "double" as a 12-byte IEEE extended float.jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power of 2.Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint.MIPS R3000:MIPS's cc version 1.31 has a rather nasty optimization bug. Don't use -Oif you have that compiler version. (Use "cc -V" to check the version.)Note that the R3000 chip is found in workstations from DEC and others.MS-DOS, generic comments for 16-bit compilers:The IJG code is designed to be compiled in 80x86 "small" or "medium" memorymodels (i.e., data pointers are 16 bits unless explicitly declared "far";code pointers can be either size). You may be able to use small model tocompile cjpeg or djpeg by itself, but you will probably have to use mediummodel for any larger application. This won't make much difference inperformance. You *will* take a noticeable performance hit if you use alarge-data memory model, and you should avoid "huge" model if at allpossible. Be sure that NEED_FAR_POINTERS is defined in jconfig.h if you usea small-data memory model; be sure it is NOT defined if you use a large-datamodel. (The supplied makefiles and jconfig files for Borland and Microsoft Ccompile in medium model and define NEED_FAR_POINTERS.)The DOS-specific memory manager, jmemdos.c, should be used if possible.It needs some assembly-code routines which are in jmemdosa.asm; make sureyour makefile assembles that file and includes it in the library. If youdon't have a suitable assembler, you can get pre-assembled object files forjmemdosa by FTP from ftp.uu.net: graphics/jpeg/jdosaobj.zip. (DOS-orienteddistributions of the IJG source code often include these object files.)When using jmemdos.c, jconfig.h must define USE_MSDOS_MEMMGR and must setMAX_ALLOC_CHUNK to less than 64K (65520L is a typical value). If yourC library's far-heap malloc() can't allocate blocks that large, reduceMAX_ALLOC_CHUNK to whatever it can handle.If you can't use jmemdos.c for some reason --- for example, because youdon't have an assembler to assemble jmemdosa.asm --- you'll have to fallback to jmemansi.c or jmemname.c. You'll probably still need to setMAX_ALLOC_CHUNK in jconfig.h, because most DOS C libraries won't malloc()more than 64K at a time. IMPORTANT: if you use jmemansi.c or jmemname.c,you will have to compile in a large-data memory model in order to get theright stdio library. Too bad.wrjpgcom needs to be compiled in large model, because it malloc()s a 64KBwork area to hold the comment text. If your C library's malloc can'thandle that, reduce MAX_COM_LENGTH as necessary in wrjpgcom.c.Most MS-DOS compilers treat stdin/stdout as text files, so you must usetwo-file command line style. But if your compiler has either fdopen() orsetmode(), you can use one-file style if you like. To do this, defineUSE_SETMODE or USE_FDOPEN so that stdin/stdout will be set to binary mode.(USE_SETMODE seems to work with more DOS compilers than USE_FDOPEN.) Youshould test that I/O through stdin/stdout produces the same results as I/Oto explicitly named files... the "make test" procedures in the suppliedmakefiles do NOT use stdin/stdout.MS-DOS, generic comments for 32-bit compilers:None of the above comments about memory models apply if you are using a32-bit flat-memory-space environment, such as DJGPP or Watcom C. (And youshould use one if you have it, as performance will be much better than8086-compatible code!) For flat-memory-space compilers, do NOT defineNEED_FAR_POINTERS, and do NOT use jmemdos.c. Use jmemnobs.c if theenvironment supplies adequate virtual memory, otherwise use jmemansi.c orjmemname.c.You'll still need to be careful about binary I/O through stdin/stdout.See the last paragraph of the previous section.MS-DOS, Borland C:Be sure to convert all the source files to DOS text format (CR/LF newlines).Although Borland C will often work OK with unmodified Unix (LF newlines)source files, sometimes it will give bogus compile errors."Illegal character '#'" is the most common such error. (This is true withBorland C 3.1, but perhaps is fixed in newer releases.)If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE.jconfig.bcc already includes #define USE_SETMODE to make this work.(fdopen does not work correctly.)MS-DOS, DJGPP:Use a recent version of DJGPP (1.11 or better). If you prefer two-filecommand line style, change the supplied jconfig.dj to defineTWO_FILE_COMMANDLINE. makefile.dj is set up to generate only COFF files(cjpeg, djpeg, etc) when you say make. After testing, say "make exe" tomake executables with stub.exe, or "make standalone" if you want executablesthat include go32. You will probably need to tweak the makefile's pointer togo32.exe to do "make standalone".MS-DOS, Microsoft C:makefile.mc6 works with Microsoft C, Visual C++, etc. Note that thismakefile assumes that the working copy of itself is called "makefile".If you want to call it something else, say "makefile.mak", be sure to adjustthe dependency line that reads "$(RFILE) : makefile". Otherwise the makewill fail because it doesn't know how to create "makefile". Worse, somereleases of Microsoft's make utilities give an incorrect error message inthis situation.If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE.jconfig.mc6 already includes #define USE_SETMODE to make this work.(fdopen does not work correctly.)Old versions of MS C fail with an "out of macro expansion space" errorbecause they can't cope with the macro TRACEMS8 (defined in jerror.h).If this happens to you, the easiest solution is to change TRACEMS8 toexpand to nothing. You'll lose the ability to dump out JPEG coefficienttables with djpeg -debug -debug, but at least you can compile.Original MS C 6.0 is very buggy; it compiles incorrect code unless you turnoff optimization entirely (remove -O from CFLAGS). 6.00A is better, but itstill generates bad code if you enable loop optimizations (-Ol or -Ox).MS C 8.0 reportedly fails to compile jquant1.c if optimization is turned off(yes, off).Microsoft Windows (all versions):Some Windows system include files define typedef boolean as "unsigned char".The IJG code also defines typedef boolean, but we make it "int" by default.This doesn't affect the IJG programs because we don't import those Windowsinclude files. But if you use the JPEG library in your own program, and someof your program's files import one definition of boolean while some import theother, you can get all sorts of mysterious problems. A good preventive stepis to change jmorecfg.h to define boolean as unsigned char. We recommendmaking that part of jmorecfg.h read like this: #ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ typedef unsigned char boolean; #endifIn v6a and later, using incompatible definitions of boolean will usually leadto the failure message "JPEG parameter struct mismatch", rather than thedifficult-to-diagnose bugs it caused with earlier versions.When using the library in a Windows application, you will almost certainlywant to modify or replace the error handler module jerror.c, since ourdefault error handler does a couple of inappropriate things: 1. it tries to write error and warning messages on stderr; 2. in event of a fatal error, it exits by calling exit().A simple stopgap solution for problem 1 is to replace the line fprintf(stderr, "%s\n", buffer);(in output_message in jerror.c) with something like MessageBox(GetActiveWindow(),buffer,"JPEG Error",MB_OK);It's highly recommended that you at least do that much, since otherwiseerror messages will disappear into nowhere.The proper solution for problem 2 is to return control to your callingapplication after a library error. This can be done with the setjmp/longjmptechnique discussed in libjpeg.doc and illustrated in example.c.You may also want to modify jdatasrc.c and jdatadst.c to use Windows fileoperations rather than fread/fwrite. This is only necessary if your Ccompiler doesn't provide a competent implementation of C stdio functions.Many people want to convert the IJG library into a DLL. This is reasonablystraightforward, but watch out for the following: 1. Don't try to compile as a DLL in small or medium memory model; uselarge model, or even better, 32-bit flat model. Many places in the IJG codeassume the address of a local variable is an ordinary (not FAR) pointer;that isn't true in a medium-model DLL. 2. Microsoft C cannot pass file pointers between applications and DLLs.(See Microsoft Knowledge Base, PSS ID Number Q50336.) So jdatasrc.c andjdatadst.c don't work if you open a file in your application and then passthe pointer to the DLL. One workaround is to make jdatasrc.c/jdatadst.cpart of your main application rather than part of the DLL. 3. You'll probably need to modify the macros GLOBAL() and EXTERN() toattach suitable linkage keywords to the exported routine names. Similarly,you'll want to modify METHODDEF() and JMETHOD() to ensure function pointersare declared in a way that lets application routines be called back throughthe function pointers. These macros are in jmorecfg.h. Typical definitionsfor a 16-bit DLL are: #define GLOBAL(type) type _far _pascal _loadds _export #define EXTERN(type) extern type _far _pascal #define METHODDEF(type) static type _far _pascal #define JMETHOD(type,methodname,arglist) \ type (_far _pascal *methodname) arglistAlthough not all the GLOBAL routines are actually intended to be called bythe application, the performance cost of making them all DLL entry points isnegligible.The unmodified IJG library presents a very C-specific application interface,so the resulting DLL is only usable from C or C++ applications. There hasbeen some talk of writing wrapper code that would present a simpler interfaceusable from other languages, such as Visual Basic. This is on our to-do listbut hasn't been very high priority --- any volunteers out there?Microsoft Windows, Borland C:Borland C++ 4.5 fails with an internal compiler error when trying to compilejdmerge.c in 32-bit mode. If enough people complain, perhaps Borland will fixit. In the meantime, the simplest known workaround is to add a redundantdefinition of the variable range_limit in h2v1_merged_upsample(), at the headof the block that handles odd image width (about line 268 in v6 jdmerge.c): /* If image width is odd, do the last output column separately */ if (cinfo->output_width & 1) { register JSAMPLE * range_limit = cinfo->sample_range_limit; /* ADD THIS */ cb = GETJSAMPLE(*inptr1);Pretty bizarre, especially since the very similar routine h2v2_merged_upsampledoesn't trigger the bug.Recent reports suggest that this bug does not occur with "bcc32a" (thePentium-optimized version of the compiler).SGI:On some SGI systems, you may need to set "AR2= ar -ts" in the Makefile.If you are using configure, you can do this by saying ./configure RANLIB='ar -ts'This change is not needed on all SGIs. Use it only if the make fails at thestage of linking the completed programs.On the MIPS R4000 architecture (Indy, etc.), the compiler option "-mips2"reportedly speeds up the float DCT method substantially, enough to make itfaster than the default int method (but still slower than the fast intmethod). If you use -mips2, you may want to alter the default DCT method tobe float. To do this, put "#define JDCT_DEFAULT JDCT_FLOAT" in jconfig.h.VMS:On an Alpha/VMS system with MMS, be sure to use the "/Marco=Alpha=1"qualifier with MMS when building the JPEG package.VAX/VMS v5.5-1 may have problems with the test step of the build procedurereporting differences when it compares the original and test images. If theerror points to the last block of the files, it is most likely bogus and maybe safely ignored. It seems to be because the files are Stream_LF andBackup/Compare has difficulty with the (presumably) null padded files.This problem was not observed on VAX/VMS v6.1 or AXP/VMS v6.1.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -