README-mozilla.txt 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. Mozilla JPEG Encoder Project
  2. ============================
  3. mozjpeg is a fork of libjpeg-turbo that aims to speed up load times of web
  4. pages by reducing the size (and, by extension, the transmission time) of JPEG
  5. files. It accomplishes this by enabling optimized Huffman trees and
  6. progressive entropy coding by default in the JPEG compressor, as well as
  7. splitting the spectrum of DCT coefficients into separate scans and using
  8. Trellis quantisation.
  9. Although it is based on libjpeg-turbo, mozjpeg is not intended to be a
  10. general-purpose or high-performance JPEG library. Its performance is highly
  11. "asymmetric". That is, the JPEG files it generates require much more time to
  12. compress than to decompress. When the default settings are used, mozjpeg is
  13. considerably slower than libjpeg-turbo or even libjpeg at compressing images.
  14. Thus, it is not generally suitable for real-time compression. It is best used
  15. as part of a web encoding workflow.
  16. libjpeg API Extensibility Framework
  17. ===================================
  18. mozjpeg's implementation of the libjpeg API includes an extensibility framework
  19. that allows new features to be added without modifying the transparent libjpeg
  20. compress/decompress structures (which would break backward ABI compatibility.)
  21. Extension parameters are placed into the opaque jpeg_comp_master structure, and
  22. a set of accessor functions and globally unique tokens allows for
  23. getting/setting those parameters without directly accessing the structure.
  24. Currently, only the accessor functions necessary to support the mozjpeg
  25. extensions are implemented, but the framework can be easily extended in the
  26. future to accommodate additional simple parameter types, complex or
  27. multi-valued parameters, or decompressor extensions.
  28. The currently-implemented accessor functions are as follows:
  29. boolean jpeg_c_bool_param_supported (j_compress_ptr cinfo,
  30. J_BOOLEAN_PARAM param)
  31. Returns TRUE if the given boolean extension parameter is supported by
  32. this implementation of the libjpeg API, or FALSE otherwise.
  33. void jpeg_c_set_bool_param (j_compress_ptr cinfo,
  34. J_BOOLEAN_PARAM param, boolean value);
  35. Set the given boolean extension parameter to the given value (TRUE or
  36. FALSE.)
  37. boolean jpeg_c_get_bool_param (j_compress_ptr cinfo, J_BOOLEAN_PARAM param)
  38. Get the value of the given boolean extension parameter (TRUE or FALSE.)
  39. boolean jpeg_c_float_param_supported (j_compress_ptr cinfo,
  40. J_FLOAT_PARAM param)
  41. Returns TRUE if the given floating point extension parameter is
  42. supported by this implementation of the libjpeg API, or FALSE
  43. otherwise.
  44. void jpeg_c_set_float_param (j_compress_ptr cinfo, J_FLOAT_PARAM param,
  45. float value)
  46. Set the given floating point extension parameter to the given value.
  47. float jpeg_c_get_float_param (j_compress_ptr cinfo, J_FLOAT_PARAM param);
  48. Get the value of the given floating point extension parameter.
  49. boolean jpeg_c_int_param_supported (j_compress_ptr cinfo,
  50. J_INT_PARAM param)
  51. Returns TRUE if the given integer extension parameter is supported by
  52. this implementation of the libjpeg API, or FALSE otherwise.
  53. void jpeg_c_set_int_param (j_compress_ptr cinfo, J_INT_PARAM param,
  54. int value)
  55. Set the given integer extension parameter to the given value.
  56. int jpeg_c_get_int_param (j_compress_ptr cinfo, J_INT_PARAM param)
  57. Get the value of the given integer extension parameter.
  58. Boolean Extension Parameters Supported by mozjpeg
  59. -------------------------------------------------
  60. * JBOOLEAN_OPTIMIZE_SCANS (default: TRUE)
  61. Specifies whether scan parameters should be optimized. Parameter
  62. optimization is done as in jpgcrush. jpeg_simple_progression() should be called
  63. after setting JBOOLEAN_OPTIMIZE_SCANS.
  64. When disabling JBOOLEAN_OPTIMIZE_SCANS, cinfo.scan_info should additionally be
  65. set to NULL to disable use of the progressive coding mode, if so desired.
  66. * JBOOLEAN_TRELLIS_QUANT (default: TRUE)
  67. Specifies whether to apply trellis quantization. For each 8x8 block, trellis
  68. quantization determines the best tradeoff between rate and distortion.
  69. * JBOOLEAN_TRELLIS_QUANT_DC (default: TRUE)
  70. Specifies whether to apply trellis quantization to DC coefficients.
  71. * JBOOLEAN_TRELLIS_EOB_OPT (default: FALSE)
  72. Specifies whether to optimize runs of zero blocks in trellis quantization.
  73. This is applicable only when JBOOLEAN_USE_SCANS_IN_TRELLIS is enabled.
  74. * JBOOLEAN_USE_LAMBDA_WEIGHT_TBL currently has no effect.
  75. * JBOOLEAN_USE_SCANS_IN_TRELLIS (default: FALSE)
  76. Specifies whether multiple scans should be considered during trellis
  77. quantization.
  78. * JBOOLEAN_TRELLIS_Q_OPT (default: FALSE)
  79. Specifies whether to optimize the quantization table after trellis
  80. quantization. If enabled, then a revised quantization table is derived so
  81. as to minimize the reconstruction error of the quantized coefficients.
  82. * JBOOLEAN_OVERSHOOT_DERINGING (default: TRUE)
  83. Specifies whether overshooting is applied to samples with extreme values
  84. (for example, 0 and 255 for 8-bit samples). Overshooting may reduce ringing
  85. artifacts from compression, in particular in areas where black text appears
  86. on a white background.
  87. Floating Point Extension Parameters Supported by mozjpeg
  88. --------------------------------------------------------
  89. * JFLOAT_LAMBDA_LOG_SCALE1 (default: 14.75)
  90. JFLOAT_LAMBDA_LOG_SCALE2 (default: 16.5)
  91. These parameters specify the lambda value used in trellis quantization. The
  92. lambda value (Lagrange multiplier) in the
  93. R + lambda * D
  94. equation is derived from
  95. lambda = 2^s1 / ((2^s2 + n) * q^2),
  96. where s1 and s2 are the values of JFLOAT_LAMBDA_LOG_SCALE1 and
  97. JFLOAT_LAMBDA_LOG_SCALE2, n is the average of the squared unquantized AC
  98. coefficients within the current 8x8 block, and q is the quantization table
  99. entry associated with the current coefficient frequency. If
  100. JFLOAT_LAMBDA_LOG_SCALE2 is 0, then an alternate form is used that does not
  101. rely on n:
  102. lambda = 2^(s1-12) / q^2.
  103. * JFLOAT_TRELLIS_DELTA_DC_WEIGHT (default: 0.0)
  104. This parameter controls how distortion is calculated in DC trellis quantization
  105. (enabled with JBOOLEAN_TRELLIS_QUANT_DC). It defines weighting between distortion
  106. of the DC coefficient and distortion of the vertical gradient of DC coefficients.
  107. The value of the parameter corresponds to the weight applied to the distortion
  108. of the vertical gradient.
  109. Integer Extension Parameters Supported by mozjpeg
  110. -------------------------------------------------
  111. * JINT_COMPRESS_PROFILE (default: JCP_MAX_COMPRESSION)
  112. Select a compression profile, which is a set of default parameters that will
  113. achieve a desired compression goal. This parameter controls the behavior of
  114. the jpeg_set_defaults() function. Thus, setting JINT_COMPRESS_PROFILE does
  115. not cause any other parameters to be modified until jpeg_set_defaults() is
  116. called. The following compression profiles are supported:
  117. - JCP_MAX_COMPRESSION (default)
  118. Increase the compression ratio as much as possible, at the expense of
  119. increased encoding time. This enables progressive entropy coding and all
  120. mozjpeg extensions.
  121. - JCP_FASTEST
  122. Use the libjpeg[-turbo] defaults (baseline entropy coding, no mozjpeg
  123. extensions enabled.)
  124. * JINT_TRELLIS_FREQ_SPLIT (default: 8)
  125. Specifies the position within the zigzag scan at which the split between
  126. scans is positioned in the context of trellis quantization.
  127. JBOOLEAN_USE_SCANS_IN_TRELLIS must be enabled for this parameter to have any
  128. effect.
  129. * JINT_TRELLIS_NUM_LOOPS (default: 1)
  130. Specifies the number of trellis quantization passes. Huffman tables are
  131. updated between passes.
  132. * JINT_BASE_QUANT_TBL_IDX (default: 3)
  133. Specifies which quantization table set to use. The following options are
  134. available:
  135. 0 = Tables from JPEG Annex K
  136. 1 = Flat table
  137. 2 = Table tuned for MSSIM on Kodak image set
  138. 3 = Table from http://www.imagemagick.org/discourse-server/viewtopic.php?f=22&t=20333&p=98008#p98008
  139. 4 = Table tuned for PSNR-HVS-M on Kodak image set
  140. 5 = Table from: Relevance of Human Vision to JPEG-DCT Compression
  141. (1992) Klein, Silverstein and Carney
  142. 6 = Table from: DCTune Perceptual Optimization of Compressed Dental X-Rays
  143. (1997) Watson, Taylor, Borthwick
  144. 7 = Table from: A Visual Detection Model for DCT Coefficient Quantization
  145. (12/9/93) Ahumada, Watson, Peterson
  146. 8 = Table from: An Improved Detection Model for DCT Coefficient Quantization
  147. (1993) Peterson, Ahumada and Watson
  148. * JINT_DC_SCAN_OPT_MODE (default: 1)
  149. Specifies the DC scan optimization mode. The following options are
  150. available:
  151. 0 = One scan for all components
  152. 1 = One scan per component
  153. 2 = Optimize between one scan for all components and one scan for the first
  154. component plus one scan for the remaining components