image_pack 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +18 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +140 -0
  5. data/THIRD_PARTY_NOTICES.md +8 -0
  6. data/ext/image_pack/extconf.rb +515 -0
  7. data/ext/image_pack/image_pack.c +1618 -0
  8. data/ext/image_pack/vendor/.vendored +1 -0
  9. data/ext/image_pack/vendor/mozjpeg/BUILDING.txt +902 -0
  10. data/ext/image_pack/vendor/mozjpeg/CMakeLists.txt +1593 -0
  11. data/ext/image_pack/vendor/mozjpeg/LICENSE.md +132 -0
  12. data/ext/image_pack/vendor/mozjpeg/README-mozilla.txt +194 -0
  13. data/ext/image_pack/vendor/mozjpeg/README-turbo.txt +346 -0
  14. data/ext/image_pack/vendor/mozjpeg/README.ijg +258 -0
  15. data/ext/image_pack/vendor/mozjpeg/README.md +29 -0
  16. data/ext/image_pack/vendor/mozjpeg/cderror.h +128 -0
  17. data/ext/image_pack/vendor/mozjpeg/cdjpeg.c +156 -0
  18. data/ext/image_pack/vendor/mozjpeg/cdjpeg.h +171 -0
  19. data/ext/image_pack/vendor/mozjpeg/cjpeg.c +961 -0
  20. data/ext/image_pack/vendor/mozjpeg/cmyk.h +60 -0
  21. data/ext/image_pack/vendor/mozjpeg/coderules.txt +78 -0
  22. data/ext/image_pack/vendor/mozjpeg/croptest.in +95 -0
  23. data/ext/image_pack/vendor/mozjpeg/djpeg.c +855 -0
  24. data/ext/image_pack/vendor/mozjpeg/example.txt +464 -0
  25. data/ext/image_pack/vendor/mozjpeg/jaricom.c +157 -0
  26. data/ext/image_pack/vendor/mozjpeg/jcapimin.c +307 -0
  27. data/ext/image_pack/vendor/mozjpeg/jcapistd.c +168 -0
  28. data/ext/image_pack/vendor/mozjpeg/jcarith.c +972 -0
  29. data/ext/image_pack/vendor/mozjpeg/jccoefct.c +609 -0
  30. data/ext/image_pack/vendor/mozjpeg/jccolext.c +144 -0
  31. data/ext/image_pack/vendor/mozjpeg/jccolor.c +721 -0
  32. data/ext/image_pack/vendor/mozjpeg/jcdctmgr.c +1776 -0
  33. data/ext/image_pack/vendor/mozjpeg/jcext.c +219 -0
  34. data/ext/image_pack/vendor/mozjpeg/jchuff.c +1146 -0
  35. data/ext/image_pack/vendor/mozjpeg/jchuff.h +57 -0
  36. data/ext/image_pack/vendor/mozjpeg/jcicc.c +105 -0
  37. data/ext/image_pack/vendor/mozjpeg/jcinit.c +82 -0
  38. data/ext/image_pack/vendor/mozjpeg/jcmainct.c +162 -0
  39. data/ext/image_pack/vendor/mozjpeg/jcmarker.c +844 -0
  40. data/ext/image_pack/vendor/mozjpeg/jcmaster.c +958 -0
  41. data/ext/image_pack/vendor/mozjpeg/jcmaster.h +56 -0
  42. data/ext/image_pack/vendor/mozjpeg/jcomapi.c +109 -0
  43. data/ext/image_pack/vendor/mozjpeg/jconfig.h.in +37 -0
  44. data/ext/image_pack/vendor/mozjpeg/jconfig.txt +93 -0
  45. data/ext/image_pack/vendor/mozjpeg/jconfigint.h.in +44 -0
  46. data/ext/image_pack/vendor/mozjpeg/jcparam.c +991 -0
  47. data/ext/image_pack/vendor/mozjpeg/jcphuff.c +1123 -0
  48. data/ext/image_pack/vendor/mozjpeg/jcprepct.c +351 -0
  49. data/ext/image_pack/vendor/mozjpeg/jcsample.c +522 -0
  50. data/ext/image_pack/vendor/mozjpeg/jcstest.c +126 -0
  51. data/ext/image_pack/vendor/mozjpeg/jctrans.c +408 -0
  52. data/ext/image_pack/vendor/mozjpeg/jdapimin.c +407 -0
  53. data/ext/image_pack/vendor/mozjpeg/jdapistd.c +691 -0
  54. data/ext/image_pack/vendor/mozjpeg/jdarith.c +782 -0
  55. data/ext/image_pack/vendor/mozjpeg/jdatadst-tj.c +198 -0
  56. data/ext/image_pack/vendor/mozjpeg/jdatadst.c +299 -0
  57. data/ext/image_pack/vendor/mozjpeg/jdatasrc-tj.c +194 -0
  58. data/ext/image_pack/vendor/mozjpeg/jdatasrc.c +295 -0
  59. data/ext/image_pack/vendor/mozjpeg/jdcoefct.c +881 -0
  60. data/ext/image_pack/vendor/mozjpeg/jdcoefct.h +83 -0
  61. data/ext/image_pack/vendor/mozjpeg/jdcol565.c +384 -0
  62. data/ext/image_pack/vendor/mozjpeg/jdcolext.c +141 -0
  63. data/ext/image_pack/vendor/mozjpeg/jdcolor.c +881 -0
  64. data/ext/image_pack/vendor/mozjpeg/jdct.h +208 -0
  65. data/ext/image_pack/vendor/mozjpeg/jddctmgr.c +367 -0
  66. data/ext/image_pack/vendor/mozjpeg/jdhuff.c +834 -0
  67. data/ext/image_pack/vendor/mozjpeg/jdhuff.h +247 -0
  68. data/ext/image_pack/vendor/mozjpeg/jdicc.c +167 -0
  69. data/ext/image_pack/vendor/mozjpeg/jdinput.c +408 -0
  70. data/ext/image_pack/vendor/mozjpeg/jdmainct.c +460 -0
  71. data/ext/image_pack/vendor/mozjpeg/jdmainct.h +71 -0
  72. data/ext/image_pack/vendor/mozjpeg/jdmarker.c +1374 -0
  73. data/ext/image_pack/vendor/mozjpeg/jdmaster.c +727 -0
  74. data/ext/image_pack/vendor/mozjpeg/jdmaster.h +33 -0
  75. data/ext/image_pack/vendor/mozjpeg/jdmerge.c +587 -0
  76. data/ext/image_pack/vendor/mozjpeg/jdmerge.h +47 -0
  77. data/ext/image_pack/vendor/mozjpeg/jdmrg565.c +354 -0
  78. data/ext/image_pack/vendor/mozjpeg/jdmrgext.c +184 -0
  79. data/ext/image_pack/vendor/mozjpeg/jdphuff.c +679 -0
  80. data/ext/image_pack/vendor/mozjpeg/jdpostct.c +294 -0
  81. data/ext/image_pack/vendor/mozjpeg/jdsample.c +524 -0
  82. data/ext/image_pack/vendor/mozjpeg/jdsample.h +50 -0
  83. data/ext/image_pack/vendor/mozjpeg/jdtrans.c +156 -0
  84. data/ext/image_pack/vendor/mozjpeg/jerror.c +251 -0
  85. data/ext/image_pack/vendor/mozjpeg/jerror.h +335 -0
  86. data/ext/image_pack/vendor/mozjpeg/jfdctflt.c +169 -0
  87. data/ext/image_pack/vendor/mozjpeg/jfdctfst.c +227 -0
  88. data/ext/image_pack/vendor/mozjpeg/jfdctint.c +288 -0
  89. data/ext/image_pack/vendor/mozjpeg/jidctflt.c +240 -0
  90. data/ext/image_pack/vendor/mozjpeg/jidctfst.c +371 -0
  91. data/ext/image_pack/vendor/mozjpeg/jidctint.c +2627 -0
  92. data/ext/image_pack/vendor/mozjpeg/jidctred.c +409 -0
  93. data/ext/image_pack/vendor/mozjpeg/jinclude.h +147 -0
  94. data/ext/image_pack/vendor/mozjpeg/jmemmgr.c +1180 -0
  95. data/ext/image_pack/vendor/mozjpeg/jmemnobs.c +110 -0
  96. data/ext/image_pack/vendor/mozjpeg/jmemsys.h +178 -0
  97. data/ext/image_pack/vendor/mozjpeg/jmorecfg.h +382 -0
  98. data/ext/image_pack/vendor/mozjpeg/jpeg_nbits_table.h +4098 -0
  99. data/ext/image_pack/vendor/mozjpeg/jpegcomp.h +32 -0
  100. data/ext/image_pack/vendor/mozjpeg/jpegint.h +453 -0
  101. data/ext/image_pack/vendor/mozjpeg/jpeglib.h +1211 -0
  102. data/ext/image_pack/vendor/mozjpeg/jpegtran.c +827 -0
  103. data/ext/image_pack/vendor/mozjpeg/jpegyuv.c +172 -0
  104. data/ext/image_pack/vendor/mozjpeg/jquant1.c +856 -0
  105. data/ext/image_pack/vendor/mozjpeg/jquant2.c +1286 -0
  106. data/ext/image_pack/vendor/mozjpeg/jsimd.h +123 -0
  107. data/ext/image_pack/vendor/mozjpeg/jsimd_none.c +431 -0
  108. data/ext/image_pack/vendor/mozjpeg/jsimddct.h +70 -0
  109. data/ext/image_pack/vendor/mozjpeg/jstdhuff.c +144 -0
  110. data/ext/image_pack/vendor/mozjpeg/jutils.c +133 -0
  111. data/ext/image_pack/vendor/mozjpeg/jversion.h.in +56 -0
  112. data/ext/image_pack/vendor/mozjpeg/libjpeg.map.in +11 -0
  113. data/ext/image_pack/vendor/mozjpeg/libjpeg.txt +3150 -0
  114. data/ext/image_pack/vendor/mozjpeg/rdbmp.c +690 -0
  115. data/ext/image_pack/vendor/mozjpeg/rdcolmap.c +253 -0
  116. data/ext/image_pack/vendor/mozjpeg/rdgif.c +720 -0
  117. data/ext/image_pack/vendor/mozjpeg/rdjpeg.c +160 -0
  118. data/ext/image_pack/vendor/mozjpeg/rdjpgcom.c +494 -0
  119. data/ext/image_pack/vendor/mozjpeg/rdpng.c +194 -0
  120. data/ext/image_pack/vendor/mozjpeg/rdppm.c +781 -0
  121. data/ext/image_pack/vendor/mozjpeg/rdswitch.c +642 -0
  122. data/ext/image_pack/vendor/mozjpeg/rdtarga.c +508 -0
  123. data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch32/jccolext-neon.c +148 -0
  124. data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch32/jchuff-neon.c +334 -0
  125. data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch32/jsimd.c +976 -0
  126. data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch32/jsimd_neon.S +1200 -0
  127. data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch64/jccolext-neon.c +316 -0
  128. data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch64/jchuff-neon.c +411 -0
  129. data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch64/jsimd.c +1053 -0
  130. data/ext/image_pack/vendor/mozjpeg/simd/arm/aarch64/jsimd_neon.S +2254 -0
  131. data/ext/image_pack/vendor/mozjpeg/simd/arm/align.h +28 -0
  132. data/ext/image_pack/vendor/mozjpeg/simd/arm/jccolor-neon.c +160 -0
  133. data/ext/image_pack/vendor/mozjpeg/simd/arm/jcgray-neon.c +120 -0
  134. data/ext/image_pack/vendor/mozjpeg/simd/arm/jcgryext-neon.c +106 -0
  135. data/ext/image_pack/vendor/mozjpeg/simd/arm/jchuff.h +131 -0
  136. data/ext/image_pack/vendor/mozjpeg/simd/arm/jcphuff-neon.c +623 -0
  137. data/ext/image_pack/vendor/mozjpeg/simd/arm/jcsample-neon.c +192 -0
  138. data/ext/image_pack/vendor/mozjpeg/simd/arm/jdcolext-neon.c +374 -0
  139. data/ext/image_pack/vendor/mozjpeg/simd/arm/jdcolor-neon.c +141 -0
  140. data/ext/image_pack/vendor/mozjpeg/simd/arm/jdmerge-neon.c +144 -0
  141. data/ext/image_pack/vendor/mozjpeg/simd/arm/jdmrgext-neon.c +723 -0
  142. data/ext/image_pack/vendor/mozjpeg/simd/arm/jdsample-neon.c +569 -0
  143. data/ext/image_pack/vendor/mozjpeg/simd/arm/jfdctfst-neon.c +214 -0
  144. data/ext/image_pack/vendor/mozjpeg/simd/arm/jfdctint-neon.c +376 -0
  145. data/ext/image_pack/vendor/mozjpeg/simd/arm/jidctfst-neon.c +472 -0
  146. data/ext/image_pack/vendor/mozjpeg/simd/arm/jidctint-neon.c +801 -0
  147. data/ext/image_pack/vendor/mozjpeg/simd/arm/jidctred-neon.c +486 -0
  148. data/ext/image_pack/vendor/mozjpeg/simd/arm/jquanti-neon.c +193 -0
  149. data/ext/image_pack/vendor/mozjpeg/simd/arm/neon-compat.h +26 -0
  150. data/ext/image_pack/vendor/mozjpeg/simd/arm/neon-compat.h.in +37 -0
  151. data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolext-avx2.asm +578 -0
  152. data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolext-mmx.asm +476 -0
  153. data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolext-sse2.asm +503 -0
  154. data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolor-avx2.asm +121 -0
  155. data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolor-mmx.asm +121 -0
  156. data/ext/image_pack/vendor/mozjpeg/simd/i386/jccolor-sse2.asm +120 -0
  157. data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgray-avx2.asm +113 -0
  158. data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgray-mmx.asm +113 -0
  159. data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgray-sse2.asm +112 -0
  160. data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgryext-avx2.asm +457 -0
  161. data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgryext-mmx.asm +355 -0
  162. data/ext/image_pack/vendor/mozjpeg/simd/i386/jcgryext-sse2.asm +382 -0
  163. data/ext/image_pack/vendor/mozjpeg/simd/i386/jchuff-sse2.asm +761 -0
  164. data/ext/image_pack/vendor/mozjpeg/simd/i386/jcphuff-sse2.asm +662 -0
  165. data/ext/image_pack/vendor/mozjpeg/simd/i386/jcsample-avx2.asm +388 -0
  166. data/ext/image_pack/vendor/mozjpeg/simd/i386/jcsample-mmx.asm +324 -0
  167. data/ext/image_pack/vendor/mozjpeg/simd/i386/jcsample-sse2.asm +351 -0
  168. data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolext-avx2.asm +515 -0
  169. data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolext-mmx.asm +404 -0
  170. data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolext-sse2.asm +458 -0
  171. data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolor-avx2.asm +118 -0
  172. data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolor-mmx.asm +117 -0
  173. data/ext/image_pack/vendor/mozjpeg/simd/i386/jdcolor-sse2.asm +117 -0
  174. data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmerge-avx2.asm +136 -0
  175. data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmerge-mmx.asm +123 -0
  176. data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmerge-sse2.asm +135 -0
  177. data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmrgext-avx2.asm +575 -0
  178. data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmrgext-mmx.asm +460 -0
  179. data/ext/image_pack/vendor/mozjpeg/simd/i386/jdmrgext-sse2.asm +517 -0
  180. data/ext/image_pack/vendor/mozjpeg/simd/i386/jdsample-avx2.asm +760 -0
  181. data/ext/image_pack/vendor/mozjpeg/simd/i386/jdsample-mmx.asm +731 -0
  182. data/ext/image_pack/vendor/mozjpeg/simd/i386/jdsample-sse2.asm +724 -0
  183. data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctflt-3dn.asm +318 -0
  184. data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctflt-sse.asm +369 -0
  185. data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctfst-mmx.asm +395 -0
  186. data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctfst-sse2.asm +403 -0
  187. data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctint-avx2.asm +331 -0
  188. data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctint-mmx.asm +620 -0
  189. data/ext/image_pack/vendor/mozjpeg/simd/i386/jfdctint-sse2.asm +633 -0
  190. data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctflt-3dn.asm +451 -0
  191. data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctflt-sse.asm +571 -0
  192. data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctflt-sse2.asm +497 -0
  193. data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctfst-mmx.asm +499 -0
  194. data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctfst-sse2.asm +501 -0
  195. data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctint-avx2.asm +453 -0
  196. data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctint-mmx.asm +851 -0
  197. data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctint-sse2.asm +858 -0
  198. data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctred-mmx.asm +704 -0
  199. data/ext/image_pack/vendor/mozjpeg/simd/i386/jidctred-sse2.asm +592 -0
  200. data/ext/image_pack/vendor/mozjpeg/simd/i386/jquant-3dn.asm +230 -0
  201. data/ext/image_pack/vendor/mozjpeg/simd/i386/jquant-mmx.asm +276 -0
  202. data/ext/image_pack/vendor/mozjpeg/simd/i386/jquant-sse.asm +208 -0
  203. data/ext/image_pack/vendor/mozjpeg/simd/i386/jquantf-sse2.asm +168 -0
  204. data/ext/image_pack/vendor/mozjpeg/simd/i386/jquanti-avx2.asm +188 -0
  205. data/ext/image_pack/vendor/mozjpeg/simd/i386/jquanti-sse2.asm +201 -0
  206. data/ext/image_pack/vendor/mozjpeg/simd/i386/jsimd.c +1312 -0
  207. data/ext/image_pack/vendor/mozjpeg/simd/i386/jsimdcpu.asm +135 -0
  208. data/ext/image_pack/vendor/mozjpeg/simd/jsimd.h +1258 -0
  209. data/ext/image_pack/vendor/mozjpeg/simd/mips/jsimd.c +1143 -0
  210. data/ext/image_pack/vendor/mozjpeg/simd/mips/jsimd_dspr2.S +4543 -0
  211. data/ext/image_pack/vendor/mozjpeg/simd/mips/jsimd_dspr2_asm.h +292 -0
  212. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jccolext-mmi.c +455 -0
  213. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jccolor-mmi.c +148 -0
  214. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jcgray-mmi.c +132 -0
  215. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jcgryext-mmi.c +374 -0
  216. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jcsample-mmi.c +98 -0
  217. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jcsample.h +28 -0
  218. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdcolext-mmi.c +415 -0
  219. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdcolor-mmi.c +139 -0
  220. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdmerge-mmi.c +149 -0
  221. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdmrgext-mmi.c +615 -0
  222. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jdsample-mmi.c +304 -0
  223. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jfdctfst-mmi.c +255 -0
  224. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jfdctint-mmi.c +398 -0
  225. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jidctfst-mmi.c +395 -0
  226. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jidctint-mmi.c +571 -0
  227. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jquanti-mmi.c +124 -0
  228. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jsimd.c +866 -0
  229. data/ext/image_pack/vendor/mozjpeg/simd/mips64/jsimd_mmi.h +69 -0
  230. data/ext/image_pack/vendor/mozjpeg/simd/mips64/loongson-mmintrin.h +1334 -0
  231. data/ext/image_pack/vendor/mozjpeg/simd/nasm/jcolsamp.inc +135 -0
  232. data/ext/image_pack/vendor/mozjpeg/simd/nasm/jdct.inc +31 -0
  233. data/ext/image_pack/vendor/mozjpeg/simd/nasm/jsimdcfg.inc +93 -0
  234. data/ext/image_pack/vendor/mozjpeg/simd/nasm/jsimdcfg.inc.h +133 -0
  235. data/ext/image_pack/vendor/mozjpeg/simd/nasm/jsimdext.inc +520 -0
  236. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jccolext-altivec.c +269 -0
  237. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jccolor-altivec.c +116 -0
  238. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jcgray-altivec.c +111 -0
  239. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jcgryext-altivec.c +228 -0
  240. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jcsample-altivec.c +159 -0
  241. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jcsample.h +28 -0
  242. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdcolext-altivec.c +276 -0
  243. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdcolor-altivec.c +106 -0
  244. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdmerge-altivec.c +130 -0
  245. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdmrgext-altivec.c +329 -0
  246. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jdsample-altivec.c +400 -0
  247. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jfdctfst-altivec.c +154 -0
  248. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jfdctint-altivec.c +258 -0
  249. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jidctfst-altivec.c +255 -0
  250. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jidctint-altivec.c +357 -0
  251. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jquanti-altivec.c +250 -0
  252. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jsimd.c +884 -0
  253. data/ext/image_pack/vendor/mozjpeg/simd/powerpc/jsimd_altivec.h +98 -0
  254. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jccolext-avx2.asm +559 -0
  255. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jccolext-sse2.asm +484 -0
  256. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jccolor-avx2.asm +121 -0
  257. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jccolor-sse2.asm +120 -0
  258. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jcgray-avx2.asm +113 -0
  259. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jcgray-sse2.asm +112 -0
  260. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jcgryext-avx2.asm +438 -0
  261. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jcgryext-sse2.asm +363 -0
  262. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jchuff-sse2.asm +583 -0
  263. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jcphuff-sse2.asm +639 -0
  264. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jcsample-avx2.asm +367 -0
  265. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jcsample-sse2.asm +330 -0
  266. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdcolext-avx2.asm +496 -0
  267. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdcolext-sse2.asm +439 -0
  268. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdcolor-avx2.asm +118 -0
  269. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdcolor-sse2.asm +117 -0
  270. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdmerge-avx2.asm +136 -0
  271. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdmerge-sse2.asm +135 -0
  272. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdmrgext-avx2.asm +596 -0
  273. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdmrgext-sse2.asm +538 -0
  274. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdsample-avx2.asm +696 -0
  275. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jdsample-sse2.asm +665 -0
  276. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jfdctflt-sse.asm +355 -0
  277. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jfdctfst-sse2.asm +389 -0
  278. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jfdctint-avx2.asm +320 -0
  279. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jfdctint-sse2.asm +619 -0
  280. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jidctflt-sse2.asm +482 -0
  281. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jidctfst-sse2.asm +491 -0
  282. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jidctint-avx2.asm +418 -0
  283. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jidctint-sse2.asm +847 -0
  284. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jidctred-sse2.asm +574 -0
  285. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jquantf-sse2.asm +155 -0
  286. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jquanti-avx2.asm +163 -0
  287. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jquanti-sse2.asm +188 -0
  288. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jsimd.c +1110 -0
  289. data/ext/image_pack/vendor/mozjpeg/simd/x86_64/jsimdcpu.asm +86 -0
  290. data/ext/image_pack/vendor/mozjpeg/strtest.c +170 -0
  291. data/ext/image_pack/vendor/mozjpeg/structure.txt +900 -0
  292. data/ext/image_pack/vendor/mozjpeg/tjbench.c +1044 -0
  293. data/ext/image_pack/vendor/mozjpeg/tjbenchtest.in +256 -0
  294. data/ext/image_pack/vendor/mozjpeg/tjbenchtest.java.in +215 -0
  295. data/ext/image_pack/vendor/mozjpeg/tjexample.c +406 -0
  296. data/ext/image_pack/vendor/mozjpeg/tjexampletest.in +149 -0
  297. data/ext/image_pack/vendor/mozjpeg/tjexampletest.java.in +151 -0
  298. data/ext/image_pack/vendor/mozjpeg/tjunittest.c +961 -0
  299. data/ext/image_pack/vendor/mozjpeg/tjutil.c +70 -0
  300. data/ext/image_pack/vendor/mozjpeg/tjutil.h +53 -0
  301. data/ext/image_pack/vendor/mozjpeg/transupp.c +2373 -0
  302. data/ext/image_pack/vendor/mozjpeg/transupp.h +243 -0
  303. data/ext/image_pack/vendor/mozjpeg/turbojpeg-jni.c +1259 -0
  304. data/ext/image_pack/vendor/mozjpeg/turbojpeg.c +2320 -0
  305. data/ext/image_pack/vendor/mozjpeg/turbojpeg.h +1784 -0
  306. data/ext/image_pack/vendor/mozjpeg/usage.txt +679 -0
  307. data/ext/image_pack/vendor/mozjpeg/wizard.txt +220 -0
  308. data/ext/image_pack/vendor/mozjpeg/wrbmp.c +552 -0
  309. data/ext/image_pack/vendor/mozjpeg/wrgif.c +580 -0
  310. data/ext/image_pack/vendor/mozjpeg/wrjpgcom.c +577 -0
  311. data/ext/image_pack/vendor/mozjpeg/wrppm.c +366 -0
  312. data/ext/image_pack/vendor/mozjpeg/wrtarga.c +258 -0
  313. data/ext/image_pack/vendor/mozjpeg/yuvjpeg.c +268 -0
  314. data/lib/image_pack/backend.rb +8 -0
  315. data/lib/image_pack/configuration.rb +23 -0
  316. data/lib/image_pack/errors.rb +13 -0
  317. data/lib/image_pack/version.rb +5 -0
  318. data/lib/image_pack.rb +208 -0
  319. metadata +433 -0
