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,1700 @@
1
+ /* $Id: tif_dir.c,v 1.12 2015/02/19 22:39:58 drolon Exp $ */
2
+
3
+ /*
4
+ * Copyright (c) 1988-1997 Sam Leffler
5
+ * Copyright (c) 1991-1997 Silicon Graphics, Inc.
6
+ *
7
+ * Permission to use, copy, modify, distribute, and sell this software and
8
+ * its documentation for any purpose is hereby granted without fee, provided
9
+ * that (i) the above copyright notices and this permission notice appear in
10
+ * all copies of the software and related documentation, and (ii) the names of
11
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
12
+ * publicity relating to the software without the specific, prior written
13
+ * permission of Sam Leffler and Silicon Graphics.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
16
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
17
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
18
+ *
19
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
20
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
21
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
22
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24
+ * OF THIS SOFTWARE.
25
+ */
26
+
27
+ /*
28
+ * TIFF Library.
29
+ *
30
+ * Directory Tag Get & Set Routines.
31
+ * (and also some miscellaneous stuff)
32
+ */
33
+ #include "tiffiop.h"
34
+
35
+ /*
36
+ * These are used in the backwards compatibility code...
37
+ */
38
+ #define DATATYPE_VOID 0 /* !untyped data */
39
+ #define DATATYPE_INT 1 /* !signed integer data */
40
+ #define DATATYPE_UINT 2 /* !unsigned integer data */
41
+ #define DATATYPE_IEEEFP 3 /* !IEEE floating point data */
42
+
43
+ static void
44
+ setByteArray(void** vpp, void* vp, size_t nmemb, size_t elem_size)
45
+ {
46
+ if (*vpp)
47
+ _TIFFfree(*vpp), *vpp = 0;
48
+ if (vp) {
49
+ tmsize_t bytes = (tmsize_t)(nmemb * elem_size);
50
+ if (elem_size && bytes / elem_size == nmemb)
51
+ *vpp = (void*) _TIFFmalloc(bytes);
52
+ if (*vpp)
53
+ _TIFFmemcpy(*vpp, vp, bytes);
54
+ }
55
+ }
56
+ void _TIFFsetByteArray(void** vpp, void* vp, uint32 n)
57
+ { setByteArray(vpp, vp, n, 1); }
58
+ void _TIFFsetString(char** cpp, char* cp)
59
+ { setByteArray((void**) cpp, (void*) cp, strlen(cp)+1, 1); }
60
+ void _TIFFsetNString(char** cpp, char* cp, uint32 n)
61
+ { setByteArray((void**) cpp, (void*) cp, n, 1); }
62
+ void _TIFFsetShortArray(uint16** wpp, uint16* wp, uint32 n)
63
+ { setByteArray((void**) wpp, (void*) wp, n, sizeof (uint16)); }
64
+ void _TIFFsetLongArray(uint32** lpp, uint32* lp, uint32 n)
65
+ { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint32)); }
66
+ void _TIFFsetLong8Array(uint64** lpp, uint64* lp, uint32 n)
67
+ { setByteArray((void**) lpp, (void*) lp, n, sizeof (uint64)); }
68
+ void _TIFFsetFloatArray(float** fpp, float* fp, uint32 n)
69
+ { setByteArray((void**) fpp, (void*) fp, n, sizeof (float)); }
70
+ void _TIFFsetDoubleArray(double** dpp, double* dp, uint32 n)
71
+ { setByteArray((void**) dpp, (void*) dp, n, sizeof (double)); }
72
+
73
+ static void
74
+ setDoubleArrayOneValue(double** vpp, double value, size_t nmemb)
75
+ {
76
+ if (*vpp)
77
+ _TIFFfree(*vpp);
78
+ *vpp = _TIFFmalloc(nmemb*sizeof(double));
79
+ if (*vpp)
80
+ {
81
+ while (nmemb--)
82
+ ((double*)*vpp)[nmemb] = value;
83
+ }
84
+ }
85
+
86
+ /*
87
+ * Install extra samples information.
88
+ */
89
+ static int
90
+ setExtraSamples(TIFFDirectory* td, va_list ap, uint32* v)
91
+ {
92
+ /* XXX: Unassociated alpha data == 999 is a known Corel Draw bug, see below */
93
+ #define EXTRASAMPLE_COREL_UNASSALPHA 999
94
+
95
+ uint16* va;
96
+ uint32 i;
97
+
98
+ *v = (uint16) va_arg(ap, uint16_vap);
99
+ if ((uint16) *v > td->td_samplesperpixel)
100
+ return 0;
101
+ va = va_arg(ap, uint16*);
102
+ if (*v > 0 && va == NULL) /* typically missing param */
103
+ return 0;
104
+ for (i = 0; i < *v; i++) {
105
+ if (va[i] > EXTRASAMPLE_UNASSALPHA) {
106
+ /*
107
+ * XXX: Corel Draw is known to produce incorrect
108
+ * ExtraSamples tags which must be patched here if we
109
+ * want to be able to open some of the damaged TIFF
110
+ * files:
111
+ */
112
+ if (va[i] == EXTRASAMPLE_COREL_UNASSALPHA)
113
+ va[i] = EXTRASAMPLE_UNASSALPHA;
114
+ else
115
+ return 0;
116
+ }
117
+ }
118
+ td->td_extrasamples = (uint16) *v;
119
+ _TIFFsetShortArray(&td->td_sampleinfo, va, td->td_extrasamples);
120
+ return 1;
121
+
122
+ #undef EXTRASAMPLE_COREL_UNASSALPHA
123
+ }
124
+
125
+ /*
126
+ * Confirm we have "samplesperpixel" ink names separated by \0. Returns
127
+ * zero if the ink names are not as expected.
128
+ */
129
+ static uint32
130
+ checkInkNamesString(TIFF* tif, uint32 slen, const char* s)
131
+ {
132
+ TIFFDirectory* td = &tif->tif_dir;
133
+ uint16 i = td->td_samplesperpixel;
134
+
135
+ if (slen > 0) {
136
+ const char* ep = s+slen;
137
+ const char* cp = s;
138
+ for (; i > 0; i--) {
139
+ for (; cp < ep && *cp != '\0'; cp++) {}
140
+ if (cp >= ep)
141
+ goto bad;
142
+ cp++; /* skip \0 */
143
+ }
144
+ return ((uint32)(cp-s));
145
+ }
146
+ bad:
147
+ TIFFErrorExt(tif->tif_clientdata, "TIFFSetField",
148
+ "%s: Invalid InkNames value; expecting %d names, found %d",
149
+ tif->tif_name,
150
+ td->td_samplesperpixel,
151
+ td->td_samplesperpixel-i);
152
+ return (0);
153
+ }
154
+
155
+ static int
156
+ _TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
157
+ {
158
+ static const char module[] = "_TIFFVSetField";
159
+
160
+ TIFFDirectory* td = &tif->tif_dir;
161
+ int status = 1;
162
+ uint32 v32, i, v;
163
+ double dblval;
164
+ char* s;
165
+ const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
166
+ uint32 standard_tag = tag;
167
+ if( fip == NULL ) /* cannot happen since OkToChangeTag() already checks it */
168
+ return 0;
169
+ /*
170
+ * We want to force the custom code to be used for custom
171
+ * fields even if the tag happens to match a well known
172
+ * one - important for reinterpreted handling of standard
173
+ * tag values in custom directories (ie. EXIF)
174
+ */
175
+ if (fip->field_bit == FIELD_CUSTOM) {
176
+ standard_tag = 0;
177
+ }
178
+
179
+ switch (standard_tag) {
180
+ case TIFFTAG_SUBFILETYPE:
181
+ td->td_subfiletype = (uint32) va_arg(ap, uint32);
182
+ break;
183
+ case TIFFTAG_IMAGEWIDTH:
184
+ td->td_imagewidth = (uint32) va_arg(ap, uint32);
185
+ break;
186
+ case TIFFTAG_IMAGELENGTH:
187
+ td->td_imagelength = (uint32) va_arg(ap, uint32);
188
+ break;
189
+ case TIFFTAG_BITSPERSAMPLE:
190
+ td->td_bitspersample = (uint16) va_arg(ap, uint16_vap);
191
+ /*
192
+ * If the data require post-decoding processing to byte-swap
193
+ * samples, set it up here. Note that since tags are required
194
+ * to be ordered, compression code can override this behaviour
195
+ * in the setup method if it wants to roll the post decoding
196
+ * work in with its normal work.
197
+ */
198
+ if (tif->tif_flags & TIFF_SWAB) {
199
+ if (td->td_bitspersample == 8)
200
+ tif->tif_postdecode = _TIFFNoPostDecode;
201
+ else if (td->td_bitspersample == 16)
202
+ tif->tif_postdecode = _TIFFSwab16BitData;
203
+ else if (td->td_bitspersample == 24)
204
+ tif->tif_postdecode = _TIFFSwab24BitData;
205
+ else if (td->td_bitspersample == 32)
206
+ tif->tif_postdecode = _TIFFSwab32BitData;
207
+ else if (td->td_bitspersample == 64)
208
+ tif->tif_postdecode = _TIFFSwab64BitData;
209
+ else if (td->td_bitspersample == 128) /* two 64's */
210
+ tif->tif_postdecode = _TIFFSwab64BitData;
211
+ }
212
+ break;
213
+ case TIFFTAG_COMPRESSION:
214
+ v = (uint16) va_arg(ap, uint16_vap);
215
+ /*
216
+ * If we're changing the compression scheme, the notify the
217
+ * previous module so that it can cleanup any state it's
218
+ * setup.
219
+ */
220
+ if (TIFFFieldSet(tif, FIELD_COMPRESSION)) {
221
+ if ((uint32)td->td_compression == v)
222
+ break;
223
+ (*tif->tif_cleanup)(tif);
224
+ tif->tif_flags &= ~TIFF_CODERSETUP;
225
+ }
226
+ /*
227
+ * Setup new compression routine state.
228
+ */
229
+ if( (status = TIFFSetCompressionScheme(tif, v)) != 0 )
230
+ td->td_compression = (uint16) v;
231
+ else
232
+ status = 0;
233
+ break;
234
+ case TIFFTAG_PHOTOMETRIC:
235
+ td->td_photometric = (uint16) va_arg(ap, uint16_vap);
236
+ break;
237
+ case TIFFTAG_THRESHHOLDING:
238
+ td->td_threshholding = (uint16) va_arg(ap, uint16_vap);
239
+ break;
240
+ case TIFFTAG_FILLORDER:
241
+ v = (uint16) va_arg(ap, uint16_vap);
242
+ if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB)
243
+ goto badvalue;
244
+ td->td_fillorder = (uint16) v;
245
+ break;
246
+ case TIFFTAG_ORIENTATION:
247
+ v = (uint16) va_arg(ap, uint16_vap);
248
+ if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v)
249
+ goto badvalue;
250
+ else
251
+ td->td_orientation = (uint16) v;
252
+ break;
253
+ case TIFFTAG_SAMPLESPERPIXEL:
254
+ v = (uint16) va_arg(ap, uint16_vap);
255
+ if (v == 0)
256
+ goto badvalue;
257
+ td->td_samplesperpixel = (uint16) v;
258
+ break;
259
+ case TIFFTAG_ROWSPERSTRIP:
260
+ v32 = (uint32) va_arg(ap, uint32);
261
+ if (v32 == 0)
262
+ goto badvalue32;
263
+ td->td_rowsperstrip = v32;
264
+ if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) {
265
+ td->td_tilelength = v32;
266
+ td->td_tilewidth = td->td_imagewidth;
267
+ }
268
+ break;
269
+ case TIFFTAG_MINSAMPLEVALUE:
270
+ td->td_minsamplevalue = (uint16) va_arg(ap, uint16_vap);
271
+ break;
272
+ case TIFFTAG_MAXSAMPLEVALUE:
273
+ td->td_maxsamplevalue = (uint16) va_arg(ap, uint16_vap);
274
+ break;
275
+ case TIFFTAG_SMINSAMPLEVALUE:
276
+ if (tif->tif_flags & TIFF_PERSAMPLE)
277
+ _TIFFsetDoubleArray(&td->td_sminsamplevalue, va_arg(ap, double*), td->td_samplesperpixel);
278
+ else
279
+ setDoubleArrayOneValue(&td->td_sminsamplevalue, va_arg(ap, double), td->td_samplesperpixel);
280
+ break;
281
+ case TIFFTAG_SMAXSAMPLEVALUE:
282
+ if (tif->tif_flags & TIFF_PERSAMPLE)
283
+ _TIFFsetDoubleArray(&td->td_smaxsamplevalue, va_arg(ap, double*), td->td_samplesperpixel);
284
+ else
285
+ setDoubleArrayOneValue(&td->td_smaxsamplevalue, va_arg(ap, double), td->td_samplesperpixel);
286
+ break;
287
+ case TIFFTAG_XRESOLUTION:
288
+ dblval = va_arg(ap, double);
289
+ if( dblval < 0 )
290
+ goto badvaluedouble;
291
+ td->td_xresolution = (float) dblval;
292
+ break;
293
+ case TIFFTAG_YRESOLUTION:
294
+ dblval = va_arg(ap, double);
295
+ if( dblval < 0 )
296
+ goto badvaluedouble;
297
+ td->td_yresolution = (float) dblval;
298
+ break;
299
+ case TIFFTAG_PLANARCONFIG:
300
+ v = (uint16) va_arg(ap, uint16_vap);
301
+ if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE)
302
+ goto badvalue;
303
+ td->td_planarconfig = (uint16) v;
304
+ break;
305
+ case TIFFTAG_XPOSITION:
306
+ td->td_xposition = (float) va_arg(ap, double);
307
+ break;
308
+ case TIFFTAG_YPOSITION:
309
+ td->td_yposition = (float) va_arg(ap, double);
310
+ break;
311
+ case TIFFTAG_RESOLUTIONUNIT:
312
+ v = (uint16) va_arg(ap, uint16_vap);
313
+ if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v)
314
+ goto badvalue;
315
+ td->td_resolutionunit = (uint16) v;
316
+ break;
317
+ case TIFFTAG_PAGENUMBER:
318
+ td->td_pagenumber[0] = (uint16) va_arg(ap, uint16_vap);
319
+ td->td_pagenumber[1] = (uint16) va_arg(ap, uint16_vap);
320
+ break;
321
+ case TIFFTAG_HALFTONEHINTS:
322
+ td->td_halftonehints[0] = (uint16) va_arg(ap, uint16_vap);
323
+ td->td_halftonehints[1] = (uint16) va_arg(ap, uint16_vap);
324
+ break;
325
+ case TIFFTAG_COLORMAP:
326
+ v32 = (uint32)(1L<<td->td_bitspersample);
327
+ _TIFFsetShortArray(&td->td_colormap[0], va_arg(ap, uint16*), v32);
328
+ _TIFFsetShortArray(&td->td_colormap[1], va_arg(ap, uint16*), v32);
329
+ _TIFFsetShortArray(&td->td_colormap[2], va_arg(ap, uint16*), v32);
330
+ break;
331
+ case TIFFTAG_EXTRASAMPLES:
332
+ if (!setExtraSamples(td, ap, &v))
333
+ goto badvalue;
334
+ break;
335
+ case TIFFTAG_MATTEING:
336
+ td->td_extrasamples = (((uint16) va_arg(ap, uint16_vap)) != 0);
337
+ if (td->td_extrasamples) {
338
+ uint16 sv = EXTRASAMPLE_ASSOCALPHA;
339
+ _TIFFsetShortArray(&td->td_sampleinfo, &sv, 1);
340
+ }
341
+ break;
342
+ case TIFFTAG_TILEWIDTH:
343
+ v32 = (uint32) va_arg(ap, uint32);
344
+ if (v32 % 16) {
345
+ if (tif->tif_mode != O_RDONLY)
346
+ goto badvalue32;
347
+ TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
348
+ "Nonstandard tile width %d, convert file", v32);
349
+ }
350
+ td->td_tilewidth = v32;
351
+ tif->tif_flags |= TIFF_ISTILED;
352
+ break;
353
+ case TIFFTAG_TILELENGTH:
354
+ v32 = (uint32) va_arg(ap, uint32);
355
+ if (v32 % 16) {
356
+ if (tif->tif_mode != O_RDONLY)
357
+ goto badvalue32;
358
+ TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
359
+ "Nonstandard tile length %d, convert file", v32);
360
+ }
361
+ td->td_tilelength = v32;
362
+ tif->tif_flags |= TIFF_ISTILED;
363
+ break;
364
+ case TIFFTAG_TILEDEPTH:
365
+ v32 = (uint32) va_arg(ap, uint32);
366
+ if (v32 == 0)
367
+ goto badvalue32;
368
+ td->td_tiledepth = v32;
369
+ break;
370
+ case TIFFTAG_DATATYPE:
371
+ v = (uint16) va_arg(ap, uint16_vap);
372
+ switch (v) {
373
+ case DATATYPE_VOID: v = SAMPLEFORMAT_VOID; break;
374
+ case DATATYPE_INT: v = SAMPLEFORMAT_INT; break;
375
+ case DATATYPE_UINT: v = SAMPLEFORMAT_UINT; break;
376
+ case DATATYPE_IEEEFP: v = SAMPLEFORMAT_IEEEFP;break;
377
+ default: goto badvalue;
378
+ }
379
+ td->td_sampleformat = (uint16) v;
380
+ break;
381
+ case TIFFTAG_SAMPLEFORMAT:
382
+ v = (uint16) va_arg(ap, uint16_vap);
383
+ if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_COMPLEXIEEEFP < v)
384
+ goto badvalue;
385
+ td->td_sampleformat = (uint16) v;
386
+
387
+ /* Try to fix up the SWAB function for complex data. */
388
+ if( td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT
389
+ && td->td_bitspersample == 32
390
+ && tif->tif_postdecode == _TIFFSwab32BitData )
391
+ tif->tif_postdecode = _TIFFSwab16BitData;
392
+ else if( (td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT
393
+ || td->td_sampleformat == SAMPLEFORMAT_COMPLEXIEEEFP)
394
+ && td->td_bitspersample == 64
395
+ && tif->tif_postdecode == _TIFFSwab64BitData )
396
+ tif->tif_postdecode = _TIFFSwab32BitData;
397
+ break;
398
+ case TIFFTAG_IMAGEDEPTH:
399
+ td->td_imagedepth = (uint32) va_arg(ap, uint32);
400
+ break;
401
+ case TIFFTAG_SUBIFD:
402
+ if ((tif->tif_flags & TIFF_INSUBIFD) == 0) {
403
+ td->td_nsubifd = (uint16) va_arg(ap, uint16_vap);
404
+ _TIFFsetLong8Array(&td->td_subifd, (uint64*) va_arg(ap, uint64*),
405
+ (long) td->td_nsubifd);
406
+ } else {
407
+ TIFFErrorExt(tif->tif_clientdata, module,
408
+ "%s: Sorry, cannot nest SubIFDs",
409
+ tif->tif_name);
410
+ status = 0;
411
+ }
412
+ break;
413
+ case TIFFTAG_YCBCRPOSITIONING:
414
+ td->td_ycbcrpositioning = (uint16) va_arg(ap, uint16_vap);
415
+ break;
416
+ case TIFFTAG_YCBCRSUBSAMPLING:
417
+ td->td_ycbcrsubsampling[0] = (uint16) va_arg(ap, uint16_vap);
418
+ td->td_ycbcrsubsampling[1] = (uint16) va_arg(ap, uint16_vap);
419
+ break;
420
+ case TIFFTAG_TRANSFERFUNCTION:
421
+ v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1;
422
+ for (i = 0; i < v; i++)
423
+ _TIFFsetShortArray(&td->td_transferfunction[i],
424
+ va_arg(ap, uint16*), 1L<<td->td_bitspersample);
425
+ break;
426
+ case TIFFTAG_REFERENCEBLACKWHITE:
427
+ /* XXX should check for null range */
428
+ _TIFFsetFloatArray(&td->td_refblackwhite, va_arg(ap, float*), 6);
429
+ break;
430
+ case TIFFTAG_INKNAMES:
431
+ v = (uint16) va_arg(ap, uint16_vap);
432
+ s = va_arg(ap, char*);
433
+ v = checkInkNamesString(tif, v, s);
434
+ status = v > 0;
435
+ if( v > 0 ) {
436
+ _TIFFsetNString(&td->td_inknames, s, v);
437
+ td->td_inknameslen = v;
438
+ }
439
+ break;
440
+ case TIFFTAG_PERSAMPLE:
441
+ v = (uint16) va_arg(ap, uint16_vap);
442
+ if( v == PERSAMPLE_MULTI )
443
+ tif->tif_flags |= TIFF_PERSAMPLE;
444
+ else
445
+ tif->tif_flags &= ~TIFF_PERSAMPLE;
446
+ break;
447
+ default: {
448
+ TIFFTagValue *tv;
449
+ int tv_size, iCustom;
450
+
451
+ /*
452
+ * This can happen if multiple images are open with different
453
+ * codecs which have private tags. The global tag information
454
+ * table may then have tags that are valid for one file but not
455
+ * the other. If the client tries to set a tag that is not valid
456
+ * for the image's codec then we'll arrive here. This
457
+ * happens, for example, when tiffcp is used to convert between
458
+ * compression schemes and codec-specific tags are blindly copied.
459
+ */
460
+ if(fip->field_bit != FIELD_CUSTOM) {
461
+ TIFFErrorExt(tif->tif_clientdata, module,
462
+ "%s: Invalid %stag \"%s\" (not supported by codec)",
463
+ tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "",
464
+ fip->field_name);
465
+ status = 0;
466
+ break;
467
+ }
468
+
469
+ /*
470
+ * Find the existing entry for this custom value.
471
+ */
472
+ tv = NULL;
473
+ for (iCustom = 0; iCustom < td->td_customValueCount; iCustom++) {
474
+ if (td->td_customValues[iCustom].info->field_tag == tag) {
475
+ tv = td->td_customValues + iCustom;
476
+ if (tv->value != NULL) {
477
+ _TIFFfree(tv->value);
478
+ tv->value = NULL;
479
+ }
480
+ break;
481
+ }
482
+ }
483
+
484
+ /*
485
+ * Grow the custom list if the entry was not found.
486
+ */
487
+ if(tv == NULL) {
488
+ TIFFTagValue *new_customValues;
489
+
490
+ td->td_customValueCount++;
491
+ new_customValues = (TIFFTagValue *)
492
+ _TIFFrealloc(td->td_customValues,
493
+ sizeof(TIFFTagValue) * td->td_customValueCount);
494
+ if (!new_customValues) {
495
+ TIFFErrorExt(tif->tif_clientdata, module,
496
+ "%s: Failed to allocate space for list of custom values",
497
+ tif->tif_name);
498
+ status = 0;
499
+ goto end;
500
+ }
501
+
502
+ td->td_customValues = new_customValues;
503
+
504
+ tv = td->td_customValues + (td->td_customValueCount - 1);
505
+ tv->info = fip;
506
+ tv->value = NULL;
507
+ tv->count = 0;
508
+ }
509
+
510
+ /*
511
+ * Set custom value ... save a copy of the custom tag value.
512
+ */
513
+ tv_size = _TIFFDataSize(fip->field_type);
514
+ if (tv_size == 0) {
515
+ status = 0;
516
+ TIFFErrorExt(tif->tif_clientdata, module,
517
+ "%s: Bad field type %d for \"%s\"",
518
+ tif->tif_name, fip->field_type,
519
+ fip->field_name);
520
+ goto end;
521
+ }
522
+
523
+ if (fip->field_type == TIFF_ASCII)
524
+ {
525
+ uint32 ma;
526
+ char* mb;
527
+ if (fip->field_passcount)
528
+ {
529
+ assert(fip->field_writecount==TIFF_VARIABLE2);
530
+ ma=(uint32)va_arg(ap,uint32);
531
+ mb=(char*)va_arg(ap,char*);
532
+ }
533
+ else
534
+ {
535
+ mb=(char*)va_arg(ap,char*);
536
+ ma=(uint32)(strlen(mb)+1);
537
+ }
538
+ tv->count=ma;
539
+ setByteArray(&tv->value,mb,ma,1);
540
+ }
541
+ else
542
+ {
543
+ if (fip->field_passcount) {
544
+ if (fip->field_writecount == TIFF_VARIABLE2)
545
+ tv->count = (uint32) va_arg(ap, uint32);
546
+ else
547
+ tv->count = (int) va_arg(ap, int);
548
+ } else if (fip->field_writecount == TIFF_VARIABLE
549
+ || fip->field_writecount == TIFF_VARIABLE2)
550
+ tv->count = 1;
551
+ else if (fip->field_writecount == TIFF_SPP)
552
+ tv->count = td->td_samplesperpixel;
553
+ else
554
+ tv->count = fip->field_writecount;
555
+
556
+ if (tv->count == 0) {
557
+ status = 0;
558
+ TIFFErrorExt(tif->tif_clientdata, module,
559
+ "%s: Null count for \"%s\" (type "
560
+ "%d, writecount %d, passcount %d)",
561
+ tif->tif_name,
562
+ fip->field_name,
563
+ fip->field_type,
564
+ fip->field_writecount,
565
+ fip->field_passcount);
566
+ goto end;
567
+ }
568
+
569
+ tv->value = _TIFFCheckMalloc(tif, tv->count, tv_size,
570
+ "custom tag binary object");
571
+ if (!tv->value) {
572
+ status = 0;
573
+ goto end;
574
+ }
575
+
576
+ if (fip->field_tag == TIFFTAG_DOTRANGE
577
+ && strcmp(fip->field_name,"DotRange") == 0) {
578
+ /* TODO: This is an evil exception and should not have been
579
+ handled this way ... likely best if we move it into
580
+ the directory structure with an explicit field in
581
+ libtiff 4.1 and assign it a FIELD_ value */
582
+ uint16 v[2];
583
+ v[0] = (uint16)va_arg(ap, int);
584
+ v[1] = (uint16)va_arg(ap, int);
585
+ _TIFFmemcpy(tv->value, &v, 4);
586
+ }
587
+
588
+ else if (fip->field_passcount
589
+ || fip->field_writecount == TIFF_VARIABLE
590
+ || fip->field_writecount == TIFF_VARIABLE2
591
+ || fip->field_writecount == TIFF_SPP
592
+ || tv->count > 1) {
593
+ _TIFFmemcpy(tv->value, va_arg(ap, void *),
594
+ tv->count * tv_size);
595
+ } else {
596
+ char *val = (char *)tv->value;
597
+ assert( tv->count == 1 );
598
+
599
+ switch (fip->field_type) {
600
+ case TIFF_BYTE:
601
+ case TIFF_UNDEFINED:
602
+ {
603
+ uint8 v = (uint8)va_arg(ap, int);
604
+ _TIFFmemcpy(val, &v, tv_size);
605
+ }
606
+ break;
607
+ case TIFF_SBYTE:
608
+ {
609
+ int8 v = (int8)va_arg(ap, int);
610
+ _TIFFmemcpy(val, &v, tv_size);
611
+ }
612
+ break;
613
+ case TIFF_SHORT:
614
+ {
615
+ uint16 v = (uint16)va_arg(ap, int);
616
+ _TIFFmemcpy(val, &v, tv_size);
617
+ }
618
+ break;
619
+ case TIFF_SSHORT:
620
+ {
621
+ int16 v = (int16)va_arg(ap, int);
622
+ _TIFFmemcpy(val, &v, tv_size);
623
+ }
624
+ break;
625
+ case TIFF_LONG:
626
+ case TIFF_IFD:
627
+ {
628
+ uint32 v = va_arg(ap, uint32);
629
+ _TIFFmemcpy(val, &v, tv_size);
630
+ }
631
+ break;
632
+ case TIFF_SLONG:
633
+ {
634
+ int32 v = va_arg(ap, int32);
635
+ _TIFFmemcpy(val, &v, tv_size);
636
+ }
637
+ break;
638
+ case TIFF_LONG8:
639
+ case TIFF_IFD8:
640
+ {
641
+ uint64 v = va_arg(ap, uint64);
642
+ _TIFFmemcpy(val, &v, tv_size);
643
+ }
644
+ break;
645
+ case TIFF_SLONG8:
646
+ {
647
+ int64 v = va_arg(ap, int64);
648
+ _TIFFmemcpy(val, &v, tv_size);
649
+ }
650
+ break;
651
+ case TIFF_RATIONAL:
652
+ case TIFF_SRATIONAL:
653
+ case TIFF_FLOAT:
654
+ {
655
+ float v = (float)va_arg(ap, double);
656
+ _TIFFmemcpy(val, &v, tv_size);
657
+ }
658
+ break;
659
+ case TIFF_DOUBLE:
660
+ {
661
+ double v = va_arg(ap, double);
662
+ _TIFFmemcpy(val, &v, tv_size);
663
+ }
664
+ break;
665
+ default:
666
+ _TIFFmemset(val, 0, tv_size);
667
+ status = 0;
668
+ break;
669
+ }
670
+ }
671
+ }
672
+ }
673
+ }
674
+ if (status) {
675
+ const TIFFField* fip=TIFFFieldWithTag(tif,tag);
676
+ if (fip)
677
+ TIFFSetFieldBit(tif, fip->field_bit);
678
+ tif->tif_flags |= TIFF_DIRTYDIRECT;
679
+ }
680
+
681
+ end:
682
+ va_end(ap);
683
+ return (status);
684
+ badvalue:
685
+ {
686
+ const TIFFField* fip=TIFFFieldWithTag(tif,tag);
687
+ TIFFErrorExt(tif->tif_clientdata, module,
688
+ "%s: Bad value %u for \"%s\" tag",
689
+ tif->tif_name, v,
690
+ fip ? fip->field_name : "Unknown");
691
+ va_end(ap);
692
+ }
693
+ return (0);
694
+ badvalue32:
695
+ {
696
+ const TIFFField* fip=TIFFFieldWithTag(tif,tag);
697
+ TIFFErrorExt(tif->tif_clientdata, module,
698
+ "%s: Bad value %u for \"%s\" tag",
699
+ tif->tif_name, v32,
700
+ fip ? fip->field_name : "Unknown");
701
+ va_end(ap);
702
+ }
703
+ return (0);
704
+ badvaluedouble:
705
+ {
706
+ const TIFFField* fip=TIFFFieldWithTag(tif,tag);
707
+ TIFFErrorExt(tif->tif_clientdata, module,
708
+ "%s: Bad value %f for \"%s\" tag",
709
+ tif->tif_name, dblval,
710
+ fip ? fip->field_name : "Unknown");
711
+ va_end(ap);
712
+ }
713
+ return (0);
714
+ }
715
+
716
+ /*
717
+ * Return 1/0 according to whether or not
718
+ * it is permissible to set the tag's value.
719
+ * Note that we allow ImageLength to be changed
720
+ * so that we can append and extend to images.
721
+ * Any other tag may not be altered once writing
722
+ * has commenced, unless its value has no effect
723
+ * on the format of the data that is written.
724
+ */
725
+ static int
726
+ OkToChangeTag(TIFF* tif, uint32 tag)
727
+ {
728
+ const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
729
+ if (!fip) { /* unknown tag */
730
+ TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %u",
731
+ tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag);
732
+ return (0);
733
+ }
734
+ if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING) &&
735
+ !fip->field_oktochange) {
736
+ /*
737
+ * Consult info table to see if tag can be changed
738
+ * after we've started writing. We only allow changes
739
+ * to those tags that don't/shouldn't affect the
740
+ * compression and/or format of the data.
741
+ */
742
+ TIFFErrorExt(tif->tif_clientdata, "TIFFSetField",
743
+ "%s: Cannot modify tag \"%s\" while writing",
744
+ tif->tif_name, fip->field_name);
745
+ return (0);
746
+ }
747
+ return (1);
748
+ }
749
+
750
+ /*
751
+ * Record the value of a field in the
752
+ * internal directory structure. The
753
+ * field will be written to the file
754
+ * when/if the directory structure is
755
+ * updated.
756
+ */
757
+ int
758
+ TIFFSetField(TIFF* tif, uint32 tag, ...)
759
+ {
760
+ va_list ap;
761
+ int status;
762
+
763
+ va_start(ap, tag);
764
+ status = TIFFVSetField(tif, tag, ap);
765
+ va_end(ap);
766
+ return (status);
767
+ }
768
+
769
+ /*
770
+ * Clear the contents of the field in the internal structure.
771
+ */
772
+ int
773
+ TIFFUnsetField(TIFF* tif, uint32 tag)
774
+ {
775
+ const TIFFField *fip = TIFFFieldWithTag(tif, tag);
776
+ TIFFDirectory* td = &tif->tif_dir;
777
+
778
+ if( !fip )
779
+ return 0;
780
+
781
+ if( fip->field_bit != FIELD_CUSTOM )
782
+ TIFFClrFieldBit(tif, fip->field_bit);
783
+ else
784
+ {
785
+ TIFFTagValue *tv = NULL;
786
+ int i;
787
+
788
+ for (i = 0; i < td->td_customValueCount; i++) {
789
+
790
+ tv = td->td_customValues + i;
791
+ if( tv->info->field_tag == tag )
792
+ break;
793
+ }
794
+
795
+ if( i < td->td_customValueCount )
796
+ {
797
+ _TIFFfree(tv->value);
798
+ for( ; i < td->td_customValueCount-1; i++) {
799
+ td->td_customValues[i] = td->td_customValues[i+1];
800
+ }
801
+ td->td_customValueCount--;
802
+ }
803
+ }
804
+
805
+ tif->tif_flags |= TIFF_DIRTYDIRECT;
806
+
807
+ return (1);
808
+ }
809
+
810
+ /*
811
+ * Like TIFFSetField, but taking a varargs
812
+ * parameter list. This routine is useful
813
+ * for building higher-level interfaces on
814
+ * top of the library.
815
+ */
816
+ int
817
+ TIFFVSetField(TIFF* tif, uint32 tag, va_list ap)
818
+ {
819
+ return OkToChangeTag(tif, tag) ?
820
+ (*tif->tif_tagmethods.vsetfield)(tif, tag, ap) : 0;
821
+ }
822
+
823
+ static int
824
+ _TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
825
+ {
826
+ TIFFDirectory* td = &tif->tif_dir;
827
+ int ret_val = 1;
828
+ uint32 standard_tag = tag;
829
+ const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
830
+ if( fip == NULL ) /* cannot happen since TIFFGetField() already checks it */
831
+ return 0;
832
+
833
+ /*
834
+ * We want to force the custom code to be used for custom
835
+ * fields even if the tag happens to match a well known
836
+ * one - important for reinterpreted handling of standard
837
+ * tag values in custom directories (ie. EXIF)
838
+ */
839
+ if (fip->field_bit == FIELD_CUSTOM) {
840
+ standard_tag = 0;
841
+ }
842
+
843
+ switch (standard_tag) {
844
+ case TIFFTAG_SUBFILETYPE:
845
+ *va_arg(ap, uint32*) = td->td_subfiletype;
846
+ break;
847
+ case TIFFTAG_IMAGEWIDTH:
848
+ *va_arg(ap, uint32*) = td->td_imagewidth;
849
+ break;
850
+ case TIFFTAG_IMAGELENGTH:
851
+ *va_arg(ap, uint32*) = td->td_imagelength;
852
+ break;
853
+ case TIFFTAG_BITSPERSAMPLE:
854
+ *va_arg(ap, uint16*) = td->td_bitspersample;
855
+ break;
856
+ case TIFFTAG_COMPRESSION:
857
+ *va_arg(ap, uint16*) = td->td_compression;
858
+ break;
859
+ case TIFFTAG_PHOTOMETRIC:
860
+ *va_arg(ap, uint16*) = td->td_photometric;
861
+ break;
862
+ case TIFFTAG_THRESHHOLDING:
863
+ *va_arg(ap, uint16*) = td->td_threshholding;
864
+ break;
865
+ case TIFFTAG_FILLORDER:
866
+ *va_arg(ap, uint16*) = td->td_fillorder;
867
+ break;
868
+ case TIFFTAG_ORIENTATION:
869
+ *va_arg(ap, uint16*) = td->td_orientation;
870
+ break;
871
+ case TIFFTAG_SAMPLESPERPIXEL:
872
+ *va_arg(ap, uint16*) = td->td_samplesperpixel;
873
+ break;
874
+ case TIFFTAG_ROWSPERSTRIP:
875
+ *va_arg(ap, uint32*) = td->td_rowsperstrip;
876
+ break;
877
+ case TIFFTAG_MINSAMPLEVALUE:
878
+ *va_arg(ap, uint16*) = td->td_minsamplevalue;
879
+ break;
880
+ case TIFFTAG_MAXSAMPLEVALUE:
881
+ *va_arg(ap, uint16*) = td->td_maxsamplevalue;
882
+ break;
883
+ case TIFFTAG_SMINSAMPLEVALUE:
884
+ if (tif->tif_flags & TIFF_PERSAMPLE)
885
+ *va_arg(ap, double**) = td->td_sminsamplevalue;
886
+ else
887
+ {
888
+ /* libtiff historially treats this as a single value. */
889
+ uint16 i;
890
+ double v = td->td_sminsamplevalue[0];
891
+ for (i=1; i < td->td_samplesperpixel; ++i)
892
+ if( td->td_sminsamplevalue[i] < v )
893
+ v = td->td_sminsamplevalue[i];
894
+ *va_arg(ap, double*) = v;
895
+ }
896
+ break;
897
+ case TIFFTAG_SMAXSAMPLEVALUE:
898
+ if (tif->tif_flags & TIFF_PERSAMPLE)
899
+ *va_arg(ap, double**) = td->td_smaxsamplevalue;
900
+ else
901
+ {
902
+ /* libtiff historially treats this as a single value. */
903
+ uint16 i;
904
+ double v = td->td_smaxsamplevalue[0];
905
+ for (i=1; i < td->td_samplesperpixel; ++i)
906
+ if( td->td_smaxsamplevalue[i] > v )
907
+ v = td->td_smaxsamplevalue[i];
908
+ *va_arg(ap, double*) = v;
909
+ }
910
+ break;
911
+ case TIFFTAG_XRESOLUTION:
912
+ *va_arg(ap, float*) = td->td_xresolution;
913
+ break;
914
+ case TIFFTAG_YRESOLUTION:
915
+ *va_arg(ap, float*) = td->td_yresolution;
916
+ break;
917
+ case TIFFTAG_PLANARCONFIG:
918
+ *va_arg(ap, uint16*) = td->td_planarconfig;
919
+ break;
920
+ case TIFFTAG_XPOSITION:
921
+ *va_arg(ap, float*) = td->td_xposition;
922
+ break;
923
+ case TIFFTAG_YPOSITION:
924
+ *va_arg(ap, float*) = td->td_yposition;
925
+ break;
926
+ case TIFFTAG_RESOLUTIONUNIT:
927
+ *va_arg(ap, uint16*) = td->td_resolutionunit;
928
+ break;
929
+ case TIFFTAG_PAGENUMBER:
930
+ *va_arg(ap, uint16*) = td->td_pagenumber[0];
931
+ *va_arg(ap, uint16*) = td->td_pagenumber[1];
932
+ break;
933
+ case TIFFTAG_HALFTONEHINTS:
934
+ *va_arg(ap, uint16*) = td->td_halftonehints[0];
935
+ *va_arg(ap, uint16*) = td->td_halftonehints[1];
936
+ break;
937
+ case TIFFTAG_COLORMAP:
938
+ *va_arg(ap, uint16**) = td->td_colormap[0];
939
+ *va_arg(ap, uint16**) = td->td_colormap[1];
940
+ *va_arg(ap, uint16**) = td->td_colormap[2];
941
+ break;
942
+ case TIFFTAG_STRIPOFFSETS:
943
+ case TIFFTAG_TILEOFFSETS:
944
+ _TIFFFillStriles( tif );
945
+ *va_arg(ap, uint64**) = td->td_stripoffset;
946
+ break;
947
+ case TIFFTAG_STRIPBYTECOUNTS:
948
+ case TIFFTAG_TILEBYTECOUNTS:
949
+ _TIFFFillStriles( tif );
950
+ *va_arg(ap, uint64**) = td->td_stripbytecount;
951
+ break;
952
+ case TIFFTAG_MATTEING:
953
+ *va_arg(ap, uint16*) =
954
+ (td->td_extrasamples == 1 &&
955
+ td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA);
956
+ break;
957
+ case TIFFTAG_EXTRASAMPLES:
958
+ *va_arg(ap, uint16*) = td->td_extrasamples;
959
+ *va_arg(ap, uint16**) = td->td_sampleinfo;
960
+ break;
961
+ case TIFFTAG_TILEWIDTH:
962
+ *va_arg(ap, uint32*) = td->td_tilewidth;
963
+ break;
964
+ case TIFFTAG_TILELENGTH:
965
+ *va_arg(ap, uint32*) = td->td_tilelength;
966
+ break;
967
+ case TIFFTAG_TILEDEPTH:
968
+ *va_arg(ap, uint32*) = td->td_tiledepth;
969
+ break;
970
+ case TIFFTAG_DATATYPE:
971
+ switch (td->td_sampleformat) {
972
+ case SAMPLEFORMAT_UINT:
973
+ *va_arg(ap, uint16*) = DATATYPE_UINT;
974
+ break;
975
+ case SAMPLEFORMAT_INT:
976
+ *va_arg(ap, uint16*) = DATATYPE_INT;
977
+ break;
978
+ case SAMPLEFORMAT_IEEEFP:
979
+ *va_arg(ap, uint16*) = DATATYPE_IEEEFP;
980
+ break;
981
+ case SAMPLEFORMAT_VOID:
982
+ *va_arg(ap, uint16*) = DATATYPE_VOID;
983
+ break;
984
+ }
985
+ break;
986
+ case TIFFTAG_SAMPLEFORMAT:
987
+ *va_arg(ap, uint16*) = td->td_sampleformat;
988
+ break;
989
+ case TIFFTAG_IMAGEDEPTH:
990
+ *va_arg(ap, uint32*) = td->td_imagedepth;
991
+ break;
992
+ case TIFFTAG_SUBIFD:
993
+ *va_arg(ap, uint16*) = td->td_nsubifd;
994
+ *va_arg(ap, uint64**) = td->td_subifd;
995
+ break;
996
+ case TIFFTAG_YCBCRPOSITIONING:
997
+ *va_arg(ap, uint16*) = td->td_ycbcrpositioning;
998
+ break;
999
+ case TIFFTAG_YCBCRSUBSAMPLING:
1000
+ *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[0];
1001
+ *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[1];
1002
+ break;
1003
+ case TIFFTAG_TRANSFERFUNCTION:
1004
+ *va_arg(ap, uint16**) = td->td_transferfunction[0];
1005
+ if (td->td_samplesperpixel - td->td_extrasamples > 1) {
1006
+ *va_arg(ap, uint16**) = td->td_transferfunction[1];
1007
+ *va_arg(ap, uint16**) = td->td_transferfunction[2];
1008
+ }
1009
+ break;
1010
+ case TIFFTAG_REFERENCEBLACKWHITE:
1011
+ *va_arg(ap, float**) = td->td_refblackwhite;
1012
+ break;
1013
+ case TIFFTAG_INKNAMES:
1014
+ *va_arg(ap, char**) = td->td_inknames;
1015
+ break;
1016
+ default:
1017
+ {
1018
+ int i;
1019
+
1020
+ /*
1021
+ * This can happen if multiple images are open
1022
+ * with different codecs which have private
1023
+ * tags. The global tag information table may
1024
+ * then have tags that are valid for one file
1025
+ * but not the other. If the client tries to
1026
+ * get a tag that is not valid for the image's
1027
+ * codec then we'll arrive here.
1028
+ */
1029
+ if( fip->field_bit != FIELD_CUSTOM )
1030
+ {
1031
+ TIFFErrorExt(tif->tif_clientdata, "_TIFFVGetField",
1032
+ "%s: Invalid %stag \"%s\" "
1033
+ "(not supported by codec)",
1034
+ tif->tif_name,
1035
+ isPseudoTag(tag) ? "pseudo-" : "",
1036
+ fip->field_name);
1037
+ ret_val = 0;
1038
+ break;
1039
+ }
1040
+
1041
+ /*
1042
+ * Do we have a custom value?
1043
+ */
1044
+ ret_val = 0;
1045
+ for (i = 0; i < td->td_customValueCount; i++) {
1046
+ TIFFTagValue *tv = td->td_customValues + i;
1047
+
1048
+ if (tv->info->field_tag != tag)
1049
+ continue;
1050
+
1051
+ if (fip->field_passcount) {
1052
+ if (fip->field_readcount == TIFF_VARIABLE2)
1053
+ *va_arg(ap, uint32*) = (uint32)tv->count;
1054
+ else /* Assume TIFF_VARIABLE */
1055
+ *va_arg(ap, uint16*) = (uint16)tv->count;
1056
+ *va_arg(ap, void **) = tv->value;
1057
+ ret_val = 1;
1058
+ } else if (fip->field_tag == TIFFTAG_DOTRANGE
1059
+ && strcmp(fip->field_name,"DotRange") == 0) {
1060
+ /* TODO: This is an evil exception and should not have been
1061
+ handled this way ... likely best if we move it into
1062
+ the directory structure with an explicit field in
1063
+ libtiff 4.1 and assign it a FIELD_ value */
1064
+ *va_arg(ap, uint16*) = ((uint16 *)tv->value)[0];
1065
+ *va_arg(ap, uint16*) = ((uint16 *)tv->value)[1];
1066
+ ret_val = 1;
1067
+ } else {
1068
+ if (fip->field_type == TIFF_ASCII
1069
+ || fip->field_readcount == TIFF_VARIABLE
1070
+ || fip->field_readcount == TIFF_VARIABLE2
1071
+ || fip->field_readcount == TIFF_SPP
1072
+ || tv->count > 1) {
1073
+ *va_arg(ap, void **) = tv->value;
1074
+ ret_val = 1;
1075
+ } else {
1076
+ char *val = (char *)tv->value;
1077
+ assert( tv->count == 1 );
1078
+ switch (fip->field_type) {
1079
+ case TIFF_BYTE:
1080
+ case TIFF_UNDEFINED:
1081
+ *va_arg(ap, uint8*) =
1082
+ *(uint8 *)val;
1083
+ ret_val = 1;
1084
+ break;
1085
+ case TIFF_SBYTE:
1086
+ *va_arg(ap, int8*) =
1087
+ *(int8 *)val;
1088
+ ret_val = 1;
1089
+ break;
1090
+ case TIFF_SHORT:
1091
+ *va_arg(ap, uint16*) =
1092
+ *(uint16 *)val;
1093
+ ret_val = 1;
1094
+ break;
1095
+ case TIFF_SSHORT:
1096
+ *va_arg(ap, int16*) =
1097
+ *(int16 *)val;
1098
+ ret_val = 1;
1099
+ break;
1100
+ case TIFF_LONG:
1101
+ case TIFF_IFD:
1102
+ *va_arg(ap, uint32*) =
1103
+ *(uint32 *)val;
1104
+ ret_val = 1;
1105
+ break;
1106
+ case TIFF_SLONG:
1107
+ *va_arg(ap, int32*) =
1108
+ *(int32 *)val;
1109
+ ret_val = 1;
1110
+ break;
1111
+ case TIFF_LONG8:
1112
+ case TIFF_IFD8:
1113
+ *va_arg(ap, uint64*) =
1114
+ *(uint64 *)val;
1115
+ ret_val = 1;
1116
+ break;
1117
+ case TIFF_SLONG8:
1118
+ *va_arg(ap, int64*) =
1119
+ *(int64 *)val;
1120
+ ret_val = 1;
1121
+ break;
1122
+ case TIFF_RATIONAL:
1123
+ case TIFF_SRATIONAL:
1124
+ case TIFF_FLOAT:
1125
+ *va_arg(ap, float*) =
1126
+ *(float *)val;
1127
+ ret_val = 1;
1128
+ break;
1129
+ case TIFF_DOUBLE:
1130
+ *va_arg(ap, double*) =
1131
+ *(double *)val;
1132
+ ret_val = 1;
1133
+ break;
1134
+ default:
1135
+ ret_val = 0;
1136
+ break;
1137
+ }
1138
+ }
1139
+ }
1140
+ break;
1141
+ }
1142
+ }
1143
+ }
1144
+ return(ret_val);
1145
+ }
1146
+
1147
+ /*
1148
+ * Return the value of a field in the
1149
+ * internal directory structure.
1150
+ */
1151
+ int
1152
+ TIFFGetField(TIFF* tif, uint32 tag, ...)
1153
+ {
1154
+ int status;
1155
+ va_list ap;
1156
+
1157
+ va_start(ap, tag);
1158
+ status = TIFFVGetField(tif, tag, ap);
1159
+ va_end(ap);
1160
+ return (status);
1161
+ }
1162
+
1163
+ /*
1164
+ * Like TIFFGetField, but taking a varargs
1165
+ * parameter list. This routine is useful
1166
+ * for building higher-level interfaces on
1167
+ * top of the library.
1168
+ */
1169
+ int
1170
+ TIFFVGetField(TIFF* tif, uint32 tag, va_list ap)
1171
+ {
1172
+ const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
1173
+ return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit)) ?
1174
+ (*tif->tif_tagmethods.vgetfield)(tif, tag, ap) : 0);
1175
+ }
1176
+
1177
+ #define CleanupField(member) { \
1178
+ if (td->member) { \
1179
+ _TIFFfree(td->member); \
1180
+ td->member = 0; \
1181
+ } \
1182
+ }
1183
+
1184
+ /*
1185
+ * Release storage associated with a directory.
1186
+ */
1187
+ void
1188
+ TIFFFreeDirectory(TIFF* tif)
1189
+ {
1190
+ TIFFDirectory *td = &tif->tif_dir;
1191
+ int i;
1192
+
1193
+ _TIFFmemset(td->td_fieldsset, 0, FIELD_SETLONGS);
1194
+ CleanupField(td_sminsamplevalue);
1195
+ CleanupField(td_smaxsamplevalue);
1196
+ CleanupField(td_colormap[0]);
1197
+ CleanupField(td_colormap[1]);
1198
+ CleanupField(td_colormap[2]);
1199
+ CleanupField(td_sampleinfo);
1200
+ CleanupField(td_subifd);
1201
+ CleanupField(td_inknames);
1202
+ CleanupField(td_refblackwhite);
1203
+ CleanupField(td_transferfunction[0]);
1204
+ CleanupField(td_transferfunction[1]);
1205
+ CleanupField(td_transferfunction[2]);
1206
+ CleanupField(td_stripoffset);
1207
+ CleanupField(td_stripbytecount);
1208
+ TIFFClrFieldBit(tif, FIELD_YCBCRSUBSAMPLING);
1209
+ TIFFClrFieldBit(tif, FIELD_YCBCRPOSITIONING);
1210
+
1211
+ /* Cleanup custom tag values */
1212
+ for( i = 0; i < td->td_customValueCount; i++ ) {
1213
+ if (td->td_customValues[i].value)
1214
+ _TIFFfree(td->td_customValues[i].value);
1215
+ }
1216
+
1217
+ td->td_customValueCount = 0;
1218
+ CleanupField(td_customValues);
1219
+
1220
+ #if defined(DEFER_STRILE_LOAD)
1221
+ _TIFFmemset( &(td->td_stripoffset_entry), 0, sizeof(TIFFDirEntry));
1222
+ _TIFFmemset( &(td->td_stripbytecount_entry), 0, sizeof(TIFFDirEntry));
1223
+ #endif
1224
+ }
1225
+ #undef CleanupField
1226
+
1227
+ /*
1228
+ * Client Tag extension support (from Niles Ritter).
1229
+ */
1230
+ static TIFFExtendProc _TIFFextender = (TIFFExtendProc) NULL;
1231
+
1232
+ TIFFExtendProc
1233
+ TIFFSetTagExtender(TIFFExtendProc extender)
1234
+ {
1235
+ TIFFExtendProc prev = _TIFFextender;
1236
+ _TIFFextender = extender;
1237
+ return (prev);
1238
+ }
1239
+
1240
+ /*
1241
+ * Setup for a new directory. Should we automatically call
1242
+ * TIFFWriteDirectory() if the current one is dirty?
1243
+ *
1244
+ * The newly created directory will not exist on the file till
1245
+ * TIFFWriteDirectory(), TIFFFlush() or TIFFClose() is called.
1246
+ */
1247
+ int
1248
+ TIFFCreateDirectory(TIFF* tif)
1249
+ {
1250
+ TIFFDefaultDirectory(tif);
1251
+ tif->tif_diroff = 0;
1252
+ tif->tif_nextdiroff = 0;
1253
+ tif->tif_curoff = 0;
1254
+ tif->tif_row = (uint32) -1;
1255
+ tif->tif_curstrip = (uint32) -1;
1256
+
1257
+ return 0;
1258
+ }
1259
+
1260
+ int
1261
+ TIFFCreateCustomDirectory(TIFF* tif, const TIFFFieldArray* infoarray)
1262
+ {
1263
+ TIFFDefaultDirectory(tif);
1264
+
1265
+ /*
1266
+ * Reset the field definitions to match the application provided list.
1267
+ * Hopefully TIFFDefaultDirectory() won't have done anything irreversable
1268
+ * based on it's assumption this is an image directory.
1269
+ */
1270
+ _TIFFSetupFields(tif, infoarray);
1271
+
1272
+ tif->tif_diroff = 0;
1273
+ tif->tif_nextdiroff = 0;
1274
+ tif->tif_curoff = 0;
1275
+ tif->tif_row = (uint32) -1;
1276
+ tif->tif_curstrip = (uint32) -1;
1277
+
1278
+ return 0;
1279
+ }
1280
+
1281
+ int
1282
+ TIFFCreateEXIFDirectory(TIFF* tif)
1283
+ {
1284
+ const TIFFFieldArray* exifFieldArray;
1285
+ exifFieldArray = _TIFFGetExifFields();
1286
+ return TIFFCreateCustomDirectory(tif, exifFieldArray);
1287
+ }
1288
+
1289
+ /*
1290
+ * Setup a default directory structure.
1291
+ */
1292
+ int
1293
+ TIFFDefaultDirectory(TIFF* tif)
1294
+ {
1295
+ register TIFFDirectory* td = &tif->tif_dir;
1296
+ const TIFFFieldArray* tiffFieldArray;
1297
+
1298
+ tiffFieldArray = _TIFFGetFields();
1299
+ _TIFFSetupFields(tif, tiffFieldArray);
1300
+
1301
+ _TIFFmemset(td, 0, sizeof (*td));
1302
+ td->td_fillorder = FILLORDER_MSB2LSB;
1303
+ td->td_bitspersample = 1;
1304
+ td->td_threshholding = THRESHHOLD_BILEVEL;
1305
+ td->td_orientation = ORIENTATION_TOPLEFT;
1306
+ td->td_samplesperpixel = 1;
1307
+ td->td_rowsperstrip = (uint32) -1;
1308
+ td->td_tilewidth = 0;
1309
+ td->td_tilelength = 0;
1310
+ td->td_tiledepth = 1;
1311
+ td->td_stripbytecountsorted = 1; /* Our own arrays always sorted. */
1312
+ td->td_resolutionunit = RESUNIT_INCH;
1313
+ td->td_sampleformat = SAMPLEFORMAT_UINT;
1314
+ td->td_imagedepth = 1;
1315
+ td->td_ycbcrsubsampling[0] = 2;
1316
+ td->td_ycbcrsubsampling[1] = 2;
1317
+ td->td_ycbcrpositioning = YCBCRPOSITION_CENTERED;
1318
+ tif->tif_postdecode = _TIFFNoPostDecode;
1319
+ tif->tif_foundfield = NULL;
1320
+ tif->tif_tagmethods.vsetfield = _TIFFVSetField;
1321
+ tif->tif_tagmethods.vgetfield = _TIFFVGetField;
1322
+ tif->tif_tagmethods.printdir = NULL;
1323
+ /*
1324
+ * Give client code a chance to install their own
1325
+ * tag extensions & methods, prior to compression overloads,
1326
+ * but do some prior cleanup first. (http://trac.osgeo.org/gdal/ticket/5054)
1327
+ */
1328
+ if (tif->tif_nfieldscompat > 0) {
1329
+ uint32 i;
1330
+
1331
+ for (i = 0; i < tif->tif_nfieldscompat; i++) {
1332
+ if (tif->tif_fieldscompat[i].allocated_size)
1333
+ _TIFFfree(tif->tif_fieldscompat[i].fields);
1334
+ }
1335
+ _TIFFfree(tif->tif_fieldscompat);
1336
+ tif->tif_nfieldscompat = 0;
1337
+ tif->tif_fieldscompat = NULL;
1338
+ }
1339
+ if (_TIFFextender)
1340
+ (*_TIFFextender)(tif);
1341
+ (void) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
1342
+ /*
1343
+ * NB: The directory is marked dirty as a result of setting
1344
+ * up the default compression scheme. However, this really
1345
+ * isn't correct -- we want TIFF_DIRTYDIRECT to be set only
1346
+ * if the user does something. We could just do the setup
1347
+ * by hand, but it seems better to use the normal mechanism
1348
+ * (i.e. TIFFSetField).
1349
+ */
1350
+ tif->tif_flags &= ~TIFF_DIRTYDIRECT;
1351
+
1352
+ /*
1353
+ * As per http://bugzilla.remotesensing.org/show_bug.cgi?id=19
1354
+ * we clear the ISTILED flag when setting up a new directory.
1355
+ * Should we also be clearing stuff like INSUBIFD?
1356
+ */
1357
+ tif->tif_flags &= ~TIFF_ISTILED;
1358
+
1359
+ return (1);
1360
+ }
1361
+
1362
+ static int
1363
+ TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off)
1364
+ {
1365
+ static const char module[] = "TIFFAdvanceDirectory";
1366
+ if (isMapped(tif))
1367
+ {
1368
+ uint64 poff=*nextdir;
1369
+ if (!(tif->tif_flags&TIFF_BIGTIFF))
1370
+ {
1371
+ tmsize_t poffa,poffb,poffc,poffd;
1372
+ uint16 dircount;
1373
+ uint32 nextdir32;
1374
+ poffa=(tmsize_t)poff;
1375
+ poffb=poffa+sizeof(uint16);
1376
+ if (((uint64)poffa!=poff)||(poffb<poffa)||(poffb<(tmsize_t)sizeof(uint16))||(poffb>tif->tif_size))
1377
+ {
1378
+ TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory count");
1379
+ *nextdir=0;
1380
+ return(0);
1381
+ }
1382
+ _TIFFmemcpy(&dircount,tif->tif_base+poffa,sizeof(uint16));
1383
+ if (tif->tif_flags&TIFF_SWAB)
1384
+ TIFFSwabShort(&dircount);
1385
+ poffc=poffb+dircount*12;
1386
+ poffd=poffc+sizeof(uint32);
1387
+ if ((poffc<poffb)||(poffc<dircount*12)||(poffd<poffc)||(poffd<(tmsize_t)sizeof(uint32))||(poffd>tif->tif_size))
1388
+ {
1389
+ TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory link");
1390
+ return(0);
1391
+ }
1392
+ if (off!=NULL)
1393
+ *off=(uint64)poffc;
1394
+ _TIFFmemcpy(&nextdir32,tif->tif_base+poffc,sizeof(uint32));
1395
+ if (tif->tif_flags&TIFF_SWAB)
1396
+ TIFFSwabLong(&nextdir32);
1397
+ *nextdir=nextdir32;
1398
+ }
1399
+ else
1400
+ {
1401
+ tmsize_t poffa,poffb,poffc,poffd;
1402
+ uint64 dircount64;
1403
+ uint16 dircount16;
1404
+ poffa=(tmsize_t)poff;
1405
+ poffb=poffa+sizeof(uint64);
1406
+ if (((uint64)poffa!=poff)||(poffb<poffa)||(poffb<(tmsize_t)sizeof(uint64))||(poffb>tif->tif_size))
1407
+ {
1408
+ TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory count");
1409
+ return(0);
1410
+ }
1411
+ _TIFFmemcpy(&dircount64,tif->tif_base+poffa,sizeof(uint64));
1412
+ if (tif->tif_flags&TIFF_SWAB)
1413
+ TIFFSwabLong8(&dircount64);
1414
+ if (dircount64>0xFFFF)
1415
+ {
1416
+ TIFFErrorExt(tif->tif_clientdata,module,"Sanity check on directory count failed");
1417
+ return(0);
1418
+ }
1419
+ dircount16=(uint16)dircount64;
1420
+ poffc=poffb+dircount16*20;
1421
+ poffd=poffc+sizeof(uint64);
1422
+ if ((poffc<poffb)||(poffc<dircount16*20)||(poffd<poffc)||(poffd<(tmsize_t)sizeof(uint64))||(poffd>tif->tif_size))
1423
+ {
1424
+ TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory link");
1425
+ return(0);
1426
+ }
1427
+ if (off!=NULL)
1428
+ *off=(uint64)poffc;
1429
+ _TIFFmemcpy(nextdir,tif->tif_base+poffc,sizeof(uint64));
1430
+ if (tif->tif_flags&TIFF_SWAB)
1431
+ TIFFSwabLong8(nextdir);
1432
+ }
1433
+ return(1);
1434
+ }
1435
+ else
1436
+ {
1437
+ if (!(tif->tif_flags&TIFF_BIGTIFF))
1438
+ {
1439
+ uint16 dircount;
1440
+ uint32 nextdir32;
1441
+ if (!SeekOK(tif, *nextdir) ||
1442
+ !ReadOK(tif, &dircount, sizeof (uint16))) {
1443
+ TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count",
1444
+ tif->tif_name);
1445
+ return (0);
1446
+ }
1447
+ if (tif->tif_flags & TIFF_SWAB)
1448
+ TIFFSwabShort(&dircount);
1449
+ if (off != NULL)
1450
+ *off = TIFFSeekFile(tif,
1451
+ dircount*12, SEEK_CUR);
1452
+ else
1453
+ (void) TIFFSeekFile(tif,
1454
+ dircount*12, SEEK_CUR);
1455
+ if (!ReadOK(tif, &nextdir32, sizeof (uint32))) {
1456
+ TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link",
1457
+ tif->tif_name);
1458
+ return (0);
1459
+ }
1460
+ if (tif->tif_flags & TIFF_SWAB)
1461
+ TIFFSwabLong(&nextdir32);
1462
+ *nextdir=nextdir32;
1463
+ }
1464
+ else
1465
+ {
1466
+ uint64 dircount64;
1467
+ uint16 dircount16;
1468
+ if (!SeekOK(tif, *nextdir) ||
1469
+ !ReadOK(tif, &dircount64, sizeof (uint64))) {
1470
+ TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count",
1471
+ tif->tif_name);
1472
+ return (0);
1473
+ }
1474
+ if (tif->tif_flags & TIFF_SWAB)
1475
+ TIFFSwabLong8(&dircount64);
1476
+ if (dircount64>0xFFFF)
1477
+ {
1478
+ TIFFErrorExt(tif->tif_clientdata, module, "Error fetching directory count");
1479
+ return(0);
1480
+ }
1481
+ dircount16 = (uint16)dircount64;
1482
+ if (off != NULL)
1483
+ *off = TIFFSeekFile(tif,
1484
+ dircount16*20, SEEK_CUR);
1485
+ else
1486
+ (void) TIFFSeekFile(tif,
1487
+ dircount16*20, SEEK_CUR);
1488
+ if (!ReadOK(tif, nextdir, sizeof (uint64))) {
1489
+ TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link",
1490
+ tif->tif_name);
1491
+ return (0);
1492
+ }
1493
+ if (tif->tif_flags & TIFF_SWAB)
1494
+ TIFFSwabLong8(nextdir);
1495
+ }
1496
+ return (1);
1497
+ }
1498
+ }
1499
+
1500
+ /*
1501
+ * Count the number of directories in a file.
1502
+ */
1503
+ uint16
1504
+ TIFFNumberOfDirectories(TIFF* tif)
1505
+ {
1506
+ static const char module[] = "TIFFNumberOfDirectories";
1507
+ uint64 nextdir;
1508
+ uint16 n;
1509
+ if (!(tif->tif_flags&TIFF_BIGTIFF))
1510
+ nextdir = tif->tif_header.classic.tiff_diroff;
1511
+ else
1512
+ nextdir = tif->tif_header.big.tiff_diroff;
1513
+ n = 0;
1514
+ while (nextdir != 0 && TIFFAdvanceDirectory(tif, &nextdir, NULL))
1515
+ {
1516
+ if(++n == 0)
1517
+ {
1518
+ TIFFErrorExt(tif->tif_clientdata, module,
1519
+ "Directory count exceeded 65535 limit, giving up on counting.");
1520
+ return (65535);
1521
+ }
1522
+ }
1523
+ return (n);
1524
+ }
1525
+
1526
+ /*
1527
+ * Set the n-th directory as the current directory.
1528
+ * NB: Directories are numbered starting at 0.
1529
+ */
1530
+ int
1531
+ TIFFSetDirectory(TIFF* tif, uint16 dirn)
1532
+ {
1533
+ uint64 nextdir;
1534
+ uint16 n;
1535
+
1536
+ if (!(tif->tif_flags&TIFF_BIGTIFF))
1537
+ nextdir = tif->tif_header.classic.tiff_diroff;
1538
+ else
1539
+ nextdir = tif->tif_header.big.tiff_diroff;
1540
+ for (n = dirn; n > 0 && nextdir != 0; n--)
1541
+ if (!TIFFAdvanceDirectory(tif, &nextdir, NULL))
1542
+ return (0);
1543
+ tif->tif_nextdiroff = nextdir;
1544
+ /*
1545
+ * Set curdir to the actual directory index. The
1546
+ * -1 is because TIFFReadDirectory will increment
1547
+ * tif_curdir after successfully reading the directory.
1548
+ */
1549
+ tif->tif_curdir = (dirn - n) - 1;
1550
+ /*
1551
+ * Reset tif_dirnumber counter and start new list of seen directories.
1552
+ * We need this to prevent IFD loops.
1553
+ */
1554
+ tif->tif_dirnumber = 0;
1555
+ return (TIFFReadDirectory(tif));
1556
+ }
1557
+
1558
+ /*
1559
+ * Set the current directory to be the directory
1560
+ * located at the specified file offset. This interface
1561
+ * is used mainly to access directories linked with
1562
+ * the SubIFD tag (e.g. thumbnail images).
1563
+ */
1564
+ int
1565
+ TIFFSetSubDirectory(TIFF* tif, uint64 diroff)
1566
+ {
1567
+ tif->tif_nextdiroff = diroff;
1568
+ /*
1569
+ * Reset tif_dirnumber counter and start new list of seen directories.
1570
+ * We need this to prevent IFD loops.
1571
+ */
1572
+ tif->tif_dirnumber = 0;
1573
+ return (TIFFReadDirectory(tif));
1574
+ }
1575
+
1576
+ /*
1577
+ * Return file offset of the current directory.
1578
+ */
1579
+ uint64
1580
+ TIFFCurrentDirOffset(TIFF* tif)
1581
+ {
1582
+ return (tif->tif_diroff);
1583
+ }
1584
+
1585
+ /*
1586
+ * Return an indication of whether or not we are
1587
+ * at the last directory in the file.
1588
+ */
1589
+ int
1590
+ TIFFLastDirectory(TIFF* tif)
1591
+ {
1592
+ return (tif->tif_nextdiroff == 0);
1593
+ }
1594
+
1595
+ /*
1596
+ * Unlink the specified directory from the directory chain.
1597
+ */
1598
+ int
1599
+ TIFFUnlinkDirectory(TIFF* tif, uint16 dirn)
1600
+ {
1601
+ static const char module[] = "TIFFUnlinkDirectory";
1602
+ uint64 nextdir;
1603
+ uint64 off;
1604
+ uint16 n;
1605
+
1606
+ if (tif->tif_mode == O_RDONLY) {
1607
+ TIFFErrorExt(tif->tif_clientdata, module,
1608
+ "Can not unlink directory in read-only file");
1609
+ return (0);
1610
+ }
1611
+ /*
1612
+ * Go to the directory before the one we want
1613
+ * to unlink and nab the offset of the link
1614
+ * field we'll need to patch.
1615
+ */
1616
+ if (!(tif->tif_flags&TIFF_BIGTIFF))
1617
+ {
1618
+ nextdir = tif->tif_header.classic.tiff_diroff;
1619
+ off = 4;
1620
+ }
1621
+ else
1622
+ {
1623
+ nextdir = tif->tif_header.big.tiff_diroff;
1624
+ off = 8;
1625
+ }
1626
+ for (n = dirn-1; n > 0; n--) {
1627
+ if (nextdir == 0) {
1628
+ TIFFErrorExt(tif->tif_clientdata, module, "Directory %d does not exist", dirn);
1629
+ return (0);
1630
+ }
1631
+ if (!TIFFAdvanceDirectory(tif, &nextdir, &off))
1632
+ return (0);
1633
+ }
1634
+ /*
1635
+ * Advance to the directory to be unlinked and fetch
1636
+ * the offset of the directory that follows.
1637
+ */
1638
+ if (!TIFFAdvanceDirectory(tif, &nextdir, NULL))
1639
+ return (0);
1640
+ /*
1641
+ * Go back and patch the link field of the preceding
1642
+ * directory to point to the offset of the directory
1643
+ * that follows.
1644
+ */
1645
+ (void) TIFFSeekFile(tif, off, SEEK_SET);
1646
+ if (!(tif->tif_flags&TIFF_BIGTIFF))
1647
+ {
1648
+ uint32 nextdir32;
1649
+ nextdir32=(uint32)nextdir;
1650
+ assert((uint64)nextdir32==nextdir);
1651
+ if (tif->tif_flags & TIFF_SWAB)
1652
+ TIFFSwabLong(&nextdir32);
1653
+ if (!WriteOK(tif, &nextdir32, sizeof (uint32))) {
1654
+ TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link");
1655
+ return (0);
1656
+ }
1657
+ }
1658
+ else
1659
+ {
1660
+ if (tif->tif_flags & TIFF_SWAB)
1661
+ TIFFSwabLong8(&nextdir);
1662
+ if (!WriteOK(tif, &nextdir, sizeof (uint64))) {
1663
+ TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link");
1664
+ return (0);
1665
+ }
1666
+ }
1667
+ /*
1668
+ * Leave directory state setup safely. We don't have
1669
+ * facilities for doing inserting and removing directories,
1670
+ * so it's safest to just invalidate everything. This
1671
+ * means that the caller can only append to the directory
1672
+ * chain.
1673
+ */
1674
+ (*tif->tif_cleanup)(tif);
1675
+ if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) {
1676
+ _TIFFfree(tif->tif_rawdata);
1677
+ tif->tif_rawdata = NULL;
1678
+ tif->tif_rawcc = 0;
1679
+ tif->tif_rawdataoff = 0;
1680
+ tif->tif_rawdataloaded = 0;
1681
+ }
1682
+ tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP|TIFF_POSTENCODE|TIFF_BUF4WRITE);
1683
+ TIFFFreeDirectory(tif);
1684
+ TIFFDefaultDirectory(tif);
1685
+ tif->tif_diroff = 0; /* force link on next write */
1686
+ tif->tif_nextdiroff = 0; /* next write must be at end */
1687
+ tif->tif_curoff = 0;
1688
+ tif->tif_row = (uint32) -1;
1689
+ tif->tif_curstrip = (uint32) -1;
1690
+ return (1);
1691
+ }
1692
+
1693
+ /* vim: set ts=8 sts=8 sw=8 noet: */
1694
+ /*
1695
+ * Local Variables:
1696
+ * mode: c
1697
+ * c-basic-offset: 8
1698
+ * fill-column: 78
1699
+ * End:
1700
+ */