libjpeg API: Support reading/writing ICC profiles

This commit does the following:

-- Merges the two glueware functions (read_icc_profile() and
write_icc_profile()) from iccjpeg.c, which is contained in downstream
projects such as LCMS, Ghostscript, Mozilla, etc.  These functions were
originally intended for inclusion in libjpeg, but Tom Lane left the IJG
before that could be accomplished.  Since then, programs and libraries
that needed to embed/extract ICC profiles in JPEG files had to include
their own local copy of iccjpeg.c, which is suboptimal.

   -- The new functions were prefixed with jpeg_ and split into separate
   files for the compressor and decompressor, per the existing libjpeg
   coding standards.

   -- jpeg_write_icc_profile() was made slightly more fault-tolerant.
   It will now trigger a libjpeg error if it is called before
   jpeg_start_compress() or if it is passed NULL arguments.

   -- jpeg_read_icc_profile() was made slightly more fault-tolerant.
   It will now trigger a libjpeg error if it is called before
   jpeg_read_header() or if it is passed NULL arguments.  It will also
   now trigger libjpeg warnings if the ICC profile data is corrupt.

   -- The code comments have been wordsmithed.

   -- Note that the one-line setup_read_icc_profile() function was not
   included.  Instead, libjpeg.txt now documents the need to call
   jpeg_save_markers(cinfo, JPEG_APP0 + 2, 0xFFFF) prior to calling
   jpeg_read_header(), if jpeg_read_icc_profile() is to be used.

-- Adds documentation for the new functions to libjpeg.txt.

-- Adds an -icc switch to cjpeg and jpegtran that allows those programs
to embed an ICC profile in the JPEG files they generate.

-- Adds an -icc switch to djpeg that allows that program to extract an
ICC profile from a JPEG file while decompressing.

-- Adds appropriate unit tests for all of the above.

-- Bumps the SO_AGE of the libjpeg API library to indicate the presence
of new API functions.

Note that the licensing information was obtained from:
https://github.com/mm2/Little-CMS/issues/37#issuecomment-66450180
24 files changed
tree: d29f9f523cc89657f70e4746ea835c047e7f9814
  1. ci/
  2. cmakescripts/
  3. doc/
  4. java/
  5. md5/
  6. release/
  7. sharedlib/
  8. simd/
  9. testimages/
  10. win/
  11. .gitattributes
  12. .travis.yml
  13. appveyor.yml
  14. bmp.c
  15. bmp.h
  16. BUILDING.md
  17. cderror.h
  18. cdjpeg.c
  19. cdjpeg.h
  20. change.log
  21. ChangeLog.md
  22. cjpeg.1
  23. cjpeg.c
  24. CMakeLists.txt
  25. coderules.txt
  26. djpeg.1
  27. djpeg.c
  28. doxygen-extra.css
  29. doxygen.config
  30. example.c
  31. jaricom.c
  32. jcapimin.c
  33. jcapistd.c
  34. jcarith.c
  35. jccoefct.c
  36. jccolext.c
  37. jccolor.c
  38. jcdctmgr.c
  39. jchuff.c
  40. jchuff.h
  41. jcicc.c
  42. jcinit.c
  43. jcmainct.c
  44. jcmarker.c
  45. jcmaster.c
  46. jcomapi.c
  47. jconfig.h.in
  48. jconfig.txt
  49. jconfigint.h.in
  50. jcparam.c
  51. jcphuff.c
  52. jcprepct.c
  53. jcsample.c
  54. jcstest.c
  55. jctrans.c
  56. jdapimin.c
  57. jdapistd.c
  58. jdarith.c
  59. jdatadst-tj.c
  60. jdatadst.c
  61. jdatasrc-tj.c
  62. jdatasrc.c
  63. jdcoefct.c
  64. jdcoefct.h
  65. jdcol565.c
  66. jdcolext.c
  67. jdcolor.c
  68. jdct.h
  69. jddctmgr.c
  70. jdhuff.c
  71. jdhuff.h
  72. jdicc.c
  73. jdinput.c
  74. jdmainct.c
  75. jdmainct.h
  76. jdmarker.c
  77. jdmaster.c
  78. jdmaster.h
  79. jdmerge.c
  80. jdmrg565.c
  81. jdmrgext.c
  82. jdphuff.c
  83. jdpostct.c
  84. jdsample.c
  85. jdsample.h
  86. jdtrans.c
  87. jerror.c
  88. jerror.h
  89. jfdctflt.c
  90. jfdctfst.c
  91. jfdctint.c
  92. jidctflt.c
  93. jidctfst.c
  94. jidctint.c
  95. jidctred.c
  96. jinclude.h
  97. jmemmgr.c
  98. jmemnobs.c
  99. jmemsys.h
  100. jmorecfg.h
  101. jpeg_nbits_table.h
  102. jpegcomp.h
  103. jpegint.h
  104. jpeglib.h
  105. jpegtran.1
  106. jpegtran.c
  107. jquant1.c
  108. jquant2.c
  109. jsimd.h
  110. jsimd_none.c
  111. jsimddct.h
  112. jstdhuff.c
  113. jutils.c
  114. jversion.h
  115. libjpeg.map.in
  116. libjpeg.txt
  117. LICENSE.md
  118. rdbmp.c
  119. rdcolmap.c
  120. rdgif.c
  121. rdjpgcom.1
  122. rdjpgcom.c
  123. rdppm.c
  124. rdrle.c
  125. rdswitch.c
  126. rdtarga.c
  127. README.ijg
  128. README.md
  129. structure.txt
  130. tjbench.c
  131. tjbenchtest.in
  132. tjbenchtest.java.in
  133. tjexampletest.in
  134. tjunittest.c
  135. tjutil.c
  136. tjutil.h
  137. transupp.c
  138. transupp.h
  139. turbojpeg-jni.c
  140. turbojpeg-mapfile
  141. turbojpeg-mapfile.jni
  142. turbojpeg.c
  143. turbojpeg.h
  144. usage.txt
  145. wizard.txt
  146. wrbmp.c
  147. wrgif.c
  148. wrjpgcom.1
  149. wrjpgcom.c
  150. wrppm.c
  151. wrppm.h
  152. wrrle.c
  153. wrtarga.c