epeg 1.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 (504) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -0
  3. data/MANIFEST +5 -0
  4. data/TODO +1 -0
  5. data/epeg/.dockerignore +4 -0
  6. data/epeg/.gitignore +5 -0
  7. data/epeg/CMakeLists.txt +30 -0
  8. data/epeg/Dockerfile +23 -0
  9. data/epeg/Epeg.h +90 -0
  10. data/epeg/README.md +42 -0
  11. data/epeg/epeg_main.c +1642 -0
  12. data/epeg/epeg_private.h +85 -0
  13. data/epeg/example/.gitignore +1 -0
  14. data/epeg/example/CMakeLists.txt +20 -0
  15. data/epeg/example/example.jpg +0 -0
  16. data/epeg/example/rotatetest.c +29 -0
  17. data/epeg/example/scaletest.c +48 -0
  18. data/epeg/vendor/libjpeg-turbo-2.0.4/BUILDING.md +828 -0
  19. data/epeg/vendor/libjpeg-turbo-2.0.4/CMakeLists.txt +1420 -0
  20. data/epeg/vendor/libjpeg-turbo-2.0.4/ChangeLog.md +1494 -0
  21. data/epeg/vendor/libjpeg-turbo-2.0.4/LICENSE.md +132 -0
  22. data/epeg/vendor/libjpeg-turbo-2.0.4/README.ijg +277 -0
  23. data/epeg/vendor/libjpeg-turbo-2.0.4/README.md +356 -0
  24. data/epeg/vendor/libjpeg-turbo-2.0.4/cderror.h +137 -0
  25. data/epeg/vendor/libjpeg-turbo-2.0.4/cdjpeg.c +145 -0
  26. data/epeg/vendor/libjpeg-turbo-2.0.4/cdjpeg.h +157 -0
  27. data/epeg/vendor/libjpeg-turbo-2.0.4/change.log +315 -0
  28. data/epeg/vendor/libjpeg-turbo-2.0.4/cjpeg.1 +354 -0
  29. data/epeg/vendor/libjpeg-turbo-2.0.4/cjpeg.c +695 -0
  30. data/epeg/vendor/libjpeg-turbo-2.0.4/cmakescripts/BuildPackages.cmake +182 -0
  31. data/epeg/vendor/libjpeg-turbo-2.0.4/cmakescripts/GNUInstallDirs.cmake +416 -0
  32. data/epeg/vendor/libjpeg-turbo-2.0.4/cmakescripts/cmake_uninstall.cmake.in +24 -0
  33. data/epeg/vendor/libjpeg-turbo-2.0.4/cmakescripts/testclean.cmake +41 -0
  34. data/epeg/vendor/libjpeg-turbo-2.0.4/cmyk.h +61 -0
  35. data/epeg/vendor/libjpeg-turbo-2.0.4/coderules.txt +78 -0
  36. data/epeg/vendor/libjpeg-turbo-2.0.4/djpeg.1 +296 -0
  37. data/epeg/vendor/libjpeg-turbo-2.0.4/djpeg.c +822 -0
  38. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/annotated.html +104 -0
  39. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/bc_s.png +0 -0
  40. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/bdwn.png +0 -0
  41. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/classes.html +106 -0
  42. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/closed.png +0 -0
  43. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/doxygen-extra.css +3 -0
  44. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/doxygen.css +1184 -0
  45. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/doxygen.png +0 -0
  46. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/dynsections.js +97 -0
  47. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/ftv2blank.png +0 -0
  48. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/ftv2cl.png +0 -0
  49. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/ftv2doc.png +0 -0
  50. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/ftv2folderclosed.png +0 -0
  51. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/ftv2folderopen.png +0 -0
  52. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/ftv2lastnode.png +0 -0
  53. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/ftv2link.png +0 -0
  54. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/ftv2mlastnode.png +0 -0
  55. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/ftv2mnode.png +0 -0
  56. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/ftv2mo.png +0 -0
  57. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/ftv2node.png +0 -0
  58. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/ftv2ns.png +0 -0
  59. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/ftv2plastnode.png +0 -0
  60. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/ftv2pnode.png +0 -0
  61. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/ftv2splitbar.png +0 -0
  62. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/ftv2vertline.png +0 -0
  63. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/functions.html +134 -0
  64. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/functions_vars.html +134 -0
  65. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/group___turbo_j_p_e_g.html +2775 -0
  66. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/index.html +90 -0
  67. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/jquery.js +8 -0
  68. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/modules.html +95 -0
  69. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/nav_f.png +0 -0
  70. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/nav_g.png +0 -0
  71. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/nav_h.png +0 -0
  72. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/open.png +0 -0
  73. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_63.html +26 -0
  74. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_63.js +4 -0
  75. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_64.html +26 -0
  76. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_64.js +5 -0
  77. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_68.html +26 -0
  78. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_68.js +4 -0
  79. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_6e.html +26 -0
  80. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_6e.js +4 -0
  81. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_6f.html +26 -0
  82. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_6f.js +5 -0
  83. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_72.html +26 -0
  84. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_72.js +4 -0
  85. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_74.html +26 -0
  86. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_74.js +102 -0
  87. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_77.html +26 -0
  88. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_77.js +4 -0
  89. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_78.html +26 -0
  90. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_78.js +4 -0
  91. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_79.html +26 -0
  92. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/all_79.js +4 -0
  93. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/classes_74.html +26 -0
  94. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/classes_74.js +6 -0
  95. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/close.png +0 -0
  96. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/enums_74.html +26 -0
  97. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/enums_74.js +8 -0
  98. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/enumvalues_74.html +26 -0
  99. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/enumvalues_74.js +37 -0
  100. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/functions_74.html +26 -0
  101. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/functions_74.js +31 -0
  102. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/groups_74.html +26 -0
  103. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/groups_74.js +4 -0
  104. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/mag_sel.png +0 -0
  105. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/nomatches.html +12 -0
  106. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/search.css +271 -0
  107. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/search.js +809 -0
  108. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/search_l.png +0 -0
  109. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/search_m.png +0 -0
  110. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/search_r.png +0 -0
  111. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/typedefs_74.html +26 -0
  112. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/typedefs_74.js +5 -0
  113. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_63.html +26 -0
  114. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_63.js +4 -0
  115. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_64.html +26 -0
  116. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_64.js +5 -0
  117. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_68.html +26 -0
  118. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_68.js +4 -0
  119. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_6e.html +26 -0
  120. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_6e.js +4 -0
  121. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_6f.html +26 -0
  122. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_6f.js +5 -0
  123. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_72.html +26 -0
  124. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_72.js +4 -0
  125. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_74.html +26 -0
  126. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_74.js +10 -0
  127. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_77.html +26 -0
  128. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_77.js +4 -0
  129. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_78.html +26 -0
  130. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_78.js +4 -0
  131. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_79.html +26 -0
  132. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/search/variables_79.js +4 -0
  133. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/structtjregion.html +186 -0
  134. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/structtjscalingfactor.html +148 -0
  135. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/structtjtransform.html +212 -0
  136. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/sync_off.png +0 -0
  137. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/sync_on.png +0 -0
  138. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/tab_a.png +0 -0
  139. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/tab_b.png +0 -0
  140. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/tab_h.png +0 -0
  141. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/tab_s.png +0 -0
  142. data/epeg/vendor/libjpeg-turbo-2.0.4/doc/html/tabs.css +60 -0
  143. data/epeg/vendor/libjpeg-turbo-2.0.4/doxygen-extra.css +3 -0
  144. data/epeg/vendor/libjpeg-turbo-2.0.4/doxygen.config +16 -0
  145. data/epeg/vendor/libjpeg-turbo-2.0.4/example.txt +464 -0
  146. data/epeg/vendor/libjpeg-turbo-2.0.4/jaricom.c +157 -0
  147. data/epeg/vendor/libjpeg-turbo-2.0.4/java/CMakeLists.txt +88 -0
  148. data/epeg/vendor/libjpeg-turbo-2.0.4/java/MANIFEST.MF +2 -0
  149. data/epeg/vendor/libjpeg-turbo-2.0.4/java/README +52 -0
  150. data/epeg/vendor/libjpeg-turbo-2.0.4/java/TJBench.java +1021 -0
  151. data/epeg/vendor/libjpeg-turbo-2.0.4/java/TJExample.java +405 -0
  152. data/epeg/vendor/libjpeg-turbo-2.0.4/java/TJUnitTest.java +960 -0
  153. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/allclasses-frame.html +24 -0
  154. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/allclasses-noframe.html +24 -0
  155. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/constant-values.html +532 -0
  156. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/deprecated-list.html +252 -0
  157. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/help-doc.html +210 -0
  158. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/index-all.html +1029 -0
  159. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/index.html +71 -0
  160. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/org/libjpegturbo/turbojpeg/TJ.html +1356 -0
  161. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/org/libjpegturbo/turbojpeg/TJCompressor.html +926 -0
  162. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/org/libjpegturbo/turbojpeg/TJCustomFilter.html +241 -0
  163. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/org/libjpegturbo/turbojpeg/TJDecompressor.html +1255 -0
  164. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/org/libjpegturbo/turbojpeg/TJException.html +340 -0
  165. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/org/libjpegturbo/turbojpeg/TJScalingFactor.html +343 -0
  166. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/org/libjpegturbo/turbojpeg/TJTransform.html +751 -0
  167. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/org/libjpegturbo/turbojpeg/TJTransformer.html +421 -0
  168. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/org/libjpegturbo/turbojpeg/YUVImage.html +765 -0
  169. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/org/libjpegturbo/turbojpeg/package-frame.html +31 -0
  170. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/org/libjpegturbo/turbojpeg/package-summary.html +202 -0
  171. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/org/libjpegturbo/turbojpeg/package-tree.html +160 -0
  172. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/overview-tree.html +164 -0
  173. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/package-list +1 -0
  174. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/resources/background.gif +0 -0
  175. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/resources/tab.gif +0 -0
  176. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/resources/titlebar.gif +0 -0
  177. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/resources/titlebar_end.gif +0 -0
  178. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/script.js +30 -0
  179. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/serialized-form.html +176 -0
  180. data/epeg/vendor/libjpeg-turbo-2.0.4/java/doc/stylesheet.css +474 -0
  181. data/epeg/vendor/libjpeg-turbo-2.0.4/java/org/libjpegturbo/turbojpeg/TJ.java +584 -0
  182. data/epeg/vendor/libjpeg-turbo-2.0.4/java/org/libjpegturbo/turbojpeg/TJCompressor.java +677 -0
  183. data/epeg/vendor/libjpeg-turbo-2.0.4/java/org/libjpegturbo/turbojpeg/TJCustomFilter.java +76 -0
  184. data/epeg/vendor/libjpeg-turbo-2.0.4/java/org/libjpegturbo/turbojpeg/TJDecompressor.java +931 -0
  185. data/epeg/vendor/libjpeg-turbo-2.0.4/java/org/libjpegturbo/turbojpeg/TJException.java +78 -0
  186. data/epeg/vendor/libjpeg-turbo-2.0.4/java/org/libjpegturbo/turbojpeg/TJLoader-unix.java.in +59 -0
  187. data/epeg/vendor/libjpeg-turbo-2.0.4/java/org/libjpegturbo/turbojpeg/TJLoader-win.java.in +35 -0
  188. data/epeg/vendor/libjpeg-turbo-2.0.4/java/org/libjpegturbo/turbojpeg/TJScalingFactor.java +115 -0
  189. data/epeg/vendor/libjpeg-turbo-2.0.4/java/org/libjpegturbo/turbojpeg/TJTransform.java +227 -0
  190. data/epeg/vendor/libjpeg-turbo-2.0.4/java/org/libjpegturbo/turbojpeg/TJTransformer.java +163 -0
  191. data/epeg/vendor/libjpeg-turbo-2.0.4/java/org/libjpegturbo/turbojpeg/YUVImage.java +445 -0
  192. data/epeg/vendor/libjpeg-turbo-2.0.4/java/org_libjpegturbo_turbojpeg_TJ.h +129 -0
  193. data/epeg/vendor/libjpeg-turbo-2.0.4/java/org_libjpegturbo_turbojpeg_TJCompressor.h +101 -0
  194. data/epeg/vendor/libjpeg-turbo-2.0.4/java/org_libjpegturbo_turbojpeg_TJDecompressor.h +101 -0
  195. data/epeg/vendor/libjpeg-turbo-2.0.4/java/org_libjpegturbo_turbojpeg_TJTransformer.h +29 -0
  196. data/epeg/vendor/libjpeg-turbo-2.0.4/jcapimin.c +295 -0
  197. data/epeg/vendor/libjpeg-turbo-2.0.4/jcapistd.c +162 -0
  198. data/epeg/vendor/libjpeg-turbo-2.0.4/jcarith.c +932 -0
  199. data/epeg/vendor/libjpeg-turbo-2.0.4/jccoefct.c +449 -0
  200. data/epeg/vendor/libjpeg-turbo-2.0.4/jccolext.c +144 -0
  201. data/epeg/vendor/libjpeg-turbo-2.0.4/jccolor.c +710 -0
  202. data/epeg/vendor/libjpeg-turbo-2.0.4/jcdctmgr.c +721 -0
  203. data/epeg/vendor/libjpeg-turbo-2.0.4/jchuff.c +1096 -0
  204. data/epeg/vendor/libjpeg-turbo-2.0.4/jchuff.h +42 -0
  205. data/epeg/vendor/libjpeg-turbo-2.0.4/jcicc.c +105 -0
  206. data/epeg/vendor/libjpeg-turbo-2.0.4/jcinit.c +77 -0
  207. data/epeg/vendor/libjpeg-turbo-2.0.4/jcmainct.c +162 -0
  208. data/epeg/vendor/libjpeg-turbo-2.0.4/jcmarker.c +664 -0
  209. data/epeg/vendor/libjpeg-turbo-2.0.4/jcmaster.c +640 -0
  210. data/epeg/vendor/libjpeg-turbo-2.0.4/jcomapi.c +109 -0
  211. data/epeg/vendor/libjpeg-turbo-2.0.4/jconfig.h.in +73 -0
  212. data/epeg/vendor/libjpeg-turbo-2.0.4/jconfig.txt +143 -0
  213. data/epeg/vendor/libjpeg-turbo-2.0.4/jconfigint.h.in +31 -0
  214. data/epeg/vendor/libjpeg-turbo-2.0.4/jcparam.c +541 -0
  215. data/epeg/vendor/libjpeg-turbo-2.0.4/jcphuff.c +1105 -0
  216. data/epeg/vendor/libjpeg-turbo-2.0.4/jcprepct.c +351 -0
  217. data/epeg/vendor/libjpeg-turbo-2.0.4/jcsample.c +539 -0
  218. data/epeg/vendor/libjpeg-turbo-2.0.4/jcstest.c +126 -0
  219. data/epeg/vendor/libjpeg-turbo-2.0.4/jctrans.c +400 -0
  220. data/epeg/vendor/libjpeg-turbo-2.0.4/jdapimin.c +407 -0
  221. data/epeg/vendor/libjpeg-turbo-2.0.4/jdapistd.c +639 -0
  222. data/epeg/vendor/libjpeg-turbo-2.0.4/jdarith.c +773 -0
  223. data/epeg/vendor/libjpeg-turbo-2.0.4/jdatadst-tj.c +203 -0
  224. data/epeg/vendor/libjpeg-turbo-2.0.4/jdatadst.c +293 -0
  225. data/epeg/vendor/libjpeg-turbo-2.0.4/jdatasrc-tj.c +194 -0
  226. data/epeg/vendor/libjpeg-turbo-2.0.4/jdatasrc.c +295 -0
  227. data/epeg/vendor/libjpeg-turbo-2.0.4/jdcoefct.c +692 -0
  228. data/epeg/vendor/libjpeg-turbo-2.0.4/jdcoefct.h +82 -0
  229. data/epeg/vendor/libjpeg-turbo-2.0.4/jdcol565.c +384 -0
  230. data/epeg/vendor/libjpeg-turbo-2.0.4/jdcolext.c +143 -0
  231. data/epeg/vendor/libjpeg-turbo-2.0.4/jdcolor.c +883 -0
  232. data/epeg/vendor/libjpeg-turbo-2.0.4/jdct.h +208 -0
  233. data/epeg/vendor/libjpeg-turbo-2.0.4/jddctmgr.c +352 -0
  234. data/epeg/vendor/libjpeg-turbo-2.0.4/jdhuff.c +831 -0
  235. data/epeg/vendor/libjpeg-turbo-2.0.4/jdhuff.h +238 -0
  236. data/epeg/vendor/libjpeg-turbo-2.0.4/jdicc.c +171 -0
  237. data/epeg/vendor/libjpeg-turbo-2.0.4/jdinput.c +408 -0
  238. data/epeg/vendor/libjpeg-turbo-2.0.4/jdmainct.c +460 -0
  239. data/epeg/vendor/libjpeg-turbo-2.0.4/jdmainct.h +71 -0
  240. data/epeg/vendor/libjpeg-turbo-2.0.4/jdmarker.c +1377 -0
  241. data/epeg/vendor/libjpeg-turbo-2.0.4/jdmaster.c +737 -0
  242. data/epeg/vendor/libjpeg-turbo-2.0.4/jdmaster.h +28 -0
  243. data/epeg/vendor/libjpeg-turbo-2.0.4/jdmerge.c +617 -0
  244. data/epeg/vendor/libjpeg-turbo-2.0.4/jdmrg565.c +354 -0
  245. data/epeg/vendor/libjpeg-turbo-2.0.4/jdmrgext.c +184 -0
  246. data/epeg/vendor/libjpeg-turbo-2.0.4/jdphuff.c +687 -0
  247. data/epeg/vendor/libjpeg-turbo-2.0.4/jdpostct.c +294 -0
  248. data/epeg/vendor/libjpeg-turbo-2.0.4/jdsample.c +518 -0
  249. data/epeg/vendor/libjpeg-turbo-2.0.4/jdsample.h +50 -0
  250. data/epeg/vendor/libjpeg-turbo-2.0.4/jdtrans.c +155 -0
  251. data/epeg/vendor/libjpeg-turbo-2.0.4/jerror.c +251 -0
  252. data/epeg/vendor/libjpeg-turbo-2.0.4/jerror.h +316 -0
  253. data/epeg/vendor/libjpeg-turbo-2.0.4/jfdctflt.c +169 -0
  254. data/epeg/vendor/libjpeg-turbo-2.0.4/jfdctfst.c +227 -0
  255. data/epeg/vendor/libjpeg-turbo-2.0.4/jfdctint.c +288 -0
  256. data/epeg/vendor/libjpeg-turbo-2.0.4/jidctflt.c +240 -0
  257. data/epeg/vendor/libjpeg-turbo-2.0.4/jidctfst.c +371 -0
  258. data/epeg/vendor/libjpeg-turbo-2.0.4/jidctint.c +2627 -0
  259. data/epeg/vendor/libjpeg-turbo-2.0.4/jidctred.c +409 -0
  260. data/epeg/vendor/libjpeg-turbo-2.0.4/jinclude.h +88 -0
  261. data/epeg/vendor/libjpeg-turbo-2.0.4/jmemmgr.c +1179 -0
  262. data/epeg/vendor/libjpeg-turbo-2.0.4/jmemnobs.c +115 -0
  263. data/epeg/vendor/libjpeg-turbo-2.0.4/jmemsys.h +178 -0
  264. data/epeg/vendor/libjpeg-turbo-2.0.4/jmorecfg.h +421 -0
  265. data/epeg/vendor/libjpeg-turbo-2.0.4/jpeg_nbits_table.h +4098 -0
  266. data/epeg/vendor/libjpeg-turbo-2.0.4/jpegcomp.h +31 -0
  267. data/epeg/vendor/libjpeg-turbo-2.0.4/jpegint.h +368 -0
  268. data/epeg/vendor/libjpeg-turbo-2.0.4/jpeglib.h +1132 -0
  269. data/epeg/vendor/libjpeg-turbo-2.0.4/jpegtran.1 +295 -0
  270. data/epeg/vendor/libjpeg-turbo-2.0.4/jpegtran.c +601 -0
  271. data/epeg/vendor/libjpeg-turbo-2.0.4/jquant1.c +859 -0
  272. data/epeg/vendor/libjpeg-turbo-2.0.4/jquant2.c +1285 -0
  273. data/epeg/vendor/libjpeg-turbo-2.0.4/jsimd.h +117 -0
  274. data/epeg/vendor/libjpeg-turbo-2.0.4/jsimd_none.c +418 -0
  275. data/epeg/vendor/libjpeg-turbo-2.0.4/jsimddct.h +70 -0
  276. data/epeg/vendor/libjpeg-turbo-2.0.4/jstdhuff.c +143 -0
  277. data/epeg/vendor/libjpeg-turbo-2.0.4/jutils.c +133 -0
  278. data/epeg/vendor/libjpeg-turbo-2.0.4/jversion.h +52 -0
  279. data/epeg/vendor/libjpeg-turbo-2.0.4/libjpeg.map.in +11 -0
  280. data/epeg/vendor/libjpeg-turbo-2.0.4/libjpeg.txt +3144 -0
  281. data/epeg/vendor/libjpeg-turbo-2.0.4/md5/CMakeLists.txt +1 -0
  282. data/epeg/vendor/libjpeg-turbo-2.0.4/md5/md5.c +275 -0
  283. data/epeg/vendor/libjpeg-turbo-2.0.4/md5/md5.h +57 -0
  284. data/epeg/vendor/libjpeg-turbo-2.0.4/md5/md5cmp.c +59 -0
  285. data/epeg/vendor/libjpeg-turbo-2.0.4/md5/md5hl.c +125 -0
  286. data/epeg/vendor/libjpeg-turbo-2.0.4/rdbmp.c +689 -0
  287. data/epeg/vendor/libjpeg-turbo-2.0.4/rdcolmap.c +254 -0
  288. data/epeg/vendor/libjpeg-turbo-2.0.4/rdgif.c +39 -0
  289. data/epeg/vendor/libjpeg-turbo-2.0.4/rdjpgcom.1 +63 -0
  290. data/epeg/vendor/libjpeg-turbo-2.0.4/rdjpgcom.c +510 -0
  291. data/epeg/vendor/libjpeg-turbo-2.0.4/rdppm.c +766 -0
  292. data/epeg/vendor/libjpeg-turbo-2.0.4/rdrle.c +389 -0
  293. data/epeg/vendor/libjpeg-turbo-2.0.4/rdswitch.c +424 -0
  294. data/epeg/vendor/libjpeg-turbo-2.0.4/rdtarga.c +509 -0
  295. data/epeg/vendor/libjpeg-turbo-2.0.4/release/Distribution.xml.in +24 -0
  296. data/epeg/vendor/libjpeg-turbo-2.0.4/release/License.rtf +20 -0
  297. data/epeg/vendor/libjpeg-turbo-2.0.4/release/ReadMe.txt +5 -0
  298. data/epeg/vendor/libjpeg-turbo-2.0.4/release/Welcome.rtf +17 -0
  299. data/epeg/vendor/libjpeg-turbo-2.0.4/release/deb-control.in +31 -0
  300. data/epeg/vendor/libjpeg-turbo-2.0.4/release/installer.nsi.in +191 -0
  301. data/epeg/vendor/libjpeg-turbo-2.0.4/release/libjpeg.pc.in +10 -0
  302. data/epeg/vendor/libjpeg-turbo-2.0.4/release/libturbojpeg.pc.in +10 -0
  303. data/epeg/vendor/libjpeg-turbo-2.0.4/release/makecygwinpkg.in +66 -0
  304. data/epeg/vendor/libjpeg-turbo-2.0.4/release/makedpkg.in +115 -0
  305. data/epeg/vendor/libjpeg-turbo-2.0.4/release/makemacpkg.in +284 -0
  306. data/epeg/vendor/libjpeg-turbo-2.0.4/release/makerpm.in +30 -0
  307. data/epeg/vendor/libjpeg-turbo-2.0.4/release/makesrpm.in +48 -0
  308. data/epeg/vendor/libjpeg-turbo-2.0.4/release/maketarball.in +51 -0
  309. data/epeg/vendor/libjpeg-turbo-2.0.4/release/rpm.spec.in +221 -0
  310. data/epeg/vendor/libjpeg-turbo-2.0.4/release/uninstall.in +113 -0
  311. data/epeg/vendor/libjpeg-turbo-2.0.4/sharedlib/CMakeLists.txt +99 -0
  312. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/CMakeLists.txt +385 -0
  313. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/arm/jsimd.c +721 -0
  314. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/arm/jsimd_neon.S +2878 -0
  315. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/arm64/jsimd.c +798 -0
  316. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/arm64/jsimd_neon.S +3433 -0
  317. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/gas-preprocessor.in +1 -0
  318. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jccolext-avx2.asm +578 -0
  319. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jccolext-mmx.asm +476 -0
  320. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jccolext-sse2.asm +503 -0
  321. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jccolor-avx2.asm +121 -0
  322. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jccolor-mmx.asm +121 -0
  323. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jccolor-sse2.asm +120 -0
  324. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jcgray-avx2.asm +113 -0
  325. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jcgray-mmx.asm +113 -0
  326. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jcgray-sse2.asm +112 -0
  327. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jcgryext-avx2.asm +457 -0
  328. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jcgryext-mmx.asm +355 -0
  329. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jcgryext-sse2.asm +382 -0
  330. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jchuff-sse2.asm +424 -0
  331. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jcphuff-sse2.asm +660 -0
  332. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jcsample-avx2.asm +388 -0
  333. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jcsample-mmx.asm +324 -0
  334. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jcsample-sse2.asm +351 -0
  335. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jdcolext-avx2.asm +515 -0
  336. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jdcolext-mmx.asm +404 -0
  337. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jdcolext-sse2.asm +458 -0
  338. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jdcolor-avx2.asm +118 -0
  339. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jdcolor-mmx.asm +117 -0
  340. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jdcolor-sse2.asm +117 -0
  341. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jdmerge-avx2.asm +136 -0
  342. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jdmerge-mmx.asm +123 -0
  343. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jdmerge-sse2.asm +135 -0
  344. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jdmrgext-avx2.asm +575 -0
  345. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jdmrgext-mmx.asm +460 -0
  346. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jdmrgext-sse2.asm +517 -0
  347. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jdsample-avx2.asm +760 -0
  348. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jdsample-mmx.asm +731 -0
  349. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jdsample-sse2.asm +724 -0
  350. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jfdctflt-3dn.asm +318 -0
  351. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jfdctflt-sse.asm +369 -0
  352. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jfdctfst-mmx.asm +395 -0
  353. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jfdctfst-sse2.asm +403 -0
  354. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jfdctint-avx2.asm +331 -0
  355. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jfdctint-mmx.asm +620 -0
  356. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jfdctint-sse2.asm +633 -0
  357. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jidctflt-3dn.asm +451 -0
  358. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jidctflt-sse.asm +571 -0
  359. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jidctflt-sse2.asm +497 -0
  360. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jidctfst-mmx.asm +499 -0
  361. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jidctfst-sse2.asm +501 -0
  362. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jidctint-avx2.asm +453 -0
  363. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jidctint-mmx.asm +851 -0
  364. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jidctint-sse2.asm +858 -0
  365. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jidctred-mmx.asm +704 -0
  366. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jidctred-sse2.asm +592 -0
  367. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jquant-3dn.asm +230 -0
  368. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jquant-mmx.asm +276 -0
  369. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jquant-sse.asm +208 -0
  370. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jquantf-sse2.asm +168 -0
  371. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jquanti-avx2.asm +188 -0
  372. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jquanti-sse2.asm +201 -0
  373. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jsimd.c +1253 -0
  374. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/i386/jsimdcpu.asm +135 -0
  375. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/jsimd.h +1083 -0
  376. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/loongson/jccolext-mmi.c +483 -0
  377. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/loongson/jccolor-mmi.c +148 -0
  378. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/loongson/jcsample-mmi.c +100 -0
  379. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/loongson/jcsample.h +28 -0
  380. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/loongson/jdcolext-mmi.c +424 -0
  381. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/loongson/jdcolor-mmi.c +139 -0
  382. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/loongson/jdsample-mmi.c +245 -0
  383. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/loongson/jfdctint-mmi.c +398 -0
  384. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/loongson/jidctint-mmi.c +571 -0
  385. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/loongson/jquanti-mmi.c +130 -0
  386. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/loongson/jsimd.c +610 -0
  387. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/loongson/jsimd_mmi.h +57 -0
  388. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/loongson/loongson-mmintrin.h +1324 -0
  389. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/mips/jsimd.c +1123 -0
  390. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/mips/jsimd_dspr2.S +4479 -0
  391. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/mips/jsimd_dspr2_asm.h +292 -0
  392. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/nasm/jcolsamp.inc +135 -0
  393. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/nasm/jdct.inc +31 -0
  394. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/nasm/jpeg_nbits_table.inc +4097 -0
  395. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/nasm/jsimdcfg.inc +93 -0
  396. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/nasm/jsimdcfg.inc.h +131 -0
  397. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/nasm/jsimdext.inc +479 -0
  398. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jccolext-altivec.c +269 -0
  399. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jccolor-altivec.c +116 -0
  400. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jcgray-altivec.c +111 -0
  401. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jcgryext-altivec.c +228 -0
  402. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jcsample-altivec.c +159 -0
  403. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jcsample.h +28 -0
  404. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jdcolext-altivec.c +276 -0
  405. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jdcolor-altivec.c +106 -0
  406. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jdmerge-altivec.c +130 -0
  407. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jdmrgext-altivec.c +329 -0
  408. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jdsample-altivec.c +400 -0
  409. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jfdctfst-altivec.c +154 -0
  410. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jfdctint-altivec.c +258 -0
  411. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jidctfst-altivec.c +255 -0
  412. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jidctint-altivec.c +357 -0
  413. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jquanti-altivec.c +250 -0
  414. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jsimd.c +872 -0
  415. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/powerpc/jsimd_altivec.h +98 -0
  416. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jccolext-avx2.asm +558 -0
  417. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jccolext-sse2.asm +483 -0
  418. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jccolor-avx2.asm +121 -0
  419. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jccolor-sse2.asm +120 -0
  420. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jcgray-avx2.asm +113 -0
  421. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jcgray-sse2.asm +112 -0
  422. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jcgryext-avx2.asm +437 -0
  423. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jcgryext-sse2.asm +362 -0
  424. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jchuff-sse2.asm +346 -0
  425. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jcphuff-sse2.asm +637 -0
  426. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jcsample-avx2.asm +366 -0
  427. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jcsample-sse2.asm +329 -0
  428. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jdcolext-avx2.asm +495 -0
  429. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jdcolext-sse2.asm +438 -0
  430. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jdcolor-avx2.asm +118 -0
  431. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jdcolor-sse2.asm +117 -0
  432. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jdmerge-avx2.asm +136 -0
  433. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jdmerge-sse2.asm +135 -0
  434. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jdmrgext-avx2.asm +593 -0
  435. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jdmrgext-sse2.asm +535 -0
  436. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jdsample-avx2.asm +695 -0
  437. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jdsample-sse2.asm +664 -0
  438. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jfdctflt-sse.asm +355 -0
  439. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jfdctfst-sse2.asm +389 -0
  440. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jfdctint-avx2.asm +320 -0
  441. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jfdctint-sse2.asm +619 -0
  442. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jidctflt-sse2.asm +481 -0
  443. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jidctfst-sse2.asm +490 -0
  444. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jidctint-avx2.asm +417 -0
  445. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jidctint-sse2.asm +846 -0
  446. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jidctred-sse2.asm +573 -0
  447. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jquantf-sse2.asm +154 -0
  448. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jquanti-avx2.asm +162 -0
  449. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jquanti-sse2.asm +187 -0
  450. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jsimd.c +1076 -0
  451. data/epeg/vendor/libjpeg-turbo-2.0.4/simd/x86_64/jsimdcpu.asm +86 -0
  452. data/epeg/vendor/libjpeg-turbo-2.0.4/structure.txt +904 -0
  453. data/epeg/vendor/libjpeg-turbo-2.0.4/testimages/nightshot_iso_100.bmp +0 -0
  454. data/epeg/vendor/libjpeg-turbo-2.0.4/testimages/nightshot_iso_100.txt +25 -0
  455. data/epeg/vendor/libjpeg-turbo-2.0.4/testimages/test.scan +5 -0
  456. data/epeg/vendor/libjpeg-turbo-2.0.4/testimages/test1.icc +0 -0
  457. data/epeg/vendor/libjpeg-turbo-2.0.4/testimages/test1.icc.txt +20 -0
  458. data/epeg/vendor/libjpeg-turbo-2.0.4/testimages/test2.icc +0 -0
  459. data/epeg/vendor/libjpeg-turbo-2.0.4/testimages/test2.icc.txt +20 -0
  460. data/epeg/vendor/libjpeg-turbo-2.0.4/testimages/testimgari.jpg +0 -0
  461. data/epeg/vendor/libjpeg-turbo-2.0.4/testimages/testimgint.jpg +0 -0
  462. data/epeg/vendor/libjpeg-turbo-2.0.4/testimages/testorig.jpg +0 -0
  463. data/epeg/vendor/libjpeg-turbo-2.0.4/testimages/testorig.ppm +4 -0
  464. data/epeg/vendor/libjpeg-turbo-2.0.4/testimages/testorig12.jpg +0 -0
  465. data/epeg/vendor/libjpeg-turbo-2.0.4/testimages/vgl_5674_0098.bmp +0 -0
  466. data/epeg/vendor/libjpeg-turbo-2.0.4/testimages/vgl_6434_0018a.bmp +0 -0
  467. data/epeg/vendor/libjpeg-turbo-2.0.4/testimages/vgl_6548_0026a.bmp +0 -0
  468. data/epeg/vendor/libjpeg-turbo-2.0.4/tjbench.c +1031 -0
  469. data/epeg/vendor/libjpeg-turbo-2.0.4/tjbenchtest.in +256 -0
  470. data/epeg/vendor/libjpeg-turbo-2.0.4/tjbenchtest.java.in +215 -0
  471. data/epeg/vendor/libjpeg-turbo-2.0.4/tjexample.c +396 -0
  472. data/epeg/vendor/libjpeg-turbo-2.0.4/tjexampletest.in +149 -0
  473. data/epeg/vendor/libjpeg-turbo-2.0.4/tjexampletest.java.in +151 -0
  474. data/epeg/vendor/libjpeg-turbo-2.0.4/tjunittest.c +931 -0
  475. data/epeg/vendor/libjpeg-turbo-2.0.4/tjutil.c +70 -0
  476. data/epeg/vendor/libjpeg-turbo-2.0.4/tjutil.h +47 -0
  477. data/epeg/vendor/libjpeg-turbo-2.0.4/transupp.c +1628 -0
  478. data/epeg/vendor/libjpeg-turbo-2.0.4/transupp.h +210 -0
  479. data/epeg/vendor/libjpeg-turbo-2.0.4/turbojpeg-jni.c +1246 -0
  480. data/epeg/vendor/libjpeg-turbo-2.0.4/turbojpeg-mapfile +65 -0
  481. data/epeg/vendor/libjpeg-turbo-2.0.4/turbojpeg-mapfile.jni +101 -0
  482. data/epeg/vendor/libjpeg-turbo-2.0.4/turbojpeg.c +2152 -0
  483. data/epeg/vendor/libjpeg-turbo-2.0.4/turbojpeg.h +1744 -0
  484. data/epeg/vendor/libjpeg-turbo-2.0.4/usage.txt +635 -0
  485. data/epeg/vendor/libjpeg-turbo-2.0.4/win/jconfig.h.in +34 -0
  486. data/epeg/vendor/libjpeg-turbo-2.0.4/win/jpeg62-memsrcdst.def +108 -0
  487. data/epeg/vendor/libjpeg-turbo-2.0.4/win/jpeg62.def +106 -0
  488. data/epeg/vendor/libjpeg-turbo-2.0.4/win/jpeg7-memsrcdst.def +110 -0
  489. data/epeg/vendor/libjpeg-turbo-2.0.4/win/jpeg7.def +108 -0
  490. data/epeg/vendor/libjpeg-turbo-2.0.4/win/jpeg8.def +111 -0
  491. data/epeg/vendor/libjpeg-turbo-2.0.4/wizard.txt +212 -0
  492. data/epeg/vendor/libjpeg-turbo-2.0.4/wrbmp.c +558 -0
  493. data/epeg/vendor/libjpeg-turbo-2.0.4/wrgif.c +413 -0
  494. data/epeg/vendor/libjpeg-turbo-2.0.4/wrjpgcom.1 +103 -0
  495. data/epeg/vendor/libjpeg-turbo-2.0.4/wrjpgcom.c +591 -0
  496. data/epeg/vendor/libjpeg-turbo-2.0.4/wrppm.c +365 -0
  497. data/epeg/vendor/libjpeg-turbo-2.0.4/wrrle.c +309 -0
  498. data/epeg/vendor/libjpeg-turbo-2.0.4/wrtarga.c +261 -0
  499. data/epeg.c +131 -0
  500. data/epeg.gemspec +18 -0
  501. data/extconf.rb +80 -0
  502. data/test.jpg +0 -0
  503. data/test.rb +42 -0
  504. metadata +546 -0