@@ -0,0 +1,508 @@
1
+ /*
2
+ * rdtarga.c
3
+ *
4
+ * This file was part of the Independent JPEG Group's software:
5
+ * Copyright (C) 1991-1996, Thomas G. Lane.
6
+ * Modified 2017 by Guido Vollbeding.
7
+ * libjpeg-turbo Modifications:
8
+ * Copyright (C) 2018, 2021-2022, D. R. Commander.
9
+ * For conditions of distribution and use, see the accompanying README.ijg
10
+ * file.
11
+ *
12
+ * This file contains routines to read input images in Targa format.
13
+ *
14
+ * These routines may need modification for non-Unix environments or
15
+ * specialized applications. As they stand, they assume input from
16
+ * an ordinary stdio stream. They further assume that reading begins
17
+ * at the start of the file; start_input may need work if the
18
+ * user interface has already read some data (e.g., to determine that
19
+ * the file is indeed Targa format).
20
+ *
21
+ * Based on code contributed by Lee Daniel Crocker.
22
+ */
23
+
24
+ #include "cdjpeg.h" /* Common decls for cjpeg/djpeg applications */
25
+
26
+ #ifdef TARGA_SUPPORTED
27
+
28
+
29
+ /* Macros to deal with unsigned chars as efficiently as compiler allows */
30
+
31
+ typedef unsigned char U_CHAR;
32
+ #define UCH(x) ((int)(x))
33
+
34
+
35
+ #define ReadOK(file, buffer, len) \
36
+ (fread(buffer, 1, len, file) == ((size_t)(len)))
37
+
38
+
39
+ /* Private version of data source object */
40
+
41
+ typedef struct _tga_source_struct *tga_source_ptr;
42
+
43
+ typedef struct _tga_source_struct {
44
+ struct cjpeg_source_struct pub; /* public fields */
45
+
46
+ j_compress_ptr cinfo; /* back link saves passing separate parm */
47
+
48
+ JSAMPARRAY colormap; /* Targa colormap (converted to my format) */
49
+
50
+ jvirt_sarray_ptr whole_image; /* Needed if funny input row order */
51
+ JDIMENSION current_row; /* Current logical row number to read */
52
+
53
+ /* Pointer to routine to extract next Targa pixel from input file */
54
+ void (*read_pixel) (tga_source_ptr sinfo);
55
+
56
+ /* Result of read_pixel is delivered here: */
57
+ U_CHAR tga_pixel[4];
58
+
59
+ int pixel_size; /* Bytes per Targa pixel (1 to 4) */
60
+ int cmap_length; /* colormap length */
61
+
62
+ /* State info for reading RLE-coded pixels; both counts must be init to 0 */
63
+ int block_count; /* # of pixels remaining in RLE block */
64
+ int dup_pixel_count; /* # of times to duplicate previous pixel */
65
+
66
+ /* This saves the correct pixel-row-expansion method for preload_image */
67
+ JDIMENSION (*get_pixel_rows) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
68
+ } tga_source_struct;
69
+
70
+
71
+ /* For expanding 5-bit pixel values to 8-bit with best rounding */
72
+
73
+ static const UINT8 c5to8bits[32] = {
74
+ 0, 8, 16, 25, 33, 41, 49, 58,
75
+ 66, 74, 82, 90, 99, 107, 115, 123,
76
+ 132, 140, 148, 156, 165, 173, 181, 189,
77
+ 197, 206, 214, 222, 230, 239, 247, 255
78
+ };
79
+
80
+
81
+
82
+ LOCAL(int)
83
+ read_byte(tga_source_ptr sinfo)
84
+ /* Read next byte from Targa file */
85
+ {
86
+ register FILE *infile = sinfo->pub.input_file;
87
+ register int c;
88
+
89
+ if ((c = getc(infile)) == EOF)
90
+ ERREXIT(sinfo->cinfo, JERR_INPUT_EOF);
91
+ return c;
92
+ }
93
+
94
+
95
+ LOCAL(void)
96
+ read_colormap(tga_source_ptr sinfo, int cmaplen, int mapentrysize)
97
+ /* Read the colormap from a Targa file */
98
+ {
99
+ int i;
100
+
101
+ /* Presently only handles 24-bit BGR format */
102
+ if (mapentrysize != 24)
103
+ ERREXIT(sinfo->cinfo, JERR_TGA_BADCMAP);
104
+
105
+ for (i = 0; i < cmaplen; i++) {
106
+ sinfo->colormap[2][i] = (JSAMPLE)read_byte(sinfo);
107
+ sinfo->colormap[1][i] = (JSAMPLE)read_byte(sinfo);
108
+ sinfo->colormap[0][i] = (JSAMPLE)read_byte(sinfo);
109
+ }
110
+ }
111
+
112
+
113
+ /*
114
+ * read_pixel methods: get a single pixel from Targa file into tga_pixel[]
115
+ */
116
+
117
+ METHODDEF(void)
118
+ read_non_rle_pixel(tga_source_ptr sinfo)
119
+ /* Read one Targa pixel from the input file; no RLE expansion */
120
+ {
121
+ register int i;
122
+
123
+ for (i = 0; i < sinfo->pixel_size; i++) {
124
+ sinfo->tga_pixel[i] = (U_CHAR)read_byte(sinfo);
125
+ }
126
+ }
127
+
128
+
129
+ METHODDEF(void)
130
+ read_rle_pixel(tga_source_ptr sinfo)
131
+ /* Read one Targa pixel from the input file, expanding RLE data as needed */
132
+ {
133
+ register int i;
134
+
135
+ /* Duplicate previously read pixel? */
136
+ if (sinfo->dup_pixel_count > 0) {
137
+ sinfo->dup_pixel_count--;
138
+ return;
139
+ }
140
+
141
+ /* Time to read RLE block header? */
142
+ if (--sinfo->block_count < 0) { /* decrement pixels remaining in block */
143
+ i = read_byte(sinfo);
144
+ if (i & 0x80) { /* Start of duplicate-pixel block? */
145
+ sinfo->dup_pixel_count = i & 0x7F; /* number of dups after this one */
146
+ sinfo->block_count = 0; /* then read new block header */
147
+ } else {
148
+ sinfo->block_count = i & 0x7F; /* number of pixels after this one */
149
+ }
150
+ }
151
+
152
+ /* Read next pixel */
153
+ for (i = 0; i < sinfo->pixel_size; i++) {
154
+ sinfo->tga_pixel[i] = (U_CHAR)read_byte(sinfo);
155
+ }
156
+ }
157
+
158
+
159
+ /*
160
+ * Read one row of pixels.
161
+ *
162
+ * We provide several different versions depending on input file format.
163
+ */
164
+
165
+
166
+ METHODDEF(JDIMENSION)
167
+ get_8bit_gray_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
168
+ /* This version is for reading 8-bit grayscale pixels */
169
+ {
170
+ tga_source_ptr source = (tga_source_ptr)sinfo;
171
+ register JSAMPROW ptr;
172
+ register JDIMENSION col;
173
+
174
+ ptr = source->pub.buffer[0];
175
+ for (col = cinfo->image_width; col > 0; col--) {
176
+ (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
177
+ *ptr++ = (JSAMPLE)UCH(source->tga_pixel[0]);
178
+ }
179
+ return 1;
180
+ }
181
+
182
+ METHODDEF(JDIMENSION)
183
+ get_8bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
184
+ /* This version is for reading 8-bit colormap indexes */
185
+ {
186
+ tga_source_ptr source = (tga_source_ptr)sinfo;
187
+ register int t;
188
+ register JSAMPROW ptr;
189
+ register JDIMENSION col;
190
+ register JSAMPARRAY colormap = source->colormap;
191
+ int cmaplen = source->cmap_length;
192
+
193
+ ptr = source->pub.buffer[0];
194
+ for (col = cinfo->image_width; col > 0; col--) {
195
+ (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
196
+ t = UCH(source->tga_pixel[0]);
197
+ if (t >= cmaplen)
198
+ ERREXIT(cinfo, JERR_TGA_BADPARMS);
199
+ *ptr++ = colormap[0][t];
200
+ *ptr++ = colormap[1][t];
201
+ *ptr++ = colormap[2][t];
202
+ }
203
+ return 1;
204
+ }
205
+
206
+ METHODDEF(JDIMENSION)
207
+ get_16bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
208
+ /* This version is for reading 16-bit pixels */
209
+ {
210
+ tga_source_ptr source = (tga_source_ptr)sinfo;
211
+ register int t;
212
+ register JSAMPROW ptr;
213
+ register JDIMENSION col;
214
+
215
+ ptr = source->pub.buffer[0];
216
+ for (col = cinfo->image_width; col > 0; col--) {
217
+ (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
218
+ t = UCH(source->tga_pixel[0]);
219
+ t += UCH(source->tga_pixel[1]) << 8;
220
+ /* We expand 5 bit data to 8 bit sample width.
221
+ * The format of the 16-bit (LSB first) input word is
222
+ * xRRRRRGGGGGBBBBB
223
+ */
224
+ ptr[2] = (JSAMPLE)c5to8bits[t & 0x1F];
225
+ t >>= 5;
226
+ ptr[1] = (JSAMPLE)c5to8bits[t & 0x1F];
227
+ t >>= 5;
228
+ ptr[0] = (JSAMPLE)c5to8bits[t & 0x1F];
229
+ ptr += 3;
230
+ }
231
+ return 1;
232
+ }
233
+
234
+ METHODDEF(JDIMENSION)
235
+ get_24bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
236
+ /* This version is for reading 24-bit pixels */
237
+ {
238
+ tga_source_ptr source = (tga_source_ptr)sinfo;
239
+ register JSAMPROW ptr;
240
+ register JDIMENSION col;
241
+
242
+ ptr = source->pub.buffer[0];
243
+ for (col = cinfo->image_width; col > 0; col--) {
244
+ (*source->read_pixel) (source); /* Load next pixel into tga_pixel */
245
+ *ptr++ = (JSAMPLE)UCH(source->tga_pixel[2]); /* change BGR to RGB order */
246
+ *ptr++ = (JSAMPLE)UCH(source->tga_pixel[1]);
247
+ *ptr++ = (JSAMPLE)UCH(source->tga_pixel[0]);
248
+ }
249
+ return 1;
250
+ }
251
+
252
+ /*
253
+ * Targa also defines a 32-bit pixel format with order B,G,R,A.
254
+ * We presently ignore the attribute byte, so the code for reading
255
+ * these pixels is identical to the 24-bit routine above.
256
+ * This works because the actual pixel length is only known to read_pixel.
257
+ */
258
+
259
+ #define get_32bit_row get_24bit_row
260
+
261
+
262
+ /*
263
+ * This method is for re-reading the input data in standard top-down
264
+ * row order. The entire image has already been read into whole_image
265
+ * with proper conversion of pixel format, but it's in a funny row order.
266
+ */
267
+
268
+ METHODDEF(JDIMENSION)
269
+ get_memory_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
270
+ {
271
+ tga_source_ptr source = (tga_source_ptr)sinfo;
272
+ JDIMENSION source_row;
273
+
274
+ /* Compute row of source that maps to current_row of normal order */
275
+ /* For now, assume image is bottom-up and not interlaced. */
276
+ /* NEEDS WORK to support interlaced images! */
277
+ source_row = cinfo->image_height - source->current_row - 1;
278
+
279
+ /* Fetch that row from virtual array */
280
+ source->pub.buffer = (*cinfo->mem->access_virt_sarray)
281
+ ((j_common_ptr)cinfo, source->whole_image,
282
+ source_row, (JDIMENSION)1, FALSE);
283
+
284
+ source->current_row++;
285
+ return 1;
286
+ }
287
+
288
+
289
+ /*
290
+ * This method loads the image into whole_image during the first call on
291
+ * get_pixel_rows. The get_pixel_rows pointer is then adjusted to call
292
+ * get_memory_row on subsequent calls.
293
+ */
294
+
295
+ METHODDEF(JDIMENSION)
296
+ preload_image(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
297
+ {
298
+ tga_source_ptr source = (tga_source_ptr)sinfo;
299
+ JDIMENSION row;
300
+ cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
301
+
302
+ /* Read the data into a virtual array in input-file row order. */
303
+ for (row = 0; row < cinfo->image_height; row++) {
304
+ if (progress != NULL) {
305
+ progress->pub.pass_counter = (long)row;
306
+ progress->pub.pass_limit = (long)cinfo->image_height;
307
+ (*progress->pub.progress_monitor) ((j_common_ptr)cinfo);
308
+ }
309
+ source->pub.buffer = (*cinfo->mem->access_virt_sarray)
310
+ ((j_common_ptr)cinfo, source->whole_image, row, (JDIMENSION)1, TRUE);
311
+ (*source->get_pixel_rows) (cinfo, sinfo);
312
+ }
313
+ if (progress != NULL)
314
+ progress->completed_extra_passes++;
315
+
316
+ /* Set up to read from the virtual array in unscrambled order */
317
+ source->pub.get_pixel_rows = get_memory_row;
318
+ source->current_row = 0;
319
+ /* And read the first row */
320
+ return get_memory_row(cinfo, sinfo);
321
+ }
322
+
323
+
324
+ /*
325
+ * Read the file header; return image size and component count.
326
+ */
327
+
328
+ METHODDEF(void)
329
+ start_input_tga(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
330
+ {
331
+ tga_source_ptr source = (tga_source_ptr)sinfo;
332
+ U_CHAR targaheader[18];
333
+ int idlen, cmaptype, subtype, flags, interlace_type, components;
334
+ unsigned int width, height, maplen;
335
+ boolean is_bottom_up;
336
+
337
+ #define GET_2B(offset) \
338
+ ((unsigned int)UCH(targaheader[offset]) + \
339
+ (((unsigned int)UCH(targaheader[offset + 1])) << 8))
340
+
341
+ if (!ReadOK(source->pub.input_file, targaheader, 18))
342
+ ERREXIT(cinfo, JERR_INPUT_EOF);
343
+
344
+ /* Pretend "15-bit" pixels are 16-bit --- we ignore attribute bit anyway */
345
+ if (targaheader[16] == 15)
346
+ targaheader[16] = 16;
347
+
348
+ idlen = UCH(targaheader[0]);
349
+ cmaptype = UCH(targaheader[1]);
350
+ subtype = UCH(targaheader[2]);
351
+ maplen = GET_2B(5);
352
+ width = GET_2B(12);
353
+ height = GET_2B(14);
354
+ source->pixel_size = UCH(targaheader[16]) >> 3;
355
+ flags = UCH(targaheader[17]); /* Image Descriptor byte */
356
+
357
+ is_bottom_up = ((flags & 0x20) == 0); /* bit 5 set => top-down */
358
+ interlace_type = flags >> 6; /* bits 6/7 are interlace code */
359
+
360
+ if (cmaptype > 1 || /* cmaptype must be 0 or 1 */
361
+ source->pixel_size < 1 || source->pixel_size > 4 ||
362
+ (UCH(targaheader[16]) & 7) != 0 || /* bits/pixel must be multiple of 8 */
363
+ interlace_type != 0 || /* currently don't allow interlaced image */
364
+ width == 0 || height == 0) /* image width/height must be non-zero */
365
+ ERREXIT(cinfo, JERR_TGA_BADPARMS);
366
+ #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
367
+ if (sinfo->max_pixels &&
368
+ (unsigned long long)width * height > sinfo->max_pixels)
369
+ ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
370
+ #endif
371
+
372
+ if (subtype > 8) {
373
+ /* It's an RLE-coded file */
374
+ source->read_pixel = read_rle_pixel;
375
+ source->block_count = source->dup_pixel_count = 0;
376
+ subtype -= 8;
377
+ } else {
378
+ /* Non-RLE file */
379
+ source->read_pixel = read_non_rle_pixel;
380
+ }
381
+
382
+ /* Now should have subtype 1, 2, or 3 */
383
+ components = 3; /* until proven different */
384
+ cinfo->in_color_space = JCS_RGB;
385
+
386
+ switch (subtype) {
387
+ case 1: /* Colormapped image */
388
+ if (source->pixel_size == 1 && cmaptype == 1)
389
+ source->get_pixel_rows = get_8bit_row;
390
+ else
391
+ ERREXIT(cinfo, JERR_TGA_BADPARMS);
392
+ TRACEMS2(cinfo, 1, JTRC_TGA_MAPPED, width, height);
393
+ break;
394
+ case 2: /* RGB image */
395
+ switch (source->pixel_size) {
396
+ case 2:
397
+ source->get_pixel_rows = get_16bit_row;
398
+ break;
399
+ case 3:
400
+ source->get_pixel_rows = get_24bit_row;
401
+ break;
402
+ case 4:
403
+ source->get_pixel_rows = get_32bit_row;
404
+ break;
405
+ default:
406
+ ERREXIT(cinfo, JERR_TGA_BADPARMS);
407
+ break;
408
+ }
409
+ TRACEMS2(cinfo, 1, JTRC_TGA, width, height);
410
+ break;
411
+ case 3: /* Grayscale image */
412
+ components = 1;
413
+ cinfo->in_color_space = JCS_GRAYSCALE;
414
+ if (source->pixel_size == 1)
415
+ source->get_pixel_rows = get_8bit_gray_row;
416
+ else
417
+ ERREXIT(cinfo, JERR_TGA_BADPARMS);
418
+ TRACEMS2(cinfo, 1, JTRC_TGA_GRAY, width, height);
419
+ break;
420
+ default:
421
+ ERREXIT(cinfo, JERR_TGA_BADPARMS);
422
+ break;
423
+ }
424
+
425
+ if (is_bottom_up) {
426
+ /* Create a virtual array to buffer the upside-down image. */
427
+ source->whole_image = (*cinfo->mem->request_virt_sarray)
428
+ ((j_common_ptr)cinfo, JPOOL_IMAGE, FALSE,
429
+ (JDIMENSION)width * components, (JDIMENSION)height, (JDIMENSION)1);
430
+ if (cinfo->progress != NULL) {
431
+ cd_progress_ptr progress = (cd_progress_ptr)cinfo->progress;
432
+ progress->total_extra_passes++; /* count file input as separate pass */
433
+ }
434
+ /* source->pub.buffer will point to the virtual array. */
435
+ source->pub.buffer_height = 1; /* in case anyone looks at it */
436
+ source->pub.get_pixel_rows = preload_image;
437
+ } else {
438
+ /* Don't need a virtual array, but do need a one-row input buffer. */
439
+ source->whole_image = NULL;
440
+ source->pub.buffer = (*cinfo->mem->alloc_sarray)
441
+ ((j_common_ptr)cinfo, JPOOL_IMAGE,
442
+ (JDIMENSION)width * components, (JDIMENSION)1);
443
+ source->pub.buffer_height = 1;
444
+ source->pub.get_pixel_rows = source->get_pixel_rows;
445
+ }
446
+
447
+ while (idlen--) /* Throw away ID field */
448
+ (void)read_byte(source);
449
+
450
+ if (maplen > 0) {
451
+ if (maplen > 256 || GET_2B(3) != 0)
452
+ ERREXIT(cinfo, JERR_TGA_BADCMAP);
453
+ /* Allocate space to store the colormap */
454
+ source->colormap = (*cinfo->mem->alloc_sarray)
455
+ ((j_common_ptr)cinfo, JPOOL_IMAGE, (JDIMENSION)maplen, (JDIMENSION)3);
456
+ source->cmap_length = (int)maplen;
457
+ /* and read it from the file */
458
+ read_colormap(source, (int)maplen, UCH(targaheader[7]));
459
+ } else {
460
+ if (cmaptype) /* but you promised a cmap! */
461
+ ERREXIT(cinfo, JERR_TGA_BADPARMS);
462
+ source->colormap = NULL;
463
+ source->cmap_length = 0;
464
+ }
465
+
466
+ cinfo->input_components = components;
467
+ cinfo->data_precision = 8;
468
+ cinfo->image_width = width;
469
+ cinfo->image_height = height;
470
+ }
471
+
472
+
473
+ /*
474
+ * Finish up at the end of the file.
475
+ */
476
+
477
+ METHODDEF(void)
478
+ finish_input_tga(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
479
+ {
480
+ /* no work */
481
+ }
482
+
483
+
484
+ /*
485
+ * The module selection routine for Targa format input.
486
+ */
487
+
488
+ GLOBAL(cjpeg_source_ptr)
489
+ jinit_read_targa(j_compress_ptr cinfo)
490
+ {
491
+ tga_source_ptr source;
492
+
493
+ /* Create module interface object */
494
+ source = (tga_source_ptr)
495
+ (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
496
+ sizeof(tga_source_struct));
497
+ source->cinfo = cinfo; /* make back link for subroutines */
498
+ /* Fill in method ptrs, except get_pixel_rows which start_input sets */
499
+ source->pub.start_input = start_input_tga;
500
+ source->pub.finish_input = finish_input_tga;
501
+ #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
502
+ source->pub.max_pixels = 0;
503
+ #endif
504
+
505
+ return (cjpeg_source_ptr)source;
506
+ }
507
+
508
+ #endif /* TARGA_SUPPORTED */
@@ -0,0 +1,148 @@
1
+ /*
2
+ * jccolext-neon.c - colorspace conversion (32-bit Arm Neon)
3
+ *
4
+ * Copyright (C) 2020, Arm Limited. All Rights Reserved.
5
+ * Copyright (C) 2020, D. R. Commander. All Rights Reserved.
6
+ *
7
+ * This software is provided 'as-is', without any express or implied
8
+ * warranty. In no event will the authors be held liable for any damages
9
+ * arising from the use of this software.
10
+ *
11
+ * Permission is granted to anyone to use this software for any purpose,
12
+ * including commercial applications, and to alter it and redistribute it
13
+ * freely, subject to the following restrictions:
14
+ *
15
+ * 1. The origin of this software must not be misrepresented; you must not
16
+ * claim that you wrote the original software. If you use this software
17
+ * in a product, an acknowledgment in the product documentation would be
18
+ * appreciated but is not required.
19
+ * 2. Altered source versions must be plainly marked as such, and must not be
20
+ * misrepresented as being the original software.
21
+ * 3. This notice may not be removed or altered from any source distribution.
22
+ */
23
+
24
+ /* This file is included by jccolor-neon.c */
25
+
26
+
27
+ /* RGB -> YCbCr conversion is defined by the following equations:
28
+ * Y = 0.29900 * R + 0.58700 * G + 0.11400 * B
29
+ * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + 128
30
+ * Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + 128
31
+ *
32
+ * Avoid floating point arithmetic by using shifted integer constants:
33
+ * 0.29899597 = 19595 * 2^-16
34
+ * 0.58700561 = 38470 * 2^-16
35
+ * 0.11399841 = 7471 * 2^-16
36
+ * 0.16874695 = 11059 * 2^-16
37
+ * 0.33125305 = 21709 * 2^-16
38
+ * 0.50000000 = 32768 * 2^-16
39
+ * 0.41868592 = 27439 * 2^-16
40
+ * 0.08131409 = 5329 * 2^-16
41
+ * These constants are defined in jccolor-neon.c
42
+ *
43
+ * We add the fixed-point equivalent of 0.5 to Cb and Cr, which effectively
44
+ * rounds up or down the result via integer truncation.
45
+ */
46
+
47
+ void jsimd_rgb_ycc_convert_neon(JDIMENSION image_width, JSAMPARRAY input_buf,
48
+ JSAMPIMAGE output_buf, JDIMENSION output_row,
49
+ int num_rows)
50
+ {
51
+ /* Pointer to RGB(X/A) input data */
52
+ JSAMPROW inptr;
53
+ /* Pointers to Y, Cb, and Cr output data */
54
+ JSAMPROW outptr0, outptr1, outptr2;
55
+ /* Allocate temporary buffer for final (image_width % 8) pixels in row. */
56
+ ALIGN(16) uint8_t tmp_buf[8 * RGB_PIXELSIZE];
57
+
58
+ /* Set up conversion constants. */
59
+ #ifdef HAVE_VLD1_U16_X2
60
+ const uint16x4x2_t consts = vld1_u16_x2(jsimd_rgb_ycc_neon_consts);
61
+ #else
62
+ /* GCC does not currently support the intrinsic vld1_<type>_x2(). */
63
+ const uint16x4_t consts1 = vld1_u16(jsimd_rgb_ycc_neon_consts);
64
+ const uint16x4_t consts2 = vld1_u16(jsimd_rgb_ycc_neon_consts + 4);
65
+ const uint16x4x2_t consts = { { consts1, consts2 } };
66
+ #endif
67
+ const uint32x4_t scaled_128_5 = vdupq_n_u32((128 << 16) + 32767);
68
+
69
+ while (--num_rows >= 0) {
70
+ inptr = *input_buf++;
71
+ outptr0 = output_buf[0][output_row];
72
+ outptr1 = output_buf[1][output_row];
73
+ outptr2 = output_buf[2][output_row];
74
+ output_row++;
75
+
76
+ int cols_remaining = image_width;
77
+ for (; cols_remaining > 0; cols_remaining -= 8) {
78
+
79
+ /* To prevent buffer overread by the vector load instructions, the last
80
+ * (image_width % 8) columns of data are first memcopied to a temporary
81
+ * buffer large enough to accommodate the vector load.
82
+ */
83
+ if (cols_remaining < 8) {
84
+ memcpy(tmp_buf, inptr, cols_remaining * RGB_PIXELSIZE);
85
+ inptr = tmp_buf;
86
+ }
87
+
88
+ #if RGB_PIXELSIZE == 4
89
+ uint8x8x4_t input_pixels = vld4_u8(inptr);
90
+ #else
91
+ uint8x8x3_t input_pixels = vld3_u8(inptr);
92
+ #endif
93
+ uint16x8_t r = vmovl_u8(input_pixels.val[RGB_RED]);
94
+ uint16x8_t g = vmovl_u8(input_pixels.val[RGB_GREEN]);
95
+ uint16x8_t b = vmovl_u8(input_pixels.val[RGB_BLUE]);
96
+
97
+ /* Compute Y = 0.29900 * R + 0.58700 * G + 0.11400 * B */
98
+ uint32x4_t y_low = vmull_lane_u16(vget_low_u16(r), consts.val[0], 0);
99
+ y_low = vmlal_lane_u16(y_low, vget_low_u16(g), consts.val[0], 1);
100
+ y_low = vmlal_lane_u16(y_low, vget_low_u16(b), consts.val[0], 2);
101
+ uint32x4_t y_high = vmull_lane_u16(vget_high_u16(r), consts.val[0], 0);
102
+ y_high = vmlal_lane_u16(y_high, vget_high_u16(g), consts.val[0], 1);
103
+ y_high = vmlal_lane_u16(y_high, vget_high_u16(b), consts.val[0], 2);
104
+
105
+ /* Compute Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + 128 */
106
+ uint32x4_t cb_low = scaled_128_5;
107
+ cb_low = vmlsl_lane_u16(cb_low, vget_low_u16(r), consts.val[0], 3);
108
+ cb_low = vmlsl_lane_u16(cb_low, vget_low_u16(g), consts.val[1], 0);
109
+ cb_low = vmlal_lane_u16(cb_low, vget_low_u16(b), consts.val[1], 1);
110
+ uint32x4_t cb_high = scaled_128_5;
111
+ cb_high = vmlsl_lane_u16(cb_high, vget_high_u16(r), consts.val[0], 3);
112
+ cb_high = vmlsl_lane_u16(cb_high, vget_high_u16(g), consts.val[1], 0);
113
+ cb_high = vmlal_lane_u16(cb_high, vget_high_u16(b), consts.val[1], 1);
114
+
115
+ /* Compute Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + 128 */
116
+ uint32x4_t cr_low = scaled_128_5;
117
+ cr_low = vmlal_lane_u16(cr_low, vget_low_u16(r), consts.val[1], 1);
118
+ cr_low = vmlsl_lane_u16(cr_low, vget_low_u16(g), consts.val[1], 2);
119
+ cr_low = vmlsl_lane_u16(cr_low, vget_low_u16(b), consts.val[1], 3);
120
+ uint32x4_t cr_high = scaled_128_5;
121
+ cr_high = vmlal_lane_u16(cr_high, vget_high_u16(r), consts.val[1], 1);
122
+ cr_high = vmlsl_lane_u16(cr_high, vget_high_u16(g), consts.val[1], 2);
123
+ cr_high = vmlsl_lane_u16(cr_high, vget_high_u16(b), consts.val[1], 3);
124
+
125
+ /* Descale Y values (rounding right shift) and narrow to 16-bit. */
126
+ uint16x8_t y_u16 = vcombine_u16(vrshrn_n_u32(y_low, 16),
127
+ vrshrn_n_u32(y_high, 16));
128
+ /* Descale Cb values (right shift) and narrow to 16-bit. */
129
+ uint16x8_t cb_u16 = vcombine_u16(vshrn_n_u32(cb_low, 16),
130
+ vshrn_n_u32(cb_high, 16));
131
+ /* Descale Cr values (right shift) and narrow to 16-bit. */
132
+ uint16x8_t cr_u16 = vcombine_u16(vshrn_n_u32(cr_low, 16),
133
+ vshrn_n_u32(cr_high, 16));
134
+ /* Narrow Y, Cb, and Cr values to 8-bit and store to memory. Buffer
135
+ * overwrite is permitted up to the next multiple of ALIGN_SIZE bytes.
136
+ */
137
+ vst1_u8(outptr0, vmovn_u16(y_u16));
138
+ vst1_u8(outptr1, vmovn_u16(cb_u16));
139
+ vst1_u8(outptr2, vmovn_u16(cr_u16));
140
+
141
+ /* Increment pointers. */
142
+ inptr += (8 * RGB_PIXELSIZE);
143
+ outptr0 += 8;
144
+ outptr1 += 8;
145
+ outptr2 += 8;
146
+ }
147
+ }
148
+ }