blob: b2b3471b2af2627f9ef497f67c849d405fbf9379 [file] [log] [blame]
DRC101f09a2010-02-12 22:52:37 +00001*******************************************************************************
2** Background
3*******************************************************************************
4
5libjpeg-turbo is a high-speed version of libjpeg for x86 and x86-64 processors
6which uses SIMD instructions (MMX, SSE2, etc.) to accelerate baseline JPEG
DRCce1546e2010-02-13 23:06:03 +00007compression and decompression. libjpeg-turbo is generally 2-4x as fast
DRC101f09a2010-02-12 22:52:37 +00008as the unmodified version of libjpeg, all else being equal.
9
10libjpeg-turbo was originally based on libjpeg/SIMD by Miyasaka Masaru, but
11the TigerVNC and VirtualGL projects made numerous enhancements to the codec,
12including improved support for Mac OS X, 64-bit support, support for 32-bit
13and big endian pixel formats, accelerated Huffman encoding/decoding, and
14various bug fixes. The goal was to produce a fully open source codec that
15could replace the partially closed source TurboJPEG/IPP codec used by VirtualGL
DRCce1546e2010-02-13 23:06:03 +000016and TurboVNC. libjpeg-turbo generally performs in the range of 80-120% of
DRC101f09a2010-02-12 22:52:37 +000017TurboJPEG/IPP. It is faster in some areas but slower in others.
18
19It was decided to split libjpeg-turbo into a separate SDK so that other
20projects could take advantage of this technology. The shared libraries
21built from the libjpeg-turbo source can be used as drop-in replacements for
22libjpeg on most systems.
23
24
25*******************************************************************************
DRCce1546e2010-02-13 23:06:03 +000026** License
27*******************************************************************************
28
29Some of the optimizations to the Huffman encoder/decoder were borrowed from
30VirtualGL, and thus libjpeg-turbo, as a whole, falls under the wxWindows
31Library Licence, Version 3.1. A copy of this license can be found in this
32directory under LICENSE.txt. The rest of the source code, apart from these
33modifications, falls under a less restrictive license (see README.)
34
35
36*******************************************************************************
DRC101f09a2010-02-12 22:52:37 +000037** Building on Unix Platforms, Cygwin, and MinGW
38*******************************************************************************
39
40==================
41Build Requirements
42==================
43
44-- autoconf 2.56 or later
45 * If using MinGW, this can be obtained by installing the MSYS DTK
46
47-- automake 1.7 or later
48 * If using MinGW, this can be obtained by installing the MSYS DTK
49
50-- libtool 1.4 or later
51 * If using MinGW, this can be obtained by installing the MSYS DTK
52
53-- NASM
54 * 0.98 or later is required for a 32-bit build
55 * NASM 2.05 or later is required for a 64-bit build
56 * NASM 2.07 or later is required for a 64-bit build on OS/X (10.6 "Snow
57 Leopard" or later.) This can be obtained from MacPorts
58 (http://www.macports.org/).
59
60 The NASM 2.05 RPMs do not work on older Linux systems, such as Enterprise
61 Linux 4. On such systems, you can easily build and install NASM 2.05
62 from the source RPM by executing the following as root:
63
64 ARCH=`uname -m`
65 wget http://www.nasm.us/pub/nasm/releasebuilds/2.05.01/nasm-2.05.01-1.src.rpm
66 rpmbuild --rebuild nasm-2.05.01-1.src.rpm
67 rpm -Uvh /usr/src/redhat/RPMS/$ARCH/nasm-2.05.01-1.$ARCH.rpm
68
69-- GCC v4 or later recommended for best performance
70
71======================
72Building libjpeg-turbo
73======================
74
75The following procedure will build libjpeg-turbo on Linux, 32-bit OS X, and
76Solaris/x86 systems (on Solaris, this generates a 32-bit library. See below
77for 64-bit build instructions.)
78
79 cd libjpeg-turbo
80 autoreconf -fiv
81 sh ./configure CFLAGS='-O3' CXXFLAGS='-O3'
82 make
83
84NOTE: Running autoreconf is only necessary if building libjpeg-turbo from the
85SVN repository.
86
87This will generate the following files under .libs/
88
89 libjpeg.a
90 Static link library for libjpeg-turbo
91
92 libjpeg.so.62.0.0 (Linux, Solaris)
93 libjpeg.62.dylib (OS X)
DRCbd17e2a2010-02-12 23:24:21 +000094 libjpeg-62.dll (MinGW)
DRC101f09a2010-02-12 22:52:37 +000095 cygjpeg-62.dll (Cygwin)
96 Shared library for libjpeg-turbo
97
98 libjpeg.so (Linux, Solaris)
99 libjpeg.dylib (OS X)
100 libjpeg.dll.a (Cygwin, MinGW)
101 Development stub for libjpeg-turbo shared library
102
103 libturbojpeg.a
104 Static link library for TurboJPEG/OSS
105
106 libturbojpeg.so (Linux, Solaris)
107 libturbojpeg.dylib (OS X)
108 Shared library and development stub for TurboJPEG/OSS
109
110 libturbojpeg.dll (MinGW)
111 cygturbojpeg.dll (Cygwin)
112 Shared library for TurboJPEG/OSS
113
114 libturbojpeg.dll.a (Cygwin, MinGW)
115 Development stub for TurboJPEG/OSS shared library
116
117========================
118Installing libjpeg-turbo
119========================
120
121If you intend to install these libraries and the associated header files, then
122replace 'make' in the instructions above with
123
124 make install prefix={base dir} libdir={library directory}
125
126For example,
127
128 make install prefix=/usr libdir=/usr/lib64
129
130will overwrite the system version of libjpeg on a 64-bit RedHat-based Linux
131machine, causing any 64-bit applications that use libjpeg to be instantly
132accelerated. BACK UP YOUR SYSTEM'S INSTALLATION OF LIBJPEG BEFORE OVERWRITING
133IT.
134
135The same can be done for 32-bit applications by building libjpeg-turbo as a
13632-bit library (see below) and installing with a libdir of /usr/lib. On
137Debian-based systems, 64-bit libraries are stored in /usr/lib and 32-bit
138libraries in /usr/lib32. On Solaris, 64-bit libraries are stored in
139/usr/lib/amd64 and 32-bit libraries in /usr/lib.
140
141Mac applications typically bundle their own copies of libjpeg.62.dylib, so it
142is not possible to globally replace libjpeg on OS X systems. However, libjpeg
143can be replaced on an application-by-application basis, for those applications
144which use a shared library version of it. This would generally involve copying
145libjpeg.62.dylib into the appropriate place in the application's Contents and
146using install_name_tool to repoint the dylib to the new directory. This
147requires an advanced knowledge of OS X and is not recommended for most users.
148
149=============
150Build Recipes
151=============
152
15332-bit Library Build on 64-bit Linux
154------------------------------------
155
156Same instructions as above, but add
157
158 --host i686-pc-linux-gnu
159
160to the configure command line and replace CFLAGS and CXXFLAGS with '-O3 -m32'.
161
162
16364-bit Library Build on 64-bit OS/X
164-----------------------------------
165
166Same instructions as above, but add
167
168 --host x86_64-apple-darwin10.0.0 NASM=/opt/local/bin/nasm
169
170to the configure command line. NASM 2.07 from MacPorts must be installed.
171
172
17332-bit Library Build on 64-bit OS/X
174-----------------------------------
175
176Same instructions as above, but add
177
178 LDFLAGS='-m32'
179
180to the configure command line and replace CFLAGS and CXXFLAGS with '-O3 -m32'.
181
182
18364-bit Library Build on 64-bit Solaris
184--------------------------------------
185
186Same instructions as above, but add
187
188 --host x86_64-pc-solaris LDFLAGS='-m64'
189
190to the configure command line and replace CFLAGS and CXXFLAGS with '-O3 -m64'.
191
192
DRCbd17e2a2010-02-12 23:24:21 +0000193MinGW Build on Cygwin
194---------------------
195
196Same instructions as above, but add
197
198 --host mingw32
199
200to the configure command line. This will produce libraries which do not
201depend on cygwin1.dll or other Cygwin DLL's.
202
203
DRC101f09a2010-02-12 22:52:37 +0000204*******************************************************************************
205** Windows (Visual C++)
206*******************************************************************************
207
208==================
209Build Requirements
210==================
211
212-- GNU Make v3.7 or later
213 * Can be found in MSYS (http://www.mingw.org/download.shtml) or
214 Cygwin (http://www.cygwin.com/)
215
216-- Microsoft Visual C++ 2003 or later
217 * Tested with Microsoft Visual C++ 2008 Express Edition (free download):
218
219 http://msdn.microsoft.com/vstudio/express/visualc/
220
221 * Add the compiler binary directories (for instance,
222 c:\Program Files\Microsoft Visual Studio 9.0\VC\BIN;
223 c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE)
224 to the system or user PATH environment variable prior to building
225 libjpeg-turbo.
226 * Add the compiler include directory (for instance,
227 c:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE)
228 to the system or user INCLUDE environment variable prior to building
229 libjpeg-turbo.
230 * Add the compiler library directory (for instance,
231 c:\Program Files\Microsoft Visual Studio 9.0\VC\LIB)
232 to the system or user LIB environment variable prior to building
233 libjpeg-turbo.
234
235-- Microsoft Windows SDK
236 * This is included with Microsoft Visual C++ 2008 Express Edition, but users
237 of prior editions of Visual C++ can download the SDK from:
238
239 http://msdn2.microsoft.com/en-us/windowsserver/bb980924.aspx
240
241 * Add the SDK binary directory (for instance,
242 c:\Program Files\Microsoft SDKs\Windows\v6.0A\bin)
243 to the system or user PATH environment variable prior to building
244 libjpeg-turbo.
245 * Add the SDK include directory (for instance,
246 c:\Program Files\Microsoft SDKs\Windows\v6.0A\include)
247 to the system or user INCLUDE environment variable prior to building
248 libjpeg-turbo.
249 * Add the SDK library directory (for instance,
250 c:\Program Files\Microsoft SDKs\Windows\v6.0A\lib)
251 to the system or user LIB environment variable prior to building
252 libjpeg-turbo.
253
254-- NASM (http://www.nasm.us/) 0.98 or later
255
256======================
257Building libjpeg-turbo
258======================
259
260 cd libjpeg-turbo
261 make -f win/Makefile
262
263This will generate the following files:
264
265 jpeg-static.lib Static link library for libjpeg-turbo
266 jpeg62.dll Shared library for libjpeg-turbo
267 jpeg.lib Development stub for libjpeg-turbo shared library
268 turbojpeg-static.lib Static link library for TurboJPEG/OSS
269 turbojpeg.dll Shared library for TurboJPEG/OSS
270 turbojpeg.lib Development stub for TurboJPEG/OSS shared library