@@ -0,0 +1,1246 @@
1
+ /*
2
+ * Copyright (C)2011-2019 D. R. Commander. All Rights Reserved.
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions are met:
6
+ *
7
+ * - Redistributions of source code must retain the above copyright notice,
8
+ * this list of conditions and the following disclaimer.
9
+ * - Redistributions in binary form must reproduce the above copyright notice,
10
+ * this list of conditions and the following disclaimer in the documentation
11
+ * and/or other materials provided with the distribution.
12
+ * - Neither the name of the libjpeg-turbo Project nor the names of its
13
+ * contributors may be used to endorse or promote products derived from this
14
+ * software without specific prior written permission.
15
+ *
16
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
17
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
+ * POSSIBILITY OF SUCH DAMAGE.
27
+ */
28
+
29
+ #include <stdlib.h>
30
+ #include <string.h>
31
+ #include "turbojpeg.h"
32
+ #ifdef WIN32
33
+ #include "tjutil.h"
34
+ #endif
35
+ #include <jni.h>
36
+ #include "java/org_libjpegturbo_turbojpeg_TJCompressor.h"
37
+ #include "java/org_libjpegturbo_turbojpeg_TJDecompressor.h"
38
+ #include "java/org_libjpegturbo_turbojpeg_TJTransformer.h"
39
+ #include "java/org_libjpegturbo_turbojpeg_TJ.h"
40
+
41
+ #define BAILIF0(f) { \
42
+ if (!(f) || (*env)->ExceptionCheck(env)) { \
43
+ goto bailout; \
44
+ } \
45
+ }
46
+
47
+ #define THROW(msg, exceptionClass) { \
48
+ jclass _exccls = (*env)->FindClass(env, exceptionClass); \
49
+ \
50
+ BAILIF0(_exccls); \
51
+ (*env)->ThrowNew(env, _exccls, msg); \
52
+ goto bailout; \
53
+ }
54
+
55
+ #define THROW_TJ() { \
56
+ jclass _exccls; \
57
+ jmethodID _excid; \
58
+ jobject _excobj; \
59
+ jstring _errstr; \
60
+ \
61
+ BAILIF0(_errstr = (*env)->NewStringUTF(env, tjGetErrorStr2(handle))); \
62
+ BAILIF0(_exccls = (*env)->FindClass(env, \
63
+ "org/libjpegturbo/turbojpeg/TJException")); \
64
+ BAILIF0(_excid = (*env)->GetMethodID(env, _exccls, "<init>", \
65
+ "(Ljava/lang/String;I)V")); \
66
+ BAILIF0(_excobj = (*env)->NewObject(env, _exccls, _excid, _errstr, \
67
+ tjGetErrorCode(handle))); \
68
+ (*env)->Throw(env, _excobj); \
69
+ goto bailout; \
70
+ }
71
+
72
+ #define THROW_ARG(msg) THROW(msg, "java/lang/IllegalArgumentException")
73
+
74
+ #define THROW_MEM() \
75
+ THROW("Memory allocation failure", "java/lang/OutOfMemoryError");
76
+
77
+ #define GET_HANDLE() \
78
+ jclass _cls = (*env)->GetObjectClass(env, obj); \
79
+ jfieldID _fid; \
80
+ \
81
+ BAILIF0(_cls); \
82
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "handle", "J")); \
83
+ handle = (tjhandle)(size_t)(*env)->GetLongField(env, obj, _fid);
84
+
85
+ #ifdef _WIN32
86
+ #define setenv(envvar, value, dummy) _putenv_s(envvar, value)
87
+ #endif
88
+
89
+ #define PROP2ENV(property, envvar) { \
90
+ if ((jName = (*env)->NewStringUTF(env, property)) != NULL && \
91
+ (jValue = (*env)->CallStaticObjectMethod(env, cls, mid, \
92
+ jName)) != NULL) { \
93
+ if ((value = (*env)->GetStringUTFChars(env, jValue, 0)) != NULL) { \
94
+ setenv(envvar, value, 1); \
95
+ (*env)->ReleaseStringUTFChars(env, jValue, value); \
96
+ } \
97
+ } \
98
+ }
99
+
100
+ #define SAFE_RELEASE(javaArray, cArray) { \
101
+ if (javaArray && cArray) \
102
+ (*env)->ReleasePrimitiveArrayCritical(env, javaArray, (void *)cArray, 0); \
103
+ cArray = NULL; \
104
+ }
105
+
106
+ static int ProcessSystemProperties(JNIEnv *env)
107
+ {
108
+ jclass cls;
109
+ jmethodID mid;
110
+ jstring jName, jValue;
111
+ const char *value;
112
+
113
+ BAILIF0(cls = (*env)->FindClass(env, "java/lang/System"));
114
+ BAILIF0(mid = (*env)->GetStaticMethodID(env, cls, "getProperty",
115
+ "(Ljava/lang/String;)Ljava/lang/String;"));
116
+
117
+ PROP2ENV("turbojpeg.optimize", "TJ_OPTIMIZE");
118
+ PROP2ENV("turbojpeg.arithmetic", "TJ_ARITHMETIC");
119
+ PROP2ENV("turbojpeg.restart", "TJ_RESTART");
120
+ PROP2ENV("turbojpeg.progressive", "TJ_PROGRESSIVE");
121
+ return 0;
122
+
123
+ bailout:
124
+ return -1;
125
+ }
126
+
127
+ /* TurboJPEG 1.2.x: TJ::bufSize() */
128
+ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSize
129
+ (JNIEnv *env, jclass cls, jint width, jint height, jint jpegSubsamp)
130
+ {
131
+ jint retval = (jint)tjBufSize(width, height, jpegSubsamp);
132
+
133
+ if (retval == -1) THROW_ARG(tjGetErrorStr());
134
+
135
+ bailout:
136
+ return retval;
137
+ }
138
+
139
+ /* TurboJPEG 1.4.x: TJ::bufSizeYUV() */
140
+ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSizeYUV__IIII
141
+ (JNIEnv *env, jclass cls, jint width, jint pad, jint height, jint subsamp)
142
+ {
143
+ jint retval = (jint)tjBufSizeYUV2(width, pad, height, subsamp);
144
+
145
+ if (retval == -1) THROW_ARG(tjGetErrorStr());
146
+
147
+ bailout:
148
+ return retval;
149
+ }
150
+
151
+ /* TurboJPEG 1.2.x: TJ::bufSizeYUV() */
152
+ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_bufSizeYUV__III
153
+ (JNIEnv *env, jclass cls, jint width, jint height, jint subsamp)
154
+ {
155
+ return Java_org_libjpegturbo_turbojpeg_TJ_bufSizeYUV__IIII(env, cls, width,
156
+ 4, height,
157
+ subsamp);
158
+ }
159
+
160
+ /* TurboJPEG 1.4.x: TJ::planeSizeYUV() */
161
+ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_planeSizeYUV__IIIII
162
+ (JNIEnv *env, jclass cls, jint componentID, jint width, jint stride,
163
+ jint height, jint subsamp)
164
+ {
165
+ jint retval = (jint)tjPlaneSizeYUV(componentID, width, stride, height,
166
+ subsamp);
167
+
168
+ if (retval == -1) THROW_ARG(tjGetErrorStr());
169
+
170
+ bailout:
171
+ return retval;
172
+ }
173
+
174
+ /* TurboJPEG 1.4.x: TJ::planeWidth() */
175
+ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_planeWidth__III
176
+ (JNIEnv *env, jclass cls, jint componentID, jint width, jint subsamp)
177
+ {
178
+ jint retval = (jint)tjPlaneWidth(componentID, width, subsamp);
179
+
180
+ if (retval == -1) THROW_ARG(tjGetErrorStr());
181
+
182
+ bailout:
183
+ return retval;
184
+ }
185
+
186
+ /* TurboJPEG 1.4.x: TJ::planeHeight() */
187
+ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJ_planeHeight__III
188
+ (JNIEnv *env, jclass cls, jint componentID, jint height, jint subsamp)
189
+ {
190
+ jint retval = (jint)tjPlaneHeight(componentID, height, subsamp);
191
+
192
+ if (retval == -1) THROW_ARG(tjGetErrorStr());
193
+
194
+ bailout:
195
+ return retval;
196
+ }
197
+
198
+ /* TurboJPEG 1.2.x: TJCompressor::init() */
199
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_init
200
+ (JNIEnv *env, jobject obj)
201
+ {
202
+ jclass cls;
203
+ jfieldID fid;
204
+ tjhandle handle;
205
+
206
+ if ((handle = tjInitCompress()) == NULL)
207
+ THROW(tjGetErrorStr(), "org/libjpegturbo/turbojpeg/TJException");
208
+
209
+ BAILIF0(cls = (*env)->GetObjectClass(env, obj));
210
+ BAILIF0(fid = (*env)->GetFieldID(env, cls, "handle", "J"));
211
+ (*env)->SetLongField(env, obj, fid, (size_t)handle);
212
+
213
+ bailout:
214
+ return;
215
+ }
216
+
217
+ static jint TJCompressor_compress
218
+ (JNIEnv *env, jobject obj, jarray src, jint srcElementSize, jint x, jint y,
219
+ jint width, jint pitch, jint height, jint pf, jbyteArray dst,
220
+ jint jpegSubsamp, jint jpegQual, jint flags)
221
+ {
222
+ tjhandle handle = 0;
223
+ unsigned long jpegSize = 0;
224
+ jsize arraySize = 0, actualPitch;
225
+ unsigned char *srcBuf = NULL, *jpegBuf = NULL;
226
+
227
+ GET_HANDLE();
228
+
229
+ if (pf < 0 || pf >= org_libjpegturbo_turbojpeg_TJ_NUMPF || width < 1 ||
230
+ height < 1 || pitch < 0)
231
+ THROW_ARG("Invalid argument in compress()");
232
+ if (org_libjpegturbo_turbojpeg_TJ_NUMPF != TJ_NUMPF)
233
+ THROW_ARG("Mismatch between Java and C API");
234
+
235
+ actualPitch = (pitch == 0) ? width * tjPixelSize[pf] : pitch;
236
+ arraySize = (y + height - 1) * actualPitch + (x + width) * tjPixelSize[pf];
237
+ if ((*env)->GetArrayLength(env, src) * srcElementSize < arraySize)
238
+ THROW_ARG("Source buffer is not large enough");
239
+ jpegSize = tjBufSize(width, height, jpegSubsamp);
240
+ if ((*env)->GetArrayLength(env, dst) < (jsize)jpegSize)
241
+ THROW_ARG("Destination buffer is not large enough");
242
+
243
+ if (ProcessSystemProperties(env) < 0) goto bailout;
244
+
245
+ BAILIF0(srcBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0));
246
+ BAILIF0(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0));
247
+
248
+ if (tjCompress2(handle, &srcBuf[y * actualPitch + x * tjPixelSize[pf]],
249
+ width, pitch, height, pf, &jpegBuf, &jpegSize, jpegSubsamp,
250
+ jpegQual, flags | TJFLAG_NOREALLOC) == -1) {
251
+ SAFE_RELEASE(dst, jpegBuf);
252
+ SAFE_RELEASE(src, srcBuf);
253
+ THROW_TJ();
254
+ }
255
+
256
+ bailout:
257
+ SAFE_RELEASE(dst, jpegBuf);
258
+ SAFE_RELEASE(src, srcBuf);
259
+ return (jint)jpegSize;
260
+ }
261
+
262
+ /* TurboJPEG 1.3.x: TJCompressor::compress() byte source */
263
+ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_compress___3BIIIIII_3BIII
264
+ (JNIEnv *env, jobject obj, jbyteArray src, jint x, jint y, jint width,
265
+ jint pitch, jint height, jint pf, jbyteArray dst, jint jpegSubsamp,
266
+ jint jpegQual, jint flags)
267
+ {
268
+ return TJCompressor_compress(env, obj, src, 1, x, y, width, pitch, height,
269
+ pf, dst, jpegSubsamp, jpegQual, flags);
270
+ }
271
+
272
+ /* TurboJPEG 1.2.x: TJCompressor::compress() byte source */
273
+ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_compress___3BIIII_3BIII
274
+ (JNIEnv *env, jobject obj, jbyteArray src, jint width, jint pitch,
275
+ jint height, jint pf, jbyteArray dst, jint jpegSubsamp, jint jpegQual,
276
+ jint flags)
277
+ {
278
+ return TJCompressor_compress(env, obj, src, 1, 0, 0, width, pitch, height,
279
+ pf, dst, jpegSubsamp, jpegQual, flags);
280
+ }
281
+
282
+ /* TurboJPEG 1.3.x: TJCompressor::compress() int source */
283
+ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_compress___3IIIIIII_3BIII
284
+ (JNIEnv *env, jobject obj, jintArray src, jint x, jint y, jint width,
285
+ jint stride, jint height, jint pf, jbyteArray dst, jint jpegSubsamp,
286
+ jint jpegQual, jint flags)
287
+ {
288
+ if (pf < 0 || pf >= org_libjpegturbo_turbojpeg_TJ_NUMPF)
289
+ THROW_ARG("Invalid argument in compress()");
290
+ if (tjPixelSize[pf] != sizeof(jint))
291
+ THROW_ARG("Pixel format must be 32-bit when compressing from an integer buffer.");
292
+
293
+ return TJCompressor_compress(env, obj, src, sizeof(jint), x, y, width,
294
+ stride * sizeof(jint), height, pf, dst,
295
+ jpegSubsamp, jpegQual, flags);
296
+
297
+ bailout:
298
+ return 0;
299
+ }
300
+
301
+ /* TurboJPEG 1.2.x: TJCompressor::compress() int source */
302
+ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_compress___3IIIII_3BIII
303
+ (JNIEnv *env, jobject obj, jintArray src, jint width, jint stride,
304
+ jint height, jint pf, jbyteArray dst, jint jpegSubsamp, jint jpegQual,
305
+ jint flags)
306
+ {
307
+ if (pf < 0 || pf >= org_libjpegturbo_turbojpeg_TJ_NUMPF)
308
+ THROW_ARG("Invalid argument in compress()");
309
+ if (tjPixelSize[pf] != sizeof(jint))
310
+ THROW_ARG("Pixel format must be 32-bit when compressing from an integer buffer.");
311
+
312
+ return TJCompressor_compress(env, obj, src, sizeof(jint), 0, 0, width,
313
+ stride * sizeof(jint), height, pf, dst,
314
+ jpegSubsamp, jpegQual, flags);
315
+
316
+ bailout:
317
+ return 0;
318
+ }
319
+
320
+ /* TurboJPEG 1.4.x: TJCompressor::compressFromYUV() */
321
+ JNIEXPORT jint JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_compressFromYUV___3_3B_3II_3III_3BII
322
+ (JNIEnv *env, jobject obj, jobjectArray srcobjs, jintArray jSrcOffsets,
323
+ jint width, jintArray jSrcStrides, jint height, jint subsamp,
324
+ jbyteArray dst, jint jpegQual, jint flags)
325
+ {
326
+ tjhandle handle = 0;
327
+ unsigned long jpegSize = 0;
328
+ jbyteArray jSrcPlanes[3] = { NULL, NULL, NULL };
329
+ const unsigned char *srcPlanes[3];
330
+ unsigned char *jpegBuf = NULL;
331
+ int *srcOffsets = NULL, *srcStrides = NULL;
332
+ int nc = (subsamp == org_libjpegturbo_turbojpeg_TJ_SAMP_GRAY ? 1 : 3), i;
333
+
334
+ GET_HANDLE();
335
+
336
+ if (subsamp < 0 || subsamp >= org_libjpegturbo_turbojpeg_TJ_NUMSAMP)
337
+ THROW_ARG("Invalid argument in compressFromYUV()");
338
+ if (org_libjpegturbo_turbojpeg_TJ_NUMSAMP != TJ_NUMSAMP)
339
+ THROW_ARG("Mismatch between Java and C API");
340
+
341
+ if ((*env)->GetArrayLength(env, srcobjs) < nc)
342
+ THROW_ARG("Planes array is too small for the subsampling type");
343
+ if ((*env)->GetArrayLength(env, jSrcOffsets) < nc)
344
+ THROW_ARG("Offsets array is too small for the subsampling type");
345
+ if ((*env)->GetArrayLength(env, jSrcStrides) < nc)
346
+ THROW_ARG("Strides array is too small for the subsampling type");
347
+
348
+ jpegSize = tjBufSize(width, height, subsamp);
349
+ if ((*env)->GetArrayLength(env, dst) < (jsize)jpegSize)
350
+ THROW_ARG("Destination buffer is not large enough");
351
+
352
+ if (ProcessSystemProperties(env) < 0) goto bailout;
353
+
354
+ #define RELEASE_ARRAYS_COMPRESSFROMYUV() { \
355
+ SAFE_RELEASE(dst, jpegBuf); \
356
+ for (i = 0; i < nc; i++) \
357
+ SAFE_RELEASE(jSrcPlanes[i], srcPlanes[i]); \
358
+ SAFE_RELEASE(jSrcStrides, srcStrides); \
359
+ SAFE_RELEASE(jSrcOffsets, srcOffsets); \
360
+ }
361
+
362
+ BAILIF0(srcOffsets = (*env)->GetPrimitiveArrayCritical(env, jSrcOffsets, 0));
363
+ BAILIF0(srcStrides = (*env)->GetPrimitiveArrayCritical(env, jSrcStrides, 0));
364
+ for (i = 0; i < nc; i++) {
365
+ int planeSize = tjPlaneSizeYUV(i, width, srcStrides[i], height, subsamp);
366
+ int pw = tjPlaneWidth(i, width, subsamp);
367
+
368
+ if (planeSize < 0 || pw < 0) {
369
+ RELEASE_ARRAYS_COMPRESSFROMYUV();
370
+ THROW_ARG(tjGetErrorStr());
371
+ }
372
+
373
+ if (srcOffsets[i] < 0) {
374
+ RELEASE_ARRAYS_COMPRESSFROMYUV();
375
+ THROW_ARG("Invalid argument in compressFromYUV()");
376
+ }
377
+ if (srcStrides[i] < 0 && srcOffsets[i] - planeSize + pw < 0) {
378
+ RELEASE_ARRAYS_COMPRESSFROMYUV();
379
+ THROW_ARG("Negative plane stride would cause memory to be accessed below plane boundary");
380
+ }
381
+
382
+ BAILIF0(jSrcPlanes[i] = (*env)->GetObjectArrayElement(env, srcobjs, i));
383
+ if ((*env)->GetArrayLength(env, jSrcPlanes[i]) <
384
+ srcOffsets[i] + planeSize) {
385
+ RELEASE_ARRAYS_COMPRESSFROMYUV();
386
+ THROW_ARG("Source plane is not large enough");
387
+ }
388
+
389
+ BAILIF0(srcPlanes[i] =
390
+ (*env)->GetPrimitiveArrayCritical(env, jSrcPlanes[i], 0));
391
+ srcPlanes[i] = &srcPlanes[i][srcOffsets[i]];
392
+ }
393
+ BAILIF0(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0));
394
+
395
+ if (tjCompressFromYUVPlanes(handle, srcPlanes, width, srcStrides, height,
396
+ subsamp, &jpegBuf, &jpegSize, jpegQual,
397
+ flags | TJFLAG_NOREALLOC) == -1) {
398
+ RELEASE_ARRAYS_COMPRESSFROMYUV();
399
+ THROW_TJ();
400
+ }
401
+
402
+ bailout:
403
+ RELEASE_ARRAYS_COMPRESSFROMYUV();
404
+ return (jint)jpegSize;
405
+ }
406
+
407
+ static void TJCompressor_encodeYUV
408
+ (JNIEnv *env, jobject obj, jarray src, jint srcElementSize, jint x, jint y,
409
+ jint width, jint pitch, jint height, jint pf, jobjectArray dstobjs,
410
+ jintArray jDstOffsets, jintArray jDstStrides, jint subsamp, jint flags)
411
+ {
412
+ tjhandle handle = 0;
413
+ jsize arraySize = 0, actualPitch;
414
+ jbyteArray jDstPlanes[3] = { NULL, NULL, NULL };
415
+ unsigned char *srcBuf = NULL, *dstPlanes[3];
416
+ int *dstOffsets = NULL, *dstStrides = NULL;
417
+ int nc = (subsamp == org_libjpegturbo_turbojpeg_TJ_SAMP_GRAY ? 1 : 3), i;
418
+
419
+ GET_HANDLE();
420
+
421
+ if (pf < 0 || pf >= org_libjpegturbo_turbojpeg_TJ_NUMPF || width < 1 ||
422
+ height < 1 || pitch < 0 || subsamp < 0 ||
423
+ subsamp >= org_libjpegturbo_turbojpeg_TJ_NUMSAMP)
424
+ THROW_ARG("Invalid argument in encodeYUV()");
425
+ if (org_libjpegturbo_turbojpeg_TJ_NUMPF != TJ_NUMPF ||
426
+ org_libjpegturbo_turbojpeg_TJ_NUMSAMP != TJ_NUMSAMP)
427
+ THROW_ARG("Mismatch between Java and C API");
428
+
429
+ if ((*env)->GetArrayLength(env, dstobjs) < nc)
430
+ THROW_ARG("Planes array is too small for the subsampling type");
431
+ if ((*env)->GetArrayLength(env, jDstOffsets) < nc)
432
+ THROW_ARG("Offsets array is too small for the subsampling type");
433
+ if ((*env)->GetArrayLength(env, jDstStrides) < nc)
434
+ THROW_ARG("Strides array is too small for the subsampling type");
435
+
436
+ actualPitch = (pitch == 0) ? width * tjPixelSize[pf] : pitch;
437
+ arraySize = (y + height - 1) * actualPitch + (x + width) * tjPixelSize[pf];
438
+ if ((*env)->GetArrayLength(env, src) * srcElementSize < arraySize)
439
+ THROW_ARG("Source buffer is not large enough");
440
+
441
+ #define RELEASE_ARRAYS_ENCODEYUV() { \
442
+ SAFE_RELEASE(src, srcBuf); \
443
+ for (i = 0; i < nc; i++) \
444
+ SAFE_RELEASE(jDstPlanes[i], dstPlanes[i]); \
445
+ SAFE_RELEASE(jDstStrides, dstStrides); \
446
+ SAFE_RELEASE(jDstOffsets, dstOffsets); \
447
+ }
448
+
449
+ BAILIF0(dstOffsets = (*env)->GetPrimitiveArrayCritical(env, jDstOffsets, 0));
450
+ BAILIF0(dstStrides = (*env)->GetPrimitiveArrayCritical(env, jDstStrides, 0));
451
+ for (i = 0; i < nc; i++) {
452
+ int planeSize = tjPlaneSizeYUV(i, width, dstStrides[i], height, subsamp);
453
+ int pw = tjPlaneWidth(i, width, subsamp);
454
+
455
+ if (planeSize < 0 || pw < 0) {
456
+ RELEASE_ARRAYS_ENCODEYUV();
457
+ THROW_ARG(tjGetErrorStr());
458
+ }
459
+
460
+ if (dstOffsets[i] < 0) {
461
+ RELEASE_ARRAYS_ENCODEYUV();
462
+ THROW_ARG("Invalid argument in encodeYUV()");
463
+ }
464
+ if (dstStrides[i] < 0 && dstOffsets[i] - planeSize + pw < 0) {
465
+ RELEASE_ARRAYS_ENCODEYUV();
466
+ THROW_ARG("Negative plane stride would cause memory to be accessed below plane boundary");
467
+ }
468
+
469
+ BAILIF0(jDstPlanes[i] = (*env)->GetObjectArrayElement(env, dstobjs, i));
470
+ if ((*env)->GetArrayLength(env, jDstPlanes[i]) <
471
+ dstOffsets[i] + planeSize) {
472
+ RELEASE_ARRAYS_ENCODEYUV();
473
+ THROW_ARG("Destination plane is not large enough");
474
+ }
475
+
476
+ BAILIF0(dstPlanes[i] =
477
+ (*env)->GetPrimitiveArrayCritical(env, jDstPlanes[i], 0));
478
+ dstPlanes[i] = &dstPlanes[i][dstOffsets[i]];
479
+ }
480
+ BAILIF0(srcBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0));
481
+
482
+ if (tjEncodeYUVPlanes(handle, &srcBuf[y * actualPitch + x * tjPixelSize[pf]],
483
+ width, pitch, height, pf, dstPlanes, dstStrides,
484
+ subsamp, flags) == -1) {
485
+ RELEASE_ARRAYS_ENCODEYUV();
486
+ THROW_TJ();
487
+ }
488
+
489
+ bailout:
490
+ RELEASE_ARRAYS_ENCODEYUV();
491
+ }
492
+
493
+ /* TurboJPEG 1.4.x: TJCompressor::encodeYUV() byte source */
494
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIIIII_3_3B_3I_3III
495
+ (JNIEnv *env, jobject obj, jbyteArray src, jint x, jint y, jint width,
496
+ jint pitch, jint height, jint pf, jobjectArray dstobjs,
497
+ jintArray jDstOffsets, jintArray jDstStrides, jint subsamp, jint flags)
498
+ {
499
+ TJCompressor_encodeYUV(env, obj, src, 1, x, y, width, pitch, height, pf,
500
+ dstobjs, jDstOffsets, jDstStrides, subsamp, flags);
501
+ }
502
+
503
+ /* TurboJPEG 1.4.x: TJCompressor::encodeYUV() int source */
504
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIIIII_3_3B_3I_3III
505
+ (JNIEnv *env, jobject obj, jintArray src, jint x, jint y, jint width,
506
+ jint stride, jint height, jint pf, jobjectArray dstobjs,
507
+ jintArray jDstOffsets, jintArray jDstStrides, jint subsamp, jint flags)
508
+ {
509
+ if (pf < 0 || pf >= org_libjpegturbo_turbojpeg_TJ_NUMPF)
510
+ THROW_ARG("Invalid argument in encodeYUV()");
511
+ if (tjPixelSize[pf] != sizeof(jint))
512
+ THROW_ARG("Pixel format must be 32-bit when encoding from an integer buffer.");
513
+
514
+ TJCompressor_encodeYUV(env, obj, src, sizeof(jint), x, y, width,
515
+ stride * sizeof(jint), height, pf, dstobjs,
516
+ jDstOffsets, jDstStrides, subsamp, flags);
517
+
518
+ bailout:
519
+ return;
520
+ }
521
+
522
+ static void JNICALL TJCompressor_encodeYUV_12
523
+ (JNIEnv *env, jobject obj, jarray src, jint srcElementSize, jint width,
524
+ jint pitch, jint height, jint pf, jbyteArray dst, jint subsamp, jint flags)
525
+ {
526
+ tjhandle handle = 0;
527
+ jsize arraySize = 0;
528
+ unsigned char *srcBuf = NULL, *dstBuf = NULL;
529
+
530
+ GET_HANDLE();
531
+
532
+ if (pf < 0 || pf >= org_libjpegturbo_turbojpeg_TJ_NUMPF || width < 1 ||
533
+ height < 1 || pitch < 0)
534
+ THROW_ARG("Invalid argument in encodeYUV()");
535
+ if (org_libjpegturbo_turbojpeg_TJ_NUMPF != TJ_NUMPF)
536
+ THROW_ARG("Mismatch between Java and C API");
537
+
538
+ arraySize = (pitch == 0) ? width * tjPixelSize[pf] * height : pitch * height;
539
+ if ((*env)->GetArrayLength(env, src) * srcElementSize < arraySize)
540
+ THROW_ARG("Source buffer is not large enough");
541
+ if ((*env)->GetArrayLength(env, dst) <
542
+ (jsize)tjBufSizeYUV(width, height, subsamp))
543
+ THROW_ARG("Destination buffer is not large enough");
544
+
545
+ BAILIF0(srcBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0));
546
+ BAILIF0(dstBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0));
547
+
548
+ if (tjEncodeYUV2(handle, srcBuf, width, pitch, height, pf, dstBuf, subsamp,
549
+ flags) == -1) {
550
+ SAFE_RELEASE(dst, dstBuf);
551
+ SAFE_RELEASE(src, srcBuf);
552
+ THROW_TJ();
553
+ }
554
+
555
+ bailout:
556
+ SAFE_RELEASE(dst, dstBuf);
557
+ SAFE_RELEASE(src, srcBuf);
558
+ }
559
+
560
+ /* TurboJPEG 1.2.x: TJCompressor::encodeYUV() byte source */
561
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3BIIII_3BII
562
+ (JNIEnv *env, jobject obj, jbyteArray src, jint width, jint pitch,
563
+ jint height, jint pf, jbyteArray dst, jint subsamp, jint flags)
564
+ {
565
+ TJCompressor_encodeYUV_12(env, obj, src, 1, width, pitch, height, pf, dst,
566
+ subsamp, flags);
567
+ }
568
+
569
+ /* TurboJPEG 1.2.x: TJCompressor::encodeYUV() int source */
570
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_encodeYUV___3IIIII_3BII
571
+ (JNIEnv *env, jobject obj, jintArray src, jint width, jint stride,
572
+ jint height, jint pf, jbyteArray dst, jint subsamp, jint flags)
573
+ {
574
+ if (pf < 0 || pf >= org_libjpegturbo_turbojpeg_TJ_NUMPF)
575
+ THROW_ARG("Invalid argument in encodeYUV()");
576
+ if (tjPixelSize[pf] != sizeof(jint))
577
+ THROW_ARG("Pixel format must be 32-bit when encoding from an integer buffer.");
578
+
579
+ TJCompressor_encodeYUV_12(env, obj, src, sizeof(jint), width,
580
+ stride * sizeof(jint), height, pf, dst, subsamp,
581
+ flags);
582
+
583
+ bailout:
584
+ return;
585
+ }
586
+
587
+ /* TurboJPEG 1.2.x: TJCompressor::destroy() */
588
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJCompressor_destroy
589
+ (JNIEnv *env, jobject obj)
590
+ {
591
+ tjhandle handle = 0;
592
+
593
+ GET_HANDLE();
594
+
595
+ if (tjDestroy(handle) == -1) THROW_TJ();
596
+ (*env)->SetLongField(env, obj, _fid, 0);
597
+
598
+ bailout:
599
+ return;
600
+ }
601
+
602
+ /* TurboJPEG 1.2.x: TJDecompressor::init() */
603
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_init
604
+ (JNIEnv *env, jobject obj)
605
+ {
606
+ jclass cls;
607
+ jfieldID fid;
608
+ tjhandle handle;
609
+
610
+ if ((handle = tjInitDecompress()) == NULL)
611
+ THROW(tjGetErrorStr(), "org/libjpegturbo/turbojpeg/TJException");
612
+
613
+ BAILIF0(cls = (*env)->GetObjectClass(env, obj));
614
+ BAILIF0(fid = (*env)->GetFieldID(env, cls, "handle", "J"));
615
+ (*env)->SetLongField(env, obj, fid, (size_t)handle);
616
+
617
+ bailout:
618
+ return;
619
+ }
620
+
621
+ /* TurboJPEG 1.2.x: TJDecompressor::getScalingFactors() */
622
+ JNIEXPORT jobjectArray JNICALL Java_org_libjpegturbo_turbojpeg_TJ_getScalingFactors
623
+ (JNIEnv *env, jclass cls)
624
+ {
625
+ jclass sfcls = NULL;
626
+ jfieldID fid = 0;
627
+ tjscalingfactor *sf = NULL;
628
+ int n = 0, i;
629
+ jobject sfobj = NULL;
630
+ jobjectArray sfjava = NULL;
631
+
632
+ if ((sf = tjGetScalingFactors(&n)) == NULL || n == 0)
633
+ THROW_ARG(tjGetErrorStr());
634
+
635
+ BAILIF0(sfcls = (*env)->FindClass(env,
636
+ "org/libjpegturbo/turbojpeg/TJScalingFactor"));
637
+ BAILIF0(sfjava = (jobjectArray)(*env)->NewObjectArray(env, n, sfcls, 0));
638
+
639
+ for (i = 0; i < n; i++) {
640
+ BAILIF0(sfobj = (*env)->AllocObject(env, sfcls));
641
+ BAILIF0(fid = (*env)->GetFieldID(env, sfcls, "num", "I"));
642
+ (*env)->SetIntField(env, sfobj, fid, sf[i].num);
643
+ BAILIF0(fid = (*env)->GetFieldID(env, sfcls, "denom", "I"));
644
+ (*env)->SetIntField(env, sfobj, fid, sf[i].denom);
645
+ (*env)->SetObjectArrayElement(env, sfjava, i, sfobj);
646
+ }
647
+
648
+ bailout:
649
+ return sfjava;
650
+ }
651
+
652
+ /* TurboJPEG 1.2.x: TJDecompressor::decompressHeader() */
653
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressHeader
654
+ (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize)
655
+ {
656
+ tjhandle handle = 0;
657
+ unsigned char *jpegBuf = NULL;
658
+ int width = 0, height = 0, jpegSubsamp = -1, jpegColorspace = -1;
659
+
660
+ GET_HANDLE();
661
+
662
+ if ((*env)->GetArrayLength(env, src) < jpegSize)
663
+ THROW_ARG("Source buffer is not large enough");
664
+
665
+ BAILIF0(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0));
666
+
667
+ if (tjDecompressHeader3(handle, jpegBuf, (unsigned long)jpegSize, &width,
668
+ &height, &jpegSubsamp, &jpegColorspace) == -1) {
669
+ SAFE_RELEASE(src, jpegBuf);
670
+ THROW_TJ();
671
+ }
672
+
673
+ SAFE_RELEASE(src, jpegBuf);
674
+
675
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "jpegSubsamp", "I"));
676
+ (*env)->SetIntField(env, obj, _fid, jpegSubsamp);
677
+ if ((_fid = (*env)->GetFieldID(env, _cls, "jpegColorspace", "I")) == 0)
678
+ (*env)->ExceptionClear(env);
679
+ else
680
+ (*env)->SetIntField(env, obj, _fid, jpegColorspace);
681
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "jpegWidth", "I"));
682
+ (*env)->SetIntField(env, obj, _fid, width);
683
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "jpegHeight", "I"));
684
+ (*env)->SetIntField(env, obj, _fid, height);
685
+
686
+ bailout:
687
+ SAFE_RELEASE(src, jpegBuf);
688
+ }
689
+
690
+ static void TJDecompressor_decompress
691
+ (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jarray dst,
692
+ jint dstElementSize, jint x, jint y, jint width, jint pitch, jint height,
693
+ jint pf, jint flags)
694
+ {
695
+ tjhandle handle = 0;
696
+ jsize arraySize = 0, actualPitch;
697
+ unsigned char *jpegBuf = NULL, *dstBuf = NULL;
698
+
699
+ GET_HANDLE();
700
+
701
+ if (pf < 0 || pf >= org_libjpegturbo_turbojpeg_TJ_NUMPF)
702
+ THROW_ARG("Invalid argument in decompress()");
703
+ if (org_libjpegturbo_turbojpeg_TJ_NUMPF != TJ_NUMPF)
704
+ THROW_ARG("Mismatch between Java and C API");
705
+
706
+ if ((*env)->GetArrayLength(env, src) < jpegSize)
707
+ THROW_ARG("Source buffer is not large enough");
708
+ actualPitch = (pitch == 0) ? width * tjPixelSize[pf] : pitch;
709
+ arraySize = (y + height - 1) * actualPitch + (x + width) * tjPixelSize[pf];
710
+ if ((*env)->GetArrayLength(env, dst) * dstElementSize < arraySize)
711
+ THROW_ARG("Destination buffer is not large enough");
712
+
713
+ BAILIF0(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0));
714
+ BAILIF0(dstBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0));
715
+
716
+ if (tjDecompress2(handle, jpegBuf, (unsigned long)jpegSize,
717
+ &dstBuf[y * actualPitch + x * tjPixelSize[pf]], width,
718
+ pitch, height, pf, flags) == -1) {
719
+ SAFE_RELEASE(dst, dstBuf);
720
+ SAFE_RELEASE(src, jpegBuf);
721
+ THROW_TJ();
722
+ }
723
+
724
+ bailout:
725
+ SAFE_RELEASE(dst, dstBuf);
726
+ SAFE_RELEASE(src, jpegBuf);
727
+ }
728
+
729
+ /* TurboJPEG 1.3.x: TJDecompressor::decompress() byte destination */
730
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3BIIIIIII
731
+ (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jbyteArray dst,
732
+ jint x, jint y, jint width, jint pitch, jint height, jint pf, jint flags)
733
+ {
734
+ TJDecompressor_decompress(env, obj, src, jpegSize, dst, 1, x, y, width,
735
+ pitch, height, pf, flags);
736
+ }
737
+
738
+ /* TurboJPEG 1.2.x: TJDecompressor::decompress() byte destination */
739
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3BIIIII
740
+ (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jbyteArray dst,
741
+ jint width, jint pitch, jint height, jint pf, jint flags)
742
+ {
743
+ TJDecompressor_decompress(env, obj, src, jpegSize, dst, 1, 0, 0, width,
744
+ pitch, height, pf, flags);
745
+ }
746
+
747
+ /* TurboJPEG 1.3.x: TJDecompressor::decompress() int destination */
748
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIIIII
749
+ (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jintArray dst,
750
+ jint x, jint y, jint width, jint stride, jint height, jint pf, jint flags)
751
+ {
752
+ if (pf < 0 || pf >= org_libjpegturbo_turbojpeg_TJ_NUMPF)
753
+ THROW_ARG("Invalid argument in decompress()");
754
+ if (tjPixelSize[pf] != sizeof(jint))
755
+ THROW_ARG("Pixel format must be 32-bit when decompressing to an integer buffer.");
756
+
757
+ TJDecompressor_decompress(env, obj, src, jpegSize, dst, sizeof(jint), x, y,
758
+ width, stride * sizeof(jint), height, pf, flags);
759
+
760
+ bailout:
761
+ return;
762
+ }
763
+
764
+ /* TurboJPEG 1.2.x: TJDecompressor::decompress() int destination */
765
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompress___3BI_3IIIIII
766
+ (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jintArray dst,
767
+ jint width, jint stride, jint height, jint pf, jint flags)
768
+ {
769
+ if (pf < 0 || pf >= org_libjpegturbo_turbojpeg_TJ_NUMPF)
770
+ THROW_ARG("Invalid argument in decompress()");
771
+ if (tjPixelSize[pf] != sizeof(jint))
772
+ THROW_ARG("Pixel format must be 32-bit when decompressing to an integer buffer.");
773
+
774
+ TJDecompressor_decompress(env, obj, src, jpegSize, dst, sizeof(jint), 0, 0,
775
+ width, stride * sizeof(jint), height, pf, flags);
776
+
777
+ bailout:
778
+ return;
779
+ }
780
+
781
+ /* TurboJPEG 1.4.x: TJDecompressor::decompressToYUV() */
782
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV___3BI_3_3B_3II_3III
783
+ (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize,
784
+ jobjectArray dstobjs, jintArray jDstOffsets, jint desiredWidth,
785
+ jintArray jDstStrides, jint desiredHeight, jint flags)
786
+ {
787
+ tjhandle handle = 0;
788
+ jbyteArray jDstPlanes[3] = { NULL, NULL, NULL };
789
+ unsigned char *jpegBuf = NULL, *dstPlanes[3];
790
+ int *dstOffsets = NULL, *dstStrides = NULL;
791
+ int jpegSubsamp = -1, jpegWidth = 0, jpegHeight = 0;
792
+ int nc = 0, i, width, height, scaledWidth, scaledHeight, nsf = 0;
793
+ tjscalingfactor *sf;
794
+
795
+ GET_HANDLE();
796
+
797
+ if ((*env)->GetArrayLength(env, src) < jpegSize)
798
+ THROW_ARG("Source buffer is not large enough");
799
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "jpegSubsamp", "I"));
800
+ jpegSubsamp = (int)(*env)->GetIntField(env, obj, _fid);
801
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "jpegWidth", "I"));
802
+ jpegWidth = (int)(*env)->GetIntField(env, obj, _fid);
803
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "jpegHeight", "I"));
804
+ jpegHeight = (int)(*env)->GetIntField(env, obj, _fid);
805
+
806
+ nc = (jpegSubsamp == org_libjpegturbo_turbojpeg_TJ_SAMP_GRAY ? 1 : 3);
807
+
808
+ width = desiredWidth;
809
+ height = desiredHeight;
810
+ if (width == 0) width = jpegWidth;
811
+ if (height == 0) height = jpegHeight;
812
+ sf = tjGetScalingFactors(&nsf);
813
+ if (!sf || nsf < 1)
814
+ THROW_ARG(tjGetErrorStr());
815
+ for (i = 0; i < nsf; i++) {
816
+ scaledWidth = TJSCALED(jpegWidth, sf[i]);
817
+ scaledHeight = TJSCALED(jpegHeight, sf[i]);
818
+ if (scaledWidth <= width && scaledHeight <= height)
819
+ break;
820
+ }
821
+ if (i >= nsf)
822
+ THROW_ARG("Could not scale down to desired image dimensions");
823
+
824
+ #define RELEASE_ARRAYS_DECOMPRESSTOYUV() { \
825
+ SAFE_RELEASE(src, jpegBuf); \
826
+ for (i = 0; i < nc; i++) \
827
+ SAFE_RELEASE(jDstPlanes[i], dstPlanes[i]); \
828
+ SAFE_RELEASE(jDstStrides, dstStrides); \
829
+ SAFE_RELEASE(jDstOffsets, dstOffsets); \
830
+ }
831
+
832
+ BAILIF0(dstOffsets = (*env)->GetPrimitiveArrayCritical(env, jDstOffsets, 0));
833
+ BAILIF0(dstStrides = (*env)->GetPrimitiveArrayCritical(env, jDstStrides, 0));
834
+ for (i = 0; i < nc; i++) {
835
+ int planeSize = tjPlaneSizeYUV(i, scaledWidth, dstStrides[i], scaledHeight,
836
+ jpegSubsamp);
837
+ int pw = tjPlaneWidth(i, scaledWidth, jpegSubsamp);
838
+
839
+ if (planeSize < 0 || pw < 0) {
840
+ RELEASE_ARRAYS_DECOMPRESSTOYUV();
841
+ THROW_ARG(tjGetErrorStr());
842
+ }
843
+
844
+ if (dstOffsets[i] < 0) {
845
+ RELEASE_ARRAYS_DECOMPRESSTOYUV();
846
+ THROW_ARG("Invalid argument in decompressToYUV()");
847
+ }
848
+ if (dstStrides[i] < 0 && dstOffsets[i] - planeSize + pw < 0) {
849
+ RELEASE_ARRAYS_DECOMPRESSTOYUV();
850
+ THROW_ARG("Negative plane stride would cause memory to be accessed below plane boundary");
851
+ }
852
+
853
+ BAILIF0(jDstPlanes[i] = (*env)->GetObjectArrayElement(env, dstobjs, i));
854
+ if ((*env)->GetArrayLength(env, jDstPlanes[i]) <
855
+ dstOffsets[i] + planeSize) {
856
+ RELEASE_ARRAYS_DECOMPRESSTOYUV();
857
+ THROW_ARG("Destination plane is not large enough");
858
+ }
859
+
860
+ BAILIF0(dstPlanes[i] =
861
+ (*env)->GetPrimitiveArrayCritical(env, jDstPlanes[i], 0));
862
+ dstPlanes[i] = &dstPlanes[i][dstOffsets[i]];
863
+ }
864
+ BAILIF0(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0));
865
+
866
+ if (tjDecompressToYUVPlanes(handle, jpegBuf, (unsigned long)jpegSize,
867
+ dstPlanes, desiredWidth, dstStrides,
868
+ desiredHeight, flags) == -1) {
869
+ RELEASE_ARRAYS_DECOMPRESSTOYUV();
870
+ THROW_TJ();
871
+ }
872
+
873
+ bailout:
874
+ RELEASE_ARRAYS_DECOMPRESSTOYUV();
875
+ }
876
+
877
+ /* TurboJPEG 1.2.x: TJDecompressor::decompressToYUV() */
878
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decompressToYUV___3BI_3BI
879
+ (JNIEnv *env, jobject obj, jbyteArray src, jint jpegSize, jbyteArray dst,
880
+ jint flags)
881
+ {
882
+ tjhandle handle = 0;
883
+ unsigned char *jpegBuf = NULL, *dstBuf = NULL;
884
+ int jpegSubsamp = -1, jpegWidth = 0, jpegHeight = 0;
885
+
886
+ GET_HANDLE();
887
+
888
+ if ((*env)->GetArrayLength(env, src) < jpegSize)
889
+ THROW_ARG("Source buffer is not large enough");
890
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "jpegSubsamp", "I"));
891
+ jpegSubsamp = (int)(*env)->GetIntField(env, obj, _fid);
892
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "jpegWidth", "I"));
893
+ jpegWidth = (int)(*env)->GetIntField(env, obj, _fid);
894
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "jpegHeight", "I"));
895
+ jpegHeight = (int)(*env)->GetIntField(env, obj, _fid);
896
+ if ((*env)->GetArrayLength(env, dst) <
897
+ (jsize)tjBufSizeYUV(jpegWidth, jpegHeight, jpegSubsamp))
898
+ THROW_ARG("Destination buffer is not large enough");
899
+
900
+ BAILIF0(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, src, 0));
901
+ BAILIF0(dstBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0));
902
+
903
+ if (tjDecompressToYUV(handle, jpegBuf, (unsigned long)jpegSize, dstBuf,
904
+ flags) == -1) {
905
+ SAFE_RELEASE(dst, dstBuf);
906
+ SAFE_RELEASE(src, jpegBuf);
907
+ THROW_TJ();
908
+ }
909
+
910
+ bailout:
911
+ SAFE_RELEASE(dst, dstBuf);
912
+ SAFE_RELEASE(src, jpegBuf);
913
+ }
914
+
915
+ static void TJDecompressor_decodeYUV
916
+ (JNIEnv *env, jobject obj, jobjectArray srcobjs, jintArray jSrcOffsets,
917
+ jintArray jSrcStrides, jint subsamp, jarray dst, jint dstElementSize,
918
+ jint x, jint y, jint width, jint pitch, jint height, jint pf, jint flags)
919
+ {
920
+ tjhandle handle = 0;
921
+ jsize arraySize = 0, actualPitch;
922
+ jbyteArray jSrcPlanes[3] = { NULL, NULL, NULL };
923
+ const unsigned char *srcPlanes[3];
924
+ unsigned char *dstBuf = NULL;
925
+ int *srcOffsets = NULL, *srcStrides = NULL;
926
+ int nc = (subsamp == org_libjpegturbo_turbojpeg_TJ_SAMP_GRAY ? 1 : 3), i;
927
+
928
+ GET_HANDLE();
929
+
930
+ if (pf < 0 || pf >= org_libjpegturbo_turbojpeg_TJ_NUMPF || subsamp < 0 ||
931
+ subsamp >= org_libjpegturbo_turbojpeg_TJ_NUMSAMP)
932
+ THROW_ARG("Invalid argument in decodeYUV()");
933
+ if (org_libjpegturbo_turbojpeg_TJ_NUMPF != TJ_NUMPF ||
934
+ org_libjpegturbo_turbojpeg_TJ_NUMSAMP != TJ_NUMSAMP)
935
+ THROW_ARG("Mismatch between Java and C API");
936
+
937
+ if ((*env)->GetArrayLength(env, srcobjs) < nc)
938
+ THROW_ARG("Planes array is too small for the subsampling type");
939
+ if ((*env)->GetArrayLength(env, jSrcOffsets) < nc)
940
+ THROW_ARG("Offsets array is too small for the subsampling type");
941
+ if ((*env)->GetArrayLength(env, jSrcStrides) < nc)
942
+ THROW_ARG("Strides array is too small for the subsampling type");
943
+
944
+ actualPitch = (pitch == 0) ? width * tjPixelSize[pf] : pitch;
945
+ arraySize = (y + height - 1) * actualPitch + (x + width) * tjPixelSize[pf];
946
+ if ((*env)->GetArrayLength(env, dst) * dstElementSize < arraySize)
947
+ THROW_ARG("Destination buffer is not large enough");
948
+
949
+ #define RELEASE_ARRAYS_DECODEYUV() { \
950
+ SAFE_RELEASE(dst, dstBuf); \
951
+ for (i = 0; i < nc; i++) \
952
+ SAFE_RELEASE(jSrcPlanes[i], srcPlanes[i]); \
953
+ SAFE_RELEASE(jSrcStrides, srcStrides); \
954
+ SAFE_RELEASE(jSrcOffsets, srcOffsets); \
955
+ }
956
+
957
+ BAILIF0(srcOffsets = (*env)->GetPrimitiveArrayCritical(env, jSrcOffsets, 0));
958
+ BAILIF0(srcStrides = (*env)->GetPrimitiveArrayCritical(env, jSrcStrides, 0));
959
+ for (i = 0; i < nc; i++) {
960
+ int planeSize = tjPlaneSizeYUV(i, width, srcStrides[i], height, subsamp);
961
+ int pw = tjPlaneWidth(i, width, subsamp);
962
+
963
+ if (planeSize < 0 || pw < 0) {
964
+ RELEASE_ARRAYS_DECODEYUV();
965
+ THROW_ARG(tjGetErrorStr());
966
+ }
967
+
968
+ if (srcOffsets[i] < 0) {
969
+ RELEASE_ARRAYS_DECODEYUV();
970
+ THROW_ARG("Invalid argument in decodeYUV()");
971
+ }
972
+ if (srcStrides[i] < 0 && srcOffsets[i] - planeSize + pw < 0) {
973
+ RELEASE_ARRAYS_DECODEYUV();
974
+ THROW_ARG("Negative plane stride would cause memory to be accessed below plane boundary");
975
+ }
976
+
977
+ BAILIF0(jSrcPlanes[i] = (*env)->GetObjectArrayElement(env, srcobjs, i));
978
+ if ((*env)->GetArrayLength(env, jSrcPlanes[i]) <
979
+ srcOffsets[i] + planeSize) {
980
+ RELEASE_ARRAYS_DECODEYUV();
981
+ THROW_ARG("Source plane is not large enough");
982
+ }
983
+
984
+ BAILIF0(srcPlanes[i] =
985
+ (*env)->GetPrimitiveArrayCritical(env, jSrcPlanes[i], 0));
986
+ srcPlanes[i] = &srcPlanes[i][srcOffsets[i]];
987
+ }
988
+ BAILIF0(dstBuf = (*env)->GetPrimitiveArrayCritical(env, dst, 0));
989
+
990
+ if (tjDecodeYUVPlanes(handle, srcPlanes, srcStrides, subsamp,
991
+ &dstBuf[y * actualPitch + x * tjPixelSize[pf]], width,
992
+ pitch, height, pf, flags) == -1) {
993
+ RELEASE_ARRAYS_DECODEYUV();
994
+ THROW_TJ();
995
+ }
996
+
997
+ bailout:
998
+ RELEASE_ARRAYS_DECODEYUV();
999
+ }
1000
+
1001
+ /* TurboJPEG 1.4.x: TJDecompressor::decodeYUV() byte destination */
1002
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decodeYUV___3_3B_3I_3II_3BIIIIIII
1003
+ (JNIEnv *env, jobject obj, jobjectArray srcobjs, jintArray jSrcOffsets,
1004
+ jintArray jSrcStrides, jint subsamp, jbyteArray dst, jint x, jint y,
1005
+ jint width, jint pitch, jint height, jint pf, jint flags)
1006
+ {
1007
+ TJDecompressor_decodeYUV(env, obj, srcobjs, jSrcOffsets, jSrcStrides,
1008
+ subsamp, dst, 1, x, y, width, pitch, height, pf,
1009
+ flags);
1010
+ }
1011
+
1012
+ /* TurboJPEG 1.4.x: TJDecompressor::decodeYUV() int destination */
1013
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_decodeYUV___3_3B_3I_3II_3IIIIIIII
1014
+ (JNIEnv *env, jobject obj, jobjectArray srcobjs, jintArray jSrcOffsets,
1015
+ jintArray jSrcStrides, jint subsamp, jintArray dst, jint x, jint y,
1016
+ jint width, jint stride, jint height, jint pf, jint flags)
1017
+ {
1018
+ if (pf < 0 || pf >= org_libjpegturbo_turbojpeg_TJ_NUMPF)
1019
+ THROW_ARG("Invalid argument in decodeYUV()");
1020
+ if (tjPixelSize[pf] != sizeof(jint))
1021
+ THROW_ARG("Pixel format must be 32-bit when decoding to an integer buffer.");
1022
+
1023
+ TJDecompressor_decodeYUV(env, obj, srcobjs, jSrcOffsets, jSrcStrides,
1024
+ subsamp, dst, sizeof(jint), x, y, width,
1025
+ stride * sizeof(jint), height, pf, flags);
1026
+
1027
+ bailout:
1028
+ return;
1029
+ }
1030
+
1031
+ /* TurboJPEG 1.2.x: TJTransformer::init() */
1032
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJTransformer_init
1033
+ (JNIEnv *env, jobject obj)
1034
+ {
1035
+ jclass cls;
1036
+ jfieldID fid;
1037
+ tjhandle handle;
1038
+
1039
+ if ((handle = tjInitTransform()) == NULL)
1040
+ THROW(tjGetErrorStr(), "org/libjpegturbo/turbojpeg/TJException");
1041
+
1042
+ BAILIF0(cls = (*env)->GetObjectClass(env, obj));
1043
+ BAILIF0(fid = (*env)->GetFieldID(env, cls, "handle", "J"));
1044
+ (*env)->SetLongField(env, obj, fid, (size_t)handle);
1045
+
1046
+ bailout:
1047
+ return;
1048
+ }
1049
+
1050
+ typedef struct _JNICustomFilterParams {
1051
+ JNIEnv *env;
1052
+ jobject tobj;
1053
+ jobject cfobj;
1054
+ } JNICustomFilterParams;
1055
+
1056
+ static int JNICustomFilter(short *coeffs, tjregion arrayRegion,
1057
+ tjregion planeRegion, int componentIndex,
1058
+ int transformIndex, tjtransform *transform)
1059
+ {
1060
+ JNICustomFilterParams *params = (JNICustomFilterParams *)transform->data;
1061
+ JNIEnv *env = params->env;
1062
+ jobject tobj = params->tobj, cfobj = params->cfobj;
1063
+ jobject arrayRegionObj, planeRegionObj, bufobj, borobj;
1064
+ jclass cls;
1065
+ jmethodID mid;
1066
+ jfieldID fid;
1067
+
1068
+ BAILIF0(bufobj = (*env)->NewDirectByteBuffer(env, coeffs,
1069
+ sizeof(short) * arrayRegion.w * arrayRegion.h));
1070
+ BAILIF0(cls = (*env)->FindClass(env, "java/nio/ByteOrder"));
1071
+ BAILIF0(mid = (*env)->GetStaticMethodID(env, cls, "nativeOrder",
1072
+ "()Ljava/nio/ByteOrder;"));
1073
+ BAILIF0(borobj = (*env)->CallStaticObjectMethod(env, cls, mid));
1074
+ BAILIF0(cls = (*env)->GetObjectClass(env, bufobj));
1075
+ BAILIF0(mid = (*env)->GetMethodID(env, cls, "order",
1076
+ "(Ljava/nio/ByteOrder;)Ljava/nio/ByteBuffer;"));
1077
+ (*env)->CallObjectMethod(env, bufobj, mid, borobj);
1078
+ BAILIF0(mid = (*env)->GetMethodID(env, cls, "asShortBuffer",
1079
+ "()Ljava/nio/ShortBuffer;"));
1080
+ BAILIF0(bufobj = (*env)->CallObjectMethod(env, bufobj, mid));
1081
+
1082
+ BAILIF0(cls = (*env)->FindClass(env, "java/awt/Rectangle"));
1083
+ BAILIF0(arrayRegionObj = (*env)->AllocObject(env, cls));
1084
+ BAILIF0(fid = (*env)->GetFieldID(env, cls, "x", "I"));
1085
+ (*env)->SetIntField(env, arrayRegionObj, fid, arrayRegion.x);
1086
+ BAILIF0(fid = (*env)->GetFieldID(env, cls, "y", "I"));
1087
+ (*env)->SetIntField(env, arrayRegionObj, fid, arrayRegion.y);
1088
+ BAILIF0(fid = (*env)->GetFieldID(env, cls, "width", "I"));
1089
+ (*env)->SetIntField(env, arrayRegionObj, fid, arrayRegion.w);
1090
+ BAILIF0(fid = (*env)->GetFieldID(env, cls, "height", "I"));
1091
+ (*env)->SetIntField(env, arrayRegionObj, fid, arrayRegion.h);
1092
+
1093
+ BAILIF0(planeRegionObj = (*env)->AllocObject(env, cls));
1094
+ BAILIF0(fid = (*env)->GetFieldID(env, cls, "x", "I"));
1095
+ (*env)->SetIntField(env, planeRegionObj, fid, planeRegion.x);
1096
+ BAILIF0(fid = (*env)->GetFieldID(env, cls, "y", "I"));
1097
+ (*env)->SetIntField(env, planeRegionObj, fid, planeRegion.y);
1098
+ BAILIF0(fid = (*env)->GetFieldID(env, cls, "width", "I"));
1099
+ (*env)->SetIntField(env, planeRegionObj, fid, planeRegion.w);
1100
+ BAILIF0(fid = (*env)->GetFieldID(env, cls, "height", "I"));
1101
+ (*env)->SetIntField(env, planeRegionObj, fid, planeRegion.h);
1102
+
1103
+ BAILIF0(cls = (*env)->GetObjectClass(env, cfobj));
1104
+ BAILIF0(mid = (*env)->GetMethodID(env, cls, "customFilter",
1105
+ "(Ljava/nio/ShortBuffer;Ljava/awt/Rectangle;Ljava/awt/Rectangle;IILorg/libjpegturbo/turbojpeg/TJTransform;)V"));
1106
+ (*env)->CallVoidMethod(env, cfobj, mid, bufobj, arrayRegionObj,
1107
+ planeRegionObj, componentIndex, transformIndex, tobj);
1108
+
1109
+ return 0;
1110
+
1111
+ bailout:
1112
+ return -1;
1113
+ }
1114
+
1115
+ /* TurboJPEG 1.2.x: TJTransformer::transform() */
1116
+ JNIEXPORT jintArray JNICALL Java_org_libjpegturbo_turbojpeg_TJTransformer_transform
1117
+ (JNIEnv *env, jobject obj, jbyteArray jsrcBuf, jint jpegSize,
1118
+ jobjectArray dstobjs, jobjectArray tobjs, jint flags)
1119
+ {
1120
+ tjhandle handle = 0;
1121
+ unsigned char *jpegBuf = NULL, **dstBufs = NULL;
1122
+ jsize n = 0;
1123
+ unsigned long *dstSizes = NULL;
1124
+ tjtransform *t = NULL;
1125
+ jbyteArray *jdstBufs = NULL;
1126
+ int i, jpegWidth = 0, jpegHeight = 0, jpegSubsamp;
1127
+ jintArray jdstSizes = 0;
1128
+ jint *dstSizesi = NULL;
1129
+ JNICustomFilterParams *params = NULL;
1130
+
1131
+ GET_HANDLE();
1132
+
1133
+ if ((*env)->GetArrayLength(env, jsrcBuf) < jpegSize)
1134
+ THROW_ARG("Source buffer is not large enough");
1135
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "jpegWidth", "I"));
1136
+ jpegWidth = (int)(*env)->GetIntField(env, obj, _fid);
1137
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "jpegHeight", "I"));
1138
+ jpegHeight = (int)(*env)->GetIntField(env, obj, _fid);
1139
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "jpegSubsamp", "I"));
1140
+ jpegSubsamp = (int)(*env)->GetIntField(env, obj, _fid);
1141
+
1142
+ n = (*env)->GetArrayLength(env, dstobjs);
1143
+ if (n != (*env)->GetArrayLength(env, tobjs))
1144
+ THROW_ARG("Mismatch between size of transforms array and destination buffers array");
1145
+
1146
+ if ((dstBufs =
1147
+ (unsigned char **)malloc(sizeof(unsigned char *) * n)) == NULL)
1148
+ THROW_MEM();
1149
+ if ((jdstBufs = (jbyteArray *)malloc(sizeof(jbyteArray) * n)) == NULL)
1150
+ THROW_MEM();
1151
+ if ((dstSizes = (unsigned long *)malloc(sizeof(unsigned long) * n)) == NULL)
1152
+ THROW_MEM();
1153
+ if ((t = (tjtransform *)malloc(sizeof(tjtransform) * n)) == NULL)
1154
+ THROW_MEM();
1155
+ if ((params = (JNICustomFilterParams *)malloc(sizeof(JNICustomFilterParams) *
1156
+ n)) == NULL)
1157
+ THROW_MEM();
1158
+ for (i = 0; i < n; i++) {
1159
+ dstBufs[i] = NULL; jdstBufs[i] = NULL; dstSizes[i] = 0;
1160
+ memset(&t[i], 0, sizeof(tjtransform));
1161
+ memset(&params[i], 0, sizeof(JNICustomFilterParams));
1162
+ }
1163
+
1164
+ for (i = 0; i < n; i++) {
1165
+ jobject tobj, cfobj;
1166
+
1167
+ BAILIF0(tobj = (*env)->GetObjectArrayElement(env, tobjs, i));
1168
+ BAILIF0(_cls = (*env)->GetObjectClass(env, tobj));
1169
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "op", "I"));
1170
+ t[i].op = (*env)->GetIntField(env, tobj, _fid);
1171
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "options", "I"));
1172
+ t[i].options = (*env)->GetIntField(env, tobj, _fid);
1173
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "x", "I"));
1174
+ t[i].r.x = (*env)->GetIntField(env, tobj, _fid);
1175
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "y", "I"));
1176
+ t[i].r.y = (*env)->GetIntField(env, tobj, _fid);
1177
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "width", "I"));
1178
+ t[i].r.w = (*env)->GetIntField(env, tobj, _fid);
1179
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "height", "I"));
1180
+ t[i].r.h = (*env)->GetIntField(env, tobj, _fid);
1181
+
1182
+ BAILIF0(_fid = (*env)->GetFieldID(env, _cls, "cf",
1183
+ "Lorg/libjpegturbo/turbojpeg/TJCustomFilter;"));
1184
+ cfobj = (*env)->GetObjectField(env, tobj, _fid);
1185
+ if (cfobj) {
1186
+ params[i].env = env;
1187
+ params[i].tobj = tobj;
1188
+ params[i].cfobj = cfobj;
1189
+ t[i].customFilter = JNICustomFilter;
1190
+ t[i].data = (void *)&params[i];
1191
+ }
1192
+ }
1193
+
1194
+ for (i = 0; i < n; i++) {
1195
+ int w = jpegWidth, h = jpegHeight;
1196
+
1197
+ if (t[i].r.w != 0) w = t[i].r.w;
1198
+ if (t[i].r.h != 0) h = t[i].r.h;
1199
+ BAILIF0(jdstBufs[i] = (*env)->GetObjectArrayElement(env, dstobjs, i));
1200
+ if ((unsigned long)(*env)->GetArrayLength(env, jdstBufs[i]) <
1201
+ tjBufSize(w, h, jpegSubsamp))
1202
+ THROW_ARG("Destination buffer is not large enough");
1203
+ }
1204
+ BAILIF0(jpegBuf = (*env)->GetPrimitiveArrayCritical(env, jsrcBuf, 0));
1205
+ for (i = 0; i < n; i++)
1206
+ BAILIF0(dstBufs[i] =
1207
+ (*env)->GetPrimitiveArrayCritical(env, jdstBufs[i], 0));
1208
+
1209
+ if (tjTransform(handle, jpegBuf, jpegSize, n, dstBufs, dstSizes, t,
1210
+ flags | TJFLAG_NOREALLOC) == -1) {
1211
+ for (i = 0; i < n; i++)
1212
+ SAFE_RELEASE(jdstBufs[i], dstBufs[i]);
1213
+ SAFE_RELEASE(jsrcBuf, jpegBuf);
1214
+ THROW_TJ();
1215
+ }
1216
+
1217
+ for (i = 0; i < n; i++)
1218
+ SAFE_RELEASE(jdstBufs[i], dstBufs[i]);
1219
+ SAFE_RELEASE(jsrcBuf, jpegBuf);
1220
+
1221
+ jdstSizes = (*env)->NewIntArray(env, n);
1222
+ BAILIF0(dstSizesi = (*env)->GetIntArrayElements(env, jdstSizes, 0));
1223
+ for (i = 0; i < n; i++) dstSizesi[i] = (int)dstSizes[i];
1224
+
1225
+ bailout:
1226
+ if (dstSizesi) (*env)->ReleaseIntArrayElements(env, jdstSizes, dstSizesi, 0);
1227
+ if (dstBufs) {
1228
+ for (i = 0; i < n; i++) {
1229
+ if (dstBufs[i] && jdstBufs && jdstBufs[i])
1230
+ (*env)->ReleasePrimitiveArrayCritical(env, jdstBufs[i], dstBufs[i], 0);
1231
+ }
1232
+ free(dstBufs);
1233
+ }
1234
+ SAFE_RELEASE(jsrcBuf, jpegBuf);
1235
+ if (jdstBufs) free(jdstBufs);
1236
+ if (dstSizes) free(dstSizes);
1237
+ if (t) free(t);
1238
+ return jdstSizes;
1239
+ }
1240
+
1241
+ /* TurboJPEG 1.2.x: TJDecompressor::destroy() */
1242
+ JNIEXPORT void JNICALL Java_org_libjpegturbo_turbojpeg_TJDecompressor_destroy
1243
+ (JNIEnv *env, jobject obj)
1244
+ {
1245
+ Java_org_libjpegturbo_turbojpeg_TJCompressor_destroy(env, obj);
1246
+ }