|
kusano |
7d535a |
INSTALLATION INSTRUCTIONS for the Independent JPEG Group's JPEG software
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding.
|
|
kusano |
7d535a |
This file is part of the Independent JPEG Group's software.
|
|
kusano |
7d535a |
For conditions of distribution and use, see the accompanying README file.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
This file explains how to configure and install the IJG software. We have
|
|
kusano |
7d535a |
tried to make this software extremely portable and flexible, so that it can be
|
|
kusano |
7d535a |
adapted to almost any environment. The downside of this decision is that the
|
|
kusano |
7d535a |
installation process is complicated. We have provided shortcuts to simplify
|
|
kusano |
7d535a |
the task on common systems. But in any case, you will need at least a little
|
|
kusano |
7d535a |
familiarity with C programming and program build procedures for your system.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you are only using this software as part of a larger program, the larger
|
|
kusano |
7d535a |
program's installation procedure may take care of configuring the IJG code.
|
|
kusano |
7d535a |
For example, Ghostscript's installation script will configure the IJG code.
|
|
kusano |
7d535a |
You don't need to read this file if you just want to compile Ghostscript.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you are on a Unix machine, you may not need to read this file at all.
|
|
kusano |
7d535a |
Try doing
|
|
kusano |
7d535a |
./configure
|
|
kusano |
7d535a |
make
|
|
kusano |
7d535a |
make test
|
|
kusano |
7d535a |
If that doesn't complain, do
|
|
kusano |
7d535a |
make install
|
|
kusano |
7d535a |
(better do "make -n install" first to see if the makefile will put the files
|
|
kusano |
7d535a |
where you want them). Read further if you run into snags or want to customize
|
|
kusano |
7d535a |
the code for your system.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
TABLE OF CONTENTS
|
|
kusano |
7d535a |
-----------------
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Before you start
|
|
kusano |
7d535a |
Configuring the software:
|
|
kusano |
7d535a |
using the automatic "configure" script
|
|
kusano |
7d535a |
using one of the supplied jconfig and makefile files
|
|
kusano |
7d535a |
by hand
|
|
kusano |
7d535a |
Building the software
|
|
kusano |
7d535a |
Testing the software
|
|
kusano |
7d535a |
Installing the software
|
|
kusano |
7d535a |
Optional stuff
|
|
kusano |
7d535a |
Optimization
|
|
kusano |
7d535a |
Hints for specific systems
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
BEFORE YOU START
|
|
kusano |
7d535a |
================
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Before installing the software you must unpack the distributed source code.
|
|
kusano |
7d535a |
Since you are reading this file, you have probably already succeeded in this
|
|
kusano |
7d535a |
task. However, there is a potential for error if you needed to convert the
|
|
kusano |
7d535a |
files to the local standard text file format (for example, if you are on
|
|
kusano |
7d535a |
MS-DOS you may have converted LF end-of-line to CR/LF). You must apply
|
|
kusano |
7d535a |
such conversion to all the files EXCEPT those whose names begin with "test".
|
|
kusano |
7d535a |
The test files contain binary data; if you change them in any way then the
|
|
kusano |
7d535a |
self-test will give bad results.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Please check the last section of this file to see if there are hints for the
|
|
kusano |
7d535a |
specific machine or compiler you are using.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
CONFIGURING THE SOFTWARE
|
|
kusano |
7d535a |
========================
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
To configure the IJG code for your system, you need to create two files:
|
|
kusano |
7d535a |
* jconfig.h: contains values for system-dependent #define symbols.
|
|
kusano |
7d535a |
* Makefile: controls the compilation process.
|
|
kusano |
7d535a |
(On a non-Unix machine, you may create "project files" or some other
|
|
kusano |
7d535a |
substitute for a Makefile. jconfig.h is needed in any environment.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
We provide three different ways to generate these files:
|
|
kusano |
7d535a |
* On a Unix system, you can just run the "configure" script.
|
|
kusano |
7d535a |
* We provide sample jconfig files and makefiles for popular machines;
|
|
kusano |
7d535a |
if your machine matches one of the samples, just copy the right sample
|
|
kusano |
7d535a |
files to jconfig.h and Makefile.
|
|
kusano |
7d535a |
* If all else fails, read the instructions below and make your own files.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Configuring the software using the automatic "configure" script
|
|
kusano |
7d535a |
---------------------------------------------------------------
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you are on a Unix machine, you can just type
|
|
kusano |
7d535a |
./configure
|
|
kusano |
7d535a |
and let the configure script construct appropriate configuration files.
|
|
kusano |
7d535a |
If you're using "csh" on an old version of System V, you might need to type
|
|
kusano |
7d535a |
sh configure
|
|
kusano |
7d535a |
instead to prevent csh from trying to execute configure itself.
|
|
kusano |
7d535a |
Expect configure to run for a few minutes, particularly on slower machines;
|
|
kusano |
7d535a |
it works by compiling a series of test programs.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Configure was created with GNU Autoconf and it follows the usual conventions
|
|
kusano |
7d535a |
for GNU configure scripts. It makes a few assumptions that you may want to
|
|
kusano |
7d535a |
override. You can do this by providing optional switches to configure:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
* Configure will build both static and shared libraries, if possible.
|
|
kusano |
7d535a |
If you want to build libjpeg only as a static library, say
|
|
kusano |
7d535a |
./configure --disable-shared
|
|
kusano |
7d535a |
If you want to build libjpeg only as a shared library, say
|
|
kusano |
7d535a |
./configure --disable-static
|
|
kusano |
7d535a |
Configure uses GNU libtool to take care of system-dependent shared library
|
|
kusano |
7d535a |
building methods.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
* Configure will use gcc (GNU C compiler) if it's available, otherwise cc.
|
|
kusano |
7d535a |
To force a particular compiler to be selected, use the CC option, for example
|
|
kusano |
7d535a |
./configure CC='cc'
|
|
kusano |
7d535a |
The same method can be used to include any unusual compiler switches.
|
|
kusano |
7d535a |
For example, on HP-UX you probably want to say
|
|
kusano |
7d535a |
./configure CC='cc -Aa'
|
|
kusano |
7d535a |
to get HP's compiler to run in ANSI mode.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
* The default CFLAGS setting is "-g" for non-gcc compilers, "-g -O2" for gcc.
|
|
kusano |
7d535a |
You can override this by saying, for example,
|
|
kusano |
7d535a |
./configure CFLAGS='-O2'
|
|
kusano |
7d535a |
if you want to compile without debugging support.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
* Configure will set up the makefile so that "make install" will install files
|
|
kusano |
7d535a |
into /usr/local/bin, /usr/local/man, etc. You can specify an installation
|
|
kusano |
7d535a |
prefix other than "/usr/local" by giving configure the option "--prefix=PATH".
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
* If you don't have a lot of swap space, you may need to enable the IJG
|
|
kusano |
7d535a |
software's internal virtual memory mechanism. To do this, give the option
|
|
kusano |
7d535a |
"--enable-maxmem=N" where N is the default maxmemory limit in megabytes.
|
|
kusano |
7d535a |
This is discussed in more detail under "Selecting a memory manager", below.
|
|
kusano |
7d535a |
You probably don't need to worry about this on reasonably-sized Unix machines,
|
|
kusano |
7d535a |
unless you plan to process very large images.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Configure has some other features that are useful if you are cross-compiling
|
|
kusano |
7d535a |
or working in a network of multiple machine types; but if you need those
|
|
kusano |
7d535a |
features, you probably already know how to use them.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Configuring the software using one of the supplied jconfig and makefile files
|
|
kusano |
7d535a |
-----------------------------------------------------------------------------
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you have one of these systems, you can just use the provided configuration
|
|
kusano |
7d535a |
files:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Makefile jconfig file System and/or compiler
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
makefile.manx jconfig.manx Amiga, Manx Aztec C
|
|
kusano |
7d535a |
makefile.sas jconfig.sas Amiga, SAS C
|
|
kusano |
7d535a |
makeproj.mac jconfig.mac Apple Macintosh, Metrowerks CodeWarrior
|
|
kusano |
7d535a |
mak*jpeg.st jconfig.st Atari ST/STE/TT, Pure C or Turbo C
|
|
kusano |
7d535a |
makefile.bcc jconfig.bcc MS-DOS or OS/2, Borland C
|
|
kusano |
7d535a |
makefile.dj jconfig.dj MS-DOS, DJGPP (Delorie's port of GNU C)
|
|
kusano |
7d535a |
makefile.mc6 jconfig.mc6 MS-DOS, Microsoft C (16-bit only)
|
|
kusano |
7d535a |
makefile.wat jconfig.wat MS-DOS, OS/2, or Windows NT, Watcom C
|
|
kusano |
7d535a |
makefile.vc jconfig.vc Windows NT/95, MS Visual C++
|
|
kusano |
7d535a |
make*.vc6 jconfig.vc Windows NT/95, MS Visual C++ 6
|
|
kusano |
7d535a |
make*.v10 jconfig.vc Windows NT/95, MS Visual C++ 2010 (v10)
|
|
kusano |
7d535a |
makefile.mms jconfig.vms Digital VMS, with MMS software
|
|
kusano |
7d535a |
makefile.vms jconfig.vms Digital VMS, without MMS software
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Copy the proper jconfig file to jconfig.h and the makefile to Makefile (or
|
|
kusano |
7d535a |
whatever your system uses as the standard makefile name). For more info see
|
|
kusano |
7d535a |
the appropriate system-specific hints section near the end of this file.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Configuring the software by hand
|
|
kusano |
7d535a |
--------------------------------
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
First, generate a jconfig.h file. If you are moderately familiar with C,
|
|
kusano |
7d535a |
the comments in jconfig.txt should be enough information to do this; just
|
|
kusano |
7d535a |
copy jconfig.txt to jconfig.h and edit it appropriately. Otherwise, you may
|
|
kusano |
7d535a |
prefer to use the ckconfig.c program. You will need to compile and execute
|
|
kusano |
7d535a |
ckconfig.c by hand --- we hope you know at least enough to do that.
|
|
kusano |
7d535a |
ckconfig.c may not compile the first try (in fact, the whole idea is for it
|
|
kusano |
7d535a |
to fail if anything is going to). If you get compile errors, fix them by
|
|
kusano |
7d535a |
editing ckconfig.c according to the directions given in ckconfig.c. Once
|
|
kusano |
7d535a |
you get it to run, it will write a suitable jconfig.h file, and will also
|
|
kusano |
7d535a |
print out some advice about which makefile to use.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
You may also want to look at the canned jconfig files, if there is one for a
|
|
kusano |
7d535a |
system similar to yours.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Second, select a makefile and copy it to Makefile (or whatever your system
|
|
kusano |
7d535a |
uses as the standard makefile name). The most generic makefiles we provide
|
|
kusano |
7d535a |
are
|
|
kusano |
7d535a |
makefile.ansi: if your C compiler supports function prototypes
|
|
kusano |
7d535a |
makefile.unix: if not.
|
|
kusano |
7d535a |
(You have function prototypes if ckconfig.c put "#define HAVE_PROTOTYPES"
|
|
kusano |
7d535a |
in jconfig.h.) You may want to start from one of the other makefiles if
|
|
kusano |
7d535a |
there is one for a system similar to yours.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Look over the selected Makefile and adjust options as needed. In particular
|
|
kusano |
7d535a |
you may want to change the CC and CFLAGS definitions. For instance, if you
|
|
kusano |
7d535a |
are using GCC, set CC=gcc. If you had to use any compiler switches to get
|
|
kusano |
7d535a |
ckconfig.c to work, make sure the same switches are in CFLAGS.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you are on a system that doesn't use makefiles, you'll need to set up
|
|
kusano |
7d535a |
project files (or whatever you do use) to compile all the source files and
|
|
kusano |
7d535a |
link them into executable files cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom.
|
|
kusano |
7d535a |
See the file lists in any of the makefiles to find out which files go into
|
|
kusano |
7d535a |
each program. Note that the provided makefiles all make a "library" file
|
|
kusano |
7d535a |
libjpeg first, but you don't have to do that if you don't want to; the file
|
|
kusano |
7d535a |
lists identify which source files are actually needed for compression,
|
|
kusano |
7d535a |
decompression, or both. As a last resort, you can make a batch script that
|
|
kusano |
7d535a |
just compiles everything and links it all together; makefile.vms is an example
|
|
kusano |
7d535a |
of this (it's for VMS systems that have no make-like utility).
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Here are comments about some specific configuration decisions you'll
|
|
kusano |
7d535a |
need to make:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Command line style
|
|
kusano |
7d535a |
------------------
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
These programs can use a Unix-like command line style which supports
|
|
kusano |
7d535a |
redirection and piping, like this:
|
|
kusano |
7d535a |
cjpeg inputfile >outputfile
|
|
kusano |
7d535a |
cjpeg <inputfile>outputfile</inputfile>
|
|
kusano |
7d535a |
source program | cjpeg >outputfile
|
|
kusano |
7d535a |
The simpler "two file" command line style is just
|
|
kusano |
7d535a |
cjpeg inputfile outputfile
|
|
kusano |
7d535a |
You may prefer the two-file style, particularly if you don't have pipes.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
You MUST use two-file style on any system that doesn't cope well with binary
|
|
kusano |
7d535a |
data fed through stdin/stdout; this is true for some MS-DOS compilers, for
|
|
kusano |
7d535a |
example. If you're not on a Unix system, it's safest to assume you need
|
|
kusano |
7d535a |
two-file style. (But if your compiler provides either the Posix-standard
|
|
kusano |
7d535a |
fdopen() library routine or a Microsoft-compatible setmode() routine, you
|
|
kusano |
7d535a |
can safely use the Unix command line style, by defining USE_FDOPEN or
|
|
kusano |
7d535a |
USE_SETMODE respectively.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
To use the two-file style, make jconfig.h say "#define TWO_FILE_COMMANDLINE".
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Selecting a memory manager
|
|
kusano |
7d535a |
--------------------------
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The IJG code is capable of working on images that are too big to fit in main
|
|
kusano |
7d535a |
memory; data is swapped out to temporary files as necessary. However, the
|
|
kusano |
7d535a |
code to do this is rather system-dependent. We provide five different
|
|
kusano |
7d535a |
memory managers:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
* jmemansi.c This version uses the ANSI-standard library routine tmpfile(),
|
|
kusano |
7d535a |
which not all non-ANSI systems have. On some systems
|
|
kusano |
7d535a |
tmpfile() may put the temporary file in a non-optimal
|
|
kusano |
7d535a |
location; if you don't like what it does, use jmemname.c.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
* jmemname.c This version creates named temporary files. For anything
|
|
kusano |
7d535a |
except a Unix machine, you'll need to configure the
|
|
kusano |
7d535a |
select_file_name() routine appropriately; see the comments
|
|
kusano |
7d535a |
near the head of jmemname.c. If you use this version, define
|
|
kusano |
7d535a |
NEED_SIGNAL_CATCHER in jconfig.h to make sure the temp files
|
|
kusano |
7d535a |
are removed if the program is aborted.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
* jmemnobs.c (That stands for No Backing Store :-).) This will compile on
|
|
kusano |
7d535a |
almost any system, but it assumes you have enough main memory
|
|
kusano |
7d535a |
or virtual memory to hold the biggest images you work with.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
* jmemdos.c This should be used with most 16-bit MS-DOS compilers.
|
|
kusano |
7d535a |
See the system-specific notes about MS-DOS for more info.
|
|
kusano |
7d535a |
IMPORTANT: if you use this, define USE_MSDOS_MEMMGR in
|
|
kusano |
7d535a |
jconfig.h, and include the assembly file jmemdosa.asm in the
|
|
kusano |
7d535a |
programs. The supplied makefiles and jconfig files for
|
|
kusano |
7d535a |
16-bit MS-DOS compilers already do both.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
* jmemmac.c Custom version for Apple Macintosh; see the system-specific
|
|
kusano |
7d535a |
notes for Macintosh for more info.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
To use a particular memory manager, change the SYSDEPMEM variable in your
|
|
kusano |
7d535a |
makefile to equal the corresponding object file name (for example, jmemansi.o
|
|
kusano |
7d535a |
or jmemansi.obj for jmemansi.c).
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you have plenty of (real or virtual) main memory, just use jmemnobs.c.
|
|
kusano |
7d535a |
"Plenty" means about ten bytes for every pixel in the largest images
|
|
kusano |
7d535a |
you plan to process, so a lot of systems don't meet this criterion.
|
|
kusano |
7d535a |
If yours doesn't, try jmemansi.c first. If that doesn't compile, you'll have
|
|
kusano |
7d535a |
to use jmemname.c; be sure to adjust select_file_name() for local conditions.
|
|
kusano |
7d535a |
You may also need to change unlink() to remove() in close_backing_store().
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Except with jmemnobs.c or jmemmac.c, you need to adjust the DEFAULT_MAX_MEM
|
|
kusano |
7d535a |
setting to a reasonable value for your system (either by adding a #define for
|
|
kusano |
7d535a |
DEFAULT_MAX_MEM to jconfig.h, or by adding a -D switch to the Makefile).
|
|
kusano |
7d535a |
This value limits the amount of data space the program will attempt to
|
|
kusano |
7d535a |
allocate. Code and static data space isn't counted, so the actual memory
|
|
kusano |
7d535a |
needs for cjpeg or djpeg are typically 100 to 150Kb more than the max-memory
|
|
kusano |
7d535a |
setting. Larger max-memory settings reduce the amount of I/O needed to
|
|
kusano |
7d535a |
process a large image, but too large a value can result in "insufficient
|
|
kusano |
7d535a |
memory" failures. On most Unix machines (and other systems with virtual
|
|
kusano |
7d535a |
memory), just set DEFAULT_MAX_MEM to several million and forget it. At the
|
|
kusano |
7d535a |
other end of the spectrum, for MS-DOS machines you probably can't go much
|
|
kusano |
7d535a |
above 300K to 400K. (On MS-DOS the value refers to conventional memory only.
|
|
kusano |
7d535a |
Extended/expanded memory is handled separately by jmemdos.c.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
BUILDING THE SOFTWARE
|
|
kusano |
7d535a |
=====================
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Now you should be able to compile the software. Just say "make" (or
|
|
kusano |
7d535a |
whatever's necessary to start the compilation). Have a cup of coffee.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Here are some things that could go wrong:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If your compiler complains about undefined structures, you should be able to
|
|
kusano |
7d535a |
shut it up by putting "#define INCOMPLETE_TYPES_BROKEN" in jconfig.h.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you have trouble with missing system include files or inclusion of the
|
|
kusano |
7d535a |
wrong ones, read jinclude.h. This shouldn't happen if you used configure
|
|
kusano |
7d535a |
or ckconfig.c to set up jconfig.h.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
There are a fair number of routines that do not use all of their parameters;
|
|
kusano |
7d535a |
some compilers will issue warnings about this, which you can ignore. There
|
|
kusano |
7d535a |
are also a few configuration checks that may give "unreachable code" warnings.
|
|
kusano |
7d535a |
Any other warning deserves investigation.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you don't have a getenv() library routine, define NO_GETENV.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Also see the system-specific hints, below.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
TESTING THE SOFTWARE
|
|
kusano |
7d535a |
====================
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
As a quick test of functionality we've included a small sample image in
|
|
kusano |
7d535a |
several forms:
|
|
kusano |
7d535a |
testorig.jpg Starting point for the djpeg tests.
|
|
kusano |
7d535a |
testimg.ppm The output of djpeg testorig.jpg
|
|
kusano |
7d535a |
testimg.bmp The output of djpeg -bmp -colors 256 testorig.jpg
|
|
kusano |
7d535a |
testimg.jpg The output of cjpeg testimg.ppm
|
|
kusano |
7d535a |
testprog.jpg Progressive-mode equivalent of testorig.jpg.
|
|
kusano |
7d535a |
testimgp.jpg The output of cjpeg -progressive -optimize testimg.ppm
|
|
kusano |
7d535a |
(The first- and second-generation .jpg files aren't identical since the
|
|
kusano |
7d535a |
default compression parameters are lossy.) If you can generate duplicates
|
|
kusano |
7d535a |
of the testimg* files then you probably have working programs.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
With most of the makefiles, "make test" will perform the necessary
|
|
kusano |
7d535a |
comparisons.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you're using a makefile that doesn't provide the test option, run djpeg
|
|
kusano |
7d535a |
and cjpeg by hand and compare the output files to testimg* with whatever
|
|
kusano |
7d535a |
binary file comparison tool you have. The files should be bit-for-bit
|
|
kusano |
7d535a |
identical.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If the programs complain "MAX_ALLOC_CHUNK is wrong, please fix", then you
|
|
kusano |
7d535a |
need to reduce MAX_ALLOC_CHUNK to a value that fits in type size_t.
|
|
kusano |
7d535a |
Try adding "#define MAX_ALLOC_CHUNK 65520L" to jconfig.h. A less likely
|
|
kusano |
7d535a |
configuration error is "ALIGN_TYPE is wrong, please fix": defining ALIGN_TYPE
|
|
kusano |
7d535a |
as long should take care of that one.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If the cjpeg test run fails with "Missing Huffman code table entry", it's a
|
|
kusano |
7d535a |
good bet that you needed to define RIGHT_SHIFT_IS_UNSIGNED. Go back to the
|
|
kusano |
7d535a |
configuration step and run ckconfig.c. (This is a good plan for any other
|
|
kusano |
7d535a |
test failure, too.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you are using Unix (one-file) command line style on a non-Unix system,
|
|
kusano |
7d535a |
it's a good idea to check that binary I/O through stdin/stdout actually
|
|
kusano |
7d535a |
works. You should get the same results from "djpeg <testorig.jpg>out.ppm"</testorig.jpg>
|
|
kusano |
7d535a |
as from "djpeg -outfile out.ppm testorig.jpg". Note that the makefiles all
|
|
kusano |
7d535a |
use the latter style and therefore do not exercise stdin/stdout! If this
|
|
kusano |
7d535a |
check fails, try recompiling with USE_SETMODE or USE_FDOPEN defined.
|
|
kusano |
7d535a |
If it still doesn't work, better use two-file style.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you chose a memory manager other than jmemnobs.c, you should test that
|
|
kusano |
7d535a |
temporary-file usage works. Try "djpeg -bmp -colors 256 -max 0 testorig.jpg"
|
|
kusano |
7d535a |
and make sure its output matches testimg.bmp. If you have any really large
|
|
kusano |
7d535a |
images handy, try compressing them with -optimize and/or decompressing with
|
|
kusano |
7d535a |
-colors 256 to make sure your DEFAULT_MAX_MEM setting is not too large.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
NOTE: this is far from an exhaustive test of the JPEG software; some modules,
|
|
kusano |
7d535a |
such as 1-pass color quantization, are not exercised at all. It's just a
|
|
kusano |
7d535a |
quick test to give you some confidence that you haven't missed something
|
|
kusano |
7d535a |
major.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
INSTALLING THE SOFTWARE
|
|
kusano |
7d535a |
=======================
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Once you're done with the above steps, you can install the software by
|
|
kusano |
7d535a |
copying the executable files (cjpeg, djpeg, jpegtran, rdjpgcom, and wrjpgcom)
|
|
kusano |
7d535a |
to wherever you normally install programs. On Unix systems, you'll also want
|
|
kusano |
7d535a |
to put the man pages (cjpeg.1, djpeg.1, jpegtran.1, rdjpgcom.1, wrjpgcom.1)
|
|
kusano |
7d535a |
in the man-page directory. The pre-fab makefiles don't support this step
|
|
kusano |
7d535a |
since there's such a wide variety of installation procedures on different
|
|
kusano |
7d535a |
systems.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you generated a Makefile with the "configure" script, you can just say
|
|
kusano |
7d535a |
make install
|
|
kusano |
7d535a |
to install the programs and their man pages into the standard places.
|
|
kusano |
7d535a |
(You'll probably need to be root to do this.) We recommend first saying
|
|
kusano |
7d535a |
make -n install
|
|
kusano |
7d535a |
to see where configure thought the files should go. You may need to edit
|
|
kusano |
7d535a |
the Makefile, particularly if your system's conventions for man page
|
|
kusano |
7d535a |
filenames don't match what configure expects.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you want to install the IJG library itself, for use in compiling other
|
|
kusano |
7d535a |
programs besides ours, then you need to put the four include files
|
|
kusano |
7d535a |
jpeglib.h jerror.h jconfig.h jmorecfg.h
|
|
kusano |
7d535a |
into your include-file directory, and put the library file libjpeg.a
|
|
kusano |
7d535a |
(extension may vary depending on system) wherever library files go.
|
|
kusano |
7d535a |
If you generated a Makefile with "configure", it will do what it thinks
|
|
kusano |
7d535a |
is the right thing if you say
|
|
kusano |
7d535a |
make install-lib
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
OPTIONAL STUFF
|
|
kusano |
7d535a |
==============
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Progress monitor:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you like, you can #define PROGRESS_REPORT (in jconfig.h) to enable display
|
|
kusano |
7d535a |
of percent-done progress reports. The routine provided in cdjpeg.c merely
|
|
kusano |
7d535a |
prints percentages to stderr, but you can customize it to do something
|
|
kusano |
7d535a |
fancier.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Utah RLE file format support:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
We distribute the software with support for RLE image files (Utah Raster
|
|
kusano |
7d535a |
Toolkit format) disabled, because the RLE support won't compile without the
|
|
kusano |
7d535a |
Utah library. If you have URT version 3.1 or later, you can enable RLE
|
|
kusano |
7d535a |
support as follows:
|
|
kusano |
7d535a |
1. #define RLE_SUPPORTED in jconfig.h.
|
|
kusano |
7d535a |
2. Add a -I option to CFLAGS in the Makefile for the directory
|
|
kusano |
7d535a |
containing the URT .h files (typically the "include"
|
|
kusano |
7d535a |
subdirectory of the URT distribution).
|
|
kusano |
7d535a |
3. Add -L... -lrle to LDLIBS in the Makefile, where ... specifies
|
|
kusano |
7d535a |
the directory containing the URT "librle.a" file (typically the
|
|
kusano |
7d535a |
"lib" subdirectory of the URT distribution).
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Support for 12-bit-deep pixel data:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The JPEG standard allows either 8-bit or 12-bit data precision. (For color,
|
|
kusano |
7d535a |
this means 8 or 12 bits per channel, of course.) If you need to work with
|
|
kusano |
7d535a |
deeper than 8-bit data, you can compile the IJG code for 12-bit operation.
|
|
kusano |
7d535a |
To do so:
|
|
kusano |
7d535a |
1. In jmorecfg.h, define BITS_IN_JSAMPLE as 12 rather than 8.
|
|
kusano |
7d535a |
2. In jconfig.h, undefine BMP_SUPPORTED, RLE_SUPPORTED, and TARGA_SUPPORTED,
|
|
kusano |
7d535a |
because the code for those formats doesn't handle 12-bit data and won't
|
|
kusano |
7d535a |
even compile. (The PPM code does work, as explained below. The GIF
|
|
kusano |
7d535a |
code works too; it scales 8-bit GIF data to and from 12-bit depth
|
|
kusano |
7d535a |
automatically.)
|
|
kusano |
7d535a |
3. Compile. Don't expect "make test" to pass, since the supplied test
|
|
kusano |
7d535a |
files are for 8-bit data.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Currently, 12-bit support does not work on 16-bit-int machines.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Note that a 12-bit version will not read 8-bit JPEG files, nor vice versa;
|
|
kusano |
7d535a |
so you'll want to keep around a regular 8-bit compilation as well.
|
|
kusano |
7d535a |
(Run-time selection of data depth, to allow a single copy that does both,
|
|
kusano |
7d535a |
is possible but would probably slow things down considerably; it's very low
|
|
kusano |
7d535a |
on our to-do list.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The PPM reader (rdppm.c) can read 12-bit data from either text-format or
|
|
kusano |
7d535a |
binary-format PPM and PGM files. Binary-format PPM/PGM files which have a
|
|
kusano |
7d535a |
maxval greater than 255 are assumed to use 2 bytes per sample, MSB first
|
|
kusano |
7d535a |
(big-endian order). As of early 1995, 2-byte binary format is not
|
|
kusano |
7d535a |
officially supported by the PBMPLUS library, but it is expected that a
|
|
kusano |
7d535a |
future release of PBMPLUS will support it. Note that the PPM reader will
|
|
kusano |
7d535a |
read files of any maxval regardless of the BITS_IN_JSAMPLE setting; incoming
|
|
kusano |
7d535a |
data is automatically rescaled to either maxval=255 or maxval=4095 as
|
|
kusano |
7d535a |
appropriate for the cjpeg bit depth.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The PPM writer (wrppm.c) will normally write 2-byte binary PPM or PGM
|
|
kusano |
7d535a |
format, maxval 4095, when compiled with BITS_IN_JSAMPLE=12. Since this
|
|
kusano |
7d535a |
format is not yet widely supported, you can disable it by compiling wrppm.c
|
|
kusano |
7d535a |
with PPM_NORAWWORD defined; then the data is scaled down to 8 bits to make a
|
|
kusano |
7d535a |
standard 1-byte/sample PPM or PGM file. (Yes, this means still another copy
|
|
kusano |
7d535a |
of djpeg to keep around. But hopefully you won't need it for very long.
|
|
kusano |
7d535a |
Poskanzer's supposed to get that new PBMPLUS release out Real Soon Now.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Of course, if you are working with 12-bit data, you probably have it stored
|
|
kusano |
7d535a |
in some other, nonstandard format. In that case you'll probably want to
|
|
kusano |
7d535a |
write your own I/O modules to read and write your format.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Note that a 12-bit version of cjpeg always runs in "-optimize" mode, in
|
|
kusano |
7d535a |
order to generate valid Huffman tables. This is necessary because our
|
|
kusano |
7d535a |
default Huffman tables only cover 8-bit data.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Removing code:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you need to make a smaller version of the JPEG software, some optional
|
|
kusano |
7d535a |
functions can be removed at compile time. See the xxx_SUPPORTED #defines in
|
|
kusano |
7d535a |
jconfig.h and jmorecfg.h. If at all possible, we recommend that you leave in
|
|
kusano |
7d535a |
decoder support for all valid JPEG files, to ensure that you can read anyone's
|
|
kusano |
7d535a |
output. Taking out support for image file formats that you don't use is the
|
|
kusano |
7d535a |
most painless way to make the programs smaller. Another possibility is to
|
|
kusano |
7d535a |
remove some of the DCT methods: in particular, the "IFAST" method may not be
|
|
kusano |
7d535a |
enough faster than the others to be worth keeping on your machine. (If you
|
|
kusano |
7d535a |
do remove ISLOW or IFAST, be sure to redefine JDCT_DEFAULT or JDCT_FASTEST
|
|
kusano |
7d535a |
to a supported method, by adding a #define in jconfig.h.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
OPTIMIZATION
|
|
kusano |
7d535a |
============
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Unless you own a Cray, you'll probably be interested in making the JPEG
|
|
kusano |
7d535a |
software go as fast as possible. This section covers some machine-dependent
|
|
kusano |
7d535a |
optimizations you may want to try. We suggest that before trying any of
|
|
kusano |
7d535a |
this, you first get the basic installation to pass the self-test step.
|
|
kusano |
7d535a |
Repeat the self-test after any optimization to make sure that you haven't
|
|
kusano |
7d535a |
broken anything.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The integer DCT routines perform a lot of multiplications. These
|
|
kusano |
7d535a |
multiplications must yield 32-bit results, but none of their input values
|
|
kusano |
7d535a |
are more than 16 bits wide. On many machines, notably the 680x0 and 80x86
|
|
kusano |
7d535a |
CPUs, a 16x16=>32 bit multiply instruction is faster than a full 32x32=>32
|
|
kusano |
7d535a |
bit multiply. Unfortunately there is no portable way to specify such a
|
|
kusano |
7d535a |
multiplication in C, but some compilers can generate one when you use the
|
|
kusano |
7d535a |
right combination of casts. See the MULTIPLYxxx macro definitions in
|
|
kusano |
7d535a |
jdct.h. If your compiler makes "int" be 32 bits and "short" be 16 bits,
|
|
kusano |
7d535a |
defining SHORTxSHORT_32 is fairly likely to work. When experimenting with
|
|
kusano |
7d535a |
alternate definitions, be sure to test not only whether the code still works
|
|
kusano |
7d535a |
(use the self-test), but also whether it is actually faster --- on some
|
|
kusano |
7d535a |
compilers, alternate definitions may compute the right answer, yet be slower
|
|
kusano |
7d535a |
than the default. Timing cjpeg on a large PGM (grayscale) input file is the
|
|
kusano |
7d535a |
best way to check this, as the DCT will be the largest fraction of the runtime
|
|
kusano |
7d535a |
in that mode. (Note: some of the distributed compiler-specific jconfig files
|
|
kusano |
7d535a |
already contain #define switches to select appropriate MULTIPLYxxx
|
|
kusano |
7d535a |
definitions.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If your machine has sufficiently fast floating point hardware, you may find
|
|
kusano |
7d535a |
that the float DCT method is faster than the integer DCT methods, even
|
|
kusano |
7d535a |
after tweaking the integer multiply macros. In that case you may want to
|
|
kusano |
7d535a |
make the float DCT be the default method. (The only objection to this is
|
|
kusano |
7d535a |
that float DCT results may vary slightly across machines.) To do that, add
|
|
kusano |
7d535a |
"#define JDCT_DEFAULT JDCT_FLOAT" to jconfig.h. Even if you don't change
|
|
kusano |
7d535a |
the default, you should redefine JDCT_FASTEST, which is the method selected
|
|
kusano |
7d535a |
by djpeg's -fast switch. Don't forget to update the documentation files
|
|
kusano |
7d535a |
(usage.txt and/or cjpeg.1, djpeg.1) to agree with what you've done.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If access to "short" arrays is slow on your machine, it may be a win to
|
|
kusano |
7d535a |
define type JCOEF as int rather than short. This will cost a good deal of
|
|
kusano |
7d535a |
memory though, particularly in some multi-pass modes, so don't do it unless
|
|
kusano |
7d535a |
you have memory to burn and short is REALLY slow.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If your compiler can compile function calls in-line, make sure the INLINE
|
|
kusano |
7d535a |
macro in jmorecfg.h is defined as the keyword that marks a function
|
|
kusano |
7d535a |
inline-able. Some compilers have a switch that tells the compiler to inline
|
|
kusano |
7d535a |
any function it thinks is profitable (e.g., -finline-functions for gcc).
|
|
kusano |
7d535a |
Enabling such a switch is likely to make the compiled code bigger but faster.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
In general, it's worth trying the maximum optimization level of your compiler,
|
|
kusano |
7d535a |
and experimenting with any optional optimizations such as loop unrolling.
|
|
kusano |
7d535a |
(Unfortunately, far too many compilers have optimizer bugs ... be prepared to
|
|
kusano |
7d535a |
back off if the code fails self-test.) If you do any experimentation along
|
|
kusano |
7d535a |
these lines, please report the optimal settings to jpeg-info@jpegclub.org so
|
|
kusano |
7d535a |
we can mention them in future releases. Be sure to specify your machine and
|
|
kusano |
7d535a |
compiler version.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
HINTS FOR SPECIFIC SYSTEMS
|
|
kusano |
7d535a |
==========================
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
We welcome reports on changes needed for systems not mentioned here. Submit
|
|
kusano |
7d535a |
'em to jpeg-info@jpegclub.org. Also, if configure or ckconfig.c is wrong
|
|
kusano |
7d535a |
about how to configure the JPEG software for your system, please let us know.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Acorn RISC OS:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
(Thanks to Simon Middleton for these hints on compiling with Desktop C.)
|
|
kusano |
7d535a |
After renaming the files according to Acorn conventions, take a copy of
|
|
kusano |
7d535a |
makefile.ansi, change all occurrences of 'libjpeg.a' to 'libjpeg.o' and
|
|
kusano |
7d535a |
change these definitions as indicated:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
CFLAGS= -throwback -IC: -Wn
|
|
kusano |
7d535a |
LDLIBS=C:o.Stubs
|
|
kusano |
7d535a |
SYSDEPMEM=jmemansi.o
|
|
kusano |
7d535a |
LN=Link
|
|
kusano |
7d535a |
AR=LibFile -c -o
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Also add a new line '.c.o:; $(cc) $< $(cflags) -c -o $@'. Remove the
|
|
kusano |
7d535a |
lines '$(RM) libjpeg.o' and '$(AR2) libjpeg.o' and the 'jconfig.h'
|
|
kusano |
7d535a |
dependency section.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Copy jconfig.txt to jconfig.h. Edit jconfig.h to define TWO_FILE_COMMANDLINE
|
|
kusano |
7d535a |
and CHAR_IS_UNSIGNED.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Run the makefile using !AMU not !Make. If you want to use the 'clean' and
|
|
kusano |
7d535a |
'test' makefile entries then you will have to fiddle with the syntax a bit
|
|
kusano |
7d535a |
and rename the test files.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Amiga:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
SAS C 6.50 reportedly is too buggy to compile the IJG code properly.
|
|
kusano |
7d535a |
A patch to update to 6.51 is available from SAS or AmiNet FTP sites.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The supplied config files are set up to use jmemname.c as the memory
|
|
kusano |
7d535a |
manager, with temporary files being created on the device named by
|
|
kusano |
7d535a |
"JPEGTMP:".
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Atari ST/STE/TT:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Copy the project files makcjpeg.st, makdjpeg.st, maktjpeg.st, and makljpeg.st
|
|
kusano |
7d535a |
to cjpeg.prj, djpeg.prj, jpegtran.prj, and libjpeg.prj respectively. The
|
|
kusano |
7d535a |
project files should work as-is with Pure C. For Turbo C, change library
|
|
kusano |
7d535a |
filenames "pc..." to "tc..." in each project file. Note that libjpeg.prj
|
|
kusano |
7d535a |
selects jmemansi.c as the recommended memory manager. You'll probably want to
|
|
kusano |
7d535a |
adjust the DEFAULT_MAX_MEM setting --- you want it to be a couple hundred K
|
|
kusano |
7d535a |
less than your normal free memory. Put "#define DEFAULT_MAX_MEM nnnn" into
|
|
kusano |
7d535a |
jconfig.h to do this.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
To use the 68881/68882 coprocessor for the floating point DCT, add the
|
|
kusano |
7d535a |
compiler option "-8" to the project files and replace pcfltlib.lib with
|
|
kusano |
7d535a |
pc881lib.lib in cjpeg.prj and djpeg.prj. Or if you don't have a
|
|
kusano |
7d535a |
coprocessor, you may prefer to remove the float DCT code by undefining
|
|
kusano |
7d535a |
DCT_FLOAT_SUPPORTED in jmorecfg.h (since without a coprocessor, the float
|
|
kusano |
7d535a |
code will be too slow to be useful). In that case, you can delete
|
|
kusano |
7d535a |
pcfltlib.lib from the project files.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Note that you must make libjpeg.lib before making cjpeg.ttp, djpeg.ttp,
|
|
kusano |
7d535a |
or jpegtran.ttp. You'll have to perform the self-test by hand.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
We haven't bothered to include project files for rdjpgcom and wrjpgcom.
|
|
kusano |
7d535a |
Those source files should just be compiled by themselves; they don't
|
|
kusano |
7d535a |
depend on the JPEG library. You can use the default.prj project file
|
|
kusano |
7d535a |
of the Pure C distribution to make the programs.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
There is a bug in some older versions of the Turbo C library which causes the
|
|
kusano |
7d535a |
space used by temporary files created with "tmpfile()" not to be freed after
|
|
kusano |
7d535a |
an abnormal program exit. If you check your disk afterwards, you will find
|
|
kusano |
7d535a |
cluster chains that are allocated but not used by a file. This should not
|
|
kusano |
7d535a |
happen in cjpeg/djpeg/jpegtran, since we enable a signal catcher to explicitly
|
|
kusano |
7d535a |
close temp files before exiting. But if you use the JPEG library with your
|
|
kusano |
7d535a |
own code, be sure to supply a signal catcher, or else use a different
|
|
kusano |
7d535a |
system-dependent memory manager.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Cray:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Should you be so fortunate as to be running JPEG on a Cray YMP, there is a
|
|
kusano |
7d535a |
compiler bug in old versions of Cray's Standard C (prior to 3.1). If you
|
|
kusano |
7d535a |
still have an old compiler, you'll need to insert a line reading
|
|
kusano |
7d535a |
"#pragma novector" just before the loop
|
|
kusano |
7d535a |
for (i = 1; i <= (int) htbl->bits[l]; i++)
|
|
kusano |
7d535a |
huffsize[p++] = (char) l;
|
|
kusano |
7d535a |
in fix_huff_tbl (in V5beta1, line 204 of jchuff.c and line 176 of jdhuff.c).
|
|
kusano |
7d535a |
[This bug may or may not still occur with the current IJG code, but it's
|
|
kusano |
7d535a |
probably a dead issue anyway...]
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
HP-UX:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you have HP-UX 7.05 or later with the "software development" C compiler,
|
|
kusano |
7d535a |
you should run the compiler in ANSI mode. If using the configure script,
|
|
kusano |
7d535a |
say
|
|
kusano |
7d535a |
./configure CC='cc -Aa'
|
|
kusano |
7d535a |
(or -Ae if you prefer). If configuring by hand, use makefile.ansi and add
|
|
kusano |
7d535a |
"-Aa" to the CFLAGS line in the makefile.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you have a pre-7.05 system, or if you are using the non-ANSI C compiler
|
|
kusano |
7d535a |
delivered with a minimum HP-UX system, then you must use makefile.unix
|
|
kusano |
7d535a |
(and do NOT add -Aa); or just run configure without the CC option.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
On HP 9000 series 800 machines, the HP C compiler is buggy in revisions prior
|
|
kusano |
7d535a |
to A.08.07. If you get complaints about "not a typedef name", you'll have to
|
|
kusano |
7d535a |
use makefile.unix, or run configure without the CC option.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Macintosh, generic comments:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The supplied user-interface files (cjpeg.c, djpeg.c, etc) are set up to
|
|
kusano |
7d535a |
provide a Unix-style command line interface. You can use this interface on
|
|
kusano |
7d535a |
the Mac by means of the ccommand() library routine provided by Metrowerks
|
|
kusano |
7d535a |
CodeWarrior or Think C. This is only appropriate for testing the library,
|
|
kusano |
7d535a |
however; to make a user-friendly equivalent of cjpeg/djpeg you'd really want
|
|
kusano |
7d535a |
to develop a Mac-style user interface. There isn't a complete example
|
|
kusano |
7d535a |
available at the moment, but there are some helpful starting points:
|
|
kusano |
7d535a |
1. Sam Bushell's free "To JPEG" applet provides drag-and-drop conversion to
|
|
kusano |
7d535a |
JPEG under System 7 and later. This only illustrates how to use the
|
|
kusano |
7d535a |
compression half of the library, but it does a very nice job of that part.
|
|
kusano |
7d535a |
The CodeWarrior source code is available from http://www.pobox.com/~jsam.
|
|
kusano |
7d535a |
2. Jim Brunner prepared a Mac-style user interface for both compression and
|
|
kusano |
7d535a |
decompression. Unfortunately, it hasn't been updated since IJG v4, and
|
|
kusano |
7d535a |
the library's API has changed considerably since then. Still it may be of
|
|
kusano |
7d535a |
some help, particularly as a guide to compiling the IJG code under Think C.
|
|
kusano |
7d535a |
Jim's code is available from the Info-Mac archives, at sumex-aim.stanford.edu
|
|
kusano |
7d535a |
or mirrors thereof; see file /info-mac/dev/src/jpeg-convert-c.hqx.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
jmemmac.c is the recommended memory manager back end for Macintosh. It uses
|
|
kusano |
7d535a |
NewPtr/DisposePtr instead of malloc/free, and has a Mac-specific
|
|
kusano |
7d535a |
implementation of jpeg_mem_available(). It also creates temporary files that
|
|
kusano |
7d535a |
follow Mac conventions. (That part of the code relies on System-7-or-later OS
|
|
kusano |
7d535a |
functions. See the comments in jmemmac.c if you need to run it on System 6.)
|
|
kusano |
7d535a |
NOTE that USE_MAC_MEMMGR must be defined in jconfig.h to use jmemmac.c.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
You can also use jmemnobs.c, if you don't care about handling images larger
|
|
kusano |
7d535a |
than available memory. If you use any memory manager back end other than
|
|
kusano |
7d535a |
jmemmac.c, we recommend replacing "malloc" and "free" by "NewPtr" and
|
|
kusano |
7d535a |
"DisposePtr", because Mac C libraries often have peculiar implementations of
|
|
kusano |
7d535a |
malloc/free. (For instance, free() may not return the freed space to the
|
|
kusano |
7d535a |
Mac Memory Manager. This is undesirable for the IJG code because jmemmgr.c
|
|
kusano |
7d535a |
already clumps space requests.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Macintosh, Metrowerks CodeWarrior:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The Unix-command-line-style interface can be used by defining USE_CCOMMAND.
|
|
kusano |
7d535a |
You'll also need to define TWO_FILE_COMMANDLINE to avoid stdin/stdout.
|
|
kusano |
7d535a |
This means that when using the cjpeg/djpeg programs, you'll have to type the
|
|
kusano |
7d535a |
input and output file names in the "Arguments" text-edit box, rather than
|
|
kusano |
7d535a |
using the file radio buttons. (Perhaps USE_FDOPEN or USE_SETMODE would
|
|
kusano |
7d535a |
eliminate the problem, but I haven't heard from anyone who's tried it.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
On 680x0 Macs, Metrowerks defines type "double" as a 10-byte IEEE extended
|
|
kusano |
7d535a |
float. jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power
|
|
kusano |
7d535a |
of 2. Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The supplied configuration file jconfig.mac can be used for your jconfig.h;
|
|
kusano |
7d535a |
it includes all the recommended symbol definitions. If you have AppleScript
|
|
kusano |
7d535a |
installed, you can run the supplied script makeproj.mac to create CodeWarrior
|
|
kusano |
7d535a |
project files for the library and the testbed applications, then build the
|
|
kusano |
7d535a |
library and applications. (Thanks to Dan Sears and Don Agro for this nifty
|
|
kusano |
7d535a |
hack, which saves us from trying to maintain CodeWarrior project files as part
|
|
kusano |
7d535a |
of the IJG distribution...)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Macintosh, Think C:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The documentation in Jim Brunner's "JPEG Convert" source code (see above)
|
|
kusano |
7d535a |
includes detailed build instructions for Think C; it's probably somewhat
|
|
kusano |
7d535a |
out of date for the current release, but may be helpful.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you want to build the minimal command line version, proceed as follows.
|
|
kusano |
7d535a |
You'll have to prepare project files for the programs; we don't include any
|
|
kusano |
7d535a |
in the distribution since they are not text files. Use the file lists in
|
|
kusano |
7d535a |
any of the supplied makefiles as a guide. Also add the ANSI and Unix C
|
|
kusano |
7d535a |
libraries in a separate segment. You may need to divide the JPEG files into
|
|
kusano |
7d535a |
more than one segment; we recommend dividing compression and decompression
|
|
kusano |
7d535a |
modules. Define USE_CCOMMAND in jconfig.h so that the ccommand() routine is
|
|
kusano |
7d535a |
called. You must also define TWO_FILE_COMMANDLINE because stdin/stdout
|
|
kusano |
7d535a |
don't handle binary data correctly.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
On 680x0 Macs, Think C defines type "double" as a 12-byte IEEE extended float.
|
|
kusano |
7d535a |
jmemmgr.c won't like this: it wants sizeof(ALIGN_TYPE) to be a power of 2.
|
|
kusano |
7d535a |
Add "#define ALIGN_TYPE long" to jconfig.h to eliminate the complaint.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
jconfig.mac should work as a jconfig.h configuration file for Think C,
|
|
kusano |
7d535a |
but the makeproj.mac AppleScript script is specific to CodeWarrior. Sorry.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
MIPS R3000:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
MIPS's cc version 1.31 has a rather nasty optimization bug. Don't use -O
|
|
kusano |
7d535a |
if you have that compiler version. (Use "cc -V" to check the version.)
|
|
kusano |
7d535a |
Note that the R3000 chip is found in workstations from DEC and others.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
MS-DOS, generic comments for 16-bit compilers:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The IJG code is designed to work well in 80x86 "small" or "medium" memory
|
|
kusano |
7d535a |
models (i.e., data pointers are 16 bits unless explicitly declared "far";
|
|
kusano |
7d535a |
code pointers can be either size). You may be able to use small model to
|
|
kusano |
7d535a |
compile cjpeg or djpeg by itself, but you will probably have to use medium
|
|
kusano |
7d535a |
model for any larger application. This won't make much difference in
|
|
kusano |
7d535a |
performance. You *will* take a noticeable performance hit if you use a
|
|
kusano |
7d535a |
large-data memory model, and you should avoid "huge" model if at all
|
|
kusano |
7d535a |
possible. Be sure that NEED_FAR_POINTERS is defined in jconfig.h if you use
|
|
kusano |
7d535a |
a small-data memory model; be sure it is NOT defined if you use a large-data
|
|
kusano |
7d535a |
model. (The supplied makefiles and jconfig files for Borland and Microsoft C
|
|
kusano |
7d535a |
compile in medium model and define NEED_FAR_POINTERS.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The DOS-specific memory manager, jmemdos.c, should be used if possible.
|
|
kusano |
7d535a |
It needs some assembly-code routines which are in jmemdosa.asm; make sure
|
|
kusano |
7d535a |
your makefile assembles that file and includes it in the library. If you
|
|
kusano |
7d535a |
don't have a suitable assembler, you can get pre-assembled object files for
|
|
kusano |
7d535a |
jmemdosa by FTP from ftp.uu.net:/graphics/jpeg/jdosaobj.zip. (DOS-oriented
|
|
kusano |
7d535a |
distributions of the IJG source code often include these object files.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
When using jmemdos.c, jconfig.h must define USE_MSDOS_MEMMGR and must set
|
|
kusano |
7d535a |
MAX_ALLOC_CHUNK to less than 64K (65520L is a typical value). If your
|
|
kusano |
7d535a |
C library's far-heap malloc() can't allocate blocks that large, reduce
|
|
kusano |
7d535a |
MAX_ALLOC_CHUNK to whatever it can handle.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you can't use jmemdos.c for some reason --- for example, because you
|
|
kusano |
7d535a |
don't have an assembler to assemble jmemdosa.asm --- you'll have to fall
|
|
kusano |
7d535a |
back to jmemansi.c or jmemname.c. You'll probably still need to set
|
|
kusano |
7d535a |
MAX_ALLOC_CHUNK in jconfig.h, because most DOS C libraries won't malloc()
|
|
kusano |
7d535a |
more than 64K at a time. IMPORTANT: if you use jmemansi.c or jmemname.c,
|
|
kusano |
7d535a |
you will have to compile in a large-data memory model in order to get the
|
|
kusano |
7d535a |
right stdio library. Too bad.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
wrjpgcom needs to be compiled in large model, because it malloc()s a 64KB
|
|
kusano |
7d535a |
work area to hold the comment text. If your C library's malloc can't
|
|
kusano |
7d535a |
handle that, reduce MAX_COM_LENGTH as necessary in wrjpgcom.c.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Most MS-DOS compilers treat stdin/stdout as text files, so you must use
|
|
kusano |
7d535a |
two-file command line style. But if your compiler has either fdopen() or
|
|
kusano |
7d535a |
setmode(), you can use one-file style if you like. To do this, define
|
|
kusano |
7d535a |
USE_SETMODE or USE_FDOPEN so that stdin/stdout will be set to binary mode.
|
|
kusano |
7d535a |
(USE_SETMODE seems to work with more DOS compilers than USE_FDOPEN.) You
|
|
kusano |
7d535a |
should test that I/O through stdin/stdout produces the same results as I/O
|
|
kusano |
7d535a |
to explicitly named files... the "make test" procedures in the supplied
|
|
kusano |
7d535a |
makefiles do NOT use stdin/stdout.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
MS-DOS, generic comments for 32-bit compilers:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
None of the above comments about memory models apply if you are using a
|
|
kusano |
7d535a |
32-bit flat-memory-space environment, such as DJGPP or Watcom C. (And you
|
|
kusano |
7d535a |
should use one if you have it, as performance will be much better than
|
|
kusano |
7d535a |
8086-compatible code!) For flat-memory-space compilers, do NOT define
|
|
kusano |
7d535a |
NEED_FAR_POINTERS, and do NOT use jmemdos.c. Use jmemnobs.c if the
|
|
kusano |
7d535a |
environment supplies adequate virtual memory, otherwise use jmemansi.c or
|
|
kusano |
7d535a |
jmemname.c.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
You'll still need to be careful about binary I/O through stdin/stdout.
|
|
kusano |
7d535a |
See the last paragraph of the previous section.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
MS-DOS, Borland C:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Be sure to convert all the source files to DOS text format (CR/LF newlines).
|
|
kusano |
7d535a |
Although Borland C will often work OK with unmodified Unix (LF newlines)
|
|
kusano |
7d535a |
source files, sometimes it will give bogus compile errors.
|
|
kusano |
7d535a |
"Illegal character '#'" is the most common such error. (This is true with
|
|
kusano |
7d535a |
Borland C 3.1, but perhaps is fixed in newer releases.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE.
|
|
kusano |
7d535a |
jconfig.bcc already includes #define USE_SETMODE to make this work.
|
|
kusano |
7d535a |
(fdopen does not work correctly.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
MS-DOS, Microsoft C:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
makefile.mc6 works with Microsoft C, DOS Visual C++, etc. It should only
|
|
kusano |
7d535a |
be used if you want to build a 16-bit (small or medium memory model) program.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
If you want one-file command line style, just undefine TWO_FILE_COMMANDLINE.
|
|
kusano |
7d535a |
jconfig.mc6 already includes #define USE_SETMODE to make this work.
|
|
kusano |
7d535a |
(fdopen does not work correctly.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Note that this makefile assumes that the working copy of itself is called
|
|
kusano |
7d535a |
"makefile". If you want to call it something else, say "makefile.mak",
|
|
kusano |
7d535a |
be sure to adjust the dependency line that reads "$(RFILE) : makefile".
|
|
kusano |
7d535a |
Otherwise the make will fail because it doesn't know how to create "makefile".
|
|
kusano |
7d535a |
Worse, some releases of Microsoft's make utilities give an incorrect error
|
|
kusano |
7d535a |
message in this situation.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Old versions of MS C fail with an "out of macro expansion space" error
|
|
kusano |
7d535a |
because they can't cope with the macro TRACEMS8 (defined in jerror.h).
|
|
kusano |
7d535a |
If this happens to you, the easiest solution is to change TRACEMS8 to
|
|
kusano |
7d535a |
expand to nothing. You'll lose the ability to dump out JPEG coefficient
|
|
kusano |
7d535a |
tables with djpeg -debug -debug, but at least you can compile.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Original MS C 6.0 is very buggy; it compiles incorrect code unless you turn
|
|
kusano |
7d535a |
off optimization entirely (remove -O from CFLAGS). 6.00A is better, but it
|
|
kusano |
7d535a |
still generates bad code if you enable loop optimizations (-Ol or -Ox).
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
MS C 8.0 crashes when compiling jquant1.c with optimization switch /Oo ...
|
|
kusano |
7d535a |
which is on by default. To work around this bug, compile that one file
|
|
kusano |
7d535a |
with /Oo-.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Microsoft Windows (all versions), generic comments:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Some Windows system include files define typedef boolean as "unsigned char".
|
|
kusano |
7d535a |
The IJG code also defines typedef boolean, but we make it an "enum" by default.
|
|
kusano |
7d535a |
This doesn't affect the IJG programs because we don't import those Windows
|
|
kusano |
7d535a |
include files. But if you use the JPEG library in your own program, and some
|
|
kusano |
7d535a |
of your program's files import one definition of boolean while some import the
|
|
kusano |
7d535a |
other, you can get all sorts of mysterious problems. A good preventive step
|
|
kusano |
7d535a |
is to make the IJG library use "unsigned char" for boolean. To do that,
|
|
kusano |
7d535a |
add something like this to your jconfig.h file:
|
|
kusano |
7d535a |
/* Define "boolean" as unsigned char, not enum, per Windows custom */
|
|
kusano |
7d535a |
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
|
|
kusano |
7d535a |
typedef unsigned char boolean;
|
|
kusano |
7d535a |
#endif
|
|
kusano |
7d535a |
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
|
|
kusano |
7d535a |
(This is already in jconfig.vc, by the way.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
windef.h contains the declarations
|
|
kusano |
7d535a |
#define far
|
|
kusano |
7d535a |
#define FAR far
|
|
kusano |
7d535a |
Since jmorecfg.h tries to define FAR as empty, you may get a compiler
|
|
kusano |
7d535a |
warning if you include both jpeglib.h and windef.h (which windows.h
|
|
kusano |
7d535a |
includes). To suppress the warning, you can put "#ifndef FAR"/"#endif"
|
|
kusano |
7d535a |
around the line "#define FAR" in jmorecfg.h.
|
|
kusano |
7d535a |
(Something like this is already in jmorecfg.h, by the way.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
When using the library in a Windows application, you will almost certainly
|
|
kusano |
7d535a |
want to modify or replace the error handler module jerror.c, since our
|
|
kusano |
7d535a |
default error handler does a couple of inappropriate things:
|
|
kusano |
7d535a |
1. it tries to write error and warning messages on stderr;
|
|
kusano |
7d535a |
2. in event of a fatal error, it exits by calling exit().
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
A simple stopgap solution for problem 1 is to replace the line
|
|
kusano |
7d535a |
fprintf(stderr, "%s\n", buffer);
|
|
kusano |
7d535a |
(in output_message in jerror.c) with
|
|
kusano |
7d535a |
MessageBox(GetActiveWindow(),buffer,"JPEG Error",MB_OK|MB_ICONERROR);
|
|
kusano |
7d535a |
It's highly recommended that you at least do that much, since otherwise
|
|
kusano |
7d535a |
error messages will disappear into nowhere. (Beginning with IJG v6b, this
|
|
kusano |
7d535a |
code is already present in jerror.c; just define USE_WINDOWS_MESSAGEBOX in
|
|
kusano |
7d535a |
jconfig.h to enable it.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The proper solution for problem 2 is to return control to your calling
|
|
kusano |
7d535a |
application after a library error. This can be done with the setjmp/longjmp
|
|
kusano |
7d535a |
technique discussed in libjpeg.txt and illustrated in example.c. (NOTE:
|
|
kusano |
7d535a |
some older Windows C compilers provide versions of setjmp/longjmp that
|
|
kusano |
7d535a |
don't actually work under Windows. You may need to use the Windows system
|
|
kusano |
7d535a |
functions Catch and Throw instead.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The recommended memory manager under Windows is jmemnobs.c; in other words,
|
|
kusano |
7d535a |
let Windows do any virtual memory management needed. You should NOT use
|
|
kusano |
7d535a |
jmemdos.c nor jmemdosa.asm under Windows.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
For Windows 3.1, we recommend compiling in medium or large memory model;
|
|
kusano |
7d535a |
for newer Windows versions, use a 32-bit flat memory model. (See the MS-DOS
|
|
kusano |
7d535a |
sections above for more info about memory models.) In the 16-bit memory
|
|
kusano |
7d535a |
models only, you'll need to put
|
|
kusano |
7d535a |
#define MAX_ALLOC_CHUNK 65520L /* Maximum request to malloc() */
|
|
kusano |
7d535a |
into jconfig.h to limit allocation chunks to 64Kb. (Without that, you'd
|
|
kusano |
7d535a |
have to use huge memory model, which slows things down unnecessarily.)
|
|
kusano |
7d535a |
jmemnobs.c works without modification in large or flat memory models, but to
|
|
kusano |
7d535a |
use medium model, you need to modify its jpeg_get_large and jpeg_free_large
|
|
kusano |
7d535a |
routines to allocate far memory. In any case, you might like to replace
|
|
kusano |
7d535a |
its calls to malloc and free with direct calls on Windows memory allocation
|
|
kusano |
7d535a |
functions.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
You may also want to modify jdatasrc.c and jdatadst.c to use Windows file
|
|
kusano |
7d535a |
operations rather than fread/fwrite. This is only necessary if your C
|
|
kusano |
7d535a |
compiler doesn't provide a competent implementation of C stdio functions.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
You might want to tweak the RGB_xxx macros in jmorecfg.h so that the library
|
|
kusano |
7d535a |
will accept or deliver color pixels in BGR sample order, not RGB; BGR order
|
|
kusano |
7d535a |
is usually more convenient under Windows. Note that this change will break
|
|
kusano |
7d535a |
the sample applications cjpeg/djpeg, but the library itself works fine.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Many people want to convert the IJG library into a DLL. This is reasonably
|
|
kusano |
7d535a |
straightforward, but watch out for the following:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
1. Don't try to compile as a DLL in small or medium memory model; use
|
|
kusano |
7d535a |
large model, or even better, 32-bit flat model. Many places in the IJG code
|
|
kusano |
7d535a |
assume the address of a local variable is an ordinary (not FAR) pointer;
|
|
kusano |
7d535a |
that isn't true in a medium-model DLL.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
2. Microsoft C cannot pass file pointers between applications and DLLs.
|
|
kusano |
7d535a |
(See Microsoft Knowledge Base, PSS ID Number Q50336.) So jdatasrc.c and
|
|
kusano |
7d535a |
jdatadst.c don't work if you open a file in your application and then pass
|
|
kusano |
7d535a |
the pointer to the DLL. One workaround is to make jdatasrc.c/jdatadst.c
|
|
kusano |
7d535a |
part of your main application rather than part of the DLL.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
3. You'll probably need to modify the macros GLOBAL() and EXTERN() to
|
|
kusano |
7d535a |
attach suitable linkage keywords to the exported routine names. Similarly,
|
|
kusano |
7d535a |
you'll want to modify METHODDEF() and JMETHOD() to ensure function pointers
|
|
kusano |
7d535a |
are declared in a way that lets application routines be called back through
|
|
kusano |
7d535a |
the function pointers. These macros are in jmorecfg.h. Typical definitions
|
|
kusano |
7d535a |
for a 16-bit DLL are:
|
|
kusano |
7d535a |
#define GLOBAL(type) type _far _pascal _loadds _export
|
|
kusano |
7d535a |
#define EXTERN(type) extern type _far _pascal _loadds
|
|
kusano |
7d535a |
#define METHODDEF(type) static type _far _pascal
|
|
kusano |
7d535a |
#define JMETHOD(type,methodname,arglist) \
|
|
kusano |
7d535a |
type (_far _pascal *methodname) arglist
|
|
kusano |
7d535a |
For a 32-bit DLL you may want something like
|
|
kusano |
7d535a |
#define GLOBAL(type) __declspec(dllexport) type
|
|
kusano |
7d535a |
#define EXTERN(type) extern __declspec(dllexport) type
|
|
kusano |
7d535a |
Although not all the GLOBAL routines are actually intended to be called by
|
|
kusano |
7d535a |
the application, the performance cost of making them all DLL entry points is
|
|
kusano |
7d535a |
negligible.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The unmodified IJG library presents a very C-specific application interface,
|
|
kusano |
7d535a |
so the resulting DLL is only usable from C or C++ applications. There has
|
|
kusano |
7d535a |
been some talk of writing wrapper code that would present a simpler interface
|
|
kusano |
7d535a |
usable from other languages, such as Visual Basic. This is on our to-do list
|
|
kusano |
7d535a |
but hasn't been very high priority --- any volunteers out there?
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Microsoft Windows, Borland C:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
The provided jconfig.bcc should work OK in a 32-bit Windows environment,
|
|
kusano |
7d535a |
but you'll need to tweak it in a 16-bit environment (you'd need to define
|
|
kusano |
7d535a |
NEED_FAR_POINTERS and MAX_ALLOC_CHUNK). Beware that makefile.bcc will need
|
|
kusano |
7d535a |
alteration if you want to use it for Windows --- in particular, you should
|
|
kusano |
7d535a |
use jmemnobs.c not jmemdos.c under Windows.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Borland C++ 4.5 fails with an internal compiler error when trying to compile
|
|
kusano |
7d535a |
jdmerge.c in 32-bit mode. If enough people complain, perhaps Borland will fix
|
|
kusano |
7d535a |
it. In the meantime, the simplest known workaround is to add a redundant
|
|
kusano |
7d535a |
definition of the variable range_limit in h2v1_merged_upsample(), at the head
|
|
kusano |
7d535a |
of the block that handles odd image width (about line 268 in v6 jdmerge.c):
|
|
kusano |
7d535a |
/* If image width is odd, do the last output column separately */
|
|
kusano |
7d535a |
if (cinfo->output_width & 1) {
|
|
kusano |
7d535a |
register JSAMPLE * range_limit = cinfo->sample_range_limit; /* ADD THIS */
|
|
kusano |
7d535a |
cb = GETJSAMPLE(*inptr1);
|
|
kusano |
7d535a |
Pretty bizarre, especially since the very similar routine h2v2_merged_upsample
|
|
kusano |
7d535a |
doesn't trigger the bug.
|
|
kusano |
7d535a |
Recent reports suggest that this bug does not occur with "bcc32a" (the
|
|
kusano |
7d535a |
Pentium-optimized version of the compiler).
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Another report from a user of Borland C 4.5 was that incorrect code (leading
|
|
kusano |
7d535a |
to a color shift in processed images) was produced if any of the following
|
|
kusano |
7d535a |
optimization switch combinations were used:
|
|
kusano |
7d535a |
-Ot -Og
|
|
kusano |
7d535a |
-Ot -Op
|
|
kusano |
7d535a |
-Ot -Om
|
|
kusano |
7d535a |
So try backing off on optimization if you see such a problem. (Are there
|
|
kusano |
7d535a |
several different releases all numbered "4.5"??)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Microsoft Windows, Microsoft Visual C++:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
jconfig.vc should work OK with any Microsoft compiler for a 32-bit memory
|
|
kusano |
7d535a |
model. makefile.vc is intended for command-line use. (If you are using
|
|
kusano |
7d535a |
the Developer Studio environment, you may prefer the DevStudio project
|
|
kusano |
7d535a |
files; see below.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
IJG JPEG 7 adds extern "C" to jpeglib.h. This avoids the need to put
|
|
kusano |
7d535a |
extern "C" { ... } around #include "jpeglib.h" in your C++ application.
|
|
kusano |
7d535a |
You can also force VC++ to treat the library as C++ code by renaming
|
|
kusano |
7d535a |
all the *.c files to *.cpp (and adjusting the makefile to match).
|
|
kusano |
7d535a |
In this case you also need to define the symbol DONT_USE_EXTERN_C in
|
|
kusano |
7d535a |
the configuration to prevent jpeglib.h from using extern "C".
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Microsoft Windows, Microsoft Visual C++ 6 Developer Studio:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
We include makefiles that should work as project files in DevStudio 6.0 or
|
|
kusano |
7d535a |
later. There is a library makefile that builds the IJG library as a static
|
|
kusano |
7d535a |
Win32 library, and application makefiles that build the sample applications
|
|
kusano |
7d535a |
as Win32 console applications. (Even if you only want the library, we
|
|
kusano |
7d535a |
recommend building the applications so that you can run the self-test.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
To use:
|
|
kusano |
7d535a |
1. Open the command prompt, change to the main directory and execute the
|
|
kusano |
7d535a |
command line
|
|
kusano |
7d535a |
NMAKE /f makefile.vc setup-vc6
|
|
kusano |
7d535a |
This will move jconfig.vc to jconfig.h and makefiles to project files.
|
|
kusano |
7d535a |
(Note that the renaming is critical!)
|
|
kusano |
7d535a |
2. Open the workspace file jpeg.dsw, build the library project.
|
|
kusano |
7d535a |
(If you are using DevStudio more recent than 6.0, you'll probably
|
|
kusano |
7d535a |
get a message saying that the project files are being updated.)
|
|
kusano |
7d535a |
3. Open the workspace file apps.dsw, build the application projects.
|
|
kusano |
7d535a |
4. To perform the self-test, execute the command line
|
|
kusano |
7d535a |
NMAKE /f makefile.vc test-build
|
|
kusano |
7d535a |
5. Move the application .exe files from `app`\Release to an
|
|
kusano |
7d535a |
appropriate location on your path.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Microsoft Windows, Microsoft Visual C++ 2010 Developer Studio (v10):
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
We include makefiles that should work as project files in Visual Studio
|
|
kusano |
7d535a |
2010 or later. There is a library makefile that builds the IJG library
|
|
kusano |
7d535a |
as a static Win32 library, and application makefiles that build the sample
|
|
kusano |
7d535a |
applications as Win32 console applications. (Even if you only want the
|
|
kusano |
7d535a |
library, we recommend building the applications so that you can run the
|
|
kusano |
7d535a |
self-test.)
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
To use:
|
|
kusano |
7d535a |
1. Open the command prompt, change to the main directory and execute the
|
|
kusano |
7d535a |
command line
|
|
kusano |
7d535a |
NMAKE /f makefile.vc setup-v10
|
|
kusano |
7d535a |
This will move jconfig.vc to jconfig.h and makefiles to project files.
|
|
kusano |
7d535a |
(Note that the renaming is critical!)
|
|
kusano |
7d535a |
2. Open the solution file jpeg.sln, build the library project.
|
|
kusano |
7d535a |
(If you are using Visual Studio more recent than 2010 (v10), you'll
|
|
kusano |
7d535a |
probably get a message saying that the project files are being updated.)
|
|
kusano |
7d535a |
3. Open the solution file apps.sln, build the application projects.
|
|
kusano |
7d535a |
4. To perform the self-test, execute the command line
|
|
kusano |
7d535a |
NMAKE /f makefile.vc test-build
|
|
kusano |
7d535a |
5. Move the application .exe files from `app`\Release to an
|
|
kusano |
7d535a |
appropriate location on your path.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Note:
|
|
kusano |
7d535a |
There seems to be an optimization bug in the compiler which causes the
|
|
kusano |
7d535a |
self-test to fail with the color quantization option.
|
|
kusano |
7d535a |
We have disabled optimization for the file jquant2.c in the library
|
|
kusano |
7d535a |
project file which causes the self-test to pass properly.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
OS/2, Borland C++:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
Watch out for optimization bugs in older Borland compilers; you may need
|
|
kusano |
7d535a |
to back off the optimization switch settings. See the comments in
|
|
kusano |
7d535a |
makefile.bcc.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
SGI:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
On some SGI systems, you may need to set "AR2= ar -ts" in the Makefile.
|
|
kusano |
7d535a |
If you are using configure, you can do this by saying
|
|
kusano |
7d535a |
./configure RANLIB='ar -ts'
|
|
kusano |
7d535a |
This change is not needed on all SGIs. Use it only if the make fails at the
|
|
kusano |
7d535a |
stage of linking the completed programs.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
On the MIPS R4000 architecture (Indy, etc.), the compiler option "-mips2"
|
|
kusano |
7d535a |
reportedly speeds up the float DCT method substantially, enough to make it
|
|
kusano |
7d535a |
faster than the default int method (but still slower than the fast int
|
|
kusano |
7d535a |
method). If you use -mips2, you may want to alter the default DCT method to
|
|
kusano |
7d535a |
be float. To do this, put "#define JDCT_DEFAULT JDCT_FLOAT" in jconfig.h.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
VMS:
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
On an Alpha/VMS system with MMS, be sure to use the "/Marco=Alpha=1"
|
|
kusano |
7d535a |
qualifier with MMS when building the JPEG package.
|
|
kusano |
7d535a |
|
|
kusano |
7d535a |
VAX/VMS v5.5-1 may have problems with the test step of the build procedure
|
|
kusano |
7d535a |
reporting differences when it compares the original and test images. If the
|
|
kusano |
7d535a |
error points to the last block of the files, it is most likely bogus and may
|
|
kusano |
7d535a |
be safely ignored. It seems to be because the files are Stream_LF and
|
|
kusano |
7d535a |
Backup/Compare has difficulty with the (presumably) null padded files.
|
|
kusano |
7d535a |
This problem was not observed on VAX/VMS v6.1 or AXP/VMS v6.1.
|