DRC | 101f09a | 2010-02-12 22:52:37 +0000 | [diff] [blame] | 1 | ******************************************************************************* |
| 2 | ** Background |
| 3 | ******************************************************************************* |
| 4 | |
| 5 | libjpeg-turbo is a high-speed version of libjpeg for x86 and x86-64 processors |
| 6 | which uses SIMD instructions (MMX, SSE2, etc.) to accelerate baseline JPEG |
DRC | ce1546e | 2010-02-13 23:06:03 +0000 | [diff] [blame^] | 7 | compression and decompression. libjpeg-turbo is generally 2-4x as fast |
DRC | 101f09a | 2010-02-12 22:52:37 +0000 | [diff] [blame] | 8 | as the unmodified version of libjpeg, all else being equal. |
| 9 | |
| 10 | libjpeg-turbo was originally based on libjpeg/SIMD by Miyasaka Masaru, but |
| 11 | the TigerVNC and VirtualGL projects made numerous enhancements to the codec, |
| 12 | including improved support for Mac OS X, 64-bit support, support for 32-bit |
| 13 | and big endian pixel formats, accelerated Huffman encoding/decoding, and |
| 14 | various bug fixes. The goal was to produce a fully open source codec that |
| 15 | could replace the partially closed source TurboJPEG/IPP codec used by VirtualGL |
DRC | ce1546e | 2010-02-13 23:06:03 +0000 | [diff] [blame^] | 16 | and TurboVNC. libjpeg-turbo generally performs in the range of 80-120% of |
DRC | 101f09a | 2010-02-12 22:52:37 +0000 | [diff] [blame] | 17 | TurboJPEG/IPP. It is faster in some areas but slower in others. |
| 18 | |
| 19 | It was decided to split libjpeg-turbo into a separate SDK so that other |
| 20 | projects could take advantage of this technology. The shared libraries |
| 21 | built from the libjpeg-turbo source can be used as drop-in replacements for |
| 22 | libjpeg on most systems. |
| 23 | |
| 24 | |
| 25 | ******************************************************************************* |
DRC | ce1546e | 2010-02-13 23:06:03 +0000 | [diff] [blame^] | 26 | ** License |
| 27 | ******************************************************************************* |
| 28 | |
| 29 | Some of the optimizations to the Huffman encoder/decoder were borrowed from |
| 30 | VirtualGL, and thus libjpeg-turbo, as a whole, falls under the wxWindows |
| 31 | Library Licence, Version 3.1. A copy of this license can be found in this |
| 32 | directory under LICENSE.txt. The rest of the source code, apart from these |
| 33 | modifications, falls under a less restrictive license (see README.) |
| 34 | |
| 35 | |
| 36 | ******************************************************************************* |
DRC | 101f09a | 2010-02-12 22:52:37 +0000 | [diff] [blame] | 37 | ** Building on Unix Platforms, Cygwin, and MinGW |
| 38 | ******************************************************************************* |
| 39 | |
| 40 | ================== |
| 41 | Build 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 | ====================== |
| 72 | Building libjpeg-turbo |
| 73 | ====================== |
| 74 | |
| 75 | The following procedure will build libjpeg-turbo on Linux, 32-bit OS X, and |
| 76 | Solaris/x86 systems (on Solaris, this generates a 32-bit library. See below |
| 77 | for 64-bit build instructions.) |
| 78 | |
| 79 | cd libjpeg-turbo |
| 80 | autoreconf -fiv |
| 81 | sh ./configure CFLAGS='-O3' CXXFLAGS='-O3' |
| 82 | make |
| 83 | |
| 84 | NOTE: Running autoreconf is only necessary if building libjpeg-turbo from the |
| 85 | SVN repository. |
| 86 | |
| 87 | This 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) |
DRC | bd17e2a | 2010-02-12 23:24:21 +0000 | [diff] [blame] | 94 | libjpeg-62.dll (MinGW) |
DRC | 101f09a | 2010-02-12 22:52:37 +0000 | [diff] [blame] | 95 | 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 | ======================== |
| 118 | Installing libjpeg-turbo |
| 119 | ======================== |
| 120 | |
| 121 | If you intend to install these libraries and the associated header files, then |
| 122 | replace 'make' in the instructions above with |
| 123 | |
| 124 | make install prefix={base dir} libdir={library directory} |
| 125 | |
| 126 | For example, |
| 127 | |
| 128 | make install prefix=/usr libdir=/usr/lib64 |
| 129 | |
| 130 | will overwrite the system version of libjpeg on a 64-bit RedHat-based Linux |
| 131 | machine, causing any 64-bit applications that use libjpeg to be instantly |
| 132 | accelerated. BACK UP YOUR SYSTEM'S INSTALLATION OF LIBJPEG BEFORE OVERWRITING |
| 133 | IT. |
| 134 | |
| 135 | The same can be done for 32-bit applications by building libjpeg-turbo as a |
| 136 | 32-bit library (see below) and installing with a libdir of /usr/lib. On |
| 137 | Debian-based systems, 64-bit libraries are stored in /usr/lib and 32-bit |
| 138 | libraries in /usr/lib32. On Solaris, 64-bit libraries are stored in |
| 139 | /usr/lib/amd64 and 32-bit libraries in /usr/lib. |
| 140 | |
| 141 | Mac applications typically bundle their own copies of libjpeg.62.dylib, so it |
| 142 | is not possible to globally replace libjpeg on OS X systems. However, libjpeg |
| 143 | can be replaced on an application-by-application basis, for those applications |
| 144 | which use a shared library version of it. This would generally involve copying |
| 145 | libjpeg.62.dylib into the appropriate place in the application's Contents and |
| 146 | using install_name_tool to repoint the dylib to the new directory. This |
| 147 | requires an advanced knowledge of OS X and is not recommended for most users. |
| 148 | |
| 149 | ============= |
| 150 | Build Recipes |
| 151 | ============= |
| 152 | |
| 153 | 32-bit Library Build on 64-bit Linux |
| 154 | ------------------------------------ |
| 155 | |
| 156 | Same instructions as above, but add |
| 157 | |
| 158 | --host i686-pc-linux-gnu |
| 159 | |
| 160 | to the configure command line and replace CFLAGS and CXXFLAGS with '-O3 -m32'. |
| 161 | |
| 162 | |
| 163 | 64-bit Library Build on 64-bit OS/X |
| 164 | ----------------------------------- |
| 165 | |
| 166 | Same instructions as above, but add |
| 167 | |
| 168 | --host x86_64-apple-darwin10.0.0 NASM=/opt/local/bin/nasm |
| 169 | |
| 170 | to the configure command line. NASM 2.07 from MacPorts must be installed. |
| 171 | |
| 172 | |
| 173 | 32-bit Library Build on 64-bit OS/X |
| 174 | ----------------------------------- |
| 175 | |
| 176 | Same instructions as above, but add |
| 177 | |
| 178 | LDFLAGS='-m32' |
| 179 | |
| 180 | to the configure command line and replace CFLAGS and CXXFLAGS with '-O3 -m32'. |
| 181 | |
| 182 | |
| 183 | 64-bit Library Build on 64-bit Solaris |
| 184 | -------------------------------------- |
| 185 | |
| 186 | Same instructions as above, but add |
| 187 | |
| 188 | --host x86_64-pc-solaris LDFLAGS='-m64' |
| 189 | |
| 190 | to the configure command line and replace CFLAGS and CXXFLAGS with '-O3 -m64'. |
| 191 | |
| 192 | |
DRC | bd17e2a | 2010-02-12 23:24:21 +0000 | [diff] [blame] | 193 | MinGW Build on Cygwin |
| 194 | --------------------- |
| 195 | |
| 196 | Same instructions as above, but add |
| 197 | |
| 198 | --host mingw32 |
| 199 | |
| 200 | to the configure command line. This will produce libraries which do not |
| 201 | depend on cygwin1.dll or other Cygwin DLL's. |
| 202 | |
| 203 | |
DRC | 101f09a | 2010-02-12 22:52:37 +0000 | [diff] [blame] | 204 | ******************************************************************************* |
| 205 | ** Windows (Visual C++) |
| 206 | ******************************************************************************* |
| 207 | |
| 208 | ================== |
| 209 | Build 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 | ====================== |
| 257 | Building libjpeg-turbo |
| 258 | ====================== |
| 259 | |
| 260 | cd libjpeg-turbo |
| 261 | make -f win/Makefile |
| 262 | |
| 263 | This 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 |