You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README-turbo.txt 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. *******************************************************************************
  2. ** Background
  3. *******************************************************************************
  4. libjpeg-turbo is a high-speed version of libjpeg for x86 and x86-64 processors
  5. which uses SIMD instructions (MMX, SSE2, etc.) to accelerate baseline JPEG
  6. compression and decompression. libjpeg-turbo is generally 2-4x as fast
  7. as the unmodified version of libjpeg, all else being equal.
  8. libjpeg-turbo was originally based on libjpeg/SIMD by Miyasaka Masaru, but
  9. the TigerVNC and VirtualGL projects made numerous enhancements to the codec,
  10. including improved support for Mac OS X, 64-bit support, support for 32-bit
  11. and big endian pixel formats, accelerated Huffman encoding/decoding, and
  12. various bug fixes. The goal was to produce a fully open source codec that
  13. could replace the partially closed source TurboJPEG/IPP codec used by VirtualGL
  14. and TurboVNC. libjpeg-turbo generally performs in the range of 80-120% of
  15. TurboJPEG/IPP. It is faster in some areas but slower in others.
  16. It was decided to split libjpeg-turbo into a separate SDK so that other
  17. projects could take advantage of this technology. The libjpeg-turbo shared
  18. libraries can be used as drop-in replacements for libjpeg on most systems.
  19. *******************************************************************************
  20. ** License
  21. *******************************************************************************
  22. Some of the optimizations to the Huffman encoder (jchuff.c) and decoder
  23. (jdhuff.c) were borrowed from VirtualGL, and thus any distribution of
  24. libjpeg-turbo which includes those optimizations must, as a whole, be subject
  25. to the terms of the wxWindows Library Licence, Version 3.1. A copy of this
  26. license can be found in this directory under LICENSE.txt. The wxWindows
  27. Library License is based on the LGPL but includes provisions which allow the
  28. Library to be statically linked into proprietary libraries and applications
  29. without requiring the resulting binaries to be distributed under the terms of
  30. the LGPL.
  31. The rest of the source code, apart from the Huffman codec optimizations, falls
  32. under a less restrictive, BSD-style license (see README.) You can choose to
  33. distribute libjpeg-turbo, as a whole, under this BSD-style license by simply
  34. replacing the optimized jchuff.c and jdhuff.c with their unoptimized
  35. counterparts from the libjpeg v6b source.
  36. *******************************************************************************
  37. ** Using libjpeg-turbo
  38. *******************************************************************************
  39. =============================
  40. Replacing libjpeg at Run Time
  41. =============================
  42. If a Unix application is dynamically linked with libjpeg, then you can replace
  43. libjpeg with libjpeg-turbo at run time by manipulating the LD_LIBRARY_PATH.
  44. For instance:
  45. [Using libjpeg]
  46. > time cjpeg <vgl_5674_0098.ppm >vgl_5674_0098.jpg
  47. real 0m0.392s
  48. user 0m0.074s
  49. sys 0m0.020s
  50. [Using libjpeg-turbo]
  51. > export LD_LIBRARY_PATH=/opt/libjpeg-turbo/{lib}:$LD_LIBRARY_PATH
  52. > time cjpeg <vgl_5674_0098.ppm >vgl_5674_0098.jpg
  53. real 0m0.109s
  54. user 0m0.029s
  55. sys 0m0.010s
  56. NOTE: {lib} can be lib, lib32, lib64, or lib/64, depending on the O/S and
  57. architecture.
  58. System administrators can also replace the libjpeg sym links in /usr/{lib} with
  59. links to the libjpeg dynamic library located in /opt/libjpeg-turbo/{lib}. This
  60. will effectively accelerate every dynamically linked libjpeg application on the
  61. system.
  62. The Windows distribution of the libjpeg-turbo SDK installs jpeg62.dll into
  63. c:\libjpeg-turbo\bin, and the PATH environment variable can be modified such
  64. that this directory is searched before any others that might contain
  65. jpeg62.dll. However, if jpeg62.dll also exists in an application's install
  66. directory, then Windows will load the application's version of it first. Thus,
  67. if an application ships with jpeg62.dll, then back up the application's version
  68. of jpeg62.dll and copy c:\libjpeg-turbo\bin\jpeg62.dll into the application's
  69. install directory to accelerate it.
  70. The version of jpeg62.dll distributed in the libjpeg-turbo SDK requires the
  71. Visual C++ 2008 C run time DLL (msvcr90.dll). This library ships with more
  72. recent versions of Windows, but users of older versions can obtain it from the
  73. Visual C++ 2008 Redistributable Package, which is available as a free download
  74. from Microsoft's web site.
  75. NOTE: Features of libjpeg which require passing a C run time structure, such
  76. as a file handle, from an application to libjpeg will probably not work with
  77. the distributed version of jpeg62.dll unless the application is also built to
  78. use the Visual C++ 2008 C run time DLL. In particular, this affects
  79. jpeg_stdio_dest() and jpeg_stdio_src().
  80. Mac applications typically embed their own copies of libjpeg.62.dylib inside
  81. the (hidden) application bundle, so it is not possible to globally replace
  82. libjpeg on OS X systems. If an application uses a shared library version of
  83. libjpeg, then it may be possible to replace the application's version of it.
  84. This would generally involve copying libjpeg.62.dylib into the appropriate
  85. place in the application bundle and using install_name_tool to repoint the
  86. dylib to the new directory. This requires an advanced knowledge of OS X and
  87. would not survive an upgrade or a re-install of the application. Thus, it is
  88. not recommended for most users.
  89. =======================
  90. Replacing TurboJPEG/IPP
  91. =======================
  92. libjpeg-turbo is a drop-in replacement for the TurboJPEG/IPP SDK used by
  93. VirtualGL 2.1.x and TurboVNC 0.6 (and prior.) libjpeg-turbo contains a wrapper
  94. library (TurboJPEG/OSS) that emulates the TurboJPEG API using libjpeg-turbo
  95. instead of the closed source Intel Performance Primitives. You can replace the
  96. TurboJPEG/IPP package on Linux systems with the libjpeg-turbo package in order
  97. to make existing releases of VirtualGL 2.1.x and TurboVNC use the new codec at
  98. run time. Note that the 64-bit libjpeg-turbo packages contain only 64-bit
  99. binaries, whereas the TurboJPEG/IPP 64-bit packages contained both 64-bit and
  100. 32-bit binaries. Thus, to replace a TurboJPEG/IPP 64-bit package, install
  101. both the 64-bit and 32-bit versions of libjpeg-turbo.
  102. You can also build the VirtualGL 2.1.x and TurboVNC 0.6 source code with
  103. the libjpeg-turbo SDK instead of TurboJPEG/IPP. It should work identically.
  104. libjpeg-turbo also includes static library versions of TurboJPEG/OSS, which
  105. are used to build TurboVNC 1.0 and later.
  106. ========================================
  107. Using libjpeg-turbo in Your Own Programs
  108. ========================================
  109. For the most part, libjpeg-turbo should work identically to libjpeg, so in
  110. most cases, an application can be built against libjpeg and then run against
  111. libjpeg-turbo. On Unix systems, you can build against libjpeg-turbo instead
  112. of libjpeg by setting
  113. CPATH=/opt/libjpeg-turbo/include
  114. and
  115. LIBRARY_PATH=/opt/libjpeg-turbo/{lib}
  116. ({lib} = lib32 or lib64, depending on whether you are building a 32-bit or a
  117. 64-bit application.)
  118. If using Cygwin, then set
  119. CPATH=/cygdrive/c/libjpeg-turbo-gcc[64]/include
  120. and
  121. LIBRARY_PATH=/cygdrive/c/libjpeg-turbo-gcc[64]/lib
  122. If using MinGW, then set
  123. CPATH=/c/libjpeg-turbo-gcc[64]/include
  124. and
  125. LIBRARY_PATH=/c/libjpeg-turbo-gcc[64]/lib
  126. Building against libjpeg-turbo is useful, for instance, if you want to build an
  127. application that leverages the libjpeg-turbo colorspace extensions (see below.)
  128. On Linux and Solaris systems, you would still need to manipulate the
  129. LD_LIBRARY_PATH or sym links appropriately to use libjpeg-turbo at run time.
  130. On such systems, you can pass -R /opt/libjpeg-turbo/{lib} to the linker to
  131. force the use of libjpeg-turbo at run time rather than libjpeg (also useful if
  132. you want to leverage the colorspace extensions), or you can link against the
  133. libjpeg-turbo static library.
  134. To force a Linux, Solaris, or MinGW application to link against the static
  135. version of libjpeg-turbo, you can use the following linker options:
  136. -Wl,-Bstatic -ljpeg -Wl,-Bdynamic
  137. On OS X, simply add /opt/libjpeg-turbo/lib/libjpeg.a to the linker command
  138. line (this also works on Linux and Solaris.)
  139. To build Visual C++ applications using libjpeg-turbo, add
  140. c:\libjpeg-turbo[64]\include to your system or user INCLUDE environment
  141. variable and c:\libjpeg-turbo[64]\lib to your system or user LIB environment
  142. variable, and then link against either jpeg.lib (to use jpeg62.dll) or
  143. jpeg-static.lib (to use the static version of libjpeg-turbo.)
  144. =====================
  145. Colorspace Extensions
  146. =====================
  147. libjpeg-turbo includes extensions which allow JPEG images to be compressed
  148. directly from (and decompressed directly to) buffers which use BGR, BGRA,
  149. RGBA, ABGR, and ARGB pixel ordering. This is implemented with six new
  150. colorspace constants:
  151. JCS_EXT_RGB /* red/green/blue */
  152. JCS_EXT_RGBX /* red/green/blue/x */
  153. JCS_EXT_BGR /* blue/green/red */
  154. JCS_EXT_BGRX /* blue/green/red/x */
  155. JCS_EXT_XBGR /* x/blue/green/red */
  156. JCS_EXT_XRGB /* x/red/green/blue */
  157. Setting cinfo.in_color_space (compression) or cinfo.out_color_space
  158. (decompression) to one of these values will cause libjpeg-turbo to read the
  159. red, green, and blue values from (or write them to) the appropriate position in
  160. the pixel when YUV conversion is performed.
  161. Your application can check for the existence of these extensions at compile
  162. time with:
  163. #ifdef JCS_EXTENSIONS
  164. At run time, attempting to use these extensions with a version of libjpeg
  165. that doesn't support them will result in a "Bogus input colorspace" error.