rfreeimage 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (860) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +1 -0
  4. data/Rakefile +34 -0
  5. data/ext/rfreeimage/extconf.rb +35 -0
  6. data/ext/rfreeimage/rfi_main.c +389 -0
  7. data/lib/rfreeimage/image.rb +26 -0
  8. data/lib/rfreeimage/version.rb +3 -0
  9. data/lib/rfreeimage.rb +3 -0
  10. data/rfreeimage.gemspec +32 -0
  11. data/vendor/FreeImage/Makefile +34 -0
  12. data/vendor/FreeImage/Makefile.cygwin +74 -0
  13. data/vendor/FreeImage/Makefile.fip +84 -0
  14. data/vendor/FreeImage/Makefile.gnu +83 -0
  15. data/vendor/FreeImage/Makefile.iphone +96 -0
  16. data/vendor/FreeImage/Makefile.mingw +136 -0
  17. data/vendor/FreeImage/Makefile.osx +115 -0
  18. data/vendor/FreeImage/Makefile.solaris +66 -0
  19. data/vendor/FreeImage/Makefile.srcs +6 -0
  20. data/vendor/FreeImage/README.iphone +19 -0
  21. data/vendor/FreeImage/README.linux +50 -0
  22. data/vendor/FreeImage/README.minGW +236 -0
  23. data/vendor/FreeImage/README.osx +44 -0
  24. data/vendor/FreeImage/README.solaris +67 -0
  25. data/vendor/FreeImage/Source/CacheFile.h +92 -0
  26. data/vendor/FreeImage/Source/DeprecationManager/Deprecated.cpp +36 -0
  27. data/vendor/FreeImage/Source/DeprecationManager/DeprecationMgr.cpp +103 -0
  28. data/vendor/FreeImage/Source/DeprecationManager/DeprecationMgr.h +83 -0
  29. data/vendor/FreeImage/Source/FreeImage/BitmapAccess.cpp +1573 -0
  30. data/vendor/FreeImage/Source/FreeImage/CacheFile.cpp +271 -0
  31. data/vendor/FreeImage/Source/FreeImage/ColorLookup.cpp +785 -0
  32. data/vendor/FreeImage/Source/FreeImage/Conversion.cpp +551 -0
  33. data/vendor/FreeImage/Source/FreeImage/Conversion16_555.cpp +209 -0
  34. data/vendor/FreeImage/Source/FreeImage/Conversion16_565.cpp +204 -0
  35. data/vendor/FreeImage/Source/FreeImage/Conversion24.cpp +252 -0
  36. data/vendor/FreeImage/Source/FreeImage/Conversion32.cpp +345 -0
  37. data/vendor/FreeImage/Source/FreeImage/Conversion4.cpp +246 -0
  38. data/vendor/FreeImage/Source/FreeImage/Conversion8.cpp +305 -0
  39. data/vendor/FreeImage/Source/FreeImage/ConversionFloat.cpp +194 -0
  40. data/vendor/FreeImage/Source/FreeImage/ConversionRGB16.cpp +144 -0
  41. data/vendor/FreeImage/Source/FreeImage/ConversionRGBA16.cpp +147 -0
  42. data/vendor/FreeImage/Source/FreeImage/ConversionRGBAF.cpp +250 -0
  43. data/vendor/FreeImage/Source/FreeImage/ConversionRGBF.cpp +243 -0
  44. data/vendor/FreeImage/Source/FreeImage/ConversionType.cpp +699 -0
  45. data/vendor/FreeImage/Source/FreeImage/ConversionUINT16.cpp +134 -0
  46. data/vendor/FreeImage/Source/FreeImage/FreeImage.cpp +226 -0
  47. data/vendor/FreeImage/Source/FreeImage/FreeImageC.c +22 -0
  48. data/vendor/FreeImage/Source/FreeImage/FreeImageIO.cpp +175 -0
  49. data/vendor/FreeImage/Source/FreeImage/GetType.cpp +92 -0
  50. data/vendor/FreeImage/Source/FreeImage/Halftoning.cpp +474 -0
  51. data/vendor/FreeImage/Source/FreeImage/J2KHelper.cpp +591 -0
  52. data/vendor/FreeImage/Source/FreeImage/J2KHelper.h +36 -0
  53. data/vendor/FreeImage/Source/FreeImage/LFPQuantizer.cpp +208 -0
  54. data/vendor/FreeImage/Source/FreeImage/MNGHelper.cpp +1320 -0
  55. data/vendor/FreeImage/Source/FreeImage/MemoryIO.cpp +237 -0
  56. data/vendor/FreeImage/Source/FreeImage/MultiPage.cpp +974 -0
  57. data/vendor/FreeImage/Source/FreeImage/NNQuantizer.cpp +507 -0
  58. data/vendor/FreeImage/Source/FreeImage/PSDParser.cpp +1057 -0
  59. data/vendor/FreeImage/Source/FreeImage/PSDParser.h +271 -0
  60. data/vendor/FreeImage/Source/FreeImage/PixelAccess.cpp +197 -0
  61. data/vendor/FreeImage/Source/FreeImage/Plugin.cpp +822 -0
  62. data/vendor/FreeImage/Source/FreeImage/PluginBMP.cpp +1494 -0
  63. data/vendor/FreeImage/Source/FreeImage/PluginCUT.cpp +240 -0
  64. data/vendor/FreeImage/Source/FreeImage/PluginDDS.cpp +655 -0
  65. data/vendor/FreeImage/Source/FreeImage/PluginEXR.cpp +773 -0
  66. data/vendor/FreeImage/Source/FreeImage/PluginG3.cpp +433 -0
  67. data/vendor/FreeImage/Source/FreeImage/PluginGIF.cpp +1407 -0
  68. data/vendor/FreeImage/Source/FreeImage/PluginHDR.cpp +722 -0
  69. data/vendor/FreeImage/Source/FreeImage/PluginICO.cpp +824 -0
  70. data/vendor/FreeImage/Source/FreeImage/PluginIFF.cpp +459 -0
  71. data/vendor/FreeImage/Source/FreeImage/PluginJ2K.cpp +328 -0
  72. data/vendor/FreeImage/Source/FreeImage/PluginJNG.cpp +162 -0
  73. data/vendor/FreeImage/Source/FreeImage/PluginJP2.cpp +328 -0
  74. data/vendor/FreeImage/Source/FreeImage/PluginJPEG.cpp +1706 -0
  75. data/vendor/FreeImage/Source/FreeImage/PluginJXR.cpp +1475 -0
  76. data/vendor/FreeImage/Source/FreeImage/PluginKOALA.cpp +243 -0
  77. data/vendor/FreeImage/Source/FreeImage/PluginMNG.cpp +153 -0
  78. data/vendor/FreeImage/Source/FreeImage/PluginPCD.cpp +251 -0
  79. data/vendor/FreeImage/Source/FreeImage/PluginPCX.cpp +659 -0
  80. data/vendor/FreeImage/Source/FreeImage/PluginPFM.cpp +409 -0
  81. data/vendor/FreeImage/Source/FreeImage/PluginPICT.cpp +1343 -0
  82. data/vendor/FreeImage/Source/FreeImage/PluginPNG.cpp +1115 -0
  83. data/vendor/FreeImage/Source/FreeImage/PluginPNM.cpp +838 -0
  84. data/vendor/FreeImage/Source/FreeImage/PluginPSD.cpp +131 -0
  85. data/vendor/FreeImage/Source/FreeImage/PluginRAS.cpp +512 -0
  86. data/vendor/FreeImage/Source/FreeImage/PluginRAW.cpp +793 -0
  87. data/vendor/FreeImage/Source/FreeImage/PluginSGI.cpp +425 -0
  88. data/vendor/FreeImage/Source/FreeImage/PluginTARGA.cpp +1591 -0
  89. data/vendor/FreeImage/Source/FreeImage/PluginTIFF.cpp +2631 -0
  90. data/vendor/FreeImage/Source/FreeImage/PluginWBMP.cpp +372 -0
  91. data/vendor/FreeImage/Source/FreeImage/PluginWebP.cpp +698 -0
  92. data/vendor/FreeImage/Source/FreeImage/PluginXBM.cpp +399 -0
  93. data/vendor/FreeImage/Source/FreeImage/PluginXPM.cpp +487 -0
  94. data/vendor/FreeImage/Source/FreeImage/TIFFLogLuv.cpp +65 -0
  95. data/vendor/FreeImage/Source/FreeImage/ToneMapping.cpp +75 -0
  96. data/vendor/FreeImage/Source/FreeImage/WuQuantizer.cpp +559 -0
  97. data/vendor/FreeImage/Source/FreeImage/ZLibInterface.cpp +223 -0
  98. data/vendor/FreeImage/Source/FreeImage/tmoColorConvert.cpp +479 -0
  99. data/vendor/FreeImage/Source/FreeImage/tmoDrago03.cpp +295 -0
  100. data/vendor/FreeImage/Source/FreeImage/tmoFattal02.cpp +689 -0
  101. data/vendor/FreeImage/Source/FreeImage/tmoReinhard05.cpp +260 -0
  102. data/vendor/FreeImage/Source/FreeImage.h +1153 -0
  103. data/vendor/FreeImage/Source/FreeImageIO.h +63 -0
  104. data/vendor/FreeImage/Source/FreeImageToolkit/BSplineRotate.cpp +730 -0
  105. data/vendor/FreeImage/Source/FreeImageToolkit/Background.cpp +895 -0
  106. data/vendor/FreeImage/Source/FreeImageToolkit/Channels.cpp +488 -0
  107. data/vendor/FreeImage/Source/FreeImageToolkit/ClassicRotate.cpp +917 -0
  108. data/vendor/FreeImage/Source/FreeImageToolkit/Colors.cpp +967 -0
  109. data/vendor/FreeImage/Source/FreeImageToolkit/CopyPaste.cpp +861 -0
  110. data/vendor/FreeImage/Source/FreeImageToolkit/Display.cpp +230 -0
  111. data/vendor/FreeImage/Source/FreeImageToolkit/Filters.h +287 -0
  112. data/vendor/FreeImage/Source/FreeImageToolkit/Flip.cpp +166 -0
  113. data/vendor/FreeImage/Source/FreeImageToolkit/JPEGTransform.cpp +623 -0
  114. data/vendor/FreeImage/Source/FreeImageToolkit/MultigridPoissonSolver.cpp +505 -0
  115. data/vendor/FreeImage/Source/FreeImageToolkit/Rescale.cpp +192 -0
  116. data/vendor/FreeImage/Source/FreeImageToolkit/Resize.cpp +2116 -0
  117. data/vendor/FreeImage/Source/FreeImageToolkit/Resize.h +196 -0
  118. data/vendor/FreeImage/Source/LibJPEG/ansi2knr.c +739 -0
  119. data/vendor/FreeImage/Source/LibJPEG/cderror.h +134 -0
  120. data/vendor/FreeImage/Source/LibJPEG/cdjpeg.c +181 -0
  121. data/vendor/FreeImage/Source/LibJPEG/cdjpeg.h +187 -0
  122. data/vendor/FreeImage/Source/LibJPEG/cjpeg.c +664 -0
  123. data/vendor/FreeImage/Source/LibJPEG/ckconfig.c +402 -0
  124. data/vendor/FreeImage/Source/LibJPEG/djpeg.c +617 -0
  125. data/vendor/FreeImage/Source/LibJPEG/example.c +433 -0
  126. data/vendor/FreeImage/Source/LibJPEG/jaricom.c +153 -0
  127. data/vendor/FreeImage/Source/LibJPEG/jcapimin.c +288 -0
  128. data/vendor/FreeImage/Source/LibJPEG/jcapistd.c +162 -0
  129. data/vendor/FreeImage/Source/LibJPEG/jcarith.c +944 -0
  130. data/vendor/FreeImage/Source/LibJPEG/jccoefct.c +454 -0
  131. data/vendor/FreeImage/Source/LibJPEG/jccolor.c +604 -0
  132. data/vendor/FreeImage/Source/LibJPEG/jcdctmgr.c +477 -0
  133. data/vendor/FreeImage/Source/LibJPEG/jchuff.c +1573 -0
  134. data/vendor/FreeImage/Source/LibJPEG/jcinit.c +84 -0
  135. data/vendor/FreeImage/Source/LibJPEG/jcmainct.c +297 -0
  136. data/vendor/FreeImage/Source/LibJPEG/jcmarker.c +719 -0
  137. data/vendor/FreeImage/Source/LibJPEG/jcmaster.c +856 -0
  138. data/vendor/FreeImage/Source/LibJPEG/jcomapi.c +106 -0
  139. data/vendor/FreeImage/Source/LibJPEG/jconfig.h +161 -0
  140. data/vendor/FreeImage/Source/LibJPEG/jcparam.c +675 -0
  141. data/vendor/FreeImage/Source/LibJPEG/jcprepct.c +358 -0
  142. data/vendor/FreeImage/Source/LibJPEG/jcsample.c +545 -0
  143. data/vendor/FreeImage/Source/LibJPEG/jctrans.c +385 -0
  144. data/vendor/FreeImage/Source/LibJPEG/jdapimin.c +399 -0
  145. data/vendor/FreeImage/Source/LibJPEG/jdapistd.c +276 -0
  146. data/vendor/FreeImage/Source/LibJPEG/jdarith.c +796 -0
  147. data/vendor/FreeImage/Source/LibJPEG/jdatadst.c +270 -0
  148. data/vendor/FreeImage/Source/LibJPEG/jdatasrc.c +275 -0
  149. data/vendor/FreeImage/Source/LibJPEG/jdcoefct.c +741 -0
  150. data/vendor/FreeImage/Source/LibJPEG/jdcolor.c +748 -0
  151. data/vendor/FreeImage/Source/LibJPEG/jdct.h +393 -0
  152. data/vendor/FreeImage/Source/LibJPEG/jddctmgr.c +384 -0
  153. data/vendor/FreeImage/Source/LibJPEG/jdhuff.c +1554 -0
  154. data/vendor/FreeImage/Source/LibJPEG/jdinput.c +662 -0
  155. data/vendor/FreeImage/Source/LibJPEG/jdmainct.c +513 -0
  156. data/vendor/FreeImage/Source/LibJPEG/jdmarker.c +1511 -0
  157. data/vendor/FreeImage/Source/LibJPEG/jdmaster.c +543 -0
  158. data/vendor/FreeImage/Source/LibJPEG/jdmerge.c +401 -0
  159. data/vendor/FreeImage/Source/LibJPEG/jdpostct.c +290 -0
  160. data/vendor/FreeImage/Source/LibJPEG/jdsample.c +361 -0
  161. data/vendor/FreeImage/Source/LibJPEG/jdtrans.c +140 -0
  162. data/vendor/FreeImage/Source/LibJPEG/jerror.c +253 -0
  163. data/vendor/FreeImage/Source/LibJPEG/jerror.h +304 -0
  164. data/vendor/FreeImage/Source/LibJPEG/jfdctflt.c +174 -0
  165. data/vendor/FreeImage/Source/LibJPEG/jfdctfst.c +230 -0
  166. data/vendor/FreeImage/Source/LibJPEG/jfdctint.c +4406 -0
  167. data/vendor/FreeImage/Source/LibJPEG/jidctflt.c +235 -0
  168. data/vendor/FreeImage/Source/LibJPEG/jidctfst.c +368 -0
  169. data/vendor/FreeImage/Source/LibJPEG/jidctint.c +5179 -0
  170. data/vendor/FreeImage/Source/LibJPEG/jinclude.h +91 -0
  171. data/vendor/FreeImage/Source/LibJPEG/jmemansi.c +167 -0
  172. data/vendor/FreeImage/Source/LibJPEG/jmemdos.c +638 -0
  173. data/vendor/FreeImage/Source/LibJPEG/jmemmac.c +289 -0
  174. data/vendor/FreeImage/Source/LibJPEG/jmemmgr.c +1119 -0
  175. data/vendor/FreeImage/Source/LibJPEG/jmemname.c +276 -0
  176. data/vendor/FreeImage/Source/LibJPEG/jmemnobs.c +109 -0
  177. data/vendor/FreeImage/Source/LibJPEG/jmemsys.h +198 -0
  178. data/vendor/FreeImage/Source/LibJPEG/jmorecfg.h +442 -0
  179. data/vendor/FreeImage/Source/LibJPEG/jpegint.h +426 -0
  180. data/vendor/FreeImage/Source/LibJPEG/jpeglib.h +1180 -0
  181. data/vendor/FreeImage/Source/LibJPEG/jpegtran.c +577 -0
  182. data/vendor/FreeImage/Source/LibJPEG/jquant1.c +857 -0
  183. data/vendor/FreeImage/Source/LibJPEG/jquant2.c +1311 -0
  184. data/vendor/FreeImage/Source/LibJPEG/jutils.c +227 -0
  185. data/vendor/FreeImage/Source/LibJPEG/jversion.h +14 -0
  186. data/vendor/FreeImage/Source/LibJPEG/rdbmp.c +480 -0
  187. data/vendor/FreeImage/Source/LibJPEG/rdcolmap.c +253 -0
  188. data/vendor/FreeImage/Source/LibJPEG/rdgif.c +38 -0
  189. data/vendor/FreeImage/Source/LibJPEG/rdjpgcom.c +515 -0
  190. data/vendor/FreeImage/Source/LibJPEG/rdppm.c +459 -0
  191. data/vendor/FreeImage/Source/LibJPEG/rdrle.c +387 -0
  192. data/vendor/FreeImage/Source/LibJPEG/rdswitch.c +365 -0
  193. data/vendor/FreeImage/Source/LibJPEG/rdtarga.c +500 -0
  194. data/vendor/FreeImage/Source/LibJPEG/transupp.c +1763 -0
  195. data/vendor/FreeImage/Source/LibJPEG/transupp.h +219 -0
  196. data/vendor/FreeImage/Source/LibJPEG/wrbmp.c +442 -0
  197. data/vendor/FreeImage/Source/LibJPEG/wrgif.c +399 -0
  198. data/vendor/FreeImage/Source/LibJPEG/wrjpgcom.c +583 -0
  199. data/vendor/FreeImage/Source/LibJPEG/wrppm.c +269 -0
  200. data/vendor/FreeImage/Source/LibJPEG/wrrle.c +305 -0
  201. data/vendor/FreeImage/Source/LibJPEG/wrtarga.c +253 -0
  202. data/vendor/FreeImage/Source/LibJXR/common/include/guiddef.h +230 -0
  203. data/vendor/FreeImage/Source/LibJXR/common/include/wmsal.h +757 -0
  204. data/vendor/FreeImage/Source/LibJXR/common/include/wmspecstring.h +342 -0
  205. data/vendor/FreeImage/Source/LibJXR/common/include/wmspecstrings_adt.h +71 -0
  206. data/vendor/FreeImage/Source/LibJXR/common/include/wmspecstrings_strict.h +1096 -0
  207. data/vendor/FreeImage/Source/LibJXR/common/include/wmspecstrings_undef.h +406 -0
  208. data/vendor/FreeImage/Source/LibJXR/image/decode/JXRTranscode.c +987 -0
  209. data/vendor/FreeImage/Source/LibJXR/image/decode/decode.c +200 -0
  210. data/vendor/FreeImage/Source/LibJXR/image/decode/decode.h +143 -0
  211. data/vendor/FreeImage/Source/LibJXR/image/decode/postprocess.c +288 -0
  212. data/vendor/FreeImage/Source/LibJXR/image/decode/segdec.c +1205 -0
  213. data/vendor/FreeImage/Source/LibJXR/image/decode/strInvTransform.c +1888 -0
  214. data/vendor/FreeImage/Source/LibJXR/image/decode/strPredQuantDec.c +539 -0
  215. data/vendor/FreeImage/Source/LibJXR/image/decode/strdec.c +3628 -0
  216. data/vendor/FreeImage/Source/LibJXR/image/decode/strdec_x86.c +1640 -0
  217. data/vendor/FreeImage/Source/LibJXR/image/encode/encode.c +144 -0
  218. data/vendor/FreeImage/Source/LibJXR/image/encode/encode.h +113 -0
  219. data/vendor/FreeImage/Source/LibJXR/image/encode/segenc.c +1186 -0
  220. data/vendor/FreeImage/Source/LibJXR/image/encode/strFwdTransform.c +1111 -0
  221. data/vendor/FreeImage/Source/LibJXR/image/encode/strPredQuantEnc.c +511 -0
  222. data/vendor/FreeImage/Source/LibJXR/image/encode/strenc.c +2370 -0
  223. data/vendor/FreeImage/Source/LibJXR/image/encode/strenc_x86.c +409 -0
  224. data/vendor/FreeImage/Source/LibJXR/image/sys/adapthuff.c +511 -0
  225. data/vendor/FreeImage/Source/LibJXR/image/sys/ansi.h +61 -0
  226. data/vendor/FreeImage/Source/LibJXR/image/sys/common.h +131 -0
  227. data/vendor/FreeImage/Source/LibJXR/image/sys/image.c +183 -0
  228. data/vendor/FreeImage/Source/LibJXR/image/sys/perfTimer.h +115 -0
  229. data/vendor/FreeImage/Source/LibJXR/image/sys/perfTimerANSI.c +274 -0
  230. data/vendor/FreeImage/Source/LibJXR/image/sys/strPredQuant.c +306 -0
  231. data/vendor/FreeImage/Source/LibJXR/image/sys/strTransform.c +85 -0
  232. data/vendor/FreeImage/Source/LibJXR/image/sys/strTransform.h +50 -0
  233. data/vendor/FreeImage/Source/LibJXR/image/sys/strcodec.c +1251 -0
  234. data/vendor/FreeImage/Source/LibJXR/image/sys/strcodec.h +681 -0
  235. data/vendor/FreeImage/Source/LibJXR/image/sys/windowsmediaphoto.h +515 -0
  236. data/vendor/FreeImage/Source/LibJXR/image/sys/xplatform_image.h +84 -0
  237. data/vendor/FreeImage/Source/LibJXR/image/x86/x86.h +58 -0
  238. data/vendor/FreeImage/Source/LibJXR/jxrgluelib/JXRGlue.c +930 -0
  239. data/vendor/FreeImage/Source/LibJXR/jxrgluelib/JXRGlue.h +636 -0
  240. data/vendor/FreeImage/Source/LibJXR/jxrgluelib/JXRGlueJxr.c +2246 -0
  241. data/vendor/FreeImage/Source/LibJXR/jxrgluelib/JXRGluePFC.c +2338 -0
  242. data/vendor/FreeImage/Source/LibJXR/jxrgluelib/JXRMeta.c +905 -0
  243. data/vendor/FreeImage/Source/LibJXR/jxrgluelib/JXRMeta.h +258 -0
  244. data/vendor/FreeImage/Source/LibOpenJPEG/bio.c +188 -0
  245. data/vendor/FreeImage/Source/LibOpenJPEG/bio.h +128 -0
  246. data/vendor/FreeImage/Source/LibOpenJPEG/cidx_manager.c +239 -0
  247. data/vendor/FreeImage/Source/LibOpenJPEG/cidx_manager.h +68 -0
  248. data/vendor/FreeImage/Source/LibOpenJPEG/cio.c +644 -0
  249. data/vendor/FreeImage/Source/LibOpenJPEG/cio.h +393 -0
  250. data/vendor/FreeImage/Source/LibOpenJPEG/dwt.c +919 -0
  251. data/vendor/FreeImage/Source/LibOpenJPEG/dwt.h +116 -0
  252. data/vendor/FreeImage/Source/LibOpenJPEG/event.c +141 -0
  253. data/vendor/FreeImage/Source/LibOpenJPEG/event.h +97 -0
  254. data/vendor/FreeImage/Source/LibOpenJPEG/function_list.c +114 -0
  255. data/vendor/FreeImage/Source/LibOpenJPEG/function_list.h +126 -0
  256. data/vendor/FreeImage/Source/LibOpenJPEG/image.c +235 -0
  257. data/vendor/FreeImage/Source/LibOpenJPEG/image.h +63 -0
  258. data/vendor/FreeImage/Source/LibOpenJPEG/indexbox_manager.h +148 -0
  259. data/vendor/FreeImage/Source/LibOpenJPEG/invert.c +289 -0
  260. data/vendor/FreeImage/Source/LibOpenJPEG/invert.h +59 -0
  261. data/vendor/FreeImage/Source/LibOpenJPEG/j2k.c +10238 -0
  262. data/vendor/FreeImage/Source/LibOpenJPEG/j2k.h +838 -0
  263. data/vendor/FreeImage/Source/LibOpenJPEG/jp2.c +2776 -0
  264. data/vendor/FreeImage/Source/LibOpenJPEG/jp2.h +490 -0
  265. data/vendor/FreeImage/Source/LibOpenJPEG/mct.c +319 -0
  266. data/vendor/FreeImage/Source/LibOpenJPEG/mct.h +149 -0
  267. data/vendor/FreeImage/Source/LibOpenJPEG/mqc.c +604 -0
  268. data/vendor/FreeImage/Source/LibOpenJPEG/mqc.h +201 -0
  269. data/vendor/FreeImage/Source/LibOpenJPEG/openjpeg.c +955 -0
  270. data/vendor/FreeImage/Source/LibOpenJPEG/openjpeg.h +1475 -0
  271. data/vendor/FreeImage/Source/LibOpenJPEG/opj_clock.c +59 -0
  272. data/vendor/FreeImage/Source/LibOpenJPEG/opj_clock.h +54 -0
  273. data/vendor/FreeImage/Source/LibOpenJPEG/opj_codec.h +160 -0
  274. data/vendor/FreeImage/Source/LibOpenJPEG/opj_config.h +9 -0
  275. data/vendor/FreeImage/Source/LibOpenJPEG/opj_config_private.h +16 -0
  276. data/vendor/FreeImage/Source/LibOpenJPEG/opj_includes.h +175 -0
  277. data/vendor/FreeImage/Source/LibOpenJPEG/opj_intmath.h +172 -0
  278. data/vendor/FreeImage/Source/LibOpenJPEG/opj_inttypes.h +43 -0
  279. data/vendor/FreeImage/Source/LibOpenJPEG/opj_malloc.h +180 -0
  280. data/vendor/FreeImage/Source/LibOpenJPEG/opj_stdint.h +47 -0
  281. data/vendor/FreeImage/Source/LibOpenJPEG/phix_manager.c +191 -0
  282. data/vendor/FreeImage/Source/LibOpenJPEG/pi.c +1870 -0
  283. data/vendor/FreeImage/Source/LibOpenJPEG/pi.h +182 -0
  284. data/vendor/FreeImage/Source/LibOpenJPEG/ppix_manager.c +194 -0
  285. data/vendor/FreeImage/Source/LibOpenJPEG/raw.c +89 -0
  286. data/vendor/FreeImage/Source/LibOpenJPEG/raw.h +100 -0
  287. data/vendor/FreeImage/Source/LibOpenJPEG/t1.c +1751 -0
  288. data/vendor/FreeImage/Source/LibOpenJPEG/t1.h +157 -0
  289. data/vendor/FreeImage/Source/LibOpenJPEG/t1_generate_luts.c +276 -0
  290. data/vendor/FreeImage/Source/LibOpenJPEG/t1_luts.h +143 -0
  291. data/vendor/FreeImage/Source/LibOpenJPEG/t2.c +1334 -0
  292. data/vendor/FreeImage/Source/LibOpenJPEG/t2.h +127 -0
  293. data/vendor/FreeImage/Source/LibOpenJPEG/tcd.c +2123 -0
  294. data/vendor/FreeImage/Source/LibOpenJPEG/tcd.h +348 -0
  295. data/vendor/FreeImage/Source/LibOpenJPEG/tgt.c +331 -0
  296. data/vendor/FreeImage/Source/LibOpenJPEG/tgt.h +140 -0
  297. data/vendor/FreeImage/Source/LibOpenJPEG/thix_manager.c +134 -0
  298. data/vendor/FreeImage/Source/LibOpenJPEG/tpix_manager.c +185 -0
  299. data/vendor/FreeImage/Source/LibPNG/example.c +1061 -0
  300. data/vendor/FreeImage/Source/LibPNG/png.c +4493 -0
  301. data/vendor/FreeImage/Source/LibPNG/png.h +3282 -0
  302. data/vendor/FreeImage/Source/LibPNG/pngconf.h +644 -0
  303. data/vendor/FreeImage/Source/LibPNG/pngdebug.h +154 -0
  304. data/vendor/FreeImage/Source/LibPNG/pngerror.c +963 -0
  305. data/vendor/FreeImage/Source/LibPNG/pngget.c +1213 -0
  306. data/vendor/FreeImage/Source/LibPNG/pnginfo.h +260 -0
  307. data/vendor/FreeImage/Source/LibPNG/pnglibconf.h +218 -0
  308. data/vendor/FreeImage/Source/LibPNG/pngmem.c +281 -0
  309. data/vendor/FreeImage/Source/LibPNG/pngpread.c +1168 -0
  310. data/vendor/FreeImage/Source/LibPNG/pngpriv.h +1944 -0
  311. data/vendor/FreeImage/Source/LibPNG/pngread.c +4121 -0
  312. data/vendor/FreeImage/Source/LibPNG/pngrio.c +120 -0
  313. data/vendor/FreeImage/Source/LibPNG/pngrtran.c +4994 -0
  314. data/vendor/FreeImage/Source/LibPNG/pngrutil.c +4474 -0
  315. data/vendor/FreeImage/Source/LibPNG/pngset.c +1611 -0
  316. data/vendor/FreeImage/Source/LibPNG/pngstruct.h +489 -0
  317. data/vendor/FreeImage/Source/LibPNG/pngtest.c +2011 -0
  318. data/vendor/FreeImage/Source/LibPNG/pngtrans.c +849 -0
  319. data/vendor/FreeImage/Source/LibPNG/pngwio.c +168 -0
  320. data/vendor/FreeImage/Source/LibPNG/pngwrite.c +2455 -0
  321. data/vendor/FreeImage/Source/LibPNG/pngwtran.c +574 -0
  322. data/vendor/FreeImage/Source/LibPNG/pngwutil.c +3029 -0
  323. data/vendor/FreeImage/Source/LibRawLite/dcraw/dcraw.c +15462 -0
  324. data/vendor/FreeImage/Source/LibRawLite/internal/aahd_demosaic.cpp +706 -0
  325. data/vendor/FreeImage/Source/LibRawLite/internal/dcb_demosaicing.c +710 -0
  326. data/vendor/FreeImage/Source/LibRawLite/internal/dcraw_common.cpp +13593 -0
  327. data/vendor/FreeImage/Source/LibRawLite/internal/dcraw_fileio.cpp +240 -0
  328. data/vendor/FreeImage/Source/LibRawLite/internal/defines.h +167 -0
  329. data/vendor/FreeImage/Source/LibRawLite/internal/demosaic_packs.cpp +99 -0
  330. data/vendor/FreeImage/Source/LibRawLite/internal/dht_demosaic.cpp +873 -0
  331. data/vendor/FreeImage/Source/LibRawLite/internal/libraw_internal_funcs.h +282 -0
  332. data/vendor/FreeImage/Source/LibRawLite/internal/libraw_x3f.cpp +1919 -0
  333. data/vendor/FreeImage/Source/LibRawLite/internal/var_defines.h +216 -0
  334. data/vendor/FreeImage/Source/LibRawLite/internal/wf_filtering.cpp +1950 -0
  335. data/vendor/FreeImage/Source/LibRawLite/libraw/libraw.h +338 -0
  336. data/vendor/FreeImage/Source/LibRawLite/libraw/libraw_alloc.h +99 -0
  337. data/vendor/FreeImage/Source/LibRawLite/libraw/libraw_const.h +233 -0
  338. data/vendor/FreeImage/Source/LibRawLite/libraw/libraw_datastream.h +238 -0
  339. data/vendor/FreeImage/Source/LibRawLite/libraw/libraw_internal.h +225 -0
  340. data/vendor/FreeImage/Source/LibRawLite/libraw/libraw_types.h +442 -0
  341. data/vendor/FreeImage/Source/LibRawLite/libraw/libraw_version.h +62 -0
  342. data/vendor/FreeImage/Source/LibRawLite/src/libraw_c_api.cpp +230 -0
  343. data/vendor/FreeImage/Source/LibRawLite/src/libraw_cxx.cpp +4533 -0
  344. data/vendor/FreeImage/Source/LibRawLite/src/libraw_datastream.cpp +703 -0
  345. data/vendor/FreeImage/Source/LibTIFF4/mkg3states.c +451 -0
  346. data/vendor/FreeImage/Source/LibTIFF4/mkspans.c +82 -0
  347. data/vendor/FreeImage/Source/LibTIFF4/t4.h +292 -0
  348. data/vendor/FreeImage/Source/LibTIFF4/tif_aux.c +358 -0
  349. data/vendor/FreeImage/Source/LibTIFF4/tif_close.c +140 -0
  350. data/vendor/FreeImage/Source/LibTIFF4/tif_codec.c +166 -0
  351. data/vendor/FreeImage/Source/LibTIFF4/tif_color.c +287 -0
  352. data/vendor/FreeImage/Source/LibTIFF4/tif_compress.c +304 -0
  353. data/vendor/FreeImage/Source/LibTIFF4/tif_config.h +97 -0
  354. data/vendor/FreeImage/Source/LibTIFF4/tif_config.vc.h +74 -0
  355. data/vendor/FreeImage/Source/LibTIFF4/tif_config.wince.h +71 -0
  356. data/vendor/FreeImage/Source/LibTIFF4/tif_dir.c +1700 -0
  357. data/vendor/FreeImage/Source/LibTIFF4/tif_dir.h +308 -0
  358. data/vendor/FreeImage/Source/LibTIFF4/tif_dirinfo.c +959 -0
  359. data/vendor/FreeImage/Source/LibTIFF4/tif_dirread.c +5640 -0
  360. data/vendor/FreeImage/Source/LibTIFF4/tif_dirwrite.c +2910 -0
  361. data/vendor/FreeImage/Source/LibTIFF4/tif_dumpmode.c +143 -0
  362. data/vendor/FreeImage/Source/LibTIFF4/tif_error.c +80 -0
  363. data/vendor/FreeImage/Source/LibTIFF4/tif_extension.c +118 -0
  364. data/vendor/FreeImage/Source/LibTIFF4/tif_fax3.c +1595 -0
  365. data/vendor/FreeImage/Source/LibTIFF4/tif_fax3.h +538 -0
  366. data/vendor/FreeImage/Source/LibTIFF4/tif_fax3sm.c +1260 -0
  367. data/vendor/FreeImage/Source/LibTIFF4/tif_flush.c +118 -0
  368. data/vendor/FreeImage/Source/LibTIFF4/tif_getimage.c +2890 -0
  369. data/vendor/FreeImage/Source/LibTIFF4/tif_jbig.c +213 -0
  370. data/vendor/FreeImage/Source/LibTIFF4/tif_jpeg.c +2354 -0
  371. data/vendor/FreeImage/Source/LibTIFF4/tif_jpeg_12.c +65 -0
  372. data/vendor/FreeImage/Source/LibTIFF4/tif_luv.c +1683 -0
  373. data/vendor/FreeImage/Source/LibTIFF4/tif_lzma.c +495 -0
  374. data/vendor/FreeImage/Source/LibTIFF4/tif_lzw.c +1169 -0
  375. data/vendor/FreeImage/Source/LibTIFF4/tif_next.c +181 -0
  376. data/vendor/FreeImage/Source/LibTIFF4/tif_ojpeg.c +2501 -0
  377. data/vendor/FreeImage/Source/LibTIFF4/tif_open.c +725 -0
  378. data/vendor/FreeImage/Source/LibTIFF4/tif_packbits.c +300 -0
  379. data/vendor/FreeImage/Source/LibTIFF4/tif_pixarlog.c +1442 -0
  380. data/vendor/FreeImage/Source/LibTIFF4/tif_predict.c +764 -0
  381. data/vendor/FreeImage/Source/LibTIFF4/tif_predict.h +77 -0
  382. data/vendor/FreeImage/Source/LibTIFF4/tif_print.c +716 -0
  383. data/vendor/FreeImage/Source/LibTIFF4/tif_read.c +1086 -0
  384. data/vendor/FreeImage/Source/LibTIFF4/tif_strip.c +383 -0
  385. data/vendor/FreeImage/Source/LibTIFF4/tif_swab.c +310 -0
  386. data/vendor/FreeImage/Source/LibTIFF4/tif_thunder.c +207 -0
  387. data/vendor/FreeImage/Source/LibTIFF4/tif_tile.c +299 -0
  388. data/vendor/FreeImage/Source/LibTIFF4/tif_unix.c +325 -0
  389. data/vendor/FreeImage/Source/LibTIFF4/tif_version.c +40 -0
  390. data/vendor/FreeImage/Source/LibTIFF4/tif_vms.c +603 -0
  391. data/vendor/FreeImage/Source/LibTIFF4/tif_warning.c +81 -0
  392. data/vendor/FreeImage/Source/LibTIFF4/tif_win32.c +443 -0
  393. data/vendor/FreeImage/Source/LibTIFF4/tif_wince.c +293 -0
  394. data/vendor/FreeImage/Source/LibTIFF4/tif_write.c +771 -0
  395. data/vendor/FreeImage/Source/LibTIFF4/tif_zip.c +472 -0
  396. data/vendor/FreeImage/Source/LibTIFF4/tiff.h +681 -0
  397. data/vendor/FreeImage/Source/LibTIFF4/tiffconf.h +170 -0
  398. data/vendor/FreeImage/Source/LibTIFF4/tiffconf.vc.h +160 -0
  399. data/vendor/FreeImage/Source/LibTIFF4/tiffconf.wince.h +121 -0
  400. data/vendor/FreeImage/Source/LibTIFF4/tiffio.h +557 -0
  401. data/vendor/FreeImage/Source/LibTIFF4/tiffiop.h +367 -0
  402. data/vendor/FreeImage/Source/LibTIFF4/tiffvers.h +9 -0
  403. data/vendor/FreeImage/Source/LibTIFF4/uvcode.h +180 -0
  404. data/vendor/FreeImage/Source/LibWebP/src/dec/alphai.h +55 -0
  405. data/vendor/FreeImage/Source/LibWebP/src/dec/dec.alpha.c +167 -0
  406. data/vendor/FreeImage/Source/LibWebP/src/dec/dec.buffer.c +249 -0
  407. data/vendor/FreeImage/Source/LibWebP/src/dec/dec.frame.c +827 -0
  408. data/vendor/FreeImage/Source/LibWebP/src/dec/dec.idec.c +857 -0
  409. data/vendor/FreeImage/Source/LibWebP/src/dec/dec.io.c +640 -0
  410. data/vendor/FreeImage/Source/LibWebP/src/dec/dec.quant.c +110 -0
  411. data/vendor/FreeImage/Source/LibWebP/src/dec/dec.tree.c +525 -0
  412. data/vendor/FreeImage/Source/LibWebP/src/dec/dec.vp8.c +663 -0
  413. data/vendor/FreeImage/Source/LibWebP/src/dec/dec.vp8l.c +1584 -0
  414. data/vendor/FreeImage/Source/LibWebP/src/dec/dec.webp.c +834 -0
  415. data/vendor/FreeImage/Source/LibWebP/src/dec/decode_vp8.h +185 -0
  416. data/vendor/FreeImage/Source/LibWebP/src/dec/vp8i.h +353 -0
  417. data/vendor/FreeImage/Source/LibWebP/src/dec/vp8li.h +136 -0
  418. data/vendor/FreeImage/Source/LibWebP/src/dec/webpi.h +120 -0
  419. data/vendor/FreeImage/Source/LibWebP/src/demux/demux.demux.c +957 -0
  420. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.alpha_processing.c +377 -0
  421. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.alpha_processing_mips_dsp_r2.c +139 -0
  422. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.alpha_processing_sse2.c +296 -0
  423. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.argb.c +68 -0
  424. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.argb_mips_dsp_r2.c +108 -0
  425. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.argb_sse2.c +62 -0
  426. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.cost.c +412 -0
  427. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.cost_mips32.c +154 -0
  428. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.cost_mips_dsp_r2.c +107 -0
  429. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.cost_sse2.c +121 -0
  430. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.cpu.c +138 -0
  431. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.dec.c +760 -0
  432. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.dec_clip_tables.c +366 -0
  433. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.dec_mips32.c +585 -0
  434. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.dec_mips_dsp_r2.c +992 -0
  435. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.dec_neon.c +1489 -0
  436. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.dec_sse2.c +1284 -0
  437. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.enc.c +788 -0
  438. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.enc_avx2.c +24 -0
  439. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.enc_mips32.c +670 -0
  440. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.enc_mips_dsp_r2.c +1510 -0
  441. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.enc_neon.c +932 -0
  442. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.enc_sse2.c +940 -0
  443. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.filters.c +240 -0
  444. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.filters_mips_dsp_r2.c +404 -0
  445. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.filters_sse2.c +349 -0
  446. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.h +434 -0
  447. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.lossless.c +1838 -0
  448. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.lossless_mips32.c +416 -0
  449. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.lossless_mips_dsp_r2.c +921 -0
  450. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.lossless_neon.c +357 -0
  451. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.lossless_sse2.c +535 -0
  452. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.rescaler.c +115 -0
  453. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.rescaler_mips32.c +192 -0
  454. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.rescaler_mips_dsp_r2.c +210 -0
  455. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.upsampling.c +252 -0
  456. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.upsampling_mips_dsp_r2.c +280 -0
  457. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.upsampling_neon.c +267 -0
  458. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.upsampling_sse2.c +214 -0
  459. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.yuv.c +166 -0
  460. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.yuv_mips32.c +100 -0
  461. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.yuv_mips_dsp_r2.c +131 -0
  462. data/vendor/FreeImage/Source/LibWebP/src/dsp/dsp.yuv_sse2.c +322 -0
  463. data/vendor/FreeImage/Source/LibWebP/src/dsp/lossless.h +313 -0
  464. data/vendor/FreeImage/Source/LibWebP/src/dsp/mips_macro.h +200 -0
  465. data/vendor/FreeImage/Source/LibWebP/src/dsp/neon.h +82 -0
  466. data/vendor/FreeImage/Source/LibWebP/src/dsp/yuv.h +321 -0
  467. data/vendor/FreeImage/Source/LibWebP/src/dsp/yuv_tables_sse2.h +536 -0
  468. data/vendor/FreeImage/Source/LibWebP/src/enc/backward_references.h +202 -0
  469. data/vendor/FreeImage/Source/LibWebP/src/enc/cost.h +69 -0
  470. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.alpha.c +440 -0
  471. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.analysis.c +501 -0
  472. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.backward_references.c +1076 -0
  473. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.config.c +163 -0
  474. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.cost.c +355 -0
  475. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.filter.c +296 -0
  476. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.frame.c +850 -0
  477. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.histogram.c +897 -0
  478. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.iterator.c +456 -0
  479. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.near_lossless.c +160 -0
  480. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.picture.c +290 -0
  481. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.picture_csp.c +1100 -0
  482. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.picture_psnr.c +150 -0
  483. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.picture_rescale.c +285 -0
  484. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.picture_tools.c +206 -0
  485. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.quant.c +1191 -0
  486. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.syntax.c +383 -0
  487. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.token.c +285 -0
  488. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.tree.c +504 -0
  489. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.vp8l.c +1437 -0
  490. data/vendor/FreeImage/Source/LibWebP/src/enc/enc.webpenc.c +379 -0
  491. data/vendor/FreeImage/Source/LibWebP/src/enc/histogram.h +114 -0
  492. data/vendor/FreeImage/Source/LibWebP/src/enc/vp8enci.h +551 -0
  493. data/vendor/FreeImage/Source/LibWebP/src/enc/vp8li.h +78 -0
  494. data/vendor/FreeImage/Source/LibWebP/src/mux/mux.anim_encode.c +1241 -0
  495. data/vendor/FreeImage/Source/LibWebP/src/mux/mux.muxedit.c +696 -0
  496. data/vendor/FreeImage/Source/LibWebP/src/mux/mux.muxinternal.c +551 -0
  497. data/vendor/FreeImage/Source/LibWebP/src/mux/mux.muxread.c +544 -0
  498. data/vendor/FreeImage/Source/LibWebP/src/mux/muxi.h +232 -0
  499. data/vendor/FreeImage/Source/LibWebP/src/utils/bit_reader.h +168 -0
  500. data/vendor/FreeImage/Source/LibWebP/src/utils/bit_reader_inl.h +172 -0
  501. data/vendor/FreeImage/Source/LibWebP/src/utils/bit_writer.h +120 -0
  502. data/vendor/FreeImage/Source/LibWebP/src/utils/color_cache.h +74 -0
  503. data/vendor/FreeImage/Source/LibWebP/src/utils/endian_inl.h +100 -0
  504. data/vendor/FreeImage/Source/LibWebP/src/utils/filters.h +32 -0
  505. data/vendor/FreeImage/Source/LibWebP/src/utils/huffman.h +67 -0
  506. data/vendor/FreeImage/Source/LibWebP/src/utils/huffman_encode.h +60 -0
  507. data/vendor/FreeImage/Source/LibWebP/src/utils/quant_levels.h +36 -0
  508. data/vendor/FreeImage/Source/LibWebP/src/utils/quant_levels_dec.h +35 -0
  509. data/vendor/FreeImage/Source/LibWebP/src/utils/random.h +63 -0
  510. data/vendor/FreeImage/Source/LibWebP/src/utils/rescaler.h +78 -0
  511. data/vendor/FreeImage/Source/LibWebP/src/utils/thread.h +93 -0
  512. data/vendor/FreeImage/Source/LibWebP/src/utils/utils.bit_reader.c +208 -0
  513. data/vendor/FreeImage/Source/LibWebP/src/utils/utils.bit_writer.c +308 -0
  514. data/vendor/FreeImage/Source/LibWebP/src/utils/utils.color_cache.c +49 -0
  515. data/vendor/FreeImage/Source/LibWebP/src/utils/utils.filters.c +76 -0
  516. data/vendor/FreeImage/Source/LibWebP/src/utils/utils.h +121 -0
  517. data/vendor/FreeImage/Source/LibWebP/src/utils/utils.huffman.c +205 -0
  518. data/vendor/FreeImage/Source/LibWebP/src/utils/utils.huffman_encode.c +417 -0
  519. data/vendor/FreeImage/Source/LibWebP/src/utils/utils.quant_levels.c +140 -0
  520. data/vendor/FreeImage/Source/LibWebP/src/utils/utils.quant_levels_dec.c +279 -0
  521. data/vendor/FreeImage/Source/LibWebP/src/utils/utils.random.c +43 -0
  522. data/vendor/FreeImage/Source/LibWebP/src/utils/utils.rescaler.c +82 -0
  523. data/vendor/FreeImage/Source/LibWebP/src/utils/utils.thread.c +309 -0
  524. data/vendor/FreeImage/Source/LibWebP/src/utils/utils.utils.c +211 -0
  525. data/vendor/FreeImage/Source/LibWebP/src/webp/decode.h +493 -0
  526. data/vendor/FreeImage/Source/LibWebP/src/webp/demux.h +224 -0
  527. data/vendor/FreeImage/Source/LibWebP/src/webp/encode.h +515 -0
  528. data/vendor/FreeImage/Source/LibWebP/src/webp/format_constants.h +88 -0
  529. data/vendor/FreeImage/Source/LibWebP/src/webp/mux.h +507 -0
  530. data/vendor/FreeImage/Source/LibWebP/src/webp/mux_types.h +97 -0
  531. data/vendor/FreeImage/Source/LibWebP/src/webp/types.h +52 -0
  532. data/vendor/FreeImage/Source/MapIntrospector.h +212 -0
  533. data/vendor/FreeImage/Source/Metadata/Exif.cpp +1253 -0
  534. data/vendor/FreeImage/Source/Metadata/FIRational.cpp +176 -0
  535. data/vendor/FreeImage/Source/Metadata/FIRational.h +108 -0
  536. data/vendor/FreeImage/Source/Metadata/FreeImageTag.cpp +353 -0
  537. data/vendor/FreeImage/Source/Metadata/FreeImageTag.h +500 -0
  538. data/vendor/FreeImage/Source/Metadata/IPTC.cpp +342 -0
  539. data/vendor/FreeImage/Source/Metadata/TagConversion.cpp +1094 -0
  540. data/vendor/FreeImage/Source/Metadata/TagLib.cpp +1618 -0
  541. data/vendor/FreeImage/Source/Metadata/XTIFF.cpp +766 -0
  542. data/vendor/FreeImage/Source/OpenEXR/Half/eLut.cpp +114 -0
  543. data/vendor/FreeImage/Source/OpenEXR/Half/eLut.h +71 -0
  544. data/vendor/FreeImage/Source/OpenEXR/Half/half.cpp +310 -0
  545. data/vendor/FreeImage/Source/OpenEXR/Half/half.h +757 -0
  546. data/vendor/FreeImage/Source/OpenEXR/Half/halfExport.h +27 -0
  547. data/vendor/FreeImage/Source/OpenEXR/Half/halfFunction.h +179 -0
  548. data/vendor/FreeImage/Source/OpenEXR/Half/halfLimits.h +102 -0
  549. data/vendor/FreeImage/Source/OpenEXR/Half/toFloat.cpp +164 -0
  550. data/vendor/FreeImage/Source/OpenEXR/Half/toFloat.h +16391 -0
  551. data/vendor/FreeImage/Source/OpenEXR/Iex/Iex.h +60 -0
  552. data/vendor/FreeImage/Source/OpenEXR/Iex/IexBaseExc.cpp +156 -0
  553. data/vendor/FreeImage/Source/OpenEXR/Iex/IexBaseExc.h +264 -0
  554. data/vendor/FreeImage/Source/OpenEXR/Iex/IexErrnoExc.h +208 -0
  555. data/vendor/FreeImage/Source/OpenEXR/Iex/IexExport.h +51 -0
  556. data/vendor/FreeImage/Source/OpenEXR/Iex/IexForward.h +229 -0
  557. data/vendor/FreeImage/Source/OpenEXR/Iex/IexMacros.h +170 -0
  558. data/vendor/FreeImage/Source/OpenEXR/Iex/IexMathExc.h +57 -0
  559. data/vendor/FreeImage/Source/OpenEXR/Iex/IexNamespace.h +112 -0
  560. data/vendor/FreeImage/Source/OpenEXR/Iex/IexThrowErrnoExc.cpp +873 -0
  561. data/vendor/FreeImage/Source/OpenEXR/Iex/IexThrowErrnoExc.h +97 -0
  562. data/vendor/FreeImage/Source/OpenEXR/IexMath/IexMathFloatExc.cpp +113 -0
  563. data/vendor/FreeImage/Source/OpenEXR/IexMath/IexMathFloatExc.h +146 -0
  564. data/vendor/FreeImage/Source/OpenEXR/IexMath/IexMathFpu.cpp +530 -0
  565. data/vendor/FreeImage/Source/OpenEXR/IexMath/IexMathFpu.h +91 -0
  566. data/vendor/FreeImage/Source/OpenEXR/IexMath/IexMathIeeeExc.h +62 -0
  567. data/vendor/FreeImage/Source/OpenEXR/IlmBaseConfig.h +61 -0
  568. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfAcesFile.cpp +633 -0
  569. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfAcesFile.h +324 -0
  570. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfArray.h +285 -0
  571. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfAttribute.cpp +158 -0
  572. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfAttribute.h +407 -0
  573. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfAutoArray.h +95 -0
  574. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfB44Compressor.cpp +1072 -0
  575. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfB44Compressor.h +118 -0
  576. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfBoxAttribute.cpp +111 -0
  577. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfBoxAttribute.h +87 -0
  578. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfCRgbaFile.cpp +1438 -0
  579. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfCRgbaFile.h +555 -0
  580. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfChannelList.cpp +322 -0
  581. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfChannelList.h +436 -0
  582. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfChannelListAttribute.cpp +150 -0
  583. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfChannelListAttribute.h +74 -0
  584. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfCheckedArithmetic.h +163 -0
  585. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfChromaticities.cpp +151 -0
  586. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfChromaticities.h +131 -0
  587. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfChromaticitiesAttribute.cpp +87 -0
  588. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfChromaticitiesAttribute.h +73 -0
  589. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfCompositeDeepScanLine.cpp +591 -0
  590. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfCompositeDeepScanLine.h +142 -0
  591. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfCompression.h +84 -0
  592. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfCompressionAttribute.cpp +78 -0
  593. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfCompressionAttribute.h +64 -0
  594. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfCompressor.cpp +226 -0
  595. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfCompressor.h +265 -0
  596. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfConvert.cpp +143 -0
  597. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfConvert.h +107 -0
  598. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepCompositing.cpp +110 -0
  599. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepCompositing.h +132 -0
  600. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepFrameBuffer.cpp +230 -0
  601. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepFrameBuffer.h +339 -0
  602. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepImageState.h +96 -0
  603. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepImageStateAttribute.cpp +78 -0
  604. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepImageStateAttribute.h +68 -0
  605. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepScanLineInputFile.cpp +2025 -0
  606. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepScanLineInputFile.h +276 -0
  607. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepScanLineInputPart.cpp +149 -0
  608. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepScanLineInputPart.h +181 -0
  609. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepScanLineOutputFile.cpp +1552 -0
  610. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepScanLineOutputFile.h +244 -0
  611. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepScanLineOutputPart.cpp +107 -0
  612. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepScanLineOutputPart.h +168 -0
  613. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepTiledInputFile.cpp +1979 -0
  614. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepTiledInputFile.h +437 -0
  615. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepTiledInputPart.cpp +273 -0
  616. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepTiledInputPart.h +362 -0
  617. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepTiledOutputFile.cpp +2055 -0
  618. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepTiledOutputFile.h +475 -0
  619. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepTiledOutputPart.cpp +250 -0
  620. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDeepTiledOutputPart.h +394 -0
  621. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDoubleAttribute.cpp +57 -0
  622. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDoubleAttribute.h +59 -0
  623. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDwaCompressor.cpp +3424 -0
  624. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDwaCompressor.h +210 -0
  625. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfDwaCompressorSimd.h +2145 -0
  626. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfEnvmap.cpp +335 -0
  627. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfEnvmap.h +336 -0
  628. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfEnvmapAttribute.cpp +76 -0
  629. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfEnvmapAttribute.h +68 -0
  630. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfExport.h +46 -0
  631. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfFastHuf.cpp +768 -0
  632. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfFastHuf.h +148 -0
  633. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfFloatAttribute.cpp +57 -0
  634. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfFloatAttribute.h +58 -0
  635. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfFloatVectorAttribute.cpp +84 -0
  636. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfFloatVectorAttribute.h +76 -0
  637. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfForward.h +127 -0
  638. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfFrameBuffer.cpp +228 -0
  639. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfFrameBuffer.h +386 -0
  640. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfFramesPerSecond.cpp +76 -0
  641. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfFramesPerSecond.h +94 -0
  642. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfGenericInputFile.cpp +76 -0
  643. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfGenericInputFile.h +58 -0
  644. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfGenericOutputFile.cpp +112 -0
  645. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfGenericOutputFile.h +62 -0
  646. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfHeader.cpp +1283 -0
  647. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfHeader.h +699 -0
  648. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfHuf.cpp +1114 -0
  649. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfHuf.h +82 -0
  650. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfIO.cpp +110 -0
  651. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfIO.h +255 -0
  652. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfInputFile.cpp +895 -0
  653. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfInputFile.h +240 -0
  654. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfInputPart.cpp +114 -0
  655. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfInputPart.h +84 -0
  656. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfInputPartData.cpp +51 -0
  657. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfInputPartData.h +69 -0
  658. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfInputStreamMutex.h +68 -0
  659. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfInt64.h +56 -0
  660. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfIntAttribute.cpp +57 -0
  661. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfIntAttribute.h +58 -0
  662. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfKeyCode.cpp +217 -0
  663. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfKeyCode.h +167 -0
  664. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfKeyCodeAttribute.cpp +99 -0
  665. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfKeyCodeAttribute.h +73 -0
  666. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfLineOrder.h +69 -0
  667. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfLineOrderAttribute.cpp +78 -0
  668. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfLineOrderAttribute.h +72 -0
  669. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfLut.cpp +178 -0
  670. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfLut.h +188 -0
  671. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfMatrixAttribute.cpp +263 -0
  672. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfMatrixAttribute.h +83 -0
  673. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfMisc.cpp +1872 -0
  674. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfMisc.h +466 -0
  675. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfMultiPartInputFile.cpp +783 -0
  676. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfMultiPartInputFile.h +128 -0
  677. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfMultiPartOutputFile.cpp +519 -0
  678. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfMultiPartOutputFile.h +118 -0
  679. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfMultiView.cpp +435 -0
  680. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfMultiView.h +187 -0
  681. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfName.h +150 -0
  682. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfNamespace.h +115 -0
  683. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfOpaqueAttribute.cpp +126 -0
  684. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfOpaqueAttribute.h +110 -0
  685. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfOptimizedPixelReading.h +646 -0
  686. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfOutputFile.cpp +1378 -0
  687. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfOutputFile.h +263 -0
  688. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfOutputPart.cpp +105 -0
  689. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfOutputPart.h +77 -0
  690. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfOutputPartData.cpp +52 -0
  691. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfOutputPartData.h +62 -0
  692. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfOutputStreamMutex.h +70 -0
  693. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfPartHelper.h +262 -0
  694. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfPartType.cpp +63 -0
  695. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfPartType.h +62 -0
  696. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfPixelType.h +67 -0
  697. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfPizCompressor.cpp +667 -0
  698. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfPizCompressor.h +117 -0
  699. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfPreviewImage.cpp +104 -0
  700. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfPreviewImage.h +135 -0
  701. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfPreviewImageAttribute.cpp +103 -0
  702. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfPreviewImageAttribute.h +70 -0
  703. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfPxr24Compressor.cpp +553 -0
  704. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfPxr24Compressor.h +109 -0
  705. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfRational.cpp +127 -0
  706. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfRational.h +98 -0
  707. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfRationalAttribute.cpp +74 -0
  708. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfRationalAttribute.h +69 -0
  709. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfRgba.h +109 -0
  710. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfRgbaFile.cpp +1405 -0
  711. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfRgbaFile.h +346 -0
  712. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfRgbaYca.cpp +497 -0
  713. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfRgbaYca.h +259 -0
  714. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfRle.cpp +157 -0
  715. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfRle.h +63 -0
  716. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfRleCompressor.cpp +220 -0
  717. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfRleCompressor.h +80 -0
  718. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfScanLineInputFile.cpp +1702 -0
  719. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfScanLineInputFile.h +210 -0
  720. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfSimd.h +59 -0
  721. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfStandardAttributes.cpp +125 -0
  722. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfStandardAttributes.h +382 -0
  723. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfStdIO.cpp +242 -0
  724. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfStdIO.h +160 -0
  725. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfStringAttribute.cpp +80 -0
  726. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfStringAttribute.h +71 -0
  727. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfStringVectorAttribute.cpp +100 -0
  728. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfStringVectorAttribute.h +74 -0
  729. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfSystemSpecific.cpp +129 -0
  730. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfSystemSpecific.h +172 -0
  731. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTestFile.cpp +216 -0
  732. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTestFile.h +97 -0
  733. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfThreading.cpp +62 -0
  734. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfThreading.h +95 -0
  735. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTileDescription.h +107 -0
  736. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTileDescriptionAttribute.cpp +86 -0
  737. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTileDescriptionAttribute.h +72 -0
  738. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTileOffsets.cpp +552 -0
  739. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTileOffsets.h +125 -0
  740. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTiledInputFile.cpp +1533 -0
  741. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTiledInputFile.h +401 -0
  742. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTiledInputPart.cpp +208 -0
  743. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTiledInputPart.h +100 -0
  744. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTiledMisc.cpp +389 -0
  745. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTiledMisc.h +106 -0
  746. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTiledOutputFile.cpp +1841 -0
  747. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTiledOutputFile.h +495 -0
  748. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTiledOutputPart.cpp +228 -0
  749. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTiledOutputPart.h +105 -0
  750. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTiledRgbaFile.cpp +1163 -0
  751. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTiledRgbaFile.h +482 -0
  752. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTimeCode.cpp +431 -0
  753. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTimeCode.h +242 -0
  754. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTimeCodeAttribute.cpp +79 -0
  755. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfTimeCodeAttribute.h +74 -0
  756. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfVecAttribute.cpp +217 -0
  757. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfVecAttribute.h +100 -0
  758. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfVersion.cpp +60 -0
  759. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfVersion.h +136 -0
  760. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfWav.cpp +391 -0
  761. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfWav.h +78 -0
  762. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfXdr.h +927 -0
  763. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfZip.cpp +196 -0
  764. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfZip.h +78 -0
  765. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfZipCompressor.cpp +127 -0
  766. data/vendor/FreeImage/Source/OpenEXR/IlmImf/ImfZipCompressor.h +89 -0
  767. data/vendor/FreeImage/Source/OpenEXR/IlmImf/b44ExpLogTable.cpp +136 -0
  768. data/vendor/FreeImage/Source/OpenEXR/IlmImf/b44ExpLogTable.h +16396 -0
  769. data/vendor/FreeImage/Source/OpenEXR/IlmImf/dwaLookups.cpp +573 -0
  770. data/vendor/FreeImage/Source/OpenEXR/IlmImf/dwaLookups.h +98334 -0
  771. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThread.cpp +80 -0
  772. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThread.h +143 -0
  773. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThreadExport.h +46 -0
  774. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThreadForward.h +52 -0
  775. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThreadMutex.cpp +59 -0
  776. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThreadMutex.h +160 -0
  777. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThreadMutexPosix.cpp +85 -0
  778. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThreadMutexWin32.cpp +79 -0
  779. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThreadNamespace.h +114 -0
  780. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThreadPool.cpp +483 -0
  781. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThreadPool.h +160 -0
  782. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThreadPosix.cpp +98 -0
  783. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThreadSemaphore.cpp +60 -0
  784. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThreadSemaphore.h +112 -0
  785. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThreadSemaphorePosix.cpp +106 -0
  786. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThreadSemaphorePosixCompat.cpp +155 -0
  787. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThreadSemaphoreWin32.cpp +153 -0
  788. data/vendor/FreeImage/Source/OpenEXR/IlmThread/IlmThreadWin32.cpp +100 -0
  789. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathBox.cpp +37 -0
  790. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathBox.h +849 -0
  791. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathBoxAlgo.h +1016 -0
  792. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathColor.h +736 -0
  793. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathColorAlgo.cpp +178 -0
  794. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathColorAlgo.h +257 -0
  795. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathEuler.h +926 -0
  796. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathExc.h +73 -0
  797. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathExport.h +46 -0
  798. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathForward.h +72 -0
  799. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathFrame.h +192 -0
  800. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathFrustum.h +741 -0
  801. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathFrustumTest.h +417 -0
  802. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathFun.cpp +181 -0
  803. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathFun.h +269 -0
  804. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathGL.h +166 -0
  805. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathGLU.h +54 -0
  806. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathHalfLimits.h +68 -0
  807. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathInt64.h +62 -0
  808. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathInterval.h +226 -0
  809. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathLimits.h +268 -0
  810. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathLine.h +185 -0
  811. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathLineAlgo.h +288 -0
  812. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathMath.h +208 -0
  813. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathMatrix.h +3441 -0
  814. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathMatrixAlgo.cpp +1252 -0
  815. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathMatrixAlgo.h +1425 -0
  816. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathNamespace.h +115 -0
  817. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathPlane.h +257 -0
  818. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathPlatform.h +112 -0
  819. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathQuat.h +964 -0
  820. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathRandom.cpp +194 -0
  821. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathRandom.h +401 -0
  822. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathRoots.h +219 -0
  823. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathShear.cpp +54 -0
  824. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathShear.h +656 -0
  825. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathSphere.h +177 -0
  826. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathVec.cpp +583 -0
  827. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathVec.h +2227 -0
  828. data/vendor/FreeImage/Source/OpenEXR/Imath/ImathVecAlgo.h +147 -0
  829. data/vendor/FreeImage/Source/OpenEXR/OpenEXRConfig.h +72 -0
  830. data/vendor/FreeImage/Source/Plugin.h +144 -0
  831. data/vendor/FreeImage/Source/Quantizers.h +354 -0
  832. data/vendor/FreeImage/Source/ToneMapping.h +44 -0
  833. data/vendor/FreeImage/Source/Utilities.h +516 -0
  834. data/vendor/FreeImage/Source/ZLib/adler32.c +179 -0
  835. data/vendor/FreeImage/Source/ZLib/compress.c +80 -0
  836. data/vendor/FreeImage/Source/ZLib/crc32.c +425 -0
  837. data/vendor/FreeImage/Source/ZLib/crc32.h +441 -0
  838. data/vendor/FreeImage/Source/ZLib/deflate.c +1967 -0
  839. data/vendor/FreeImage/Source/ZLib/deflate.h +346 -0
  840. data/vendor/FreeImage/Source/ZLib/gzclose.c +25 -0
  841. data/vendor/FreeImage/Source/ZLib/gzguts.h +209 -0
  842. data/vendor/FreeImage/Source/ZLib/gzlib.c +634 -0
  843. data/vendor/FreeImage/Source/ZLib/gzread.c +594 -0
  844. data/vendor/FreeImage/Source/ZLib/gzwrite.c +577 -0
  845. data/vendor/FreeImage/Source/ZLib/infback.c +640 -0
  846. data/vendor/FreeImage/Source/ZLib/inffast.c +340 -0
  847. data/vendor/FreeImage/Source/ZLib/inffast.h +11 -0
  848. data/vendor/FreeImage/Source/ZLib/inffixed.h +94 -0
  849. data/vendor/FreeImage/Source/ZLib/inflate.c +1512 -0
  850. data/vendor/FreeImage/Source/ZLib/inflate.h +122 -0
  851. data/vendor/FreeImage/Source/ZLib/inftrees.c +306 -0
  852. data/vendor/FreeImage/Source/ZLib/inftrees.h +62 -0
  853. data/vendor/FreeImage/Source/ZLib/trees.c +1226 -0
  854. data/vendor/FreeImage/Source/ZLib/trees.h +128 -0
  855. data/vendor/FreeImage/Source/ZLib/uncompr.c +59 -0
  856. data/vendor/FreeImage/Source/ZLib/zconf.h +511 -0
  857. data/vendor/FreeImage/Source/ZLib/zlib.h +1768 -0
  858. data/vendor/FreeImage/Source/ZLib/zutil.c +324 -0
  859. data/vendor/FreeImage/Source/ZLib/zutil.h +253 -0
  860. metadata +931 -0
