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,4533 @@
1
+ /* -*- C++ -*-
2
+ * File: libraw_cxx.cpp
3
+ * Copyright 2008-2013 LibRaw LLC (info@libraw.org)
4
+ * Created: Sat Mar 8 , 2008
5
+ *
6
+ * LibRaw C++ interface (implementation)
7
+
8
+ LibRaw is free software; you can redistribute it and/or modify
9
+ it under the terms of the one of three licenses as you choose:
10
+
11
+ 1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
12
+ (See file LICENSE.LGPL provided in LibRaw distribution archive for details).
13
+
14
+ 2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
15
+ (See file LICENSE.CDDL provided in LibRaw distribution archive for details).
16
+
17
+ 3. LibRaw Software License 27032010
18
+ (See file LICENSE.LibRaw.pdf provided in LibRaw distribution archive for details).
19
+
20
+ */
21
+
22
+ #include <math.h>
23
+ #include <errno.h>
24
+ #include <float.h>
25
+ #include <new>
26
+ #include <exception>
27
+ #include <sys/types.h>
28
+ #include <sys/stat.h>
29
+ #ifndef WIN32
30
+ #include <netinet/in.h>
31
+ #else
32
+ #include <winsock2.h>
33
+ #endif
34
+ #define LIBRAW_LIBRARY_BUILD
35
+ #include "libraw/libraw.h"
36
+ #include "internal/defines.h"
37
+
38
+
39
+ #if defined(_WIN32)
40
+ #if defined _MSC_VER
41
+ typedef signed __int8 int8_t;
42
+ typedef unsigned __int8 uint8_t;
43
+ typedef signed __int16 int16_t;
44
+ typedef unsigned __int16 uint16_t;
45
+ typedef signed __int32 int32_t;
46
+ typedef unsigned __int32 uint32_t;
47
+ typedef signed __int64 int64_t;
48
+ typedef unsigned __int64 uint64_t;
49
+ #else
50
+ #include <stdint.h>
51
+ #endif // _WIN32
52
+ #include <sys/types.h>
53
+ #else
54
+ #include <inttypes.h>
55
+ #endif
56
+
57
+
58
+ #ifdef USE_RAWSPEED
59
+ #include "../RawSpeed/rawspeed_xmldata.cpp"
60
+ #include <RawSpeed/StdAfx.h>
61
+ #include <RawSpeed/FileMap.h>
62
+ #include <RawSpeed/RawParser.h>
63
+ #include <RawSpeed/RawDecoder.h>
64
+ #include <RawSpeed/CameraMetaData.h>
65
+ #include <RawSpeed/ColorFilterArray.h>
66
+ #endif
67
+
68
+
69
+ #ifdef __cplusplus
70
+ extern "C"
71
+ {
72
+ #endif
73
+ void default_memory_callback(void *,const char *file,const char *where)
74
+ {
75
+ fprintf (stderr,"%s: Out of memory in %s\n", file?file:"unknown file", where);
76
+ }
77
+
78
+ void default_data_callback(void*,const char *file, const int offset)
79
+ {
80
+ if(offset < 0)
81
+ fprintf (stderr,"%s: Unexpected end of file\n", file?file:"unknown file");
82
+ else
83
+ fprintf (stderr,"%s: data corrupted at %d\n",file?file:"unknown file",offset);
84
+ }
85
+ const char *libraw_strerror(int e)
86
+ {
87
+ enum LibRaw_errors errorcode = (LibRaw_errors)e;
88
+ switch(errorcode)
89
+ {
90
+ case LIBRAW_SUCCESS:
91
+ return "No error";
92
+ case LIBRAW_UNSPECIFIED_ERROR:
93
+ return "Unspecified error";
94
+ case LIBRAW_FILE_UNSUPPORTED:
95
+ return "Unsupported file format or not RAW file";
96
+ case LIBRAW_REQUEST_FOR_NONEXISTENT_IMAGE:
97
+ return "Request for nonexisting image number";
98
+ case LIBRAW_OUT_OF_ORDER_CALL:
99
+ return "Out of order call of libraw function";
100
+ case LIBRAW_NO_THUMBNAIL:
101
+ return "No thumbnail in file";
102
+ case LIBRAW_UNSUPPORTED_THUMBNAIL:
103
+ return "Unsupported thumbnail format";
104
+ case LIBRAW_INPUT_CLOSED:
105
+ return "No input stream, or input stream closed";
106
+ case LIBRAW_UNSUFFICIENT_MEMORY:
107
+ return "Unsufficient memory";
108
+ case LIBRAW_DATA_ERROR:
109
+ return "Corrupted data or unexpected EOF";
110
+ case LIBRAW_IO_ERROR:
111
+ return "Input/output error";
112
+ case LIBRAW_CANCELLED_BY_CALLBACK:
113
+ return "Cancelled by user callback";
114
+ case LIBRAW_BAD_CROP:
115
+ return "Bad crop box";
116
+ default:
117
+ return "Unknown error code";
118
+ }
119
+ }
120
+
121
+ #ifdef __cplusplus
122
+ }
123
+ #endif
124
+
125
+ #define Sigma_X3F 22
126
+
127
+ const double LibRaw_constants::xyz_rgb[3][3] =
128
+ {
129
+ { 0.412453, 0.357580, 0.180423 },
130
+ { 0.212671, 0.715160, 0.072169 },
131
+ { 0.019334, 0.119193, 0.950227 }
132
+ };
133
+
134
+ const float LibRaw_constants::d65_white[3] = { 0.950456f, 1.0f, 1.088754f };
135
+
136
+ #define P1 imgdata.idata
137
+ #define S imgdata.sizes
138
+ #define O imgdata.params
139
+ #define C imgdata.color
140
+ #define T imgdata.thumbnail
141
+ #define IO libraw_internal_data.internal_output_params
142
+ #define ID libraw_internal_data.internal_data
143
+
144
+ #define EXCEPTION_HANDLER(e) do{ \
145
+ /* fprintf(stderr,"Exception %d caught\n",e);*/ \
146
+ switch(e) \
147
+ { \
148
+ case LIBRAW_EXCEPTION_ALLOC: \
149
+ recycle(); \
150
+ return LIBRAW_UNSUFFICIENT_MEMORY; \
151
+ case LIBRAW_EXCEPTION_DECODE_RAW: \
152
+ case LIBRAW_EXCEPTION_DECODE_JPEG: \
153
+ recycle(); \
154
+ return LIBRAW_DATA_ERROR; \
155
+ case LIBRAW_EXCEPTION_DECODE_JPEG2000: \
156
+ recycle(); \
157
+ return LIBRAW_DATA_ERROR; \
158
+ case LIBRAW_EXCEPTION_IO_EOF: \
159
+ case LIBRAW_EXCEPTION_IO_CORRUPT: \
160
+ recycle(); \
161
+ return LIBRAW_IO_ERROR; \
162
+ case LIBRAW_EXCEPTION_CANCELLED_BY_CALLBACK: \
163
+ recycle(); \
164
+ return LIBRAW_CANCELLED_BY_CALLBACK; \
165
+ case LIBRAW_EXCEPTION_BAD_CROP: \
166
+ recycle(); \
167
+ return LIBRAW_BAD_CROP; \
168
+ default: \
169
+ return LIBRAW_UNSPECIFIED_ERROR; \
170
+ } \
171
+ }while(0)
172
+
173
+ const char* LibRaw::version() { return LIBRAW_VERSION_STR;}
174
+ int LibRaw::versionNumber() { return LIBRAW_VERSION; }
175
+ const char* LibRaw::strerror(int p) { return libraw_strerror(p);}
176
+
177
+ LibRaw_colormatrix_type LibRaw::camera_color_type()
178
+ {
179
+ if(C.cmatrix[0][0] <= 0.125) return LIBRAW_CMATRIX_NONE;
180
+ if(P1.dng_version) return LIBRAW_CMATRIX_DNG;
181
+ if(C.digitalBack_color) return LIBRAW_CMATRIX_DIGBACK;
182
+ return LIBRAW_CMATRIX_OTHER;
183
+
184
+ }
185
+
186
+ void LibRaw::derror()
187
+ {
188
+ if (!libraw_internal_data.unpacker_data.data_error && libraw_internal_data.internal_data.input)
189
+ {
190
+ if (libraw_internal_data.internal_data.input->eof())
191
+ {
192
+ if(callbacks.data_cb)(*callbacks.data_cb)(callbacks.datacb_data,
193
+ libraw_internal_data.internal_data.input->fname(),-1);
194
+ throw LIBRAW_EXCEPTION_IO_EOF;
195
+ }
196
+ else
197
+ {
198
+ if(callbacks.data_cb)(*callbacks.data_cb)(callbacks.datacb_data,
199
+ libraw_internal_data.internal_data.input->fname(),
200
+ libraw_internal_data.internal_data.input->tell());
201
+ //throw LIBRAW_EXCEPTION_IO_CORRUPT;
202
+ }
203
+ }
204
+ libraw_internal_data.unpacker_data.data_error++;
205
+ }
206
+
207
+ void LibRaw::dcraw_clear_mem(libraw_processed_image_t* p)
208
+ {
209
+ if(p) ::free(p);
210
+ }
211
+
212
+ int LibRaw::is_sraw() { return load_raw == &LibRaw::canon_sraw_load_raw || load_raw == &LibRaw::nikon_load_sraw ; }
213
+ int LibRaw::is_coolscan_nef() { return load_raw == &LibRaw::nikon_coolscan_load_raw;}
214
+
215
+ int LibRaw::is_nikon_sraw(){
216
+ return load_raw == &LibRaw::nikon_load_sraw;
217
+ }
218
+ int LibRaw::sraw_midpoint() {
219
+ if (load_raw == &LibRaw::canon_sraw_load_raw) return 8192;
220
+ else if (load_raw == &LibRaw::nikon_load_sraw) return 2048;
221
+ else return 0;
222
+ }
223
+
224
+
225
+ #ifdef USE_RAWSPEED
226
+ using namespace RawSpeed;
227
+ class CameraMetaDataLR : public CameraMetaData
228
+ {
229
+ public:
230
+ CameraMetaDataLR() : CameraMetaData() {}
231
+ CameraMetaDataLR(char *filename) : CameraMetaData(filename){}
232
+ CameraMetaDataLR(char *data, int sz);
233
+ };
234
+
235
+ CameraMetaDataLR::CameraMetaDataLR(char *data, int sz) : CameraMetaData() {
236
+ ctxt = xmlNewParserCtxt();
237
+ if (ctxt == NULL) {
238
+ ThrowCME("CameraMetaData:Could not initialize context.");
239
+ }
240
+
241
+ xmlResetLastError();
242
+ doc = xmlCtxtReadMemory(ctxt, data,sz, "", NULL, XML_PARSE_DTDVALID);
243
+
244
+ if (doc == NULL) {
245
+ ThrowCME("CameraMetaData: XML Document could not be parsed successfully. Error was: %s", ctxt->lastError.message);
246
+ }
247
+
248
+ if (ctxt->valid == 0) {
249
+ if (ctxt->lastError.code == 0x5e) {
250
+ // printf("CameraMetaData: Unable to locate DTD, attempting to ignore.");
251
+ } else {
252
+ ThrowCME("CameraMetaData: XML file does not validate. DTD Error was: %s", ctxt->lastError.message);
253
+ }
254
+ }
255
+
256
+ xmlNodePtr cur;
257
+ cur = xmlDocGetRootElement(doc);
258
+ if (xmlStrcmp(cur->name, (const xmlChar *) "Cameras")) {
259
+ ThrowCME("CameraMetaData: XML document of the wrong type, root node is not cameras.");
260
+ return;
261
+ }
262
+
263
+ cur = cur->xmlChildrenNode;
264
+ while (cur != NULL) {
265
+ if ((!xmlStrcmp(cur->name, (const xmlChar *)"Camera"))) {
266
+ Camera *camera = new Camera(doc, cur);
267
+ addCamera(camera);
268
+
269
+ // Create cameras for aliases.
270
+ for (unsigned int i = 0; i < camera->aliases.size(); i++) {
271
+ addCamera(new Camera(camera, i));
272
+ }
273
+ }
274
+ cur = cur->next;
275
+ }
276
+ if (doc)
277
+ xmlFreeDoc(doc);
278
+ doc = 0;
279
+ if (ctxt)
280
+ xmlFreeParserCtxt(ctxt);
281
+ ctxt = 0;
282
+ }
283
+
284
+ #define RAWSPEED_DATA_COUNT (sizeof(_rawspeed_data_xml)/sizeof(_rawspeed_data_xml[0]))
285
+ static CameraMetaDataLR* make_camera_metadata()
286
+ {
287
+ int len = 0,i;
288
+ for(i=0;i<RAWSPEED_DATA_COUNT;i++)
289
+ if(_rawspeed_data_xml[i])
290
+ {
291
+ len+=strlen(_rawspeed_data_xml[i]);
292
+ }
293
+ char *rawspeed_xml = (char*)calloc(len+1,sizeof(_rawspeed_data_xml[0][0]));
294
+ if(!rawspeed_xml) return NULL;
295
+ int offt = 0;
296
+ for(i=0;i<RAWSPEED_DATA_COUNT;i++)
297
+ if(_rawspeed_data_xml[i])
298
+ {
299
+ int ll = strlen(_rawspeed_data_xml[i]);
300
+ if(offt+ll>len) break;
301
+ memmove(rawspeed_xml+offt,_rawspeed_data_xml[i],ll);
302
+ offt+=ll;
303
+ }
304
+ rawspeed_xml[offt]=0;
305
+ CameraMetaDataLR *ret=NULL;
306
+ try {
307
+ ret = new CameraMetaDataLR(rawspeed_xml,offt);
308
+ } catch (...) {
309
+ // Mask all exceptions
310
+ }
311
+ free(rawspeed_xml);
312
+ return ret;
313
+ }
314
+
315
+ #endif
316
+
317
+ #define ZERO(a) memset(&a,0,sizeof(a))
318
+
319
+ static void cleargps(libraw_gps_info_t*q)
320
+ {
321
+ for (int i = 0; i < 3; i++)
322
+ q->latitude[i] = q->longtitude[i] = q->gpstimestamp[i] = 0.f;
323
+ q->altitude = 0.f;
324
+ q->altref = q->latref = q->longref = q->gpsstatus = q->gpsparsed = 0;
325
+ }
326
+
327
+ LibRaw:: LibRaw(unsigned int flags)
328
+ {
329
+ double aber[4] = {1,1,1,1};
330
+ double gamm[6] = { 0.45,4.5,0,0,0,0 };
331
+ unsigned greybox[4] = { 0, 0, UINT_MAX, UINT_MAX };
332
+ unsigned cropbox[4] = { 0, 0, UINT_MAX, UINT_MAX };
333
+ #ifdef DCRAW_VERBOSE
334
+ verbose = 1;
335
+ #else
336
+ verbose = 0;
337
+ #endif
338
+ ZERO(imgdata);
339
+ imgdata.lens.makernotes.CanonFocalUnits = 1;
340
+ imgdata.lens.makernotes.LensID = 0xffffffffffffffffULL;
341
+
342
+ cleargps(&imgdata.other.parsed_gps);
343
+ ZERO(libraw_internal_data);
344
+ ZERO(callbacks);
345
+
346
+ _rawspeed_camerameta = _rawspeed_decoder = NULL;
347
+ _x3f_data = NULL;
348
+
349
+ #ifdef USE_RAWSPEED
350
+ CameraMetaDataLR *camerameta = make_camera_metadata(); // May be NULL in case of exception in make_camera_metadata()
351
+ _rawspeed_camerameta = static_cast<void*>(camerameta);
352
+ #endif
353
+ callbacks.mem_cb = (flags & LIBRAW_OPIONS_NO_MEMERR_CALLBACK) ? NULL: &default_memory_callback;
354
+ callbacks.data_cb = (flags & LIBRAW_OPIONS_NO_DATAERR_CALLBACK)? NULL : &default_data_callback;
355
+ callbacks.exif_cb = NULL; // no default callback
356
+ memmove(&imgdata.params.aber,&aber,sizeof(aber));
357
+ memmove(&imgdata.params.gamm,&gamm,sizeof(gamm));
358
+ memmove(&imgdata.params.greybox,&greybox,sizeof(greybox));
359
+ memmove(&imgdata.params.cropbox,&cropbox,sizeof(cropbox));
360
+
361
+ imgdata.params.bright=1;
362
+ imgdata.params.use_camera_matrix=1;
363
+ imgdata.params.user_flip=-1;
364
+ imgdata.params.user_black=-1;
365
+ imgdata.params.user_cblack[0]=imgdata.params.user_cblack[1]=imgdata.params.user_cblack[2]=imgdata.params.user_cblack[3]=-1000001;
366
+ imgdata.params.user_sat=-1;
367
+ imgdata.params.user_qual=-1;
368
+ imgdata.params.output_color=1;
369
+ imgdata.params.output_bps=8;
370
+ imgdata.params.use_fuji_rotate=1;
371
+ imgdata.params.exp_shift = 1.0;
372
+ imgdata.params.auto_bright_thr = LIBRAW_DEFAULT_AUTO_BRIGHTNESS_THRESHOLD;
373
+ imgdata.params.adjust_maximum_thr= LIBRAW_DEFAULT_ADJUST_MAXIMUM_THRESHOLD;
374
+ imgdata.params.use_rawspeed = 1;
375
+ imgdata.params.no_auto_scale = 0;
376
+ imgdata.params.no_interpolation = 0;
377
+ imgdata.params.sraw_ycc = 0;
378
+ imgdata.params.force_foveon_x3f = 0;
379
+ imgdata.params.x3f_flags = LIBRAW_DP2Q_INTERPOLATERG|LIBRAW_DP2Q_INTERPOLATEAF;
380
+ imgdata.params.sony_arw2_options = 0;
381
+ imgdata.params.sony_arw2_posterization_thr = 0;
382
+ imgdata.params.green_matching = 0;
383
+ imgdata.params.coolscan_nef_gamma = 1.0f;
384
+ imgdata.parent_class = this;
385
+ imgdata.progress_flags = 0;
386
+ imgdata.color.baseline_exposure = -999.f;
387
+ _exitflag = 0;
388
+ tls = new LibRaw_TLS;
389
+ tls->init();
390
+ }
391
+
392
+ int LibRaw::set_rawspeed_camerafile(char *filename)
393
+ {
394
+ #ifdef USE_RAWSPEED
395
+ try
396
+ {
397
+ CameraMetaDataLR *camerameta = new CameraMetaDataLR(filename);
398
+ if(_rawspeed_camerameta)
399
+ {
400
+ CameraMetaDataLR *d = static_cast<CameraMetaDataLR*>(_rawspeed_camerameta);
401
+ delete d;
402
+ }
403
+ _rawspeed_camerameta = static_cast<void*>(camerameta);
404
+ }
405
+ catch (...)
406
+ {
407
+ //just return error code
408
+ return -1;
409
+ }
410
+ #endif
411
+ return 0;
412
+ }
413
+
414
+ LibRaw::~LibRaw()
415
+ {
416
+ recycle();
417
+ delete tls;
418
+ #ifdef USE_RAWSPEED
419
+ if(_rawspeed_camerameta)
420
+ {
421
+ CameraMetaDataLR *cmeta = static_cast<CameraMetaDataLR*>(_rawspeed_camerameta);
422
+ delete cmeta;
423
+ _rawspeed_camerameta = NULL;
424
+ }
425
+ #endif
426
+ }
427
+
428
+ void* LibRaw:: malloc(size_t t)
429
+ {
430
+ void *p = memmgr.malloc(t);
431
+ if(!p)
432
+ throw LIBRAW_EXCEPTION_ALLOC;
433
+ return p;
434
+ }
435
+ void* LibRaw:: realloc(void *q,size_t t)
436
+ {
437
+ void *p = memmgr.realloc(q,t);
438
+ if(!p)
439
+ throw LIBRAW_EXCEPTION_ALLOC;
440
+ return p;
441
+ }
442
+
443
+
444
+ void* LibRaw:: calloc(size_t n,size_t t)
445
+ {
446
+ void *p = memmgr.calloc(n,t);
447
+ if(!p)
448
+ throw LIBRAW_EXCEPTION_ALLOC;
449
+ return p;
450
+ }
451
+ void LibRaw:: free(void *p)
452
+ {
453
+ memmgr.free(p);
454
+ }
455
+
456
+ void LibRaw:: recycle_datastream()
457
+ {
458
+ if(libraw_internal_data.internal_data.input && libraw_internal_data.internal_data.input_internal)
459
+ {
460
+ delete libraw_internal_data.internal_data.input;
461
+ libraw_internal_data.internal_data.input = NULL;
462
+ }
463
+ libraw_internal_data.internal_data.input_internal = 0;
464
+ }
465
+
466
+ void x3f_clear(void*);
467
+
468
+
469
+ void LibRaw:: recycle()
470
+ {
471
+ recycle_datastream();
472
+ #define FREE(a) do { if(a) { free(a); a = NULL;} }while(0)
473
+
474
+ FREE(imgdata.image);
475
+ FREE(imgdata.thumbnail.thumb);
476
+ FREE(libraw_internal_data.internal_data.meta_data);
477
+ FREE(libraw_internal_data.output_data.histogram);
478
+ FREE(libraw_internal_data.output_data.oprof);
479
+ FREE(imgdata.color.profile);
480
+ FREE(imgdata.rawdata.ph1_cblack);
481
+ FREE(imgdata.rawdata.ph1_rblack);
482
+ FREE(imgdata.rawdata.raw_alloc);
483
+ FREE(imgdata.idata.xmpdata);
484
+ #undef FREE
485
+ ZERO(imgdata.rawdata);
486
+ ZERO(imgdata.sizes);
487
+ ZERO(imgdata.color);
488
+ cleargps(&imgdata.other.parsed_gps);
489
+ imgdata.color.baseline_exposure = -999.f;
490
+ ZERO(libraw_internal_data);
491
+ ZERO(imgdata.lens);
492
+ imgdata.lens.makernotes.CanonFocalUnits = 1;
493
+ imgdata.lens.makernotes.LensID = 0xffffffffffffffffULL;
494
+
495
+ _exitflag = 0;
496
+ #ifdef USE_RAWSPEED
497
+ if(_rawspeed_decoder)
498
+ {
499
+ RawDecoder *d = static_cast<RawDecoder*>(_rawspeed_decoder);
500
+ delete d;
501
+ }
502
+ _rawspeed_decoder = 0;
503
+ #endif
504
+ if(_x3f_data)
505
+ {
506
+ x3f_clear(_x3f_data);
507
+ _x3f_data = 0;
508
+ }
509
+
510
+ memmgr.cleanup();
511
+ imgdata.thumbnail.tformat = LIBRAW_THUMBNAIL_UNKNOWN;
512
+ imgdata.progress_flags = 0;
513
+
514
+ tls->init();
515
+ }
516
+
517
+ const char * LibRaw::unpack_function_name()
518
+ {
519
+ libraw_decoder_info_t decoder_info;
520
+ get_decoder_info(&decoder_info);
521
+ return decoder_info.decoder_name;
522
+ }
523
+
524
+ int LibRaw::get_decoder_info(libraw_decoder_info_t* d_info)
525
+ {
526
+ if(!d_info) return LIBRAW_UNSPECIFIED_ERROR;
527
+ if(!load_raw) return LIBRAW_OUT_OF_ORDER_CALL;
528
+
529
+ d_info->decoder_flags = 0;
530
+ int rawdata = (imgdata.idata.filters || P1.colors == 1);
531
+ // dcraw.c names order
532
+ if (load_raw == &LibRaw::android_tight_load_raw)
533
+ {
534
+ d_info->decoder_name = "android_tight_load_raw()";
535
+ }
536
+ else if (load_raw == &LibRaw::android_loose_load_raw)
537
+ {
538
+ d_info->decoder_name = "android_loose_load_raw()";
539
+ }
540
+ else if (load_raw == &LibRaw::canon_600_load_raw)
541
+ {
542
+ d_info->decoder_name = "canon_600_load_raw()";
543
+ }
544
+ else if (load_raw == &LibRaw::canon_load_raw)
545
+ {
546
+ d_info->decoder_name = "canon_load_raw()";
547
+ }
548
+ else if (load_raw == &LibRaw::lossless_jpeg_load_raw)
549
+ {
550
+ // Check rbayer
551
+ d_info->decoder_name = "lossless_jpeg_load_raw()";
552
+ d_info->decoder_flags = LIBRAW_DECODER_HASCURVE | LIBRAW_DECODER_TRYRAWSPEED;
553
+ }
554
+ else if (load_raw == &LibRaw::canon_sraw_load_raw)
555
+ {
556
+ d_info->decoder_name = "canon_sraw_load_raw()";
557
+ d_info->decoder_flags = LIBRAW_DECODER_TRYRAWSPEED;
558
+ }
559
+ else if (load_raw == &LibRaw::lossless_dng_load_raw)
560
+ {
561
+ // Check rbayer
562
+ d_info->decoder_name = "lossless_dng_load_raw()";
563
+ d_info->decoder_flags = LIBRAW_DECODER_HASCURVE | LIBRAW_DECODER_TRYRAWSPEED;
564
+ }
565
+ else if (load_raw == &LibRaw::packed_dng_load_raw)
566
+ {
567
+ // Check rbayer
568
+ d_info->decoder_name = "packed_dng_load_raw()";
569
+ d_info->decoder_flags = LIBRAW_DECODER_HASCURVE | LIBRAW_DECODER_TRYRAWSPEED;
570
+ }
571
+ else if (load_raw == &LibRaw::pentax_load_raw )
572
+ {
573
+ d_info->decoder_name = "pentax_load_raw()";
574
+ d_info->decoder_flags = LIBRAW_DECODER_TRYRAWSPEED;
575
+ }
576
+ else if (load_raw == &LibRaw::nikon_load_raw)
577
+ {
578
+ // Check rbayer
579
+ d_info->decoder_name = "nikon_load_raw()";
580
+ d_info->decoder_flags = LIBRAW_DECODER_TRYRAWSPEED;
581
+ }
582
+ else if (load_raw == &LibRaw::nikon_coolscan_load_raw )
583
+ {
584
+ d_info->decoder_name = "nikon_coolscan_load_raw()";
585
+ d_info->decoder_flags = LIBRAW_DECODER_FIXEDMAXC;
586
+ }
587
+ else if (load_raw == &LibRaw::nikon_load_sraw )
588
+ {
589
+ d_info->decoder_name = "nikon_load_sraw()";
590
+ d_info->decoder_flags = LIBRAW_DECODER_HASCURVE | LIBRAW_DECODER_FIXEDMAXC;
591
+ }
592
+ else if (load_raw == &LibRaw::nikon_yuv_load_raw )
593
+ {
594
+ d_info->decoder_name = "nikon_load_sraw()";
595
+ d_info->decoder_flags = LIBRAW_DECODER_HASCURVE;
596
+ }
597
+ else if (load_raw == &LibRaw::rollei_load_raw )
598
+ {
599
+ // UNTESTED
600
+ d_info->decoder_name = "rollei_load_raw()";
601
+ }
602
+ else if (load_raw == &LibRaw::phase_one_load_raw )
603
+ {
604
+ d_info->decoder_name = "phase_one_load_raw()";
605
+ }
606
+ else if (load_raw == &LibRaw::phase_one_load_raw_c )
607
+ {
608
+ d_info->decoder_name = "phase_one_load_raw_c()";
609
+ }
610
+ else if (load_raw == &LibRaw::hasselblad_load_raw )
611
+ {
612
+ d_info->decoder_name = "hasselblad_load_raw()";
613
+ }
614
+ else if (load_raw == &LibRaw::leaf_hdr_load_raw )
615
+ {
616
+ d_info->decoder_name = "leaf_hdr_load_raw()";
617
+ }
618
+ else if (load_raw == &LibRaw::unpacked_load_raw )
619
+ {
620
+ d_info->decoder_name = "unpacked_load_raw()";
621
+ }
622
+ else if (load_raw == &LibRaw::sinar_4shot_load_raw )
623
+ {
624
+ // UNTESTED
625
+ d_info->decoder_name = "sinar_4shot_load_raw()";
626
+ }
627
+ else if (load_raw == &LibRaw::imacon_full_load_raw )
628
+ {
629
+ d_info->decoder_name = "imacon_full_load_raw()";
630
+ }
631
+ else if (load_raw == &LibRaw::hasselblad_full_load_raw )
632
+ {
633
+ d_info->decoder_name = "hasselblad_full_load_raw()";
634
+ }
635
+ else if (load_raw == &LibRaw::packed_load_raw )
636
+ {
637
+ d_info->decoder_name = "packed_load_raw()";
638
+ d_info->decoder_flags = LIBRAW_DECODER_TRYRAWSPEED;
639
+ }
640
+ else if (load_raw == &LibRaw::nokia_load_raw )
641
+ {
642
+ // UNTESTED
643
+ d_info->decoder_name = "nokia_load_raw()";
644
+ }
645
+ else if (load_raw == &LibRaw::canon_rmf_load_raw )
646
+ {
647
+ // UNTESTED
648
+ d_info->decoder_name = "canon_rmf_load_raw()";
649
+ }
650
+ else if (load_raw == &LibRaw::panasonic_load_raw )
651
+ {
652
+ d_info->decoder_name = "panasonic_load_raw()";
653
+ d_info->decoder_flags = LIBRAW_DECODER_TRYRAWSPEED;
654
+ }
655
+ else if (load_raw == &LibRaw::olympus_load_raw )
656
+ {
657
+ d_info->decoder_name = "olympus_load_raw()";
658
+ d_info->decoder_flags = LIBRAW_DECODER_TRYRAWSPEED;
659
+ }
660
+ else if (load_raw == &LibRaw::minolta_rd175_load_raw )
661
+ {
662
+ // UNTESTED
663
+ d_info->decoder_name = "minolta_rd175_load_raw()";
664
+ }
665
+ else if (load_raw == &LibRaw::quicktake_100_load_raw )
666
+ {
667
+ // UNTESTED
668
+ d_info->decoder_name = "quicktake_100_load_raw()";
669
+ }
670
+ else if (load_raw == &LibRaw::kodak_radc_load_raw )
671
+ {
672
+ d_info->decoder_name = "kodak_radc_load_raw()";
673
+ }
674
+ else if (load_raw == &LibRaw::kodak_jpeg_load_raw )
675
+ {
676
+ // UNTESTED + RBAYER
677
+ d_info->decoder_name = "kodak_jpeg_load_raw()";
678
+ }
679
+ else if (load_raw == &LibRaw::lossy_dng_load_raw)
680
+ {
681
+ // Check rbayer
682
+ d_info->decoder_name = "lossy_dng_load_raw()";
683
+ d_info->decoder_flags = LIBRAW_DECODER_TRYRAWSPEED | LIBRAW_DECODER_HASCURVE;
684
+ }
685
+ else if (load_raw == &LibRaw::kodak_dc120_load_raw )
686
+ {
687
+ d_info->decoder_name = "kodak_dc120_load_raw()";
688
+ }
689
+ else if (load_raw == &LibRaw::eight_bit_load_raw )
690
+ {
691
+ d_info->decoder_name = "eight_bit_load_raw()";
692
+ d_info->decoder_flags = LIBRAW_DECODER_HASCURVE;
693
+ }
694
+ else if (load_raw == &LibRaw::kodak_c330_load_raw )
695
+ {
696
+ d_info->decoder_name = "kodak_yrgb_load_raw()";
697
+ d_info->decoder_flags = LIBRAW_DECODER_HASCURVE;
698
+ }
699
+ else if (load_raw == &LibRaw::kodak_c603_load_raw )
700
+ {
701
+ d_info->decoder_name = "kodak_yrgb_load_raw()";
702
+ d_info->decoder_flags = LIBRAW_DECODER_HASCURVE;
703
+ }
704
+ else if (load_raw == &LibRaw::kodak_262_load_raw )
705
+ {
706
+ d_info->decoder_name = "kodak_262_load_raw()"; // UNTESTED!
707
+ d_info->decoder_flags = LIBRAW_DECODER_HASCURVE;
708
+ }
709
+ else if (load_raw == &LibRaw::kodak_65000_load_raw )
710
+ {
711
+ d_info->decoder_name = "kodak_65000_load_raw()";
712
+ d_info->decoder_flags = LIBRAW_DECODER_HASCURVE;
713
+ }
714
+ else if (load_raw == &LibRaw::kodak_ycbcr_load_raw )
715
+ {
716
+ // UNTESTED
717
+ d_info->decoder_name = "kodak_ycbcr_load_raw()";
718
+ d_info->decoder_flags = LIBRAW_DECODER_HASCURVE;
719
+ }
720
+ else if (load_raw == &LibRaw::kodak_rgb_load_raw )
721
+ {
722
+ // UNTESTED
723
+ d_info->decoder_name = "kodak_rgb_load_raw()";
724
+ }
725
+ else if (load_raw == &LibRaw::sony_load_raw )
726
+ {
727
+ d_info->decoder_name = "sony_load_raw()";
728
+ }
729
+ else if (load_raw == &LibRaw::sony_arw_load_raw )
730
+ {
731
+ d_info->decoder_name = "sony_arw_load_raw()";
732
+ d_info->decoder_flags = LIBRAW_DECODER_TRYRAWSPEED;
733
+
734
+ }
735
+ else if (load_raw == &LibRaw::sony_arw2_load_raw )
736
+ {
737
+ d_info->decoder_name = "sony_arw2_load_raw()";
738
+ d_info->decoder_flags = LIBRAW_DECODER_HASCURVE | LIBRAW_DECODER_TRYRAWSPEED | LIBRAW_DECODER_SONYARW2;
739
+ }
740
+ else if (load_raw == &LibRaw::samsung_load_raw )
741
+ {
742
+ d_info->decoder_name = "samsung_load_raw()";
743
+ d_info->decoder_flags = LIBRAW_DECODER_TRYRAWSPEED;
744
+ }
745
+ else if (load_raw == &LibRaw::samsung2_load_raw )
746
+ {
747
+ d_info->decoder_name = "samsung2_load_raw()";
748
+ }
749
+ else if (load_raw == &LibRaw::samsung3_load_raw )
750
+ {
751
+ d_info->decoder_name = "samsung3_load_raw()";
752
+ }
753
+ else if (load_raw == &LibRaw::smal_v6_load_raw )
754
+ {
755
+ // UNTESTED
756
+ d_info->decoder_name = "smal_v6_load_raw()";
757
+ }
758
+ else if (load_raw == &LibRaw::smal_v9_load_raw )
759
+ {
760
+ // UNTESTED
761
+ d_info->decoder_name = "smal_v9_load_raw()";
762
+ }
763
+ else if (load_raw == &LibRaw::redcine_load_raw)
764
+ {
765
+ d_info->decoder_name = "redcine_load_raw()";
766
+ d_info->decoder_flags = LIBRAW_DECODER_HASCURVE;
767
+ }
768
+ else if (load_raw == &LibRaw::x3f_load_raw )
769
+ {
770
+ d_info->decoder_name = "x3f_load_raw()";
771
+ d_info->decoder_flags = LIBRAW_DECODER_OWNALLOC;
772
+ }
773
+ #ifdef LIBRAW_DEMOSAIC_PACK_GPL2
774
+ else if (load_raw == &LibRaw::foveon_sd_load_raw )
775
+ {
776
+ d_info->decoder_name = "foveon_sd_load_raw()";
777
+ }
778
+ else if (load_raw == &LibRaw::foveon_dp_load_raw )
779
+ {
780
+ d_info->decoder_name = "foveon_dp_load_raw()";
781
+ }
782
+ #endif
783
+ else
784
+ {
785
+ d_info->decoder_name = "Unknown unpack function";
786
+ d_info->decoder_flags = LIBRAW_DECODER_NOTSET;
787
+ }
788
+ return LIBRAW_SUCCESS;
789
+ }
790
+
791
+ int LibRaw::adjust_maximum()
792
+ {
793
+ ushort real_max;
794
+ float auto_threshold;
795
+
796
+ if(O.adjust_maximum_thr < 0.00001)
797
+ return LIBRAW_SUCCESS;
798
+ else if (O.adjust_maximum_thr > 0.99999)
799
+ auto_threshold = LIBRAW_DEFAULT_ADJUST_MAXIMUM_THRESHOLD;
800
+ else
801
+ auto_threshold = O.adjust_maximum_thr;
802
+
803
+
804
+ real_max = C.data_maximum;
805
+ if (real_max > 0 && real_max < C.maximum && real_max > C.maximum* auto_threshold)
806
+ {
807
+ C.maximum = real_max;
808
+ }
809
+ return LIBRAW_SUCCESS;
810
+ }
811
+
812
+
813
+ void LibRaw:: merror (void *ptr, const char *where)
814
+ {
815
+ if (ptr) return;
816
+ if(callbacks.mem_cb)(*callbacks.mem_cb)(callbacks.memcb_data,
817
+ libraw_internal_data.internal_data.input
818
+ ?libraw_internal_data.internal_data.input->fname()
819
+ :NULL,
820
+ where);
821
+ throw LIBRAW_EXCEPTION_ALLOC;
822
+ }
823
+
824
+
825
+
826
+ int LibRaw::open_file(const char *fname, INT64 max_buf_size)
827
+ {
828
+ #ifndef WIN32
829
+ struct stat st;
830
+ if(stat(fname,&st))
831
+ return LIBRAW_IO_ERROR;
832
+ int big = (st.st_size > max_buf_size)?1:0;
833
+ #else
834
+ struct _stati64 st;
835
+ if(_stati64(fname,&st))
836
+ return LIBRAW_IO_ERROR;
837
+ int big = (st.st_size > max_buf_size)?1:0;
838
+ #endif
839
+
840
+ LibRaw_abstract_datastream *stream;
841
+ try {
842
+ if(big)
843
+ stream = new LibRaw_bigfile_datastream(fname);
844
+ else
845
+ stream = new LibRaw_file_datastream(fname);
846
+ }
847
+
848
+ catch (std::bad_alloc)
849
+ {
850
+ recycle();
851
+ return LIBRAW_UNSUFFICIENT_MEMORY;
852
+ }
853
+ if(!stream->valid())
854
+ {
855
+ delete stream;
856
+ return LIBRAW_IO_ERROR;
857
+ }
858
+ ID.input_internal = 0; // preserve from deletion on error
859
+ int ret = open_datastream(stream);
860
+ if (ret == LIBRAW_SUCCESS)
861
+ {
862
+ ID.input_internal =1 ; // flag to delete datastream on recycle
863
+ }
864
+ else
865
+ {
866
+ delete stream;
867
+ ID.input_internal = 0;
868
+ }
869
+ return ret;
870
+ }
871
+
872
+ #if defined(_WIN32) && !defined(__MINGW32__) && defined(_MSC_VER) && (_MSC_VER > 1310)
873
+ int LibRaw::open_file(const wchar_t *fname, INT64 max_buf_size)
874
+ {
875
+ struct _stati64 st;
876
+ if(_wstati64(fname,&st))
877
+ return LIBRAW_IO_ERROR;
878
+ int big = (st.st_size > max_buf_size)?1:0;
879
+
880
+ LibRaw_abstract_datastream *stream;
881
+ try {
882
+ if(big)
883
+ stream = new LibRaw_bigfile_datastream(fname);
884
+ else
885
+ stream = new LibRaw_file_datastream(fname);
886
+ }
887
+
888
+ catch (std::bad_alloc)
889
+ {
890
+ recycle();
891
+ return LIBRAW_UNSUFFICIENT_MEMORY;
892
+ }
893
+ if(!stream->valid())
894
+ {
895
+ delete stream;
896
+ return LIBRAW_IO_ERROR;
897
+ }
898
+ ID.input_internal = 0; // preserve from deletion on error
899
+ int ret = open_datastream(stream);
900
+ if (ret == LIBRAW_SUCCESS)
901
+ {
902
+ ID.input_internal =1 ; // flag to delete datastream on recycle
903
+ }
904
+ else
905
+ {
906
+ delete stream;
907
+ ID.input_internal = 0;
908
+ }
909
+ return ret;
910
+ }
911
+ #endif
912
+
913
+ int LibRaw::open_buffer(void *buffer, size_t size)
914
+ {
915
+ // this stream will close on recycle()
916
+ if(!buffer || buffer==(void*)-1)
917
+ return LIBRAW_IO_ERROR;
918
+
919
+ LibRaw_buffer_datastream *stream;
920
+ try {
921
+ stream = new LibRaw_buffer_datastream(buffer,size);
922
+ }
923
+ catch (std::bad_alloc)
924
+ {
925
+ recycle();
926
+ return LIBRAW_UNSUFFICIENT_MEMORY;
927
+ }
928
+ if(!stream->valid())
929
+ {
930
+ delete stream;
931
+ return LIBRAW_IO_ERROR;
932
+ }
933
+ ID.input_internal = 0; // preserve from deletion on error
934
+ int ret = open_datastream(stream);
935
+ if (ret == LIBRAW_SUCCESS)
936
+ {
937
+ ID.input_internal =1 ; // flag to delete datastream on recycle
938
+ }
939
+ else
940
+ {
941
+ delete stream;
942
+ ID.input_internal = 0;
943
+ }
944
+ return ret;
945
+ }
946
+
947
+ void LibRaw::hasselblad_full_load_raw()
948
+ {
949
+ int row, col;
950
+
951
+ for (row=0; row < S.height; row++)
952
+ for (col=0; col < S.width; col++)
953
+ {
954
+ read_shorts (&imgdata.image[row*S.width+col][2], 1); // B
955
+ read_shorts (&imgdata.image[row*S.width+col][1], 1); // G
956
+ read_shorts (&imgdata.image[row*S.width+col][0], 1); // R
957
+ }
958
+ }
959
+
960
+ struct foveon_data_t
961
+ {
962
+ const char *make;
963
+ const char *model;
964
+ const int raw_width,raw_height;
965
+ const int white;
966
+ const int left_margin,top_margin;
967
+ const int width,height;
968
+ } foveon_data [] =
969
+ {
970
+ {"Sigma","SD9",2304,1531,12000,20,8,2266,1510},
971
+ {"Sigma","SD9",1152,763,12000,10,2,1132,755},
972
+ {"Sigma","SD10",2304,1531,12000,20,8,2266,1510},
973
+ {"Sigma","SD10",1152,763,12000,10,2,1132,755},
974
+ {"Sigma","SD14",2688,1792,14000,18,12,2651,1767},
975
+ {"Sigma","SD14",2688,896,14000,18,6,2651,883}, // 2/3
976
+ {"Sigma","SD14",1344,896,14000,9,6,1326,883}, // 1/2
977
+ {"Sigma","SD15",2688,1792,2900,18,12,2651,1767},
978
+ {"Sigma","SD15",2688,896,2900,18,6,2651,883}, // 2/3 ?
979
+ {"Sigma","SD15",1344,896,2900,9,6,1326,883}, // 1/2 ?
980
+ {"Sigma","DP1",2688,1792,2100,18,12,2651,1767},
981
+ {"Sigma","DP1",2688,896,2100,18,6,2651,883}, // 2/3 ?
982
+ {"Sigma","DP1",1344,896,2100,9,6,1326,883}, // 1/2 ?
983
+ {"Sigma","DP1S",2688,1792,2200,18,12,2651,1767},
984
+ {"Sigma","DP1S",2688,896,2200,18,6,2651,883}, // 2/3
985
+ {"Sigma","DP1S",1344,896,2200,9,6,1326,883}, // 1/2
986
+ {"Sigma","DP1X",2688,1792,3560,18,12,2651,1767},
987
+ {"Sigma","DP1X",2688,896,3560,18,6,2651,883}, // 2/3
988
+ {"Sigma","DP1X",1344,896,3560,9,6,1326,883}, // 1/2
989
+ {"Sigma","DP2",2688,1792,2326,13,16,2651,1767},
990
+ {"Sigma","DP2",2688,896,2326,13,8,2651,883}, // 2/3 ??
991
+ {"Sigma","DP2",1344,896,2326,7,8,1325,883}, // 1/2 ??
992
+ {"Sigma","DP2S",2688,1792,2300,18,12,2651,1767},
993
+ {"Sigma","DP2S",2688,896,2300,18,6,2651,883}, // 2/3
994
+ {"Sigma","DP2S",1344,896,2300,9,6,1326,883}, // 1/2
995
+ {"Sigma","DP2X",2688,1792,2300,18,12,2651,1767},
996
+ {"Sigma","DP2X",2688,896,2300,18,6,2651,883}, // 2/3
997
+ {"Sigma","DP2X",1344,896,2300,9,6,1325,883}, // 1/2
998
+ {"Sigma","SD1",4928,3264,3900,12,52,4807,3205}, // Full size
999
+ {"Sigma","SD1",4928,1632,3900,12,26,4807,1603}, // 2/3 size
1000
+ {"Sigma","SD1",2464,1632,3900,6,26,2403,1603}, // 1/2 size
1001
+ {"Sigma","SD1 Merrill",4928,3264,3900,12,52,4807,3205}, // Full size
1002
+ {"Sigma","SD1 Merrill",4928,1632,3900,12,26,4807,1603}, // 2/3 size
1003
+ {"Sigma","SD1 Merrill",2464,1632,3900,6,26,2403,1603}, // 1/2 size
1004
+ {"Sigma","DP1 Merrill",4928,3264,3900,12,0,4807,3205},
1005
+ {"Sigma","DP1 Merrill",2464,1632,3900,12,0,2403,1603}, // 1/2 size
1006
+ {"Sigma","DP1 Merrill",4928,1632,3900,12,0,4807,1603}, // 2/3 size
1007
+ {"Sigma","DP2 Merrill",4928,3264,3900,12,0,4807,3205},
1008
+ {"Sigma","DP2 Merrill",2464,1632,3900,12,0,2403,1603}, // 1/2 size
1009
+ {"Sigma","DP2 Merrill",4928,1632,3900,12,0,4807,1603}, // 2/3 size
1010
+ {"Sigma","DP3 Merrill",4928,3264,3900,12,0,4807,3205},
1011
+ {"Sigma","DP3 Merrill",2464,1632,3900,12,0,2403,1603}, // 1/2 size
1012
+ {"Sigma","DP3 Merrill",4928,1632,3900,12,0,4807,1603}, // 2/3 size
1013
+ {"Polaroid","x530",1440,1088,2700,10,13,1419,1059},
1014
+ // dp2 Q
1015
+ {"Sigma","dp2 Quattro",5888,3672,16383,204,24,5446,3624}, // full size
1016
+ {"Sigma","dp2 Quattro",2944,1836,16383,102,12,2723,1812}, // half size
1017
+ {"Sigma","dp1 Quattro",5888,3672,16383,204,24,5446,3624}, // full size
1018
+ {"Sigma","dp1 Quattro",2944,1836,16383,102,12,2723,1812}, // half size
1019
+ };
1020
+ const int foveon_count = sizeof(foveon_data)/sizeof(foveon_data[0]);
1021
+
1022
+
1023
+ int LibRaw::open_datastream(LibRaw_abstract_datastream *stream)
1024
+ {
1025
+
1026
+ if(!stream)
1027
+ return ENOENT;
1028
+ if(!stream->valid())
1029
+ return LIBRAW_IO_ERROR;
1030
+ recycle();
1031
+
1032
+ try {
1033
+ ID.input = stream;
1034
+ SET_PROC_FLAG(LIBRAW_PROGRESS_OPEN);
1035
+
1036
+ identify();
1037
+
1038
+ if (!imgdata.idata.dng_version && !strcmp(imgdata.idata.make, "Leaf") && !strcmp(imgdata.idata.model, "Credo 50"))
1039
+ {
1040
+ imgdata.color.pre_mul[0] = 1.f / 0.3984f;
1041
+ imgdata.color.pre_mul[2] = 1.f / 0.7666f;
1042
+ imgdata.color.pre_mul[1] = imgdata.color.pre_mul[3] = 1.0;
1043
+ }
1044
+
1045
+ // S3Pro DNG patch
1046
+ if(imgdata.idata.dng_version && !strcmp(imgdata.idata.make,"Fujifilm") && !strcmp(imgdata.idata.model,"S3Pro") && imgdata.sizes.raw_width == 4288 )
1047
+ {
1048
+ imgdata.sizes.left_margin++;
1049
+ imgdata.sizes.width--;
1050
+ }
1051
+ if(imgdata.idata.dng_version && !strcmp(imgdata.idata.make,"Fujifilm") && !strcmp(imgdata.idata.model,"S5Pro") && imgdata.sizes.raw_width == 4288 )
1052
+ {
1053
+ imgdata.sizes.left_margin++;
1054
+ imgdata.sizes.width--;
1055
+ }
1056
+ if(!imgdata.idata.dng_version && !strcmp(imgdata.idata.make,"Fujifilm") && !strcmp(imgdata.idata.model,"S20Pro"))
1057
+ {
1058
+ if(imgdata.idata.raw_count>1)
1059
+ imgdata.idata.raw_count = 1;
1060
+ }
1061
+ if(load_raw == &LibRaw::packed_load_raw && !strcasecmp(imgdata.idata.make,"Nikon")
1062
+ && !libraw_internal_data.unpacker_data.load_flags
1063
+ && (!strcasecmp(imgdata.idata.model,"D810") || !strcasecmp(imgdata.idata.model,"D4S"))
1064
+ && libraw_internal_data.unpacker_data.data_size*2 == imgdata.sizes.raw_height*imgdata.sizes.raw_width*3)
1065
+ {
1066
+ libraw_internal_data.unpacker_data.load_flags = 80;
1067
+ }
1068
+ // Adjust BL for Sony A900/A850
1069
+ if(load_raw == &LibRaw::packed_load_raw && !strcasecmp(imgdata.idata.make,"Sony")) // 12 bit sony, but metadata may be for 14-bit range
1070
+ {
1071
+ if(C.maximum>4095)
1072
+ C.maximum = 4095;
1073
+ if(C.black > 256 || C.cblack[0] > 256)
1074
+ {
1075
+ C.black /=4;
1076
+ for(int c=0; c< 4; c++)
1077
+ C.cblack[c]/=4;
1078
+ for(int c=0; c< C.cblack[4]*C.cblack[5];c++)
1079
+ C.cblack[6+c]/=4;
1080
+ }
1081
+ }
1082
+ if( load_raw == &LibRaw::nikon_yuv_load_raw ) // Is it Nikon sRAW?
1083
+ {
1084
+ load_raw= &LibRaw::nikon_load_sraw;
1085
+ C.black =0;
1086
+ memset(C.cblack,0,sizeof(C.cblack));
1087
+ imgdata.idata.filters = 0;
1088
+ libraw_internal_data.unpacker_data.tiff_samples=3;
1089
+ imgdata.idata.colors = 3;
1090
+ double beta_1 = -5.79342238397656E-02;
1091
+ double beta_2 = 3.28163551282665;
1092
+ double beta_3 = -8.43136004842678;
1093
+ double beta_4 = 1.03533181861023E+01;
1094
+ for(int i=0; i<=3072;i++)
1095
+ {
1096
+ double x = (double)i/3072.;
1097
+ double y = (1.-exp(-beta_1*x-beta_2*x*x-beta_3*x*x*x-beta_4*x*x*x*x));
1098
+ if(y<0.)y=0.;
1099
+ imgdata.color.curve[i] = (y*16383.);
1100
+ }
1101
+ for(int i=0;i<3;i++)
1102
+ for(int j=0;j<4;j++)
1103
+ imgdata.color.rgb_cam[i][j]=float(i==j);
1104
+ }
1105
+ // Adjust BL for Nikon 12bit
1106
+ if((
1107
+ load_raw == &LibRaw::nikon_load_raw
1108
+ || load_raw == &LibRaw::packed_load_raw)
1109
+ && !strcasecmp(imgdata.idata.make,"Nikon")
1110
+ && strncmp(imgdata.idata.model,"COOLPIX",7)
1111
+ && strncmp(imgdata.idata.model,"1 ",2)
1112
+ && libraw_internal_data.unpacker_data.tiff_bps == 12)
1113
+ {
1114
+ C.maximum = 4095;
1115
+ C.black /=4;
1116
+ for(int c=0; c< 4; c++)
1117
+ C.cblack[c]/=4;
1118
+ for(int c=0; c< C.cblack[4]*C.cblack[5];c++)
1119
+ C.cblack[6+c]/=4;
1120
+ }
1121
+
1122
+ // Adjust BL for Panasonic
1123
+ if(load_raw == &LibRaw::panasonic_load_raw && (!strcasecmp(imgdata.idata.make,"Panasonic") || !strcasecmp(imgdata.idata.make,"Leica"))
1124
+ && ID.pana_black[0] && ID.pana_black[1] && ID.pana_black[2])
1125
+ {
1126
+ C.black=0;
1127
+ C.cblack[0] = ID.pana_black[0]+ID.pana_black[3];
1128
+ C.cblack[1] = C.cblack[3] = ID.pana_black[1]+ID.pana_black[3];
1129
+ C.cblack[2] = ID.pana_black[2]+ID.pana_black[3];
1130
+ int i = C.cblack[3];
1131
+ for(int c=0; c<3; c++) if(i>C.cblack[c]) i = C.cblack[c];
1132
+ for(int c=0; c< 4; c++) C.cblack[c]-=i;
1133
+ C.black = i;
1134
+ }
1135
+
1136
+ // Adjust sizes for X3F processing
1137
+ if(load_raw == &LibRaw::x3f_load_raw)
1138
+ {
1139
+ for(int i=0; i< foveon_count;i++)
1140
+ if(!strcasecmp(imgdata.idata.make,foveon_data[i].make) && !strcasecmp(imgdata.idata.model,foveon_data[i].model)
1141
+ && imgdata.sizes.raw_width == foveon_data[i].raw_width
1142
+ && imgdata.sizes.raw_height == foveon_data[i].raw_height
1143
+ )
1144
+ {
1145
+ imgdata.sizes.top_margin = foveon_data[i].top_margin;
1146
+ imgdata.sizes.left_margin = foveon_data[i].left_margin;
1147
+ imgdata.sizes.width = imgdata.sizes.iwidth = foveon_data[i].width;
1148
+ imgdata.sizes.height = imgdata.sizes.iheight = foveon_data[i].height;
1149
+ C.maximum = foveon_data[i].white;
1150
+ break;
1151
+ }
1152
+ }
1153
+ #if 0
1154
+ size_t bytes = ID.input->size()-libraw_internal_data.unpacker_data.data_offset;
1155
+ float bpp = float(bytes)/float(S.raw_width)/float(S.raw_height);
1156
+ float bpp2 = float(bytes)/float(S.width)/float(S.height);
1157
+ printf("RawSize: %dx%d data offset: %d data size:%d bpp: %g bpp2: %g\n",S.raw_width,S.raw_height,libraw_internal_data.unpacker_data.data_offset,bytes,bpp,bpp2);
1158
+ if(!strcasecmp(imgdata.idata.make,"Hasselblad") && bpp == 6.0f)
1159
+ {
1160
+ load_raw = &LibRaw::hasselblad_full_load_raw;
1161
+ S.width = S.raw_width;
1162
+ S.height = S.raw_height;
1163
+ P1.filters = 0;
1164
+ P1.colors=3;
1165
+ P1.raw_count=1;
1166
+ C.maximum=0xffff;
1167
+ printf("3 channel hassy found\n");
1168
+ }
1169
+ #endif
1170
+ if(C.profile_length)
1171
+ {
1172
+ if(C.profile) free(C.profile);
1173
+ C.profile = malloc(C.profile_length);
1174
+ merror(C.profile,"LibRaw::open_file()");
1175
+ ID.input->seek(ID.profile_offset,SEEK_SET);
1176
+ ID.input->read(C.profile,C.profile_length,1);
1177
+ }
1178
+
1179
+ SET_PROC_FLAG(LIBRAW_PROGRESS_IDENTIFY);
1180
+ }
1181
+ catch ( LibRaw_exceptions err) {
1182
+ EXCEPTION_HANDLER(err);
1183
+ }
1184
+ catch (std::exception ee) {
1185
+ EXCEPTION_HANDLER(LIBRAW_EXCEPTION_IO_CORRUPT);
1186
+ }
1187
+
1188
+ if(P1.raw_count < 1)
1189
+ return LIBRAW_FILE_UNSUPPORTED;
1190
+
1191
+
1192
+ write_fun = &LibRaw::write_ppm_tiff;
1193
+
1194
+ if (load_raw == &LibRaw::kodak_ycbcr_load_raw)
1195
+ {
1196
+ S.height += S.height & 1;
1197
+ S.width += S.width & 1;
1198
+ }
1199
+
1200
+ IO.shrink = P1.filters && (O.half_size ||
1201
+ ((O.threshold || O.aber[0] != 1 || O.aber[2] != 1) ));
1202
+
1203
+ S.iheight = (S.height + IO.shrink) >> IO.shrink;
1204
+ S.iwidth = (S.width + IO.shrink) >> IO.shrink;
1205
+
1206
+ // Save color,sizes and internal data into raw_image fields
1207
+ memmove(&imgdata.rawdata.color,&imgdata.color,sizeof(imgdata.color));
1208
+ memmove(&imgdata.rawdata.sizes,&imgdata.sizes,sizeof(imgdata.sizes));
1209
+ memmove(&imgdata.rawdata.iparams,&imgdata.idata,sizeof(imgdata.idata));
1210
+ memmove(&imgdata.rawdata.ioparams,&libraw_internal_data.internal_output_params,sizeof(libraw_internal_data.internal_output_params));
1211
+
1212
+ SET_PROC_FLAG(LIBRAW_PROGRESS_SIZE_ADJUST);
1213
+
1214
+
1215
+ return LIBRAW_SUCCESS;
1216
+ }
1217
+
1218
+ #ifdef USE_RAWSPEED
1219
+ void LibRaw::fix_after_rawspeed(int bl)
1220
+ {
1221
+ if (load_raw == &LibRaw::lossy_dng_load_raw)
1222
+ C.maximum = 0xffff;
1223
+ else if (load_raw == &LibRaw::sony_load_raw)
1224
+ C.maximum = 0x3ff0;
1225
+ }
1226
+ #else
1227
+ void LibRaw::fix_after_rawspeed(int)
1228
+ {
1229
+ }
1230
+ #endif
1231
+
1232
+ void LibRaw::clearCancelFlag()
1233
+ {
1234
+ #ifdef WIN32
1235
+ InterlockedExchange(&_exitflag, 0);
1236
+ #else
1237
+ __sync_fetch_and_and(&_exitflag, 0);
1238
+ #endif
1239
+ #ifdef RAWSPEED_FASTEXIT
1240
+ if (_rawspeed_decoder)
1241
+ {
1242
+ RawDecoder *d = static_cast<RawDecoder*>(_rawspeed_decoder);
1243
+ d->resumeProcessing();
1244
+ }
1245
+ #endif
1246
+
1247
+ }
1248
+
1249
+ void LibRaw::setCancelFlag()
1250
+ {
1251
+ #ifdef WIN32
1252
+ InterlockedExchange(&_exitflag,1);
1253
+ #else
1254
+ __sync_fetch_and_add(&_exitflag,1);
1255
+ #endif
1256
+ #ifdef RAWSPEED_FASTEXIT
1257
+ if(_rawspeed_decoder)
1258
+ {
1259
+ RawDecoder *d = static_cast<RawDecoder*>(_rawspeed_decoder);
1260
+ d->cancelProcessing();
1261
+ }
1262
+ #endif
1263
+ }
1264
+
1265
+ void LibRaw::checkCancel()
1266
+ {
1267
+ #ifdef WIN32
1268
+ if(InterlockedExchange(&_exitflag,0))
1269
+ throw LIBRAW_EXCEPTION_CANCELLED_BY_CALLBACK;
1270
+ #else
1271
+ if( __sync_fetch_and_and(&_exitflag,0))
1272
+ throw LIBRAW_EXCEPTION_CANCELLED_BY_CALLBACK;
1273
+ #endif
1274
+ }
1275
+
1276
+ int LibRaw::unpack(void)
1277
+ {
1278
+ CHECK_ORDER_HIGH(LIBRAW_PROGRESS_LOAD_RAW);
1279
+ CHECK_ORDER_LOW(LIBRAW_PROGRESS_IDENTIFY);
1280
+ try {
1281
+
1282
+ if(!libraw_internal_data.internal_data.input)
1283
+ return LIBRAW_INPUT_CLOSED;
1284
+
1285
+ RUN_CALLBACK(LIBRAW_PROGRESS_LOAD_RAW,0,2);
1286
+ if (O.shot_select >= P1.raw_count)
1287
+ return LIBRAW_REQUEST_FOR_NONEXISTENT_IMAGE;
1288
+
1289
+ if(!load_raw)
1290
+ return LIBRAW_UNSPECIFIED_ERROR;
1291
+
1292
+ // already allocated ?
1293
+ if(imgdata.image)
1294
+ {
1295
+ free(imgdata.image);
1296
+ imgdata.image = 0;
1297
+ }
1298
+ if(imgdata.rawdata.raw_alloc)
1299
+ {
1300
+ free(imgdata.rawdata.raw_alloc);
1301
+ imgdata.rawdata.raw_alloc = 0;
1302
+ }
1303
+ if (libraw_internal_data.unpacker_data.meta_length)
1304
+ {
1305
+ libraw_internal_data.internal_data.meta_data =
1306
+ (char *) malloc (libraw_internal_data.unpacker_data.meta_length);
1307
+ merror (libraw_internal_data.internal_data.meta_data, "LibRaw::unpack()");
1308
+ }
1309
+
1310
+ libraw_decoder_info_t decoder_info;
1311
+ get_decoder_info(&decoder_info);
1312
+
1313
+ int save_iwidth = S.iwidth, save_iheight = S.iheight, save_shrink = IO.shrink;
1314
+
1315
+ int rwidth = S.raw_width, rheight = S.raw_height;
1316
+ if( !IO.fuji_width)
1317
+ {
1318
+ // adjust non-Fuji allocation
1319
+ if(rwidth < S.width + S.left_margin)
1320
+ rwidth = S.width + S.left_margin;
1321
+ if(rheight < S.height + S.top_margin)
1322
+ rheight = S.height + S.top_margin;
1323
+ }
1324
+
1325
+ imgdata.rawdata.raw_image = 0;
1326
+ imgdata.rawdata.color4_image = 0;
1327
+ imgdata.rawdata.color3_image = 0;
1328
+ #ifdef USE_RAWSPEED
1329
+ int rawspeed_enabled = 1;
1330
+ if(imgdata.idata.dng_version && libraw_internal_data.unpacker_data.tiff_samples == 2)
1331
+ rawspeed_enabled = 0;
1332
+ // Disable rawspeed for double-sized Oly files
1333
+ if(!strncasecmp(imgdata.idata.make,"Olympus",7) && !strncasecmp(imgdata.idata.model,"E-M5MarkII",10) && imgdata.sizes.raw_width == 9280)
1334
+ rawspeed_enabled = 0;
1335
+
1336
+ // RawSpeed Supported,
1337
+ if(O.use_rawspeed && rawspeed_enabled
1338
+ && !(is_sraw() && O.sraw_ycc)
1339
+ && (decoder_info.decoder_flags & LIBRAW_DECODER_TRYRAWSPEED) && _rawspeed_camerameta)
1340
+ {
1341
+ INT64 spos = ID.input->tell();
1342
+ void *_rawspeed_buffer = 0;
1343
+ try
1344
+ {
1345
+ // printf("Using rawspeed\n");
1346
+ ID.input->seek(0,SEEK_SET);
1347
+ INT64 _rawspeed_buffer_sz = ID.input->size()+32;
1348
+ _rawspeed_buffer = malloc(_rawspeed_buffer_sz);
1349
+ if(!_rawspeed_buffer) throw LIBRAW_EXCEPTION_ALLOC;
1350
+ ID.input->read(_rawspeed_buffer,_rawspeed_buffer_sz,1);
1351
+ FileMap map((uchar8*)_rawspeed_buffer,_rawspeed_buffer_sz);
1352
+ RawParser t(&map);
1353
+ RawDecoder *d = 0;
1354
+ CameraMetaDataLR *meta = static_cast<CameraMetaDataLR*>(_rawspeed_camerameta);
1355
+ d = t.getDecoder();
1356
+ if(!d) throw "Unable to find decoder";
1357
+ try {
1358
+ d->checkSupport(meta);
1359
+ }
1360
+ catch (const RawDecoderException& e)
1361
+ {
1362
+ imgdata.process_warnings |= LIBRAW_WARN_RAWSPEED_UNSUPPORTED;
1363
+ throw e;
1364
+ }
1365
+ d->interpolateBadPixels = FALSE;
1366
+ d->applyStage1DngOpcodes = FALSE;
1367
+ _rawspeed_decoder = static_cast<void*>(d);
1368
+ d->decodeRaw();
1369
+ d->decodeMetaData(meta);
1370
+ RawImage r = d->mRaw;
1371
+ if( r->errors.size()>0)
1372
+ {
1373
+ delete d;
1374
+ _rawspeed_decoder = 0;
1375
+ throw 1;
1376
+ }
1377
+ if (r->isCFA)
1378
+ {
1379
+ imgdata.rawdata.raw_image = (ushort*) r->getDataUncropped(0,0);
1380
+ }
1381
+ else if(r->getCpp()==4)
1382
+ {
1383
+ imgdata.rawdata.color4_image = (ushort(*)[4]) r->getDataUncropped(0,0);
1384
+ if(r->whitePoint > 0 && r->whitePoint < 65536)
1385
+ C.maximum = r->whitePoint;
1386
+ } else if(r->getCpp() == 3)
1387
+ {
1388
+ imgdata.rawdata.color3_image = (ushort(*)[3]) r->getDataUncropped(0,0);
1389
+ if(r->whitePoint > 0 && r->whitePoint < 65536)
1390
+ C.maximum = r->whitePoint;
1391
+ }
1392
+ else
1393
+ {
1394
+ delete d;
1395
+ _rawspeed_decoder = 0;
1396
+ }
1397
+ if(_rawspeed_decoder)
1398
+ {
1399
+ // set sizes
1400
+ iPoint2D rsdim = r->getUncroppedDim();
1401
+ S.raw_pitch = r->pitch;
1402
+ S.raw_width = rsdim.x;
1403
+ S.raw_height = rsdim.y;
1404
+ //C.maximum = r->whitePoint;
1405
+ fix_after_rawspeed(r->blackLevel);
1406
+ }
1407
+ free(_rawspeed_buffer);
1408
+ _rawspeed_buffer = 0;
1409
+ imgdata.process_warnings |= LIBRAW_WARN_RAWSPEED_PROCESSED;
1410
+ }
1411
+ catch (const RawDecoderException& RDE)
1412
+ {
1413
+ imgdata.process_warnings |= LIBRAW_WARN_RAWSPEED_PROBLEM;
1414
+ if (_rawspeed_buffer)
1415
+ {
1416
+ free(_rawspeed_buffer);
1417
+ _rawspeed_buffer = 0;
1418
+ }
1419
+ const char *p = RDE.what();
1420
+ if (!strncmp(RDE.what(), "Decoder canceled", strlen("Decoder canceled")))
1421
+ throw LIBRAW_EXCEPTION_CANCELLED_BY_CALLBACK;
1422
+ }
1423
+ catch (...)
1424
+ {
1425
+ // We may get here due to cancellation flag
1426
+ imgdata.process_warnings |= LIBRAW_WARN_RAWSPEED_PROBLEM;
1427
+ if(_rawspeed_buffer)
1428
+ {
1429
+ free(_rawspeed_buffer);
1430
+ _rawspeed_buffer = 0;
1431
+ }
1432
+ }
1433
+ ID.input->seek(spos,SEEK_SET);
1434
+ }
1435
+ #endif
1436
+ if(!imgdata.rawdata.raw_image && !imgdata.rawdata.color4_image && !imgdata.rawdata.color3_image) //RawSpeed failed!
1437
+ {
1438
+ // Not allocated on RawSpeed call, try call LibRaw
1439
+ if(decoder_info.decoder_flags & LIBRAW_DECODER_OWNALLOC)
1440
+ {
1441
+ // x3f foveon decoder
1442
+ // Do nothing! Decoder will allocate data internally
1443
+ }
1444
+ else if(imgdata.idata.filters || P1.colors == 1) // Bayer image or single color -> decode to raw_image
1445
+ {
1446
+ imgdata.rawdata.raw_alloc = malloc(rwidth*(rheight+8)*sizeof(imgdata.rawdata.raw_image[0]));
1447
+ imgdata.rawdata.raw_image = (ushort*) imgdata.rawdata.raw_alloc;
1448
+ if(!S.raw_pitch)
1449
+ S.raw_pitch = S.raw_width*2; // Bayer case, not set before
1450
+ }
1451
+ else // NO LEGACY FLAG if (decoder_info.decoder_flags & LIBRAW_DECODER_LEGACY)
1452
+ {
1453
+ // sRAW and old Foveon decoders only, so extra buffer size is just 1/4
1454
+ S.iwidth = S.width;
1455
+ S.iheight= S.height;
1456
+ IO.shrink = 0;
1457
+ S.raw_pitch = S.width*8;
1458
+ // allocate image as temporary buffer, size
1459
+ imgdata.rawdata.raw_alloc = 0;
1460
+ imgdata.image = (ushort (*)[4]) calloc(S.iwidth*S.iheight,sizeof(*imgdata.image));
1461
+ }
1462
+ ID.input->seek(libraw_internal_data.unpacker_data.data_offset, SEEK_SET);
1463
+
1464
+ unsigned m_save = C.maximum;
1465
+ if(load_raw == &LibRaw::unpacked_load_raw && !strcasecmp(imgdata.idata.make,"Nikon"))
1466
+ C.maximum=65535;
1467
+ (this->*load_raw)();
1468
+ if(load_raw == &LibRaw::unpacked_load_raw && !strcasecmp(imgdata.idata.make,"Nikon"))
1469
+ C.maximum = m_save;
1470
+ if(decoder_info.decoder_flags & LIBRAW_DECODER_OWNALLOC)
1471
+ {
1472
+ // x3f foveon decoder only: do nothing
1473
+
1474
+ }
1475
+ else if (!(imgdata.idata.filters || P1.colors == 1))
1476
+ {
1477
+ // successfully decoded legacy image, attach image to raw_alloc
1478
+ imgdata.rawdata.raw_alloc = imgdata.image;
1479
+ imgdata.image = 0;
1480
+ // Restore saved values. Note: Foveon have masked frame
1481
+ // Other 4-color legacy data: no borders
1482
+ S.raw_width = S.width;
1483
+ S.left_margin = 0;
1484
+ S.raw_height = S.height;
1485
+ S.top_margin = 0;
1486
+ }
1487
+ }
1488
+
1489
+ if(imgdata.rawdata.raw_image)
1490
+ crop_masked_pixels(); // calculate black levels
1491
+
1492
+ // recover saved
1493
+ if( !(imgdata.idata.filters || P1.colors == 1) && !imgdata.rawdata.color4_image)
1494
+ {
1495
+ imgdata.image = 0;
1496
+ imgdata.rawdata.color4_image = (ushort (*)[4]) imgdata.rawdata.raw_alloc;
1497
+ }
1498
+
1499
+ // recover image sizes
1500
+ S.iwidth = save_iwidth;
1501
+ S.iheight = save_iheight;
1502
+ IO.shrink = save_shrink;
1503
+
1504
+ // adjust black to possible maximum
1505
+ unsigned int i = C.cblack[3];
1506
+ unsigned int c;
1507
+ for(c=0;c<3;c++)
1508
+ if (i > C.cblack[c]) i = C.cblack[c];
1509
+ for (c=0;c<4;c++)
1510
+ C.cblack[c] -= i;
1511
+ C.black += i;
1512
+
1513
+ // Save color,sizes and internal data into raw_image fields
1514
+ memmove(&imgdata.rawdata.color,&imgdata.color,sizeof(imgdata.color));
1515
+ memmove(&imgdata.rawdata.sizes,&imgdata.sizes,sizeof(imgdata.sizes));
1516
+ memmove(&imgdata.rawdata.iparams,&imgdata.idata,sizeof(imgdata.idata));
1517
+ memmove(&imgdata.rawdata.ioparams,&libraw_internal_data.internal_output_params,sizeof(libraw_internal_data.internal_output_params));
1518
+
1519
+ SET_PROC_FLAG(LIBRAW_PROGRESS_LOAD_RAW);
1520
+ RUN_CALLBACK(LIBRAW_PROGRESS_LOAD_RAW,1,2);
1521
+
1522
+ return 0;
1523
+ }
1524
+ catch ( LibRaw_exceptions err) {
1525
+ EXCEPTION_HANDLER(err);
1526
+ }
1527
+ catch (std::exception ee) {
1528
+ EXCEPTION_HANDLER(LIBRAW_EXCEPTION_IO_CORRUPT);
1529
+ }
1530
+ }
1531
+
1532
+ void LibRaw::nikon_load_sraw()
1533
+ {
1534
+ // We're already seeked to data!
1535
+ unsigned char *rd = (unsigned char *)malloc(3*(imgdata.sizes.raw_width+2));
1536
+ if(!rd) throw LIBRAW_EXCEPTION_ALLOC;
1537
+ try {
1538
+ int row,col;
1539
+ for(row = 0; row < imgdata.sizes.raw_height; row++)
1540
+ {
1541
+ checkCancel();
1542
+ libraw_internal_data.internal_data.input->read(rd,3,imgdata.sizes.raw_width);
1543
+ for(col = 0; col < imgdata.sizes.raw_width-1;col+=2)
1544
+ {
1545
+ int bi = col*3;
1546
+ ushort bits1 = (rd[bi+1] &0xf)<<8| rd[bi]; // 3,0,1
1547
+ ushort bits2 = rd[bi+2] << 4 | ((rd[bi+1]>>4)& 0xf); //452
1548
+ ushort bits3 = ((rd[bi+4] & 0xf)<<8) | rd[bi+3]; // 967
1549
+ ushort bits4 = rd[bi+5] << 4 | ((rd[bi+4]>>4)& 0xf); // ab8
1550
+ imgdata.image[row*imgdata.sizes.raw_width+col][0]=bits1;
1551
+ imgdata.image[row*imgdata.sizes.raw_width+col][1]=bits3;
1552
+ imgdata.image[row*imgdata.sizes.raw_width+col][2]=bits4;
1553
+ imgdata.image[row*imgdata.sizes.raw_width+col+1][0]=bits2;
1554
+ imgdata.image[row*imgdata.sizes.raw_width+col+1][1]=2048;
1555
+ imgdata.image[row*imgdata.sizes.raw_width+col+1][2]=2048;
1556
+ }
1557
+ }
1558
+ }catch (...) {
1559
+ free(rd);
1560
+ throw ;
1561
+ }
1562
+ free(rd);
1563
+ C.maximum = 0xfff; // 12 bit?
1564
+ if(imgdata.params.sraw_ycc>=2)
1565
+ {
1566
+ return; // no CbCr interpolation
1567
+ }
1568
+ // Interpolate CC channels
1569
+ int row,col;
1570
+ for(row = 0; row < imgdata.sizes.raw_height; row++)
1571
+ {
1572
+ checkCancel(); // will throw out
1573
+ for(col = 0; col < imgdata.sizes.raw_width;col+=2)
1574
+ {
1575
+ int col2 = col<imgdata.sizes.raw_width-2?col+2:col;
1576
+ imgdata.image[row*imgdata.sizes.raw_width+col+1][1]
1577
+ =(unsigned short)(int(imgdata.image[row*imgdata.sizes.raw_width+col][1]
1578
+ +imgdata.image[row*imgdata.sizes.raw_width+col2][1])/2);
1579
+ imgdata.image[row*imgdata.sizes.raw_width+col+1][2]
1580
+ =(unsigned short)(int(imgdata.image[row*imgdata.sizes.raw_width+col][2]
1581
+ +imgdata.image[row*imgdata.sizes.raw_width+col2][2])/2);
1582
+ }
1583
+ }
1584
+ if(imgdata.params.sraw_ycc>0)
1585
+ return;
1586
+
1587
+ for(row = 0; row < imgdata.sizes.raw_height; row++)
1588
+ {
1589
+ checkCancel(); // will throw out
1590
+ for(col = 0; col < imgdata.sizes.raw_width;col++)
1591
+ {
1592
+ float Y = float(imgdata.image[row*imgdata.sizes.raw_width+col][0])/2549.f;
1593
+ float Ch2 = float(imgdata.image[row*imgdata.sizes.raw_width+col][1]-1280)/1536.f;
1594
+ float Ch3 = float(imgdata.image[row*imgdata.sizes.raw_width+col][2]-1280)/1536.f;
1595
+ if(Y>1.f) Y = 1.f;
1596
+ if(Y>0.803f) Ch2 = Ch3 = 0.5f;
1597
+ float r = Y + 1.40200f*(Ch3 - 0.5f);
1598
+ if(r<0.f) r=0.f;
1599
+ if(r>1.f) r=1.f;
1600
+ float g = Y - 0.34414f*(Ch2-0.5f) - 0.71414*(Ch3 - 0.5f) ;
1601
+ if(g>1.f) g = 1.f;
1602
+ if(g<0.f) g = 0.f;
1603
+ float b = Y + 1.77200*(Ch2-0.5f);
1604
+ if(b>1.f) b = 1.f;
1605
+ if(b<0.f) b = 0.f;
1606
+ imgdata.image[row*imgdata.sizes.raw_width+col][0]=imgdata.color.curve[int(r*3072.f)];
1607
+ imgdata.image[row*imgdata.sizes.raw_width+col][1]=imgdata.color.curve[int(g*3072.f)];
1608
+ imgdata.image[row*imgdata.sizes.raw_width+col][2]=imgdata.color.curve[int(b*3072.f)];
1609
+ }
1610
+ }
1611
+ C.maximum=16383;
1612
+ }
1613
+
1614
+ void LibRaw::free_image(void)
1615
+ {
1616
+ if(imgdata.image)
1617
+ {
1618
+ free(imgdata.image);
1619
+ imgdata.image = 0;
1620
+ imgdata.progress_flags
1621
+ = LIBRAW_PROGRESS_START|LIBRAW_PROGRESS_OPEN
1622
+ |LIBRAW_PROGRESS_IDENTIFY|LIBRAW_PROGRESS_SIZE_ADJUST|LIBRAW_PROGRESS_LOAD_RAW;
1623
+ }
1624
+ }
1625
+
1626
+
1627
+ void LibRaw::raw2image_start()
1628
+ {
1629
+ // restore color,sizes and internal data into raw_image fields
1630
+ memmove(&imgdata.color,&imgdata.rawdata.color,sizeof(imgdata.color));
1631
+ memmove(&imgdata.sizes,&imgdata.rawdata.sizes,sizeof(imgdata.sizes));
1632
+ memmove(&imgdata.idata,&imgdata.rawdata.iparams,sizeof(imgdata.idata));
1633
+ memmove(&libraw_internal_data.internal_output_params,&imgdata.rawdata.ioparams,sizeof(libraw_internal_data.internal_output_params));
1634
+
1635
+ if (O.user_flip >= 0)
1636
+ S.flip = O.user_flip;
1637
+
1638
+ switch ((S.flip+3600) % 360)
1639
+ {
1640
+ case 270: S.flip = 5; break;
1641
+ case 180: S.flip = 3; break;
1642
+ case 90: S.flip = 6; break;
1643
+ }
1644
+
1645
+ // adjust for half mode!
1646
+ IO.shrink = P1.filters && (O.half_size ||
1647
+ ((O.threshold || O.aber[0] != 1 || O.aber[2] != 1) ));
1648
+
1649
+ S.iheight = (S.height + IO.shrink) >> IO.shrink;
1650
+ S.iwidth = (S.width + IO.shrink) >> IO.shrink;
1651
+
1652
+ }
1653
+
1654
+ int LibRaw::is_phaseone_compressed()
1655
+ {
1656
+ return (load_raw == &LibRaw::phase_one_load_raw_c || load_raw == &LibRaw::phase_one_load_raw);
1657
+ }
1658
+
1659
+ int LibRaw::raw2image(void)
1660
+ {
1661
+
1662
+ CHECK_ORDER_LOW(LIBRAW_PROGRESS_LOAD_RAW);
1663
+
1664
+ try {
1665
+ raw2image_start();
1666
+
1667
+ if (is_phaseone_compressed())
1668
+ {
1669
+ phase_one_allocate_tempbuffer();
1670
+ phase_one_subtract_black((ushort*)imgdata.rawdata.raw_alloc,imgdata.rawdata.raw_image);
1671
+ phase_one_correct();
1672
+ }
1673
+
1674
+ // free and re-allocate image bitmap
1675
+ if(imgdata.image)
1676
+ {
1677
+ imgdata.image = (ushort (*)[4]) realloc (imgdata.image,S.iheight*S.iwidth *sizeof (*imgdata.image));
1678
+ memset(imgdata.image,0,S.iheight*S.iwidth *sizeof (*imgdata.image));
1679
+ }
1680
+ else
1681
+ imgdata.image = (ushort (*)[4]) calloc (S.iheight*S.iwidth, sizeof (*imgdata.image));
1682
+
1683
+ merror (imgdata.image, "raw2image()");
1684
+
1685
+ libraw_decoder_info_t decoder_info;
1686
+ get_decoder_info(&decoder_info);
1687
+
1688
+ // Move saved bitmap to imgdata.image
1689
+ if( imgdata.idata.filters || P1.colors == 1)
1690
+ {
1691
+ if (IO.fuji_width) {
1692
+ unsigned r,c;
1693
+ int row,col;
1694
+ for (row=0; row < S.raw_height-S.top_margin*2; row++) {
1695
+ for (col=0; col < IO.fuji_width << !libraw_internal_data.unpacker_data.fuji_layout; col++) {
1696
+ if (libraw_internal_data.unpacker_data.fuji_layout) {
1697
+ r = IO.fuji_width - 1 - col + (row >> 1);
1698
+ c = col + ((row+1) >> 1);
1699
+ } else {
1700
+ r = IO.fuji_width - 1 + row - (col >> 1);
1701
+ c = row + ((col+1) >> 1);
1702
+ }
1703
+ if (r < S.height && c < S.width)
1704
+ imgdata.image[((r)>>IO.shrink)*S.iwidth+((c)>>IO.shrink)][FC(r,c)]
1705
+ = imgdata.rawdata.raw_image[(row+S.top_margin)*S.raw_pitch/2+(col+S.left_margin)];
1706
+ }
1707
+ }
1708
+ }
1709
+ else {
1710
+ int row,col;
1711
+ for (row=0; row < S.height; row++)
1712
+ for (col=0; col < S.width; col++)
1713
+ imgdata.image[((row) >> IO.shrink)*S.iwidth + ((col) >> IO.shrink)][fcol(row,col)]
1714
+ = imgdata.rawdata.raw_image[(row+S.top_margin)*S.raw_pitch/2+(col+S.left_margin)];
1715
+ }
1716
+ }
1717
+ else // if(decoder_info.decoder_flags & LIBRAW_DECODER_LEGACY)
1718
+ {
1719
+ if(imgdata.rawdata.color4_image)
1720
+ {
1721
+ if(S.width*8 == S.raw_pitch)
1722
+ memmove(imgdata.image,imgdata.rawdata.color4_image,S.width*S.height*sizeof(*imgdata.image));
1723
+ else
1724
+ {
1725
+ for(int row = 0; row < S.height; row++)
1726
+ memmove(&imgdata.image[row*S.width],
1727
+ &imgdata.rawdata.color4_image[(row+S.top_margin)*S.raw_pitch/8+S.left_margin],
1728
+ S.width*sizeof(*imgdata.image));
1729
+ }
1730
+ }
1731
+ else if(imgdata.rawdata.color3_image)
1732
+ {
1733
+ unsigned char *c3image = (unsigned char*) imgdata.rawdata.color3_image;
1734
+ for(int row = 0; row < S.height; row++)
1735
+ {
1736
+ ushort (*srcrow)[3] = (ushort (*)[3]) &c3image[(row+S.top_margin)*S.raw_pitch];
1737
+ ushort (*dstrow)[4] = (ushort (*)[4]) &imgdata.image[row*S.width];
1738
+ for(int col=0; col < S.width; col++)
1739
+ {
1740
+ for(int c=0; c< 3; c++)
1741
+ dstrow[col][c] = srcrow[S.left_margin+col][c];
1742
+ dstrow[col][3]=0;
1743
+ }
1744
+ }
1745
+ }
1746
+ else
1747
+ {
1748
+ // legacy decoder, but no data?
1749
+ throw LIBRAW_EXCEPTION_DECODE_RAW;
1750
+ }
1751
+ }
1752
+
1753
+ // Free PhaseOne separate copy allocated at function start
1754
+ if (is_phaseone_compressed())
1755
+ {
1756
+ phase_one_free_tempbuffer();
1757
+ }
1758
+ // hack - clear later flags!
1759
+
1760
+ if (load_raw == &CLASS canon_600_load_raw && S.width < S.raw_width)
1761
+ {
1762
+ canon_600_correct();
1763
+ }
1764
+
1765
+ imgdata.progress_flags
1766
+ = LIBRAW_PROGRESS_START|LIBRAW_PROGRESS_OPEN | LIBRAW_PROGRESS_RAW2_IMAGE
1767
+ |LIBRAW_PROGRESS_IDENTIFY|LIBRAW_PROGRESS_SIZE_ADJUST|LIBRAW_PROGRESS_LOAD_RAW;
1768
+ return 0;
1769
+ }
1770
+ catch ( LibRaw_exceptions err) {
1771
+ EXCEPTION_HANDLER(err);
1772
+ }
1773
+ }
1774
+
1775
+ void LibRaw::phase_one_allocate_tempbuffer()
1776
+ {
1777
+ // Allocate temp raw_image buffer
1778
+ imgdata.rawdata.raw_image = (ushort*)malloc(S.raw_pitch*S.raw_height);
1779
+ merror (imgdata.rawdata.raw_image, "phase_one_prepare_to_correct()");
1780
+ }
1781
+ void LibRaw::phase_one_free_tempbuffer()
1782
+ {
1783
+ free(imgdata.rawdata.raw_image);
1784
+ imgdata.rawdata.raw_image = (ushort*) imgdata.rawdata.raw_alloc;
1785
+ }
1786
+
1787
+ int LibRaw::phase_one_subtract_black(ushort *src, ushort *dest)
1788
+ {
1789
+
1790
+ try
1791
+ {
1792
+ if (O.user_black < 0 && O.user_cblack[0] <= -1000000 && O.user_cblack[1] <= -1000000 && O.user_cblack[2] <= -1000000 && O.user_cblack[3] <= -1000000)
1793
+ {
1794
+ if (!imgdata.rawdata.ph1_cblack || !imgdata.rawdata.ph1_rblack)
1795
+ {
1796
+ register int bl = imgdata.color.phase_one_data.t_black;
1797
+ for (int row = 0; row < S.raw_height; row++)
1798
+ {
1799
+ checkCancel();
1800
+ for (int col = 0; col < S.raw_width; col++)
1801
+ {
1802
+ int idx = row*S.raw_width + col;
1803
+ int val = int(src[idx]) - bl;
1804
+ dest[idx] = val>0 ? val : 0;
1805
+ }
1806
+ }
1807
+ }
1808
+ else
1809
+ {
1810
+ register int bl = imgdata.color.phase_one_data.t_black;
1811
+ for (int row = 0; row < S.raw_height; row++)
1812
+ {
1813
+ checkCancel();
1814
+ for (int col = 0; col < S.raw_width; col++)
1815
+ {
1816
+ int idx = row*S.raw_width + col;
1817
+ int val = int(src[idx]) - bl
1818
+ + imgdata.rawdata.ph1_cblack[row][col >= imgdata.rawdata.color.phase_one_data.split_col]
1819
+ + imgdata.rawdata.ph1_rblack[col][row >= imgdata.rawdata.color.phase_one_data.split_row];
1820
+ dest[idx] = val>0 ? val : 0;
1821
+ }
1822
+ }
1823
+ }
1824
+ }
1825
+ else // black set by user interaction
1826
+ {
1827
+ // Black level in cblack!
1828
+ for (int row = 0; row < S.raw_height; row++)
1829
+ {
1830
+ checkCancel();
1831
+ unsigned short cblk[16];
1832
+ for (int cc = 0; cc < 16; cc++)
1833
+ cblk[cc] = C.cblack[fcol(row, cc)];
1834
+ for (int col = 0; col < S.raw_width; col++)
1835
+ {
1836
+ int idx = row*S.raw_width + col;
1837
+ ushort val = src[idx];
1838
+ ushort bl = cblk[col & 0xf];
1839
+ dest[idx] = val>bl ? val - bl : 0;
1840
+ }
1841
+ }
1842
+ }
1843
+ return 0;
1844
+ }
1845
+ catch (LibRaw_exceptions err) {
1846
+ return LIBRAW_CANCELLED_BY_CALLBACK;
1847
+ }
1848
+ }
1849
+
1850
+ void LibRaw::copy_fuji_uncropped(unsigned short cblack[4],unsigned short *dmaxp)
1851
+ {
1852
+ int row;
1853
+ #if defined(LIBRAW_USE_OPENMP)
1854
+ #pragma omp parallel for default(shared)
1855
+ #endif
1856
+ for (row=0; row < S.raw_height-S.top_margin*2; row++)
1857
+ {
1858
+ int col;
1859
+ unsigned short ldmax = 0;
1860
+ for (col=0; col < IO.fuji_width << !libraw_internal_data.unpacker_data.fuji_layout; col++)
1861
+ {
1862
+ unsigned r,c;
1863
+ if (libraw_internal_data.unpacker_data.fuji_layout) {
1864
+ r = IO.fuji_width - 1 - col + (row >> 1);
1865
+ c = col + ((row+1) >> 1);
1866
+ } else {
1867
+ r = IO.fuji_width - 1 + row - (col >> 1);
1868
+ c = row + ((col+1) >> 1);
1869
+ }
1870
+ if (r < S.height && c < S.width)
1871
+ {
1872
+ unsigned short val = imgdata.rawdata.raw_image[(row+S.top_margin)*S.raw_pitch/2+(col+S.left_margin)];
1873
+ int cc = FC(r,c);
1874
+ if(val>cblack[cc])
1875
+ {
1876
+ val-=cblack[cc];
1877
+ if(val>ldmax)ldmax = val;
1878
+ }
1879
+ else
1880
+ val = 0;
1881
+ imgdata.image[((r)>>IO.shrink)*S.iwidth+((c)>>IO.shrink)][cc] = val;
1882
+ }
1883
+ }
1884
+ #if defined(LIBRAW_USE_OPENMP)
1885
+ #pragma omp critical(dataupdate)
1886
+ #endif
1887
+ {
1888
+ if(*dmaxp < ldmax)
1889
+ *dmaxp = ldmax;
1890
+ }
1891
+ }
1892
+ }
1893
+
1894
+ void LibRaw::copy_bayer(unsigned short cblack[4],unsigned short *dmaxp)
1895
+ {
1896
+ // Both cropped and uncropped
1897
+ int row;
1898
+
1899
+ #if defined(LIBRAW_USE_OPENMP)
1900
+ #pragma omp parallel for default(shared)
1901
+ #endif
1902
+ for (row=0; row < S.height; row++)
1903
+ {
1904
+ int col;
1905
+ unsigned short ldmax = 0;
1906
+ for (col=0; col < S.width; col++)
1907
+ {
1908
+ unsigned short val = imgdata.rawdata.raw_image[(row+S.top_margin)*S.raw_pitch/2+(col+S.left_margin)];
1909
+ int cc = fcol(row,col);
1910
+ if(val>cblack[cc])
1911
+ {
1912
+ val-=cblack[cc];
1913
+ if(val>ldmax)ldmax = val;
1914
+ }
1915
+ else
1916
+ val = 0;
1917
+ imgdata.image[((row) >> IO.shrink)*S.iwidth + ((col) >> IO.shrink)][cc] = val;
1918
+ }
1919
+ #if defined(LIBRAW_USE_OPENMP)
1920
+ #pragma omp critical(dataupdate)
1921
+ #endif
1922
+ {
1923
+ if(*dmaxp < ldmax)
1924
+ *dmaxp = ldmax;
1925
+ }
1926
+ }
1927
+ }
1928
+
1929
+
1930
+ int LibRaw::raw2image_ex(int do_subtract_black)
1931
+ {
1932
+
1933
+ CHECK_ORDER_LOW(LIBRAW_PROGRESS_LOAD_RAW);
1934
+
1935
+ try {
1936
+ raw2image_start();
1937
+
1938
+ // Compressed P1 files with bl data!
1939
+ if (is_phaseone_compressed())
1940
+ {
1941
+ phase_one_allocate_tempbuffer();
1942
+ phase_one_subtract_black((ushort*)imgdata.rawdata.raw_alloc,imgdata.rawdata.raw_image);
1943
+ phase_one_correct();
1944
+ }
1945
+
1946
+ // process cropping
1947
+ int do_crop = 0;
1948
+ unsigned save_width = S.width;
1949
+ if (~O.cropbox[2] && ~O.cropbox[3]
1950
+ #ifdef LIBRAW_DEMOSAIC_PACK_GPL2
1951
+ && load_raw != &LibRaw::foveon_sd_load_raw
1952
+ #endif
1953
+ ) // Foveon SD to be cropped later
1954
+ {
1955
+ int crop[4],c,filt;
1956
+ for(int c=0;c<4;c++)
1957
+ {
1958
+ crop[c] = O.cropbox[c];
1959
+ if(crop[c]<0)
1960
+ crop[c]=0;
1961
+ }
1962
+
1963
+ if(IO.fuji_width && imgdata.idata.filters >= 1000)
1964
+ {
1965
+ crop[0] = (crop[0]/4)*4;
1966
+ crop[1] = (crop[1]/4)*4;
1967
+ if(!libraw_internal_data.unpacker_data.fuji_layout)
1968
+ {
1969
+ crop[2]*=sqrt(2.0);
1970
+ crop[3]/=sqrt(2.0);
1971
+ }
1972
+ crop[2] = (crop[2]/4+1)*4;
1973
+ crop[3] = (crop[3]/4+1)*4;
1974
+ }
1975
+ else if (imgdata.idata.filters == 1)
1976
+ {
1977
+ crop[0] = (crop[0]/16)*16;
1978
+ crop[1] = (crop[1]/16)*16;
1979
+ }
1980
+ else if(imgdata.idata.filters == LIBRAW_XTRANS)
1981
+ {
1982
+ crop[0] = (crop[0]/6)*6;
1983
+ crop[1] = (crop[1]/6)*6;
1984
+ }
1985
+ do_crop = 1;
1986
+
1987
+ crop[2] = MIN (crop[2], (signed) S.width-crop[0]);
1988
+ crop[3] = MIN (crop[3], (signed) S.height-crop[1]);
1989
+ if (crop[2] <= 0 || crop[3] <= 0)
1990
+ throw LIBRAW_EXCEPTION_BAD_CROP;
1991
+
1992
+ // adjust sizes!
1993
+ S.left_margin+=crop[0];
1994
+ S.top_margin+=crop[1];
1995
+ S.width=crop[2];
1996
+ S.height=crop[3];
1997
+
1998
+ S.iheight = (S.height + IO.shrink) >> IO.shrink;
1999
+ S.iwidth = (S.width + IO.shrink) >> IO.shrink;
2000
+ if(!IO.fuji_width && imgdata.idata.filters && imgdata.idata.filters >= 1000)
2001
+ {
2002
+ for (filt=c=0; c < 16; c++)
2003
+ filt |= FC((c >> 1)+(crop[1]),
2004
+ (c & 1)+(crop[0])) << c*2;
2005
+ imgdata.idata.filters = filt;
2006
+ }
2007
+ }
2008
+
2009
+ int alloc_width = S.iwidth;
2010
+ int alloc_height = S.iheight;
2011
+
2012
+ if(IO.fuji_width && do_crop)
2013
+ {
2014
+ int IO_fw = S.width >> !libraw_internal_data.unpacker_data.fuji_layout;
2015
+ int t_alloc_width = (S.height >> libraw_internal_data.unpacker_data.fuji_layout) + IO_fw;
2016
+ int t_alloc_height = t_alloc_width - 1;
2017
+ alloc_height = (t_alloc_height + IO.shrink) >> IO.shrink;
2018
+ alloc_width = (t_alloc_width + IO.shrink) >> IO.shrink;
2019
+ }
2020
+ int alloc_sz = alloc_width*alloc_height;
2021
+
2022
+ if(imgdata.image)
2023
+ {
2024
+ imgdata.image = (ushort (*)[4]) realloc (imgdata.image,alloc_sz *sizeof (*imgdata.image));
2025
+ memset(imgdata.image,0,alloc_sz *sizeof (*imgdata.image));
2026
+ }
2027
+ else
2028
+ imgdata.image = (ushort (*)[4]) calloc (alloc_sz, sizeof (*imgdata.image));
2029
+ merror (imgdata.image, "raw2image_ex()");
2030
+
2031
+ libraw_decoder_info_t decoder_info;
2032
+ get_decoder_info(&decoder_info);
2033
+
2034
+ // Adjust black levels
2035
+ unsigned short cblack[4]={0,0,0,0};
2036
+ unsigned short dmax = 0;
2037
+ if(do_subtract_black)
2038
+ {
2039
+ adjust_bl();
2040
+ for(int i=0; i< 4; i++)
2041
+ cblack[i] = (unsigned short)C.cblack[i];
2042
+ }
2043
+
2044
+ // Move saved bitmap to imgdata.image
2045
+ if(imgdata.idata.filters || P1.colors == 1)
2046
+ {
2047
+ if (IO.fuji_width)
2048
+ {
2049
+ if(do_crop)
2050
+ {
2051
+ IO.fuji_width = S.width >> !libraw_internal_data.unpacker_data.fuji_layout;
2052
+ int IO_fwidth = (S.height >> libraw_internal_data.unpacker_data.fuji_layout) + IO.fuji_width;
2053
+ int IO_fheight = IO_fwidth - 1;
2054
+
2055
+ int row,col;
2056
+ for(row=0;row<S.height;row++)
2057
+ {
2058
+ for(col=0;col<S.width;col++)
2059
+ {
2060
+ int r,c;
2061
+ if (libraw_internal_data.unpacker_data.fuji_layout) {
2062
+ r = IO.fuji_width - 1 - col + (row >> 1);
2063
+ c = col + ((row+1) >> 1);
2064
+ } else {
2065
+ r = IO.fuji_width - 1 + row - (col >> 1);
2066
+ c = row + ((col+1) >> 1);
2067
+ }
2068
+
2069
+ unsigned short val = imgdata.rawdata.raw_image[(row+S.top_margin)*S.raw_pitch/2
2070
+ +(col+S.left_margin)];
2071
+ int cc = FCF(row,col);
2072
+ if(val > cblack[cc])
2073
+ {
2074
+ val-=cblack[cc];
2075
+ if(dmax < val) dmax = val;
2076
+ }
2077
+ else
2078
+ val = 0;
2079
+ imgdata.image[((r) >> IO.shrink)*alloc_width + ((c) >> IO.shrink)][cc] = val;
2080
+ }
2081
+ }
2082
+ S.height = IO_fheight;
2083
+ S.width = IO_fwidth;
2084
+ S.iheight = (S.height + IO.shrink) >> IO.shrink;
2085
+ S.iwidth = (S.width + IO.shrink) >> IO.shrink;
2086
+ S.raw_height -= 2*S.top_margin;
2087
+ }
2088
+ else
2089
+ {
2090
+ copy_fuji_uncropped(cblack,&dmax);
2091
+ }
2092
+ } // end Fuji
2093
+ else
2094
+ {
2095
+ copy_bayer(cblack,&dmax);
2096
+ }
2097
+ }
2098
+ else //if(decoder_info.decoder_flags & LIBRAW_DECODER_LEGACY)
2099
+ {
2100
+ if(imgdata.rawdata.color4_image)
2101
+ {
2102
+ if(S.raw_pitch != S.width*8)
2103
+ {
2104
+ for(int row = 0; row < S.height; row++)
2105
+ memmove(&imgdata.image[row*S.width],
2106
+ &imgdata.rawdata.color4_image[(row+S.top_margin)*S.raw_pitch/8+S.left_margin],
2107
+ S.width*sizeof(*imgdata.image));
2108
+ }
2109
+ else
2110
+ {
2111
+ // legacy is always 4channel and not shrinked!
2112
+ memmove(imgdata.image,imgdata.rawdata.color4_image,S.width*S.height*sizeof(*imgdata.image));
2113
+ }
2114
+ }
2115
+ else if(imgdata.rawdata.color3_image)
2116
+ {
2117
+ unsigned char *c3image = (unsigned char*) imgdata.rawdata.color3_image;
2118
+ for(int row = 0; row < S.height; row++)
2119
+ {
2120
+ ushort (*srcrow)[3] = (ushort (*)[3]) &c3image[(row+S.top_margin)*S.raw_pitch];
2121
+ ushort (*dstrow)[4] = (ushort (*)[4]) &imgdata.image[row*S.width];
2122
+ for(int col=0; col < S.width; col++)
2123
+ {
2124
+ for(int c=0; c< 3; c++)
2125
+ dstrow[col][c] = srcrow[S.left_margin+col][c];
2126
+ dstrow[col][3]=0;
2127
+ }
2128
+ }
2129
+ }
2130
+ else
2131
+ {
2132
+ // legacy decoder, but no data?
2133
+ throw LIBRAW_EXCEPTION_DECODE_RAW;
2134
+ }
2135
+ }
2136
+
2137
+ // Free PhaseOne separate copy allocated at function start
2138
+ if (is_phaseone_compressed())
2139
+ {
2140
+ phase_one_free_tempbuffer();
2141
+ }
2142
+ if (load_raw == &CLASS canon_600_load_raw && S.width < S.raw_width)
2143
+ {
2144
+ canon_600_correct();
2145
+ }
2146
+
2147
+ if(do_subtract_black)
2148
+ {
2149
+ C.data_maximum = (int)dmax;
2150
+ C.maximum -= C.black;
2151
+ // ZERO(C.cblack);
2152
+ C.cblack[0]=C.cblack[1]=C.cblack[2]=C.cblack[3]=0;
2153
+ C.black = 0;
2154
+ }
2155
+
2156
+ // hack - clear later flags!
2157
+ imgdata.progress_flags
2158
+ = LIBRAW_PROGRESS_START|LIBRAW_PROGRESS_OPEN | LIBRAW_PROGRESS_RAW2_IMAGE
2159
+ |LIBRAW_PROGRESS_IDENTIFY|LIBRAW_PROGRESS_SIZE_ADJUST|LIBRAW_PROGRESS_LOAD_RAW;
2160
+ return 0;
2161
+ }
2162
+ catch ( LibRaw_exceptions err) {
2163
+ EXCEPTION_HANDLER(err);
2164
+ }
2165
+ }
2166
+
2167
+ #if 1
2168
+
2169
+ libraw_processed_image_t * LibRaw::dcraw_make_mem_thumb(int *errcode)
2170
+ {
2171
+ if(!T.thumb)
2172
+ {
2173
+ if ( !ID.toffset)
2174
+ {
2175
+ if(errcode) *errcode= LIBRAW_NO_THUMBNAIL;
2176
+ }
2177
+ else
2178
+ {
2179
+ if(errcode) *errcode= LIBRAW_OUT_OF_ORDER_CALL;
2180
+ }
2181
+ return NULL;
2182
+ }
2183
+
2184
+ if (T.tformat == LIBRAW_THUMBNAIL_BITMAP)
2185
+ {
2186
+ libraw_processed_image_t * ret =
2187
+ (libraw_processed_image_t *)::malloc(sizeof(libraw_processed_image_t)+T.tlength);
2188
+
2189
+ if(!ret)
2190
+ {
2191
+ if(errcode) *errcode= ENOMEM;
2192
+ return NULL;
2193
+ }
2194
+
2195
+ memset(ret,0,sizeof(libraw_processed_image_t));
2196
+ ret->type = LIBRAW_IMAGE_BITMAP;
2197
+ ret->height = T.theight;
2198
+ ret->width = T.twidth;
2199
+ ret->colors = 3;
2200
+ ret->bits = 8;
2201
+ ret->data_size = T.tlength;
2202
+ memmove(ret->data,T.thumb,T.tlength);
2203
+ if(errcode) *errcode= 0;
2204
+ return ret;
2205
+ }
2206
+ else if (T.tformat == LIBRAW_THUMBNAIL_JPEG)
2207
+ {
2208
+ ushort exif[5];
2209
+ int mk_exif = 0;
2210
+ if(strcmp(T.thumb+6,"Exif")) mk_exif = 1;
2211
+
2212
+ int dsize = T.tlength + mk_exif * (sizeof(exif)+sizeof(tiff_hdr));
2213
+
2214
+ libraw_processed_image_t * ret =
2215
+ (libraw_processed_image_t *)::malloc(sizeof(libraw_processed_image_t)+dsize);
2216
+
2217
+ if(!ret)
2218
+ {
2219
+ if(errcode) *errcode= ENOMEM;
2220
+ return NULL;
2221
+ }
2222
+
2223
+ memset(ret,0,sizeof(libraw_processed_image_t));
2224
+
2225
+ ret->type = LIBRAW_IMAGE_JPEG;
2226
+ ret->data_size = dsize;
2227
+
2228
+ ret->data[0] = 0xff;
2229
+ ret->data[1] = 0xd8;
2230
+ if(mk_exif)
2231
+ {
2232
+ struct tiff_hdr th;
2233
+ memcpy (exif, "\xff\xe1 Exif\0\0", 10);
2234
+ exif[1] = htons (8 + sizeof th);
2235
+ memmove(ret->data+2,exif,sizeof(exif));
2236
+ tiff_head (&th, 0);
2237
+ memmove(ret->data+(2+sizeof(exif)),&th,sizeof(th));
2238
+ memmove(ret->data+(2+sizeof(exif)+sizeof(th)),T.thumb+2,T.tlength-2);
2239
+ }
2240
+ else
2241
+ {
2242
+ memmove(ret->data+2,T.thumb+2,T.tlength-2);
2243
+ }
2244
+ if(errcode) *errcode= 0;
2245
+ return ret;
2246
+
2247
+ }
2248
+ else
2249
+ {
2250
+ if(errcode) *errcode= LIBRAW_UNSUPPORTED_THUMBNAIL;
2251
+ return NULL;
2252
+ }
2253
+ }
2254
+
2255
+
2256
+
2257
+ // jlb
2258
+ // macros for copying pixels to either BGR or RGB formats
2259
+ #define FORBGR for(c=P1.colors-1; c >=0 ; c--)
2260
+ #define FORRGB for(c=0; c < P1.colors ; c++)
2261
+
2262
+ void LibRaw::get_mem_image_format(int* width, int* height, int* colors, int* bps) const
2263
+
2264
+ {
2265
+ if (S.flip & 4) {
2266
+ *width = S.height;
2267
+ *height = S.width;
2268
+ }
2269
+ else {
2270
+ *width = S.width;
2271
+ *height = S.height;
2272
+ }
2273
+ *colors = P1.colors;
2274
+ *bps = O.output_bps;
2275
+ }
2276
+
2277
+ int LibRaw::copy_mem_image(void* scan0, int stride, int bgr)
2278
+
2279
+ {
2280
+ // the image memory pointed to by scan0 is assumed to be in the format returned by get_mem_image_format
2281
+ if((imgdata.progress_flags & LIBRAW_PROGRESS_THUMB_MASK) < LIBRAW_PROGRESS_PRE_INTERPOLATE)
2282
+ return LIBRAW_OUT_OF_ORDER_CALL;
2283
+
2284
+ if(libraw_internal_data.output_data.histogram)
2285
+ {
2286
+ int perc, val, total, t_white=0x2000,c;
2287
+ perc = S.width * S.height * O.auto_bright_thr;
2288
+ if (IO.fuji_width) perc /= 2;
2289
+ if (!((O.highlight & ~2) || O.no_auto_bright))
2290
+ for (t_white=c=0; c < P1.colors; c++) {
2291
+ for (val=0x2000, total=0; --val > 32; )
2292
+ if ((total += libraw_internal_data.output_data.histogram[c][val]) > perc) break;
2293
+ if (t_white < val) t_white = val;
2294
+ }
2295
+ gamma_curve (O.gamm[0], O.gamm[1], 2, (t_white << 3)/O.bright);
2296
+ }
2297
+
2298
+ int s_iheight = S.iheight;
2299
+ int s_iwidth = S.iwidth;
2300
+ int s_width = S.width;
2301
+ int s_hwight = S.height;
2302
+
2303
+ S.iheight = S.height;
2304
+ S.iwidth = S.width;
2305
+
2306
+ if (S.flip & 4) SWAP(S.height,S.width);
2307
+ uchar *ppm;
2308
+ ushort *ppm2;
2309
+ int c, row, col, soff, rstep, cstep;
2310
+
2311
+ soff = flip_index (0, 0);
2312
+ cstep = flip_index (0, 1) - soff;
2313
+ rstep = flip_index (1, 0) - flip_index (0, S.width);
2314
+
2315
+ for (row=0; row < S.height; row++, soff += rstep)
2316
+ {
2317
+ uchar *bufp = ((uchar*)scan0)+row*stride;
2318
+ ppm2 = (ushort*) (ppm = bufp);
2319
+ // keep trivial decisions in the outer loop for speed
2320
+ if (bgr) {
2321
+ if (O.output_bps == 8) {
2322
+ for (col=0; col < S.width; col++, soff += cstep)
2323
+ FORBGR *ppm++ = imgdata.color.curve[imgdata.image[soff][c]]>>8;
2324
+ }
2325
+ else {
2326
+ for (col=0; col < S.width; col++, soff += cstep)
2327
+ FORBGR *ppm2++ = imgdata.color.curve[imgdata.image[soff][c]];
2328
+ }
2329
+ }
2330
+ else {
2331
+ if (O.output_bps == 8) {
2332
+ for (col=0; col < S.width; col++, soff += cstep)
2333
+ FORRGB *ppm++ = imgdata.color.curve[imgdata.image[soff][c]]>>8;
2334
+ }
2335
+ else {
2336
+ for (col=0; col < S.width; col++, soff += cstep)
2337
+ FORRGB *ppm2++ = imgdata.color.curve[imgdata.image[soff][c]];
2338
+ }
2339
+ }
2340
+
2341
+ // bufp += stride; // go to the next line
2342
+ }
2343
+
2344
+ S.iheight = s_iheight;
2345
+ S.iwidth = s_iwidth;
2346
+ S.width = s_width;
2347
+ S.height = s_hwight;
2348
+
2349
+ return 0;
2350
+
2351
+
2352
+ }
2353
+ #undef FORBGR
2354
+ #undef FORRGB
2355
+
2356
+
2357
+
2358
+ libraw_processed_image_t *LibRaw::dcraw_make_mem_image(int *errcode)
2359
+
2360
+ {
2361
+ int width, height, colors, bps;
2362
+ get_mem_image_format(&width, &height, &colors, &bps);
2363
+ int stride = width * (bps/8) * colors;
2364
+ unsigned ds = height * stride;
2365
+ libraw_processed_image_t *ret = (libraw_processed_image_t*)::malloc(sizeof(libraw_processed_image_t)+ds);
2366
+ if(!ret)
2367
+ {
2368
+ if(errcode) *errcode= ENOMEM;
2369
+ return NULL;
2370
+ }
2371
+ memset(ret,0,sizeof(libraw_processed_image_t));
2372
+
2373
+ // metadata init
2374
+ ret->type = LIBRAW_IMAGE_BITMAP;
2375
+ ret->height = height;
2376
+ ret->width = width;
2377
+ ret->colors = colors;
2378
+ ret->bits = bps;
2379
+ ret->data_size = ds;
2380
+ copy_mem_image(ret->data, stride, 0);
2381
+
2382
+ return ret;
2383
+ }
2384
+
2385
+ #undef FORC
2386
+ #undef FORCC
2387
+ #undef SWAP
2388
+ #endif
2389
+
2390
+
2391
+ int LibRaw::dcraw_ppm_tiff_writer(const char *filename)
2392
+ {
2393
+ CHECK_ORDER_LOW(LIBRAW_PROGRESS_LOAD_RAW);
2394
+
2395
+ if(!imgdata.image)
2396
+ return LIBRAW_OUT_OF_ORDER_CALL;
2397
+
2398
+ if(!filename)
2399
+ return ENOENT;
2400
+ FILE *f = fopen(filename,"wb");
2401
+
2402
+ if(!f)
2403
+ return errno;
2404
+
2405
+ try {
2406
+ if(!libraw_internal_data.output_data.histogram)
2407
+ {
2408
+ libraw_internal_data.output_data.histogram =
2409
+ (int (*)[LIBRAW_HISTOGRAM_SIZE]) malloc(sizeof(*libraw_internal_data.output_data.histogram)*4);
2410
+ merror(libraw_internal_data.output_data.histogram,"LibRaw::dcraw_ppm_tiff_writer()");
2411
+ }
2412
+ libraw_internal_data.internal_data.output = f;
2413
+ write_ppm_tiff();
2414
+ SET_PROC_FLAG(LIBRAW_PROGRESS_FLIP);
2415
+ libraw_internal_data.internal_data.output = NULL;
2416
+ fclose(f);
2417
+ return 0;
2418
+ }
2419
+ catch ( LibRaw_exceptions err) {
2420
+ fclose(f);
2421
+ EXCEPTION_HANDLER(err);
2422
+ }
2423
+ }
2424
+
2425
+ void LibRaw::kodak_thumb_loader()
2426
+ {
2427
+ // some kodak cameras
2428
+ ushort s_height = S.height, s_width = S.width,s_iwidth = S.iwidth,s_iheight=S.iheight;
2429
+ ushort s_flags = libraw_internal_data.unpacker_data.load_flags;
2430
+ libraw_internal_data.unpacker_data.load_flags = 12;
2431
+ int s_colors = P1.colors;
2432
+ unsigned s_filters = P1.filters;
2433
+ ushort (*s_image)[4] = imgdata.image;
2434
+
2435
+
2436
+ S.height = T.theight;
2437
+ S.width = T.twidth;
2438
+ P1.filters = 0;
2439
+
2440
+ if (thumb_load_raw == &CLASS kodak_ycbcr_load_raw)
2441
+ {
2442
+ S.height += S.height & 1;
2443
+ S.width += S.width & 1;
2444
+ }
2445
+
2446
+ imgdata.image = (ushort (*)[4]) calloc (S.iheight*S.iwidth, sizeof (*imgdata.image));
2447
+ merror (imgdata.image, "LibRaw::kodak_thumb_loader()");
2448
+
2449
+ ID.input->seek(ID.toffset, SEEK_SET);
2450
+ // read kodak thumbnail into T.image[]
2451
+ try {
2452
+ (this->*thumb_load_raw)();
2453
+ } catch (...)
2454
+ {
2455
+ free(imgdata.image);
2456
+ imgdata.image = s_image;
2457
+
2458
+ T.twidth = 0;
2459
+ S.width = s_width;
2460
+
2461
+ S.iwidth = s_iwidth;
2462
+ S.iheight = s_iheight;
2463
+
2464
+ T.theight = 0;
2465
+ S.height = s_height;
2466
+
2467
+ T.tcolors = 0;
2468
+ P1.colors = s_colors;
2469
+
2470
+ P1.filters = s_filters;
2471
+ T.tlength=0;
2472
+ libraw_internal_data.unpacker_data.load_flags = s_flags;
2473
+ return;
2474
+ }
2475
+
2476
+ // copy-n-paste from image pipe
2477
+ #define MIN(a,b) ((a) < (b) ? (a) : (b))
2478
+ #define MAX(a,b) ((a) > (b) ? (a) : (b))
2479
+ #define LIM(x,min,max) MAX(min,MIN(x,max))
2480
+ #define CLIP(x) LIM(x,0,65535)
2481
+ #define SWAP(a,b) { a ^= b; a ^= (b ^= a); }
2482
+
2483
+ // from scale_colors
2484
+ {
2485
+ double dmax;
2486
+ float scale_mul[4];
2487
+ int c,val;
2488
+ for (dmax=DBL_MAX, c=0; c < 3; c++)
2489
+ if (dmax > C.pre_mul[c])
2490
+ dmax = C.pre_mul[c];
2491
+
2492
+ for( c=0; c< 3; c++)
2493
+ scale_mul[c] = (C.pre_mul[c] / dmax) * 65535.0 / C.maximum;
2494
+ scale_mul[3] = scale_mul[1];
2495
+
2496
+ size_t size = S.height * S.width;
2497
+ for (unsigned i=0; i < size*4 ; i++)
2498
+ {
2499
+ val = imgdata.image[0][i];
2500
+ if(!val) continue;
2501
+ val *= scale_mul[i & 3];
2502
+ imgdata.image[0][i] = CLIP(val);
2503
+ }
2504
+ }
2505
+
2506
+ // from convert_to_rgb
2507
+ ushort *img;
2508
+ int row,col;
2509
+
2510
+ int (*t_hist)[LIBRAW_HISTOGRAM_SIZE] = (int (*)[LIBRAW_HISTOGRAM_SIZE]) calloc(sizeof(*t_hist),4);
2511
+ merror (t_hist, "LibRaw::kodak_thumb_loader()");
2512
+
2513
+ float out[3],
2514
+ out_cam[3][4] =
2515
+ {
2516
+ {2.81761312, -1.98369181, 0.166078627, 0},
2517
+ {-0.111855984, 1.73688626, -0.625030339, 0},
2518
+ {-0.0379119813, -0.891268849, 1.92918086, 0}
2519
+ };
2520
+
2521
+ for (img=imgdata.image[0], row=0; row < S.height; row++)
2522
+ for (col=0; col < S.width; col++, img+=4)
2523
+ {
2524
+ out[0] = out[1] = out[2] = 0;
2525
+ int c;
2526
+ for(c=0;c<3;c++)
2527
+ {
2528
+ out[0] += out_cam[0][c] * img[c];
2529
+ out[1] += out_cam[1][c] * img[c];
2530
+ out[2] += out_cam[2][c] * img[c];
2531
+ }
2532
+ for(c=0; c<3; c++)
2533
+ img[c] = CLIP((int) out[c]);
2534
+ for(c=0; c<P1.colors;c++)
2535
+ t_hist[c][img[c] >> 3]++;
2536
+
2537
+ }
2538
+
2539
+ // from gamma_lut
2540
+ int (*save_hist)[LIBRAW_HISTOGRAM_SIZE] = libraw_internal_data.output_data.histogram;
2541
+ libraw_internal_data.output_data.histogram = t_hist;
2542
+
2543
+ // make curve output curve!
2544
+ ushort (*t_curve) = (ushort*) calloc(sizeof(C.curve),1);
2545
+ merror (t_curve, "LibRaw::kodak_thumb_loader()");
2546
+ memmove(t_curve,C.curve,sizeof(C.curve));
2547
+ memset(C.curve,0,sizeof(C.curve));
2548
+ {
2549
+ int perc, val, total, t_white=0x2000,c;
2550
+
2551
+ perc = S.width * S.height * 0.01; /* 99th percentile white level */
2552
+ if (IO.fuji_width) perc /= 2;
2553
+ if (!((O.highlight & ~2) || O.no_auto_bright))
2554
+ for (t_white=c=0; c < P1.colors; c++) {
2555
+ for (val=0x2000, total=0; --val > 32; )
2556
+ if ((total += libraw_internal_data.output_data.histogram[c][val]) > perc) break;
2557
+ if (t_white < val) t_white = val;
2558
+ }
2559
+ gamma_curve (O.gamm[0], O.gamm[1], 2, (t_white << 3)/O.bright);
2560
+ }
2561
+
2562
+ libraw_internal_data.output_data.histogram = save_hist;
2563
+ free(t_hist);
2564
+
2565
+ // from write_ppm_tiff - copy pixels into bitmap
2566
+
2567
+ S.iheight = S.height;
2568
+ S.iwidth = S.width;
2569
+ if (S.flip & 4) SWAP(S.height,S.width);
2570
+
2571
+ if(T.thumb) free(T.thumb);
2572
+ T.thumb = (char*) calloc (S.width * S.height, P1.colors);
2573
+ merror (T.thumb, "LibRaw::kodak_thumb_loader()");
2574
+ T.tlength = S.width * S.height * P1.colors;
2575
+
2576
+ // from write_tiff_ppm
2577
+ {
2578
+ int soff = flip_index (0, 0);
2579
+ int cstep = flip_index (0, 1) - soff;
2580
+ int rstep = flip_index (1, 0) - flip_index (0, S.width);
2581
+
2582
+ for (int row=0; row < S.height; row++, soff += rstep)
2583
+ {
2584
+ char *ppm = T.thumb + row*S.width*P1.colors;
2585
+ for (int col=0; col < S.width; col++, soff += cstep)
2586
+ for(int c = 0; c < P1.colors; c++)
2587
+ ppm [col*P1.colors+c] = imgdata.color.curve[imgdata.image[soff][c]]>>8;
2588
+ }
2589
+ }
2590
+
2591
+ memmove(C.curve,t_curve,sizeof(C.curve));
2592
+ free(t_curve);
2593
+
2594
+ // restore variables
2595
+ free(imgdata.image);
2596
+ imgdata.image = s_image;
2597
+
2598
+ T.twidth = S.width;
2599
+ S.width = s_width;
2600
+
2601
+ S.iwidth = s_iwidth;
2602
+ S.iheight = s_iheight;
2603
+
2604
+ T.theight = S.height;
2605
+ S.height = s_height;
2606
+
2607
+ T.tcolors = P1.colors;
2608
+ P1.colors = s_colors;
2609
+
2610
+ P1.filters = s_filters;
2611
+ libraw_internal_data.unpacker_data.load_flags = s_flags;
2612
+ }
2613
+ #undef MIN
2614
+ #undef MAX
2615
+ #undef LIM
2616
+ #undef CLIP
2617
+ #undef SWAP
2618
+
2619
+
2620
+ // ������� thumbnail �� �����, ������ thumb_format � ������������ � ��������
2621
+ int LibRaw::unpack_thumb(void)
2622
+ {
2623
+ CHECK_ORDER_LOW(LIBRAW_PROGRESS_IDENTIFY);
2624
+ CHECK_ORDER_BIT(LIBRAW_PROGRESS_THUMB_LOAD);
2625
+
2626
+ try {
2627
+ if(!libraw_internal_data.internal_data.input)
2628
+ return LIBRAW_INPUT_CLOSED;
2629
+
2630
+ if ( !ID.toffset)
2631
+ {
2632
+ return LIBRAW_NO_THUMBNAIL;
2633
+ }
2634
+ else if (thumb_load_raw)
2635
+ {
2636
+ kodak_thumb_loader();
2637
+ T.tformat = LIBRAW_THUMBNAIL_BITMAP;
2638
+ SET_PROC_FLAG(LIBRAW_PROGRESS_THUMB_LOAD);
2639
+ return 0;
2640
+ }
2641
+ else
2642
+ {
2643
+ ID.input->seek(ID.toffset, SEEK_SET);
2644
+ if ( write_thumb == &LibRaw::jpeg_thumb)
2645
+ {
2646
+ if(T.thumb) free(T.thumb);
2647
+ T.thumb = (char *) malloc (T.tlength);
2648
+ merror (T.thumb, "jpeg_thumb()");
2649
+ ID.input->read (T.thumb, 1, T.tlength);
2650
+ T.tcolors = 3;
2651
+ T.tformat = LIBRAW_THUMBNAIL_JPEG;
2652
+ SET_PROC_FLAG(LIBRAW_PROGRESS_THUMB_LOAD);
2653
+ return 0;
2654
+ }
2655
+ else if (write_thumb == &LibRaw::ppm_thumb)
2656
+ {
2657
+ T.tlength = T.twidth * T.theight*3;
2658
+ if(T.thumb) free(T.thumb);
2659
+
2660
+ T.thumb = (char *) malloc (T.tlength);
2661
+ merror (T.thumb, "ppm_thumb()");
2662
+
2663
+ ID.input->read(T.thumb, 1, T.tlength);
2664
+
2665
+ T.tformat = LIBRAW_THUMBNAIL_BITMAP;
2666
+ SET_PROC_FLAG(LIBRAW_PROGRESS_THUMB_LOAD);
2667
+ return 0;
2668
+
2669
+ }
2670
+ else if (write_thumb == &LibRaw::ppm16_thumb)
2671
+ {
2672
+ T.tlength = T.twidth * T.theight*3;
2673
+ ushort *t_thumb = (ushort*)calloc(T.tlength,2);
2674
+ ID.input->read(t_thumb,2,T.tlength);
2675
+ if ((libraw_internal_data.unpacker_data.order == 0x4949) == (ntohs(0x1234) == 0x1234))
2676
+ swab ((char*)t_thumb, (char*)t_thumb, T.tlength*2);
2677
+
2678
+ if(T.thumb) free(T.thumb);
2679
+ T.thumb = (char *) malloc (T.tlength);
2680
+ merror (T.thumb, "ppm_thumb()");
2681
+ for (int i=0; i < T.tlength; i++)
2682
+ T.thumb[i] = t_thumb[i] >> 8;
2683
+ free(t_thumb);
2684
+ T.tformat = LIBRAW_THUMBNAIL_BITMAP;
2685
+ SET_PROC_FLAG(LIBRAW_PROGRESS_THUMB_LOAD);
2686
+ return 0;
2687
+
2688
+ }
2689
+ else if (write_thumb == &LibRaw::x3f_thumb_loader)
2690
+ {
2691
+ x3f_thumb_loader();
2692
+ SET_PROC_FLAG(LIBRAW_PROGRESS_THUMB_LOAD);
2693
+ return 0;
2694
+ }
2695
+ #ifdef LIBRAW_DEMOSAIC_PACK_GPL2
2696
+ else if (write_thumb == &LibRaw::foveon_thumb)
2697
+ {
2698
+ foveon_thumb_loader();
2699
+ // may return with error, so format is set in
2700
+ // foveon thumb loader itself
2701
+ SET_PROC_FLAG(LIBRAW_PROGRESS_THUMB_LOAD);
2702
+ return 0;
2703
+ }
2704
+ // else if -- all other write_thumb cases!
2705
+ #endif
2706
+ else
2707
+ {
2708
+ return LIBRAW_UNSUPPORTED_THUMBNAIL;
2709
+ }
2710
+ }
2711
+ // last resort
2712
+ return LIBRAW_UNSUPPORTED_THUMBNAIL;
2713
+ }
2714
+ catch ( LibRaw_exceptions err) {
2715
+ EXCEPTION_HANDLER(err);
2716
+ }
2717
+
2718
+ }
2719
+
2720
+ int LibRaw::dcraw_thumb_writer(const char *fname)
2721
+ {
2722
+ // CHECK_ORDER_LOW(LIBRAW_PROGRESS_THUMB_LOAD);
2723
+
2724
+ if(!fname)
2725
+ return ENOENT;
2726
+
2727
+ FILE *tfp = fopen(fname,"wb");
2728
+
2729
+ if(!tfp)
2730
+ return errno;
2731
+
2732
+ if(!T.thumb)
2733
+ {
2734
+ fclose(tfp);
2735
+ return LIBRAW_OUT_OF_ORDER_CALL;
2736
+ }
2737
+
2738
+ try {
2739
+ switch (T.tformat)
2740
+ {
2741
+ case LIBRAW_THUMBNAIL_JPEG:
2742
+ jpeg_thumb_writer (tfp,T.thumb,T.tlength);
2743
+ break;
2744
+ case LIBRAW_THUMBNAIL_BITMAP:
2745
+ fprintf (tfp, "P6\n%d %d\n255\n", T.twidth, T.theight);
2746
+ fwrite (T.thumb, 1, T.tlength, tfp);
2747
+ break;
2748
+ default:
2749
+ fclose(tfp);
2750
+ return LIBRAW_UNSUPPORTED_THUMBNAIL;
2751
+ }
2752
+ fclose(tfp);
2753
+ return 0;
2754
+ }
2755
+ catch ( LibRaw_exceptions err) {
2756
+ fclose(tfp);
2757
+ EXCEPTION_HANDLER(err);
2758
+ }
2759
+ }
2760
+
2761
+ int LibRaw::adjust_sizes_info_only(void)
2762
+ {
2763
+ CHECK_ORDER_LOW(LIBRAW_PROGRESS_IDENTIFY);
2764
+
2765
+ raw2image_start();
2766
+ if (O.use_fuji_rotate)
2767
+ {
2768
+ if (IO.fuji_width)
2769
+ {
2770
+ IO.fuji_width = (IO.fuji_width - 1 + IO.shrink) >> IO.shrink;
2771
+ S.iwidth = (ushort)(IO.fuji_width / sqrt(0.5));
2772
+ S.iheight = (ushort)( (S.iheight - IO.fuji_width) / sqrt(0.5));
2773
+ }
2774
+ else
2775
+ {
2776
+ if (S.pixel_aspect < 0.995) S.iheight = (ushort)( S.iheight / S.pixel_aspect + 0.5);
2777
+ if (S.pixel_aspect > 1.005) S.iwidth = (ushort) (S.iwidth * S.pixel_aspect + 0.5);
2778
+ }
2779
+ }
2780
+ SET_PROC_FLAG(LIBRAW_PROGRESS_FUJI_ROTATE);
2781
+ if ( S.flip & 4)
2782
+ {
2783
+ unsigned short t = S.iheight;
2784
+ S.iheight=S.iwidth;
2785
+ S.iwidth = t;
2786
+ SET_PROC_FLAG(LIBRAW_PROGRESS_FLIP);
2787
+ }
2788
+ return 0;
2789
+ }
2790
+
2791
+ int LibRaw::subtract_black()
2792
+ {
2793
+ adjust_bl();
2794
+ return subtract_black_internal();
2795
+ }
2796
+
2797
+ int LibRaw::subtract_black_internal()
2798
+ {
2799
+ CHECK_ORDER_LOW(LIBRAW_PROGRESS_RAW2_IMAGE);
2800
+
2801
+ try {
2802
+ if(!is_phaseone_compressed() && (C.cblack[0] || C.cblack[1] || C.cblack[2] || C.cblack[3] || (C.cblack[4] && C.cblack[5]) ))
2803
+ {
2804
+ #define BAYERC(row,col,c) imgdata.image[((row) >> IO.shrink)*S.iwidth + ((col) >> IO.shrink)][c]
2805
+ int cblk[4],i;
2806
+ for(i=0;i<4;i++)
2807
+ cblk[i] = C.cblack[i];
2808
+
2809
+ int size = S.iheight * S.iwidth;
2810
+ #define MIN(a,b) ((a) < (b) ? (a) : (b))
2811
+ #define MAX(a,b) ((a) > (b) ? (a) : (b))
2812
+ #define LIM(x,min,max) MAX(min,MIN(x,max))
2813
+ #define CLIP(x) LIM(x,0,65535)
2814
+ int dmax = 0;
2815
+ if(C.cblack[4] && C.cblack[5])
2816
+ {
2817
+ for(i=0; i< size*4; i++)
2818
+ {
2819
+ int val = imgdata.image[0][i];
2820
+ val -= C.cblack[6 + i/4 / S.iwidth % C.cblack[4] * C.cblack[5] +
2821
+ i/4 % S.iwidth % C.cblack[5]];
2822
+ val -= cblk[i & 3];
2823
+ imgdata.image[0][i] = CLIP(val);
2824
+ if(dmax < val) dmax = val;
2825
+ }
2826
+ }
2827
+ else
2828
+ {
2829
+ for(i=0; i< size*4; i++)
2830
+ {
2831
+ int val = imgdata.image[0][i];
2832
+ val -= cblk[i & 3];
2833
+ imgdata.image[0][i] = CLIP(val);
2834
+ if(dmax < val) dmax = val;
2835
+ }
2836
+ }
2837
+ C.data_maximum = dmax & 0xffff;
2838
+ #undef MIN
2839
+ #undef MAX
2840
+ #undef LIM
2841
+ #undef CLIP
2842
+ C.maximum -= C.black;
2843
+ ZERO(C.cblack); // Yeah, we used cblack[6+] values too!
2844
+ C.black = 0;
2845
+ #undef BAYERC
2846
+ }
2847
+ else
2848
+ {
2849
+ // Nothing to Do, maximum is already calculated, black level is 0, so no change
2850
+ // only calculate channel maximum;
2851
+ int idx;
2852
+ ushort *p = (ushort*)imgdata.image;
2853
+ int dmax = 0;
2854
+ for(idx=0;idx<S.iheight*S.iwidth*4;idx++)
2855
+ if(dmax < p[idx]) dmax = p[idx];
2856
+ C.data_maximum = dmax;
2857
+ }
2858
+ return 0;
2859
+ }
2860
+ catch ( LibRaw_exceptions err) {
2861
+ EXCEPTION_HANDLER(err);
2862
+ }
2863
+
2864
+ }
2865
+
2866
+ #define TBLN 65535
2867
+
2868
+ void LibRaw::exp_bef(float shift, float smooth)
2869
+ {
2870
+ // params limits
2871
+ if(shift>8) shift = 8;
2872
+ if(shift<0.25) shift = 0.25;
2873
+ if(smooth < 0.0) smooth = 0.0;
2874
+ if(smooth > 1.0) smooth = 1.0;
2875
+
2876
+ unsigned short *lut = (ushort*)malloc((TBLN+1)*sizeof(unsigned short));
2877
+
2878
+ if(shift <=1.0)
2879
+ {
2880
+ for(int i=0;i<=TBLN;i++)
2881
+ lut[i] = (unsigned short)((float)i*shift);
2882
+ }
2883
+ else
2884
+ {
2885
+ float x1,x2,y1,y2;
2886
+
2887
+ float cstops = log(shift)/log(2.0f);
2888
+ float room = cstops*2;
2889
+ float roomlin = powf(2.0f,room);
2890
+ x2 = (float)TBLN;
2891
+ x1 = (x2+1)/roomlin-1;
2892
+ y1 = x1*shift;
2893
+ y2 = x2*(1+(1-smooth)*(shift-1));
2894
+ float sq3x=powf(x1*x1*x2,1.0f/3.0f);
2895
+ float B = (y2-y1+shift*(3*x1-3.0f*sq3x)) / (x2+2.0f*x1-3.0f*sq3x);
2896
+ float A = (shift - B)*3.0f*powf(x1*x1,1.0f/3.0f);
2897
+ float CC = y2 - A*powf(x2,1.0f/3.0f)-B*x2;
2898
+ for(int i=0;i<=TBLN;i++)
2899
+ {
2900
+ float X = (float)i;
2901
+ float Y = A*powf(X,1.0f/3.0f)+B*X+CC;
2902
+ if(i<x1)
2903
+ lut[i] = (unsigned short)((float)i*shift);
2904
+ else
2905
+ lut[i] = Y<0?0:(Y>TBLN?TBLN:(unsigned short)(Y));
2906
+ }
2907
+ }
2908
+ for(int i=0; i< S.height*S.width; i++)
2909
+ {
2910
+ imgdata.image[i][0] = lut[imgdata.image[i][0]];
2911
+ imgdata.image[i][1] = lut[imgdata.image[i][1]];
2912
+ imgdata.image[i][2] = lut[imgdata.image[i][2]];
2913
+ imgdata.image[i][3] = lut[imgdata.image[i][3]];
2914
+ }
2915
+
2916
+ if(C.data_maximum <=TBLN)
2917
+ C.data_maximum = lut[C.data_maximum];
2918
+ if(C.maximum <= TBLN)
2919
+ C.maximum = lut[C.maximum];
2920
+ // no need to adjust the minumum, black is already subtracted
2921
+ free(lut);
2922
+ }
2923
+
2924
+ #define MIN(a,b) ((a) < (b) ? (a) : (b))
2925
+ #define MAX(a,b) ((a) > (b) ? (a) : (b))
2926
+ #define LIM(x,min,max) MAX(min,MIN(x,max))
2927
+ #define ULIM(x,y,z) ((y) < (z) ? LIM(x,y,z) : LIM(x,z,y))
2928
+ #define CLIP(x) LIM(x,0,65535)
2929
+
2930
+ void LibRaw::convert_to_rgb_loop(float out_cam[3][4])
2931
+ {
2932
+ int row,col,c;
2933
+ float out[3];
2934
+ ushort *img;
2935
+ memset(libraw_internal_data.output_data.histogram,0,sizeof(int)*LIBRAW_HISTOGRAM_SIZE*4);
2936
+ for (img=imgdata.image[0], row=0; row < S.height; row++)
2937
+ for (col=0; col < S.width; col++, img+=4) {
2938
+ if (!libraw_internal_data.internal_output_params.raw_color) {
2939
+ out[0] = out[1] = out[2] = 0;
2940
+ for(c=0; c< imgdata.idata.colors; c++) {
2941
+ out[0] += out_cam[0][c] * img[c];
2942
+ out[1] += out_cam[1][c] * img[c];
2943
+ out[2] += out_cam[2][c] * img[c];
2944
+ }
2945
+ for(c=0;c<3;c++) img[c] = CLIP((int) out[c]);
2946
+ }
2947
+ for(c=0; c< imgdata.idata.colors; c++) libraw_internal_data.output_data.histogram[c][img[c] >> 3]++;
2948
+ }
2949
+
2950
+ }
2951
+
2952
+ void LibRaw::scale_colors_loop(float scale_mul[4])
2953
+ {
2954
+ unsigned size = S.iheight*S.iwidth;
2955
+
2956
+
2957
+ if (C.cblack[4] && C.cblack[5])
2958
+ {
2959
+ int val;
2960
+ for (unsigned i=0; i < size*4; i++)
2961
+ {
2962
+ if (!(val = imgdata.image[0][i])) continue;
2963
+ val -= C.cblack[6 + i/4 / S.iwidth % C.cblack[4] * C.cblack[5] +
2964
+ i/4 % S.iwidth % C.cblack[5]];
2965
+ val -= C.cblack[i & 3];
2966
+ val *= scale_mul[i & 3];
2967
+ imgdata.image[0][i] = CLIP(val);
2968
+ }
2969
+ }
2970
+ else if(C.cblack[0]||C.cblack[1]||C.cblack[2]||C.cblack[3])
2971
+ {
2972
+ for (unsigned i=0; i < size*4; i++)
2973
+ {
2974
+ int val = imgdata.image[0][i];
2975
+ if (!val) continue;
2976
+ val -= C.cblack[i & 3];
2977
+ val *= scale_mul[i & 3];
2978
+ imgdata.image[0][i] = CLIP(val);
2979
+ }
2980
+ }
2981
+ else // BL is zero
2982
+ {
2983
+ for (unsigned i=0; i < size*4; i++)
2984
+ {
2985
+ int val = imgdata.image[0][i];
2986
+ val *= scale_mul[i & 3];
2987
+ imgdata.image[0][i] = CLIP(val);
2988
+ }
2989
+ }
2990
+ }
2991
+
2992
+ void LibRaw::adjust_bl()
2993
+ {
2994
+ int clear_repeat=0;
2995
+ if (O.user_black >= 0)
2996
+ {
2997
+ C.black = O.user_black;
2998
+ clear_repeat = 1;
2999
+ }
3000
+ for(int i=0; i<4; i++)
3001
+ if(O.user_cblack[i]>-1000000)
3002
+ {
3003
+ C.cblack[i] = O.user_cblack[i];
3004
+ clear_repeat = 1;
3005
+ }
3006
+
3007
+ if(clear_repeat)
3008
+ C.cblack[4]=C.cblack[5]=0;
3009
+
3010
+ // Add common part to cblack[] early
3011
+ if (imgdata.idata.filters > 1000 && (C.cblack[4]+1)/2 == 1 && (C.cblack[5]+1)/2 == 1)
3012
+ {
3013
+ for(int c=0; c<4; c++)
3014
+ C.cblack[c] += C.cblack[6 + c/2 % C.cblack[4] * C.cblack[5] + c%2 % C.cblack[5]];
3015
+ C.cblack[4]=C.cblack[5]=0;
3016
+ }
3017
+ else if(imgdata.idata.filters <= 1000 && C.cblack[4]==1 && C.cblack[5]==1) // Fuji RAF dng
3018
+ {
3019
+ for(int c=0; c<4; c++)
3020
+ C.cblack[c] += C.cblack[6];
3021
+ C.cblack[4]=C.cblack[5]=0;
3022
+ }
3023
+ // remove common part from C.cblack[]
3024
+ int i = C.cblack[3];
3025
+ int c;
3026
+ for(c=0;c<3;c++) if (i > C.cblack[c]) i = C.cblack[c];
3027
+
3028
+ for(c=0;c<4;c++) C.cblack[c] -= i; // remove common part
3029
+ C.black += i;
3030
+
3031
+ // Now calculate common part for cblack[6+] part and move it to C.black
3032
+
3033
+ if(C.cblack[4] && C.cblack[5])
3034
+ {
3035
+ i = C.cblack[6];
3036
+ for(c=1; c<C.cblack[4]*C.cblack[5]; c++)
3037
+ if(i>C.cblack[6+c]) i = C.cblack[6+c];
3038
+ // Remove i from cblack[6+]
3039
+ int nonz=0;
3040
+ for(c=0; c<C.cblack[4]*C.cblack[5]; c++)
3041
+ {
3042
+ C.cblack[6+c]-=i;
3043
+ if(C.cblack[6+c])nonz++;
3044
+ }
3045
+ C.black +=i;
3046
+ if(!nonz)
3047
+ C.cblack[4] = C.cblack[5] = 0;
3048
+ }
3049
+ for(c=0;c<4;c++) C.cblack[c] += C.black;
3050
+ }
3051
+
3052
+ int LibRaw::dcraw_process(void)
3053
+ {
3054
+ int quality,i;
3055
+
3056
+ int iterations=-1, dcb_enhance=1, noiserd=0;
3057
+ int eeci_refine_fl=0, es_med_passes_fl=0;
3058
+ float cared=0,cablue=0;
3059
+ float linenoise=0;
3060
+ float lclean=0,cclean=0;
3061
+ float thresh=0;
3062
+ float preser=0;
3063
+ float expos=1.0;
3064
+
3065
+
3066
+ CHECK_ORDER_LOW(LIBRAW_PROGRESS_LOAD_RAW);
3067
+ // CHECK_ORDER_HIGH(LIBRAW_PROGRESS_PRE_INTERPOLATE);
3068
+
3069
+ try {
3070
+
3071
+ int no_crop = 1;
3072
+
3073
+ if (~O.cropbox[2] && ~O.cropbox[3])
3074
+ no_crop=0;
3075
+
3076
+ libraw_decoder_info_t di;
3077
+ get_decoder_info(&di);
3078
+
3079
+ bool is_bayer = (imgdata.idata.filters || P1.colors == 1);
3080
+ int subtract_inline = !O.bad_pixels && !O.dark_frame && !O.wf_debanding && is_bayer && !IO.zero_is_bad;
3081
+
3082
+ raw2image_ex(subtract_inline); // allocate imgdata.image and copy data!
3083
+
3084
+ // Adjust sizes
3085
+
3086
+ int save_4color = O.four_color_rgb;
3087
+
3088
+ if (IO.zero_is_bad)
3089
+ {
3090
+ remove_zeroes();
3091
+ SET_PROC_FLAG(LIBRAW_PROGRESS_REMOVE_ZEROES);
3092
+ }
3093
+
3094
+ if(O.bad_pixels && no_crop)
3095
+ {
3096
+ bad_pixels(O.bad_pixels);
3097
+ SET_PROC_FLAG(LIBRAW_PROGRESS_BAD_PIXELS);
3098
+ }
3099
+
3100
+ if (O.dark_frame && no_crop)
3101
+ {
3102
+ subtract (O.dark_frame);
3103
+ SET_PROC_FLAG(LIBRAW_PROGRESS_DARK_FRAME);
3104
+ }
3105
+
3106
+ if (O.wf_debanding)
3107
+ {
3108
+ wf_remove_banding();
3109
+ }
3110
+
3111
+ quality = 2 + !IO.fuji_width;
3112
+
3113
+ if (O.user_qual >= 0) quality = O.user_qual;
3114
+
3115
+ if(!subtract_inline || !C.data_maximum)
3116
+ {
3117
+ adjust_bl();
3118
+ subtract_black_internal();
3119
+ }
3120
+
3121
+ if(!(di.decoder_flags & LIBRAW_DECODER_FIXEDMAXC))
3122
+ adjust_maximum();
3123
+
3124
+ if (O.user_sat > 0) C.maximum = O.user_sat;
3125
+
3126
+ if (P1.is_foveon)
3127
+ {
3128
+ if(load_raw == &LibRaw::x3f_load_raw)
3129
+ {
3130
+ // Filter out zeroes
3131
+ for (int i=0; i < S.height*S.width*4; i++)
3132
+ if ((short) imgdata.image[0][i] < 0) imgdata.image[0][i] = 0;
3133
+ }
3134
+ #ifdef LIBRAW_DEMOSAIC_PACK_GPL2
3135
+ else if(load_raw == &LibRaw::foveon_dp_load_raw)
3136
+ {
3137
+ for (int i=0; i < S.height*S.width*4; i++)
3138
+ if ((short) imgdata.image[0][i] < 0) imgdata.image[0][i] = 0;
3139
+ }
3140
+ else
3141
+ {
3142
+ foveon_interpolate();
3143
+ }
3144
+ #endif
3145
+ SET_PROC_FLAG(LIBRAW_PROGRESS_FOVEON_INTERPOLATE);
3146
+ }
3147
+
3148
+ if (O.green_matching && !O.half_size)
3149
+ {
3150
+ green_matching();
3151
+ }
3152
+
3153
+ if (
3154
+ #ifdef LIBRAW_DEMOSAIC_PACK_GPL2
3155
+ (!P1.is_foveon || O.force_foveon_x3f) &&
3156
+ #endif
3157
+ !O.no_auto_scale)
3158
+ {
3159
+ scale_colors();
3160
+ SET_PROC_FLAG(LIBRAW_PROGRESS_SCALE_COLORS);
3161
+ }
3162
+
3163
+ pre_interpolate();
3164
+
3165
+ SET_PROC_FLAG(LIBRAW_PROGRESS_PRE_INTERPOLATE);
3166
+
3167
+ if (O.dcb_iterations >= 0) iterations = O.dcb_iterations;
3168
+ if (O.dcb_enhance_fl >=0 ) dcb_enhance = O.dcb_enhance_fl;
3169
+ if (O.fbdd_noiserd >=0 ) noiserd = O.fbdd_noiserd;
3170
+ if (O.eeci_refine >=0 ) eeci_refine_fl = O.eeci_refine;
3171
+ if (O.es_med_passes >0 ) es_med_passes_fl = O.es_med_passes;
3172
+
3173
+ // LIBRAW_DEMOSAIC_PACK_GPL3
3174
+
3175
+ if (!O.half_size && O.cfa_green >0) {thresh=O.green_thresh ;green_equilibrate(thresh);}
3176
+ if (O.exp_correc >0) {expos=O.exp_shift ; preser=O.exp_preser; exp_bef(expos,preser);}
3177
+ if (O.ca_correc >0 ) {cablue=O.cablue; cared=O.cared; CA_correct_RT(cablue, cared);}
3178
+ if (O.cfaline >0 ) {linenoise=O.linenoise; cfa_linedn(linenoise);}
3179
+ if (O.cfa_clean >0 ) {lclean=O.lclean; cclean=O.cclean; cfa_impulse_gauss(lclean,cclean);}
3180
+
3181
+ if (P1.filters && !O.no_interpolation)
3182
+ {
3183
+ if (noiserd>0 && P1.colors==3 && P1.filters) fbdd(noiserd);
3184
+ if (quality == 0)
3185
+ lin_interpolate();
3186
+ else if (quality == 1 || P1.colors > 3)
3187
+ vng_interpolate();
3188
+ else if (quality == 2 && P1.filters > 1000)
3189
+ ppg_interpolate();
3190
+ else if (P1.filters == LIBRAW_XTRANS)
3191
+ {
3192
+ // Fuji X-Trans
3193
+ xtrans_interpolate(quality>2?3:1);
3194
+ }
3195
+ else if (quality == 3)
3196
+ ahd_interpolate(); // really don't need it here due to fallback op
3197
+ else if (quality == 4)
3198
+ dcb(iterations, dcb_enhance);
3199
+ // LIBRAW_DEMOSAIC_PACK_GPL2
3200
+ else if (quality == 5)
3201
+ ahd_interpolate_mod();
3202
+ else if (quality == 6)
3203
+ afd_interpolate_pl(2,1);
3204
+ else if (quality == 7)
3205
+ vcd_interpolate(0);
3206
+ else if (quality == 8)
3207
+ vcd_interpolate(12);
3208
+ else if (quality == 9)
3209
+ lmmse_interpolate(1);
3210
+
3211
+ // LIBRAW_DEMOSAIC_PACK_GPL3
3212
+ else if (quality == 10)
3213
+ amaze_demosaic_RT();
3214
+ // LGPL2
3215
+ else if (quality == 11)
3216
+ dht_interpolate();
3217
+ else if (quality == 12)
3218
+ aahd_interpolate();
3219
+ // fallback to AHD
3220
+ else
3221
+ {
3222
+ ahd_interpolate();
3223
+ imgdata.process_warnings |= LIBRAW_WARN_FALLBACK_TO_AHD;
3224
+ }
3225
+
3226
+
3227
+ SET_PROC_FLAG(LIBRAW_PROGRESS_INTERPOLATE);
3228
+ }
3229
+ if (IO.mix_green)
3230
+ {
3231
+ for (P1.colors=3, i=0; i < S.height * S.width; i++)
3232
+ imgdata.image[i][1] = (imgdata.image[i][1] + imgdata.image[i][3]) >> 1;
3233
+ SET_PROC_FLAG(LIBRAW_PROGRESS_MIX_GREEN);
3234
+ }
3235
+
3236
+ if(!P1.is_foveon)
3237
+ {
3238
+ if (P1.colors == 3)
3239
+ {
3240
+
3241
+ if (quality == 8)
3242
+ {
3243
+ if (eeci_refine_fl == 1) refinement();
3244
+ if (O.med_passes > 0) median_filter_new();
3245
+ if (es_med_passes_fl > 0) es_median_filter();
3246
+ }
3247
+ else {
3248
+ median_filter();
3249
+ }
3250
+ SET_PROC_FLAG(LIBRAW_PROGRESS_MEDIAN_FILTER);
3251
+ }
3252
+ }
3253
+
3254
+ if (O.highlight == 2)
3255
+ {
3256
+ blend_highlights();
3257
+ SET_PROC_FLAG(LIBRAW_PROGRESS_HIGHLIGHTS);
3258
+ }
3259
+
3260
+ if (O.highlight > 2)
3261
+ {
3262
+ recover_highlights();
3263
+ SET_PROC_FLAG(LIBRAW_PROGRESS_HIGHLIGHTS);
3264
+ }
3265
+
3266
+ if (O.use_fuji_rotate)
3267
+ {
3268
+ fuji_rotate();
3269
+ SET_PROC_FLAG(LIBRAW_PROGRESS_FUJI_ROTATE);
3270
+ }
3271
+
3272
+ if(!libraw_internal_data.output_data.histogram)
3273
+ {
3274
+ libraw_internal_data.output_data.histogram = (int (*)[LIBRAW_HISTOGRAM_SIZE]) malloc(sizeof(*libraw_internal_data.output_data.histogram)*4);
3275
+ merror(libraw_internal_data.output_data.histogram,"LibRaw::dcraw_process()");
3276
+ }
3277
+ #ifndef NO_LCMS
3278
+ if(O.camera_profile)
3279
+ {
3280
+ apply_profile(O.camera_profile,O.output_profile);
3281
+ SET_PROC_FLAG(LIBRAW_PROGRESS_APPLY_PROFILE);
3282
+ }
3283
+ #endif
3284
+
3285
+ convert_to_rgb();
3286
+ SET_PROC_FLAG(LIBRAW_PROGRESS_CONVERT_RGB);
3287
+
3288
+ if (O.use_fuji_rotate)
3289
+ {
3290
+ stretch();
3291
+ SET_PROC_FLAG(LIBRAW_PROGRESS_STRETCH);
3292
+ }
3293
+ O.four_color_rgb = save_4color; // also, restore
3294
+
3295
+ return 0;
3296
+ }
3297
+ catch ( LibRaw_exceptions err) {
3298
+ EXCEPTION_HANDLER(err);
3299
+ }
3300
+ }
3301
+
3302
+ // Supported cameras:
3303
+ static const char *static_camera_list[] =
3304
+ {
3305
+ "Adobe Digital Negative (DNG)",
3306
+ "AgfaPhoto DC-833m",
3307
+ "Alcatel 5035D",
3308
+ "Apple QuickTake 100",
3309
+ "Apple QuickTake 150",
3310
+ "Apple QuickTake 200",
3311
+ "ARRIRAW format",
3312
+ "AVT F-080C",
3313
+ "AVT F-145C",
3314
+ "AVT F-201C",
3315
+ "AVT F-510C",
3316
+ "AVT F-810C",
3317
+ "Baumer TXG14",
3318
+ "BlackMagic Cinema Camera",
3319
+ "BlackMagic Pocket Cinema Camera",
3320
+ "BlackMagic Production Camera 4k",
3321
+ "Canon PowerShot 600",
3322
+ "Canon PowerShot A5",
3323
+ "Canon PowerShot A5 Zoom",
3324
+ "Canon PowerShot A50",
3325
+ "Canon PowerShot A460 (CHDK hack)",
3326
+ "Canon PowerShot A470 (CHDK hack)",
3327
+ "Canon PowerShot A530 (CHDK hack)",
3328
+ "Canon PowerShot A550 (CHDK hack)",
3329
+ "Canon PowerShot A570 (CHDK hack)",
3330
+ "Canon PowerShot A590 (CHDK hack)",
3331
+ "Canon PowerShot A610 (CHDK hack)",
3332
+ "Canon PowerShot A620 (CHDK hack)",
3333
+ "Canon PowerShot A630 (CHDK hack)",
3334
+ "Canon PowerShot A640 (CHDK hack)",
3335
+ "Canon PowerShot A650 (CHDK hack)",
3336
+ "Canon PowerShot A710 IS (CHDK hack)",
3337
+ "Canon PowerShot A720 IS (CHDK hack)",
3338
+ "Canon PowerShot A3300 IS (CHDK hack)",
3339
+ "Canon PowerShot Pro70",
3340
+ "Canon PowerShot Pro90 IS",
3341
+ "Canon PowerShot Pro1",
3342
+ "Canon PowerShot G1",
3343
+ "Canon PowerShot G1 X",
3344
+ "Canon PowerShot G1 X Mark II",
3345
+ "Canon PowerShot G2",
3346
+ "Canon PowerShot G3",
3347
+ "Canon PowerShot G5",
3348
+ "Canon PowerShot G6",
3349
+ "Canon PowerShot G7 (CHDK hack)",
3350
+ "Canon PowerShot G7 X",
3351
+ "Canon PowerShot G9",
3352
+ "Canon PowerShot G10",
3353
+ "Canon PowerShot G11",
3354
+ "Canon PowerShot G12",
3355
+ "Canon PowerShot G15",
3356
+ "Canon PowerShot G16",
3357
+ "Canon PowerShot S2 IS (CHDK hack)",
3358
+ "Canon PowerShot S3 IS (CHDK hack)",
3359
+ "Canon PowerShot S5 IS (CHDK hack)",
3360
+ "Canon PowerShot SD300 (CHDK hack)",
3361
+ "Canon PowerShot SD950 (CHDK hack)",
3362
+ "Canon PowerShot S30",
3363
+ "Canon PowerShot S40",
3364
+ "Canon PowerShot S45",
3365
+ "Canon PowerShot S50",
3366
+ "Canon PowerShot S60",
3367
+ "Canon PowerShot S70",
3368
+ "Canon PowerShot S90",
3369
+ "Canon PowerShot S95",
3370
+ "Canon PowerShot S100",
3371
+ "Canon PowerShot S110",
3372
+ "Canon PowerShot S120",
3373
+ "Canon PowerShot SX1 IS",
3374
+ "Canon PowerShot SX50 HS",
3375
+ "Canon PowerShot SX60 HS",
3376
+ "Canon PowerShot SX110 IS (CHDK hack)",
3377
+ "Canon PowerShot SX120 IS (CHDK hack)",
3378
+ "Canon PowerShot SX220 HS (CHDK hack)",
3379
+ "Canon PowerShot SX20 IS (CHDK hack)",
3380
+ "Canon PowerShot SX30 IS (CHDK hack)",
3381
+ "Canon EOS D30",
3382
+ "Canon EOS D60",
3383
+ "Canon EOS 5D",
3384
+ "Canon EOS 5D Mark II",
3385
+ "Canon EOS 5D Mark III",
3386
+ "Canon EOS 6D",
3387
+ "Canon EOS 7D",
3388
+ "Canon EOS 7D Mark II",
3389
+ "Canon EOS 10D",
3390
+ "Canon EOS 20D",
3391
+ "Canon EOS 20Da",
3392
+ "Canon EOS 30D",
3393
+ "Canon EOS 40D",
3394
+ "Canon EOS 50D",
3395
+ "Canon EOS 60D",
3396
+ "Canon EOS 60Da",
3397
+ "Canon EOS 70D",
3398
+ "Canon EOS 300D / Digital Rebel / Kiss Digital",
3399
+ "Canon EOS 350D / Digital Rebel XT / Kiss Digital N",
3400
+ "Canon EOS 400D / Digital Rebel XTi / Kiss Digital X",
3401
+ "Canon EOS 450D / Digital Rebel XSi / Kiss Digital X2",
3402
+ "Canon EOS 500D / Digital Rebel T1i / Kiss Digital X3",
3403
+ "Canon EOS 550D / Digital Rebel T2i / Kiss Digital X4",
3404
+ "Canon EOS 600D / Digital Rebel T3i / Kiss Digital X5",
3405
+ "Canon EOS 650D / Digital Rebel T4i / Kiss Digital X6i",
3406
+ "Canon EOS 700D / Digital Rebel T5i",
3407
+ "Canon EOS 100D / Digital Rebel SL1",
3408
+ "Canon EOS 1000D / Digital Rebel XS / Kiss Digital F",
3409
+ "Canon EOS 1100D / Digital Rebel T3 / Kiss Digital X50",
3410
+ "Canon EOS 1200D",
3411
+ "Canon EOS C500",
3412
+ "Canon EOS D2000C",
3413
+ "Canon EOS M",
3414
+ "Canon EOS-1D",
3415
+ "Canon EOS-1DS",
3416
+ "Canon EOS-1D C",
3417
+ "Canon EOS-1D X",
3418
+ "Canon EOS-1D Mark II",
3419
+ "Canon EOS-1D Mark II N",
3420
+ "Canon EOS-1D Mark III",
3421
+ "Canon EOS-1D Mark IV",
3422
+ "Canon EOS-1Ds Mark II",
3423
+ "Canon EOS-1Ds Mark III",
3424
+ "Casio QV-2000UX",
3425
+ "Casio QV-3000EX",
3426
+ "Casio QV-3500EX",
3427
+ "Casio QV-4000",
3428
+ "Casio QV-5700",
3429
+ "Casio QV-R41",
3430
+ "Casio QV-R51",
3431
+ "Casio QV-R61",
3432
+ "Casio EX-F1",
3433
+ "Casio EX-FC300S",
3434
+ "Casio EX-FC400S",
3435
+ "Casio EX-FH20",
3436
+ "Casio EX-FH25",
3437
+ "Casio EX-FH100",
3438
+ "Casio EX-S20",
3439
+ "Casio EX-S100",
3440
+ "Casio EX-Z4",
3441
+ "Casio EX-Z50",
3442
+ "Casio EX-Z500",
3443
+ "Casio EX-Z55",
3444
+ "Casio EX-Z60",
3445
+ "Casio EX-Z75",
3446
+ "Casio EX-Z750",
3447
+ "Casio EX-Z8",
3448
+ "Casio EX-Z850",
3449
+ "Casio EX-Z1050",
3450
+ "Casio EX-ZR100",
3451
+ "Casio EX-Z1080",
3452
+ "Casio EX-ZR700",
3453
+ "Casio EX-ZR710",
3454
+ "Casio EX-ZR750",
3455
+ "Casio EX-ZR800",
3456
+ "Casio EX-ZR850",
3457
+ "Casio EX-ZR1000",
3458
+ "Casio EX-ZR1100",
3459
+ "Casio EX-ZR1200",
3460
+ "Casio EX-ZR1300",
3461
+ "Casio EX-ZR1500",
3462
+ "Casio EX-100",
3463
+ "Casio EX-10",
3464
+ "Casio Exlim Pro 505",
3465
+ "Casio Exlim Pro 600",
3466
+ "Casio Exlim Pro 700",
3467
+ "Contax N Digital",
3468
+ "Creative PC-CAM 600",
3469
+ "Digital Bolex D16",
3470
+ "Digital Bolex D16M",
3471
+ "DJI 4384x3288",
3472
+ "Epson R-D1",
3473
+ "Epson R-D1s",
3474
+ "Epson R-D1x",
3475
+ "Foculus 531C",
3476
+ "FujiFilm E505",
3477
+ "FujiFilm E900",
3478
+ "FujiFilm F700",
3479
+ "FujiFilm F710",
3480
+ "FujiFilm F800",
3481
+ "FujiFilm F810",
3482
+ "FujiFilm S2Pro",
3483
+ "FujiFilm S3Pro",
3484
+ "FujiFilm S5Pro",
3485
+ "FujiFilm S20Pro",
3486
+ "FujiFilm S1",
3487
+ "FujiFilm S100FS",
3488
+ "FujiFilm S5000",
3489
+ "FujiFilm S5100/S5500",
3490
+ "FujiFilm S5200/S5600",
3491
+ "FujiFilm S6000fd",
3492
+ "FujiFilm S7000",
3493
+ "FujiFilm S9000/S9500",
3494
+ "FujiFilm S9100/S9600",
3495
+ "FujiFilm S200EXR",
3496
+ "FujiFilm S205EXR",
3497
+ "FujiFilm SL1000",
3498
+ "FujiFilm HS10",
3499
+ "FujiFilm HS11",
3500
+ "FujiFilm HS20EXR",
3501
+ "FujiFilm HS22EXR",
3502
+ "FujiFilm HS30EXR",
3503
+ "FujiFilm HS33EXR",
3504
+ "FujiFilm HS35EXR",
3505
+ "FujiFilm HS50EXR",
3506
+ "FujiFilm F505EXR",
3507
+ "FujiFilm F550EXR",
3508
+ "FujiFilm F600EXR",
3509
+ "FujiFilm F605EXR",
3510
+ "FujiFilm F770EXR",
3511
+ "FujiFilm F775EXR",
3512
+ "FujiFilm F800EXR",
3513
+ "FujiFilm F900EXR",
3514
+ "FujiFilm X-Pro1",
3515
+ "FujiFilm X-S1",
3516
+ "FujiFilm XQ1",
3517
+ "FujiFilm X100",
3518
+ "FujiFilm X100S",
3519
+ "FujiFilm X100T",
3520
+ "FujiFilm X10",
3521
+ "FujiFilm X20",
3522
+ "FujiFilm X30",
3523
+ "FujiFilm X-A1",
3524
+ "FujiFilm X-E1",
3525
+ "FujiFilm X-E2",
3526
+ "FujiFilm X-M1",
3527
+ "FujiFilm XF1",
3528
+ "FujiFilm X-T1",
3529
+ "FujiFilm X-T1 Graphite Silver",
3530
+ "FujiFilm IS-1",
3531
+ "Hasselblad H5D-60",
3532
+ "Hasselblad H5D-50",
3533
+ "Hasselblad H5D-50c",
3534
+ "Hasselblad H5D-40",
3535
+ "Hasselblad H4D-60",
3536
+ "Hasselblad H4D-50",
3537
+ "Hasselblad H4D-40",
3538
+ "Hasselblad H4D-31",
3539
+ "Hasselblad H3DII-22",
3540
+ "Hasselblad H3DII-31",
3541
+ "Hasselblad H3DII-39",
3542
+ "Hasselblad H3DII-50",
3543
+ "Hasselblad H3D-22",
3544
+ "Hasselblad H3D-31",
3545
+ "Hasselblad H3D-39",
3546
+ "Hasselblad H2D-22",
3547
+ "Hasselblad H2D-39",
3548
+ "Hasselblad CFV",
3549
+ "Hasselblad CFH",
3550
+ "Hasselblad CF-22",
3551
+ "Hasselblad CF-31",
3552
+ "Hasselblad CF-39",
3553
+ "Hasselblad V96C",
3554
+ "Hasselblad Lunar",
3555
+ "Hasselblad Stellar",
3556
+ "Hasselblad Stellar II",
3557
+ "Hasselblad HV",
3558
+ "HTC UltraPixel",
3559
+ "Imacon Ixpress 96, 96C",
3560
+ "Imacon Ixpress 384, 384C (single shot only)",
3561
+ "Imacon Ixpress 132C",
3562
+ "Imacon Ixpress 528C (single shot only)",
3563
+ "ISG 2020x1520",
3564
+ "Ikonoskop A-Cam dII Panchromatic",
3565
+ "Ikonoskop A-Cam dII",
3566
+ "Kinefinity KineMINI",
3567
+ "Kinefinity KineRAW Mini",
3568
+ "Kinefinity KineRAW S35",
3569
+ "Kodak DC20",
3570
+ "Kodak DC25",
3571
+ "Kodak DC40",
3572
+ "Kodak DC50",
3573
+ "Kodak DC120",
3574
+ "Kodak DCS200",
3575
+ "Kodak DCS315C",
3576
+ "Kodak DCS330C",
3577
+ "Kodak DCS420",
3578
+ "Kodak DCS460",
3579
+ "Kodak DCS460A",
3580
+ "Kodak DCS460D",
3581
+ "Kodak DCS520C",
3582
+ "Kodak DCS560C",
3583
+ "Kodak DCS620C",
3584
+ "Kodak DCS620X",
3585
+ "Kodak DCS660C",
3586
+ "Kodak DCS660M",
3587
+ "Kodak DCS720X",
3588
+ "Kodak DCS760C",
3589
+ "Kodak DCS760M",
3590
+ "Kodak EOSDCS1",
3591
+ "Kodak EOSDCS3B",
3592
+ "Kodak NC2000F",
3593
+ "Kodak ProBack",
3594
+ "Kodak PB645C",
3595
+ "Kodak PB645H",
3596
+ "Kodak PB645M",
3597
+ "Kodak DCS Pro 14n",
3598
+ "Kodak DCS Pro 14nx",
3599
+ "Kodak DCS Pro SLR/c",
3600
+ "Kodak DCS Pro SLR/n",
3601
+ "Kodak C330",
3602
+ "Kodak C603",
3603
+ "Kodak P850",
3604
+ "Kodak P880",
3605
+ "Kodak S-1",
3606
+ "Kodak Z980",
3607
+ "Kodak Z981",
3608
+ "Kodak Z990",
3609
+ "Kodak Z1015",
3610
+ "Kodak KAI-0340",
3611
+ "Konica KD-400Z",
3612
+ "Konica KD-510Z",
3613
+ "Leaf AFi 7",
3614
+ "Leaf AFi-II 5",
3615
+ "Leaf AFi-II 6",
3616
+ "Leaf AFi-II 7",
3617
+ "Leaf AFi-II 8",
3618
+ "Leaf AFi-II 10",
3619
+ "Leaf AFi-II 10R",
3620
+ "Leaf AFi-II 12",
3621
+ "Leaf AFi-II 12R",
3622
+ "Leaf Aptus 17",
3623
+ "Leaf Aptus 22",
3624
+ "Leaf Aptus 54S",
3625
+ "Leaf Aptus 65",
3626
+ "Leaf Aptus 75",
3627
+ "Leaf Aptus 75S",
3628
+ "Leaf Cantare",
3629
+ "Leaf CatchLight",
3630
+ "Leaf CMost",
3631
+ "Leaf Credo 40",
3632
+ "Leaf Credo 50",
3633
+ "Leaf Credo 60",
3634
+ "Leaf Credo 80",
3635
+ "Leaf DCB2",
3636
+ "Leaf Valeo 6",
3637
+ "Leaf Valeo 11",
3638
+ "Leaf Valeo 17",
3639
+ "Leaf Valeo 22",
3640
+ "Leaf Volare",
3641
+ "Lenovo a820",
3642
+ "Leica C (Typ 112)",
3643
+ "Leica Digilux 2",
3644
+ "Leica Digilux 3",
3645
+ "Leica Digital-Modul-R",
3646
+ "Leica D-LUX2",
3647
+ "Leica D-LUX3",
3648
+ "Leica D-LUX4",
3649
+ "Leica D-LUX5",
3650
+ "Leica D-LUX6",
3651
+ "Leica D-Lux (Typ 109)",
3652
+ "Leica M8",
3653
+ "Leica M8.2",
3654
+ "Leica M9",
3655
+ "Leica M (Typ 240)",
3656
+ "Leica Monochrom (Typ 240)",
3657
+ "Leica M-E",
3658
+ "Leica M-P",
3659
+ "Leica R8",
3660
+ "Leica S",
3661
+ "Leica S2",
3662
+ //"Leica S3",
3663
+ "Leica T (Typ 701)",
3664
+ "Leica X1",
3665
+ "Leica X (Typ 113)",
3666
+ "Leica X2",
3667
+ "Leica X-E (Typ 102)",
3668
+ "Leica V-LUX1",
3669
+ "Leica V-LUX2",
3670
+ "Leica V-LUX3",
3671
+ "Leica V-LUX4",
3672
+ "Leica V-Lux (Typ 114)",
3673
+ "Leica X VARIO (Typ 107)",
3674
+ "Logitech Fotoman Pixtura",
3675
+ "Mamiya ZD",
3676
+ "Matrix 4608x3288",
3677
+ "Micron 2010",
3678
+ "Minolta RD175",
3679
+ "Minolta DiMAGE 5",
3680
+ "Minolta DiMAGE 7",
3681
+ "Minolta DiMAGE 7i",
3682
+ "Minolta DiMAGE 7Hi",
3683
+ "Minolta DiMAGE A1",
3684
+ "Minolta DiMAGE A2",
3685
+ "Minolta DiMAGE A200",
3686
+ "Minolta DiMAGE G400",
3687
+ "Minolta DiMAGE G500",
3688
+ "Minolta DiMAGE G530",
3689
+ "Minolta DiMAGE G600",
3690
+ "Minolta DiMAGE Z2",
3691
+ "Minolta Alpha/Dynax/Maxxum 5D",
3692
+ "Minolta Alpha/Dynax/Maxxum 7D",
3693
+ "Motorola PIXL",
3694
+ "Nikon D1",
3695
+ "Nikon D1H",
3696
+ "Nikon D1X",
3697
+ "Nikon D2H",
3698
+ "Nikon D2Hs",
3699
+ "Nikon D2X",
3700
+ "Nikon D2Xs",
3701
+ "Nikon D3",
3702
+ "Nikon D3s",
3703
+ "Nikon D3X",
3704
+ "Nikon D4",
3705
+ "Nikon D4s",
3706
+ "Nikon D40",
3707
+ "Nikon D40X",
3708
+ "Nikon D50",
3709
+ "Nikon D60",
3710
+ "Nikon D70",
3711
+ "Nikon D70s",
3712
+ "Nikon D80",
3713
+ "Nikon D90",
3714
+ "Nikon D100",
3715
+ "Nikon D200",
3716
+ "Nikon D300",
3717
+ "Nikon D300s",
3718
+ "Nikon D600",
3719
+ "Nikon D610",
3720
+ "Nikon D700",
3721
+ "Nikon D750",
3722
+ "Nikon D800",
3723
+ "Nikon D800E",
3724
+ "Nikon D810",
3725
+ "Nikon D3000",
3726
+ "Nikon D3100",
3727
+ "Nikon D3200",
3728
+ "Nikon D3300",
3729
+ "Nikon D5000",
3730
+ "Nikon D5100",
3731
+ "Nikon D5200",
3732
+ "Nikon D5300",
3733
+ "Nikon D5500",
3734
+ "Nikon D7000",
3735
+ "Nikon D7100",
3736
+ "Nikon Df",
3737
+ "Nikon 1 AW1",
3738
+ "Nikon 1 J1",
3739
+ "Nikon 1 J2",
3740
+ "Nikon 1 J3",
3741
+ "Nikon 1 J4",
3742
+ "Nikon 1 S1",
3743
+ "Nikon 1 S2",
3744
+ "Nikon 1 V1",
3745
+ "Nikon 1 V2",
3746
+ "Nikon 1 V3",
3747
+ "Nikon E700 (\"DIAG RAW\" hack)",
3748
+ "Nikon E800 (\"DIAG RAW\" hack)",
3749
+ "Nikon E880 (\"DIAG RAW\" hack)",
3750
+ "Nikon E900 (\"DIAG RAW\" hack)",
3751
+ "Nikon E950 (\"DIAG RAW\" hack)",
3752
+ "Nikon E990 (\"DIAG RAW\" hack)",
3753
+ "Nikon E995 (\"DIAG RAW\" hack)",
3754
+ "Nikon E2100 (\"DIAG RAW\" hack)",
3755
+ "Nikon E2500 (\"DIAG RAW\" hack)",
3756
+ "Nikon E3200 (\"DIAG RAW\" hack)",
3757
+ "Nikon E3700 (\"DIAG RAW\" hack)",
3758
+ "Nikon E4300 (\"DIAG RAW\" hack)",
3759
+ "Nikon E4500 (\"DIAG RAW\" hack)",
3760
+ "Nikon E5000",
3761
+ "Nikon E5400",
3762
+ "Nikon E5700",
3763
+ "Nikon E8400",
3764
+ "Nikon E8700",
3765
+ "Nikon E8800",
3766
+ "Nikon Coolpix A",
3767
+ "Nikon Coolpix P330",
3768
+ "Nikon Coolpix P340",
3769
+ "Nikon Coolpix P6000",
3770
+ "Nikon Coolpix P7000",
3771
+ "Nikon Coolpix P7100",
3772
+ "Nikon Coolpix P7700",
3773
+ "Nikon Coolpix P7800",
3774
+ "Nikon Coolpix S6 (\"DIAG RAW\" hack)",
3775
+ "Nikon Coolscan NEF",
3776
+ "Nokia N95",
3777
+ "Nokia X2",
3778
+ "Nokia 1200x1600",
3779
+ "Nokia Lumia 1020",
3780
+ "Nokia Lumia 1520",
3781
+ "Olympus C3030Z",
3782
+ "Olympus C5050Z",
3783
+ "Olympus C5060Z",
3784
+ "Olympus C7070WZ",
3785
+ "Olympus C70Z,C7000Z",
3786
+ "Olympus C740UZ",
3787
+ "Olympus C770UZ",
3788
+ "Olympus C8080WZ",
3789
+ "Olympus X200,D560Z,C350Z",
3790
+ "Olympus E-1",
3791
+ "Olympus E-3",
3792
+ "Olympus E-5",
3793
+ "Olympus E-10",
3794
+ "Olympus E-20",
3795
+ "Olympus E-30",
3796
+ "Olympus E-300",
3797
+ "Olympus E-330",
3798
+ "Olympus E-400",
3799
+ "Olympus E-410",
3800
+ "Olympus E-420",
3801
+ "Olympus E-450",
3802
+ "Olympus E-500",
3803
+ "Olympus E-510",
3804
+ "Olympus E-520",
3805
+ "Olympus E-600",
3806
+ "Olympus E-620",
3807
+ "Olympus E-P1",
3808
+ "Olympus E-P2",
3809
+ "Olympus E-P3",
3810
+ "Olympus E-P5",
3811
+ "Olympus E-PL1",
3812
+ "Olympus E-PL1s",
3813
+ "Olympus E-PL2",
3814
+ "Olympus E-PL3",
3815
+ "Olympus E-PL5",
3816
+ "Olympus E-PL6",
3817
+ "Olympus E-PL7",
3818
+ "Olympus E-PM1",
3819
+ "Olympus E-PM2",
3820
+ "Olympus E-M1",
3821
+ "Olympus E-M10",
3822
+ "Olympus E-M5",
3823
+ "Olympus E-M5 Mark II",
3824
+ "Olympus SP310",
3825
+ "Olympus SP320",
3826
+ "Olympus SP350",
3827
+ "Olympus SP500UZ",
3828
+ "Olympus SP510UZ",
3829
+ "Olympus SP550UZ",
3830
+ "Olympus SP560UZ",
3831
+ "Olympus SP565UZ",
3832
+ "Olympus SP570UZ",
3833
+ "Olympus STYLUS1",
3834
+ "Olympus STYLUS1s",
3835
+ "Olympus XZ-1",
3836
+ "Olympus XZ-2",
3837
+ "Olympus XZ-10",
3838
+ "OmniVision OV5647 (Raspberry Pi)",
3839
+ "Panasonic DMC-CM1",
3840
+ "Panasonic DMC-FZ8",
3841
+ "Panasonic DMC-FZ18",
3842
+ "Panasonic DMC-FZ28",
3843
+ "Panasonic DMC-FZ30",
3844
+ "Panasonic DMC-FZ35/FZ38",
3845
+ "Panasonic DMC-FZ40",
3846
+ "Panasonic DMC-FZ50",
3847
+ "Panasonic DMC-FZ7",
3848
+ "Panasonic DMC-FZ70",
3849
+ "Panasonic DMC-FZ100",
3850
+ "Panasonic DMC-FZ150",
3851
+ "Panasonic DMC-FZ200",
3852
+ "Panasonic DMC-FZ1000",
3853
+ "Panasonic DMC-FX150",
3854
+ "Panasonic DMC-G1",
3855
+ "Panasonic DMC-G10",
3856
+ "Panasonic DMC-G2",
3857
+ "Panasonic DMC-G3",
3858
+ "Panasonic DMC-G5",
3859
+ "Panasonic DMC-G6",
3860
+ "Panasonic DMC-GF1",
3861
+ "Panasonic DMC-GF2",
3862
+ "Panasonic DMC-GF3",
3863
+ //"Panasonic DMC-GF3KK",
3864
+ "Panasonic DMC-GF5",
3865
+ "Panasonic DMC-GF6",
3866
+ "Panasonic DMC-GF7",
3867
+ "Panasonic DMC-GH1",
3868
+ "Panasonic DMC-GH2",
3869
+ "Panasonic DMC-GH3",
3870
+ "Panasonic DMC-GH4",
3871
+ "Panasonic AG-GH4",
3872
+ "Panasonic DMC-GM1",
3873
+ "Panasonic DMC-GM1s",
3874
+ "Panasonic DMC-GM5",
3875
+ "Panasonic DMC-GX1",
3876
+ "Panasonic DMC-GX7",
3877
+ "Panasonic DMC-L1",
3878
+ "Panasonic DMC-L10",
3879
+ "Panasonic DMC-LC1",
3880
+ "Panasonic DMC-LX1",
3881
+ "Panasonic DMC-LF1",
3882
+ "Panasonic DMC-LX2",
3883
+ "Panasonic DMC-LX3",
3884
+ "Panasonic DMC-LX5",
3885
+ "Panasonic DMC-LX7",
3886
+ "Panasonic DMC-LX100",
3887
+ "Panasonic DMC-TZ60/61/SZ40",
3888
+ "Panasonic DMC-TZ70",
3889
+ "Pentax *ist D",
3890
+ "Pentax *ist DL",
3891
+ "Pentax *ist DL2",
3892
+ "Pentax *ist DS",
3893
+ "Pentax *ist DS2",
3894
+ "Pentax GR",
3895
+ "Pentax K10D",
3896
+ "Pentax K20D",
3897
+ "Pentax K100D",
3898
+ "Pentax K100D Super",
3899
+ "Pentax K110D",
3900
+ "Pentax K200D",
3901
+ "Pentax K2000/K-m",
3902
+ "Pentax K-x",
3903
+ "Pentax K-r",
3904
+ "Pentax K-01",
3905
+ "Pentax K-3",
3906
+ "Pentax K-30",
3907
+ "Pentax K-5",
3908
+ "Pentax K-5 II",
3909
+ "Pentax K-5 IIs",
3910
+ "Pentax K-50",
3911
+ "Pentax K-500",
3912
+ "Pentax K-7",
3913
+ "Pentax K-S1",
3914
+ "Pentax MX-1",
3915
+ "Pentax Q",
3916
+ "Pentax Q7",
3917
+ "Pentax Q10",
3918
+ "Pentax QS-1",
3919
+ "Pentax Optio S",
3920
+ "Pentax Optio S4",
3921
+ "Pentax Optio 33WR",
3922
+ "Pentax Optio 750Z",
3923
+ "Pentax 645D",
3924
+ "Pentax 645Z",
3925
+ "PhaseOne IQ140",
3926
+ "PhaseOne IQ160",
3927
+ "PhaseOne IQ180",
3928
+ "PhaseOne IQ250",
3929
+ "PhaseOne IQ260",
3930
+ "PhaseOne IQ260 Achromatic",
3931
+ "PhaseOne IQ280",
3932
+ "PhaseOne LightPhase",
3933
+ "PhaseOne Achromatic+",
3934
+ "PhaseOne H 10",
3935
+ "PhaseOne H 20",
3936
+ "PhaseOne H 25",
3937
+ "PhaseOne P 20",
3938
+ "PhaseOne P 20+",
3939
+ "PhaseOne P 21",
3940
+ "PhaseOne P 25",
3941
+ "PhaseOne P 25+",
3942
+ "PhaseOne P 30",
3943
+ "PhaseOne P 30+",
3944
+ "PhaseOne P 40+",
3945
+ "PhaseOne P 45",
3946
+ "PhaseOne P 45+",
3947
+ "PhaseOne P 65",
3948
+ "PhaseOne P 65+",
3949
+ "Pixelink A782",
3950
+ "Polaroid x530",
3951
+ "Ricoh GR",
3952
+ "Ricoh GR Digital",
3953
+ "Ricoh GR Digital II",
3954
+ "Ricoh GR Digital III",
3955
+ "Ricoh GR Digital IV",
3956
+ "Ricoh GX100",
3957
+ "Ricoh GX200",
3958
+ "Ricoh GXR MOUNT A12",
3959
+ "Ricoh GXR MOUNT A16 24-85mm F3.5-5.5",
3960
+ "Ricoh GXR, S10 24-72mm F2.5-4.4 VC",
3961
+ "Ricoh GXR, GR A12 50mm F2.5 MACRO",
3962
+ "Ricoh GXR, GR LENS A12 28mm F2.5",
3963
+ "Ricoh GXR, GXR P10",
3964
+ #ifndef NO_JASPER
3965
+ "Redcode R3D format",
3966
+ #endif
3967
+ "Rollei d530flex",
3968
+ "RoverShot 3320af",
3969
+ "Samsung EX1",
3970
+ "Samsung EX2F",
3971
+ "Samsung GX-1L",
3972
+ "Samsung GX-1S",
3973
+ "Samsung GX10",
3974
+ "Samsung GX20",
3975
+ "Samsung Galaxy NX (EK-GN120)",
3976
+ "Samsung NX1",
3977
+ "Samsung NX5",
3978
+ "Samsung NX10",
3979
+ "Samsung NX11",
3980
+ "Samsung NX100",
3981
+ "Samsung NX1000",
3982
+ "Samsung NX1100",
3983
+ "Samsung NX20",
3984
+ "Samsung NX200",
3985
+ "Samsung NX210",
3986
+ "Samsung NX2000",
3987
+ "Samsung NX30",
3988
+ "Samsung NX300",
3989
+ "Samsung NX300M",
3990
+ "Samsung NX3000",
3991
+ "Samsung NX mini",
3992
+ "Samsung Pro815",
3993
+ "Samsung WB550",
3994
+ "Samsung WB2000",
3995
+ "Samsung S85 (hacked)",
3996
+ "Samsung S850 (hacked)",
3997
+ "Samsung Galaxy S3",
3998
+ "Samsung Galaxy Nexus",
3999
+ "Sarnoff 4096x5440",
4000
+ "Seitz 6x17",
4001
+ "Seitz Roundshot D3",
4002
+ "Seitz Roundshot D2X",
4003
+ "Seitz Roundshot D2Xs",
4004
+ "Sigma SD9",
4005
+ "Sigma SD10",
4006
+ "Sigma SD14",
4007
+ "Sigma SD15",
4008
+ "Sigma SD1",
4009
+ "Sigma SD1 Merill",
4010
+ "Sigma DP1",
4011
+ "Sigma DP1 Merill",
4012
+ "Sigma DP1S",
4013
+ "Sigma DP1X",
4014
+ "Sigma DP2",
4015
+ "Sigma DP2 Merill",
4016
+ "Sigma DP2S",
4017
+ "Sigma DP2X",
4018
+ "Sigma dp1 Quattro",
4019
+ "Sigma dp2 Quattro",
4020
+ "Sinar eMotion 22",
4021
+ "Sinar eMotion 54",
4022
+ "Sinar eSpirit 65",
4023
+ "Sinar eMotion 75",
4024
+ "Sinar eVolution 75",
4025
+ "Sinar 3072x2048",
4026
+ "Sinar 4080x4080",
4027
+ "Sinar 4080x5440",
4028
+ "Sinar STI format",
4029
+ "Sinar Sinarback 54",
4030
+ "SMaL Ultra-Pocket 3",
4031
+ "SMaL Ultra-Pocket 4",
4032
+ "SMaL Ultra-Pocket 5",
4033
+ "Sony A7",
4034
+ "Sony A7 II",
4035
+ "Sony A7R",
4036
+ "Sony A7S",
4037
+ "Sony ILCA-77M2 (A77-II)",
4038
+ "Sony ILCE-3000",
4039
+ "Sony ILCE-5000",
4040
+ "Sony ILCE-5100",
4041
+ "Sony ILCE-6000",
4042
+ "Sony ILCE-QX1",
4043
+ "Sony DSC-F828",
4044
+ "Sony DSC-R1",
4045
+ "Sony DSC-RX1",
4046
+ "Sony DSC-RX1R",
4047
+ "Sony DSC-RX10",
4048
+ "Sony DSC-RX100",
4049
+ "Sony DSC-RX100II",
4050
+ "Sony DSC-RX100III",
4051
+ "Sony DSC-V3",
4052
+ "Sony DSLR-A100",
4053
+ "Sony DSLR-A200",
4054
+ "Sony DSLR-A230",
4055
+ "Sony DSLR-A290",
4056
+ "Sony DSLR-A300",
4057
+ "Sony DSLR-A330",
4058
+ "Sony DSLR-A350",
4059
+ "Sony DSLR-A380",
4060
+ "Sony DSLR-A390",
4061
+ "Sony DSLR-A450",
4062
+ "Sony DSLR-A500",
4063
+ "Sony DSLR-A550",
4064
+ "Sony DSLR-A560",
4065
+ "Sony DSLR-A580",
4066
+ "Sony DSLR-A700",
4067
+ "Sony DSLR-A850",
4068
+ "Sony DSLR-A900",
4069
+ "Sony NEX-3",
4070
+ "Sony NEX-3N",
4071
+ "Sony NEX-5",
4072
+ "Sony NEX-5N",
4073
+ "Sony NEX-5R",
4074
+ "Sony NEX-5T",
4075
+ "Sony NEX-6",
4076
+ "Sony NEX-7",
4077
+ "Sony NEX-C3",
4078
+ "Sony NEX-F3",
4079
+ "Sony NEX-VG20",
4080
+ "Sony NEX-VG30",
4081
+ "Sony NEX-VG900",
4082
+ "Sony SLT-A33",
4083
+ "Sony SLT-A35",
4084
+ "Sony SLT-A37",
4085
+ "Sony SLT-A55V",
4086
+ "Sony SLT-A57",
4087
+ "Sony SLT-A58",
4088
+ "Sony SLT-A65V",
4089
+ "Sony SLT-A77V",
4090
+ "Sony SLT-A99V",
4091
+ "Sony XCD-SX910CR",
4092
+ "Sony IMX135-mipi 13mp",
4093
+ "Sony IMX135-QCOM",
4094
+ "Sony IMX072-mipi",
4095
+ "STV680 VGA",
4096
+ "ptGrey GRAS-50S5C",
4097
+ "JaiPulnix BB-500CL",
4098
+ "JaiPulnix BB-500GE",
4099
+ "SVS SVS625CL",
4100
+ NULL
4101
+ };
4102
+
4103
+ const char** LibRaw::cameraList() { return static_camera_list;}
4104
+ int LibRaw::cameraCount() { return (sizeof(static_camera_list)/sizeof(static_camera_list[0]))-1; }
4105
+
4106
+
4107
+ const char * LibRaw::strprogress(enum LibRaw_progress p)
4108
+ {
4109
+ switch(p)
4110
+ {
4111
+ case LIBRAW_PROGRESS_START:
4112
+ return "Starting";
4113
+ case LIBRAW_PROGRESS_OPEN :
4114
+ return "Opening file";
4115
+ case LIBRAW_PROGRESS_IDENTIFY :
4116
+ return "Reading metadata";
4117
+ case LIBRAW_PROGRESS_SIZE_ADJUST:
4118
+ return "Adjusting size";
4119
+ case LIBRAW_PROGRESS_LOAD_RAW:
4120
+ return "Reading RAW data";
4121
+ case LIBRAW_PROGRESS_REMOVE_ZEROES:
4122
+ return "Clearing zero values";
4123
+ case LIBRAW_PROGRESS_BAD_PIXELS :
4124
+ return "Removing dead pixels";
4125
+ case LIBRAW_PROGRESS_DARK_FRAME:
4126
+ return "Subtracting dark frame data";
4127
+ case LIBRAW_PROGRESS_FOVEON_INTERPOLATE:
4128
+ return "Interpolating Foveon sensor data";
4129
+ case LIBRAW_PROGRESS_SCALE_COLORS:
4130
+ return "Scaling colors";
4131
+ case LIBRAW_PROGRESS_PRE_INTERPOLATE:
4132
+ return "Pre-interpolating";
4133
+ case LIBRAW_PROGRESS_INTERPOLATE:
4134
+ return "Interpolating";
4135
+ case LIBRAW_PROGRESS_MIX_GREEN :
4136
+ return "Mixing green channels";
4137
+ case LIBRAW_PROGRESS_MEDIAN_FILTER :
4138
+ return "Median filter";
4139
+ case LIBRAW_PROGRESS_HIGHLIGHTS:
4140
+ return "Highlight recovery";
4141
+ case LIBRAW_PROGRESS_FUJI_ROTATE :
4142
+ return "Rotating Fuji diagonal data";
4143
+ case LIBRAW_PROGRESS_FLIP :
4144
+ return "Flipping image";
4145
+ case LIBRAW_PROGRESS_APPLY_PROFILE:
4146
+ return "ICC conversion";
4147
+ case LIBRAW_PROGRESS_CONVERT_RGB:
4148
+ return "Converting to RGB";
4149
+ case LIBRAW_PROGRESS_STRETCH:
4150
+ return "Stretching image";
4151
+ case LIBRAW_PROGRESS_THUMB_LOAD:
4152
+ return "Loading thumbnail";
4153
+ default:
4154
+ return "Some strange things";
4155
+ }
4156
+ }
4157
+
4158
+ #undef ID
4159
+
4160
+
4161
+ #include "../internal/libraw_x3f.cpp"
4162
+
4163
+ void x3f_clear(void *p)
4164
+ {
4165
+ x3f_delete((x3f_t*)p);
4166
+ }
4167
+
4168
+ static char *utf2char(utf16_t *str, char *buffer)
4169
+ {
4170
+ char *b = buffer;
4171
+
4172
+ while (*str != 0x00) {
4173
+ char *chr = (char *)str;
4174
+ *b++ = *chr;
4175
+ str++;
4176
+ }
4177
+ *b = 0;
4178
+ return buffer;
4179
+ }
4180
+
4181
+ static void *lr_memmem(const void *l, size_t l_len, const void *s, size_t s_len)
4182
+ {
4183
+ register char *cur, *last;
4184
+ const char *cl = (const char *)l;
4185
+ const char *cs = (const char *)s;
4186
+
4187
+ /* we need something to compare */
4188
+ if (l_len == 0 || s_len == 0)
4189
+ return NULL;
4190
+
4191
+ /* "s" must be smaller or equal to "l" */
4192
+ if (l_len < s_len)
4193
+ return NULL;
4194
+
4195
+ /* special case where s_len == 1 */
4196
+ if (s_len == 1)
4197
+ return (void*)memchr(l, (int)*cs, l_len);
4198
+
4199
+ /* the last position where its possible to find "s" in "l" */
4200
+ last = (char *)cl + l_len - s_len;
4201
+
4202
+ for (cur = (char *)cl; cur <= last; cur++)
4203
+ if (cur[0] == cs[0] && memcmp(cur, cs, s_len) == 0)
4204
+ return cur;
4205
+ return NULL;
4206
+ }
4207
+
4208
+ void LibRaw::parse_x3f()
4209
+ {
4210
+ x3f_t *x3f = x3f_new_from_file(libraw_internal_data.internal_data.input);
4211
+ if(!x3f)
4212
+ return;
4213
+ _x3f_data = x3f;
4214
+
4215
+ x3f_header_t *H = NULL;
4216
+ x3f_directory_section_t *DS = NULL;
4217
+
4218
+ H = &x3f->header;
4219
+ // Parse RAW size from RAW section
4220
+ x3f_directory_entry_t *DE = x3f_get_raw(x3f);
4221
+ if(!DE) return;
4222
+ imgdata.sizes.flip = H->rotation;
4223
+ x3f_directory_entry_header_t *DEH = &DE->header;
4224
+ x3f_image_data_t *ID = &DEH->data_subsection.image_data;
4225
+ imgdata.sizes.raw_width = ID->columns;
4226
+ imgdata.sizes.raw_height = ID->rows;
4227
+ // Parse other params from property section
4228
+ DE = x3f_get_prop(x3f);
4229
+ if((x3f_load_data(x3f,DE) == X3F_OK))
4230
+ {
4231
+ // Parse property list
4232
+ DEH = &DE->header;
4233
+ x3f_property_list_t *PL = &DEH->data_subsection.property_list;
4234
+ if (PL->property_table.size != 0) {
4235
+ int i;
4236
+ x3f_property_t *P = PL->property_table.element;
4237
+ for (i=0; i<PL->num_properties; i++) {
4238
+ char name[100], value[100];
4239
+ utf2char(P[i].name,name);
4240
+ utf2char(P[i].value,value);
4241
+ if (!strcmp (name, "ISO"))
4242
+ imgdata.other.iso_speed = atoi(value);
4243
+ if (!strcmp (name, "CAMMANUF"))
4244
+ strcpy (imgdata.idata.make, value);
4245
+ if (!strcmp (name, "CAMMODEL"))
4246
+ strcpy (imgdata.idata.model, value);
4247
+ if (!strcmp (name, "WB_DESC"))
4248
+ strcpy (imgdata.color.model2, value);
4249
+ if (!strcmp (name, "TIME"))
4250
+ imgdata.other.timestamp = atoi(value);
4251
+ if (!strcmp (name, "SHUTTER"))
4252
+ imgdata.other.shutter = atof(value);
4253
+ if (!strcmp (name, "APERTURE"))
4254
+ imgdata.other.aperture = atof(value);
4255
+ if (!strcmp (name, "FLENGTH"))
4256
+ imgdata.other.focal_len = atof(value);
4257
+ if (!strcmp (name, "FLEQ35MM"))
4258
+ imgdata.lens.makernotes.FocalLengthIn35mmFormat = atof(value);
4259
+ if (!strcmp (name, "LENSARANGE"))
4260
+ {
4261
+ char *sp;
4262
+ imgdata.lens.makernotes.MaxAp4CurFocal = imgdata.lens.makernotes.MinAp4CurFocal = atof(value);
4263
+ sp = strrchr (value, ' ');
4264
+ if (sp)
4265
+ {
4266
+ imgdata.lens.makernotes.MinAp4CurFocal = atof(sp);
4267
+ if (imgdata.lens.makernotes.MaxAp4CurFocal > imgdata.lens.makernotes.MinAp4CurFocal)
4268
+ my_swap (float, imgdata.lens.makernotes.MaxAp4CurFocal, imgdata.lens.makernotes.MinAp4CurFocal);
4269
+ }
4270
+ }
4271
+ if (!strcmp (name, "LENSFRANGE"))
4272
+ {
4273
+ char *sp;
4274
+ imgdata.lens.makernotes.MinFocal = imgdata.lens.makernotes.MaxFocal = atof(value);
4275
+ sp = strrchr (value, ' ');
4276
+ if (sp)
4277
+ {
4278
+ imgdata.lens.makernotes.MaxFocal = atof(sp);
4279
+ if ((imgdata.lens.makernotes.MaxFocal + 0.17f) < imgdata.lens.makernotes.MinFocal)
4280
+ my_swap (float, imgdata.lens.makernotes.MaxFocal, imgdata.lens.makernotes.MinFocal);
4281
+ }
4282
+ }
4283
+ if (!strcmp (name, "LENSMODEL"))
4284
+ {
4285
+ imgdata.lens.makernotes.LensID = atoi(value);
4286
+ if (imgdata.lens.makernotes.LensID)
4287
+ imgdata.lens.makernotes.LensMount = Sigma_X3F;
4288
+ }
4289
+ }
4290
+ imgdata.idata.raw_count=1;
4291
+ load_raw = &LibRaw::x3f_load_raw;
4292
+ imgdata.sizes.raw_pitch = imgdata.sizes.raw_width*6;
4293
+ imgdata.idata.is_foveon = 1;
4294
+ libraw_internal_data.internal_output_params.raw_color=1; // Force adobe coeff
4295
+ imgdata.color.maximum=0x3fff; // To be reset by color table
4296
+ libraw_internal_data.unpacker_data.order = 0x4949;
4297
+ }
4298
+ }
4299
+ else
4300
+ {
4301
+ // No property list
4302
+ if(imgdata.sizes.raw_width == 5888 ||imgdata.sizes.raw_width == 2944 ) // dp2Q
4303
+ {
4304
+ imgdata.idata.raw_count=1;
4305
+ load_raw = &LibRaw::x3f_load_raw;
4306
+ imgdata.sizes.raw_pitch = imgdata.sizes.raw_width*6;
4307
+ imgdata.idata.is_foveon = 1;
4308
+ libraw_internal_data.internal_output_params.raw_color=1; // Force adobe coeff
4309
+ libraw_internal_data.unpacker_data.order = 0x4949;
4310
+ strcpy (imgdata.idata.make, "SIGMA");
4311
+ #if 1
4312
+ // Try to find model number in first 2048 bytes;
4313
+ int pos = libraw_internal_data.internal_data.input->tell();
4314
+ libraw_internal_data.internal_data.input->seek(0,SEEK_SET);
4315
+ unsigned char buf[2048];
4316
+ libraw_internal_data.internal_data.input->read(buf,2048,1);
4317
+ libraw_internal_data.internal_data.input->seek(pos,SEEK_SET);
4318
+ unsigned char *fnd=(unsigned char*)lr_memmem(buf,2048,"SIGMA dp",8);
4319
+ if(fnd)
4320
+ {
4321
+ unsigned char *nm = fnd+8;
4322
+ snprintf(imgdata.idata.model,64,"dp%c Quattro",*nm<='9' && *nm >='0' ? *nm: '2');
4323
+ }
4324
+ else
4325
+ #endif
4326
+ strcpy (imgdata.idata.model, "dp2 Quattro");
4327
+ }
4328
+ }
4329
+ // Try to get thumbnail data
4330
+ LibRaw_thumbnail_formats format = LIBRAW_THUMBNAIL_UNKNOWN;
4331
+ if(DE = x3f_get_thumb_jpeg(x3f))
4332
+ {
4333
+ format = LIBRAW_THUMBNAIL_JPEG;
4334
+ }
4335
+ else if(DE = x3f_get_thumb_plain(x3f))
4336
+ {
4337
+ format = LIBRAW_THUMBNAIL_BITMAP;
4338
+ }
4339
+ if(DE)
4340
+ {
4341
+ x3f_directory_entry_header_t *DEH = &DE->header;
4342
+ x3f_image_data_t *ID = &DEH->data_subsection.image_data;
4343
+ imgdata.thumbnail.twidth = ID->columns;
4344
+ imgdata.thumbnail.theight = ID->rows;
4345
+ imgdata.thumbnail.tcolors = 3;
4346
+ imgdata.thumbnail.tformat = format;
4347
+ libraw_internal_data.internal_data.toffset = DE->input.offset;
4348
+ write_thumb = &LibRaw::x3f_thumb_loader;
4349
+ }
4350
+ }
4351
+
4352
+ void LibRaw::x3f_thumb_loader()
4353
+ {
4354
+ x3f_t *x3f = (x3f_t*)_x3f_data;
4355
+ if(!x3f) return; // No data pointer set
4356
+ x3f_directory_entry_t *DE = x3f_get_thumb_jpeg(x3f);
4357
+ if(!DE)
4358
+ DE = x3f_get_thumb_plain(x3f);
4359
+ if(!DE)
4360
+ return;
4361
+ if(X3F_OK != x3f_load_data(x3f, DE))
4362
+ throw LIBRAW_EXCEPTION_IO_CORRUPT;
4363
+ x3f_directory_entry_header_t *DEH = &DE->header;
4364
+ x3f_image_data_t *ID = &DEH->data_subsection.image_data;
4365
+ imgdata.thumbnail.twidth = ID->columns;
4366
+ imgdata.thumbnail.theight = ID->rows;
4367
+ imgdata.thumbnail.tcolors = 3;
4368
+ if(imgdata.thumbnail.tformat == LIBRAW_THUMBNAIL_JPEG)
4369
+ {
4370
+ imgdata.thumbnail.thumb = (char*)malloc(ID->data_size);
4371
+ merror(imgdata.thumbnail.thumb,"LibRaw::x3f_thumb_loader()");
4372
+ memmove(imgdata.thumbnail.thumb,ID->data,ID->data_size);
4373
+ imgdata.thumbnail.tlength = ID->data_size;
4374
+ }
4375
+ else if(imgdata.thumbnail.tformat == LIBRAW_THUMBNAIL_BITMAP)
4376
+ {
4377
+ imgdata.thumbnail.tlength = ID->columns * ID->rows * 3;
4378
+ imgdata.thumbnail.thumb = (char*)malloc(ID->columns * ID->rows * 3);
4379
+ merror(imgdata.thumbnail.thumb,"LibRaw::x3f_thumb_loader()");
4380
+ char *src0 = (char*)ID->data;
4381
+ for(int row = 0; row < ID->rows;row++)
4382
+ {
4383
+ char *dest = &imgdata.thumbnail.thumb[row*ID->columns*3];
4384
+ char *src = &src0[row * ID->row_stride];
4385
+ memmove(dest,src,ID->columns*3);
4386
+ }
4387
+ }
4388
+ }
4389
+
4390
+ static inline uint32_t _clampbits(int x, uint32_t n) {
4391
+ uint32_t _y_temp;
4392
+ if( (_y_temp=x>>n) )
4393
+ x = ~_y_temp >> (32-n);
4394
+ return x;
4395
+ }
4396
+
4397
+ void LibRaw::x3f_dpq_interpolate_rg()
4398
+ {
4399
+ int w = imgdata.sizes.raw_width/2;
4400
+ int h = imgdata.sizes.raw_height/2;
4401
+ unsigned short *image = (ushort*)imgdata.rawdata.color3_image;
4402
+
4403
+ for (int color = 0; color < 2; color++)
4404
+ {
4405
+ for (int y = 2; y < (h-2); y++)
4406
+ {
4407
+ uint16_t* row0 = &image[imgdata.sizes.raw_width*3*(y*2)+color]; // dst[1]
4408
+ uint16_t row0_3 = row0[3];
4409
+ uint16_t* row1 = &image[imgdata.sizes.raw_width*3*(y*2+1)+color]; //dst1[1]
4410
+ uint16_t row1_3 = row1[3];
4411
+ for (int x = 2; x < (w-2); x++)
4412
+ {
4413
+ row1[0]=row1[3]=row0[3]=row0[0];
4414
+ row0 += 6;
4415
+ row1 += 6;
4416
+ }
4417
+ }
4418
+ }
4419
+ }
4420
+
4421
+ #define _ABS(a) ((a)<0?-(a):(a))
4422
+
4423
+ #undef CLIP
4424
+ #define CLIP(value,high) ((value)>(high)?(high):(value))
4425
+
4426
+ void LibRaw::x3f_dpq_interpolate_af(int xstep, int ystep, int scale)
4427
+ {
4428
+ unsigned short *image = (ushort*)imgdata.rawdata.color3_image;
4429
+ unsigned int rowpitch = imgdata.rawdata.sizes.raw_pitch/2; // in 16-bit words
4430
+ // Interpolate single pixel
4431
+ for(int y = 0; y < imgdata.rawdata.sizes.height+imgdata.rawdata.sizes.top_margin; y+=ystep)
4432
+ {
4433
+ if(y<imgdata.rawdata.sizes.top_margin) continue;
4434
+ if(y<scale) continue;
4435
+ if(y>imgdata.rawdata.sizes.raw_height-scale) break;
4436
+ uint16_t* row0 = &image[imgdata.sizes.raw_width*3*y]; // Наша строка
4437
+ uint16_t* row_minus = &image[imgdata.sizes.raw_width*3*(y-scale)]; // Строка выше
4438
+ uint16_t* row_plus = &image[imgdata.sizes.raw_width*3*(y+scale)]; // Строка ниже
4439
+ for(int x = 0; x < imgdata.rawdata.sizes.width+imgdata.rawdata.sizes.left_margin; x+= xstep)
4440
+ {
4441
+ if(x<imgdata.rawdata.sizes.left_margin) continue;
4442
+ if(x<scale) continue;
4443
+ if(x>imgdata.rawdata.sizes.raw_width-scale) break;
4444
+ uint16_t* pixel0 = &row0[x*3];
4445
+ uint16_t* pixel_top = &row_minus[x*3];
4446
+ uint16_t* pixel_bottom = &row_plus[x*3];
4447
+ uint16_t* pixel_left = &row0[(x-scale)*3];
4448
+ uint16_t* pixel_right = &row0[(x+scale)*3];
4449
+ uint16_t* pixf = pixel_top;
4450
+ if(_ABS(pixf[2]-pixel0[2])>_ABS(pixel_bottom[2]-pixel0[2]))
4451
+ pixf = pixel_bottom;
4452
+ if(_ABS(pixf[2]-pixel0[2])>_ABS(pixel_left[2]-pixel0[2]))
4453
+ pixf = pixel_left;
4454
+ if(_ABS(pixf[2]-pixel0[2])>_ABS(pixel_right[2]-pixel0[2]))
4455
+ pixf = pixel_right;
4456
+ int blocal = pixel0[2],bnear = pixf[2];
4457
+ if(blocal < imgdata.color.black+16 || bnear < imgdata.color.black+16 )
4458
+ {
4459
+ pixel0[0] = CLIP((pixel0[0] - imgdata.color.black)*4 + imgdata.color.black,16383);
4460
+ pixel0[1] = CLIP((pixel0[1] - imgdata.color.black)*4 + imgdata.color.black,16383);
4461
+ }
4462
+ else
4463
+ {
4464
+ float multip = float(bnear - imgdata.color.black)/float(blocal-imgdata.color.black);
4465
+ pixel0[0] = CLIP(((float(pixf[0]-imgdata.color.black)*multip + imgdata.color.black)+((pixel0[0]-imgdata.color.black)*3.75 + imgdata.color.black))/2,16383);
4466
+ pixel0[1] = CLIP(((float(pixf[1]-imgdata.color.black)*multip + imgdata.color.black)+((pixel0[1]-imgdata.color.black)*3.75 + imgdata.color.black))/2,16383);
4467
+ //pixel0[1] = float(pixf[1]-imgdata.color.black)*multip + imgdata.color.black;
4468
+ }
4469
+ }
4470
+ }
4471
+ }
4472
+
4473
+
4474
+ void LibRaw::x3f_load_raw()
4475
+ {
4476
+ int raise_error=0;
4477
+ x3f_t *x3f = (x3f_t*)_x3f_data;
4478
+ if(!x3f) return; // No data pointer set
4479
+ if(X3F_OK == x3f_load_data(x3f, x3f_get_raw(x3f)))
4480
+ {
4481
+ x3f_directory_entry_t *DE = x3f_get_raw(x3f);
4482
+ x3f_directory_entry_header_t *DEH = &DE->header;
4483
+ x3f_image_data_t *ID = &DEH->data_subsection.image_data;
4484
+ x3f_huffman_t *HUF = ID->huffman;
4485
+ x3f_true_t *TRU = ID->tru;
4486
+ uint16_t *data = NULL;
4487
+ if(ID->rows != S.raw_height || ID->columns != S.raw_width)
4488
+ {
4489
+ raise_error = 1;
4490
+ goto end;
4491
+ }
4492
+ if (HUF != NULL)
4493
+ data = HUF->x3rgb16.element;
4494
+ if (TRU != NULL)
4495
+ data = TRU->x3rgb16.element;
4496
+ if (data == NULL)
4497
+ {
4498
+ raise_error = 1;
4499
+ goto end;
4500
+ }
4501
+ imgdata.rawdata.color3_image = (ushort (*)[3])data;
4502
+
4503
+ if(!strcasecmp(imgdata.idata.make,"Sigma")
4504
+ && (!strcasecmp(imgdata.idata.model,"dp2 Quattro") || !strcasecmp(imgdata.idata.model,"dp1 Quattro"))
4505
+ && (imgdata.params.x3f_flags & LIBRAW_DP2Q_INTERPOLATEAF)
4506
+ )
4507
+ {
4508
+ if(imgdata.sizes.raw_width == 5888)
4509
+ {
4510
+ x3f_dpq_interpolate_af(32,8,2);
4511
+ }
4512
+ if(imgdata.sizes.raw_width == 2944)
4513
+ {
4514
+ x3f_dpq_interpolate_af(16,4,1);
4515
+ }
4516
+ }
4517
+
4518
+ if(!strcasecmp(imgdata.idata.make,"Sigma")
4519
+ && (!strcasecmp(imgdata.idata.model,"dp2 Quattro") || !strcasecmp(imgdata.idata.model,"dp1 Quattro"))
4520
+ && (imgdata.params.x3f_flags & LIBRAW_DP2Q_INTERPOLATERG)
4521
+ && (imgdata.sizes.raw_width== 5888)
4522
+ )
4523
+ x3f_dpq_interpolate_rg();
4524
+
4525
+
4526
+ }
4527
+ else
4528
+ raise_error = 1;
4529
+ end:
4530
+ if(raise_error)
4531
+ throw LIBRAW_EXCEPTION_IO_CORRUPT;
4532
+ }
4533
+