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,1838 @@
1
+ // Copyright 2012 Google Inc. All Rights Reserved.
2
+ //
3
+ // Use of this source code is governed by a BSD-style license
4
+ // that can be found in the COPYING file in the root of the source
5
+ // tree. An additional intellectual property rights grant can be found
6
+ // in the file PATENTS. All contributing project authors may
7
+ // be found in the AUTHORS file in the root of the source tree.
8
+ // -----------------------------------------------------------------------------
9
+ //
10
+ // Image transforms and color space conversion methods for lossless decoder.
11
+ //
12
+ // Authors: Vikas Arora (vikaas.arora@gmail.com)
13
+ // Jyrki Alakuijala (jyrki@google.com)
14
+ // Urvang Joshi (urvang@google.com)
15
+
16
+ #include "./dsp.h"
17
+
18
+ #include <math.h>
19
+ #include <stdlib.h>
20
+ #include "../dec/vp8li.h"
21
+ #include "../utils/endian_inl.h"
22
+ #include "./lossless.h"
23
+ #include "./yuv.h"
24
+
25
+ #define MAX_DIFF_COST (1e30f)
26
+
27
+ // lookup table for small values of log2(int)
28
+ const float kLog2Table[LOG_LOOKUP_IDX_MAX] = {
29
+ 0.0000000000000000f, 0.0000000000000000f,
30
+ 1.0000000000000000f, 1.5849625007211560f,
31
+ 2.0000000000000000f, 2.3219280948873621f,
32
+ 2.5849625007211560f, 2.8073549220576041f,
33
+ 3.0000000000000000f, 3.1699250014423121f,
34
+ 3.3219280948873621f, 3.4594316186372973f,
35
+ 3.5849625007211560f, 3.7004397181410921f,
36
+ 3.8073549220576041f, 3.9068905956085187f,
37
+ 4.0000000000000000f, 4.0874628412503390f,
38
+ 4.1699250014423121f, 4.2479275134435852f,
39
+ 4.3219280948873626f, 4.3923174227787606f,
40
+ 4.4594316186372973f, 4.5235619560570130f,
41
+ 4.5849625007211560f, 4.6438561897747243f,
42
+ 4.7004397181410917f, 4.7548875021634682f,
43
+ 4.8073549220576037f, 4.8579809951275718f,
44
+ 4.9068905956085187f, 4.9541963103868749f,
45
+ 5.0000000000000000f, 5.0443941193584533f,
46
+ 5.0874628412503390f, 5.1292830169449663f,
47
+ 5.1699250014423121f, 5.2094533656289501f,
48
+ 5.2479275134435852f, 5.2854022188622487f,
49
+ 5.3219280948873626f, 5.3575520046180837f,
50
+ 5.3923174227787606f, 5.4262647547020979f,
51
+ 5.4594316186372973f, 5.4918530963296747f,
52
+ 5.5235619560570130f, 5.5545888516776376f,
53
+ 5.5849625007211560f, 5.6147098441152083f,
54
+ 5.6438561897747243f, 5.6724253419714951f,
55
+ 5.7004397181410917f, 5.7279204545631987f,
56
+ 5.7548875021634682f, 5.7813597135246599f,
57
+ 5.8073549220576037f, 5.8328900141647412f,
58
+ 5.8579809951275718f, 5.8826430493618415f,
59
+ 5.9068905956085187f, 5.9307373375628866f,
60
+ 5.9541963103868749f, 5.9772799234999167f,
61
+ 6.0000000000000000f, 6.0223678130284543f,
62
+ 6.0443941193584533f, 6.0660891904577720f,
63
+ 6.0874628412503390f, 6.1085244567781691f,
64
+ 6.1292830169449663f, 6.1497471195046822f,
65
+ 6.1699250014423121f, 6.1898245588800175f,
66
+ 6.2094533656289501f, 6.2288186904958804f,
67
+ 6.2479275134435852f, 6.2667865406949010f,
68
+ 6.2854022188622487f, 6.3037807481771030f,
69
+ 6.3219280948873626f, 6.3398500028846243f,
70
+ 6.3575520046180837f, 6.3750394313469245f,
71
+ 6.3923174227787606f, 6.4093909361377017f,
72
+ 6.4262647547020979f, 6.4429434958487279f,
73
+ 6.4594316186372973f, 6.4757334309663976f,
74
+ 6.4918530963296747f, 6.5077946401986963f,
75
+ 6.5235619560570130f, 6.5391588111080309f,
76
+ 6.5545888516776376f, 6.5698556083309478f,
77
+ 6.5849625007211560f, 6.5999128421871278f,
78
+ 6.6147098441152083f, 6.6293566200796094f,
79
+ 6.6438561897747243f, 6.6582114827517946f,
80
+ 6.6724253419714951f, 6.6865005271832185f,
81
+ 6.7004397181410917f, 6.7142455176661224f,
82
+ 6.7279204545631987f, 6.7414669864011464f,
83
+ 6.7548875021634682f, 6.7681843247769259f,
84
+ 6.7813597135246599f, 6.7944158663501061f,
85
+ 6.8073549220576037f, 6.8201789624151878f,
86
+ 6.8328900141647412f, 6.8454900509443747f,
87
+ 6.8579809951275718f, 6.8703647195834047f,
88
+ 6.8826430493618415f, 6.8948177633079437f,
89
+ 6.9068905956085187f, 6.9188632372745946f,
90
+ 6.9307373375628866f, 6.9425145053392398f,
91
+ 6.9541963103868749f, 6.9657842846620869f,
92
+ 6.9772799234999167f, 6.9886846867721654f,
93
+ 7.0000000000000000f, 7.0112272554232539f,
94
+ 7.0223678130284543f, 7.0334230015374501f,
95
+ 7.0443941193584533f, 7.0552824355011898f,
96
+ 7.0660891904577720f, 7.0768155970508308f,
97
+ 7.0874628412503390f, 7.0980320829605263f,
98
+ 7.1085244567781691f, 7.1189410727235076f,
99
+ 7.1292830169449663f, 7.1395513523987936f,
100
+ 7.1497471195046822f, 7.1598713367783890f,
101
+ 7.1699250014423121f, 7.1799090900149344f,
102
+ 7.1898245588800175f, 7.1996723448363644f,
103
+ 7.2094533656289501f, 7.2191685204621611f,
104
+ 7.2288186904958804f, 7.2384047393250785f,
105
+ 7.2479275134435852f, 7.2573878426926521f,
106
+ 7.2667865406949010f, 7.2761244052742375f,
107
+ 7.2854022188622487f, 7.2946207488916270f,
108
+ 7.3037807481771030f, 7.3128829552843557f,
109
+ 7.3219280948873626f, 7.3309168781146167f,
110
+ 7.3398500028846243f, 7.3487281542310771f,
111
+ 7.3575520046180837f, 7.3663222142458160f,
112
+ 7.3750394313469245f, 7.3837042924740519f,
113
+ 7.3923174227787606f, 7.4008794362821843f,
114
+ 7.4093909361377017f, 7.4178525148858982f,
115
+ 7.4262647547020979f, 7.4346282276367245f,
116
+ 7.4429434958487279f, 7.4512111118323289f,
117
+ 7.4594316186372973f, 7.4676055500829976f,
118
+ 7.4757334309663976f, 7.4838157772642563f,
119
+ 7.4918530963296747f, 7.4998458870832056f,
120
+ 7.5077946401986963f, 7.5156998382840427f,
121
+ 7.5235619560570130f, 7.5313814605163118f,
122
+ 7.5391588111080309f, 7.5468944598876364f,
123
+ 7.5545888516776376f, 7.5622424242210728f,
124
+ 7.5698556083309478f, 7.5774288280357486f,
125
+ 7.5849625007211560f, 7.5924570372680806f,
126
+ 7.5999128421871278f, 7.6073303137496104f,
127
+ 7.6147098441152083f, 7.6220518194563764f,
128
+ 7.6293566200796094f, 7.6366246205436487f,
129
+ 7.6438561897747243f, 7.6510516911789281f,
130
+ 7.6582114827517946f, 7.6653359171851764f,
131
+ 7.6724253419714951f, 7.6794800995054464f,
132
+ 7.6865005271832185f, 7.6934869574993252f,
133
+ 7.7004397181410917f, 7.7073591320808825f,
134
+ 7.7142455176661224f, 7.7210991887071855f,
135
+ 7.7279204545631987f, 7.7347096202258383f,
136
+ 7.7414669864011464f, 7.7481928495894605f,
137
+ 7.7548875021634682f, 7.7615512324444795f,
138
+ 7.7681843247769259f, 7.7747870596011736f,
139
+ 7.7813597135246599f, 7.7879025593914317f,
140
+ 7.7944158663501061f, 7.8008998999203047f,
141
+ 7.8073549220576037f, 7.8137811912170374f,
142
+ 7.8201789624151878f, 7.8265484872909150f,
143
+ 7.8328900141647412f, 7.8392037880969436f,
144
+ 7.8454900509443747f, 7.8517490414160571f,
145
+ 7.8579809951275718f, 7.8641861446542797f,
146
+ 7.8703647195834047f, 7.8765169465649993f,
147
+ 7.8826430493618415f, 7.8887432488982591f,
148
+ 7.8948177633079437f, 7.9008668079807486f,
149
+ 7.9068905956085187f, 7.9128893362299619f,
150
+ 7.9188632372745946f, 7.9248125036057812f,
151
+ 7.9307373375628866f, 7.9366379390025709f,
152
+ 7.9425145053392398f, 7.9483672315846778f,
153
+ 7.9541963103868749f, 7.9600019320680805f,
154
+ 7.9657842846620869f, 7.9715435539507719f,
155
+ 7.9772799234999167f, 7.9829935746943103f,
156
+ 7.9886846867721654f, 7.9943534368588577f
157
+ };
158
+
159
+ const float kSLog2Table[LOG_LOOKUP_IDX_MAX] = {
160
+ 0.00000000f, 0.00000000f, 2.00000000f, 4.75488750f,
161
+ 8.00000000f, 11.60964047f, 15.50977500f, 19.65148445f,
162
+ 24.00000000f, 28.52932501f, 33.21928095f, 38.05374781f,
163
+ 43.01955001f, 48.10571634f, 53.30296891f, 58.60335893f,
164
+ 64.00000000f, 69.48686830f, 75.05865003f, 80.71062276f,
165
+ 86.43856190f, 92.23866588f, 98.10749561f, 104.04192499f,
166
+ 110.03910002f, 116.09640474f, 122.21143267f, 128.38196256f,
167
+ 134.60593782f, 140.88144886f, 147.20671787f, 153.58008562f,
168
+ 160.00000000f, 166.46500594f, 172.97373660f, 179.52490559f,
169
+ 186.11730005f, 192.74977453f, 199.42124551f, 206.13068654f,
170
+ 212.87712380f, 219.65963219f, 226.47733176f, 233.32938445f,
171
+ 240.21499122f, 247.13338933f, 254.08384998f, 261.06567603f,
172
+ 268.07820003f, 275.12078236f, 282.19280949f, 289.29369244f,
173
+ 296.42286534f, 303.57978409f, 310.76392512f, 317.97478424f,
174
+ 325.21187564f, 332.47473081f, 339.76289772f, 347.07593991f,
175
+ 354.41343574f, 361.77497759f, 369.16017124f, 376.56863518f,
176
+ 384.00000000f, 391.45390785f, 398.93001188f, 406.42797576f,
177
+ 413.94747321f, 421.48818752f, 429.04981119f, 436.63204548f,
178
+ 444.23460010f, 451.85719280f, 459.49954906f, 467.16140179f,
179
+ 474.84249102f, 482.54256363f, 490.26137307f, 497.99867911f,
180
+ 505.75424759f, 513.52785023f, 521.31926438f, 529.12827280f,
181
+ 536.95466351f, 544.79822957f, 552.65876890f, 560.53608414f,
182
+ 568.42998244f, 576.34027536f, 584.26677867f, 592.20931226f,
183
+ 600.16769996f, 608.14176943f, 616.13135206f, 624.13628279f,
184
+ 632.15640007f, 640.19154569f, 648.24156472f, 656.30630539f,
185
+ 664.38561898f, 672.47935976f, 680.58738488f, 688.70955430f,
186
+ 696.84573069f, 704.99577935f, 713.15956818f, 721.33696754f,
187
+ 729.52785023f, 737.73209140f, 745.94956849f, 754.18016116f,
188
+ 762.42375127f, 770.68022275f, 778.94946161f, 787.23135586f,
189
+ 795.52579543f, 803.83267219f, 812.15187982f, 820.48331383f,
190
+ 828.82687147f, 837.18245171f, 845.54995518f, 853.92928416f,
191
+ 862.32034249f, 870.72303558f, 879.13727036f, 887.56295522f,
192
+ 896.00000000f, 904.44831595f, 912.90781569f, 921.37841320f,
193
+ 929.86002376f, 938.35256392f, 946.85595152f, 955.37010560f,
194
+ 963.89494641f, 972.43039537f, 980.97637504f, 989.53280911f,
195
+ 998.09962237f, 1006.67674069f, 1015.26409097f, 1023.86160116f,
196
+ 1032.46920021f, 1041.08681805f, 1049.71438560f, 1058.35183469f,
197
+ 1066.99909811f, 1075.65610955f, 1084.32280357f, 1092.99911564f,
198
+ 1101.68498204f, 1110.38033993f, 1119.08512727f, 1127.79928282f,
199
+ 1136.52274614f, 1145.25545758f, 1153.99735821f, 1162.74838989f,
200
+ 1171.50849518f, 1180.27761738f, 1189.05570047f, 1197.84268914f,
201
+ 1206.63852876f, 1215.44316535f, 1224.25654560f, 1233.07861684f,
202
+ 1241.90932703f, 1250.74862473f, 1259.59645914f, 1268.45278005f,
203
+ 1277.31753781f, 1286.19068338f, 1295.07216828f, 1303.96194457f,
204
+ 1312.85996488f, 1321.76618236f, 1330.68055071f, 1339.60302413f,
205
+ 1348.53355734f, 1357.47210556f, 1366.41862452f, 1375.37307041f,
206
+ 1384.33539991f, 1393.30557020f, 1402.28353887f, 1411.26926400f,
207
+ 1420.26270412f, 1429.26381818f, 1438.27256558f, 1447.28890615f,
208
+ 1456.31280014f, 1465.34420819f, 1474.38309138f, 1483.42941118f,
209
+ 1492.48312945f, 1501.54420843f, 1510.61261078f, 1519.68829949f,
210
+ 1528.77123795f, 1537.86138993f, 1546.95871952f, 1556.06319119f,
211
+ 1565.17476976f, 1574.29342040f, 1583.41910860f, 1592.55180020f,
212
+ 1601.69146137f, 1610.83805860f, 1619.99155871f, 1629.15192882f,
213
+ 1638.31913637f, 1647.49314911f, 1656.67393509f, 1665.86146266f,
214
+ 1675.05570047f, 1684.25661744f, 1693.46418280f, 1702.67836605f,
215
+ 1711.89913698f, 1721.12646563f, 1730.36032233f, 1739.60067768f,
216
+ 1748.84750254f, 1758.10076802f, 1767.36044551f, 1776.62650662f,
217
+ 1785.89892323f, 1795.17766747f, 1804.46271172f, 1813.75402857f,
218
+ 1823.05159087f, 1832.35537170f, 1841.66534438f, 1850.98148244f,
219
+ 1860.30375965f, 1869.63214999f, 1878.96662767f, 1888.30716711f,
220
+ 1897.65374295f, 1907.00633003f, 1916.36490342f, 1925.72943838f,
221
+ 1935.09991037f, 1944.47629506f, 1953.85856831f, 1963.24670620f,
222
+ 1972.64068498f, 1982.04048108f, 1991.44607117f, 2000.85743204f,
223
+ 2010.27454072f, 2019.69737440f, 2029.12591044f, 2038.56012640f
224
+ };
225
+
226
+ const VP8LPrefixCode kPrefixEncodeCode[PREFIX_LOOKUP_IDX_MAX] = {
227
+ { 0, 0}, { 0, 0}, { 1, 0}, { 2, 0}, { 3, 0}, { 4, 1}, { 4, 1}, { 5, 1},
228
+ { 5, 1}, { 6, 2}, { 6, 2}, { 6, 2}, { 6, 2}, { 7, 2}, { 7, 2}, { 7, 2},
229
+ { 7, 2}, { 8, 3}, { 8, 3}, { 8, 3}, { 8, 3}, { 8, 3}, { 8, 3}, { 8, 3},
230
+ { 8, 3}, { 9, 3}, { 9, 3}, { 9, 3}, { 9, 3}, { 9, 3}, { 9, 3}, { 9, 3},
231
+ { 9, 3}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4},
232
+ {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4}, {10, 4},
233
+ {10, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4},
234
+ {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4}, {11, 4},
235
+ {11, 4}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5},
236
+ {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5},
237
+ {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5},
238
+ {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5}, {12, 5},
239
+ {12, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5},
240
+ {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5},
241
+ {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5},
242
+ {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5}, {13, 5},
243
+ {13, 5}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},
244
+ {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},
245
+ {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},
246
+ {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},
247
+ {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},
248
+ {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},
249
+ {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},
250
+ {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6}, {14, 6},
251
+ {14, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},
252
+ {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},
253
+ {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},
254
+ {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},
255
+ {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},
256
+ {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},
257
+ {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},
258
+ {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6}, {15, 6},
259
+ {15, 6}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
260
+ {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
261
+ {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
262
+ {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
263
+ {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
264
+ {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
265
+ {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
266
+ {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
267
+ {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
268
+ {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
269
+ {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
270
+ {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
271
+ {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
272
+ {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
273
+ {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
274
+ {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7}, {16, 7},
275
+ {16, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
276
+ {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
277
+ {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
278
+ {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
279
+ {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
280
+ {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
281
+ {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
282
+ {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
283
+ {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
284
+ {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
285
+ {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
286
+ {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
287
+ {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
288
+ {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
289
+ {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
290
+ {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7}, {17, 7},
291
+ };
292
+
293
+ const uint8_t kPrefixEncodeExtraBitsValue[PREFIX_LOOKUP_IDX_MAX] = {
294
+ 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 2, 3, 0, 1, 2, 3,
295
+ 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7,
296
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
297
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
298
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
299
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
300
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
301
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
302
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
303
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
304
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
305
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
306
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
307
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
308
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
309
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
310
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
311
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
312
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
313
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
314
+ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
315
+ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
316
+ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
317
+ 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
318
+ 127,
319
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
320
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
321
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
322
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
323
+ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
324
+ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
325
+ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
326
+ 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126
327
+ };
328
+
329
+ // The threshold till approximate version of log_2 can be used.
330
+ // Practically, we can get rid of the call to log() as the two values match to
331
+ // very high degree (the ratio of these two is 0.99999x).
332
+ // Keeping a high threshold for now.
333
+ #define APPROX_LOG_WITH_CORRECTION_MAX 65536
334
+ #define APPROX_LOG_MAX 4096
335
+ #define LOG_2_RECIPROCAL 1.44269504088896338700465094007086
336
+ static float FastSLog2Slow(uint32_t v) {
337
+ assert(v >= LOG_LOOKUP_IDX_MAX);
338
+ if (v < APPROX_LOG_WITH_CORRECTION_MAX) {
339
+ int log_cnt = 0;
340
+ uint32_t y = 1;
341
+ int correction = 0;
342
+ const float v_f = (float)v;
343
+ const uint32_t orig_v = v;
344
+ do {
345
+ ++log_cnt;
346
+ v = v >> 1;
347
+ y = y << 1;
348
+ } while (v >= LOG_LOOKUP_IDX_MAX);
349
+ // vf = (2^log_cnt) * Xf; where y = 2^log_cnt and Xf < 256
350
+ // Xf = floor(Xf) * (1 + (v % y) / v)
351
+ // log2(Xf) = log2(floor(Xf)) + log2(1 + (v % y) / v)
352
+ // The correction factor: log(1 + d) ~ d; for very small d values, so
353
+ // log2(1 + (v % y) / v) ~ LOG_2_RECIPROCAL * (v % y)/v
354
+ // LOG_2_RECIPROCAL ~ 23/16
355
+ correction = (23 * (orig_v & (y - 1))) >> 4;
356
+ return v_f * (kLog2Table[v] + log_cnt) + correction;
357
+ } else {
358
+ return (float)(LOG_2_RECIPROCAL * v * log((double)v));
359
+ }
360
+ }
361
+
362
+ static float FastLog2Slow(uint32_t v) {
363
+ assert(v >= LOG_LOOKUP_IDX_MAX);
364
+ if (v < APPROX_LOG_WITH_CORRECTION_MAX) {
365
+ int log_cnt = 0;
366
+ uint32_t y = 1;
367
+ const uint32_t orig_v = v;
368
+ double log_2;
369
+ do {
370
+ ++log_cnt;
371
+ v = v >> 1;
372
+ y = y << 1;
373
+ } while (v >= LOG_LOOKUP_IDX_MAX);
374
+ log_2 = kLog2Table[v] + log_cnt;
375
+ if (orig_v >= APPROX_LOG_MAX) {
376
+ // Since the division is still expensive, add this correction factor only
377
+ // for large values of 'v'.
378
+ const int correction = (23 * (orig_v & (y - 1))) >> 4;
379
+ log_2 += (double)correction / orig_v;
380
+ }
381
+ return (float)log_2;
382
+ } else {
383
+ return (float)(LOG_2_RECIPROCAL * log((double)v));
384
+ }
385
+ }
386
+
387
+ //------------------------------------------------------------------------------
388
+ // Image transforms.
389
+
390
+ // Mostly used to reduce code size + readability
391
+ static WEBP_INLINE int GetMin(int a, int b) { return (a > b) ? b : a; }
392
+
393
+ // In-place sum of each component with mod 256.
394
+ static WEBP_INLINE void AddPixelsEq(uint32_t* a, uint32_t b) {
395
+ const uint32_t alpha_and_green = (*a & 0xff00ff00u) + (b & 0xff00ff00u);
396
+ const uint32_t red_and_blue = (*a & 0x00ff00ffu) + (b & 0x00ff00ffu);
397
+ *a = (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu);
398
+ }
399
+
400
+ static WEBP_INLINE uint32_t Average2(uint32_t a0, uint32_t a1) {
401
+ return (((a0 ^ a1) & 0xfefefefeL) >> 1) + (a0 & a1);
402
+ }
403
+
404
+ static WEBP_INLINE uint32_t Average3(uint32_t a0, uint32_t a1, uint32_t a2) {
405
+ return Average2(Average2(a0, a2), a1);
406
+ }
407
+
408
+ static WEBP_INLINE uint32_t Average4(uint32_t a0, uint32_t a1,
409
+ uint32_t a2, uint32_t a3) {
410
+ return Average2(Average2(a0, a1), Average2(a2, a3));
411
+ }
412
+
413
+ static WEBP_INLINE uint32_t Clip255(uint32_t a) {
414
+ if (a < 256) {
415
+ return a;
416
+ }
417
+ // return 0, when a is a negative integer.
418
+ // return 255, when a is positive.
419
+ return ~a >> 24;
420
+ }
421
+
422
+ static WEBP_INLINE int AddSubtractComponentFull(int a, int b, int c) {
423
+ return Clip255(a + b - c);
424
+ }
425
+
426
+ static WEBP_INLINE uint32_t ClampedAddSubtractFull(uint32_t c0, uint32_t c1,
427
+ uint32_t c2) {
428
+ const int a = AddSubtractComponentFull(c0 >> 24, c1 >> 24, c2 >> 24);
429
+ const int r = AddSubtractComponentFull((c0 >> 16) & 0xff,
430
+ (c1 >> 16) & 0xff,
431
+ (c2 >> 16) & 0xff);
432
+ const int g = AddSubtractComponentFull((c0 >> 8) & 0xff,
433
+ (c1 >> 8) & 0xff,
434
+ (c2 >> 8) & 0xff);
435
+ const int b = AddSubtractComponentFull(c0 & 0xff, c1 & 0xff, c2 & 0xff);
436
+ return ((uint32_t)a << 24) | (r << 16) | (g << 8) | b;
437
+ }
438
+
439
+ static WEBP_INLINE int AddSubtractComponentHalf(int a, int b) {
440
+ return Clip255(a + (a - b) / 2);
441
+ }
442
+
443
+ static WEBP_INLINE uint32_t ClampedAddSubtractHalf(uint32_t c0, uint32_t c1,
444
+ uint32_t c2) {
445
+ const uint32_t ave = Average2(c0, c1);
446
+ const int a = AddSubtractComponentHalf(ave >> 24, c2 >> 24);
447
+ const int r = AddSubtractComponentHalf((ave >> 16) & 0xff, (c2 >> 16) & 0xff);
448
+ const int g = AddSubtractComponentHalf((ave >> 8) & 0xff, (c2 >> 8) & 0xff);
449
+ const int b = AddSubtractComponentHalf((ave >> 0) & 0xff, (c2 >> 0) & 0xff);
450
+ return ((uint32_t)a << 24) | (r << 16) | (g << 8) | b;
451
+ }
452
+
453
+ // gcc-4.9 on ARM generates incorrect code in Select() when Sub3() is inlined.
454
+ #if defined(__arm__) && LOCAL_GCC_VERSION == 0x409
455
+ # define LOCAL_INLINE __attribute__ ((noinline))
456
+ #else
457
+ # define LOCAL_INLINE WEBP_INLINE
458
+ #endif
459
+
460
+ static LOCAL_INLINE int Sub3(int a, int b, int c) {
461
+ const int pb = b - c;
462
+ const int pa = a - c;
463
+ return abs(pb) - abs(pa);
464
+ }
465
+
466
+ #undef LOCAL_INLINE
467
+
468
+ static WEBP_INLINE uint32_t Select(uint32_t a, uint32_t b, uint32_t c) {
469
+ const int pa_minus_pb =
470
+ Sub3((a >> 24) , (b >> 24) , (c >> 24) ) +
471
+ Sub3((a >> 16) & 0xff, (b >> 16) & 0xff, (c >> 16) & 0xff) +
472
+ Sub3((a >> 8) & 0xff, (b >> 8) & 0xff, (c >> 8) & 0xff) +
473
+ Sub3((a ) & 0xff, (b ) & 0xff, (c ) & 0xff);
474
+ return (pa_minus_pb <= 0) ? a : b;
475
+ }
476
+
477
+ //------------------------------------------------------------------------------
478
+ // Predictors
479
+
480
+ static uint32_t Predictor0(uint32_t left, const uint32_t* const top) {
481
+ (void)top;
482
+ (void)left;
483
+ return ARGB_BLACK;
484
+ }
485
+ static uint32_t Predictor1(uint32_t left, const uint32_t* const top) {
486
+ (void)top;
487
+ return left;
488
+ }
489
+ static uint32_t Predictor2(uint32_t left, const uint32_t* const top) {
490
+ (void)left;
491
+ return top[0];
492
+ }
493
+ static uint32_t Predictor3(uint32_t left, const uint32_t* const top) {
494
+ (void)left;
495
+ return top[1];
496
+ }
497
+ static uint32_t Predictor4(uint32_t left, const uint32_t* const top) {
498
+ (void)left;
499
+ return top[-1];
500
+ }
501
+ static uint32_t Predictor5(uint32_t left, const uint32_t* const top) {
502
+ const uint32_t pred = Average3(left, top[0], top[1]);
503
+ return pred;
504
+ }
505
+ static uint32_t Predictor6(uint32_t left, const uint32_t* const top) {
506
+ const uint32_t pred = Average2(left, top[-1]);
507
+ return pred;
508
+ }
509
+ static uint32_t Predictor7(uint32_t left, const uint32_t* const top) {
510
+ const uint32_t pred = Average2(left, top[0]);
511
+ return pred;
512
+ }
513
+ static uint32_t Predictor8(uint32_t left, const uint32_t* const top) {
514
+ const uint32_t pred = Average2(top[-1], top[0]);
515
+ (void)left;
516
+ return pred;
517
+ }
518
+ static uint32_t Predictor9(uint32_t left, const uint32_t* const top) {
519
+ const uint32_t pred = Average2(top[0], top[1]);
520
+ (void)left;
521
+ return pred;
522
+ }
523
+ static uint32_t Predictor10(uint32_t left, const uint32_t* const top) {
524
+ const uint32_t pred = Average4(left, top[-1], top[0], top[1]);
525
+ return pred;
526
+ }
527
+ static uint32_t Predictor11(uint32_t left, const uint32_t* const top) {
528
+ const uint32_t pred = Select(top[0], left, top[-1]);
529
+ return pred;
530
+ }
531
+ static uint32_t Predictor12(uint32_t left, const uint32_t* const top) {
532
+ const uint32_t pred = ClampedAddSubtractFull(left, top[0], top[-1]);
533
+ return pred;
534
+ }
535
+ static uint32_t Predictor13(uint32_t left, const uint32_t* const top) {
536
+ const uint32_t pred = ClampedAddSubtractHalf(left, top[0], top[-1]);
537
+ return pred;
538
+ }
539
+
540
+ //------------------------------------------------------------------------------
541
+ // Methods to calculate Entropy (Shannon).
542
+
543
+ static float PredictionCostSpatial(const int counts[256], int weight_0,
544
+ double exp_val) {
545
+ const int significant_symbols = 256 >> 4;
546
+ const double exp_decay_factor = 0.6;
547
+ double bits = weight_0 * counts[0];
548
+ int i;
549
+ for (i = 1; i < significant_symbols; ++i) {
550
+ bits += exp_val * (counts[i] + counts[256 - i]);
551
+ exp_val *= exp_decay_factor;
552
+ }
553
+ return (float)(-0.1 * bits);
554
+ }
555
+
556
+ // Compute the combined Shanon's entropy for distribution {X} and {X+Y}
557
+ static float CombinedShannonEntropy(const int X[256], const int Y[256]) {
558
+ int i;
559
+ double retval = 0.;
560
+ int sumX = 0, sumXY = 0;
561
+ for (i = 0; i < 256; ++i) {
562
+ const int x = X[i];
563
+ const int xy = x + Y[i];
564
+ if (x != 0) {
565
+ sumX += x;
566
+ retval -= VP8LFastSLog2(x);
567
+ sumXY += xy;
568
+ retval -= VP8LFastSLog2(xy);
569
+ } else if (xy != 0) {
570
+ sumXY += xy;
571
+ retval -= VP8LFastSLog2(xy);
572
+ }
573
+ }
574
+ retval += VP8LFastSLog2(sumX) + VP8LFastSLog2(sumXY);
575
+ return (float)retval;
576
+ }
577
+
578
+ static float PredictionCostSpatialHistogram(const int accumulated[4][256],
579
+ const int tile[4][256]) {
580
+ int i;
581
+ double retval = 0;
582
+ for (i = 0; i < 4; ++i) {
583
+ const double kExpValue = 0.94;
584
+ retval += PredictionCostSpatial(tile[i], 1, kExpValue);
585
+ retval += CombinedShannonEntropy(tile[i], accumulated[i]);
586
+ }
587
+ return (float)retval;
588
+ }
589
+
590
+ static WEBP_INLINE double BitsEntropyRefine(int nonzeros, int sum, int max_val,
591
+ double retval) {
592
+ double mix;
593
+ if (nonzeros < 5) {
594
+ if (nonzeros <= 1) {
595
+ return 0;
596
+ }
597
+ // Two symbols, they will be 0 and 1 in a Huffman code.
598
+ // Let's mix in a bit of entropy to favor good clustering when
599
+ // distributions of these are combined.
600
+ if (nonzeros == 2) {
601
+ return 0.99 * sum + 0.01 * retval;
602
+ }
603
+ // No matter what the entropy says, we cannot be better than min_limit
604
+ // with Huffman coding. I am mixing a bit of entropy into the
605
+ // min_limit since it produces much better (~0.5 %) compression results
606
+ // perhaps because of better entropy clustering.
607
+ if (nonzeros == 3) {
608
+ mix = 0.95;
609
+ } else {
610
+ mix = 0.7; // nonzeros == 4.
611
+ }
612
+ } else {
613
+ mix = 0.627;
614
+ }
615
+
616
+ {
617
+ double min_limit = 2 * sum - max_val;
618
+ min_limit = mix * min_limit + (1.0 - mix) * retval;
619
+ return (retval < min_limit) ? min_limit : retval;
620
+ }
621
+ }
622
+
623
+ // Returns the entropy for the symbols in the input array.
624
+ // Also sets trivial_symbol to the code value, if the array has only one code
625
+ // value. Otherwise, set it to VP8L_NON_TRIVIAL_SYM.
626
+ static double BitsEntropy(const uint32_t* const array, int n,
627
+ uint32_t* const trivial_symbol) {
628
+ double retval = 0.;
629
+ uint32_t sum = 0;
630
+ uint32_t nonzero_code = VP8L_NON_TRIVIAL_SYM;
631
+ int nonzeros = 0;
632
+ uint32_t max_val = 0;
633
+ int i;
634
+ for (i = 0; i < n; ++i) {
635
+ if (array[i] != 0) {
636
+ sum += array[i];
637
+ nonzero_code = i;
638
+ ++nonzeros;
639
+ retval -= VP8LFastSLog2(array[i]);
640
+ if (max_val < array[i]) {
641
+ max_val = array[i];
642
+ }
643
+ }
644
+ }
645
+ retval += VP8LFastSLog2(sum);
646
+ if (trivial_symbol != NULL) {
647
+ *trivial_symbol = (nonzeros == 1) ? nonzero_code : VP8L_NON_TRIVIAL_SYM;
648
+ }
649
+ return BitsEntropyRefine(nonzeros, sum, max_val, retval);
650
+ }
651
+
652
+ static double BitsEntropyCombined(const uint32_t* const X,
653
+ const uint32_t* const Y, int n) {
654
+ double retval = 0.;
655
+ int sum = 0;
656
+ int nonzeros = 0;
657
+ int max_val = 0;
658
+ int i;
659
+ for (i = 0; i < n; ++i) {
660
+ const int xy = X[i] + Y[i];
661
+ if (xy != 0) {
662
+ sum += xy;
663
+ ++nonzeros;
664
+ retval -= VP8LFastSLog2(xy);
665
+ if (max_val < xy) {
666
+ max_val = xy;
667
+ }
668
+ }
669
+ }
670
+ retval += VP8LFastSLog2(sum);
671
+ return BitsEntropyRefine(nonzeros, sum, max_val, retval);
672
+ }
673
+
674
+ static double InitialHuffmanCost(void) {
675
+ // Small bias because Huffman code length is typically not stored in
676
+ // full length.
677
+ static const int kHuffmanCodeOfHuffmanCodeSize = CODE_LENGTH_CODES * 3;
678
+ static const double kSmallBias = 9.1;
679
+ return kHuffmanCodeOfHuffmanCodeSize - kSmallBias;
680
+ }
681
+
682
+ // Finalize the Huffman cost based on streak numbers and length type (<3 or >=3)
683
+ static double FinalHuffmanCost(const VP8LStreaks* const stats) {
684
+ double retval = InitialHuffmanCost();
685
+ retval += stats->counts[0] * 1.5625 + 0.234375 * stats->streaks[0][1];
686
+ retval += stats->counts[1] * 2.578125 + 0.703125 * stats->streaks[1][1];
687
+ retval += 1.796875 * stats->streaks[0][0];
688
+ retval += 3.28125 * stats->streaks[1][0];
689
+ return retval;
690
+ }
691
+
692
+ // Trampolines
693
+ static double HuffmanCost(const uint32_t* const population, int length) {
694
+ const VP8LStreaks stats = VP8LHuffmanCostCount(population, length);
695
+ return FinalHuffmanCost(&stats);
696
+ }
697
+
698
+ static double HuffmanCostCombined(const uint32_t* const X,
699
+ const uint32_t* const Y, int length) {
700
+ const VP8LStreaks stats = VP8LHuffmanCostCombinedCount(X, Y, length);
701
+ return FinalHuffmanCost(&stats);
702
+ }
703
+
704
+ // Aggregated costs
705
+ double VP8LPopulationCost(const uint32_t* const population, int length,
706
+ uint32_t* const trivial_sym) {
707
+ return
708
+ BitsEntropy(population, length, trivial_sym) +
709
+ HuffmanCost(population, length);
710
+ }
711
+
712
+ double VP8LGetCombinedEntropy(const uint32_t* const X,
713
+ const uint32_t* const Y, int length) {
714
+ return BitsEntropyCombined(X, Y, length) + HuffmanCostCombined(X, Y, length);
715
+ }
716
+
717
+ // Estimates the Entropy + Huffman + other block overhead size cost.
718
+ double VP8LHistogramEstimateBits(const VP8LHistogram* const p) {
719
+ return
720
+ VP8LPopulationCost(
721
+ p->literal_, VP8LHistogramNumCodes(p->palette_code_bits_), NULL)
722
+ + VP8LPopulationCost(p->red_, NUM_LITERAL_CODES, NULL)
723
+ + VP8LPopulationCost(p->blue_, NUM_LITERAL_CODES, NULL)
724
+ + VP8LPopulationCost(p->alpha_, NUM_LITERAL_CODES, NULL)
725
+ + VP8LPopulationCost(p->distance_, NUM_DISTANCE_CODES, NULL)
726
+ + VP8LExtraCost(p->literal_ + NUM_LITERAL_CODES, NUM_LENGTH_CODES)
727
+ + VP8LExtraCost(p->distance_, NUM_DISTANCE_CODES);
728
+ }
729
+
730
+ double VP8LHistogramEstimateBitsBulk(const VP8LHistogram* const p) {
731
+ return
732
+ BitsEntropy(p->literal_, VP8LHistogramNumCodes(p->palette_code_bits_),
733
+ NULL)
734
+ + BitsEntropy(p->red_, NUM_LITERAL_CODES, NULL)
735
+ + BitsEntropy(p->blue_, NUM_LITERAL_CODES, NULL)
736
+ + BitsEntropy(p->alpha_, NUM_LITERAL_CODES, NULL)
737
+ + BitsEntropy(p->distance_, NUM_DISTANCE_CODES, NULL)
738
+ + VP8LExtraCost(p->literal_ + NUM_LITERAL_CODES, NUM_LENGTH_CODES)
739
+ + VP8LExtraCost(p->distance_, NUM_DISTANCE_CODES);
740
+ }
741
+
742
+ static WEBP_INLINE void UpdateHisto(int histo_argb[4][256], uint32_t argb) {
743
+ ++histo_argb[0][argb >> 24];
744
+ ++histo_argb[1][(argb >> 16) & 0xff];
745
+ ++histo_argb[2][(argb >> 8) & 0xff];
746
+ ++histo_argb[3][argb & 0xff];
747
+ }
748
+
749
+ //------------------------------------------------------------------------------
750
+
751
+ static int GetBestPredictorForTile(int width, int height,
752
+ int tile_x, int tile_y, int bits,
753
+ const int accumulated[4][256],
754
+ const uint32_t* const argb_scratch) {
755
+ const int kNumPredModes = 14;
756
+ const int col_start = tile_x << bits;
757
+ const int row_start = tile_y << bits;
758
+ const int tile_size = 1 << bits;
759
+ const int max_y = GetMin(tile_size, height - row_start);
760
+ const int max_x = GetMin(tile_size, width - col_start);
761
+ float best_diff = MAX_DIFF_COST;
762
+ int best_mode = 0;
763
+ int mode;
764
+ for (mode = 0; mode < kNumPredModes; ++mode) {
765
+ const uint32_t* current_row = argb_scratch;
766
+ const VP8LPredictorFunc pred_func = VP8LPredictors[mode];
767
+ float cur_diff;
768
+ int y;
769
+ int histo_argb[4][256];
770
+ memset(histo_argb, 0, sizeof(histo_argb));
771
+ for (y = 0; y < max_y; ++y) {
772
+ int x;
773
+ const int row = row_start + y;
774
+ const uint32_t* const upper_row = current_row;
775
+ current_row = upper_row + width;
776
+ for (x = 0; x < max_x; ++x) {
777
+ const int col = col_start + x;
778
+ uint32_t predict;
779
+ if (row == 0) {
780
+ predict = (col == 0) ? ARGB_BLACK : current_row[col - 1]; // Left.
781
+ } else if (col == 0) {
782
+ predict = upper_row[col]; // Top.
783
+ } else {
784
+ predict = pred_func(current_row[col - 1], upper_row + col);
785
+ }
786
+ UpdateHisto(histo_argb, VP8LSubPixels(current_row[col], predict));
787
+ }
788
+ }
789
+ cur_diff = PredictionCostSpatialHistogram(
790
+ accumulated, (const int (*)[256])histo_argb);
791
+ if (cur_diff < best_diff) {
792
+ best_diff = cur_diff;
793
+ best_mode = mode;
794
+ }
795
+ }
796
+
797
+ return best_mode;
798
+ }
799
+
800
+ static void CopyTileWithPrediction(int width, int height,
801
+ int tile_x, int tile_y, int bits, int mode,
802
+ const uint32_t* const argb_scratch,
803
+ uint32_t* const argb) {
804
+ const int col_start = tile_x << bits;
805
+ const int row_start = tile_y << bits;
806
+ const int tile_size = 1 << bits;
807
+ const int max_y = GetMin(tile_size, height - row_start);
808
+ const int max_x = GetMin(tile_size, width - col_start);
809
+ const VP8LPredictorFunc pred_func = VP8LPredictors[mode];
810
+ const uint32_t* current_row = argb_scratch;
811
+
812
+ int y;
813
+ for (y = 0; y < max_y; ++y) {
814
+ int x;
815
+ const int row = row_start + y;
816
+ const uint32_t* const upper_row = current_row;
817
+ current_row = upper_row + width;
818
+ for (x = 0; x < max_x; ++x) {
819
+ const int col = col_start + x;
820
+ const int pix = row * width + col;
821
+ uint32_t predict;
822
+ if (row == 0) {
823
+ predict = (col == 0) ? ARGB_BLACK : current_row[col - 1]; // Left.
824
+ } else if (col == 0) {
825
+ predict = upper_row[col]; // Top.
826
+ } else {
827
+ predict = pred_func(current_row[col - 1], upper_row + col);
828
+ }
829
+ argb[pix] = VP8LSubPixels(current_row[col], predict);
830
+ }
831
+ }
832
+ }
833
+
834
+ void VP8LResidualImage(int width, int height, int bits, int low_effort,
835
+ uint32_t* const argb, uint32_t* const argb_scratch,
836
+ uint32_t* const image) {
837
+ const int max_tile_size = 1 << bits;
838
+ const int tiles_per_row = VP8LSubSampleSize(width, bits);
839
+ const int tiles_per_col = VP8LSubSampleSize(height, bits);
840
+ const int kPredLowEffort = 11;
841
+ uint32_t* const upper_row = argb_scratch;
842
+ uint32_t* const current_tile_rows = argb_scratch + width;
843
+ int tile_y;
844
+ int histo[4][256];
845
+ memset(histo, 0, sizeof(histo));
846
+ for (tile_y = 0; tile_y < tiles_per_col; ++tile_y) {
847
+ const int tile_y_offset = tile_y * max_tile_size;
848
+ const int this_tile_height =
849
+ (tile_y < tiles_per_col - 1) ? max_tile_size : height - tile_y_offset;
850
+ int tile_x;
851
+ if (tile_y > 0) {
852
+ memcpy(upper_row, current_tile_rows + (max_tile_size - 1) * width,
853
+ width * sizeof(*upper_row));
854
+ }
855
+ memcpy(current_tile_rows, &argb[tile_y_offset * width],
856
+ this_tile_height * width * sizeof(*current_tile_rows));
857
+ for (tile_x = 0; tile_x < tiles_per_row; ++tile_x) {
858
+ int pred;
859
+ int y;
860
+ const int tile_x_offset = tile_x * max_tile_size;
861
+ int all_x_max = tile_x_offset + max_tile_size;
862
+ if (all_x_max > width) {
863
+ all_x_max = width;
864
+ }
865
+ pred = low_effort ? kPredLowEffort :
866
+ GetBestPredictorForTile(width, height, tile_x,
867
+ tile_y, bits,
868
+ (const int (*)[256])histo,
869
+ argb_scratch);
870
+ image[tile_y * tiles_per_row + tile_x] = 0xff000000u | (pred << 8);
871
+ CopyTileWithPrediction(width, height, tile_x, tile_y, bits, pred,
872
+ argb_scratch, argb);
873
+ for (y = 0; y < max_tile_size; ++y) {
874
+ int all_x;
875
+ int all_y = tile_y_offset + y;
876
+ if (all_y >= height) {
877
+ break;
878
+ }
879
+ for (all_x = tile_x_offset; all_x < all_x_max; ++all_x) {
880
+ UpdateHisto(histo, argb[all_y * width + all_x]);
881
+ }
882
+ }
883
+ }
884
+ }
885
+ }
886
+
887
+ // Inverse prediction.
888
+ static void PredictorInverseTransform(const VP8LTransform* const transform,
889
+ int y_start, int y_end, uint32_t* data) {
890
+ const int width = transform->xsize_;
891
+ if (y_start == 0) { // First Row follows the L (mode=1) mode.
892
+ int x;
893
+ const uint32_t pred0 = Predictor0(data[-1], NULL);
894
+ AddPixelsEq(data, pred0);
895
+ for (x = 1; x < width; ++x) {
896
+ const uint32_t pred1 = Predictor1(data[x - 1], NULL);
897
+ AddPixelsEq(data + x, pred1);
898
+ }
899
+ data += width;
900
+ ++y_start;
901
+ }
902
+
903
+ {
904
+ int y = y_start;
905
+ const int tile_width = 1 << transform->bits_;
906
+ const int mask = tile_width - 1;
907
+ const int safe_width = width & ~mask;
908
+ const int tiles_per_row = VP8LSubSampleSize(width, transform->bits_);
909
+ const uint32_t* pred_mode_base =
910
+ transform->data_ + (y >> transform->bits_) * tiles_per_row;
911
+
912
+ while (y < y_end) {
913
+ const uint32_t pred2 = Predictor2(data[-1], data - width);
914
+ const uint32_t* pred_mode_src = pred_mode_base;
915
+ VP8LPredictorFunc pred_func;
916
+ int x = 1;
917
+ int t = 1;
918
+ // First pixel follows the T (mode=2) mode.
919
+ AddPixelsEq(data, pred2);
920
+ // .. the rest:
921
+ while (x < safe_width) {
922
+ pred_func = VP8LPredictors[((*pred_mode_src++) >> 8) & 0xf];
923
+ for (; t < tile_width; ++t, ++x) {
924
+ const uint32_t pred = pred_func(data[x - 1], data + x - width);
925
+ AddPixelsEq(data + x, pred);
926
+ }
927
+ t = 0;
928
+ }
929
+ if (x < width) {
930
+ pred_func = VP8LPredictors[((*pred_mode_src++) >> 8) & 0xf];
931
+ for (; x < width; ++x) {
932
+ const uint32_t pred = pred_func(data[x - 1], data + x - width);
933
+ AddPixelsEq(data + x, pred);
934
+ }
935
+ }
936
+ data += width;
937
+ ++y;
938
+ if ((y & mask) == 0) { // Use the same mask, since tiles are squares.
939
+ pred_mode_base += tiles_per_row;
940
+ }
941
+ }
942
+ }
943
+ }
944
+
945
+ void VP8LSubtractGreenFromBlueAndRed_C(uint32_t* argb_data, int num_pixels) {
946
+ int i;
947
+ for (i = 0; i < num_pixels; ++i) {
948
+ const uint32_t argb = argb_data[i];
949
+ const uint32_t green = (argb >> 8) & 0xff;
950
+ const uint32_t new_r = (((argb >> 16) & 0xff) - green) & 0xff;
951
+ const uint32_t new_b = ((argb & 0xff) - green) & 0xff;
952
+ argb_data[i] = (argb & 0xff00ff00) | (new_r << 16) | new_b;
953
+ }
954
+ }
955
+
956
+ // Add green to blue and red channels (i.e. perform the inverse transform of
957
+ // 'subtract green').
958
+ void VP8LAddGreenToBlueAndRed_C(uint32_t* data, int num_pixels) {
959
+ int i;
960
+ for (i = 0; i < num_pixels; ++i) {
961
+ const uint32_t argb = data[i];
962
+ const uint32_t green = ((argb >> 8) & 0xff);
963
+ uint32_t red_blue = (argb & 0x00ff00ffu);
964
+ red_blue += (green << 16) | green;
965
+ red_blue &= 0x00ff00ffu;
966
+ data[i] = (argb & 0xff00ff00u) | red_blue;
967
+ }
968
+ }
969
+
970
+ static WEBP_INLINE void MultipliersClear(VP8LMultipliers* const m) {
971
+ m->green_to_red_ = 0;
972
+ m->green_to_blue_ = 0;
973
+ m->red_to_blue_ = 0;
974
+ }
975
+
976
+ static WEBP_INLINE uint32_t ColorTransformDelta(int8_t color_pred,
977
+ int8_t color) {
978
+ return (uint32_t)((int)(color_pred) * color) >> 5;
979
+ }
980
+
981
+ static WEBP_INLINE void ColorCodeToMultipliers(uint32_t color_code,
982
+ VP8LMultipliers* const m) {
983
+ m->green_to_red_ = (color_code >> 0) & 0xff;
984
+ m->green_to_blue_ = (color_code >> 8) & 0xff;
985
+ m->red_to_blue_ = (color_code >> 16) & 0xff;
986
+ }
987
+
988
+ static WEBP_INLINE uint32_t MultipliersToColorCode(
989
+ const VP8LMultipliers* const m) {
990
+ return 0xff000000u |
991
+ ((uint32_t)(m->red_to_blue_) << 16) |
992
+ ((uint32_t)(m->green_to_blue_) << 8) |
993
+ m->green_to_red_;
994
+ }
995
+
996
+ void VP8LTransformColor_C(const VP8LMultipliers* const m, uint32_t* data,
997
+ int num_pixels) {
998
+ int i;
999
+ for (i = 0; i < num_pixels; ++i) {
1000
+ const uint32_t argb = data[i];
1001
+ const uint32_t green = argb >> 8;
1002
+ const uint32_t red = argb >> 16;
1003
+ uint32_t new_red = red;
1004
+ uint32_t new_blue = argb;
1005
+ new_red -= ColorTransformDelta(m->green_to_red_, green);
1006
+ new_red &= 0xff;
1007
+ new_blue -= ColorTransformDelta(m->green_to_blue_, green);
1008
+ new_blue -= ColorTransformDelta(m->red_to_blue_, red);
1009
+ new_blue &= 0xff;
1010
+ data[i] = (argb & 0xff00ff00u) | (new_red << 16) | (new_blue);
1011
+ }
1012
+ }
1013
+
1014
+ void VP8LTransformColorInverse_C(const VP8LMultipliers* const m, uint32_t* data,
1015
+ int num_pixels) {
1016
+ int i;
1017
+ for (i = 0; i < num_pixels; ++i) {
1018
+ const uint32_t argb = data[i];
1019
+ const uint32_t green = argb >> 8;
1020
+ const uint32_t red = argb >> 16;
1021
+ uint32_t new_red = red;
1022
+ uint32_t new_blue = argb;
1023
+ new_red += ColorTransformDelta(m->green_to_red_, green);
1024
+ new_red &= 0xff;
1025
+ new_blue += ColorTransformDelta(m->green_to_blue_, green);
1026
+ new_blue += ColorTransformDelta(m->red_to_blue_, new_red);
1027
+ new_blue &= 0xff;
1028
+ data[i] = (argb & 0xff00ff00u) | (new_red << 16) | (new_blue);
1029
+ }
1030
+ }
1031
+
1032
+ static WEBP_INLINE uint8_t TransformColorRed(uint8_t green_to_red,
1033
+ uint32_t argb) {
1034
+ const uint32_t green = argb >> 8;
1035
+ uint32_t new_red = argb >> 16;
1036
+ new_red -= ColorTransformDelta(green_to_red, green);
1037
+ return (new_red & 0xff);
1038
+ }
1039
+
1040
+ static WEBP_INLINE uint8_t TransformColorBlue(uint8_t green_to_blue,
1041
+ uint8_t red_to_blue,
1042
+ uint32_t argb) {
1043
+ const uint32_t green = argb >> 8;
1044
+ const uint32_t red = argb >> 16;
1045
+ uint8_t new_blue = argb;
1046
+ new_blue -= ColorTransformDelta(green_to_blue, green);
1047
+ new_blue -= ColorTransformDelta(red_to_blue, red);
1048
+ return (new_blue & 0xff);
1049
+ }
1050
+
1051
+ static float PredictionCostCrossColor(const int accumulated[256],
1052
+ const int counts[256]) {
1053
+ // Favor low entropy, locally and globally.
1054
+ // Favor small absolute values for PredictionCostSpatial
1055
+ static const double kExpValue = 2.4;
1056
+ return CombinedShannonEntropy(counts, accumulated) +
1057
+ PredictionCostSpatial(counts, 3, kExpValue);
1058
+ }
1059
+
1060
+ static void CollectColorRedTransforms(const uint32_t* argb, int stride,
1061
+ int tile_width, int tile_height,
1062
+ int green_to_red, int histo[]) {
1063
+ while (tile_height-- > 0) {
1064
+ int x;
1065
+ for (x = 0; x < tile_width; ++x) {
1066
+ ++histo[TransformColorRed(green_to_red, argb[x])];
1067
+ }
1068
+ argb += stride;
1069
+ }
1070
+ }
1071
+
1072
+ static float GetPredictionCostCrossColorRed(
1073
+ const uint32_t* argb, int stride, int tile_width, int tile_height,
1074
+ VP8LMultipliers prev_x, VP8LMultipliers prev_y, int green_to_red,
1075
+ const int accumulated_red_histo[256]) {
1076
+ int histo[256] = { 0 };
1077
+ float cur_diff;
1078
+
1079
+ VP8LCollectColorRedTransforms(argb, stride, tile_width, tile_height,
1080
+ green_to_red, histo);
1081
+
1082
+ cur_diff = PredictionCostCrossColor(accumulated_red_histo, histo);
1083
+ if ((uint8_t)green_to_red == prev_x.green_to_red_) {
1084
+ cur_diff -= 3; // favor keeping the areas locally similar
1085
+ }
1086
+ if ((uint8_t)green_to_red == prev_y.green_to_red_) {
1087
+ cur_diff -= 3; // favor keeping the areas locally similar
1088
+ }
1089
+ if (green_to_red == 0) {
1090
+ cur_diff -= 3;
1091
+ }
1092
+ return cur_diff;
1093
+ }
1094
+
1095
+ static void GetBestGreenToRed(
1096
+ const uint32_t* argb, int stride, int tile_width, int tile_height,
1097
+ VP8LMultipliers prev_x, VP8LMultipliers prev_y,
1098
+ const int accumulated_red_histo[256], VP8LMultipliers* const best_tx) {
1099
+ int min_green_to_red = -64;
1100
+ int max_green_to_red = 64;
1101
+ int green_to_red = 0;
1102
+ int eval_min = 1;
1103
+ int eval_max = 1;
1104
+ float cur_diff_min = MAX_DIFF_COST;
1105
+ float cur_diff_max = MAX_DIFF_COST;
1106
+ // Do a binary search to find the optimal green_to_red color transform.
1107
+ while (max_green_to_red - min_green_to_red > 2) {
1108
+ if (eval_min) {
1109
+ cur_diff_min = GetPredictionCostCrossColorRed(
1110
+ argb, stride, tile_width, tile_height,
1111
+ prev_x, prev_y, min_green_to_red, accumulated_red_histo);
1112
+ eval_min = 0;
1113
+ }
1114
+ if (eval_max) {
1115
+ cur_diff_max = GetPredictionCostCrossColorRed(
1116
+ argb, stride, tile_width, tile_height,
1117
+ prev_x, prev_y, max_green_to_red, accumulated_red_histo);
1118
+ eval_max = 0;
1119
+ }
1120
+ if (cur_diff_min < cur_diff_max) {
1121
+ green_to_red = min_green_to_red;
1122
+ max_green_to_red = (max_green_to_red + min_green_to_red) / 2;
1123
+ eval_max = 1;
1124
+ } else {
1125
+ green_to_red = max_green_to_red;
1126
+ min_green_to_red = (max_green_to_red + min_green_to_red) / 2;
1127
+ eval_min = 1;
1128
+ }
1129
+ }
1130
+ best_tx->green_to_red_ = green_to_red;
1131
+ }
1132
+
1133
+ static void CollectColorBlueTransforms(const uint32_t* argb, int stride,
1134
+ int tile_width, int tile_height,
1135
+ int green_to_blue, int red_to_blue,
1136
+ int histo[]) {
1137
+ while (tile_height-- > 0) {
1138
+ int x;
1139
+ for (x = 0; x < tile_width; ++x) {
1140
+ ++histo[TransformColorBlue(green_to_blue, red_to_blue, argb[x])];
1141
+ }
1142
+ argb += stride;
1143
+ }
1144
+ }
1145
+
1146
+ static float GetPredictionCostCrossColorBlue(
1147
+ const uint32_t* argb, int stride, int tile_width, int tile_height,
1148
+ VP8LMultipliers prev_x, VP8LMultipliers prev_y,
1149
+ int green_to_blue, int red_to_blue, const int accumulated_blue_histo[256]) {
1150
+ int histo[256] = { 0 };
1151
+ float cur_diff;
1152
+
1153
+ VP8LCollectColorBlueTransforms(argb, stride, tile_width, tile_height,
1154
+ green_to_blue, red_to_blue, histo);
1155
+
1156
+ cur_diff = PredictionCostCrossColor(accumulated_blue_histo, histo);
1157
+ if ((uint8_t)green_to_blue == prev_x.green_to_blue_) {
1158
+ cur_diff -= 3; // favor keeping the areas locally similar
1159
+ }
1160
+ if ((uint8_t)green_to_blue == prev_y.green_to_blue_) {
1161
+ cur_diff -= 3; // favor keeping the areas locally similar
1162
+ }
1163
+ if ((uint8_t)red_to_blue == prev_x.red_to_blue_) {
1164
+ cur_diff -= 3; // favor keeping the areas locally similar
1165
+ }
1166
+ if ((uint8_t)red_to_blue == prev_y.red_to_blue_) {
1167
+ cur_diff -= 3; // favor keeping the areas locally similar
1168
+ }
1169
+ if (green_to_blue == 0) {
1170
+ cur_diff -= 3;
1171
+ }
1172
+ if (red_to_blue == 0) {
1173
+ cur_diff -= 3;
1174
+ }
1175
+ return cur_diff;
1176
+ }
1177
+
1178
+ static void GetBestGreenRedToBlue(
1179
+ const uint32_t* argb, int stride, int tile_width, int tile_height,
1180
+ VP8LMultipliers prev_x, VP8LMultipliers prev_y, int quality,
1181
+ const int accumulated_blue_histo[256],
1182
+ VP8LMultipliers* const best_tx) {
1183
+ float best_diff = MAX_DIFF_COST;
1184
+ float cur_diff;
1185
+ const int step = (quality < 25) ? 32 : (quality > 50) ? 8 : 16;
1186
+ const int min_green_to_blue = -32;
1187
+ const int max_green_to_blue = 32;
1188
+ const int min_red_to_blue = -32;
1189
+ const int max_red_to_blue = 32;
1190
+ const int num_iters =
1191
+ (1 + (max_green_to_blue - min_green_to_blue) / step) *
1192
+ (1 + (max_red_to_blue - min_red_to_blue) / step);
1193
+ // Number of tries to get optimal green_to_blue & red_to_blue color transforms
1194
+ // after finding a local minima.
1195
+ const int max_tries_after_min = 4 + (num_iters >> 2);
1196
+ int num_tries_after_min = 0;
1197
+ int green_to_blue;
1198
+ for (green_to_blue = min_green_to_blue;
1199
+ green_to_blue <= max_green_to_blue &&
1200
+ num_tries_after_min < max_tries_after_min;
1201
+ green_to_blue += step) {
1202
+ int red_to_blue;
1203
+ for (red_to_blue = min_red_to_blue;
1204
+ red_to_blue <= max_red_to_blue &&
1205
+ num_tries_after_min < max_tries_after_min;
1206
+ red_to_blue += step) {
1207
+ cur_diff = GetPredictionCostCrossColorBlue(
1208
+ argb, stride, tile_width, tile_height, prev_x, prev_y,
1209
+ green_to_blue, red_to_blue, accumulated_blue_histo);
1210
+ if (cur_diff < best_diff) {
1211
+ best_diff = cur_diff;
1212
+ best_tx->green_to_blue_ = green_to_blue;
1213
+ best_tx->red_to_blue_ = red_to_blue;
1214
+ num_tries_after_min = 0;
1215
+ } else {
1216
+ ++num_tries_after_min;
1217
+ }
1218
+ }
1219
+ }
1220
+ }
1221
+
1222
+ static VP8LMultipliers GetBestColorTransformForTile(
1223
+ int tile_x, int tile_y, int bits,
1224
+ VP8LMultipliers prev_x,
1225
+ VP8LMultipliers prev_y,
1226
+ int quality, int xsize, int ysize,
1227
+ const int accumulated_red_histo[256],
1228
+ const int accumulated_blue_histo[256],
1229
+ const uint32_t* const argb) {
1230
+ const int max_tile_size = 1 << bits;
1231
+ const int tile_y_offset = tile_y * max_tile_size;
1232
+ const int tile_x_offset = tile_x * max_tile_size;
1233
+ const int all_x_max = GetMin(tile_x_offset + max_tile_size, xsize);
1234
+ const int all_y_max = GetMin(tile_y_offset + max_tile_size, ysize);
1235
+ const int tile_width = all_x_max - tile_x_offset;
1236
+ const int tile_height = all_y_max - tile_y_offset;
1237
+ const uint32_t* const tile_argb = argb + tile_y_offset * xsize
1238
+ + tile_x_offset;
1239
+ VP8LMultipliers best_tx;
1240
+ MultipliersClear(&best_tx);
1241
+
1242
+ GetBestGreenToRed(tile_argb, xsize, tile_width, tile_height,
1243
+ prev_x, prev_y, accumulated_red_histo, &best_tx);
1244
+ GetBestGreenRedToBlue(tile_argb, xsize, tile_width, tile_height,
1245
+ prev_x, prev_y, quality, accumulated_blue_histo,
1246
+ &best_tx);
1247
+ return best_tx;
1248
+ }
1249
+
1250
+ static void CopyTileWithColorTransform(int xsize, int ysize,
1251
+ int tile_x, int tile_y,
1252
+ int max_tile_size,
1253
+ VP8LMultipliers color_transform,
1254
+ uint32_t* argb) {
1255
+ const int xscan = GetMin(max_tile_size, xsize - tile_x);
1256
+ int yscan = GetMin(max_tile_size, ysize - tile_y);
1257
+ argb += tile_y * xsize + tile_x;
1258
+ while (yscan-- > 0) {
1259
+ VP8LTransformColor(&color_transform, argb, xscan);
1260
+ argb += xsize;
1261
+ }
1262
+ }
1263
+
1264
+ void VP8LColorSpaceTransform(int width, int height, int bits, int quality,
1265
+ uint32_t* const argb, uint32_t* image) {
1266
+ const int max_tile_size = 1 << bits;
1267
+ const int tile_xsize = VP8LSubSampleSize(width, bits);
1268
+ const int tile_ysize = VP8LSubSampleSize(height, bits);
1269
+ int accumulated_red_histo[256] = { 0 };
1270
+ int accumulated_blue_histo[256] = { 0 };
1271
+ int tile_x, tile_y;
1272
+ VP8LMultipliers prev_x, prev_y;
1273
+ MultipliersClear(&prev_y);
1274
+ MultipliersClear(&prev_x);
1275
+ for (tile_y = 0; tile_y < tile_ysize; ++tile_y) {
1276
+ for (tile_x = 0; tile_x < tile_xsize; ++tile_x) {
1277
+ int y;
1278
+ const int tile_x_offset = tile_x * max_tile_size;
1279
+ const int tile_y_offset = tile_y * max_tile_size;
1280
+ const int all_x_max = GetMin(tile_x_offset + max_tile_size, width);
1281
+ const int all_y_max = GetMin(tile_y_offset + max_tile_size, height);
1282
+ const int offset = tile_y * tile_xsize + tile_x;
1283
+ if (tile_y != 0) {
1284
+ ColorCodeToMultipliers(image[offset - tile_xsize], &prev_y);
1285
+ }
1286
+ prev_x = GetBestColorTransformForTile(tile_x, tile_y, bits,
1287
+ prev_x, prev_y,
1288
+ quality, width, height,
1289
+ accumulated_red_histo,
1290
+ accumulated_blue_histo,
1291
+ argb);
1292
+ image[offset] = MultipliersToColorCode(&prev_x);
1293
+ CopyTileWithColorTransform(width, height, tile_x_offset, tile_y_offset,
1294
+ max_tile_size, prev_x, argb);
1295
+
1296
+ // Gather accumulated histogram data.
1297
+ for (y = tile_y_offset; y < all_y_max; ++y) {
1298
+ int ix = y * width + tile_x_offset;
1299
+ const int ix_end = ix + all_x_max - tile_x_offset;
1300
+ for (; ix < ix_end; ++ix) {
1301
+ const uint32_t pix = argb[ix];
1302
+ if (ix >= 2 &&
1303
+ pix == argb[ix - 2] &&
1304
+ pix == argb[ix - 1]) {
1305
+ continue; // repeated pixels are handled by backward references
1306
+ }
1307
+ if (ix >= width + 2 &&
1308
+ argb[ix - 2] == argb[ix - width - 2] &&
1309
+ argb[ix - 1] == argb[ix - width - 1] &&
1310
+ pix == argb[ix - width]) {
1311
+ continue; // repeated pixels are handled by backward references
1312
+ }
1313
+ ++accumulated_red_histo[(pix >> 16) & 0xff];
1314
+ ++accumulated_blue_histo[(pix >> 0) & 0xff];
1315
+ }
1316
+ }
1317
+ }
1318
+ }
1319
+ }
1320
+
1321
+ // Color space inverse transform.
1322
+ static void ColorSpaceInverseTransform(const VP8LTransform* const transform,
1323
+ int y_start, int y_end, uint32_t* data) {
1324
+ const int width = transform->xsize_;
1325
+ const int tile_width = 1 << transform->bits_;
1326
+ const int mask = tile_width - 1;
1327
+ const int safe_width = width & ~mask;
1328
+ const int remaining_width = width - safe_width;
1329
+ const int tiles_per_row = VP8LSubSampleSize(width, transform->bits_);
1330
+ int y = y_start;
1331
+ const uint32_t* pred_row =
1332
+ transform->data_ + (y >> transform->bits_) * tiles_per_row;
1333
+
1334
+ while (y < y_end) {
1335
+ const uint32_t* pred = pred_row;
1336
+ VP8LMultipliers m = { 0, 0, 0 };
1337
+ const uint32_t* const data_safe_end = data + safe_width;
1338
+ const uint32_t* const data_end = data + width;
1339
+ while (data < data_safe_end) {
1340
+ ColorCodeToMultipliers(*pred++, &m);
1341
+ VP8LTransformColorInverse(&m, data, tile_width);
1342
+ data += tile_width;
1343
+ }
1344
+ if (data < data_end) { // Left-overs using C-version.
1345
+ ColorCodeToMultipliers(*pred++, &m);
1346
+ VP8LTransformColorInverse(&m, data, remaining_width);
1347
+ data += remaining_width;
1348
+ }
1349
+ ++y;
1350
+ if ((y & mask) == 0) pred_row += tiles_per_row;
1351
+ }
1352
+ }
1353
+
1354
+ // Separate out pixels packed together using pixel-bundling.
1355
+ // We define two methods for ARGB data (uint32_t) and alpha-only data (uint8_t).
1356
+ #define COLOR_INDEX_INVERSE(FUNC_NAME, F_NAME, STATIC_DECL, TYPE, BIT_SUFFIX, \
1357
+ GET_INDEX, GET_VALUE) \
1358
+ static void F_NAME(const TYPE* src, const uint32_t* const color_map, \
1359
+ TYPE* dst, int y_start, int y_end, int width) { \
1360
+ int y; \
1361
+ for (y = y_start; y < y_end; ++y) { \
1362
+ int x; \
1363
+ for (x = 0; x < width; ++x) { \
1364
+ *dst++ = GET_VALUE(color_map[GET_INDEX(*src++)]); \
1365
+ } \
1366
+ } \
1367
+ } \
1368
+ STATIC_DECL void FUNC_NAME(const VP8LTransform* const transform, \
1369
+ int y_start, int y_end, const TYPE* src, \
1370
+ TYPE* dst) { \
1371
+ int y; \
1372
+ const int bits_per_pixel = 8 >> transform->bits_; \
1373
+ const int width = transform->xsize_; \
1374
+ const uint32_t* const color_map = transform->data_; \
1375
+ if (bits_per_pixel < 8) { \
1376
+ const int pixels_per_byte = 1 << transform->bits_; \
1377
+ const int count_mask = pixels_per_byte - 1; \
1378
+ const uint32_t bit_mask = (1 << bits_per_pixel) - 1; \
1379
+ for (y = y_start; y < y_end; ++y) { \
1380
+ uint32_t packed_pixels = 0; \
1381
+ int x; \
1382
+ for (x = 0; x < width; ++x) { \
1383
+ /* We need to load fresh 'packed_pixels' once every */ \
1384
+ /* 'pixels_per_byte' increments of x. Fortunately, pixels_per_byte */ \
1385
+ /* is a power of 2, so can just use a mask for that, instead of */ \
1386
+ /* decrementing a counter. */ \
1387
+ if ((x & count_mask) == 0) packed_pixels = GET_INDEX(*src++); \
1388
+ *dst++ = GET_VALUE(color_map[packed_pixels & bit_mask]); \
1389
+ packed_pixels >>= bits_per_pixel; \
1390
+ } \
1391
+ } \
1392
+ } else { \
1393
+ VP8LMapColor##BIT_SUFFIX(src, color_map, dst, y_start, y_end, width); \
1394
+ } \
1395
+ }
1396
+
1397
+ COLOR_INDEX_INVERSE(ColorIndexInverseTransform, MapARGB, static, uint32_t, 32b,
1398
+ VP8GetARGBIndex, VP8GetARGBValue)
1399
+ COLOR_INDEX_INVERSE(VP8LColorIndexInverseTransformAlpha, MapAlpha, , uint8_t,
1400
+ 8b, VP8GetAlphaIndex, VP8GetAlphaValue)
1401
+
1402
+ #undef COLOR_INDEX_INVERSE
1403
+
1404
+ void VP8LInverseTransform(const VP8LTransform* const transform,
1405
+ int row_start, int row_end,
1406
+ const uint32_t* const in, uint32_t* const out) {
1407
+ const int width = transform->xsize_;
1408
+ assert(row_start < row_end);
1409
+ assert(row_end <= transform->ysize_);
1410
+ switch (transform->type_) {
1411
+ case SUBTRACT_GREEN:
1412
+ VP8LAddGreenToBlueAndRed(out, (row_end - row_start) * width);
1413
+ break;
1414
+ case PREDICTOR_TRANSFORM:
1415
+ PredictorInverseTransform(transform, row_start, row_end, out);
1416
+ if (row_end != transform->ysize_) {
1417
+ // The last predicted row in this iteration will be the top-pred row
1418
+ // for the first row in next iteration.
1419
+ memcpy(out - width, out + (row_end - row_start - 1) * width,
1420
+ width * sizeof(*out));
1421
+ }
1422
+ break;
1423
+ case CROSS_COLOR_TRANSFORM:
1424
+ ColorSpaceInverseTransform(transform, row_start, row_end, out);
1425
+ break;
1426
+ case COLOR_INDEXING_TRANSFORM:
1427
+ if (in == out && transform->bits_ > 0) {
1428
+ // Move packed pixels to the end of unpacked region, so that unpacking
1429
+ // can occur seamlessly.
1430
+ // Also, note that this is the only transform that applies on
1431
+ // the effective width of VP8LSubSampleSize(xsize_, bits_). All other
1432
+ // transforms work on effective width of xsize_.
1433
+ const int out_stride = (row_end - row_start) * width;
1434
+ const int in_stride = (row_end - row_start) *
1435
+ VP8LSubSampleSize(transform->xsize_, transform->bits_);
1436
+ uint32_t* const src = out + out_stride - in_stride;
1437
+ memmove(src, out, in_stride * sizeof(*src));
1438
+ ColorIndexInverseTransform(transform, row_start, row_end, src, out);
1439
+ } else {
1440
+ ColorIndexInverseTransform(transform, row_start, row_end, in, out);
1441
+ }
1442
+ break;
1443
+ }
1444
+ }
1445
+
1446
+ //------------------------------------------------------------------------------
1447
+ // Color space conversion.
1448
+
1449
+ static int is_big_endian(void) {
1450
+ static const union {
1451
+ uint16_t w;
1452
+ uint8_t b[2];
1453
+ } tmp = { 1 };
1454
+ return (tmp.b[0] != 1);
1455
+ }
1456
+
1457
+ void VP8LConvertBGRAToRGB_C(const uint32_t* src,
1458
+ int num_pixels, uint8_t* dst) {
1459
+ const uint32_t* const src_end = src + num_pixels;
1460
+ while (src < src_end) {
1461
+ const uint32_t argb = *src++;
1462
+ *dst++ = (argb >> 16) & 0xff;
1463
+ *dst++ = (argb >> 8) & 0xff;
1464
+ *dst++ = (argb >> 0) & 0xff;
1465
+ }
1466
+ }
1467
+
1468
+ void VP8LConvertBGRAToRGBA_C(const uint32_t* src,
1469
+ int num_pixels, uint8_t* dst) {
1470
+ const uint32_t* const src_end = src + num_pixels;
1471
+ while (src < src_end) {
1472
+ const uint32_t argb = *src++;
1473
+ *dst++ = (argb >> 16) & 0xff;
1474
+ *dst++ = (argb >> 8) & 0xff;
1475
+ *dst++ = (argb >> 0) & 0xff;
1476
+ *dst++ = (argb >> 24) & 0xff;
1477
+ }
1478
+ }
1479
+
1480
+ void VP8LConvertBGRAToRGBA4444_C(const uint32_t* src,
1481
+ int num_pixels, uint8_t* dst) {
1482
+ const uint32_t* const src_end = src + num_pixels;
1483
+ while (src < src_end) {
1484
+ const uint32_t argb = *src++;
1485
+ const uint8_t rg = ((argb >> 16) & 0xf0) | ((argb >> 12) & 0xf);
1486
+ const uint8_t ba = ((argb >> 0) & 0xf0) | ((argb >> 28) & 0xf);
1487
+ #ifdef WEBP_SWAP_16BIT_CSP
1488
+ *dst++ = ba;
1489
+ *dst++ = rg;
1490
+ #else
1491
+ *dst++ = rg;
1492
+ *dst++ = ba;
1493
+ #endif
1494
+ }
1495
+ }
1496
+
1497
+ void VP8LConvertBGRAToRGB565_C(const uint32_t* src,
1498
+ int num_pixels, uint8_t* dst) {
1499
+ const uint32_t* const src_end = src + num_pixels;
1500
+ while (src < src_end) {
1501
+ const uint32_t argb = *src++;
1502
+ const uint8_t rg = ((argb >> 16) & 0xf8) | ((argb >> 13) & 0x7);
1503
+ const uint8_t gb = ((argb >> 5) & 0xe0) | ((argb >> 3) & 0x1f);
1504
+ #ifdef WEBP_SWAP_16BIT_CSP
1505
+ *dst++ = gb;
1506
+ *dst++ = rg;
1507
+ #else
1508
+ *dst++ = rg;
1509
+ *dst++ = gb;
1510
+ #endif
1511
+ }
1512
+ }
1513
+
1514
+ void VP8LConvertBGRAToBGR_C(const uint32_t* src,
1515
+ int num_pixels, uint8_t* dst) {
1516
+ const uint32_t* const src_end = src + num_pixels;
1517
+ while (src < src_end) {
1518
+ const uint32_t argb = *src++;
1519
+ *dst++ = (argb >> 0) & 0xff;
1520
+ *dst++ = (argb >> 8) & 0xff;
1521
+ *dst++ = (argb >> 16) & 0xff;
1522
+ }
1523
+ }
1524
+
1525
+ static void CopyOrSwap(const uint32_t* src, int num_pixels, uint8_t* dst,
1526
+ int swap_on_big_endian) {
1527
+ if (is_big_endian() == swap_on_big_endian) {
1528
+ const uint32_t* const src_end = src + num_pixels;
1529
+ while (src < src_end) {
1530
+ const uint32_t argb = *src++;
1531
+
1532
+ #if !defined(WORDS_BIGENDIAN)
1533
+ #if !defined(WEBP_REFERENCE_IMPLEMENTATION)
1534
+ *(uint32_t*)dst = BSwap32(argb);
1535
+ #else // WEBP_REFERENCE_IMPLEMENTATION
1536
+ dst[0] = (argb >> 24) & 0xff;
1537
+ dst[1] = (argb >> 16) & 0xff;
1538
+ dst[2] = (argb >> 8) & 0xff;
1539
+ dst[3] = (argb >> 0) & 0xff;
1540
+ #endif
1541
+ #else // WORDS_BIGENDIAN
1542
+ dst[0] = (argb >> 0) & 0xff;
1543
+ dst[1] = (argb >> 8) & 0xff;
1544
+ dst[2] = (argb >> 16) & 0xff;
1545
+ dst[3] = (argb >> 24) & 0xff;
1546
+ #endif
1547
+ dst += sizeof(argb);
1548
+ }
1549
+ } else {
1550
+ memcpy(dst, src, num_pixels * sizeof(*src));
1551
+ }
1552
+ }
1553
+
1554
+ void VP8LConvertFromBGRA(const uint32_t* const in_data, int num_pixels,
1555
+ WEBP_CSP_MODE out_colorspace, uint8_t* const rgba) {
1556
+ switch (out_colorspace) {
1557
+ case MODE_RGB:
1558
+ VP8LConvertBGRAToRGB(in_data, num_pixels, rgba);
1559
+ break;
1560
+ case MODE_RGBA:
1561
+ VP8LConvertBGRAToRGBA(in_data, num_pixels, rgba);
1562
+ break;
1563
+ case MODE_rgbA:
1564
+ VP8LConvertBGRAToRGBA(in_data, num_pixels, rgba);
1565
+ WebPApplyAlphaMultiply(rgba, 0, num_pixels, 1, 0);
1566
+ break;
1567
+ case MODE_BGR:
1568
+ VP8LConvertBGRAToBGR(in_data, num_pixels, rgba);
1569
+ break;
1570
+ case MODE_BGRA:
1571
+ CopyOrSwap(in_data, num_pixels, rgba, 1);
1572
+ break;
1573
+ case MODE_bgrA:
1574
+ CopyOrSwap(in_data, num_pixels, rgba, 1);
1575
+ WebPApplyAlphaMultiply(rgba, 0, num_pixels, 1, 0);
1576
+ break;
1577
+ case MODE_ARGB:
1578
+ CopyOrSwap(in_data, num_pixels, rgba, 0);
1579
+ break;
1580
+ case MODE_Argb:
1581
+ CopyOrSwap(in_data, num_pixels, rgba, 0);
1582
+ WebPApplyAlphaMultiply(rgba, 1, num_pixels, 1, 0);
1583
+ break;
1584
+ case MODE_RGBA_4444:
1585
+ VP8LConvertBGRAToRGBA4444(in_data, num_pixels, rgba);
1586
+ break;
1587
+ case MODE_rgbA_4444:
1588
+ VP8LConvertBGRAToRGBA4444(in_data, num_pixels, rgba);
1589
+ WebPApplyAlphaMultiply4444(rgba, num_pixels, 1, 0);
1590
+ break;
1591
+ case MODE_RGB_565:
1592
+ VP8LConvertBGRAToRGB565(in_data, num_pixels, rgba);
1593
+ break;
1594
+ default:
1595
+ assert(0); // Code flow should not reach here.
1596
+ }
1597
+ }
1598
+
1599
+ //------------------------------------------------------------------------------
1600
+ // Bundles multiple (1, 2, 4 or 8) pixels into a single pixel.
1601
+ void VP8LBundleColorMap(const uint8_t* const row, int width,
1602
+ int xbits, uint32_t* const dst) {
1603
+ int x;
1604
+ if (xbits > 0) {
1605
+ const int bit_depth = 1 << (3 - xbits);
1606
+ const int mask = (1 << xbits) - 1;
1607
+ uint32_t code = 0xff000000;
1608
+ for (x = 0; x < width; ++x) {
1609
+ const int xsub = x & mask;
1610
+ if (xsub == 0) {
1611
+ code = 0xff000000;
1612
+ }
1613
+ code |= row[x] << (8 + bit_depth * xsub);
1614
+ dst[x >> xbits] = code;
1615
+ }
1616
+ } else {
1617
+ for (x = 0; x < width; ++x) dst[x] = 0xff000000 | (row[x] << 8);
1618
+ }
1619
+ }
1620
+
1621
+ //------------------------------------------------------------------------------
1622
+
1623
+ static double ExtraCost(const uint32_t* population, int length) {
1624
+ int i;
1625
+ double cost = 0.;
1626
+ for (i = 2; i < length - 2; ++i) cost += (i >> 1) * population[i + 2];
1627
+ return cost;
1628
+ }
1629
+
1630
+ static double ExtraCostCombined(const uint32_t* X, const uint32_t* Y,
1631
+ int length) {
1632
+ int i;
1633
+ double cost = 0.;
1634
+ for (i = 2; i < length - 2; ++i) {
1635
+ const int xy = X[i + 2] + Y[i + 2];
1636
+ cost += (i >> 1) * xy;
1637
+ }
1638
+ return cost;
1639
+ }
1640
+
1641
+ // Returns the various RLE counts
1642
+ static VP8LStreaks HuffmanCostCount(const uint32_t* population, int length) {
1643
+ int i;
1644
+ int streak = 0;
1645
+ VP8LStreaks stats;
1646
+ memset(&stats, 0, sizeof(stats));
1647
+ for (i = 0; i < length - 1; ++i) {
1648
+ ++streak;
1649
+ if (population[i] == population[i + 1]) {
1650
+ continue;
1651
+ }
1652
+ stats.counts[population[i] != 0] += (streak > 3);
1653
+ stats.streaks[population[i] != 0][(streak > 3)] += streak;
1654
+ streak = 0;
1655
+ }
1656
+ ++streak;
1657
+ stats.counts[population[i] != 0] += (streak > 3);
1658
+ stats.streaks[population[i] != 0][(streak > 3)] += streak;
1659
+ return stats;
1660
+ }
1661
+
1662
+ static VP8LStreaks HuffmanCostCombinedCount(const uint32_t* X,
1663
+ const uint32_t* Y, int length) {
1664
+ int i;
1665
+ int streak = 0;
1666
+ VP8LStreaks stats;
1667
+ memset(&stats, 0, sizeof(stats));
1668
+ for (i = 0; i < length - 1; ++i) {
1669
+ const int xy = X[i] + Y[i];
1670
+ const int xy_next = X[i + 1] + Y[i + 1];
1671
+ ++streak;
1672
+ if (xy == xy_next) {
1673
+ continue;
1674
+ }
1675
+ stats.counts[xy != 0] += (streak > 3);
1676
+ stats.streaks[xy != 0][(streak > 3)] += streak;
1677
+ streak = 0;
1678
+ }
1679
+ {
1680
+ const int xy = X[i] + Y[i];
1681
+ ++streak;
1682
+ stats.counts[xy != 0] += (streak > 3);
1683
+ stats.streaks[xy != 0][(streak > 3)] += streak;
1684
+ }
1685
+ return stats;
1686
+ }
1687
+
1688
+ //------------------------------------------------------------------------------
1689
+
1690
+ static void HistogramAdd(const VP8LHistogram* const a,
1691
+ const VP8LHistogram* const b,
1692
+ VP8LHistogram* const out) {
1693
+ int i;
1694
+ const int literal_size = VP8LHistogramNumCodes(a->palette_code_bits_);
1695
+ assert(a->palette_code_bits_ == b->palette_code_bits_);
1696
+ if (b != out) {
1697
+ for (i = 0; i < literal_size; ++i) {
1698
+ out->literal_[i] = a->literal_[i] + b->literal_[i];
1699
+ }
1700
+ for (i = 0; i < NUM_DISTANCE_CODES; ++i) {
1701
+ out->distance_[i] = a->distance_[i] + b->distance_[i];
1702
+ }
1703
+ for (i = 0; i < NUM_LITERAL_CODES; ++i) {
1704
+ out->red_[i] = a->red_[i] + b->red_[i];
1705
+ out->blue_[i] = a->blue_[i] + b->blue_[i];
1706
+ out->alpha_[i] = a->alpha_[i] + b->alpha_[i];
1707
+ }
1708
+ } else {
1709
+ for (i = 0; i < literal_size; ++i) {
1710
+ out->literal_[i] += a->literal_[i];
1711
+ }
1712
+ for (i = 0; i < NUM_DISTANCE_CODES; ++i) {
1713
+ out->distance_[i] += a->distance_[i];
1714
+ }
1715
+ for (i = 0; i < NUM_LITERAL_CODES; ++i) {
1716
+ out->red_[i] += a->red_[i];
1717
+ out->blue_[i] += a->blue_[i];
1718
+ out->alpha_[i] += a->alpha_[i];
1719
+ }
1720
+ }
1721
+ }
1722
+
1723
+ //------------------------------------------------------------------------------
1724
+
1725
+ VP8LProcessBlueAndRedFunc VP8LSubtractGreenFromBlueAndRed;
1726
+ VP8LProcessBlueAndRedFunc VP8LAddGreenToBlueAndRed;
1727
+ VP8LPredictorFunc VP8LPredictors[16];
1728
+
1729
+ VP8LTransformColorFunc VP8LTransformColor;
1730
+ VP8LTransformColorFunc VP8LTransformColorInverse;
1731
+
1732
+ VP8LConvertFunc VP8LConvertBGRAToRGB;
1733
+ VP8LConvertFunc VP8LConvertBGRAToRGBA;
1734
+ VP8LConvertFunc VP8LConvertBGRAToRGBA4444;
1735
+ VP8LConvertFunc VP8LConvertBGRAToRGB565;
1736
+ VP8LConvertFunc VP8LConvertBGRAToBGR;
1737
+
1738
+ VP8LCollectColorBlueTransformsFunc VP8LCollectColorBlueTransforms;
1739
+ VP8LCollectColorRedTransformsFunc VP8LCollectColorRedTransforms;
1740
+
1741
+ VP8LFastLog2SlowFunc VP8LFastLog2Slow;
1742
+ VP8LFastLog2SlowFunc VP8LFastSLog2Slow;
1743
+
1744
+ VP8LCostFunc VP8LExtraCost;
1745
+ VP8LCostCombinedFunc VP8LExtraCostCombined;
1746
+
1747
+ VP8LCostCountFunc VP8LHuffmanCostCount;
1748
+ VP8LCostCombinedCountFunc VP8LHuffmanCostCombinedCount;
1749
+
1750
+ VP8LHistogramAddFunc VP8LHistogramAdd;
1751
+
1752
+ VP8LMapARGBFunc VP8LMapColor32b;
1753
+ VP8LMapAlphaFunc VP8LMapColor8b;
1754
+
1755
+ extern void VP8LDspInitSSE2(void);
1756
+ extern void VP8LDspInitNEON(void);
1757
+ extern void VP8LDspInitMIPS32(void);
1758
+ extern void VP8LDspInitMIPSdspR2(void);
1759
+
1760
+ static volatile VP8CPUInfo lossless_last_cpuinfo_used =
1761
+ (VP8CPUInfo)&lossless_last_cpuinfo_used;
1762
+
1763
+ WEBP_TSAN_IGNORE_FUNCTION void VP8LDspInit(void) {
1764
+ if (lossless_last_cpuinfo_used == VP8GetCPUInfo) return;
1765
+
1766
+ VP8LPredictors[0] = Predictor0;
1767
+ VP8LPredictors[1] = Predictor1;
1768
+ VP8LPredictors[2] = Predictor2;
1769
+ VP8LPredictors[3] = Predictor3;
1770
+ VP8LPredictors[4] = Predictor4;
1771
+ VP8LPredictors[5] = Predictor5;
1772
+ VP8LPredictors[6] = Predictor6;
1773
+ VP8LPredictors[7] = Predictor7;
1774
+ VP8LPredictors[8] = Predictor8;
1775
+ VP8LPredictors[9] = Predictor9;
1776
+ VP8LPredictors[10] = Predictor10;
1777
+ VP8LPredictors[11] = Predictor11;
1778
+ VP8LPredictors[12] = Predictor12;
1779
+ VP8LPredictors[13] = Predictor13;
1780
+ VP8LPredictors[14] = Predictor0; // <- padding security sentinels
1781
+ VP8LPredictors[15] = Predictor0;
1782
+
1783
+ VP8LSubtractGreenFromBlueAndRed = VP8LSubtractGreenFromBlueAndRed_C;
1784
+ VP8LAddGreenToBlueAndRed = VP8LAddGreenToBlueAndRed_C;
1785
+
1786
+ VP8LTransformColor = VP8LTransformColor_C;
1787
+ VP8LTransformColorInverse = VP8LTransformColorInverse_C;
1788
+
1789
+ VP8LConvertBGRAToRGB = VP8LConvertBGRAToRGB_C;
1790
+ VP8LConvertBGRAToRGBA = VP8LConvertBGRAToRGBA_C;
1791
+ VP8LConvertBGRAToRGBA4444 = VP8LConvertBGRAToRGBA4444_C;
1792
+ VP8LConvertBGRAToRGB565 = VP8LConvertBGRAToRGB565_C;
1793
+ VP8LConvertBGRAToBGR = VP8LConvertBGRAToBGR_C;
1794
+
1795
+ VP8LCollectColorBlueTransforms = CollectColorBlueTransforms;
1796
+ VP8LCollectColorRedTransforms = CollectColorRedTransforms;
1797
+
1798
+ VP8LFastLog2Slow = FastLog2Slow;
1799
+ VP8LFastSLog2Slow = FastSLog2Slow;
1800
+
1801
+ VP8LExtraCost = ExtraCost;
1802
+ VP8LExtraCostCombined = ExtraCostCombined;
1803
+
1804
+ VP8LHuffmanCostCount = HuffmanCostCount;
1805
+ VP8LHuffmanCostCombinedCount = HuffmanCostCombinedCount;
1806
+
1807
+ VP8LHistogramAdd = HistogramAdd;
1808
+
1809
+ VP8LMapColor32b = MapARGB;
1810
+ VP8LMapColor8b = MapAlpha;
1811
+
1812
+ // If defined, use CPUInfo() to overwrite some pointers with faster versions.
1813
+ if (VP8GetCPUInfo != NULL) {
1814
+ #if defined(WEBP_USE_SSE2)
1815
+ if (VP8GetCPUInfo(kSSE2)) {
1816
+ VP8LDspInitSSE2();
1817
+ }
1818
+ #endif
1819
+ #if defined(WEBP_USE_NEON)
1820
+ if (VP8GetCPUInfo(kNEON)) {
1821
+ VP8LDspInitNEON();
1822
+ }
1823
+ #endif
1824
+ #if defined(WEBP_USE_MIPS32)
1825
+ if (VP8GetCPUInfo(kMIPS32)) {
1826
+ VP8LDspInitMIPS32();
1827
+ }
1828
+ #endif
1829
+ #if defined(WEBP_USE_MIPS_DSP_R2)
1830
+ if (VP8GetCPUInfo(kMIPSdspR2)) {
1831
+ VP8LDspInitMIPSdspR2();
1832
+ }
1833
+ #endif
1834
+ }
1835
+ lossless_last_cpuinfo_used = VP8GetCPUInfo;
1836
+ }
1837
+
1838
+ //------------------------------------------------------------------------------