@@ -0,0 +1,1573 @@
1
+ /*
2
+ * jchuff.c
3
+ *
4
+ * Copyright (C) 1991-1997, Thomas G. Lane.
5
+ * Modified 2006-2013 by Guido Vollbeding.
6
+ * This file is part of the Independent JPEG Group's software.
7
+ * For conditions of distribution and use, see the accompanying README file.
8
+ *
9
+ * This file contains Huffman entropy encoding routines.
10
+ * Both sequential and progressive modes are supported in this single module.
11
+ *
12
+ * Much of the complexity here has to do with supporting output suspension.
13
+ * If the data destination module demands suspension, we want to be able to
14
+ * back up to the start of the current MCU. To do this, we copy state
15
+ * variables into local working storage, and update them back to the
16
+ * permanent JPEG objects only upon successful completion of an MCU.
17
+ *
18
+ * We do not support output suspension for the progressive JPEG mode, since
19
+ * the library currently does not allow multiple-scan files to be written
20
+ * with output suspension.
21
+ */
22
+
23
+ #define JPEG_INTERNALS
24
+ #include "jinclude.h"
25
+ #include "jpeglib.h"
26
+
27
+
28
+ /* The legal range of a DCT coefficient is
29
+ * -1024 .. +1023 for 8-bit data;
30
+ * -16384 .. +16383 for 12-bit data.
31
+ * Hence the magnitude should always fit in 10 or 14 bits respectively.
32
+ */
33
+
34
+ #if BITS_IN_JSAMPLE == 8
35
+ #define MAX_COEF_BITS 10
36
+ #else
37
+ #define MAX_COEF_BITS 14
38
+ #endif
39
+
40
+ /* Derived data constructed for each Huffman table */
41
+
42
+ typedef struct {
43
+ unsigned int ehufco[256]; /* code for each symbol */
44
+ char ehufsi[256]; /* length of code for each symbol */
45
+ /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */
46
+ } c_derived_tbl;
47
+
48
+
49
+ /* Expanded entropy encoder object for Huffman encoding.
50
+ *
51
+ * The savable_state subrecord contains fields that change within an MCU,
52
+ * but must not be updated permanently until we complete the MCU.
53
+ */
54
+
55
+ typedef struct {
56
+ INT32 put_buffer; /* current bit-accumulation buffer */
57
+ int put_bits; /* # of bits now in it */
58
+ int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
59
+ } savable_state;
60
+
61
+ /* This macro is to work around compilers with missing or broken
62
+ * structure assignment. You'll need to fix this code if you have
63
+ * such a compiler and you change MAX_COMPS_IN_SCAN.
64
+ */
65
+
66
+ #ifndef NO_STRUCT_ASSIGN
67
+ #define ASSIGN_STATE(dest,src) ((dest) = (src))
68
+ #else
69
+ #if MAX_COMPS_IN_SCAN == 4
70
+ #define ASSIGN_STATE(dest,src) \
71
+ ((dest).put_buffer = (src).put_buffer, \
72
+ (dest).put_bits = (src).put_bits, \
73
+ (dest).last_dc_val[0] = (src).last_dc_val[0], \
74
+ (dest).last_dc_val[1] = (src).last_dc_val[1], \
75
+ (dest).last_dc_val[2] = (src).last_dc_val[2], \
76
+ (dest).last_dc_val[3] = (src).last_dc_val[3])
77
+ #endif
78
+ #endif
79
+
80
+
81
+ typedef struct {
82
+ struct jpeg_entropy_encoder pub; /* public fields */
83
+
84
+ savable_state saved; /* Bit buffer & DC state at start of MCU */
85
+
86
+ /* These fields are NOT loaded into local working state. */
87
+ unsigned int restarts_to_go; /* MCUs left in this restart interval */
88
+ int next_restart_num; /* next restart number to write (0-7) */
89
+
90
+ /* Pointers to derived tables (these workspaces have image lifespan) */
91
+ c_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS];
92
+ c_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS];
93
+
94
+ /* Statistics tables for optimization */
95
+ long * dc_count_ptrs[NUM_HUFF_TBLS];
96
+ long * ac_count_ptrs[NUM_HUFF_TBLS];
97
+
98
+ /* Following fields used only in progressive mode */
99
+
100
+ /* Mode flag: TRUE for optimization, FALSE for actual data output */
101
+ boolean gather_statistics;
102
+
103
+ /* next_output_byte/free_in_buffer are local copies of cinfo->dest fields.
104
+ */
105
+ JOCTET * next_output_byte; /* => next byte to write in buffer */
106
+ size_t free_in_buffer; /* # of byte spaces remaining in buffer */
107
+ j_compress_ptr cinfo; /* link to cinfo (needed for dump_buffer) */
108
+
109
+ /* Coding status for AC components */
110
+ int ac_tbl_no; /* the table number of the single component */
111
+ unsigned int EOBRUN; /* run length of EOBs */
112
+ unsigned int BE; /* # of buffered correction bits before MCU */
113
+ char * bit_buffer; /* buffer for correction bits (1 per char) */
114
+ /* packing correction bits tightly would save some space but cost time... */
115
+ } huff_entropy_encoder;
116
+
117
+ typedef huff_entropy_encoder * huff_entropy_ptr;
118
+
119
+ /* Working state while writing an MCU (sequential mode).
120
+ * This struct contains all the fields that are needed by subroutines.
121
+ */
122
+
123
+ typedef struct {
124
+ JOCTET * next_output_byte; /* => next byte to write in buffer */
125
+ size_t free_in_buffer; /* # of byte spaces remaining in buffer */
126
+ savable_state cur; /* Current bit buffer & DC state */
127
+ j_compress_ptr cinfo; /* dump_buffer needs access to this */
128
+ } working_state;
129
+
130
+ /* MAX_CORR_BITS is the number of bits the AC refinement correction-bit
131
+ * buffer can hold. Larger sizes may slightly improve compression, but
132
+ * 1000 is already well into the realm of overkill.
133
+ * The minimum safe size is 64 bits.
134
+ */
135
+
136
+ #define MAX_CORR_BITS 1000 /* Max # of correction bits I can buffer */
137
+
138
+ /* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than INT32.
139
+ * We assume that int right shift is unsigned if INT32 right shift is,
140
+ * which should be safe.
141
+ */
142
+
143
+ #ifdef RIGHT_SHIFT_IS_UNSIGNED
144
+ #define ISHIFT_TEMPS int ishift_temp;
145
+ #define IRIGHT_SHIFT(x,shft) \
146
+ ((ishift_temp = (x)) < 0 ? \
147
+ (ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \
148
+ (ishift_temp >> (shft)))
149
+ #else
150
+ #define ISHIFT_TEMPS
151
+ #define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
152
+ #endif
153
+
154
+
155
+ /*
156
+ * Compute the derived values for a Huffman table.
157
+ * This routine also performs some validation checks on the table.
158
+ */
159
+
160
+ LOCAL(void)
161
+ jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno,
162
+ c_derived_tbl ** pdtbl)
163
+ {
164
+ JHUFF_TBL *htbl;
165
+ c_derived_tbl *dtbl;
166
+ int p, i, l, lastp, si, maxsymbol;
167
+ char huffsize[257];
168
+ unsigned int huffcode[257];
169
+ unsigned int code;
170
+
171
+ /* Note that huffsize[] and huffcode[] are filled in code-length order,
172
+ * paralleling the order of the symbols themselves in htbl->huffval[].
173
+ */
174
+
175
+ /* Find the input Huffman table */
176
+ if (tblno < 0 || tblno >= NUM_HUFF_TBLS)
177
+ ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
178
+ htbl =
179
+ isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno];
180
+ if (htbl == NULL)
181
+ ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
182
+
183
+ /* Allocate a workspace if we haven't already done so. */
184
+ if (*pdtbl == NULL)
185
+ *pdtbl = (c_derived_tbl *)
186
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
187
+ SIZEOF(c_derived_tbl));
188
+ dtbl = *pdtbl;
189
+
190
+ /* Figure C.1: make table of Huffman code length for each symbol */
191
+
192
+ p = 0;
193
+ for (l = 1; l <= 16; l++) {
194
+ i = (int) htbl->bits[l];
195
+ if (i < 0 || p + i > 256) /* protect against table overrun */
196
+ ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
197
+ while (i--)
198
+ huffsize[p++] = (char) l;
199
+ }
200
+ huffsize[p] = 0;
201
+ lastp = p;
202
+
203
+ /* Figure C.2: generate the codes themselves */
204
+ /* We also validate that the counts represent a legal Huffman code tree. */
205
+
206
+ code = 0;
207
+ si = huffsize[0];
208
+ p = 0;
209
+ while (huffsize[p]) {
210
+ while (((int) huffsize[p]) == si) {
211
+ huffcode[p++] = code;
212
+ code++;
213
+ }
214
+ /* code is now 1 more than the last code used for codelength si; but
215
+ * it must still fit in si bits, since no code is allowed to be all ones.
216
+ */
217
+ if (((INT32) code) >= (((INT32) 1) << si))
218
+ ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
219
+ code <<= 1;
220
+ si++;
221
+ }
222
+
223
+ /* Figure C.3: generate encoding tables */
224
+ /* These are code and size indexed by symbol value */
225
+
226
+ /* Set all codeless symbols to have code length 0;
227
+ * this lets us detect duplicate VAL entries here, and later
228
+ * allows emit_bits to detect any attempt to emit such symbols.
229
+ */
230
+ MEMZERO(dtbl->ehufsi, SIZEOF(dtbl->ehufsi));
231
+
232
+ /* This is also a convenient place to check for out-of-range
233
+ * and duplicated VAL entries. We allow 0..255 for AC symbols
234
+ * but only 0..15 for DC. (We could constrain them further
235
+ * based on data depth and mode, but this seems enough.)
236
+ */
237
+ maxsymbol = isDC ? 15 : 255;
238
+
239
+ for (p = 0; p < lastp; p++) {
240
+ i = htbl->huffval[p];
241
+ if (i < 0 || i > maxsymbol || dtbl->ehufsi[i])
242
+ ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
243
+ dtbl->ehufco[i] = huffcode[p];
244
+ dtbl->ehufsi[i] = huffsize[p];
245
+ }
246
+ }
247
+
248
+
249
+ /* Outputting bytes to the file.
250
+ * NB: these must be called only when actually outputting,
251
+ * that is, entropy->gather_statistics == FALSE.
252
+ */
253
+
254
+ /* Emit a byte, taking 'action' if must suspend. */
255
+ #define emit_byte_s(state,val,action) \
256
+ { *(state)->next_output_byte++ = (JOCTET) (val); \
257
+ if (--(state)->free_in_buffer == 0) \
258
+ if (! dump_buffer_s(state)) \
259
+ { action; } }
260
+
261
+ /* Emit a byte */
262
+ #define emit_byte_e(entropy,val) \
263
+ { *(entropy)->next_output_byte++ = (JOCTET) (val); \
264
+ if (--(entropy)->free_in_buffer == 0) \
265
+ dump_buffer_e(entropy); }
266
+
267
+
268
+ LOCAL(boolean)
269
+ dump_buffer_s (working_state * state)
270
+ /* Empty the output buffer; return TRUE if successful, FALSE if must suspend */
271
+ {
272
+ struct jpeg_destination_mgr * dest = state->cinfo->dest;
273
+
274
+ if (! (*dest->empty_output_buffer) (state->cinfo))
275
+ return FALSE;
276
+ /* After a successful buffer dump, must reset buffer pointers */
277
+ state->next_output_byte = dest->next_output_byte;
278
+ state->free_in_buffer = dest->free_in_buffer;
279
+ return TRUE;
280
+ }
281
+
282
+
283
+ LOCAL(void)
284
+ dump_buffer_e (huff_entropy_ptr entropy)
285
+ /* Empty the output buffer; we do not support suspension in this case. */
286
+ {
287
+ struct jpeg_destination_mgr * dest = entropy->cinfo->dest;
288
+
289
+ if (! (*dest->empty_output_buffer) (entropy->cinfo))
290
+ ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND);
291
+ /* After a successful buffer dump, must reset buffer pointers */
292
+ entropy->next_output_byte = dest->next_output_byte;
293
+ entropy->free_in_buffer = dest->free_in_buffer;
294
+ }
295
+
296
+
297
+ /* Outputting bits to the file */
298
+
299
+ /* Only the right 24 bits of put_buffer are used; the valid bits are
300
+ * left-justified in this part. At most 16 bits can be passed to emit_bits
301
+ * in one call, and we never retain more than 7 bits in put_buffer
302
+ * between calls, so 24 bits are sufficient.
303
+ */
304
+
305
+ INLINE
306
+ LOCAL(boolean)
307
+ emit_bits_s (working_state * state, unsigned int code, int size)
308
+ /* Emit some bits; return TRUE if successful, FALSE if must suspend */
309
+ {
310
+ /* This routine is heavily used, so it's worth coding tightly. */
311
+ register INT32 put_buffer;
312
+ register int put_bits;
313
+
314
+ /* if size is 0, caller used an invalid Huffman table entry */
315
+ if (size == 0)
316
+ ERREXIT(state->cinfo, JERR_HUFF_MISSING_CODE);
317
+
318
+ /* mask off any extra bits in code */
319
+ put_buffer = ((INT32) code) & ((((INT32) 1) << size) - 1);
320
+
321
+ /* new number of bits in buffer */
322
+ put_bits = size + state->cur.put_bits;
323
+
324
+ put_buffer <<= 24 - put_bits; /* align incoming bits */
325
+
326
+ /* and merge with old buffer contents */
327
+ put_buffer |= state->cur.put_buffer;
328
+
329
+ while (put_bits >= 8) {
330
+ int c = (int) ((put_buffer >> 16) & 0xFF);
331
+
332
+ emit_byte_s(state, c, return FALSE);
333
+ if (c == 0xFF) { /* need to stuff a zero byte? */
334
+ emit_byte_s(state, 0, return FALSE);
335
+ }
336
+ put_buffer <<= 8;
337
+ put_bits -= 8;
338
+ }
339
+
340
+ state->cur.put_buffer = put_buffer; /* update state variables */
341
+ state->cur.put_bits = put_bits;
342
+
343
+ return TRUE;
344
+ }
345
+
346
+
347
+ INLINE
348
+ LOCAL(void)
349
+ emit_bits_e (huff_entropy_ptr entropy, unsigned int code, int size)
350
+ /* Emit some bits, unless we are in gather mode */
351
+ {
352
+ /* This routine is heavily used, so it's worth coding tightly. */
353
+ register INT32 put_buffer;
354
+ register int put_bits;
355
+
356
+ /* if size is 0, caller used an invalid Huffman table entry */
357
+ if (size == 0)
358
+ ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);
359
+
360
+ if (entropy->gather_statistics)
361
+ return; /* do nothing if we're only getting stats */
362
+
363
+ /* mask off any extra bits in code */
364
+ put_buffer = ((INT32) code) & ((((INT32) 1) << size) - 1);
365
+
366
+ /* new number of bits in buffer */
367
+ put_bits = size + entropy->saved.put_bits;
368
+
369
+ put_buffer <<= 24 - put_bits; /* align incoming bits */
370
+
371
+ /* and merge with old buffer contents */
372
+ put_buffer |= entropy->saved.put_buffer;
373
+
374
+ while (put_bits >= 8) {
375
+ int c = (int) ((put_buffer >> 16) & 0xFF);
376
+
377
+ emit_byte_e(entropy, c);
378
+ if (c == 0xFF) { /* need to stuff a zero byte? */
379
+ emit_byte_e(entropy, 0);
380
+ }
381
+ put_buffer <<= 8;
382
+ put_bits -= 8;
383
+ }
384
+
385
+ entropy->saved.put_buffer = put_buffer; /* update variables */
386
+ entropy->saved.put_bits = put_bits;
387
+ }
388
+
389
+
390
+ LOCAL(boolean)
391
+ flush_bits_s (working_state * state)
392
+ {
393
+ if (! emit_bits_s(state, 0x7F, 7)) /* fill any partial byte with ones */
394
+ return FALSE;
395
+ state->cur.put_buffer = 0; /* and reset bit-buffer to empty */
396
+ state->cur.put_bits = 0;
397
+ return TRUE;
398
+ }
399
+
400
+
401
+ LOCAL(void)
402
+ flush_bits_e (huff_entropy_ptr entropy)
403
+ {
404
+ emit_bits_e(entropy, 0x7F, 7); /* fill any partial byte with ones */
405
+ entropy->saved.put_buffer = 0; /* and reset bit-buffer to empty */
406
+ entropy->saved.put_bits = 0;
407
+ }
408
+
409
+
410
+ /*
411
+ * Emit (or just count) a Huffman symbol.
412
+ */
413
+
414
+ INLINE
415
+ LOCAL(void)
416
+ emit_dc_symbol (huff_entropy_ptr entropy, int tbl_no, int symbol)
417
+ {
418
+ if (entropy->gather_statistics)
419
+ entropy->dc_count_ptrs[tbl_no][symbol]++;
420
+ else {
421
+ c_derived_tbl * tbl = entropy->dc_derived_tbls[tbl_no];
422
+ emit_bits_e(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]);
423
+ }
424
+ }
425
+
426
+
427
+ INLINE
428
+ LOCAL(void)
429
+ emit_ac_symbol (huff_entropy_ptr entropy, int tbl_no, int symbol)
430
+ {
431
+ if (entropy->gather_statistics)
432
+ entropy->ac_count_ptrs[tbl_no][symbol]++;
433
+ else {
434
+ c_derived_tbl * tbl = entropy->ac_derived_tbls[tbl_no];
435
+ emit_bits_e(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]);
436
+ }
437
+ }
438
+
439
+
440
+ /*
441
+ * Emit bits from a correction bit buffer.
442
+ */
443
+
444
+ LOCAL(void)
445
+ emit_buffered_bits (huff_entropy_ptr entropy, char * bufstart,
446
+ unsigned int nbits)
447
+ {
448
+ if (entropy->gather_statistics)
449
+ return; /* no real work */
450
+
451
+ while (nbits > 0) {
452
+ emit_bits_e(entropy, (unsigned int) (*bufstart), 1);
453
+ bufstart++;
454
+ nbits--;
455
+ }
456
+ }
457
+
458
+
459
+ /*
460
+ * Emit any pending EOBRUN symbol.
461
+ */
462
+
463
+ LOCAL(void)
464
+ emit_eobrun (huff_entropy_ptr entropy)
465
+ {
466
+ register int temp, nbits;
467
+
468
+ if (entropy->EOBRUN > 0) { /* if there is any pending EOBRUN */
469
+ temp = entropy->EOBRUN;
470
+ nbits = 0;
471
+ while ((temp >>= 1))
472
+ nbits++;
473
+ /* safety check: shouldn't happen given limited correction-bit buffer */
474
+ if (nbits > 14)
475
+ ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);
476
+
477
+ emit_ac_symbol(entropy, entropy->ac_tbl_no, nbits << 4);
478
+ if (nbits)
479
+ emit_bits_e(entropy, entropy->EOBRUN, nbits);
480
+
481
+ entropy->EOBRUN = 0;
482
+
483
+ /* Emit any buffered correction bits */
484
+ emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE);
485
+ entropy->BE = 0;
486
+ }
487
+ }
488
+
489
+
490
+ /*
491
+ * Emit a restart marker & resynchronize predictions.
492
+ */
493
+
494
+ LOCAL(boolean)
495
+ emit_restart_s (working_state * state, int restart_num)
496
+ {
497
+ int ci;
498
+
499
+ if (! flush_bits_s(state))
500
+ return FALSE;
501
+
502
+ emit_byte_s(state, 0xFF, return FALSE);
503
+ emit_byte_s(state, JPEG_RST0 + restart_num, return FALSE);
504
+
505
+ /* Re-initialize DC predictions to 0 */
506
+ for (ci = 0; ci < state->cinfo->comps_in_scan; ci++)
507
+ state->cur.last_dc_val[ci] = 0;
508
+
509
+ /* The restart counter is not updated until we successfully write the MCU. */
510
+
511
+ return TRUE;
512
+ }
513
+
514
+
515
+ LOCAL(void)
516
+ emit_restart_e (huff_entropy_ptr entropy, int restart_num)
517
+ {
518
+ int ci;
519
+
520
+ emit_eobrun(entropy);
521
+
522
+ if (! entropy->gather_statistics) {
523
+ flush_bits_e(entropy);
524
+ emit_byte_e(entropy, 0xFF);
525
+ emit_byte_e(entropy, JPEG_RST0 + restart_num);
526
+ }
527
+
528
+ if (entropy->cinfo->Ss == 0) {
529
+ /* Re-initialize DC predictions to 0 */
530
+ for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++)
531
+ entropy->saved.last_dc_val[ci] = 0;
532
+ } else {
533
+ /* Re-initialize all AC-related fields to 0 */
534
+ entropy->EOBRUN = 0;
535
+ entropy->BE = 0;
536
+ }
537
+ }
538
+
539
+
540
+ /*
541
+ * MCU encoding for DC initial scan (either spectral selection,
542
+ * or first pass of successive approximation).
543
+ */
544
+
545
+ METHODDEF(boolean)
546
+ encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
547
+ {
548
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
549
+ register int temp, temp2;
550
+ register int nbits;
551
+ int blkn, ci, tbl;
552
+ ISHIFT_TEMPS
553
+
554
+ entropy->next_output_byte = cinfo->dest->next_output_byte;
555
+ entropy->free_in_buffer = cinfo->dest->free_in_buffer;
556
+
557
+ /* Emit restart marker if needed */
558
+ if (cinfo->restart_interval)
559
+ if (entropy->restarts_to_go == 0)
560
+ emit_restart_e(entropy, entropy->next_restart_num);
561
+
562
+ /* Encode the MCU data blocks */
563
+ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
564
+ ci = cinfo->MCU_membership[blkn];
565
+ tbl = cinfo->cur_comp_info[ci]->dc_tbl_no;
566
+
567
+ /* Compute the DC value after the required point transform by Al.
568
+ * This is simply an arithmetic right shift.
569
+ */
570
+ temp = IRIGHT_SHIFT((int) (MCU_data[blkn][0][0]), cinfo->Al);
571
+
572
+ /* DC differences are figured on the point-transformed values. */
573
+ temp2 = temp - entropy->saved.last_dc_val[ci];
574
+ entropy->saved.last_dc_val[ci] = temp;
575
+
576
+ /* Encode the DC coefficient difference per section G.1.2.1 */
577
+ temp = temp2;
578
+ if (temp < 0) {
579
+ temp = -temp; /* temp is abs value of input */
580
+ /* For a negative input, want temp2 = bitwise complement of abs(input) */
581
+ /* This code assumes we are on a two's complement machine */
582
+ temp2--;
583
+ }
584
+
585
+ /* Find the number of bits needed for the magnitude of the coefficient */
586
+ nbits = 0;
587
+ while (temp) {
588
+ nbits++;
589
+ temp >>= 1;
590
+ }
591
+ /* Check for out-of-range coefficient values.
592
+ * Since we're encoding a difference, the range limit is twice as much.
593
+ */
594
+ if (nbits > MAX_COEF_BITS+1)
595
+ ERREXIT(cinfo, JERR_BAD_DCT_COEF);
596
+
597
+ /* Count/emit the Huffman-coded symbol for the number of bits */
598
+ emit_dc_symbol(entropy, tbl, nbits);
599
+
600
+ /* Emit that number of bits of the value, if positive, */
601
+ /* or the complement of its magnitude, if negative. */
602
+ if (nbits) /* emit_bits rejects calls with size 0 */
603
+ emit_bits_e(entropy, (unsigned int) temp2, nbits);
604
+ }
605
+
606
+ cinfo->dest->next_output_byte = entropy->next_output_byte;
607
+ cinfo->dest->free_in_buffer = entropy->free_in_buffer;
608
+
609
+ /* Update restart-interval state too */
610
+ if (cinfo->restart_interval) {
611
+ if (entropy->restarts_to_go == 0) {
612
+ entropy->restarts_to_go = cinfo->restart_interval;
613
+ entropy->next_restart_num++;
614
+ entropy->next_restart_num &= 7;
615
+ }
616
+ entropy->restarts_to_go--;
617
+ }
618
+
619
+ return TRUE;
620
+ }
621
+
622
+
623
+ /*
624
+ * MCU encoding for AC initial scan (either spectral selection,
625
+ * or first pass of successive approximation).
626
+ */
627
+
628
+ METHODDEF(boolean)
629
+ encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
630
+ {
631
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
632
+ const int * natural_order;
633
+ JBLOCKROW block;
634
+ register int temp, temp2;
635
+ register int nbits;
636
+ register int r, k;
637
+ int Se, Al;
638
+
639
+ entropy->next_output_byte = cinfo->dest->next_output_byte;
640
+ entropy->free_in_buffer = cinfo->dest->free_in_buffer;
641
+
642
+ /* Emit restart marker if needed */
643
+ if (cinfo->restart_interval)
644
+ if (entropy->restarts_to_go == 0)
645
+ emit_restart_e(entropy, entropy->next_restart_num);
646
+
647
+ Se = cinfo->Se;
648
+ Al = cinfo->Al;
649
+ natural_order = cinfo->natural_order;
650
+
651
+ /* Encode the MCU data block */
652
+ block = MCU_data[0];
653
+
654
+ /* Encode the AC coefficients per section G.1.2.2, fig. G.3 */
655
+
656
+ r = 0; /* r = run length of zeros */
657
+
658
+ for (k = cinfo->Ss; k <= Se; k++) {
659
+ if ((temp = (*block)[natural_order[k]]) == 0) {
660
+ r++;
661
+ continue;
662
+ }
663
+ /* We must apply the point transform by Al. For AC coefficients this
664
+ * is an integer division with rounding towards 0. To do this portably
665
+ * in C, we shift after obtaining the absolute value; so the code is
666
+ * interwoven with finding the abs value (temp) and output bits (temp2).
667
+ */
668
+ if (temp < 0) {
669
+ temp = -temp; /* temp is abs value of input */
670
+ temp >>= Al; /* apply the point transform */
671
+ /* For a negative coef, want temp2 = bitwise complement of abs(coef) */
672
+ temp2 = ~temp;
673
+ } else {
674
+ temp >>= Al; /* apply the point transform */
675
+ temp2 = temp;
676
+ }
677
+ /* Watch out for case that nonzero coef is zero after point transform */
678
+ if (temp == 0) {
679
+ r++;
680
+ continue;
681
+ }
682
+
683
+ /* Emit any pending EOBRUN */
684
+ if (entropy->EOBRUN > 0)
685
+ emit_eobrun(entropy);
686
+ /* if run length > 15, must emit special run-length-16 codes (0xF0) */
687
+ while (r > 15) {
688
+ emit_ac_symbol(entropy, entropy->ac_tbl_no, 0xF0);
689
+ r -= 16;
690
+ }
691
+
692
+ /* Find the number of bits needed for the magnitude of the coefficient */
693
+ nbits = 1; /* there must be at least one 1 bit */
694
+ while ((temp >>= 1))
695
+ nbits++;
696
+ /* Check for out-of-range coefficient values */
697
+ if (nbits > MAX_COEF_BITS)
698
+ ERREXIT(cinfo, JERR_BAD_DCT_COEF);
699
+
700
+ /* Count/emit Huffman symbol for run length / number of bits */
701
+ emit_ac_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits);
702
+
703
+ /* Emit that number of bits of the value, if positive, */
704
+ /* or the complement of its magnitude, if negative. */
705
+ emit_bits_e(entropy, (unsigned int) temp2, nbits);
706
+
707
+ r = 0; /* reset zero run length */
708
+ }
709
+
710
+ if (r > 0) { /* If there are trailing zeroes, */
711
+ entropy->EOBRUN++; /* count an EOB */
712
+ if (entropy->EOBRUN == 0x7FFF)
713
+ emit_eobrun(entropy); /* force it out to avoid overflow */
714
+ }
715
+
716
+ cinfo->dest->next_output_byte = entropy->next_output_byte;
717
+ cinfo->dest->free_in_buffer = entropy->free_in_buffer;
718
+
719
+ /* Update restart-interval state too */
720
+ if (cinfo->restart_interval) {
721
+ if (entropy->restarts_to_go == 0) {
722
+ entropy->restarts_to_go = cinfo->restart_interval;
723
+ entropy->next_restart_num++;
724
+ entropy->next_restart_num &= 7;
725
+ }
726
+ entropy->restarts_to_go--;
727
+ }
728
+
729
+ return TRUE;
730
+ }
731
+
732
+
733
+ /*
734
+ * MCU encoding for DC successive approximation refinement scan.
735
+ * Note: we assume such scans can be multi-component,
736
+ * although the spec is not very clear on the point.
737
+ */
738
+
739
+ METHODDEF(boolean)
740
+ encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
741
+ {
742
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
743
+ int Al, blkn;
744
+
745
+ entropy->next_output_byte = cinfo->dest->next_output_byte;
746
+ entropy->free_in_buffer = cinfo->dest->free_in_buffer;
747
+
748
+ /* Emit restart marker if needed */
749
+ if (cinfo->restart_interval)
750
+ if (entropy->restarts_to_go == 0)
751
+ emit_restart_e(entropy, entropy->next_restart_num);
752
+
753
+ Al = cinfo->Al;
754
+
755
+ /* Encode the MCU data blocks */
756
+ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
757
+ /* We simply emit the Al'th bit of the DC coefficient value. */
758
+ emit_bits_e(entropy, (unsigned int) (MCU_data[blkn][0][0] >> Al), 1);
759
+ }
760
+
761
+ cinfo->dest->next_output_byte = entropy->next_output_byte;
762
+ cinfo->dest->free_in_buffer = entropy->free_in_buffer;
763
+
764
+ /* Update restart-interval state too */
765
+ if (cinfo->restart_interval) {
766
+ if (entropy->restarts_to_go == 0) {
767
+ entropy->restarts_to_go = cinfo->restart_interval;
768
+ entropy->next_restart_num++;
769
+ entropy->next_restart_num &= 7;
770
+ }
771
+ entropy->restarts_to_go--;
772
+ }
773
+
774
+ return TRUE;
775
+ }
776
+
777
+
778
+ /*
779
+ * MCU encoding for AC successive approximation refinement scan.
780
+ */
781
+
782
+ METHODDEF(boolean)
783
+ encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
784
+ {
785
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
786
+ const int * natural_order;
787
+ JBLOCKROW block;
788
+ register int temp;
789
+ register int r, k;
790
+ int Se, Al;
791
+ int EOB;
792
+ char *BR_buffer;
793
+ unsigned int BR;
794
+ int absvalues[DCTSIZE2];
795
+
796
+ entropy->next_output_byte = cinfo->dest->next_output_byte;
797
+ entropy->free_in_buffer = cinfo->dest->free_in_buffer;
798
+
799
+ /* Emit restart marker if needed */
800
+ if (cinfo->restart_interval)
801
+ if (entropy->restarts_to_go == 0)
802
+ emit_restart_e(entropy, entropy->next_restart_num);
803
+
804
+ Se = cinfo->Se;
805
+ Al = cinfo->Al;
806
+ natural_order = cinfo->natural_order;
807
+
808
+ /* Encode the MCU data block */
809
+ block = MCU_data[0];
810
+
811
+ /* It is convenient to make a pre-pass to determine the transformed
812
+ * coefficients' absolute values and the EOB position.
813
+ */
814
+ EOB = 0;
815
+ for (k = cinfo->Ss; k <= Se; k++) {
816
+ temp = (*block)[natural_order[k]];
817
+ /* We must apply the point transform by Al. For AC coefficients this
818
+ * is an integer division with rounding towards 0. To do this portably
819
+ * in C, we shift after obtaining the absolute value.
820
+ */
821
+ if (temp < 0)
822
+ temp = -temp; /* temp is abs value of input */
823
+ temp >>= Al; /* apply the point transform */
824
+ absvalues[k] = temp; /* save abs value for main pass */
825
+ if (temp == 1)
826
+ EOB = k; /* EOB = index of last newly-nonzero coef */
827
+ }
828
+
829
+ /* Encode the AC coefficients per section G.1.2.3, fig. G.7 */
830
+
831
+ r = 0; /* r = run length of zeros */
832
+ BR = 0; /* BR = count of buffered bits added now */
833
+ BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */
834
+
835
+ for (k = cinfo->Ss; k <= Se; k++) {
836
+ if ((temp = absvalues[k]) == 0) {
837
+ r++;
838
+ continue;
839
+ }
840
+
841
+ /* Emit any required ZRLs, but not if they can be folded into EOB */
842
+ while (r > 15 && k <= EOB) {
843
+ /* emit any pending EOBRUN and the BE correction bits */
844
+ emit_eobrun(entropy);
845
+ /* Emit ZRL */
846
+ emit_ac_symbol(entropy, entropy->ac_tbl_no, 0xF0);
847
+ r -= 16;
848
+ /* Emit buffered correction bits that must be associated with ZRL */
849
+ emit_buffered_bits(entropy, BR_buffer, BR);
850
+ BR_buffer = entropy->bit_buffer; /* BE bits are gone now */
851
+ BR = 0;
852
+ }
853
+
854
+ /* If the coef was previously nonzero, it only needs a correction bit.
855
+ * NOTE: a straight translation of the spec's figure G.7 would suggest
856
+ * that we also need to test r > 15. But if r > 15, we can only get here
857
+ * if k > EOB, which implies that this coefficient is not 1.
858
+ */
859
+ if (temp > 1) {
860
+ /* The correction bit is the next bit of the absolute value. */
861
+ BR_buffer[BR++] = (char) (temp & 1);
862
+ continue;
863
+ }
864
+
865
+ /* Emit any pending EOBRUN and the BE correction bits */
866
+ emit_eobrun(entropy);
867
+
868
+ /* Count/emit Huffman symbol for run length / number of bits */
869
+ emit_ac_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1);
870
+
871
+ /* Emit output bit for newly-nonzero coef */
872
+ temp = ((*block)[natural_order[k]] < 0) ? 0 : 1;
873
+ emit_bits_e(entropy, (unsigned int) temp, 1);
874
+
875
+ /* Emit buffered correction bits that must be associated with this code */
876
+ emit_buffered_bits(entropy, BR_buffer, BR);
877
+ BR_buffer = entropy->bit_buffer; /* BE bits are gone now */
878
+ BR = 0;
879
+ r = 0; /* reset zero run length */
880
+ }
881
+
882
+ if (r > 0 || BR > 0) { /* If there are trailing zeroes, */
883
+ entropy->EOBRUN++; /* count an EOB */
884
+ entropy->BE += BR; /* concat my correction bits to older ones */
885
+ /* We force out the EOB if we risk either:
886
+ * 1. overflow of the EOB counter;
887
+ * 2. overflow of the correction bit buffer during the next MCU.
888
+ */
889
+ if (entropy->EOBRUN == 0x7FFF || entropy->BE > (MAX_CORR_BITS-DCTSIZE2+1))
890
+ emit_eobrun(entropy);
891
+ }
892
+
893
+ cinfo->dest->next_output_byte = entropy->next_output_byte;
894
+ cinfo->dest->free_in_buffer = entropy->free_in_buffer;
895
+
896
+ /* Update restart-interval state too */
897
+ if (cinfo->restart_interval) {
898
+ if (entropy->restarts_to_go == 0) {
899
+ entropy->restarts_to_go = cinfo->restart_interval;
900
+ entropy->next_restart_num++;
901
+ entropy->next_restart_num &= 7;
902
+ }
903
+ entropy->restarts_to_go--;
904
+ }
905
+
906
+ return TRUE;
907
+ }
908
+
909
+
910
+ /* Encode a single block's worth of coefficients */
911
+
912
+ LOCAL(boolean)
913
+ encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val,
914
+ c_derived_tbl *dctbl, c_derived_tbl *actbl)
915
+ {
916
+ register int temp, temp2;
917
+ register int nbits;
918
+ register int r, k;
919
+ int Se = state->cinfo->lim_Se;
920
+ const int * natural_order = state->cinfo->natural_order;
921
+
922
+ /* Encode the DC coefficient difference per section F.1.2.1 */
923
+
924
+ temp = temp2 = block[0] - last_dc_val;
925
+
926
+ if (temp < 0) {
927
+ temp = -temp; /* temp is abs value of input */
928
+ /* For a negative input, want temp2 = bitwise complement of abs(input) */
929
+ /* This code assumes we are on a two's complement machine */
930
+ temp2--;
931
+ }
932
+
933
+ /* Find the number of bits needed for the magnitude of the coefficient */
934
+ nbits = 0;
935
+ while (temp) {
936
+ nbits++;
937
+ temp >>= 1;
938
+ }
939
+ /* Check for out-of-range coefficient values.
940
+ * Since we're encoding a difference, the range limit is twice as much.
941
+ */
942
+ if (nbits > MAX_COEF_BITS+1)
943
+ ERREXIT(state->cinfo, JERR_BAD_DCT_COEF);
944
+
945
+ /* Emit the Huffman-coded symbol for the number of bits */
946
+ if (! emit_bits_s(state, dctbl->ehufco[nbits], dctbl->ehufsi[nbits]))
947
+ return FALSE;
948
+
949
+ /* Emit that number of bits of the value, if positive, */
950
+ /* or the complement of its magnitude, if negative. */
951
+ if (nbits) /* emit_bits rejects calls with size 0 */
952
+ if (! emit_bits_s(state, (unsigned int) temp2, nbits))
953
+ return FALSE;
954
+
955
+ /* Encode the AC coefficients per section F.1.2.2 */
956
+
957
+ r = 0; /* r = run length of zeros */
958
+
959
+ for (k = 1; k <= Se; k++) {
960
+ if ((temp2 = block[natural_order[k]]) == 0) {
961
+ r++;
962
+ } else {
963
+ /* if run length > 15, must emit special run-length-16 codes (0xF0) */
964
+ while (r > 15) {
965
+ if (! emit_bits_s(state, actbl->ehufco[0xF0], actbl->ehufsi[0xF0]))
966
+ return FALSE;
967
+ r -= 16;
968
+ }
969
+
970
+ temp = temp2;
971
+ if (temp < 0) {
972
+ temp = -temp; /* temp is abs value of input */
973
+ /* This code assumes we are on a two's complement machine */
974
+ temp2--;
975
+ }
976
+
977
+ /* Find the number of bits needed for the magnitude of the coefficient */
978
+ nbits = 1; /* there must be at least one 1 bit */
979
+ while ((temp >>= 1))
980
+ nbits++;
981
+ /* Check for out-of-range coefficient values */
982
+ if (nbits > MAX_COEF_BITS)
983
+ ERREXIT(state->cinfo, JERR_BAD_DCT_COEF);
984
+
985
+ /* Emit Huffman symbol for run length / number of bits */
986
+ temp = (r << 4) + nbits;
987
+ if (! emit_bits_s(state, actbl->ehufco[temp], actbl->ehufsi[temp]))
988
+ return FALSE;
989
+
990
+ /* Emit that number of bits of the value, if positive, */
991
+ /* or the complement of its magnitude, if negative. */
992
+ if (! emit_bits_s(state, (unsigned int) temp2, nbits))
993
+ return FALSE;
994
+
995
+ r = 0;
996
+ }
997
+ }
998
+
999
+ /* If the last coef(s) were zero, emit an end-of-block code */
1000
+ if (r > 0)
1001
+ if (! emit_bits_s(state, actbl->ehufco[0], actbl->ehufsi[0]))
1002
+ return FALSE;
1003
+
1004
+ return TRUE;
1005
+ }
1006
+
1007
+
1008
+ /*
1009
+ * Encode and output one MCU's worth of Huffman-compressed coefficients.
1010
+ */
1011
+
1012
+ METHODDEF(boolean)
1013
+ encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
1014
+ {
1015
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
1016
+ working_state state;
1017
+ int blkn, ci;
1018
+ jpeg_component_info * compptr;
1019
+
1020
+ /* Load up working state */
1021
+ state.next_output_byte = cinfo->dest->next_output_byte;
1022
+ state.free_in_buffer = cinfo->dest->free_in_buffer;
1023
+ ASSIGN_STATE(state.cur, entropy->saved);
1024
+ state.cinfo = cinfo;
1025
+
1026
+ /* Emit restart marker if needed */
1027
+ if (cinfo->restart_interval) {
1028
+ if (entropy->restarts_to_go == 0)
1029
+ if (! emit_restart_s(&state, entropy->next_restart_num))
1030
+ return FALSE;
1031
+ }
1032
+
1033
+ /* Encode the MCU data blocks */
1034
+ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
1035
+ ci = cinfo->MCU_membership[blkn];
1036
+ compptr = cinfo->cur_comp_info[ci];
1037
+ if (! encode_one_block(&state,
1038
+ MCU_data[blkn][0], state.cur.last_dc_val[ci],
1039
+ entropy->dc_derived_tbls[compptr->dc_tbl_no],
1040
+ entropy->ac_derived_tbls[compptr->ac_tbl_no]))
1041
+ return FALSE;
1042
+ /* Update last_dc_val */
1043
+ state.cur.last_dc_val[ci] = MCU_data[blkn][0][0];
1044
+ }
1045
+
1046
+ /* Completed MCU, so update state */
1047
+ cinfo->dest->next_output_byte = state.next_output_byte;
1048
+ cinfo->dest->free_in_buffer = state.free_in_buffer;
1049
+ ASSIGN_STATE(entropy->saved, state.cur);
1050
+
1051
+ /* Update restart-interval state too */
1052
+ if (cinfo->restart_interval) {
1053
+ if (entropy->restarts_to_go == 0) {
1054
+ entropy->restarts_to_go = cinfo->restart_interval;
1055
+ entropy->next_restart_num++;
1056
+ entropy->next_restart_num &= 7;
1057
+ }
1058
+ entropy->restarts_to_go--;
1059
+ }
1060
+
1061
+ return TRUE;
1062
+ }
1063
+
1064
+
1065
+ /*
1066
+ * Finish up at the end of a Huffman-compressed scan.
1067
+ */
1068
+
1069
+ METHODDEF(void)
1070
+ finish_pass_huff (j_compress_ptr cinfo)
1071
+ {
1072
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
1073
+ working_state state;
1074
+
1075
+ if (cinfo->progressive_mode) {
1076
+ entropy->next_output_byte = cinfo->dest->next_output_byte;
1077
+ entropy->free_in_buffer = cinfo->dest->free_in_buffer;
1078
+
1079
+ /* Flush out any buffered data */
1080
+ emit_eobrun(entropy);
1081
+ flush_bits_e(entropy);
1082
+
1083
+ cinfo->dest->next_output_byte = entropy->next_output_byte;
1084
+ cinfo->dest->free_in_buffer = entropy->free_in_buffer;
1085
+ } else {
1086
+ /* Load up working state ... flush_bits needs it */
1087
+ state.next_output_byte = cinfo->dest->next_output_byte;
1088
+ state.free_in_buffer = cinfo->dest->free_in_buffer;
1089
+ ASSIGN_STATE(state.cur, entropy->saved);
1090
+ state.cinfo = cinfo;
1091
+
1092
+ /* Flush out the last data */
1093
+ if (! flush_bits_s(&state))
1094
+ ERREXIT(cinfo, JERR_CANT_SUSPEND);
1095
+
1096
+ /* Update state */
1097
+ cinfo->dest->next_output_byte = state.next_output_byte;
1098
+ cinfo->dest->free_in_buffer = state.free_in_buffer;
1099
+ ASSIGN_STATE(entropy->saved, state.cur);
1100
+ }
1101
+ }
1102
+
1103
+
1104
+ /*
1105
+ * Huffman coding optimization.
1106
+ *
1107
+ * We first scan the supplied data and count the number of uses of each symbol
1108
+ * that is to be Huffman-coded. (This process MUST agree with the code above.)
1109
+ * Then we build a Huffman coding tree for the observed counts.
1110
+ * Symbols which are not needed at all for the particular image are not
1111
+ * assigned any code, which saves space in the DHT marker as well as in
1112
+ * the compressed data.
1113
+ */
1114
+
1115
+
1116
+ /* Process a single block's worth of coefficients */
1117
+
1118
+ LOCAL(void)
1119
+ htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val,
1120
+ long dc_counts[], long ac_counts[])
1121
+ {
1122
+ register int temp;
1123
+ register int nbits;
1124
+ register int r, k;
1125
+ int Se = cinfo->lim_Se;
1126
+ const int * natural_order = cinfo->natural_order;
1127
+
1128
+ /* Encode the DC coefficient difference per section F.1.2.1 */
1129
+
1130
+ temp = block[0] - last_dc_val;
1131
+ if (temp < 0)
1132
+ temp = -temp;
1133
+
1134
+ /* Find the number of bits needed for the magnitude of the coefficient */
1135
+ nbits = 0;
1136
+ while (temp) {
1137
+ nbits++;
1138
+ temp >>= 1;
1139
+ }
1140
+ /* Check for out-of-range coefficient values.
1141
+ * Since we're encoding a difference, the range limit is twice as much.
1142
+ */
1143
+ if (nbits > MAX_COEF_BITS+1)
1144
+ ERREXIT(cinfo, JERR_BAD_DCT_COEF);
1145
+
1146
+ /* Count the Huffman symbol for the number of bits */
1147
+ dc_counts[nbits]++;
1148
+
1149
+ /* Encode the AC coefficients per section F.1.2.2 */
1150
+
1151
+ r = 0; /* r = run length of zeros */
1152
+
1153
+ for (k = 1; k <= Se; k++) {
1154
+ if ((temp = block[natural_order[k]]) == 0) {
1155
+ r++;
1156
+ } else {
1157
+ /* if run length > 15, must emit special run-length-16 codes (0xF0) */
1158
+ while (r > 15) {
1159
+ ac_counts[0xF0]++;
1160
+ r -= 16;
1161
+ }
1162
+
1163
+ /* Find the number of bits needed for the magnitude of the coefficient */
1164
+ if (temp < 0)
1165
+ temp = -temp;
1166
+
1167
+ /* Find the number of bits needed for the magnitude of the coefficient */
1168
+ nbits = 1; /* there must be at least one 1 bit */
1169
+ while ((temp >>= 1))
1170
+ nbits++;
1171
+ /* Check for out-of-range coefficient values */
1172
+ if (nbits > MAX_COEF_BITS)
1173
+ ERREXIT(cinfo, JERR_BAD_DCT_COEF);
1174
+
1175
+ /* Count Huffman symbol for run length / number of bits */
1176
+ ac_counts[(r << 4) + nbits]++;
1177
+
1178
+ r = 0;
1179
+ }
1180
+ }
1181
+
1182
+ /* If the last coef(s) were zero, emit an end-of-block code */
1183
+ if (r > 0)
1184
+ ac_counts[0]++;
1185
+ }
1186
+
1187
+
1188
+ /*
1189
+ * Trial-encode one MCU's worth of Huffman-compressed coefficients.
1190
+ * No data is actually output, so no suspension return is possible.
1191
+ */
1192
+
1193
+ METHODDEF(boolean)
1194
+ encode_mcu_gather (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
1195
+ {
1196
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
1197
+ int blkn, ci;
1198
+ jpeg_component_info * compptr;
1199
+
1200
+ /* Take care of restart intervals if needed */
1201
+ if (cinfo->restart_interval) {
1202
+ if (entropy->restarts_to_go == 0) {
1203
+ /* Re-initialize DC predictions to 0 */
1204
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++)
1205
+ entropy->saved.last_dc_val[ci] = 0;
1206
+ /* Update restart state */
1207
+ entropy->restarts_to_go = cinfo->restart_interval;
1208
+ }
1209
+ entropy->restarts_to_go--;
1210
+ }
1211
+
1212
+ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
1213
+ ci = cinfo->MCU_membership[blkn];
1214
+ compptr = cinfo->cur_comp_info[ci];
1215
+ htest_one_block(cinfo, MCU_data[blkn][0], entropy->saved.last_dc_val[ci],
1216
+ entropy->dc_count_ptrs[compptr->dc_tbl_no],
1217
+ entropy->ac_count_ptrs[compptr->ac_tbl_no]);
1218
+ entropy->saved.last_dc_val[ci] = MCU_data[blkn][0][0];
1219
+ }
1220
+
1221
+ return TRUE;
1222
+ }
1223
+
1224
+
1225
+ /*
1226
+ * Generate the best Huffman code table for the given counts, fill htbl.
1227
+ *
1228
+ * The JPEG standard requires that no symbol be assigned a codeword of all
1229
+ * one bits (so that padding bits added at the end of a compressed segment
1230
+ * can't look like a valid code). Because of the canonical ordering of
1231
+ * codewords, this just means that there must be an unused slot in the
1232
+ * longest codeword length category. Section K.2 of the JPEG spec suggests
1233
+ * reserving such a slot by pretending that symbol 256 is a valid symbol
1234
+ * with count 1. In theory that's not optimal; giving it count zero but
1235
+ * including it in the symbol set anyway should give a better Huffman code.
1236
+ * But the theoretically better code actually seems to come out worse in
1237
+ * practice, because it produces more all-ones bytes (which incur stuffed
1238
+ * zero bytes in the final file). In any case the difference is tiny.
1239
+ *
1240
+ * The JPEG standard requires Huffman codes to be no more than 16 bits long.
1241
+ * If some symbols have a very small but nonzero probability, the Huffman tree
1242
+ * must be adjusted to meet the code length restriction. We currently use
1243
+ * the adjustment method suggested in JPEG section K.2. This method is *not*
1244
+ * optimal; it may not choose the best possible limited-length code. But
1245
+ * typically only very-low-frequency symbols will be given less-than-optimal
1246
+ * lengths, so the code is almost optimal. Experimental comparisons against
1247
+ * an optimal limited-length-code algorithm indicate that the difference is
1248
+ * microscopic --- usually less than a hundredth of a percent of total size.
1249
+ * So the extra complexity of an optimal algorithm doesn't seem worthwhile.
1250
+ */
1251
+
1252
+ LOCAL(void)
1253
+ jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])
1254
+ {
1255
+ #define MAX_CLEN 32 /* assumed maximum initial code length */
1256
+ UINT8 bits[MAX_CLEN+1]; /* bits[k] = # of symbols with code length k */
1257
+ int codesize[257]; /* codesize[k] = code length of symbol k */
1258
+ int others[257]; /* next symbol in current branch of tree */
1259
+ int c1, c2;
1260
+ int p, i, j;
1261
+ long v;
1262
+
1263
+ /* This algorithm is explained in section K.2 of the JPEG standard */
1264
+
1265
+ MEMZERO(bits, SIZEOF(bits));
1266
+ MEMZERO(codesize, SIZEOF(codesize));
1267
+ for (i = 0; i < 257; i++)
1268
+ others[i] = -1; /* init links to empty */
1269
+
1270
+ freq[256] = 1; /* make sure 256 has a nonzero count */
1271
+ /* Including the pseudo-symbol 256 in the Huffman procedure guarantees
1272
+ * that no real symbol is given code-value of all ones, because 256
1273
+ * will be placed last in the largest codeword category.
1274
+ */
1275
+
1276
+ /* Huffman's basic algorithm to assign optimal code lengths to symbols */
1277
+
1278
+ for (;;) {
1279
+ /* Find the smallest nonzero frequency, set c1 = its symbol */
1280
+ /* In case of ties, take the larger symbol number */
1281
+ c1 = -1;
1282
+ v = 1000000000L;
1283
+ for (i = 0; i <= 256; i++) {
1284
+ if (freq[i] && freq[i] <= v) {
1285
+ v = freq[i];
1286
+ c1 = i;
1287
+ }
1288
+ }
1289
+
1290
+ /* Find the next smallest nonzero frequency, set c2 = its symbol */
1291
+ /* In case of ties, take the larger symbol number */
1292
+ c2 = -1;
1293
+ v = 1000000000L;
1294
+ for (i = 0; i <= 256; i++) {
1295
+ if (freq[i] && freq[i] <= v && i != c1) {
1296
+ v = freq[i];
1297
+ c2 = i;
1298
+ }
1299
+ }
1300
+
1301
+ /* Done if we've merged everything into one frequency */
1302
+ if (c2 < 0)
1303
+ break;
1304
+
1305
+ /* Else merge the two counts/trees */
1306
+ freq[c1] += freq[c2];
1307
+ freq[c2] = 0;
1308
+
1309
+ /* Increment the codesize of everything in c1's tree branch */
1310
+ codesize[c1]++;
1311
+ while (others[c1] >= 0) {
1312
+ c1 = others[c1];
1313
+ codesize[c1]++;
1314
+ }
1315
+
1316
+ others[c1] = c2; /* chain c2 onto c1's tree branch */
1317
+
1318
+ /* Increment the codesize of everything in c2's tree branch */
1319
+ codesize[c2]++;
1320
+ while (others[c2] >= 0) {
1321
+ c2 = others[c2];
1322
+ codesize[c2]++;
1323
+ }
1324
+ }
1325
+
1326
+ /* Now count the number of symbols of each code length */
1327
+ for (i = 0; i <= 256; i++) {
1328
+ if (codesize[i]) {
1329
+ /* The JPEG standard seems to think that this can't happen, */
1330
+ /* but I'm paranoid... */
1331
+ if (codesize[i] > MAX_CLEN)
1332
+ ERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW);
1333
+
1334
+ bits[codesize[i]]++;
1335
+ }
1336
+ }
1337
+
1338
+ /* JPEG doesn't allow symbols with code lengths over 16 bits, so if the pure
1339
+ * Huffman procedure assigned any such lengths, we must adjust the coding.
1340
+ * Here is what the JPEG spec says about how this next bit works:
1341
+ * Since symbols are paired for the longest Huffman code, the symbols are
1342
+ * removed from this length category two at a time. The prefix for the pair
1343
+ * (which is one bit shorter) is allocated to one of the pair; then,
1344
+ * skipping the BITS entry for that prefix length, a code word from the next
1345
+ * shortest nonzero BITS entry is converted into a prefix for two code words
1346
+ * one bit longer.
1347
+ */
1348
+
1349
+ for (i = MAX_CLEN; i > 16; i--) {
1350
+ while (bits[i] > 0) {
1351
+ j = i - 2; /* find length of new prefix to be used */
1352
+ while (bits[j] == 0)
1353
+ j--;
1354
+
1355
+ bits[i] -= 2; /* remove two symbols */
1356
+ bits[i-1]++; /* one goes in this length */
1357
+ bits[j+1] += 2; /* two new symbols in this length */
1358
+ bits[j]--; /* symbol of this length is now a prefix */
1359
+ }
1360
+ }
1361
+
1362
+ /* Remove the count for the pseudo-symbol 256 from the largest codelength */
1363
+ while (bits[i] == 0) /* find largest codelength still in use */
1364
+ i--;
1365
+ bits[i]--;
1366
+
1367
+ /* Return final symbol counts (only for lengths 0..16) */
1368
+ MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits));
1369
+
1370
+ /* Return a list of the symbols sorted by code length */
1371
+ /* It's not real clear to me why we don't need to consider the codelength
1372
+ * changes made above, but the JPEG spec seems to think this works.
1373
+ */
1374
+ p = 0;
1375
+ for (i = 1; i <= MAX_CLEN; i++) {
1376
+ for (j = 0; j <= 255; j++) {
1377
+ if (codesize[j] == i) {
1378
+ htbl->huffval[p] = (UINT8) j;
1379
+ p++;
1380
+ }
1381
+ }
1382
+ }
1383
+
1384
+ /* Set sent_table FALSE so updated table will be written to JPEG file. */
1385
+ htbl->sent_table = FALSE;
1386
+ }
1387
+
1388
+
1389
+ /*
1390
+ * Finish up a statistics-gathering pass and create the new Huffman tables.
1391
+ */
1392
+
1393
+ METHODDEF(void)
1394
+ finish_pass_gather (j_compress_ptr cinfo)
1395
+ {
1396
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
1397
+ int ci, tbl;
1398
+ jpeg_component_info * compptr;
1399
+ JHUFF_TBL **htblptr;
1400
+ boolean did_dc[NUM_HUFF_TBLS];
1401
+ boolean did_ac[NUM_HUFF_TBLS];
1402
+
1403
+ /* It's important not to apply jpeg_gen_optimal_table more than once
1404
+ * per table, because it clobbers the input frequency counts!
1405
+ */
1406
+ if (cinfo->progressive_mode)
1407
+ /* Flush out buffered data (all we care about is counting the EOB symbol) */
1408
+ emit_eobrun(entropy);
1409
+
1410
+ MEMZERO(did_dc, SIZEOF(did_dc));
1411
+ MEMZERO(did_ac, SIZEOF(did_ac));
1412
+
1413
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
1414
+ compptr = cinfo->cur_comp_info[ci];
1415
+ /* DC needs no table for refinement scan */
1416
+ if (cinfo->Ss == 0 && cinfo->Ah == 0) {
1417
+ tbl = compptr->dc_tbl_no;
1418
+ if (! did_dc[tbl]) {
1419
+ htblptr = & cinfo->dc_huff_tbl_ptrs[tbl];
1420
+ if (*htblptr == NULL)
1421
+ *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
1422
+ jpeg_gen_optimal_table(cinfo, *htblptr, entropy->dc_count_ptrs[tbl]);
1423
+ did_dc[tbl] = TRUE;
1424
+ }
1425
+ }
1426
+ /* AC needs no table when not present */
1427
+ if (cinfo->Se) {
1428
+ tbl = compptr->ac_tbl_no;
1429
+ if (! did_ac[tbl]) {
1430
+ htblptr = & cinfo->ac_huff_tbl_ptrs[tbl];
1431
+ if (*htblptr == NULL)
1432
+ *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
1433
+ jpeg_gen_optimal_table(cinfo, *htblptr, entropy->ac_count_ptrs[tbl]);
1434
+ did_ac[tbl] = TRUE;
1435
+ }
1436
+ }
1437
+ }
1438
+ }
1439
+
1440
+
1441
+ /*
1442
+ * Initialize for a Huffman-compressed scan.
1443
+ * If gather_statistics is TRUE, we do not output anything during the scan,
1444
+ * just count the Huffman symbols used and generate Huffman code tables.
1445
+ */
1446
+
1447
+ METHODDEF(void)
1448
+ start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics)
1449
+ {
1450
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
1451
+ int ci, tbl;
1452
+ jpeg_component_info * compptr;
1453
+
1454
+ if (gather_statistics)
1455
+ entropy->pub.finish_pass = finish_pass_gather;
1456
+ else
1457
+ entropy->pub.finish_pass = finish_pass_huff;
1458
+
1459
+ if (cinfo->progressive_mode) {
1460
+ entropy->cinfo = cinfo;
1461
+ entropy->gather_statistics = gather_statistics;
1462
+
1463
+ /* We assume jcmaster.c already validated the scan parameters. */
1464
+
1465
+ /* Select execution routine */
1466
+ if (cinfo->Ah == 0) {
1467
+ if (cinfo->Ss == 0)
1468
+ entropy->pub.encode_mcu = encode_mcu_DC_first;
1469
+ else
1470
+ entropy->pub.encode_mcu = encode_mcu_AC_first;
1471
+ } else {
1472
+ if (cinfo->Ss == 0)
1473
+ entropy->pub.encode_mcu = encode_mcu_DC_refine;
1474
+ else {
1475
+ entropy->pub.encode_mcu = encode_mcu_AC_refine;
1476
+ /* AC refinement needs a correction bit buffer */
1477
+ if (entropy->bit_buffer == NULL)
1478
+ entropy->bit_buffer = (char *)
1479
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
1480
+ MAX_CORR_BITS * SIZEOF(char));
1481
+ }
1482
+ }
1483
+
1484
+ /* Initialize AC stuff */
1485
+ entropy->ac_tbl_no = cinfo->cur_comp_info[0]->ac_tbl_no;
1486
+ entropy->EOBRUN = 0;
1487
+ entropy->BE = 0;
1488
+ } else {
1489
+ if (gather_statistics)
1490
+ entropy->pub.encode_mcu = encode_mcu_gather;
1491
+ else
1492
+ entropy->pub.encode_mcu = encode_mcu_huff;
1493
+ }
1494
+
1495
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
1496
+ compptr = cinfo->cur_comp_info[ci];
1497
+ /* DC needs no table for refinement scan */
1498
+ if (cinfo->Ss == 0 && cinfo->Ah == 0) {
1499
+ tbl = compptr->dc_tbl_no;
1500
+ if (gather_statistics) {
1501
+ /* Check for invalid table index */
1502
+ /* (make_c_derived_tbl does this in the other path) */
1503
+ if (tbl < 0 || tbl >= NUM_HUFF_TBLS)
1504
+ ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);
1505
+ /* Allocate and zero the statistics tables */
1506
+ /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
1507
+ if (entropy->dc_count_ptrs[tbl] == NULL)
1508
+ entropy->dc_count_ptrs[tbl] = (long *)
1509
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
1510
+ 257 * SIZEOF(long));
1511
+ MEMZERO(entropy->dc_count_ptrs[tbl], 257 * SIZEOF(long));
1512
+ } else {
1513
+ /* Compute derived values for Huffman tables */
1514
+ /* We may do this more than once for a table, but it's not expensive */
1515
+ jpeg_make_c_derived_tbl(cinfo, TRUE, tbl,
1516
+ & entropy->dc_derived_tbls[tbl]);
1517
+ }
1518
+ /* Initialize DC predictions to 0 */
1519
+ entropy->saved.last_dc_val[ci] = 0;
1520
+ }
1521
+ /* AC needs no table when not present */
1522
+ if (cinfo->Se) {
1523
+ tbl = compptr->ac_tbl_no;
1524
+ if (gather_statistics) {
1525
+ if (tbl < 0 || tbl >= NUM_HUFF_TBLS)
1526
+ ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);
1527
+ if (entropy->ac_count_ptrs[tbl] == NULL)
1528
+ entropy->ac_count_ptrs[tbl] = (long *)
1529
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
1530
+ 257 * SIZEOF(long));
1531
+ MEMZERO(entropy->ac_count_ptrs[tbl], 257 * SIZEOF(long));
1532
+ } else {
1533
+ jpeg_make_c_derived_tbl(cinfo, FALSE, tbl,
1534
+ & entropy->ac_derived_tbls[tbl]);
1535
+ }
1536
+ }
1537
+ }
1538
+
1539
+ /* Initialize bit buffer to empty */
1540
+ entropy->saved.put_buffer = 0;
1541
+ entropy->saved.put_bits = 0;
1542
+
1543
+ /* Initialize restart stuff */
1544
+ entropy->restarts_to_go = cinfo->restart_interval;
1545
+ entropy->next_restart_num = 0;
1546
+ }
1547
+
1548
+
1549
+ /*
1550
+ * Module initialization routine for Huffman entropy encoding.
1551
+ */
1552
+
1553
+ GLOBAL(void)
1554
+ jinit_huff_encoder (j_compress_ptr cinfo)
1555
+ {
1556
+ huff_entropy_ptr entropy;
1557
+ int i;
1558
+
1559
+ entropy = (huff_entropy_ptr)
1560
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
1561
+ SIZEOF(huff_entropy_encoder));
1562
+ cinfo->entropy = &entropy->pub;
1563
+ entropy->pub.start_pass = start_pass_huff;
1564
+
1565
+ /* Mark tables unallocated */
1566
+ for (i = 0; i < NUM_HUFF_TBLS; i++) {
1567
+ entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL;
1568
+ entropy->dc_count_ptrs[i] = entropy->ac_count_ptrs[i] = NULL;
1569
+ }
1570
+
1571
+ if (cinfo->progressive_mode)
1572
+ entropy->bit_buffer = NULL; /* needed only in AC refinement scan */
1573
+ }