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,1554 @@
1
+ /*
2
+ * jdhuff.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 decoding 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 input suspension.
13
+ * If the data source module demands suspension, we want to be able to back
14
+ * up to the start of the current MCU. To do this, we copy state variables
15
+ * into local working storage, and update them back to the permanent
16
+ * storage only upon successful completion of an MCU.
17
+ */
18
+
19
+ #define JPEG_INTERNALS
20
+ #include "jinclude.h"
21
+ #include "jpeglib.h"
22
+
23
+
24
+ /* Derived data constructed for each Huffman table */
25
+
26
+ #define HUFF_LOOKAHEAD 8 /* # of bits of lookahead */
27
+
28
+ typedef struct {
29
+ /* Basic tables: (element [0] of each array is unused) */
30
+ INT32 maxcode[18]; /* largest code of length k (-1 if none) */
31
+ /* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */
32
+ INT32 valoffset[17]; /* huffval[] offset for codes of length k */
33
+ /* valoffset[k] = huffval[] index of 1st symbol of code length k, less
34
+ * the smallest code of length k; so given a code of length k, the
35
+ * corresponding symbol is huffval[code + valoffset[k]]
36
+ */
37
+
38
+ /* Link to public Huffman table (needed only in jpeg_huff_decode) */
39
+ JHUFF_TBL *pub;
40
+
41
+ /* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of
42
+ * the input data stream. If the next Huffman code is no more
43
+ * than HUFF_LOOKAHEAD bits long, we can obtain its length and
44
+ * the corresponding symbol directly from these tables.
45
+ */
46
+ int look_nbits[1<<HUFF_LOOKAHEAD]; /* # bits, or 0 if too long */
47
+ UINT8 look_sym[1<<HUFF_LOOKAHEAD]; /* symbol, or unused */
48
+ } d_derived_tbl;
49
+
50
+
51
+ /*
52
+ * Fetching the next N bits from the input stream is a time-critical operation
53
+ * for the Huffman decoders. We implement it with a combination of inline
54
+ * macros and out-of-line subroutines. Note that N (the number of bits
55
+ * demanded at one time) never exceeds 15 for JPEG use.
56
+ *
57
+ * We read source bytes into get_buffer and dole out bits as needed.
58
+ * If get_buffer already contains enough bits, they are fetched in-line
59
+ * by the macros CHECK_BIT_BUFFER and GET_BITS. When there aren't enough
60
+ * bits, jpeg_fill_bit_buffer is called; it will attempt to fill get_buffer
61
+ * as full as possible (not just to the number of bits needed; this
62
+ * prefetching reduces the overhead cost of calling jpeg_fill_bit_buffer).
63
+ * Note that jpeg_fill_bit_buffer may return FALSE to indicate suspension.
64
+ * On TRUE return, jpeg_fill_bit_buffer guarantees that get_buffer contains
65
+ * at least the requested number of bits --- dummy zeroes are inserted if
66
+ * necessary.
67
+ */
68
+
69
+ typedef INT32 bit_buf_type; /* type of bit-extraction buffer */
70
+ #define BIT_BUF_SIZE 32 /* size of buffer in bits */
71
+
72
+ /* If long is > 32 bits on your machine, and shifting/masking longs is
73
+ * reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE
74
+ * appropriately should be a win. Unfortunately we can't define the size
75
+ * with something like #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8)
76
+ * because not all machines measure sizeof in 8-bit bytes.
77
+ */
78
+
79
+ typedef struct { /* Bitreading state saved across MCUs */
80
+ bit_buf_type get_buffer; /* current bit-extraction buffer */
81
+ int bits_left; /* # of unused bits in it */
82
+ } bitread_perm_state;
83
+
84
+ typedef struct { /* Bitreading working state within an MCU */
85
+ /* Current data source location */
86
+ /* We need a copy, rather than munging the original, in case of suspension */
87
+ const JOCTET * next_input_byte; /* => next byte to read from source */
88
+ size_t bytes_in_buffer; /* # of bytes remaining in source buffer */
89
+ /* Bit input buffer --- note these values are kept in register variables,
90
+ * not in this struct, inside the inner loops.
91
+ */
92
+ bit_buf_type get_buffer; /* current bit-extraction buffer */
93
+ int bits_left; /* # of unused bits in it */
94
+ /* Pointer needed by jpeg_fill_bit_buffer. */
95
+ j_decompress_ptr cinfo; /* back link to decompress master record */
96
+ } bitread_working_state;
97
+
98
+ /* Macros to declare and load/save bitread local variables. */
99
+ #define BITREAD_STATE_VARS \
100
+ register bit_buf_type get_buffer; \
101
+ register int bits_left; \
102
+ bitread_working_state br_state
103
+
104
+ #define BITREAD_LOAD_STATE(cinfop,permstate) \
105
+ br_state.cinfo = cinfop; \
106
+ br_state.next_input_byte = cinfop->src->next_input_byte; \
107
+ br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \
108
+ get_buffer = permstate.get_buffer; \
109
+ bits_left = permstate.bits_left;
110
+
111
+ #define BITREAD_SAVE_STATE(cinfop,permstate) \
112
+ cinfop->src->next_input_byte = br_state.next_input_byte; \
113
+ cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \
114
+ permstate.get_buffer = get_buffer; \
115
+ permstate.bits_left = bits_left
116
+
117
+ /*
118
+ * These macros provide the in-line portion of bit fetching.
119
+ * Use CHECK_BIT_BUFFER to ensure there are N bits in get_buffer
120
+ * before using GET_BITS, PEEK_BITS, or DROP_BITS.
121
+ * The variables get_buffer and bits_left are assumed to be locals,
122
+ * but the state struct might not be (jpeg_huff_decode needs this).
123
+ * CHECK_BIT_BUFFER(state,n,action);
124
+ * Ensure there are N bits in get_buffer; if suspend, take action.
125
+ * val = GET_BITS(n);
126
+ * Fetch next N bits.
127
+ * val = PEEK_BITS(n);
128
+ * Fetch next N bits without removing them from the buffer.
129
+ * DROP_BITS(n);
130
+ * Discard next N bits.
131
+ * The value N should be a simple variable, not an expression, because it
132
+ * is evaluated multiple times.
133
+ */
134
+
135
+ #define CHECK_BIT_BUFFER(state,nbits,action) \
136
+ { if (bits_left < (nbits)) { \
137
+ if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits)) \
138
+ { action; } \
139
+ get_buffer = (state).get_buffer; bits_left = (state).bits_left; } }
140
+
141
+ #define GET_BITS(nbits) \
142
+ (((int) (get_buffer >> (bits_left -= (nbits)))) & BIT_MASK(nbits))
143
+
144
+ #define PEEK_BITS(nbits) \
145
+ (((int) (get_buffer >> (bits_left - (nbits)))) & BIT_MASK(nbits))
146
+
147
+ #define DROP_BITS(nbits) \
148
+ (bits_left -= (nbits))
149
+
150
+
151
+ /*
152
+ * Code for extracting next Huffman-coded symbol from input bit stream.
153
+ * Again, this is time-critical and we make the main paths be macros.
154
+ *
155
+ * We use a lookahead table to process codes of up to HUFF_LOOKAHEAD bits
156
+ * without looping. Usually, more than 95% of the Huffman codes will be 8
157
+ * or fewer bits long. The few overlength codes are handled with a loop,
158
+ * which need not be inline code.
159
+ *
160
+ * Notes about the HUFF_DECODE macro:
161
+ * 1. Near the end of the data segment, we may fail to get enough bits
162
+ * for a lookahead. In that case, we do it the hard way.
163
+ * 2. If the lookahead table contains no entry, the next code must be
164
+ * more than HUFF_LOOKAHEAD bits long.
165
+ * 3. jpeg_huff_decode returns -1 if forced to suspend.
166
+ */
167
+
168
+ #define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \
169
+ { register int nb, look; \
170
+ if (bits_left < HUFF_LOOKAHEAD) { \
171
+ if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \
172
+ get_buffer = state.get_buffer; bits_left = state.bits_left; \
173
+ if (bits_left < HUFF_LOOKAHEAD) { \
174
+ nb = 1; goto slowlabel; \
175
+ } \
176
+ } \
177
+ look = PEEK_BITS(HUFF_LOOKAHEAD); \
178
+ if ((nb = htbl->look_nbits[look]) != 0) { \
179
+ DROP_BITS(nb); \
180
+ result = htbl->look_sym[look]; \
181
+ } else { \
182
+ nb = HUFF_LOOKAHEAD+1; \
183
+ slowlabel: \
184
+ if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \
185
+ { failaction; } \
186
+ get_buffer = state.get_buffer; bits_left = state.bits_left; \
187
+ } \
188
+ }
189
+
190
+
191
+ /*
192
+ * Expanded entropy decoder object for Huffman decoding.
193
+ *
194
+ * The savable_state subrecord contains fields that change within an MCU,
195
+ * but must not be updated permanently until we complete the MCU.
196
+ */
197
+
198
+ typedef struct {
199
+ unsigned int EOBRUN; /* remaining EOBs in EOBRUN */
200
+ int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
201
+ } savable_state;
202
+
203
+ /* This macro is to work around compilers with missing or broken
204
+ * structure assignment. You'll need to fix this code if you have
205
+ * such a compiler and you change MAX_COMPS_IN_SCAN.
206
+ */
207
+
208
+ #ifndef NO_STRUCT_ASSIGN
209
+ #define ASSIGN_STATE(dest,src) ((dest) = (src))
210
+ #else
211
+ #if MAX_COMPS_IN_SCAN == 4
212
+ #define ASSIGN_STATE(dest,src) \
213
+ ((dest).EOBRUN = (src).EOBRUN, \
214
+ (dest).last_dc_val[0] = (src).last_dc_val[0], \
215
+ (dest).last_dc_val[1] = (src).last_dc_val[1], \
216
+ (dest).last_dc_val[2] = (src).last_dc_val[2], \
217
+ (dest).last_dc_val[3] = (src).last_dc_val[3])
218
+ #endif
219
+ #endif
220
+
221
+
222
+ typedef struct {
223
+ struct jpeg_entropy_decoder pub; /* public fields */
224
+
225
+ /* These fields are loaded into local variables at start of each MCU.
226
+ * In case of suspension, we exit WITHOUT updating them.
227
+ */
228
+ bitread_perm_state bitstate; /* Bit buffer at start of MCU */
229
+ savable_state saved; /* Other state at start of MCU */
230
+
231
+ /* These fields are NOT loaded into local working state. */
232
+ boolean insufficient_data; /* set TRUE after emitting warning */
233
+ unsigned int restarts_to_go; /* MCUs left in this restart interval */
234
+
235
+ /* Following two fields used only in progressive mode */
236
+
237
+ /* Pointers to derived tables (these workspaces have image lifespan) */
238
+ d_derived_tbl * derived_tbls[NUM_HUFF_TBLS];
239
+
240
+ d_derived_tbl * ac_derived_tbl; /* active table during an AC scan */
241
+
242
+ /* Following fields used only in sequential mode */
243
+
244
+ /* Pointers to derived tables (these workspaces have image lifespan) */
245
+ d_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS];
246
+ d_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS];
247
+
248
+ /* Precalculated info set up by start_pass for use in decode_mcu: */
249
+
250
+ /* Pointers to derived tables to be used for each block within an MCU */
251
+ d_derived_tbl * dc_cur_tbls[D_MAX_BLOCKS_IN_MCU];
252
+ d_derived_tbl * ac_cur_tbls[D_MAX_BLOCKS_IN_MCU];
253
+ /* Whether we care about the DC and AC coefficient values for each block */
254
+ int coef_limit[D_MAX_BLOCKS_IN_MCU];
255
+ } huff_entropy_decoder;
256
+
257
+ typedef huff_entropy_decoder * huff_entropy_ptr;
258
+
259
+
260
+ static const int jpeg_zigzag_order[8][8] = {
261
+ { 0, 1, 5, 6, 14, 15, 27, 28 },
262
+ { 2, 4, 7, 13, 16, 26, 29, 42 },
263
+ { 3, 8, 12, 17, 25, 30, 41, 43 },
264
+ { 9, 11, 18, 24, 31, 40, 44, 53 },
265
+ { 10, 19, 23, 32, 39, 45, 52, 54 },
266
+ { 20, 22, 33, 38, 46, 51, 55, 60 },
267
+ { 21, 34, 37, 47, 50, 56, 59, 61 },
268
+ { 35, 36, 48, 49, 57, 58, 62, 63 }
269
+ };
270
+
271
+ static const int jpeg_zigzag_order7[7][7] = {
272
+ { 0, 1, 5, 6, 14, 15, 27 },
273
+ { 2, 4, 7, 13, 16, 26, 28 },
274
+ { 3, 8, 12, 17, 25, 29, 38 },
275
+ { 9, 11, 18, 24, 30, 37, 39 },
276
+ { 10, 19, 23, 31, 36, 40, 45 },
277
+ { 20, 22, 32, 35, 41, 44, 46 },
278
+ { 21, 33, 34, 42, 43, 47, 48 }
279
+ };
280
+
281
+ static const int jpeg_zigzag_order6[6][6] = {
282
+ { 0, 1, 5, 6, 14, 15 },
283
+ { 2, 4, 7, 13, 16, 25 },
284
+ { 3, 8, 12, 17, 24, 26 },
285
+ { 9, 11, 18, 23, 27, 32 },
286
+ { 10, 19, 22, 28, 31, 33 },
287
+ { 20, 21, 29, 30, 34, 35 }
288
+ };
289
+
290
+ static const int jpeg_zigzag_order5[5][5] = {
291
+ { 0, 1, 5, 6, 14 },
292
+ { 2, 4, 7, 13, 15 },
293
+ { 3, 8, 12, 16, 21 },
294
+ { 9, 11, 17, 20, 22 },
295
+ { 10, 18, 19, 23, 24 }
296
+ };
297
+
298
+ static const int jpeg_zigzag_order4[4][4] = {
299
+ { 0, 1, 5, 6 },
300
+ { 2, 4, 7, 12 },
301
+ { 3, 8, 11, 13 },
302
+ { 9, 10, 14, 15 }
303
+ };
304
+
305
+ static const int jpeg_zigzag_order3[3][3] = {
306
+ { 0, 1, 5 },
307
+ { 2, 4, 6 },
308
+ { 3, 7, 8 }
309
+ };
310
+
311
+ static const int jpeg_zigzag_order2[2][2] = {
312
+ { 0, 1 },
313
+ { 2, 3 }
314
+ };
315
+
316
+
317
+ /*
318
+ * Compute the derived values for a Huffman table.
319
+ * This routine also performs some validation checks on the table.
320
+ */
321
+
322
+ LOCAL(void)
323
+ jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno,
324
+ d_derived_tbl ** pdtbl)
325
+ {
326
+ JHUFF_TBL *htbl;
327
+ d_derived_tbl *dtbl;
328
+ int p, i, l, si, numsymbols;
329
+ int lookbits, ctr;
330
+ char huffsize[257];
331
+ unsigned int huffcode[257];
332
+ unsigned int code;
333
+
334
+ /* Note that huffsize[] and huffcode[] are filled in code-length order,
335
+ * paralleling the order of the symbols themselves in htbl->huffval[].
336
+ */
337
+
338
+ /* Find the input Huffman table */
339
+ if (tblno < 0 || tblno >= NUM_HUFF_TBLS)
340
+ ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
341
+ htbl =
342
+ isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno];
343
+ if (htbl == NULL)
344
+ ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno);
345
+
346
+ /* Allocate a workspace if we haven't already done so. */
347
+ if (*pdtbl == NULL)
348
+ *pdtbl = (d_derived_tbl *)
349
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
350
+ SIZEOF(d_derived_tbl));
351
+ dtbl = *pdtbl;
352
+ dtbl->pub = htbl; /* fill in back link */
353
+
354
+ /* Figure C.1: make table of Huffman code length for each symbol */
355
+
356
+ p = 0;
357
+ for (l = 1; l <= 16; l++) {
358
+ i = (int) htbl->bits[l];
359
+ if (i < 0 || p + i > 256) /* protect against table overrun */
360
+ ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
361
+ while (i--)
362
+ huffsize[p++] = (char) l;
363
+ }
364
+ huffsize[p] = 0;
365
+ numsymbols = p;
366
+
367
+ /* Figure C.2: generate the codes themselves */
368
+ /* We also validate that the counts represent a legal Huffman code tree. */
369
+
370
+ code = 0;
371
+ si = huffsize[0];
372
+ p = 0;
373
+ while (huffsize[p]) {
374
+ while (((int) huffsize[p]) == si) {
375
+ huffcode[p++] = code;
376
+ code++;
377
+ }
378
+ /* code is now 1 more than the last code used for codelength si; but
379
+ * it must still fit in si bits, since no code is allowed to be all ones.
380
+ */
381
+ if (((INT32) code) >= (((INT32) 1) << si))
382
+ ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
383
+ code <<= 1;
384
+ si++;
385
+ }
386
+
387
+ /* Figure F.15: generate decoding tables for bit-sequential decoding */
388
+
389
+ p = 0;
390
+ for (l = 1; l <= 16; l++) {
391
+ if (htbl->bits[l]) {
392
+ /* valoffset[l] = huffval[] index of 1st symbol of code length l,
393
+ * minus the minimum code of length l
394
+ */
395
+ dtbl->valoffset[l] = (INT32) p - (INT32) huffcode[p];
396
+ p += htbl->bits[l];
397
+ dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */
398
+ } else {
399
+ dtbl->maxcode[l] = -1; /* -1 if no codes of this length */
400
+ }
401
+ }
402
+ dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */
403
+
404
+ /* Compute lookahead tables to speed up decoding.
405
+ * First we set all the table entries to 0, indicating "too long";
406
+ * then we iterate through the Huffman codes that are short enough and
407
+ * fill in all the entries that correspond to bit sequences starting
408
+ * with that code.
409
+ */
410
+
411
+ MEMZERO(dtbl->look_nbits, SIZEOF(dtbl->look_nbits));
412
+
413
+ p = 0;
414
+ for (l = 1; l <= HUFF_LOOKAHEAD; l++) {
415
+ for (i = 1; i <= (int) htbl->bits[l]; i++, p++) {
416
+ /* l = current code's length, p = its index in huffcode[] & huffval[]. */
417
+ /* Generate left-justified code followed by all possible bit sequences */
418
+ lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l);
419
+ for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) {
420
+ dtbl->look_nbits[lookbits] = l;
421
+ dtbl->look_sym[lookbits] = htbl->huffval[p];
422
+ lookbits++;
423
+ }
424
+ }
425
+ }
426
+
427
+ /* Validate symbols as being reasonable.
428
+ * For AC tables, we make no check, but accept all byte values 0..255.
429
+ * For DC tables, we require the symbols to be in range 0..15.
430
+ * (Tighter bounds could be applied depending on the data depth and mode,
431
+ * but this is sufficient to ensure safe decoding.)
432
+ */
433
+ if (isDC) {
434
+ for (i = 0; i < numsymbols; i++) {
435
+ int sym = htbl->huffval[i];
436
+ if (sym < 0 || sym > 15)
437
+ ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
438
+ }
439
+ }
440
+ }
441
+
442
+
443
+ /*
444
+ * Out-of-line code for bit fetching.
445
+ * Note: current values of get_buffer and bits_left are passed as parameters,
446
+ * but are returned in the corresponding fields of the state struct.
447
+ *
448
+ * On most machines MIN_GET_BITS should be 25 to allow the full 32-bit width
449
+ * of get_buffer to be used. (On machines with wider words, an even larger
450
+ * buffer could be used.) However, on some machines 32-bit shifts are
451
+ * quite slow and take time proportional to the number of places shifted.
452
+ * (This is true with most PC compilers, for instance.) In this case it may
453
+ * be a win to set MIN_GET_BITS to the minimum value of 15. This reduces the
454
+ * average shift distance at the cost of more calls to jpeg_fill_bit_buffer.
455
+ */
456
+
457
+ #ifdef SLOW_SHIFT_32
458
+ #define MIN_GET_BITS 15 /* minimum allowable value */
459
+ #else
460
+ #define MIN_GET_BITS (BIT_BUF_SIZE-7)
461
+ #endif
462
+
463
+
464
+ LOCAL(boolean)
465
+ jpeg_fill_bit_buffer (bitread_working_state * state,
466
+ register bit_buf_type get_buffer, register int bits_left,
467
+ int nbits)
468
+ /* Load up the bit buffer to a depth of at least nbits */
469
+ {
470
+ /* Copy heavily used state fields into locals (hopefully registers) */
471
+ register const JOCTET * next_input_byte = state->next_input_byte;
472
+ register size_t bytes_in_buffer = state->bytes_in_buffer;
473
+ j_decompress_ptr cinfo = state->cinfo;
474
+
475
+ /* Attempt to load at least MIN_GET_BITS bits into get_buffer. */
476
+ /* (It is assumed that no request will be for more than that many bits.) */
477
+ /* We fail to do so only if we hit a marker or are forced to suspend. */
478
+
479
+ if (cinfo->unread_marker == 0) { /* cannot advance past a marker */
480
+ while (bits_left < MIN_GET_BITS) {
481
+ register int c;
482
+
483
+ /* Attempt to read a byte */
484
+ if (bytes_in_buffer == 0) {
485
+ if (! (*cinfo->src->fill_input_buffer) (cinfo))
486
+ return FALSE;
487
+ next_input_byte = cinfo->src->next_input_byte;
488
+ bytes_in_buffer = cinfo->src->bytes_in_buffer;
489
+ }
490
+ bytes_in_buffer--;
491
+ c = GETJOCTET(*next_input_byte++);
492
+
493
+ /* If it's 0xFF, check and discard stuffed zero byte */
494
+ if (c == 0xFF) {
495
+ /* Loop here to discard any padding FF's on terminating marker,
496
+ * so that we can save a valid unread_marker value. NOTE: we will
497
+ * accept multiple FF's followed by a 0 as meaning a single FF data
498
+ * byte. This data pattern is not valid according to the standard.
499
+ */
500
+ do {
501
+ if (bytes_in_buffer == 0) {
502
+ if (! (*cinfo->src->fill_input_buffer) (cinfo))
503
+ return FALSE;
504
+ next_input_byte = cinfo->src->next_input_byte;
505
+ bytes_in_buffer = cinfo->src->bytes_in_buffer;
506
+ }
507
+ bytes_in_buffer--;
508
+ c = GETJOCTET(*next_input_byte++);
509
+ } while (c == 0xFF);
510
+
511
+ if (c == 0) {
512
+ /* Found FF/00, which represents an FF data byte */
513
+ c = 0xFF;
514
+ } else {
515
+ /* Oops, it's actually a marker indicating end of compressed data.
516
+ * Save the marker code for later use.
517
+ * Fine point: it might appear that we should save the marker into
518
+ * bitread working state, not straight into permanent state. But
519
+ * once we have hit a marker, we cannot need to suspend within the
520
+ * current MCU, because we will read no more bytes from the data
521
+ * source. So it is OK to update permanent state right away.
522
+ */
523
+ cinfo->unread_marker = c;
524
+ /* See if we need to insert some fake zero bits. */
525
+ goto no_more_bytes;
526
+ }
527
+ }
528
+
529
+ /* OK, load c into get_buffer */
530
+ get_buffer = (get_buffer << 8) | c;
531
+ bits_left += 8;
532
+ } /* end while */
533
+ } else {
534
+ no_more_bytes:
535
+ /* We get here if we've read the marker that terminates the compressed
536
+ * data segment. There should be enough bits in the buffer register
537
+ * to satisfy the request; if so, no problem.
538
+ */
539
+ if (nbits > bits_left) {
540
+ /* Uh-oh. Report corrupted data to user and stuff zeroes into
541
+ * the data stream, so that we can produce some kind of image.
542
+ * We use a nonvolatile flag to ensure that only one warning message
543
+ * appears per data segment.
544
+ */
545
+ if (! ((huff_entropy_ptr) cinfo->entropy)->insufficient_data) {
546
+ WARNMS(cinfo, JWRN_HIT_MARKER);
547
+ ((huff_entropy_ptr) cinfo->entropy)->insufficient_data = TRUE;
548
+ }
549
+ /* Fill the buffer with zero bits */
550
+ get_buffer <<= MIN_GET_BITS - bits_left;
551
+ bits_left = MIN_GET_BITS;
552
+ }
553
+ }
554
+
555
+ /* Unload the local registers */
556
+ state->next_input_byte = next_input_byte;
557
+ state->bytes_in_buffer = bytes_in_buffer;
558
+ state->get_buffer = get_buffer;
559
+ state->bits_left = bits_left;
560
+
561
+ return TRUE;
562
+ }
563
+
564
+
565
+ /*
566
+ * Figure F.12: extend sign bit.
567
+ * On some machines, a shift and sub will be faster than a table lookup.
568
+ */
569
+
570
+ #ifdef AVOID_TABLES
571
+
572
+ #define BIT_MASK(nbits) ((1<<(nbits))-1)
573
+ #define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) - ((1<<(s))-1) : (x))
574
+
575
+ #else
576
+
577
+ #define BIT_MASK(nbits) bmask[nbits]
578
+ #define HUFF_EXTEND(x,s) ((x) <= bmask[(s) - 1] ? (x) - bmask[s] : (x))
579
+
580
+ static const int bmask[16] = /* bmask[n] is mask for n rightmost bits */
581
+ { 0, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF,
582
+ 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF };
583
+
584
+ #endif /* AVOID_TABLES */
585
+
586
+
587
+ /*
588
+ * Out-of-line code for Huffman code decoding.
589
+ */
590
+
591
+ LOCAL(int)
592
+ jpeg_huff_decode (bitread_working_state * state,
593
+ register bit_buf_type get_buffer, register int bits_left,
594
+ d_derived_tbl * htbl, int min_bits)
595
+ {
596
+ register int l = min_bits;
597
+ register INT32 code;
598
+
599
+ /* HUFF_DECODE has determined that the code is at least min_bits */
600
+ /* bits long, so fetch that many bits in one swoop. */
601
+
602
+ CHECK_BIT_BUFFER(*state, l, return -1);
603
+ code = GET_BITS(l);
604
+
605
+ /* Collect the rest of the Huffman code one bit at a time. */
606
+ /* This is per Figure F.16 in the JPEG spec. */
607
+
608
+ while (code > htbl->maxcode[l]) {
609
+ code <<= 1;
610
+ CHECK_BIT_BUFFER(*state, 1, return -1);
611
+ code |= GET_BITS(1);
612
+ l++;
613
+ }
614
+
615
+ /* Unload the local registers */
616
+ state->get_buffer = get_buffer;
617
+ state->bits_left = bits_left;
618
+
619
+ /* With garbage input we may reach the sentinel value l = 17. */
620
+
621
+ if (l > 16) {
622
+ WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE);
623
+ return 0; /* fake a zero as the safest result */
624
+ }
625
+
626
+ return htbl->pub->huffval[ (int) (code + htbl->valoffset[l]) ];
627
+ }
628
+
629
+
630
+ /*
631
+ * Finish up at the end of a Huffman-compressed scan.
632
+ */
633
+
634
+ METHODDEF(void)
635
+ finish_pass_huff (j_decompress_ptr cinfo)
636
+ {
637
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
638
+
639
+ /* Throw away any unused bits remaining in bit buffer; */
640
+ /* include any full bytes in next_marker's count of discarded bytes */
641
+ cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;
642
+ entropy->bitstate.bits_left = 0;
643
+ }
644
+
645
+
646
+ /*
647
+ * Check for a restart marker & resynchronize decoder.
648
+ * Returns FALSE if must suspend.
649
+ */
650
+
651
+ LOCAL(boolean)
652
+ process_restart (j_decompress_ptr cinfo)
653
+ {
654
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
655
+ int ci;
656
+
657
+ finish_pass_huff(cinfo);
658
+
659
+ /* Advance past the RSTn marker */
660
+ if (! (*cinfo->marker->read_restart_marker) (cinfo))
661
+ return FALSE;
662
+
663
+ /* Re-initialize DC predictions to 0 */
664
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++)
665
+ entropy->saved.last_dc_val[ci] = 0;
666
+ /* Re-init EOB run count, too */
667
+ entropy->saved.EOBRUN = 0;
668
+
669
+ /* Reset restart counter */
670
+ entropy->restarts_to_go = cinfo->restart_interval;
671
+
672
+ /* Reset out-of-data flag, unless read_restart_marker left us smack up
673
+ * against a marker. In that case we will end up treating the next data
674
+ * segment as empty, and we can avoid producing bogus output pixels by
675
+ * leaving the flag set.
676
+ */
677
+ if (cinfo->unread_marker == 0)
678
+ entropy->insufficient_data = FALSE;
679
+
680
+ return TRUE;
681
+ }
682
+
683
+
684
+ /*
685
+ * Huffman MCU decoding.
686
+ * Each of these routines decodes and returns one MCU's worth of
687
+ * Huffman-compressed coefficients.
688
+ * The coefficients are reordered from zigzag order into natural array order,
689
+ * but are not dequantized.
690
+ *
691
+ * The i'th block of the MCU is stored into the block pointed to by
692
+ * MCU_data[i]. WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER.
693
+ * (Wholesale zeroing is usually a little faster than retail...)
694
+ *
695
+ * We return FALSE if data source requested suspension. In that case no
696
+ * changes have been made to permanent state. (Exception: some output
697
+ * coefficients may already have been assigned. This is harmless for
698
+ * spectral selection, since we'll just re-assign them on the next call.
699
+ * Successive approximation AC refinement has to be more careful, however.)
700
+ */
701
+
702
+ /*
703
+ * MCU decoding for DC initial scan (either spectral selection,
704
+ * or first pass of successive approximation).
705
+ */
706
+
707
+ METHODDEF(boolean)
708
+ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
709
+ {
710
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
711
+ int Al = cinfo->Al;
712
+ register int s, r;
713
+ int blkn, ci;
714
+ JBLOCKROW block;
715
+ BITREAD_STATE_VARS;
716
+ savable_state state;
717
+ d_derived_tbl * tbl;
718
+ jpeg_component_info * compptr;
719
+
720
+ /* Process restart marker if needed; may have to suspend */
721
+ if (cinfo->restart_interval) {
722
+ if (entropy->restarts_to_go == 0)
723
+ if (! process_restart(cinfo))
724
+ return FALSE;
725
+ }
726
+
727
+ /* If we've run out of data, just leave the MCU set to zeroes.
728
+ * This way, we return uniform gray for the remainder of the segment.
729
+ */
730
+ if (! entropy->insufficient_data) {
731
+
732
+ /* Load up working state */
733
+ BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
734
+ ASSIGN_STATE(state, entropy->saved);
735
+
736
+ /* Outer loop handles each block in the MCU */
737
+
738
+ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
739
+ block = MCU_data[blkn];
740
+ ci = cinfo->MCU_membership[blkn];
741
+ compptr = cinfo->cur_comp_info[ci];
742
+ tbl = entropy->derived_tbls[compptr->dc_tbl_no];
743
+
744
+ /* Decode a single block's worth of coefficients */
745
+
746
+ /* Section F.2.2.1: decode the DC coefficient difference */
747
+ HUFF_DECODE(s, br_state, tbl, return FALSE, label1);
748
+ if (s) {
749
+ CHECK_BIT_BUFFER(br_state, s, return FALSE);
750
+ r = GET_BITS(s);
751
+ s = HUFF_EXTEND(r, s);
752
+ }
753
+
754
+ /* Convert DC difference to actual value, update last_dc_val */
755
+ s += state.last_dc_val[ci];
756
+ state.last_dc_val[ci] = s;
757
+ /* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */
758
+ (*block)[0] = (JCOEF) (s << Al);
759
+ }
760
+
761
+ /* Completed MCU, so update state */
762
+ BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
763
+ ASSIGN_STATE(entropy->saved, state);
764
+ }
765
+
766
+ /* Account for restart interval (no-op if not using restarts) */
767
+ entropy->restarts_to_go--;
768
+
769
+ return TRUE;
770
+ }
771
+
772
+
773
+ /*
774
+ * MCU decoding for AC initial scan (either spectral selection,
775
+ * or first pass of successive approximation).
776
+ */
777
+
778
+ METHODDEF(boolean)
779
+ decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
780
+ {
781
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
782
+ register int s, k, r;
783
+ unsigned int EOBRUN;
784
+ int Se, Al;
785
+ const int * natural_order;
786
+ JBLOCKROW block;
787
+ BITREAD_STATE_VARS;
788
+ d_derived_tbl * tbl;
789
+
790
+ /* Process restart marker if needed; may have to suspend */
791
+ if (cinfo->restart_interval) {
792
+ if (entropy->restarts_to_go == 0)
793
+ if (! process_restart(cinfo))
794
+ return FALSE;
795
+ }
796
+
797
+ /* If we've run out of data, just leave the MCU set to zeroes.
798
+ * This way, we return uniform gray for the remainder of the segment.
799
+ */
800
+ if (! entropy->insufficient_data) {
801
+
802
+ Se = cinfo->Se;
803
+ Al = cinfo->Al;
804
+ natural_order = cinfo->natural_order;
805
+
806
+ /* Load up working state.
807
+ * We can avoid loading/saving bitread state if in an EOB run.
808
+ */
809
+ EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */
810
+
811
+ /* There is always only one block per MCU */
812
+
813
+ if (EOBRUN) /* if it's a band of zeroes... */
814
+ EOBRUN--; /* ...process it now (we do nothing) */
815
+ else {
816
+ BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
817
+ block = MCU_data[0];
818
+ tbl = entropy->ac_derived_tbl;
819
+
820
+ for (k = cinfo->Ss; k <= Se; k++) {
821
+ HUFF_DECODE(s, br_state, tbl, return FALSE, label2);
822
+ r = s >> 4;
823
+ s &= 15;
824
+ if (s) {
825
+ k += r;
826
+ CHECK_BIT_BUFFER(br_state, s, return FALSE);
827
+ r = GET_BITS(s);
828
+ s = HUFF_EXTEND(r, s);
829
+ /* Scale and output coefficient in natural (dezigzagged) order */
830
+ (*block)[natural_order[k]] = (JCOEF) (s << Al);
831
+ } else {
832
+ if (r != 15) { /* EOBr, run length is 2^r + appended bits */
833
+ if (r) { /* EOBr, r > 0 */
834
+ EOBRUN = 1 << r;
835
+ CHECK_BIT_BUFFER(br_state, r, return FALSE);
836
+ r = GET_BITS(r);
837
+ EOBRUN += r;
838
+ EOBRUN--; /* this band is processed at this moment */
839
+ }
840
+ break; /* force end-of-band */
841
+ }
842
+ k += 15; /* ZRL: skip 15 zeroes in band */
843
+ }
844
+ }
845
+
846
+ BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
847
+ }
848
+
849
+ /* Completed MCU, so update state */
850
+ entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
851
+ }
852
+
853
+ /* Account for restart interval (no-op if not using restarts) */
854
+ entropy->restarts_to_go--;
855
+
856
+ return TRUE;
857
+ }
858
+
859
+
860
+ /*
861
+ * MCU decoding for DC successive approximation refinement scan.
862
+ * Note: we assume such scans can be multi-component,
863
+ * although the spec is not very clear on the point.
864
+ */
865
+
866
+ METHODDEF(boolean)
867
+ decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
868
+ {
869
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
870
+ int p1, blkn;
871
+ BITREAD_STATE_VARS;
872
+
873
+ /* Process restart marker if needed; may have to suspend */
874
+ if (cinfo->restart_interval) {
875
+ if (entropy->restarts_to_go == 0)
876
+ if (! process_restart(cinfo))
877
+ return FALSE;
878
+ }
879
+
880
+ /* Not worth the cycles to check insufficient_data here,
881
+ * since we will not change the data anyway if we read zeroes.
882
+ */
883
+
884
+ /* Load up working state */
885
+ BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
886
+
887
+ p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
888
+
889
+ /* Outer loop handles each block in the MCU */
890
+
891
+ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
892
+ /* Encoded data is simply the next bit of the two's-complement DC value */
893
+ CHECK_BIT_BUFFER(br_state, 1, return FALSE);
894
+ if (GET_BITS(1))
895
+ MCU_data[blkn][0][0] |= p1;
896
+ /* Note: since we use |=, repeating the assignment later is safe */
897
+ }
898
+
899
+ /* Completed MCU, so update state */
900
+ BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
901
+
902
+ /* Account for restart interval (no-op if not using restarts) */
903
+ entropy->restarts_to_go--;
904
+
905
+ return TRUE;
906
+ }
907
+
908
+
909
+ /*
910
+ * MCU decoding for AC successive approximation refinement scan.
911
+ */
912
+
913
+ METHODDEF(boolean)
914
+ decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
915
+ {
916
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
917
+ register int s, k, r;
918
+ unsigned int EOBRUN;
919
+ int Se, p1, m1;
920
+ const int * natural_order;
921
+ JBLOCKROW block;
922
+ JCOEFPTR thiscoef;
923
+ BITREAD_STATE_VARS;
924
+ d_derived_tbl * tbl;
925
+ int num_newnz;
926
+ int newnz_pos[DCTSIZE2];
927
+
928
+ /* Process restart marker if needed; may have to suspend */
929
+ if (cinfo->restart_interval) {
930
+ if (entropy->restarts_to_go == 0)
931
+ if (! process_restart(cinfo))
932
+ return FALSE;
933
+ }
934
+
935
+ /* If we've run out of data, don't modify the MCU.
936
+ */
937
+ if (! entropy->insufficient_data) {
938
+
939
+ Se = cinfo->Se;
940
+ p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */
941
+ m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */
942
+ natural_order = cinfo->natural_order;
943
+
944
+ /* Load up working state */
945
+ BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
946
+ EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */
947
+
948
+ /* There is always only one block per MCU */
949
+ block = MCU_data[0];
950
+ tbl = entropy->ac_derived_tbl;
951
+
952
+ /* If we are forced to suspend, we must undo the assignments to any newly
953
+ * nonzero coefficients in the block, because otherwise we'd get confused
954
+ * next time about which coefficients were already nonzero.
955
+ * But we need not undo addition of bits to already-nonzero coefficients;
956
+ * instead, we can test the current bit to see if we already did it.
957
+ */
958
+ num_newnz = 0;
959
+
960
+ /* initialize coefficient loop counter to start of band */
961
+ k = cinfo->Ss;
962
+
963
+ if (EOBRUN == 0) {
964
+ do {
965
+ HUFF_DECODE(s, br_state, tbl, goto undoit, label3);
966
+ r = s >> 4;
967
+ s &= 15;
968
+ if (s) {
969
+ if (s != 1) /* size of new coef should always be 1 */
970
+ WARNMS(cinfo, JWRN_HUFF_BAD_CODE);
971
+ CHECK_BIT_BUFFER(br_state, 1, goto undoit);
972
+ if (GET_BITS(1))
973
+ s = p1; /* newly nonzero coef is positive */
974
+ else
975
+ s = m1; /* newly nonzero coef is negative */
976
+ } else {
977
+ if (r != 15) {
978
+ EOBRUN = 1 << r; /* EOBr, run length is 2^r + appended bits */
979
+ if (r) {
980
+ CHECK_BIT_BUFFER(br_state, r, goto undoit);
981
+ r = GET_BITS(r);
982
+ EOBRUN += r;
983
+ }
984
+ break; /* rest of block is handled by EOB logic */
985
+ }
986
+ /* note s = 0 for processing ZRL */
987
+ }
988
+ /* Advance over already-nonzero coefs and r still-zero coefs,
989
+ * appending correction bits to the nonzeroes. A correction bit is 1
990
+ * if the absolute value of the coefficient must be increased.
991
+ */
992
+ do {
993
+ thiscoef = *block + natural_order[k];
994
+ if (*thiscoef) {
995
+ CHECK_BIT_BUFFER(br_state, 1, goto undoit);
996
+ if (GET_BITS(1)) {
997
+ if ((*thiscoef & p1) == 0) { /* do nothing if already set it */
998
+ if (*thiscoef >= 0)
999
+ *thiscoef += p1;
1000
+ else
1001
+ *thiscoef += m1;
1002
+ }
1003
+ }
1004
+ } else {
1005
+ if (--r < 0)
1006
+ break; /* reached target zero coefficient */
1007
+ }
1008
+ k++;
1009
+ } while (k <= Se);
1010
+ if (s) {
1011
+ int pos = natural_order[k];
1012
+ /* Output newly nonzero coefficient */
1013
+ (*block)[pos] = (JCOEF) s;
1014
+ /* Remember its position in case we have to suspend */
1015
+ newnz_pos[num_newnz++] = pos;
1016
+ }
1017
+ k++;
1018
+ } while (k <= Se);
1019
+ }
1020
+
1021
+ if (EOBRUN) {
1022
+ /* Scan any remaining coefficient positions after the end-of-band
1023
+ * (the last newly nonzero coefficient, if any). Append a correction
1024
+ * bit to each already-nonzero coefficient. A correction bit is 1
1025
+ * if the absolute value of the coefficient must be increased.
1026
+ */
1027
+ do {
1028
+ thiscoef = *block + natural_order[k];
1029
+ if (*thiscoef) {
1030
+ CHECK_BIT_BUFFER(br_state, 1, goto undoit);
1031
+ if (GET_BITS(1)) {
1032
+ if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */
1033
+ if (*thiscoef >= 0)
1034
+ *thiscoef += p1;
1035
+ else
1036
+ *thiscoef += m1;
1037
+ }
1038
+ }
1039
+ }
1040
+ k++;
1041
+ } while (k <= Se);
1042
+ /* Count one block completed in EOB run */
1043
+ EOBRUN--;
1044
+ }
1045
+
1046
+ /* Completed MCU, so update state */
1047
+ BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
1048
+ entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */
1049
+ }
1050
+
1051
+ /* Account for restart interval (no-op if not using restarts) */
1052
+ entropy->restarts_to_go--;
1053
+
1054
+ return TRUE;
1055
+
1056
+ undoit:
1057
+ /* Re-zero any output coefficients that we made newly nonzero */
1058
+ while (num_newnz)
1059
+ (*block)[newnz_pos[--num_newnz]] = 0;
1060
+
1061
+ return FALSE;
1062
+ }
1063
+
1064
+
1065
+ /*
1066
+ * Decode one MCU's worth of Huffman-compressed coefficients,
1067
+ * partial blocks.
1068
+ */
1069
+
1070
+ METHODDEF(boolean)
1071
+ decode_mcu_sub (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
1072
+ {
1073
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
1074
+ const int * natural_order;
1075
+ int Se, blkn;
1076
+ BITREAD_STATE_VARS;
1077
+ savable_state state;
1078
+
1079
+ /* Process restart marker if needed; may have to suspend */
1080
+ if (cinfo->restart_interval) {
1081
+ if (entropy->restarts_to_go == 0)
1082
+ if (! process_restart(cinfo))
1083
+ return FALSE;
1084
+ }
1085
+
1086
+ /* If we've run out of data, just leave the MCU set to zeroes.
1087
+ * This way, we return uniform gray for the remainder of the segment.
1088
+ */
1089
+ if (! entropy->insufficient_data) {
1090
+
1091
+ natural_order = cinfo->natural_order;
1092
+ Se = cinfo->lim_Se;
1093
+
1094
+ /* Load up working state */
1095
+ BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
1096
+ ASSIGN_STATE(state, entropy->saved);
1097
+
1098
+ /* Outer loop handles each block in the MCU */
1099
+
1100
+ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
1101
+ JBLOCKROW block = MCU_data[blkn];
1102
+ d_derived_tbl * htbl;
1103
+ register int s, k, r;
1104
+ int coef_limit, ci;
1105
+
1106
+ /* Decode a single block's worth of coefficients */
1107
+
1108
+ /* Section F.2.2.1: decode the DC coefficient difference */
1109
+ htbl = entropy->dc_cur_tbls[blkn];
1110
+ HUFF_DECODE(s, br_state, htbl, return FALSE, label1);
1111
+
1112
+ htbl = entropy->ac_cur_tbls[blkn];
1113
+ k = 1;
1114
+ coef_limit = entropy->coef_limit[blkn];
1115
+ if (coef_limit) {
1116
+ /* Convert DC difference to actual value, update last_dc_val */
1117
+ if (s) {
1118
+ CHECK_BIT_BUFFER(br_state, s, return FALSE);
1119
+ r = GET_BITS(s);
1120
+ s = HUFF_EXTEND(r, s);
1121
+ }
1122
+ ci = cinfo->MCU_membership[blkn];
1123
+ s += state.last_dc_val[ci];
1124
+ state.last_dc_val[ci] = s;
1125
+ /* Output the DC coefficient */
1126
+ (*block)[0] = (JCOEF) s;
1127
+
1128
+ /* Section F.2.2.2: decode the AC coefficients */
1129
+ /* Since zeroes are skipped, output area must be cleared beforehand */
1130
+ for (; k < coef_limit; k++) {
1131
+ HUFF_DECODE(s, br_state, htbl, return FALSE, label2);
1132
+
1133
+ r = s >> 4;
1134
+ s &= 15;
1135
+
1136
+ if (s) {
1137
+ k += r;
1138
+ CHECK_BIT_BUFFER(br_state, s, return FALSE);
1139
+ r = GET_BITS(s);
1140
+ s = HUFF_EXTEND(r, s);
1141
+ /* Output coefficient in natural (dezigzagged) order.
1142
+ * Note: the extra entries in natural_order[] will save us
1143
+ * if k > Se, which could happen if the data is corrupted.
1144
+ */
1145
+ (*block)[natural_order[k]] = (JCOEF) s;
1146
+ } else {
1147
+ if (r != 15)
1148
+ goto EndOfBlock;
1149
+ k += 15;
1150
+ }
1151
+ }
1152
+ } else {
1153
+ if (s) {
1154
+ CHECK_BIT_BUFFER(br_state, s, return FALSE);
1155
+ DROP_BITS(s);
1156
+ }
1157
+ }
1158
+
1159
+ /* Section F.2.2.2: decode the AC coefficients */
1160
+ /* In this path we just discard the values */
1161
+ for (; k <= Se; k++) {
1162
+ HUFF_DECODE(s, br_state, htbl, return FALSE, label3);
1163
+
1164
+ r = s >> 4;
1165
+ s &= 15;
1166
+
1167
+ if (s) {
1168
+ k += r;
1169
+ CHECK_BIT_BUFFER(br_state, s, return FALSE);
1170
+ DROP_BITS(s);
1171
+ } else {
1172
+ if (r != 15)
1173
+ break;
1174
+ k += 15;
1175
+ }
1176
+ }
1177
+
1178
+ EndOfBlock: ;
1179
+ }
1180
+
1181
+ /* Completed MCU, so update state */
1182
+ BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
1183
+ ASSIGN_STATE(entropy->saved, state);
1184
+ }
1185
+
1186
+ /* Account for restart interval (no-op if not using restarts) */
1187
+ entropy->restarts_to_go--;
1188
+
1189
+ return TRUE;
1190
+ }
1191
+
1192
+
1193
+ /*
1194
+ * Decode one MCU's worth of Huffman-compressed coefficients,
1195
+ * full-size blocks.
1196
+ */
1197
+
1198
+ METHODDEF(boolean)
1199
+ decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
1200
+ {
1201
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
1202
+ int blkn;
1203
+ BITREAD_STATE_VARS;
1204
+ savable_state state;
1205
+
1206
+ /* Process restart marker if needed; may have to suspend */
1207
+ if (cinfo->restart_interval) {
1208
+ if (entropy->restarts_to_go == 0)
1209
+ if (! process_restart(cinfo))
1210
+ return FALSE;
1211
+ }
1212
+
1213
+ /* If we've run out of data, just leave the MCU set to zeroes.
1214
+ * This way, we return uniform gray for the remainder of the segment.
1215
+ */
1216
+ if (! entropy->insufficient_data) {
1217
+
1218
+ /* Load up working state */
1219
+ BITREAD_LOAD_STATE(cinfo,entropy->bitstate);
1220
+ ASSIGN_STATE(state, entropy->saved);
1221
+
1222
+ /* Outer loop handles each block in the MCU */
1223
+
1224
+ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
1225
+ JBLOCKROW block = MCU_data[blkn];
1226
+ d_derived_tbl * htbl;
1227
+ register int s, k, r;
1228
+ int coef_limit, ci;
1229
+
1230
+ /* Decode a single block's worth of coefficients */
1231
+
1232
+ /* Section F.2.2.1: decode the DC coefficient difference */
1233
+ htbl = entropy->dc_cur_tbls[blkn];
1234
+ HUFF_DECODE(s, br_state, htbl, return FALSE, label1);
1235
+
1236
+ htbl = entropy->ac_cur_tbls[blkn];
1237
+ k = 1;
1238
+ coef_limit = entropy->coef_limit[blkn];
1239
+ if (coef_limit) {
1240
+ /* Convert DC difference to actual value, update last_dc_val */
1241
+ if (s) {
1242
+ CHECK_BIT_BUFFER(br_state, s, return FALSE);
1243
+ r = GET_BITS(s);
1244
+ s = HUFF_EXTEND(r, s);
1245
+ }
1246
+ ci = cinfo->MCU_membership[blkn];
1247
+ s += state.last_dc_val[ci];
1248
+ state.last_dc_val[ci] = s;
1249
+ /* Output the DC coefficient */
1250
+ (*block)[0] = (JCOEF) s;
1251
+
1252
+ /* Section F.2.2.2: decode the AC coefficients */
1253
+ /* Since zeroes are skipped, output area must be cleared beforehand */
1254
+ for (; k < coef_limit; k++) {
1255
+ HUFF_DECODE(s, br_state, htbl, return FALSE, label2);
1256
+
1257
+ r = s >> 4;
1258
+ s &= 15;
1259
+
1260
+ if (s) {
1261
+ k += r;
1262
+ CHECK_BIT_BUFFER(br_state, s, return FALSE);
1263
+ r = GET_BITS(s);
1264
+ s = HUFF_EXTEND(r, s);
1265
+ /* Output coefficient in natural (dezigzagged) order.
1266
+ * Note: the extra entries in jpeg_natural_order[] will save us
1267
+ * if k >= DCTSIZE2, which could happen if the data is corrupted.
1268
+ */
1269
+ (*block)[jpeg_natural_order[k]] = (JCOEF) s;
1270
+ } else {
1271
+ if (r != 15)
1272
+ goto EndOfBlock;
1273
+ k += 15;
1274
+ }
1275
+ }
1276
+ } else {
1277
+ if (s) {
1278
+ CHECK_BIT_BUFFER(br_state, s, return FALSE);
1279
+ DROP_BITS(s);
1280
+ }
1281
+ }
1282
+
1283
+ /* Section F.2.2.2: decode the AC coefficients */
1284
+ /* In this path we just discard the values */
1285
+ for (; k < DCTSIZE2; k++) {
1286
+ HUFF_DECODE(s, br_state, htbl, return FALSE, label3);
1287
+
1288
+ r = s >> 4;
1289
+ s &= 15;
1290
+
1291
+ if (s) {
1292
+ k += r;
1293
+ CHECK_BIT_BUFFER(br_state, s, return FALSE);
1294
+ DROP_BITS(s);
1295
+ } else {
1296
+ if (r != 15)
1297
+ break;
1298
+ k += 15;
1299
+ }
1300
+ }
1301
+
1302
+ EndOfBlock: ;
1303
+ }
1304
+
1305
+ /* Completed MCU, so update state */
1306
+ BITREAD_SAVE_STATE(cinfo,entropy->bitstate);
1307
+ ASSIGN_STATE(entropy->saved, state);
1308
+ }
1309
+
1310
+ /* Account for restart interval (no-op if not using restarts) */
1311
+ entropy->restarts_to_go--;
1312
+
1313
+ return TRUE;
1314
+ }
1315
+
1316
+
1317
+ /*
1318
+ * Initialize for a Huffman-compressed scan.
1319
+ */
1320
+
1321
+ METHODDEF(void)
1322
+ start_pass_huff_decoder (j_decompress_ptr cinfo)
1323
+ {
1324
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
1325
+ int ci, blkn, tbl, i;
1326
+ jpeg_component_info * compptr;
1327
+
1328
+ if (cinfo->progressive_mode) {
1329
+ /* Validate progressive scan parameters */
1330
+ if (cinfo->Ss == 0) {
1331
+ if (cinfo->Se != 0)
1332
+ goto bad;
1333
+ } else {
1334
+ /* need not check Ss/Se < 0 since they came from unsigned bytes */
1335
+ if (cinfo->Se < cinfo->Ss || cinfo->Se > cinfo->lim_Se)
1336
+ goto bad;
1337
+ /* AC scans may have only one component */
1338
+ if (cinfo->comps_in_scan != 1)
1339
+ goto bad;
1340
+ }
1341
+ if (cinfo->Ah != 0) {
1342
+ /* Successive approximation refinement scan: must have Al = Ah-1. */
1343
+ if (cinfo->Ah-1 != cinfo->Al)
1344
+ goto bad;
1345
+ }
1346
+ if (cinfo->Al > 13) { /* need not check for < 0 */
1347
+ /* Arguably the maximum Al value should be less than 13 for 8-bit precision,
1348
+ * but the spec doesn't say so, and we try to be liberal about what we
1349
+ * accept. Note: large Al values could result in out-of-range DC
1350
+ * coefficients during early scans, leading to bizarre displays due to
1351
+ * overflows in the IDCT math. But we won't crash.
1352
+ */
1353
+ bad:
1354
+ ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
1355
+ cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
1356
+ }
1357
+ /* Update progression status, and verify that scan order is legal.
1358
+ * Note that inter-scan inconsistencies are treated as warnings
1359
+ * not fatal errors ... not clear if this is right way to behave.
1360
+ */
1361
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
1362
+ int coefi, cindex = cinfo->cur_comp_info[ci]->component_index;
1363
+ int *coef_bit_ptr = & cinfo->coef_bits[cindex][0];
1364
+ if (cinfo->Ss && coef_bit_ptr[0] < 0) /* AC without prior DC scan */
1365
+ WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);
1366
+ for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) {
1367
+ int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi];
1368
+ if (cinfo->Ah != expected)
1369
+ WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi);
1370
+ coef_bit_ptr[coefi] = cinfo->Al;
1371
+ }
1372
+ }
1373
+
1374
+ /* Select MCU decoding routine */
1375
+ if (cinfo->Ah == 0) {
1376
+ if (cinfo->Ss == 0)
1377
+ entropy->pub.decode_mcu = decode_mcu_DC_first;
1378
+ else
1379
+ entropy->pub.decode_mcu = decode_mcu_AC_first;
1380
+ } else {
1381
+ if (cinfo->Ss == 0)
1382
+ entropy->pub.decode_mcu = decode_mcu_DC_refine;
1383
+ else
1384
+ entropy->pub.decode_mcu = decode_mcu_AC_refine;
1385
+ }
1386
+
1387
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
1388
+ compptr = cinfo->cur_comp_info[ci];
1389
+ /* Make sure requested tables are present, and compute derived tables.
1390
+ * We may build same derived table more than once, but it's not expensive.
1391
+ */
1392
+ if (cinfo->Ss == 0) {
1393
+ if (cinfo->Ah == 0) { /* DC refinement needs no table */
1394
+ tbl = compptr->dc_tbl_no;
1395
+ jpeg_make_d_derived_tbl(cinfo, TRUE, tbl,
1396
+ & entropy->derived_tbls[tbl]);
1397
+ }
1398
+ } else {
1399
+ tbl = compptr->ac_tbl_no;
1400
+ jpeg_make_d_derived_tbl(cinfo, FALSE, tbl,
1401
+ & entropy->derived_tbls[tbl]);
1402
+ /* remember the single active table */
1403
+ entropy->ac_derived_tbl = entropy->derived_tbls[tbl];
1404
+ }
1405
+ /* Initialize DC predictions to 0 */
1406
+ entropy->saved.last_dc_val[ci] = 0;
1407
+ }
1408
+
1409
+ /* Initialize private state variables */
1410
+ entropy->saved.EOBRUN = 0;
1411
+ } else {
1412
+ /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG.
1413
+ * This ought to be an error condition, but we make it a warning because
1414
+ * there are some baseline files out there with all zeroes in these bytes.
1415
+ */
1416
+ if (cinfo->Ss != 0 || cinfo->Ah != 0 || cinfo->Al != 0 ||
1417
+ ((cinfo->is_baseline || cinfo->Se < DCTSIZE2) &&
1418
+ cinfo->Se != cinfo->lim_Se))
1419
+ WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);
1420
+
1421
+ /* Select MCU decoding routine */
1422
+ /* We retain the hard-coded case for full-size blocks.
1423
+ * This is not necessary, but it appears that this version is slightly
1424
+ * more performant in the given implementation.
1425
+ * With an improved implementation we would prefer a single optimized
1426
+ * function.
1427
+ */
1428
+ if (cinfo->lim_Se != DCTSIZE2-1)
1429
+ entropy->pub.decode_mcu = decode_mcu_sub;
1430
+ else
1431
+ entropy->pub.decode_mcu = decode_mcu;
1432
+
1433
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
1434
+ compptr = cinfo->cur_comp_info[ci];
1435
+ /* Compute derived values for Huffman tables */
1436
+ /* We may do this more than once for a table, but it's not expensive */
1437
+ tbl = compptr->dc_tbl_no;
1438
+ jpeg_make_d_derived_tbl(cinfo, TRUE, tbl,
1439
+ & entropy->dc_derived_tbls[tbl]);
1440
+ if (cinfo->lim_Se) { /* AC needs no table when not present */
1441
+ tbl = compptr->ac_tbl_no;
1442
+ jpeg_make_d_derived_tbl(cinfo, FALSE, tbl,
1443
+ & entropy->ac_derived_tbls[tbl]);
1444
+ }
1445
+ /* Initialize DC predictions to 0 */
1446
+ entropy->saved.last_dc_val[ci] = 0;
1447
+ }
1448
+
1449
+ /* Precalculate decoding info for each block in an MCU of this scan */
1450
+ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
1451
+ ci = cinfo->MCU_membership[blkn];
1452
+ compptr = cinfo->cur_comp_info[ci];
1453
+ /* Precalculate which table to use for each block */
1454
+ entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no];
1455
+ entropy->ac_cur_tbls[blkn] = entropy->ac_derived_tbls[compptr->ac_tbl_no];
1456
+ /* Decide whether we really care about the coefficient values */
1457
+ if (compptr->component_needed) {
1458
+ ci = compptr->DCT_v_scaled_size;
1459
+ i = compptr->DCT_h_scaled_size;
1460
+ switch (cinfo->lim_Se) {
1461
+ case (1*1-1):
1462
+ entropy->coef_limit[blkn] = 1;
1463
+ break;
1464
+ case (2*2-1):
1465
+ if (ci <= 0 || ci > 2) ci = 2;
1466
+ if (i <= 0 || i > 2) i = 2;
1467
+ entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order2[ci - 1][i - 1];
1468
+ break;
1469
+ case (3*3-1):
1470
+ if (ci <= 0 || ci > 3) ci = 3;
1471
+ if (i <= 0 || i > 3) i = 3;
1472
+ entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order3[ci - 1][i - 1];
1473
+ break;
1474
+ case (4*4-1):
1475
+ if (ci <= 0 || ci > 4) ci = 4;
1476
+ if (i <= 0 || i > 4) i = 4;
1477
+ entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order4[ci - 1][i - 1];
1478
+ break;
1479
+ case (5*5-1):
1480
+ if (ci <= 0 || ci > 5) ci = 5;
1481
+ if (i <= 0 || i > 5) i = 5;
1482
+ entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order5[ci - 1][i - 1];
1483
+ break;
1484
+ case (6*6-1):
1485
+ if (ci <= 0 || ci > 6) ci = 6;
1486
+ if (i <= 0 || i > 6) i = 6;
1487
+ entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order6[ci - 1][i - 1];
1488
+ break;
1489
+ case (7*7-1):
1490
+ if (ci <= 0 || ci > 7) ci = 7;
1491
+ if (i <= 0 || i > 7) i = 7;
1492
+ entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order7[ci - 1][i - 1];
1493
+ break;
1494
+ default:
1495
+ if (ci <= 0 || ci > 8) ci = 8;
1496
+ if (i <= 0 || i > 8) i = 8;
1497
+ entropy->coef_limit[blkn] = 1 + jpeg_zigzag_order[ci - 1][i - 1];
1498
+ break;
1499
+ }
1500
+ } else {
1501
+ entropy->coef_limit[blkn] = 0;
1502
+ }
1503
+ }
1504
+ }
1505
+
1506
+ /* Initialize bitread state variables */
1507
+ entropy->bitstate.bits_left = 0;
1508
+ entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */
1509
+ entropy->insufficient_data = FALSE;
1510
+
1511
+ /* Initialize restart counter */
1512
+ entropy->restarts_to_go = cinfo->restart_interval;
1513
+ }
1514
+
1515
+
1516
+ /*
1517
+ * Module initialization routine for Huffman entropy decoding.
1518
+ */
1519
+
1520
+ GLOBAL(void)
1521
+ jinit_huff_decoder (j_decompress_ptr cinfo)
1522
+ {
1523
+ huff_entropy_ptr entropy;
1524
+ int i;
1525
+
1526
+ entropy = (huff_entropy_ptr)
1527
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
1528
+ SIZEOF(huff_entropy_decoder));
1529
+ cinfo->entropy = &entropy->pub;
1530
+ entropy->pub.start_pass = start_pass_huff_decoder;
1531
+ entropy->pub.finish_pass = finish_pass_huff;
1532
+
1533
+ if (cinfo->progressive_mode) {
1534
+ /* Create progression status table */
1535
+ int *coef_bit_ptr, ci;
1536
+ cinfo->coef_bits = (int (*)[DCTSIZE2])
1537
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
1538
+ cinfo->num_components*DCTSIZE2*SIZEOF(int));
1539
+ coef_bit_ptr = & cinfo->coef_bits[0][0];
1540
+ for (ci = 0; ci < cinfo->num_components; ci++)
1541
+ for (i = 0; i < DCTSIZE2; i++)
1542
+ *coef_bit_ptr++ = -1;
1543
+
1544
+ /* Mark derived tables unallocated */
1545
+ for (i = 0; i < NUM_HUFF_TBLS; i++) {
1546
+ entropy->derived_tbls[i] = NULL;
1547
+ }
1548
+ } else {
1549
+ /* Mark tables unallocated */
1550
+ for (i = 0; i < NUM_HUFF_TBLS; i++) {
1551
+ entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL;
1552
+ }
1553
+ }
1554
+ }