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,486 @@
1
+ /*
2
+ * jidctred-neon.c - reduced-size IDCT (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
+ #define JPEG_INTERNALS
25
+ #include "../../jinclude.h"
26
+ #include "../../jpeglib.h"
27
+ #include "../../jsimd.h"
28
+ #include "../../jdct.h"
29
+ #include "../../jsimddct.h"
30
+ #include "../jsimd.h"
31
+ #include "align.h"
32
+ #include "neon-compat.h"
33
+
34
+ #include <arm_neon.h>
35
+
36
+
37
+ #define CONST_BITS 13
38
+ #define PASS1_BITS 2
39
+
40
+ #define F_0_211 1730
41
+ #define F_0_509 4176
42
+ #define F_0_601 4926
43
+ #define F_0_720 5906
44
+ #define F_0_765 6270
45
+ #define F_0_850 6967
46
+ #define F_0_899 7373
47
+ #define F_1_061 8697
48
+ #define F_1_272 10426
49
+ #define F_1_451 11893
50
+ #define F_1_847 15137
51
+ #define F_2_172 17799
52
+ #define F_2_562 20995
53
+ #define F_3_624 29692
54
+
55
+
56
+ /* jsimd_idct_2x2_neon() is an inverse DCT function that produces reduced-size
57
+ * 2x2 output from an 8x8 DCT block. It uses the same calculations and
58
+ * produces exactly the same output as IJG's original jpeg_idct_2x2() function
59
+ * from jpeg-6b, which can be found in jidctred.c.
60
+ *
61
+ * Scaled integer constants are used to avoid floating-point arithmetic:
62
+ * 0.720959822 = 5906 * 2^-13
63
+ * 0.850430095 = 6967 * 2^-13
64
+ * 1.272758580 = 10426 * 2^-13
65
+ * 3.624509785 = 29692 * 2^-13
66
+ *
67
+ * See jidctred.c for further details of the 2x2 IDCT algorithm. Where
68
+ * possible, the variable names and comments here in jsimd_idct_2x2_neon()
69
+ * match up with those in jpeg_idct_2x2().
70
+ */
71
+
72
+ ALIGN(16) static const int16_t jsimd_idct_2x2_neon_consts[] = {
73
+ -F_0_720, F_0_850, -F_1_272, F_3_624
74
+ };
75
+
76
+ void jsimd_idct_2x2_neon(void *dct_table, JCOEFPTR coef_block,
77
+ JSAMPARRAY output_buf, JDIMENSION output_col)
78
+ {
79
+ ISLOW_MULT_TYPE *quantptr = dct_table;
80
+
81
+ /* Load DCT coefficients. */
82
+ int16x8_t row0 = vld1q_s16(coef_block + 0 * DCTSIZE);
83
+ int16x8_t row1 = vld1q_s16(coef_block + 1 * DCTSIZE);
84
+ int16x8_t row3 = vld1q_s16(coef_block + 3 * DCTSIZE);
85
+ int16x8_t row5 = vld1q_s16(coef_block + 5 * DCTSIZE);
86
+ int16x8_t row7 = vld1q_s16(coef_block + 7 * DCTSIZE);
87
+
88
+ /* Load quantization table values. */
89
+ int16x8_t quant_row0 = vld1q_s16(quantptr + 0 * DCTSIZE);
90
+ int16x8_t quant_row1 = vld1q_s16(quantptr + 1 * DCTSIZE);
91
+ int16x8_t quant_row3 = vld1q_s16(quantptr + 3 * DCTSIZE);
92
+ int16x8_t quant_row5 = vld1q_s16(quantptr + 5 * DCTSIZE);
93
+ int16x8_t quant_row7 = vld1q_s16(quantptr + 7 * DCTSIZE);
94
+
95
+ /* Dequantize DCT coefficients. */
96
+ row0 = vmulq_s16(row0, quant_row0);
97
+ row1 = vmulq_s16(row1, quant_row1);
98
+ row3 = vmulq_s16(row3, quant_row3);
99
+ row5 = vmulq_s16(row5, quant_row5);
100
+ row7 = vmulq_s16(row7, quant_row7);
101
+
102
+ /* Load IDCT conversion constants. */
103
+ const int16x4_t consts = vld1_s16(jsimd_idct_2x2_neon_consts);
104
+
105
+ /* Pass 1: process columns from input, put results in vectors row0 and
106
+ * row1.
107
+ */
108
+
109
+ /* Even part */
110
+ int32x4_t tmp10_l = vshll_n_s16(vget_low_s16(row0), CONST_BITS + 2);
111
+ int32x4_t tmp10_h = vshll_n_s16(vget_high_s16(row0), CONST_BITS + 2);
112
+
113
+ /* Odd part */
114
+ int32x4_t tmp0_l = vmull_lane_s16(vget_low_s16(row1), consts, 3);
115
+ tmp0_l = vmlal_lane_s16(tmp0_l, vget_low_s16(row3), consts, 2);
116
+ tmp0_l = vmlal_lane_s16(tmp0_l, vget_low_s16(row5), consts, 1);
117
+ tmp0_l = vmlal_lane_s16(tmp0_l, vget_low_s16(row7), consts, 0);
118
+ int32x4_t tmp0_h = vmull_lane_s16(vget_high_s16(row1), consts, 3);
119
+ tmp0_h = vmlal_lane_s16(tmp0_h, vget_high_s16(row3), consts, 2);
120
+ tmp0_h = vmlal_lane_s16(tmp0_h, vget_high_s16(row5), consts, 1);
121
+ tmp0_h = vmlal_lane_s16(tmp0_h, vget_high_s16(row7), consts, 0);
122
+
123
+ /* Final output stage: descale and narrow to 16-bit. */
124
+ row0 = vcombine_s16(vrshrn_n_s32(vaddq_s32(tmp10_l, tmp0_l), CONST_BITS),
125
+ vrshrn_n_s32(vaddq_s32(tmp10_h, tmp0_h), CONST_BITS));
126
+ row1 = vcombine_s16(vrshrn_n_s32(vsubq_s32(tmp10_l, tmp0_l), CONST_BITS),
127
+ vrshrn_n_s32(vsubq_s32(tmp10_h, tmp0_h), CONST_BITS));
128
+
129
+ /* Transpose two rows, ready for second pass. */
130
+ int16x8x2_t cols_0246_1357 = vtrnq_s16(row0, row1);
131
+ int16x8_t cols_0246 = cols_0246_1357.val[0];
132
+ int16x8_t cols_1357 = cols_0246_1357.val[1];
133
+ /* Duplicate columns such that each is accessible in its own vector. */
134
+ int32x4x2_t cols_1155_3377 = vtrnq_s32(vreinterpretq_s32_s16(cols_1357),
135
+ vreinterpretq_s32_s16(cols_1357));
136
+ int16x8_t cols_1155 = vreinterpretq_s16_s32(cols_1155_3377.val[0]);
137
+ int16x8_t cols_3377 = vreinterpretq_s16_s32(cols_1155_3377.val[1]);
138
+
139
+ /* Pass 2: process two rows, store to output array. */
140
+
141
+ /* Even part: we're only interested in col0; the top half of tmp10 is "don't
142
+ * care."
143
+ */
144
+ int32x4_t tmp10 = vshll_n_s16(vget_low_s16(cols_0246), CONST_BITS + 2);
145
+
146
+ /* Odd part: we're only interested in the bottom half of tmp0. */
147
+ int32x4_t tmp0 = vmull_lane_s16(vget_low_s16(cols_1155), consts, 3);
148
+ tmp0 = vmlal_lane_s16(tmp0, vget_low_s16(cols_3377), consts, 2);
149
+ tmp0 = vmlal_lane_s16(tmp0, vget_high_s16(cols_1155), consts, 1);
150
+ tmp0 = vmlal_lane_s16(tmp0, vget_high_s16(cols_3377), consts, 0);
151
+
152
+ /* Final output stage: descale and clamp to range [0-255]. */
153
+ int16x8_t output_s16 = vcombine_s16(vaddhn_s32(tmp10, tmp0),
154
+ vsubhn_s32(tmp10, tmp0));
155
+ output_s16 = vrsraq_n_s16(vdupq_n_s16(CENTERJSAMPLE), output_s16,
156
+ CONST_BITS + PASS1_BITS + 3 + 2 - 16);
157
+ /* Narrow to 8-bit and convert to unsigned. */
158
+ uint8x8_t output_u8 = vqmovun_s16(output_s16);
159
+
160
+ /* Store 2x2 block to memory. */
161
+ vst1_lane_u8(output_buf[0] + output_col, output_u8, 0);
162
+ vst1_lane_u8(output_buf[1] + output_col, output_u8, 1);
163
+ vst1_lane_u8(output_buf[0] + output_col + 1, output_u8, 4);
164
+ vst1_lane_u8(output_buf[1] + output_col + 1, output_u8, 5);
165
+ }
166
+
167
+
168
+ /* jsimd_idct_4x4_neon() is an inverse DCT function that produces reduced-size
169
+ * 4x4 output from an 8x8 DCT block. It uses the same calculations and
170
+ * produces exactly the same output as IJG's original jpeg_idct_4x4() function
171
+ * from jpeg-6b, which can be found in jidctred.c.
172
+ *
173
+ * Scaled integer constants are used to avoid floating-point arithmetic:
174
+ * 0.211164243 = 1730 * 2^-13
175
+ * 0.509795579 = 4176 * 2^-13
176
+ * 0.601344887 = 4926 * 2^-13
177
+ * 0.765366865 = 6270 * 2^-13
178
+ * 0.899976223 = 7373 * 2^-13
179
+ * 1.061594337 = 8697 * 2^-13
180
+ * 1.451774981 = 11893 * 2^-13
181
+ * 1.847759065 = 15137 * 2^-13
182
+ * 2.172734803 = 17799 * 2^-13
183
+ * 2.562915447 = 20995 * 2^-13
184
+ *
185
+ * See jidctred.c for further details of the 4x4 IDCT algorithm. Where
186
+ * possible, the variable names and comments here in jsimd_idct_4x4_neon()
187
+ * match up with those in jpeg_idct_4x4().
188
+ */
189
+
190
+ ALIGN(16) static const int16_t jsimd_idct_4x4_neon_consts[] = {
191
+ F_1_847, -F_0_765, -F_0_211, F_1_451,
192
+ -F_2_172, F_1_061, -F_0_509, -F_0_601,
193
+ F_0_899, F_2_562, 0, 0
194
+ };
195
+
196
+ void jsimd_idct_4x4_neon(void *dct_table, JCOEFPTR coef_block,
197
+ JSAMPARRAY output_buf, JDIMENSION output_col)
198
+ {
199
+ ISLOW_MULT_TYPE *quantptr = dct_table;
200
+
201
+ /* Load DCT coefficients. */
202
+ int16x8_t row0 = vld1q_s16(coef_block + 0 * DCTSIZE);
203
+ int16x8_t row1 = vld1q_s16(coef_block + 1 * DCTSIZE);
204
+ int16x8_t row2 = vld1q_s16(coef_block + 2 * DCTSIZE);
205
+ int16x8_t row3 = vld1q_s16(coef_block + 3 * DCTSIZE);
206
+ int16x8_t row5 = vld1q_s16(coef_block + 5 * DCTSIZE);
207
+ int16x8_t row6 = vld1q_s16(coef_block + 6 * DCTSIZE);
208
+ int16x8_t row7 = vld1q_s16(coef_block + 7 * DCTSIZE);
209
+
210
+ /* Load quantization table values for DC coefficients. */
211
+ int16x8_t quant_row0 = vld1q_s16(quantptr + 0 * DCTSIZE);
212
+ /* Dequantize DC coefficients. */
213
+ row0 = vmulq_s16(row0, quant_row0);
214
+
215
+ /* Construct bitmap to test if all AC coefficients are 0. */
216
+ int16x8_t bitmap = vorrq_s16(row1, row2);
217
+ bitmap = vorrq_s16(bitmap, row3);
218
+ bitmap = vorrq_s16(bitmap, row5);
219
+ bitmap = vorrq_s16(bitmap, row6);
220
+ bitmap = vorrq_s16(bitmap, row7);
221
+
222
+ int64_t left_ac_bitmap = vgetq_lane_s64(vreinterpretq_s64_s16(bitmap), 0);
223
+ int64_t right_ac_bitmap = vgetq_lane_s64(vreinterpretq_s64_s16(bitmap), 1);
224
+
225
+ /* Load constants for IDCT computation. */
226
+ #ifdef HAVE_VLD1_S16_X3
227
+ const int16x4x3_t consts = vld1_s16_x3(jsimd_idct_4x4_neon_consts);
228
+ #else
229
+ /* GCC does not currently support the intrinsic vld1_<type>_x3(). */
230
+ const int16x4_t consts1 = vld1_s16(jsimd_idct_4x4_neon_consts);
231
+ const int16x4_t consts2 = vld1_s16(jsimd_idct_4x4_neon_consts + 4);
232
+ const int16x4_t consts3 = vld1_s16(jsimd_idct_4x4_neon_consts + 8);
233
+ const int16x4x3_t consts = { { consts1, consts2, consts3 } };
234
+ #endif
235
+
236
+ if (left_ac_bitmap == 0 && right_ac_bitmap == 0) {
237
+ /* All AC coefficients are zero.
238
+ * Compute DC values and duplicate into row vectors 0, 1, 2, and 3.
239
+ */
240
+ int16x8_t dcval = vshlq_n_s16(row0, PASS1_BITS);
241
+ row0 = dcval;
242
+ row1 = dcval;
243
+ row2 = dcval;
244
+ row3 = dcval;
245
+ } else if (left_ac_bitmap == 0) {
246
+ /* AC coefficients are zero for columns 0, 1, 2, and 3.
247
+ * Compute DC values for these columns.
248
+ */
249
+ int16x4_t dcval = vshl_n_s16(vget_low_s16(row0), PASS1_BITS);
250
+
251
+ /* Commence regular IDCT computation for columns 4, 5, 6, and 7. */
252
+
253
+ /* Load quantization table. */
254
+ int16x4_t quant_row1 = vld1_s16(quantptr + 1 * DCTSIZE + 4);
255
+ int16x4_t quant_row2 = vld1_s16(quantptr + 2 * DCTSIZE + 4);
256
+ int16x4_t quant_row3 = vld1_s16(quantptr + 3 * DCTSIZE + 4);
257
+ int16x4_t quant_row5 = vld1_s16(quantptr + 5 * DCTSIZE + 4);
258
+ int16x4_t quant_row6 = vld1_s16(quantptr + 6 * DCTSIZE + 4);
259
+ int16x4_t quant_row7 = vld1_s16(quantptr + 7 * DCTSIZE + 4);
260
+
261
+ /* Even part */
262
+ int32x4_t tmp0 = vshll_n_s16(vget_high_s16(row0), CONST_BITS + 1);
263
+
264
+ int16x4_t z2 = vmul_s16(vget_high_s16(row2), quant_row2);
265
+ int16x4_t z3 = vmul_s16(vget_high_s16(row6), quant_row6);
266
+
267
+ int32x4_t tmp2 = vmull_lane_s16(z2, consts.val[0], 0);
268
+ tmp2 = vmlal_lane_s16(tmp2, z3, consts.val[0], 1);
269
+
270
+ int32x4_t tmp10 = vaddq_s32(tmp0, tmp2);
271
+ int32x4_t tmp12 = vsubq_s32(tmp0, tmp2);
272
+
273
+ /* Odd part */
274
+ int16x4_t z1 = vmul_s16(vget_high_s16(row7), quant_row7);
275
+ z2 = vmul_s16(vget_high_s16(row5), quant_row5);
276
+ z3 = vmul_s16(vget_high_s16(row3), quant_row3);
277
+ int16x4_t z4 = vmul_s16(vget_high_s16(row1), quant_row1);
278
+
279
+ tmp0 = vmull_lane_s16(z1, consts.val[0], 2);
280
+ tmp0 = vmlal_lane_s16(tmp0, z2, consts.val[0], 3);
281
+ tmp0 = vmlal_lane_s16(tmp0, z3, consts.val[1], 0);
282
+ tmp0 = vmlal_lane_s16(tmp0, z4, consts.val[1], 1);
283
+
284
+ tmp2 = vmull_lane_s16(z1, consts.val[1], 2);
285
+ tmp2 = vmlal_lane_s16(tmp2, z2, consts.val[1], 3);
286
+ tmp2 = vmlal_lane_s16(tmp2, z3, consts.val[2], 0);
287
+ tmp2 = vmlal_lane_s16(tmp2, z4, consts.val[2], 1);
288
+
289
+ /* Final output stage: descale and narrow to 16-bit. */
290
+ row0 = vcombine_s16(dcval, vrshrn_n_s32(vaddq_s32(tmp10, tmp2),
291
+ CONST_BITS - PASS1_BITS + 1));
292
+ row3 = vcombine_s16(dcval, vrshrn_n_s32(vsubq_s32(tmp10, tmp2),
293
+ CONST_BITS - PASS1_BITS + 1));
294
+ row1 = vcombine_s16(dcval, vrshrn_n_s32(vaddq_s32(tmp12, tmp0),
295
+ CONST_BITS - PASS1_BITS + 1));
296
+ row2 = vcombine_s16(dcval, vrshrn_n_s32(vsubq_s32(tmp12, tmp0),
297
+ CONST_BITS - PASS1_BITS + 1));
298
+ } else if (right_ac_bitmap == 0) {
299
+ /* AC coefficients are zero for columns 4, 5, 6, and 7.
300
+ * Compute DC values for these columns.
301
+ */
302
+ int16x4_t dcval = vshl_n_s16(vget_high_s16(row0), PASS1_BITS);
303
+
304
+ /* Commence regular IDCT computation for columns 0, 1, 2, and 3. */
305
+
306
+ /* Load quantization table. */
307
+ int16x4_t quant_row1 = vld1_s16(quantptr + 1 * DCTSIZE);
308
+ int16x4_t quant_row2 = vld1_s16(quantptr + 2 * DCTSIZE);
309
+ int16x4_t quant_row3 = vld1_s16(quantptr + 3 * DCTSIZE);
310
+ int16x4_t quant_row5 = vld1_s16(quantptr + 5 * DCTSIZE);
311
+ int16x4_t quant_row6 = vld1_s16(quantptr + 6 * DCTSIZE);
312
+ int16x4_t quant_row7 = vld1_s16(quantptr + 7 * DCTSIZE);
313
+
314
+ /* Even part */
315
+ int32x4_t tmp0 = vshll_n_s16(vget_low_s16(row0), CONST_BITS + 1);
316
+
317
+ int16x4_t z2 = vmul_s16(vget_low_s16(row2), quant_row2);
318
+ int16x4_t z3 = vmul_s16(vget_low_s16(row6), quant_row6);
319
+
320
+ int32x4_t tmp2 = vmull_lane_s16(z2, consts.val[0], 0);
321
+ tmp2 = vmlal_lane_s16(tmp2, z3, consts.val[0], 1);
322
+
323
+ int32x4_t tmp10 = vaddq_s32(tmp0, tmp2);
324
+ int32x4_t tmp12 = vsubq_s32(tmp0, tmp2);
325
+
326
+ /* Odd part */
327
+ int16x4_t z1 = vmul_s16(vget_low_s16(row7), quant_row7);
328
+ z2 = vmul_s16(vget_low_s16(row5), quant_row5);
329
+ z3 = vmul_s16(vget_low_s16(row3), quant_row3);
330
+ int16x4_t z4 = vmul_s16(vget_low_s16(row1), quant_row1);
331
+
332
+ tmp0 = vmull_lane_s16(z1, consts.val[0], 2);
333
+ tmp0 = vmlal_lane_s16(tmp0, z2, consts.val[0], 3);
334
+ tmp0 = vmlal_lane_s16(tmp0, z3, consts.val[1], 0);
335
+ tmp0 = vmlal_lane_s16(tmp0, z4, consts.val[1], 1);
336
+
337
+ tmp2 = vmull_lane_s16(z1, consts.val[1], 2);
338
+ tmp2 = vmlal_lane_s16(tmp2, z2, consts.val[1], 3);
339
+ tmp2 = vmlal_lane_s16(tmp2, z3, consts.val[2], 0);
340
+ tmp2 = vmlal_lane_s16(tmp2, z4, consts.val[2], 1);
341
+
342
+ /* Final output stage: descale and narrow to 16-bit. */
343
+ row0 = vcombine_s16(vrshrn_n_s32(vaddq_s32(tmp10, tmp2),
344
+ CONST_BITS - PASS1_BITS + 1), dcval);
345
+ row3 = vcombine_s16(vrshrn_n_s32(vsubq_s32(tmp10, tmp2),
346
+ CONST_BITS - PASS1_BITS + 1), dcval);
347
+ row1 = vcombine_s16(vrshrn_n_s32(vaddq_s32(tmp12, tmp0),
348
+ CONST_BITS - PASS1_BITS + 1), dcval);
349
+ row2 = vcombine_s16(vrshrn_n_s32(vsubq_s32(tmp12, tmp0),
350
+ CONST_BITS - PASS1_BITS + 1), dcval);
351
+ } else {
352
+ /* All AC coefficients are non-zero; full IDCT calculation required. */
353
+ int16x8_t quant_row1 = vld1q_s16(quantptr + 1 * DCTSIZE);
354
+ int16x8_t quant_row2 = vld1q_s16(quantptr + 2 * DCTSIZE);
355
+ int16x8_t quant_row3 = vld1q_s16(quantptr + 3 * DCTSIZE);
356
+ int16x8_t quant_row5 = vld1q_s16(quantptr + 5 * DCTSIZE);
357
+ int16x8_t quant_row6 = vld1q_s16(quantptr + 6 * DCTSIZE);
358
+ int16x8_t quant_row7 = vld1q_s16(quantptr + 7 * DCTSIZE);
359
+
360
+ /* Even part */
361
+ int32x4_t tmp0_l = vshll_n_s16(vget_low_s16(row0), CONST_BITS + 1);
362
+ int32x4_t tmp0_h = vshll_n_s16(vget_high_s16(row0), CONST_BITS + 1);
363
+
364
+ int16x8_t z2 = vmulq_s16(row2, quant_row2);
365
+ int16x8_t z3 = vmulq_s16(row6, quant_row6);
366
+
367
+ int32x4_t tmp2_l = vmull_lane_s16(vget_low_s16(z2), consts.val[0], 0);
368
+ int32x4_t tmp2_h = vmull_lane_s16(vget_high_s16(z2), consts.val[0], 0);
369
+ tmp2_l = vmlal_lane_s16(tmp2_l, vget_low_s16(z3), consts.val[0], 1);
370
+ tmp2_h = vmlal_lane_s16(tmp2_h, vget_high_s16(z3), consts.val[0], 1);
371
+
372
+ int32x4_t tmp10_l = vaddq_s32(tmp0_l, tmp2_l);
373
+ int32x4_t tmp10_h = vaddq_s32(tmp0_h, tmp2_h);
374
+ int32x4_t tmp12_l = vsubq_s32(tmp0_l, tmp2_l);
375
+ int32x4_t tmp12_h = vsubq_s32(tmp0_h, tmp2_h);
376
+
377
+ /* Odd part */
378
+ int16x8_t z1 = vmulq_s16(row7, quant_row7);
379
+ z2 = vmulq_s16(row5, quant_row5);
380
+ z3 = vmulq_s16(row3, quant_row3);
381
+ int16x8_t z4 = vmulq_s16(row1, quant_row1);
382
+
383
+ tmp0_l = vmull_lane_s16(vget_low_s16(z1), consts.val[0], 2);
384
+ tmp0_l = vmlal_lane_s16(tmp0_l, vget_low_s16(z2), consts.val[0], 3);
385
+ tmp0_l = vmlal_lane_s16(tmp0_l, vget_low_s16(z3), consts.val[1], 0);
386
+ tmp0_l = vmlal_lane_s16(tmp0_l, vget_low_s16(z4), consts.val[1], 1);
387
+ tmp0_h = vmull_lane_s16(vget_high_s16(z1), consts.val[0], 2);
388
+ tmp0_h = vmlal_lane_s16(tmp0_h, vget_high_s16(z2), consts.val[0], 3);
389
+ tmp0_h = vmlal_lane_s16(tmp0_h, vget_high_s16(z3), consts.val[1], 0);
390
+ tmp0_h = vmlal_lane_s16(tmp0_h, vget_high_s16(z4), consts.val[1], 1);
391
+
392
+ tmp2_l = vmull_lane_s16(vget_low_s16(z1), consts.val[1], 2);
393
+ tmp2_l = vmlal_lane_s16(tmp2_l, vget_low_s16(z2), consts.val[1], 3);
394
+ tmp2_l = vmlal_lane_s16(tmp2_l, vget_low_s16(z3), consts.val[2], 0);
395
+ tmp2_l = vmlal_lane_s16(tmp2_l, vget_low_s16(z4), consts.val[2], 1);
396
+ tmp2_h = vmull_lane_s16(vget_high_s16(z1), consts.val[1], 2);
397
+ tmp2_h = vmlal_lane_s16(tmp2_h, vget_high_s16(z2), consts.val[1], 3);
398
+ tmp2_h = vmlal_lane_s16(tmp2_h, vget_high_s16(z3), consts.val[2], 0);
399
+ tmp2_h = vmlal_lane_s16(tmp2_h, vget_high_s16(z4), consts.val[2], 1);
400
+
401
+ /* Final output stage: descale and narrow to 16-bit. */
402
+ row0 = vcombine_s16(vrshrn_n_s32(vaddq_s32(tmp10_l, tmp2_l),
403
+ CONST_BITS - PASS1_BITS + 1),
404
+ vrshrn_n_s32(vaddq_s32(tmp10_h, tmp2_h),
405
+ CONST_BITS - PASS1_BITS + 1));
406
+ row3 = vcombine_s16(vrshrn_n_s32(vsubq_s32(tmp10_l, tmp2_l),
407
+ CONST_BITS - PASS1_BITS + 1),
408
+ vrshrn_n_s32(vsubq_s32(tmp10_h, tmp2_h),
409
+ CONST_BITS - PASS1_BITS + 1));
410
+ row1 = vcombine_s16(vrshrn_n_s32(vaddq_s32(tmp12_l, tmp0_l),
411
+ CONST_BITS - PASS1_BITS + 1),
412
+ vrshrn_n_s32(vaddq_s32(tmp12_h, tmp0_h),
413
+ CONST_BITS - PASS1_BITS + 1));
414
+ row2 = vcombine_s16(vrshrn_n_s32(vsubq_s32(tmp12_l, tmp0_l),
415
+ CONST_BITS - PASS1_BITS + 1),
416
+ vrshrn_n_s32(vsubq_s32(tmp12_h, tmp0_h),
417
+ CONST_BITS - PASS1_BITS + 1));
418
+ }
419
+
420
+ /* Transpose 8x4 block to perform IDCT on rows in second pass. */
421
+ int16x8x2_t row_01 = vtrnq_s16(row0, row1);
422
+ int16x8x2_t row_23 = vtrnq_s16(row2, row3);
423
+
424
+ int32x4x2_t cols_0426 = vtrnq_s32(vreinterpretq_s32_s16(row_01.val[0]),
425
+ vreinterpretq_s32_s16(row_23.val[0]));
426
+ int32x4x2_t cols_1537 = vtrnq_s32(vreinterpretq_s32_s16(row_01.val[1]),
427
+ vreinterpretq_s32_s16(row_23.val[1]));
428
+
429
+ int16x4_t col0 = vreinterpret_s16_s32(vget_low_s32(cols_0426.val[0]));
430
+ int16x4_t col1 = vreinterpret_s16_s32(vget_low_s32(cols_1537.val[0]));
431
+ int16x4_t col2 = vreinterpret_s16_s32(vget_low_s32(cols_0426.val[1]));
432
+ int16x4_t col3 = vreinterpret_s16_s32(vget_low_s32(cols_1537.val[1]));
433
+ int16x4_t col5 = vreinterpret_s16_s32(vget_high_s32(cols_1537.val[0]));
434
+ int16x4_t col6 = vreinterpret_s16_s32(vget_high_s32(cols_0426.val[1]));
435
+ int16x4_t col7 = vreinterpret_s16_s32(vget_high_s32(cols_1537.val[1]));
436
+
437
+ /* Commence second pass of IDCT. */
438
+
439
+ /* Even part */
440
+ int32x4_t tmp0 = vshll_n_s16(col0, CONST_BITS + 1);
441
+ int32x4_t tmp2 = vmull_lane_s16(col2, consts.val[0], 0);
442
+ tmp2 = vmlal_lane_s16(tmp2, col6, consts.val[0], 1);
443
+
444
+ int32x4_t tmp10 = vaddq_s32(tmp0, tmp2);
445
+ int32x4_t tmp12 = vsubq_s32(tmp0, tmp2);
446
+
447
+ /* Odd part */
448
+ tmp0 = vmull_lane_s16(col7, consts.val[0], 2);
449
+ tmp0 = vmlal_lane_s16(tmp0, col5, consts.val[0], 3);
450
+ tmp0 = vmlal_lane_s16(tmp0, col3, consts.val[1], 0);
451
+ tmp0 = vmlal_lane_s16(tmp0, col1, consts.val[1], 1);
452
+
453
+ tmp2 = vmull_lane_s16(col7, consts.val[1], 2);
454
+ tmp2 = vmlal_lane_s16(tmp2, col5, consts.val[1], 3);
455
+ tmp2 = vmlal_lane_s16(tmp2, col3, consts.val[2], 0);
456
+ tmp2 = vmlal_lane_s16(tmp2, col1, consts.val[2], 1);
457
+
458
+ /* Final output stage: descale and clamp to range [0-255]. */
459
+ int16x8_t output_cols_02 = vcombine_s16(vaddhn_s32(tmp10, tmp2),
460
+ vsubhn_s32(tmp12, tmp0));
461
+ int16x8_t output_cols_13 = vcombine_s16(vaddhn_s32(tmp12, tmp0),
462
+ vsubhn_s32(tmp10, tmp2));
463
+ output_cols_02 = vrsraq_n_s16(vdupq_n_s16(CENTERJSAMPLE), output_cols_02,
464
+ CONST_BITS + PASS1_BITS + 3 + 1 - 16);
465
+ output_cols_13 = vrsraq_n_s16(vdupq_n_s16(CENTERJSAMPLE), output_cols_13,
466
+ CONST_BITS + PASS1_BITS + 3 + 1 - 16);
467
+ /* Narrow to 8-bit and convert to unsigned while zipping 8-bit elements.
468
+ * An interleaving store completes the transpose.
469
+ */
470
+ uint8x8x2_t output_0123 = vzip_u8(vqmovun_s16(output_cols_02),
471
+ vqmovun_s16(output_cols_13));
472
+ uint16x4x2_t output_01_23 = { {
473
+ vreinterpret_u16_u8(output_0123.val[0]),
474
+ vreinterpret_u16_u8(output_0123.val[1])
475
+ } };
476
+
477
+ /* Store 4x4 block to memory. */
478
+ JSAMPROW outptr0 = output_buf[0] + output_col;
479
+ JSAMPROW outptr1 = output_buf[1] + output_col;
480
+ JSAMPROW outptr2 = output_buf[2] + output_col;
481
+ JSAMPROW outptr3 = output_buf[3] + output_col;
482
+ vst2_lane_u16((uint16_t *)outptr0, output_01_23, 0);
483
+ vst2_lane_u16((uint16_t *)outptr1, output_01_23, 1);
484
+ vst2_lane_u16((uint16_t *)outptr2, output_01_23, 2);
485
+ vst2_lane_u16((uint16_t *)outptr3, output_01_23, 3);
486
+ }
@@ -0,0 +1,193 @@
1
+ /*
2
+ * jquanti-neon.c - sample data conversion and quantization (Arm Neon)
3
+ *
4
+ * Copyright (C) 2020-2021, Arm Limited. All Rights Reserved.
5
+ *
6
+ * This software is provided 'as-is', without any express or implied
7
+ * warranty. In no event will the authors be held liable for any damages
8
+ * arising from the use of this software.
9
+ *
10
+ * Permission is granted to anyone to use this software for any purpose,
11
+ * including commercial applications, and to alter it and redistribute it
12
+ * freely, subject to the following restrictions:
13
+ *
14
+ * 1. The origin of this software must not be misrepresented; you must not
15
+ * claim that you wrote the original software. If you use this software
16
+ * in a product, an acknowledgment in the product documentation would be
17
+ * appreciated but is not required.
18
+ * 2. Altered source versions must be plainly marked as such, and must not be
19
+ * misrepresented as being the original software.
20
+ * 3. This notice may not be removed or altered from any source distribution.
21
+ */
22
+
23
+ #define JPEG_INTERNALS
24
+ #include "../../jinclude.h"
25
+ #include "../../jpeglib.h"
26
+ #include "../../jsimd.h"
27
+ #include "../../jdct.h"
28
+ #include "../../jsimddct.h"
29
+ #include "../jsimd.h"
30
+
31
+ #include <arm_neon.h>
32
+
33
+
34
+ /* After downsampling, the resulting sample values are in the range [0, 255],
35
+ * but the Discrete Cosine Transform (DCT) operates on values centered around
36
+ * 0.
37
+ *
38
+ * To prepare sample values for the DCT, load samples into a DCT workspace,
39
+ * subtracting CENTERJSAMPLE (128). The samples, now in the range [-128, 127],
40
+ * are also widened from 8- to 16-bit.
41
+ *
42
+ * The equivalent scalar C function convsamp() can be found in jcdctmgr.c.
43
+ */
44
+
45
+ void jsimd_convsamp_neon(JSAMPARRAY sample_data, JDIMENSION start_col,
46
+ DCTELEM *workspace)
47
+ {
48
+ uint8x8_t samp_row0 = vld1_u8(sample_data[0] + start_col);
49
+ uint8x8_t samp_row1 = vld1_u8(sample_data[1] + start_col);
50
+ uint8x8_t samp_row2 = vld1_u8(sample_data[2] + start_col);
51
+ uint8x8_t samp_row3 = vld1_u8(sample_data[3] + start_col);
52
+ uint8x8_t samp_row4 = vld1_u8(sample_data[4] + start_col);
53
+ uint8x8_t samp_row5 = vld1_u8(sample_data[5] + start_col);
54
+ uint8x8_t samp_row6 = vld1_u8(sample_data[6] + start_col);
55
+ uint8x8_t samp_row7 = vld1_u8(sample_data[7] + start_col);
56
+
57
+ int16x8_t row0 =
58
+ vreinterpretq_s16_u16(vsubl_u8(samp_row0, vdup_n_u8(CENTERJSAMPLE)));
59
+ int16x8_t row1 =
60
+ vreinterpretq_s16_u16(vsubl_u8(samp_row1, vdup_n_u8(CENTERJSAMPLE)));
61
+ int16x8_t row2 =
62
+ vreinterpretq_s16_u16(vsubl_u8(samp_row2, vdup_n_u8(CENTERJSAMPLE)));
63
+ int16x8_t row3 =
64
+ vreinterpretq_s16_u16(vsubl_u8(samp_row3, vdup_n_u8(CENTERJSAMPLE)));
65
+ int16x8_t row4 =
66
+ vreinterpretq_s16_u16(vsubl_u8(samp_row4, vdup_n_u8(CENTERJSAMPLE)));
67
+ int16x8_t row5 =
68
+ vreinterpretq_s16_u16(vsubl_u8(samp_row5, vdup_n_u8(CENTERJSAMPLE)));
69
+ int16x8_t row6 =
70
+ vreinterpretq_s16_u16(vsubl_u8(samp_row6, vdup_n_u8(CENTERJSAMPLE)));
71
+ int16x8_t row7 =
72
+ vreinterpretq_s16_u16(vsubl_u8(samp_row7, vdup_n_u8(CENTERJSAMPLE)));
73
+
74
+ vst1q_s16(workspace + 0 * DCTSIZE, row0);
75
+ vst1q_s16(workspace + 1 * DCTSIZE, row1);
76
+ vst1q_s16(workspace + 2 * DCTSIZE, row2);
77
+ vst1q_s16(workspace + 3 * DCTSIZE, row3);
78
+ vst1q_s16(workspace + 4 * DCTSIZE, row4);
79
+ vst1q_s16(workspace + 5 * DCTSIZE, row5);
80
+ vst1q_s16(workspace + 6 * DCTSIZE, row6);
81
+ vst1q_s16(workspace + 7 * DCTSIZE, row7);
82
+ }
83
+
84
+
85
+ /* After the DCT, the resulting array of coefficient values needs to be divided
86
+ * by an array of quantization values.
87
+ *
88
+ * To avoid a slow division operation, the DCT coefficients are multiplied by
89
+ * the (scaled) reciprocals of the quantization values and then right-shifted.
90
+ *
91
+ * The equivalent scalar C function quantize() can be found in jcdctmgr.c.
92
+ */
93
+
94
+ void jsimd_quantize_neon(JCOEFPTR coef_block, DCTELEM *divisors,
95
+ DCTELEM *workspace)
96
+ {
97
+ JCOEFPTR out_ptr = coef_block;
98
+ UDCTELEM *recip_ptr = (UDCTELEM *)divisors;
99
+ UDCTELEM *corr_ptr = (UDCTELEM *)divisors + DCTSIZE2;
100
+ DCTELEM *shift_ptr = divisors + 3 * DCTSIZE2;
101
+ int i;
102
+
103
+ #if defined(__clang__) && (defined(__aarch64__) || defined(_M_ARM64))
104
+ #pragma unroll
105
+ #endif
106
+ for (i = 0; i < DCTSIZE; i += DCTSIZE / 2) {
107
+ /* Load DCT coefficients. */
108
+ int16x8_t row0 = vld1q_s16(workspace + (i + 0) * DCTSIZE);
109
+ int16x8_t row1 = vld1q_s16(workspace + (i + 1) * DCTSIZE);
110
+ int16x8_t row2 = vld1q_s16(workspace + (i + 2) * DCTSIZE);
111
+ int16x8_t row3 = vld1q_s16(workspace + (i + 3) * DCTSIZE);
112
+ /* Load reciprocals of quantization values. */
113
+ uint16x8_t recip0 = vld1q_u16(recip_ptr + (i + 0) * DCTSIZE);
114
+ uint16x8_t recip1 = vld1q_u16(recip_ptr + (i + 1) * DCTSIZE);
115
+ uint16x8_t recip2 = vld1q_u16(recip_ptr + (i + 2) * DCTSIZE);
116
+ uint16x8_t recip3 = vld1q_u16(recip_ptr + (i + 3) * DCTSIZE);
117
+ uint16x8_t corr0 = vld1q_u16(corr_ptr + (i + 0) * DCTSIZE);
118
+ uint16x8_t corr1 = vld1q_u16(corr_ptr + (i + 1) * DCTSIZE);
119
+ uint16x8_t corr2 = vld1q_u16(corr_ptr + (i + 2) * DCTSIZE);
120
+ uint16x8_t corr3 = vld1q_u16(corr_ptr + (i + 3) * DCTSIZE);
121
+ int16x8_t shift0 = vld1q_s16(shift_ptr + (i + 0) * DCTSIZE);
122
+ int16x8_t shift1 = vld1q_s16(shift_ptr + (i + 1) * DCTSIZE);
123
+ int16x8_t shift2 = vld1q_s16(shift_ptr + (i + 2) * DCTSIZE);
124
+ int16x8_t shift3 = vld1q_s16(shift_ptr + (i + 3) * DCTSIZE);
125
+
126
+ /* Extract sign from coefficients. */
127
+ int16x8_t sign_row0 = vshrq_n_s16(row0, 15);
128
+ int16x8_t sign_row1 = vshrq_n_s16(row1, 15);
129
+ int16x8_t sign_row2 = vshrq_n_s16(row2, 15);
130
+ int16x8_t sign_row3 = vshrq_n_s16(row3, 15);
131
+ /* Get absolute value of DCT coefficients. */
132
+ uint16x8_t abs_row0 = vreinterpretq_u16_s16(vabsq_s16(row0));
133
+ uint16x8_t abs_row1 = vreinterpretq_u16_s16(vabsq_s16(row1));
134
+ uint16x8_t abs_row2 = vreinterpretq_u16_s16(vabsq_s16(row2));
135
+ uint16x8_t abs_row3 = vreinterpretq_u16_s16(vabsq_s16(row3));
136
+ /* Add correction. */
137
+ abs_row0 = vaddq_u16(abs_row0, corr0);
138
+ abs_row1 = vaddq_u16(abs_row1, corr1);
139
+ abs_row2 = vaddq_u16(abs_row2, corr2);
140
+ abs_row3 = vaddq_u16(abs_row3, corr3);
141
+
142
+ /* Multiply DCT coefficients by quantization reciprocals. */
143
+ int32x4_t row0_l = vreinterpretq_s32_u32(vmull_u16(vget_low_u16(abs_row0),
144
+ vget_low_u16(recip0)));
145
+ int32x4_t row0_h = vreinterpretq_s32_u32(vmull_u16(vget_high_u16(abs_row0),
146
+ vget_high_u16(recip0)));
147
+ int32x4_t row1_l = vreinterpretq_s32_u32(vmull_u16(vget_low_u16(abs_row1),
148
+ vget_low_u16(recip1)));
149
+ int32x4_t row1_h = vreinterpretq_s32_u32(vmull_u16(vget_high_u16(abs_row1),
150
+ vget_high_u16(recip1)));
151
+ int32x4_t row2_l = vreinterpretq_s32_u32(vmull_u16(vget_low_u16(abs_row2),
152
+ vget_low_u16(recip2)));
153
+ int32x4_t row2_h = vreinterpretq_s32_u32(vmull_u16(vget_high_u16(abs_row2),
154
+ vget_high_u16(recip2)));
155
+ int32x4_t row3_l = vreinterpretq_s32_u32(vmull_u16(vget_low_u16(abs_row3),
156
+ vget_low_u16(recip3)));
157
+ int32x4_t row3_h = vreinterpretq_s32_u32(vmull_u16(vget_high_u16(abs_row3),
158
+ vget_high_u16(recip3)));
159
+ /* Narrow back to 16-bit. */
160
+ row0 = vcombine_s16(vshrn_n_s32(row0_l, 16), vshrn_n_s32(row0_h, 16));
161
+ row1 = vcombine_s16(vshrn_n_s32(row1_l, 16), vshrn_n_s32(row1_h, 16));
162
+ row2 = vcombine_s16(vshrn_n_s32(row2_l, 16), vshrn_n_s32(row2_h, 16));
163
+ row3 = vcombine_s16(vshrn_n_s32(row3_l, 16), vshrn_n_s32(row3_h, 16));
164
+
165
+ /* Since VSHR only supports an immediate as its second argument, negate the
166
+ * shift value and shift left.
167
+ */
168
+ row0 = vreinterpretq_s16_u16(vshlq_u16(vreinterpretq_u16_s16(row0),
169
+ vnegq_s16(shift0)));
170
+ row1 = vreinterpretq_s16_u16(vshlq_u16(vreinterpretq_u16_s16(row1),
171
+ vnegq_s16(shift1)));
172
+ row2 = vreinterpretq_s16_u16(vshlq_u16(vreinterpretq_u16_s16(row2),
173
+ vnegq_s16(shift2)));
174
+ row3 = vreinterpretq_s16_u16(vshlq_u16(vreinterpretq_u16_s16(row3),
175
+ vnegq_s16(shift3)));
176
+
177
+ /* Restore sign to original product. */
178
+ row0 = veorq_s16(row0, sign_row0);
179
+ row0 = vsubq_s16(row0, sign_row0);
180
+ row1 = veorq_s16(row1, sign_row1);
181
+ row1 = vsubq_s16(row1, sign_row1);
182
+ row2 = veorq_s16(row2, sign_row2);
183
+ row2 = vsubq_s16(row2, sign_row2);
184
+ row3 = veorq_s16(row3, sign_row3);
185
+ row3 = vsubq_s16(row3, sign_row3);
186
+
187
+ /* Store quantized coefficients to memory. */
188
+ vst1q_s16(out_ptr + (i + 0) * DCTSIZE, row0);
189
+ vst1q_s16(out_ptr + (i + 1) * DCTSIZE, row1);
190
+ vst1q_s16(out_ptr + (i + 2) * DCTSIZE, row2);
191
+ vst1q_s16(out_ptr + (i + 3) * DCTSIZE, row3);
192
+ }
193
+ }