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
data/epeg/epeg_main.c ADDED
@@ -0,0 +1,1642 @@
1
+ #include "Epeg.h"
2
+ #include "epeg_private.h"
3
+ #include <jerror.h>
4
+
5
+ static Epeg_Image *_epeg_open_header (Epeg_Image *im);
6
+ static int _epeg_decode (Epeg_Image *im);
7
+ static int _epeg_scale (Epeg_Image *im);
8
+ static int _epeg_decode_for_trim (Epeg_Image *im);
9
+ static int _epeg_trim (Epeg_Image *im);
10
+ static int _epeg_encode (Epeg_Image *im);
11
+ static int _epeg_transform (Epeg_Image *im);
12
+
13
+ static void _epeg_fatal_error_handler (j_common_ptr cinfo);
14
+
15
+ #define MIN(__x,__y) ((__x) < (__y) ? (__x) : (__y))
16
+ #define MAX(__x,__y) ((__x) > (__y) ? (__x) : (__y))
17
+
18
+ static const JOCTET fake_EOI[2] = { 0xFF, JPEG_EOI };
19
+
20
+ /**
21
+ * Open a JPEG image by filename.
22
+ * @param file The file path to open.
23
+ * @return A handle to the opened JPEG file, with the header decoded.
24
+ *
25
+ * This function opens the file indicated by the @p file parameter, and
26
+ * attempts to decode it as a jpeg file. If this failes, NULL is returned.
27
+ * Otherwise a valid handle to an open JPEG file is returned that can be used
28
+ * by other Epeg calls.
29
+ *
30
+ * The @p file must be a pointer to a valid C string, NUL (0 byte) terminated
31
+ * thats is a relative or absolute file path. If not results are not
32
+ * determined.
33
+ *
34
+ * See also: epeg_memory_open(), epeg_close()
35
+ */
36
+ EAPI Epeg_Image *
37
+ epeg_file_open(const char *file) {
38
+ Epeg_Image *im;
39
+
40
+ im = calloc(1, sizeof(Epeg_Image));
41
+ if (!im) {
42
+ return NULL;
43
+ }
44
+
45
+ im->in.file = strdup(file);
46
+ if (!im->in.file) {
47
+ free(im);
48
+ return NULL;
49
+ }
50
+
51
+ im->in.f = fopen(im->in.file, "rb");
52
+ if (!im->in.f) {
53
+ epeg_close(im);
54
+ return NULL;
55
+ }
56
+ fstat(fileno(im->in.f), &(im->stat_info));
57
+ im->out.quality = 75;
58
+ return _epeg_open_header(im);
59
+ }
60
+
61
+ /**
62
+ * Open a JPEG image stored in memory.
63
+ * @param data A pointer to the memory containing the JPEG data.
64
+ * @param size The size of the memory segment containing the JPEG.
65
+ * @return A handle to the opened JPEG, with the header decoded.
66
+ *
67
+ * This function opens a JPEG file that is stored in memory pointed to by
68
+ * @p data, and that is @p size bytes in size. If successful a valid handle
69
+ * is returned, or on failure NULL is returned.
70
+ *
71
+ * See also: epeg_file_open(), epeg_close()
72
+ */
73
+ EAPI EAPI Epeg_Image *
74
+ epeg_memory_open(unsigned char *data, int size) {
75
+ Epeg_Image *im;
76
+
77
+ im = calloc(1, sizeof(Epeg_Image));
78
+ if (!im) {
79
+ return NULL;
80
+ }
81
+
82
+ im->out.quality = 75;
83
+ im->in.mem.data = (unsigned char **)data;
84
+ im->in.mem.size = size;
85
+ im->in.f = NULL;
86
+ im->in.w = 0;
87
+ im->in.h = 0;
88
+ return _epeg_open_header(im);
89
+ }
90
+
91
+ /**
92
+ * Return the original JPEG pixel size.
93
+ * @param im A handle to an opened Epeg image.
94
+ * @param w A pointer to the width value in pixels to be filled in.
95
+ * @param h A pointer to the height value in pixels to be filled in.
96
+ *
97
+ * Returns the image size in pixels.
98
+ *
99
+ */
100
+ EAPI void
101
+ epeg_size_get(Epeg_Image *im, int *w, int *h) {
102
+ if (w) {
103
+ *w = im->in.w;
104
+ }
105
+ if (h) {
106
+ *h = im->in.h;
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Return the original JPEG pixel color space.
112
+ * @param im A handle to an opened Epeg image.
113
+ * @param space A pointer to the color space value to be filled in.
114
+ *
115
+ * Returns the image color space.
116
+ *
117
+ */
118
+ EAPI void
119
+ epeg_colorspace_get(Epeg_Image *im, int *space) {
120
+ if (space) {
121
+ *space = im->color_space;
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Set the size of the image to decode in pixels.
127
+ * @param im A handle to an opened Epeg image.
128
+ * @param w The width of the image to decode at, in pixels.
129
+ * @param h The height of the image to decode at, in pixels.
130
+ *
131
+ * Sets the size at which to deocode the JPEG image, giving an optimised load
132
+ * that only decodes the pixels needed.
133
+ *
134
+ */
135
+ EAPI void
136
+ epeg_decode_size_set(Epeg_Image *im, int w, int h) {
137
+ if (im->pixels) {
138
+ return;
139
+ }
140
+ if (w < 1) {
141
+ w = 1;
142
+ } else if (w > im->in.w) {
143
+ w = im->in.w;
144
+ }
145
+ if (h < 1) {
146
+ h = 1;
147
+ } else if (h > im->in.h) {
148
+ h = im->in.h;
149
+ }
150
+ im->out.w = w;
151
+ im->out.h = h;
152
+ im->out.x = 0;
153
+ im->out.y = 0;
154
+ }
155
+
156
+ EAPI void
157
+ epeg_decode_bounds_set(Epeg_Image *im, int x, int y, int w, int h) {
158
+ if (im->pixels) {
159
+ return;
160
+ }
161
+ if (w < 1) {
162
+ w = 1;
163
+ } else if (w > im->in.w) {
164
+ w = im->in.w;
165
+ }
166
+ if (h < 1) {
167
+ h = 1;
168
+ } else if (h > im->in.h) {
169
+ h = im->in.h;
170
+ }
171
+ im->out.w = w;
172
+ im->out.h = h;
173
+ if (x < 0) {
174
+ x = 0;
175
+ }
176
+ if (y < 0) {
177
+ y = 0;
178
+ }
179
+ im->out.x = x;
180
+ im->out.y = y;
181
+ }
182
+
183
+ /**
184
+ * Set the colorspace in which to decode the image.
185
+ * @param im A handle to an opened Epeg image.
186
+ * @param colorspace The colorspace to decode the image in.
187
+ *
188
+ * This sets the colorspace to decode the image in. The default is EPEG_YUV8,
189
+ * as this is normally the native colorspace of a JPEG file, avoiding any
190
+ * colorspace conversions for a faster load and/or save.
191
+ */
192
+ EAPI void
193
+ epeg_decode_colorspace_set(Epeg_Image *im, Epeg_Colorspace colorspace) {
194
+ if (im->pixels) {
195
+ return;
196
+ }
197
+ if ((colorspace < EPEG_GRAY8) || (colorspace > EPEG_CMYK)) {
198
+ return;
199
+ }
200
+ im->color_space = colorspace;
201
+ }
202
+
203
+ /**
204
+ * Set the transformation of the image.
205
+ * @param im A handle to an opened Epeg image.
206
+ * @param transform The transformation of the image.
207
+ *
208
+ * Sets the transformation of the JPEG image.
209
+ *
210
+ */
211
+ EAPI void
212
+ epeg_transform_set(Epeg_Image *im, Epeg_Transform transform) {
213
+ if (im->pixels) {
214
+ return;
215
+ }
216
+ im->out.transform = transform;
217
+ }
218
+
219
+ /**
220
+ * Get a segment of decoded pixels from an image.
221
+ * @param im A handle to an opened Epeg image.
222
+ * @param x Rectangle X.
223
+ * @param y Rectangle Y.
224
+ * @param w Rectangle width.
225
+ * @param h Rectangle height.
226
+ * @return Pointer to the top left of the requested pixel block.
227
+ *
228
+ * Return image pixels in the decoded format from the specified location
229
+ * rectangle bounded with the box @p x, @p y @p w X @p y. The pixel block is
230
+ * packed with no row padding, and it organsied from top-left to bottom right,
231
+ * row by row. You must free the pixel block using epeg_pixels_free() before
232
+ * you close the image handle, and assume the pixels to be read-only memory.
233
+ *
234
+ * On success the pointer is returned, on failure, NULL is returned. Failure
235
+ * may be because the rectangle is out of the bounds of the image, memory
236
+ * allocations failed or the image data cannot be decoded.
237
+ *
238
+ */
239
+ EAPI const void *
240
+ epeg_pixels_get(Epeg_Image *im, int x, int y, int w, int h) {
241
+ int xx, yy, ww, hh, bpp, ox, oy, ow, oh, iw, ih;
242
+
243
+ if (!im->pixels) {
244
+ if (_epeg_decode(im) != 0) {
245
+ return NULL;
246
+ }
247
+ }
248
+
249
+ if (!im->pixels) {
250
+ return NULL;
251
+ }
252
+ if ((im->out.w < 1) || (im->out.h < 1)) {
253
+ return NULL;
254
+ }
255
+
256
+ if (_epeg_scale(im) != 0) {
257
+ return NULL;
258
+ }
259
+
260
+ bpp = im->in.jinfo.output_components;
261
+ iw = im->out.w;
262
+ ih = im->out.h;
263
+ ow = w;
264
+ oh = h;
265
+ ox = 0;
266
+ oy = 0;
267
+ if ((x + ow) > iw) {
268
+ ow = iw - x;
269
+ }
270
+ if ((y + oh) > ih) {
271
+ oh = ih - y;
272
+ }
273
+ if (ow < 1) {
274
+ return NULL;
275
+ }
276
+ if (oh < 1) {
277
+ return NULL;
278
+ }
279
+ if (x < 0) {
280
+ ow += x;
281
+ ox = -x;
282
+ }
283
+ if (y < 0) {
284
+ oh += y;
285
+ oy = -y;
286
+ }
287
+ if (ow < 1) {
288
+ return NULL;
289
+ }
290
+ if (oh < 1) {
291
+ return NULL;
292
+ }
293
+
294
+ ww = x + ox + ow;
295
+ hh = y + oy + oh;
296
+
297
+ if (im->color_space == EPEG_GRAY8) {
298
+ unsigned char *pix, *p;
299
+
300
+ pix = malloc(w * h * 1);
301
+ if (!pix) {
302
+ return NULL;
303
+ }
304
+ for (yy = y + oy; yy < hh; yy++) {
305
+ unsigned char *s;
306
+
307
+ s = im->lines[yy] + ((x + ox) * bpp);
308
+ p = pix + ((((yy - y) * w) + ox));
309
+ for (xx = x + ox; xx < ww; xx++) {
310
+ p[0] = s[0];
311
+ p++;
312
+ s += bpp;
313
+ }
314
+ }
315
+ return pix;
316
+ } else if (im->color_space == EPEG_YUV8) {
317
+ unsigned char *pix, *p;
318
+
319
+ pix = malloc(w * h * 3);
320
+ if (!pix) {
321
+ return NULL;
322
+ }
323
+ for (yy = y + oy; yy < hh; yy++) {
324
+ unsigned char *s;
325
+
326
+ s = im->lines[yy] + ((x + ox) * bpp);
327
+ p = pix + ((((yy - y) * w) + ox) * 3);
328
+ for (xx = x + ox; xx < ww; xx++) {
329
+ p[0] = s[0];
330
+ p[1] = s[1];
331
+ p[2] = s[2];
332
+ p += 3;
333
+ s += bpp;
334
+ }
335
+ }
336
+ return pix;
337
+ } else if (im->color_space == EPEG_RGB8) {
338
+ unsigned char *pix, *p;
339
+
340
+ pix = malloc(w * h * 3);
341
+ if (!pix) {
342
+ return NULL;
343
+ }
344
+ for (yy = y + oy; yy < hh; yy++) {
345
+ unsigned char *s;
346
+
347
+ s = im->lines[yy] + ((x + ox) * bpp);
348
+ p = pix + ((((yy - y) * w) + ox) * 3);
349
+ for (xx = x + ox; xx < ww; xx++) {
350
+ p[0] = s[0];
351
+ p[1] = s[1];
352
+ p[2] = s[2];
353
+ p += 3;
354
+ s += bpp;
355
+ }
356
+ }
357
+ return pix;
358
+ } else if (im->color_space == EPEG_BGR8) {
359
+ unsigned char *pix, *p;
360
+
361
+ pix = malloc(w * h * 3);
362
+ if (!pix) {
363
+ return NULL;
364
+ }
365
+ for (yy = y + oy; yy < hh; yy++) {
366
+ unsigned char *s;
367
+
368
+ s = im->lines[yy] + ((x + ox) * bpp);
369
+ p = pix + ((((yy - y) * w) + ox) * 3);
370
+ for (xx = x + ox; xx < ww; xx++) {
371
+ p[0] = s[2];
372
+ p[1] = s[1];
373
+ p[2] = s[0];
374
+ p += 3;
375
+ s += bpp;
376
+ }
377
+ }
378
+ return pix;
379
+ } else if (im->color_space == EPEG_RGBA8) {
380
+ unsigned char *pix, *p;
381
+
382
+ pix = malloc(w * h * 4);
383
+ if (!pix) {
384
+ return NULL;
385
+ }
386
+ for (yy = y + oy; yy < hh; yy++) {
387
+ unsigned char *s;
388
+
389
+ s = im->lines[yy] + ((x + ox) * bpp);
390
+ p = pix + ((((yy - y) * w) + ox) * 4);
391
+ for (xx = x + ox; xx < ww; xx++) {
392
+ p[0] = s[0];
393
+ p[1] = s[1];
394
+ p[2] = s[2];
395
+ p[3] = 0xff;
396
+ p += 4;
397
+ s += bpp;
398
+ }
399
+ }
400
+ return pix;
401
+ } else if (im->color_space == EPEG_BGRA8) {
402
+ unsigned char *pix, *p;
403
+
404
+ pix = malloc(w * h * 4);
405
+ if (!pix) {
406
+ return NULL;
407
+ }
408
+ for (yy = y + oy; yy < hh; yy++) {
409
+ unsigned char *s;
410
+
411
+ s = im->lines[yy] + ((x + ox) * bpp);
412
+ p = pix + ((((yy - y) * w) + ox) * 4);
413
+ for (xx = x + ox; xx < ww; xx++) {
414
+ p[0] = 0xff;
415
+ p[1] = s[2];
416
+ p[2] = s[1];
417
+ p[3] = s[0];
418
+ p += 4;
419
+ s += bpp;
420
+ }
421
+ }
422
+ return pix;
423
+ } else if (im->color_space == EPEG_ARGB32) {
424
+ unsigned int *pix, *p;
425
+
426
+ pix = malloc(w * h * 4);
427
+ if (!pix) {
428
+ return NULL;
429
+ }
430
+ for (yy = y + oy; yy < hh; yy++) {
431
+ unsigned char *s;
432
+
433
+ s = im->lines[yy] + ((x + ox) * bpp);
434
+ p = pix + ((((yy - y) * w) + ox));
435
+ for (xx = x + ox; xx < ww; xx++) {
436
+ p[0] = 0xff000000 | (s[0] << 16) | (s[1] << 8) | (s[2]);
437
+ p++;
438
+ s += bpp;
439
+ }
440
+ }
441
+ return pix;
442
+ } else if (im->color_space == EPEG_CMYK) {
443
+ unsigned char *pix, *p;
444
+
445
+ pix = malloc(w * h * 4);
446
+ if (!pix) {
447
+ return NULL;
448
+ }
449
+ for (yy = y + oy; yy < hh; yy++) {
450
+ unsigned char *s;
451
+
452
+ s = im->lines[yy] + ((x + ox) * bpp);
453
+ p = pix + ((((yy - y) * w) + ox) * 4);
454
+ for (xx = x + ox; xx < ww; xx++) {
455
+ p[0] = s[0];
456
+ p[1] = s[1];
457
+ p[2] = s[2];
458
+ p[3] = 0xff;
459
+ p += 4;
460
+ s += bpp;
461
+ }
462
+ }
463
+ return pix;
464
+ }
465
+ return NULL;
466
+ }
467
+
468
+ /**
469
+ * Get a segment of decoded pixels from an image.
470
+ * @param im A handle to an opened Epeg image.
471
+ * @param x Rectangle X.
472
+ * @param y Rectangle Y.
473
+ * @param w Rectangle width.
474
+ * @param h Rectangle height.
475
+ * @return Pointer to the top left of the requested pixel block.
476
+ *
477
+ * Return image pixels in the decoded format from the specified location
478
+ * rectangle bounded with the box @p x, @p y @p w X @p y. The pixel block is
479
+ * packed with no row padding, and it organsied from top-left to bottom right,
480
+ * row by row. You must free the pixel block using epeg_pixels_free() before
481
+ * you close the image handle, and assume the pixels to be read-only memory.
482
+ *
483
+ * On success the pointer is returned, on failure, NULL is returned. Failure
484
+ * may be because the rectangle is out of the bounds of the image, memory
485
+ * allocations failed or the image data cannot be decoded.
486
+ *
487
+ */
488
+ EAPI const void *
489
+ epeg_pixels_get_as_RGB8(Epeg_Image *im, int x, int y, int w, int h) {
490
+ int xx, yy, ww, hh, bpp, ox, oy, ow, oh, iw, ih;
491
+
492
+ if (!im->pixels) {
493
+ if (_epeg_decode(im) != 0) {
494
+ return NULL;
495
+ }
496
+ }
497
+
498
+ if (!im->pixels) {
499
+ return NULL;
500
+ }
501
+ if ((im->out.w < 1) || (im->out.h < 1)) {
502
+ return NULL;
503
+ }
504
+
505
+ bpp = im->in.jinfo.output_components;
506
+ iw = im->out.w;
507
+ ih = im->out.h;
508
+ ow = w;
509
+ oh = h;
510
+ ox = 0;
511
+ oy = 0;
512
+ if ((x + ow) > iw) {
513
+ ow = iw - x;
514
+ }
515
+ if ((y + oh) > ih) {
516
+ oh = ih - y;
517
+ }
518
+ if (ow < 1) {
519
+ return NULL;
520
+ }
521
+ if (oh < 1) {
522
+ return NULL;
523
+ }
524
+ if (x < 0) {
525
+ ow += x;
526
+ ox = -x;
527
+ }
528
+ if (y < 0) {
529
+ oh += y;
530
+ oy = -y;
531
+ }
532
+ if (ow < 1) {
533
+ return NULL;
534
+ }
535
+ if (oh < 1) {
536
+ return NULL;
537
+ }
538
+
539
+ ww = x + ox + ow;
540
+ hh = y + oy + oh;
541
+
542
+ if (im->color_space == EPEG_GRAY8) {
543
+ unsigned char *pix, *p;
544
+
545
+ pix = malloc(w * h * 3);
546
+ if (!pix) {
547
+ return NULL;
548
+ }
549
+ for (yy = y + oy; yy < hh; yy++) {
550
+ unsigned char *s;
551
+
552
+ s = im->lines[yy] + ((x + ox) * bpp);
553
+ p = pix + ((((yy - y) * w) + ox) * 3);
554
+ for (xx = x + ox; xx < ww; xx++) {
555
+ p[0] = s[0];
556
+ p[1] = s[0];
557
+ p[2] = s[0];
558
+ p += 3;
559
+ s += bpp;
560
+ }
561
+ }
562
+ return pix;
563
+ }
564
+ if (im->color_space == EPEG_RGB8) {
565
+ unsigned char *pix, *p;
566
+
567
+ pix = malloc(w * h * 3);
568
+ if (!pix) {
569
+ return NULL;
570
+ }
571
+ for (yy = y + oy; yy < hh; yy++) {
572
+ unsigned char *s;
573
+
574
+ s = im->lines[yy] + ((x + ox) * bpp);
575
+ p = pix + ((((yy - y) * w) + ox) * 3);
576
+ for (xx = x + ox; xx < ww; xx++) {
577
+ p[0] = s[0];
578
+ p[1] = s[1];
579
+ p[2] = s[2];
580
+ p += 3;
581
+ s += bpp;
582
+ }
583
+ }
584
+ return pix;
585
+ }
586
+ if (im->color_space == EPEG_CMYK) {
587
+ unsigned char *pix, *p;
588
+
589
+ pix = malloc(w * h * 3);
590
+ if (!pix) {
591
+ return NULL;
592
+ }
593
+ for (yy = y + oy; yy < hh; yy++) {
594
+ unsigned char *s;
595
+
596
+ s = im->lines[yy] + ((x + ox) * bpp);
597
+ p = pix + ((((yy - y) * w) + ox) * 3);
598
+ for (xx = x + ox; xx < ww; xx++) {
599
+ p[0] = (unsigned char)(MIN(255, (s[0] * s[3]) / 255));
600
+ p[1] = (unsigned char)(MIN(255, (s[1] * s[3]) / 255));
601
+ p[2] = (unsigned char)(MIN(255, (s[2] * s[3]) / 255));
602
+ p += 3;
603
+ s += bpp;
604
+ }
605
+ }
606
+ return pix;
607
+ }
608
+ return NULL;
609
+ }
610
+
611
+ /**
612
+ * Free requested pixel block from an image.
613
+ * @param im A handle to an opened Epeg image.
614
+ * @param data The pointer to the image pixels.
615
+ *
616
+ * This frees the data for a block of pixels requested from image @p im.
617
+ * @p data must be a valid (non NULL) pointer to a pixel block taken from the
618
+ * image @p im by epeg_pixels_get() and mustbe called before the image is
619
+ * closed by epeg_close().
620
+ */
621
+ EAPI void
622
+ epeg_pixels_free(Epeg_Image *im, const void *data) {
623
+ free((void *)data);
624
+ }
625
+
626
+ /**
627
+ * Get the image comment field as a string.
628
+ * @param im A handle to an opened Epeg image.
629
+ * @return A pointer to the loaded image comments.
630
+ *
631
+ * This function returns the comment field as a string (NUL byte terminated)
632
+ * of the loaded image @p im, if there is a comment, or NULL if no comment is
633
+ * saved with the image. Consider the string returned to be read-only.
634
+ *
635
+ */
636
+ EAPI const char *
637
+ epeg_comment_get(Epeg_Image *im) {
638
+ return im->in.comment;
639
+ }
640
+
641
+ /**
642
+ * Get thumbnail comments of loaded image.
643
+ * @param im A handle to an opened Epeg image.
644
+ * @param info Pointer to a thumbnail info struct to be filled in.
645
+ *
646
+ * This function retrieves thumbnail comments written by Epeg to any saved
647
+ * JPEG files. If no thumbnail comments were saved, the fields will be 0 in
648
+ * the @p info struct on return.
649
+ *
650
+ */
651
+ EAPI void
652
+ epeg_thumbnail_comments_get(Epeg_Image *im, Epeg_Thumbnail_Info *info) {
653
+ if (!info) {
654
+ return;
655
+ }
656
+ info->uri = im->in.thumb_info.uri;
657
+ info->mtime = im->in.thumb_info.mtime;
658
+ info->w = im->in.thumb_info.w;
659
+ info->h = im->in.thumb_info.h;
660
+ info->mimetype = im->in.thumb_info.mime;
661
+ }
662
+
663
+ /**
664
+ * Set the comment field of the image for saving.
665
+ * @param im A handle to an opened Epeg image.
666
+ * @param comment The comment to set.
667
+ *
668
+ * Set the comment for the image file for when it gets saved. This is a NUL
669
+ * byte terminated C string. If @p comment is NULL the output file will have
670
+ * no comment field.
671
+ *
672
+ * The default comment will be any comment loaded from the input file.
673
+ *
674
+ */
675
+ EAPI void
676
+ epeg_comment_set(Epeg_Image *im, const char *comment) {
677
+ if (im->out.comment) {
678
+ free(im->out.comment);
679
+ }
680
+ if (!comment) {
681
+ im->out.comment = NULL;
682
+ } else {
683
+ im->out.comment = strdup(comment);
684
+ }
685
+ }
686
+
687
+ /**
688
+ * Set the encoding quality of the saved image.
689
+ * @param im A handle to an opened Epeg image.
690
+ * @param quality The quality of encoding from 0 to 100.
691
+ *
692
+ * Set the quality of the output encoded image. Values from 0 to 100
693
+ * inclusive are valid, with 100 being the maximum quality, and 0 being the
694
+ * minimum. If the quality is set equal to or above 90%, the output U and V
695
+ * color planes are encoded at 1:1 with the Y plane.
696
+ *
697
+ * The default quality is 75.
698
+ *
699
+ */
700
+ EAPI void
701
+ epeg_quality_set(Epeg_Image *im, int quality) {
702
+ if (quality < 0) {
703
+ quality = 0;
704
+ } else if (quality > 100) {
705
+ quality = 100;
706
+ }
707
+ im->out.quality = quality;
708
+ }
709
+
710
+ /**
711
+ * Enable thumbnail comments in saved image.
712
+ * @param im A handle to an opened Epeg image.
713
+ * @param onoff A boolean on and off enabling flag.
714
+ *
715
+ * if @p onoff is 1, the output file will have thumbnail comments added to
716
+ * it, and if it is 0, it will not. The default is 0.
717
+ *
718
+ */
719
+ EAPI void
720
+ epeg_thumbnail_comments_enable(Epeg_Image *im, int onoff) {
721
+ im->out.thumbnail_info = onoff;
722
+ }
723
+
724
+ /**
725
+ * Set the output file path for the image when saved.
726
+ * @param im A handle to an opened Epeg image.
727
+ * @param file The path to the output file.
728
+ *
729
+ * This sets the output file path name (either a full or relative path name)
730
+ * to where the file will be written when saved. @p file must be a NUL
731
+ * terminated C string conatining the path to the file to be saved to. If it is
732
+ * NULL, the image will not be saved to a file when calling epeg_encode().
733
+ */
734
+ EAPI void
735
+ epeg_file_output_set(Epeg_Image *im, const char *file) {
736
+ if (im->out.file) {
737
+ free(im->out.file);
738
+ }
739
+ if (!file) {
740
+ im->out.file = NULL;
741
+ } else {
742
+ im->out.file = strdup(file);
743
+ }
744
+ }
745
+
746
+ /**
747
+ * Set the output file to be a block of allocated memory.
748
+ * @param im A handle to an opened Epeg image.
749
+ * @param data A pointer to a pointer to a memory block.
750
+ * @param size A pointer to a counter of the size of the memory block.
751
+ *
752
+ * This sets the output encoding of the image when saved to be allocated
753
+ * memory. After epeg_close() is called the pointer pointed to by @p data
754
+ * and the integer pointed to by @p size will contain the pointer to the
755
+ * memory block and its size in bytes, respecitvely. The memory block can be
756
+ * freed with the free() function call. If the save fails the pointer to the
757
+ * memory block will be unaffected, as will the size.
758
+ *
759
+ */
760
+ EAPI void
761
+ epeg_memory_output_set(Epeg_Image *im, unsigned char **data, int *size) {
762
+ im->out.mem.data = data;
763
+ im->out.mem.size = size;
764
+ im->out.file = NULL;
765
+ }
766
+
767
+ /**
768
+ * This saves the image to its specified destination.
769
+ * @param im A handle to an opened Epeg image.
770
+ *
771
+ * This saves the image @p im to its destination specified by
772
+ * epeg_file_output_set() or epeg_memory_output_set(). The image will be
773
+ * encoded at the deoded pixel size, using the quality, comment and thumbnail
774
+ * comment settings set on the image.
775
+ *
776
+ * retval 1 - error scale
777
+ * 2 - error encode
778
+ * 3 - error decode
779
+ * 4 - error decode ( setjmp )
780
+ */
781
+ EAPI int
782
+ epeg_encode(Epeg_Image *im) {
783
+ int ret;
784
+ if ((ret = _epeg_decode(im)) != 0) {
785
+ return (ret == 2 ? 4 : 3);
786
+ }
787
+ if (_epeg_scale(im) != 0) {
788
+ return 1;
789
+ }
790
+ if (_epeg_encode(im) != 0) {
791
+ return 2;
792
+ }
793
+ return 0;
794
+ }
795
+
796
+ /**
797
+ * FIXME: Document this
798
+ * @param im A handle to an opened Epeg image.
799
+ *
800
+ * FIXME: Document this.
801
+ */
802
+ EAPI int
803
+ epeg_trim(Epeg_Image *im) {
804
+ if (_epeg_decode_for_trim(im) != 0) {
805
+ return 1;
806
+ }
807
+ if (_epeg_trim(im) != 0) {
808
+ return 1;
809
+ }
810
+ if (_epeg_encode(im) != 0) {
811
+ return 1;
812
+ }
813
+ return 0;
814
+ }
815
+
816
+ /**
817
+ * This saves the transformed image to its specified destination.
818
+ * @param im A handle to an opened Epeg image.
819
+ *
820
+ * This saves the image @p im to its destination specified by
821
+ * epeg_file_output_set() or epeg_memory_output_set(). The image will be
822
+ * transformed using specified transformation.
823
+ *
824
+ * retval 1 - error transform
825
+ */
826
+ EAPI int
827
+ epeg_transform(Epeg_Image *im) {
828
+ if (_epeg_transform(im) != 0) {
829
+ return 1;
830
+ }
831
+ return 0;
832
+ }
833
+
834
+ /**
835
+ * Get the last error message.
836
+ * @param im A handle to an opened Epeg image.
837
+ * @param buffer Char buffer for error message
838
+ *
839
+ * This copies the last error to the buffer parameter.
840
+ */
841
+ EAPI void
842
+ epeg_error(Epeg_Image *im, char *buffer) {
843
+ if (!im->error) {
844
+ return;
845
+ }
846
+ strcpy(buffer, im->error_msg);
847
+ }
848
+
849
+ /**
850
+ * Close an image handle.
851
+ * @param im A handle to an opened Epeg image.
852
+ *
853
+ * This closes an opened image handle and frees all memory associated with it.
854
+ * It does not free encoded data generated by epeg_memory_output_set() followed
855
+ * by epeg_encode() nor does it guarantee to free any data recieved by
856
+ * epeg_pixels_get(). Once an image handle is closed consider it invalid.
857
+ */
858
+ EAPI void
859
+ epeg_close(Epeg_Image *im) {
860
+ if (!im) {
861
+ return;
862
+ }
863
+ if (im->pixels) {
864
+ free(im->pixels);
865
+ }
866
+ if (im->lines) {
867
+ free(im->lines);
868
+ }
869
+ if (im->in.file) {
870
+ free(im->in.file);
871
+ }
872
+ if (!im->in.file) {
873
+ free(im->in.jinfo.src);
874
+ }
875
+ if (im->in.f || im->in.mem.data) {
876
+ jpeg_destroy_decompress(&(im->in.jinfo));
877
+ }
878
+ if (im->in.f) {
879
+ fclose(im->in.f);
880
+ }
881
+ if (im->in.comment) {
882
+ free(im->in.comment);
883
+ }
884
+ if (im->in.thumb_info.uri) {
885
+ free(im->in.thumb_info.uri);
886
+ }
887
+ if (im->in.thumb_info.mime) {
888
+ free(im->in.thumb_info.mime);
889
+ }
890
+ if (im->out.file) {
891
+ free(im->out.file);
892
+ }
893
+ if (!im->out.file) {
894
+ free(im->out.jinfo.dest);
895
+ }
896
+ if (im->out.f || im->in.mem.data) {
897
+ jpeg_destroy_compress(&(im->out.jinfo));
898
+ }
899
+ if (im->out.f) {
900
+ fclose(im->out.f);
901
+ }
902
+ if (im->out.comment) {
903
+ free(im->out.comment);
904
+ }
905
+ free(im);
906
+ }
907
+
908
+ static Epeg_Image *
909
+ _epeg_open_header(Epeg_Image *im) {
910
+ struct jpeg_marker_struct *m;
911
+ struct jpeg_source_mgr *src_mgr = NULL;
912
+
913
+ im->in.jinfo.err = jpeg_std_error(&(im->jerr.pub));
914
+ im->jerr.pub.error_exit = _epeg_fatal_error_handler;
915
+ #ifdef NOWARNINGS
916
+ im->jerr.pub.emit_message = _emit_message;
917
+ im->jerr.pub.output_message = _output_message;
918
+ im->jerr.pub.format_message = _format_message;
919
+ #endif
920
+
921
+ if (setjmp(im->jerr.setjmp_buffer)) {
922
+ error:
923
+ epeg_close(im);
924
+ im = NULL;
925
+ return NULL;
926
+ }
927
+
928
+ jpeg_create_decompress(&(im->in.jinfo));
929
+ jpeg_save_markers(&(im->in.jinfo), JPEG_APP0 + 7, 1024);
930
+ jpeg_save_markers(&(im->in.jinfo), JPEG_COM, 65535);
931
+ if (im->in.f != NULL) {
932
+ jpeg_stdio_src(&(im->in.jinfo), im->in.f);
933
+ } else {
934
+ /* Setup RAM source manager. */
935
+ src_mgr = calloc(1, sizeof(struct jpeg_source_mgr));
936
+ if (!src_mgr) {
937
+ goto error;
938
+ }
939
+ src_mgr->init_source = _jpeg_init_source;
940
+ src_mgr->fill_input_buffer = _jpeg_fill_input_buffer;
941
+ src_mgr->skip_input_data = _jpeg_skip_input_data;
942
+ src_mgr->resync_to_restart = jpeg_resync_to_restart;
943
+ src_mgr->term_source = _jpeg_term_source;
944
+ src_mgr->bytes_in_buffer = im->in.mem.size;
945
+ src_mgr->next_input_byte = (JOCTET *) im->in.mem.data;
946
+ im->in.jinfo.src = (struct jpeg_source_mgr *) src_mgr;
947
+ }
948
+
949
+ jpeg_read_header(&(im->in.jinfo), TRUE);
950
+ im->in.w = im->in.jinfo.image_width;
951
+ im->in.h = im->in.jinfo.image_height;
952
+ if (im->in.w < 1) {
953
+ goto error;
954
+ }
955
+ if (im->in.h < 1) {
956
+ goto error;
957
+ }
958
+
959
+ im->out.w = im->in.w;
960
+ im->out.h = im->in.h;
961
+
962
+ im->color_space = ((im->in.color_space = im->in.jinfo.out_color_space) == JCS_GRAYSCALE) ? EPEG_GRAY8 : EPEG_RGB8;
963
+ if (im->in.color_space == JCS_CMYK) {
964
+ im->color_space = EPEG_CMYK;
965
+ }
966
+
967
+ for (m = im->in.jinfo.marker_list; m; m = m->next) {
968
+ if (m->marker == JPEG_COM) {
969
+ if (im->in.comment) {
970
+ free(im->in.comment);
971
+ }
972
+ im->in.comment = malloc(m->data_length + 1);
973
+ if (im->in.comment) {
974
+ memcpy(im->in.comment, m->data, m->data_length);
975
+ im->in.comment[m->data_length] = 0;
976
+ }
977
+ } else if (m->marker == (JPEG_APP0 + 7)) {
978
+ if ((m->data_length > 7) &&
979
+ (!strncmp((char *)m->data, "Thumb::", 7))) {
980
+ char *p, *p2;
981
+
982
+ p = malloc(m->data_length + 1);
983
+ if (p) {
984
+ memcpy(p, m->data, m->data_length);
985
+ p[m->data_length] = 0;
986
+ p2 = strchr(p, '\n');
987
+ if (p2) {
988
+ p2[0] = 0;
989
+ if (!strcmp(p, "Thumb::URI"))
990
+
991
+ {
992
+ im->in.thumb_info.uri = strdup(p2 + 1);
993
+ } else if (!strcmp(p, "Thumb::MTime")) {
994
+ sscanf(p2 + 1, "%llu", &(im->in.thumb_info.mtime));
995
+ } else if (!strcmp(p, "Thumb::Image::Width")) {
996
+ im->in.thumb_info.w = atoi(p2 + 1);
997
+ } else if (!strcmp(p, "Thumb::Image::Height")) {
998
+ im->in.thumb_info.h = atoi(p2 + 1);
999
+ } else if (!strcmp(p, "Thumb::Mimetype")) {
1000
+ im->in.thumb_info.mime = strdup(p2 + 1);
1001
+ }
1002
+ }
1003
+ free(p);
1004
+ }
1005
+ }
1006
+ }
1007
+ }
1008
+ return im;
1009
+ }
1010
+
1011
+ /**
1012
+ retval 1 - malloc or other
1013
+ 2 - setjmp error
1014
+ */
1015
+ static int
1016
+ _epeg_decode(Epeg_Image *im) {
1017
+ int scale, scalew, scaleh, y;
1018
+ JDIMENSION old_output_scanline = 1;
1019
+
1020
+ if (im->pixels) {
1021
+ return 1;
1022
+ }
1023
+ if ((im->out.w < 1) || (im->out.h < 1)) {
1024
+ return 1;
1025
+ }
1026
+
1027
+ scalew = im->in.w / im->out.w;
1028
+ scaleh = im->in.h / im->out.h;
1029
+
1030
+ scale = scalew;
1031
+ if (scaleh < scalew) {
1032
+ scale = scaleh;
1033
+ }
1034
+
1035
+ if (scale > 8) {
1036
+ scale = 8;
1037
+ } else if (scale < 1) {
1038
+ scale = 1;
1039
+ }
1040
+
1041
+ im->in.jinfo.scale_num = 1;
1042
+ im->in.jinfo.scale_denom = scale;
1043
+ im->in.jinfo.do_fancy_upsampling = FALSE;
1044
+ im->in.jinfo.do_block_smoothing = FALSE;
1045
+ im->in.jinfo.dct_method = JDCT_IFAST;
1046
+
1047
+ switch (im->color_space) {
1048
+ case EPEG_GRAY8:
1049
+ im->in.jinfo.out_color_space = JCS_GRAYSCALE;
1050
+ im->in.jinfo.output_components = 1;
1051
+ break;
1052
+
1053
+ case EPEG_YUV8:
1054
+ im->in.jinfo.out_color_space = JCS_YCbCr;
1055
+ break;
1056
+
1057
+ case EPEG_RGB8:
1058
+ case EPEG_BGR8:
1059
+ case EPEG_RGBA8:
1060
+ case EPEG_BGRA8:
1061
+ case EPEG_ARGB32:
1062
+ im->in.jinfo.out_color_space = JCS_RGB;
1063
+ break;
1064
+
1065
+ case EPEG_CMYK:
1066
+ im->in.jinfo.out_color_space = JCS_CMYK;
1067
+ im->in.jinfo.output_components = 4;
1068
+ break;
1069
+
1070
+ default:
1071
+ break;
1072
+ }
1073
+
1074
+ im->out.jinfo.err = jpeg_std_error(&(im->jerr.pub));
1075
+ im->jerr.pub.error_exit = _epeg_fatal_error_handler;
1076
+ #ifdef NOWARNINGS
1077
+ im->jerr.pub.emit_message = _emit_message;
1078
+ im->jerr.pub.output_message = _output_message;
1079
+ im->jerr.pub.format_message = _format_message;
1080
+ #endif
1081
+
1082
+ if (setjmp(im->jerr.setjmp_buffer)) {
1083
+ im->jerr.pub.format_message((j_common_ptr)&(im->out.jinfo), im->error_msg);
1084
+ return 2;
1085
+ }
1086
+
1087
+ jpeg_calc_output_dimensions(&(im->in.jinfo));
1088
+
1089
+ im->pixels = malloc(im->in.jinfo.output_width * im->in.jinfo.output_height * im->in.jinfo.output_components);
1090
+ if (!im->pixels) {
1091
+ return 1;
1092
+ }
1093
+
1094
+ im->lines = malloc(im->in.jinfo.output_height * sizeof(char *));
1095
+ if (!im->lines) {
1096
+ free(im->pixels);
1097
+ im->pixels = NULL;
1098
+ return 1;
1099
+ }
1100
+
1101
+ jpeg_start_decompress(&(im->in.jinfo));
1102
+
1103
+ for (y = 0; y < im->in.jinfo.output_height; y++) {
1104
+ im->lines[y] = im->pixels + (y * im->in.jinfo.output_components * im->in.jinfo.output_width);
1105
+ }
1106
+
1107
+ while (im->in.jinfo.output_scanline < im->in.jinfo.output_height) {
1108
+ if (old_output_scanline == im->in.jinfo.output_scanline) {
1109
+ jpeg_abort_decompress(&(im->in.jinfo));
1110
+ return 1;
1111
+ }
1112
+ old_output_scanline = im->in.jinfo.output_scanline;
1113
+ jpeg_read_scanlines(&(im->in.jinfo),
1114
+ &(im->lines[im->in.jinfo.output_scanline]),
1115
+ im->in.jinfo.rec_outbuf_height);
1116
+ }
1117
+
1118
+ jpeg_finish_decompress(&(im->in.jinfo));
1119
+
1120
+ return 0;
1121
+ }
1122
+
1123
+ static int
1124
+ _epeg_scale(Epeg_Image *im) {
1125
+ unsigned char *dst, *row, *src;
1126
+ int x, y, w, h, i;
1127
+
1128
+ if ((im->in.w == im->out.w) && (im->in.h == im->out.h)) {
1129
+ return 0;
1130
+ }
1131
+ if (im->scaled) {
1132
+ return 0;
1133
+ }
1134
+
1135
+ if ((im->out.w < 1) || (im->out.h < 1)) {
1136
+ return 0;
1137
+ }
1138
+
1139
+ im->scaled = 1;
1140
+ w = im->out.w;
1141
+ h = im->out.h;
1142
+ for (y = 0; y < h; y++) {
1143
+ row = im->pixels + (((y * im->in.jinfo.output_height) / h) * im->in.jinfo.output_components * im->in.jinfo.output_width);
1144
+ dst = im->pixels + (y * im->in.jinfo.output_components * im->in.jinfo.output_width);
1145
+
1146
+ for (x = 0; x < im->out.w; x++) {
1147
+ src = row + (((x * im->in.jinfo.output_width) / w) * im->in.jinfo.output_components);
1148
+ for (i = 0; i < im->in.jinfo.output_components; i++) {
1149
+ dst[i] = src[i];
1150
+ }
1151
+ dst += im->in.jinfo.output_components;
1152
+ }
1153
+ }
1154
+ return 0;
1155
+ }
1156
+
1157
+ static int
1158
+ _epeg_decode_for_trim(Epeg_Image *im) {
1159
+ int y;
1160
+
1161
+ if (im->pixels) {
1162
+ return 1;
1163
+ }
1164
+
1165
+ im->in.jinfo.scale_num = 1;
1166
+ im->in.jinfo.scale_denom = 1;
1167
+ im->in.jinfo.do_fancy_upsampling = FALSE;
1168
+ im->in.jinfo.do_block_smoothing = FALSE;
1169
+ im->in.jinfo.dct_method = JDCT_ISLOW;
1170
+
1171
+ switch (im->color_space) {
1172
+ case EPEG_GRAY8:
1173
+ im->in.jinfo.out_color_space = JCS_GRAYSCALE;
1174
+ im->in.jinfo.output_components = 1;
1175
+ break;
1176
+
1177
+ case EPEG_YUV8:
1178
+ im->in.jinfo.out_color_space = JCS_YCbCr;
1179
+ break;
1180
+
1181
+ case EPEG_RGB8:
1182
+ case EPEG_BGR8:
1183
+ case EPEG_RGBA8:
1184
+ case EPEG_BGRA8:
1185
+ case EPEG_ARGB32:
1186
+ im->in.jinfo.out_color_space = JCS_RGB;
1187
+ break;
1188
+
1189
+ case EPEG_CMYK:
1190
+ im->in.jinfo.out_color_space = JCS_CMYK;
1191
+ im->in.jinfo.output_components = 4;
1192
+ break;
1193
+
1194
+ default:
1195
+ break;
1196
+ }
1197
+
1198
+ im->out.jinfo.err = jpeg_std_error(&(im->jerr.pub));
1199
+ im->jerr.pub.error_exit = _epeg_fatal_error_handler;
1200
+ #ifdef NOWARNINGS
1201
+ im->jerr.pub.emit_message = _emit_message;
1202
+ im->jerr.pub.output_message = _output_message;
1203
+ im->jerr.pub.format_message = _format_message;
1204
+ #endif
1205
+
1206
+ if (setjmp(im->jerr.setjmp_buffer)) {
1207
+ im->jerr.pub.format_message((j_common_ptr)&(im->out.jinfo), im->error_msg);
1208
+ return 1;
1209
+ }
1210
+
1211
+ jpeg_calc_output_dimensions(&(im->in.jinfo));
1212
+
1213
+ im->pixels = malloc(im->in.jinfo.output_width * im->in.jinfo.output_height * im->in.jinfo.output_components);
1214
+ if (!im->pixels) {
1215
+ return 1;
1216
+ }
1217
+
1218
+ im->lines = malloc(im->in.jinfo.output_height * sizeof(char *));
1219
+ if (!im->lines) {
1220
+ free(im->pixels);
1221
+ im->pixels = NULL;
1222
+ return 1;
1223
+ }
1224
+
1225
+ jpeg_start_decompress(&(im->in.jinfo));
1226
+
1227
+ for (y = 0; y < im->in.jinfo.output_height; y++) {
1228
+ im->lines[y] = im->pixels + (y * im->in.jinfo.output_components * im->in.jinfo.output_width);
1229
+ }
1230
+
1231
+ while (im->in.jinfo.output_scanline < im->in.jinfo.output_height)
1232
+ jpeg_read_scanlines(&(im->in.jinfo),
1233
+ &(im->lines[im->in.jinfo.output_scanline]),
1234
+ im->in.jinfo.rec_outbuf_height);
1235
+
1236
+ jpeg_finish_decompress(&(im->in.jinfo));
1237
+
1238
+ return 0;
1239
+ }
1240
+
1241
+ static int
1242
+ _epeg_trim(Epeg_Image *im) {
1243
+ int y, a, b, w, h;
1244
+
1245
+ if ((im->in.w == im->out.w) && (im->in.h == im->out.h)) {
1246
+ return 1;
1247
+ }
1248
+ if (im->scaled) {
1249
+ return 1;
1250
+ }
1251
+
1252
+ im->scaled = 1;
1253
+ w = im->out.w;
1254
+ h = im->out.h;
1255
+ a = im->out.x;
1256
+ b = im->out.y;
1257
+
1258
+ for (y = 0; y < h; y++) {
1259
+ im->lines[y] = im->pixels + ((y + b) * im->in.jinfo.output_components * im->in.jinfo.output_width) + (a * im->in.jinfo.output_components);
1260
+ }
1261
+
1262
+ return 0;
1263
+ }
1264
+
1265
+ struct epeg_destination_mgr {
1266
+ struct jpeg_destination_mgr dst_mgr;
1267
+ Epeg_Image *im;
1268
+ unsigned char *buf;
1269
+ };
1270
+
1271
+ static int
1272
+ _epeg_encode(Epeg_Image *im) {
1273
+ struct epeg_destination_mgr *dst_mgr = NULL;
1274
+ int ok = 0;
1275
+
1276
+ if ((im->out.w < 1) || (im->out.h < 1)) {
1277
+ return 1;
1278
+ }
1279
+ if (im->out.f) {
1280
+ return 1;
1281
+ }
1282
+
1283
+ if (im->out.file) {
1284
+ im->out.f = fopen(im->out.file, "wb");
1285
+ if (!im->out.f) {
1286
+ im->error = 1;
1287
+ return 1;
1288
+ }
1289
+ } else {
1290
+ im->out.f = NULL;
1291
+ }
1292
+
1293
+ im->out.jinfo.err = jpeg_std_error(&(im->jerr.pub));
1294
+ im->jerr.pub.error_exit = _epeg_fatal_error_handler;
1295
+ #ifdef NOWARNINGS
1296
+ im->jerr.pub.emit_message = _emit_message;
1297
+ im->jerr.pub.output_message = _output_message;
1298
+ im->jerr.pub.format_message = _format_message;
1299
+ #endif
1300
+
1301
+ if (setjmp(im->jerr.setjmp_buffer)) {
1302
+ im->jerr.pub.format_message((j_common_ptr)&(im->out.jinfo), im->error_msg);
1303
+
1304
+ ok = 1;
1305
+ im->error = 1;
1306
+ goto done;
1307
+ }
1308
+
1309
+ jpeg_create_compress(&(im->out.jinfo));
1310
+ if (im->out.f) {
1311
+ jpeg_stdio_dest(&(im->out.jinfo), im->out.f);
1312
+ } else {
1313
+ *(im->out.mem.data) = NULL;
1314
+ *(im->out.mem.size) = 0;
1315
+ /* Setup RAM destination manager */
1316
+ dst_mgr = calloc(1, sizeof(struct epeg_destination_mgr));
1317
+ if (!dst_mgr) {
1318
+ return 1;
1319
+ }
1320
+ dst_mgr->dst_mgr.init_destination = _jpeg_init_destination;
1321
+ dst_mgr->dst_mgr.empty_output_buffer = _jpeg_empty_output_buffer;
1322
+ dst_mgr->dst_mgr.term_destination = _jpeg_term_destination;
1323
+ dst_mgr->im = im;
1324
+ dst_mgr->buf = malloc(65536);
1325
+ if (!dst_mgr->buf) {
1326
+ ok = 1;
1327
+ im->error = 1;
1328
+ goto done;
1329
+ }
1330
+ im->out.jinfo.dest = (struct jpeg_destination_mgr *)dst_mgr;
1331
+ }
1332
+ im->out.jinfo.image_width = im->out.w;
1333
+ im->out.jinfo.image_height = im->out.h;
1334
+ im->out.jinfo.input_components = im->in.jinfo.output_components;
1335
+ im->out.jinfo.in_color_space = im->in.jinfo.out_color_space;
1336
+ im->out.jinfo.dct_method = im->in.jinfo.dct_method;
1337
+ jpeg_set_defaults(&(im->out.jinfo));
1338
+ jpeg_set_quality(&(im->out.jinfo), im->out.quality, TRUE);
1339
+
1340
+ if (im->out.quality >= 90) {
1341
+ im->out.jinfo.comp_info[0].h_samp_factor = 1;
1342
+ im->out.jinfo.comp_info[0].v_samp_factor = 1;
1343
+ im->out.jinfo.comp_info[1].h_samp_factor = 1;
1344
+ im->out.jinfo.comp_info[1].v_samp_factor = 1;
1345
+ im->out.jinfo.comp_info[2].h_samp_factor = 1;
1346
+ im->out.jinfo.comp_info[2].v_samp_factor = 1;
1347
+ }
1348
+ jpeg_start_compress(&(im->out.jinfo), TRUE);
1349
+
1350
+ if (im->out.comment) {
1351
+ jpeg_write_marker(&(im->out.jinfo), JPEG_COM, im->out.comment, strlen(im->out.comment));
1352
+ }
1353
+
1354
+ if (im->out.thumbnail_info) {
1355
+ char buf[8192];
1356
+
1357
+ if (im->in.file) {
1358
+ snprintf(buf, sizeof(buf), "Thumb::URI\nfile://%s", im->in.file);
1359
+ jpeg_write_marker(&(im->out.jinfo), JPEG_APP0 + 7, buf, strlen(buf));
1360
+ snprintf(buf, sizeof(buf), "Thumb::MTime\n%llu", (unsigned long long int)im->stat_info.st_mtime);
1361
+ }
1362
+ jpeg_write_marker(&(im->out.jinfo), JPEG_APP0 + 7, buf, strlen(buf));
1363
+ snprintf(buf, sizeof(buf), "Thumb::Image::Width\n%i", im->in.w);
1364
+ jpeg_write_marker(&(im->out.jinfo), JPEG_APP0 + 7, buf, strlen(buf));
1365
+ snprintf(buf, sizeof(buf), "Thumb::Image::Height\n%i", im->in.h);
1366
+ jpeg_write_marker(&(im->out.jinfo), JPEG_APP0 + 7, buf, strlen(buf));
1367
+ snprintf(buf, sizeof(buf), "Thumb::Mimetype\nimage/jpeg");
1368
+ jpeg_write_marker(&(im->out.jinfo), JPEG_APP0 + 7, buf, strlen(buf));
1369
+ }
1370
+
1371
+ while (im->out.jinfo.next_scanline < im->out.h) {
1372
+ jpeg_write_scanlines(&(im->out.jinfo), &(im->lines[im->out.jinfo.next_scanline]), 1);
1373
+ }
1374
+ jpeg_finish_compress(&(im->out.jinfo));
1375
+
1376
+ done:
1377
+ if ((im->in.f) || (im->in.mem.data != NULL)) {
1378
+ jpeg_destroy_decompress(&(im->in.jinfo));
1379
+ }
1380
+ if ((im->in.f) && (im->in.file)) {
1381
+ fclose(im->in.f);
1382
+ }
1383
+ if (dst_mgr) {
1384
+ if (dst_mgr->buf) {
1385
+ free(dst_mgr->buf);
1386
+ }
1387
+ free(dst_mgr);
1388
+ im->out.jinfo.dest = NULL;
1389
+ }
1390
+ jpeg_destroy_compress(&(im->out.jinfo));
1391
+ if ((im->out.f) && (im->out.file)) {
1392
+ fclose(im->out.f);
1393
+ }
1394
+ im->in.f = NULL;
1395
+ im->out.f = NULL;
1396
+
1397
+ return ok;
1398
+ }
1399
+
1400
+ static int
1401
+ _epeg_transform(Epeg_Image *im) {
1402
+ jvirt_barray_ptr * src_coef_arrays;
1403
+ jvirt_barray_ptr * dst_coef_arrays;
1404
+ JCOPY_OPTION copyoption;
1405
+ jpeg_transform_info transformoption;
1406
+ memset(&transformoption, 0, sizeof(jpeg_transform_info));
1407
+
1408
+ copyoption = JCOPYOPT_NONE;
1409
+ transformoption.crop = FALSE;
1410
+ transformoption.trim = TRUE;
1411
+ transformoption.force_grayscale = FALSE;
1412
+
1413
+ switch(im->out.transform) {
1414
+ case EPEG_TRANSFORM_NONE:
1415
+ transformoption.transform = JXFORM_NONE;
1416
+ break;
1417
+ case EPEG_TRANSFORM_FLIP_H:
1418
+ transformoption.transform = JXFORM_FLIP_H;
1419
+ break;
1420
+ case EPEG_TRANSFORM_FLIP_V:
1421
+ transformoption.transform = JXFORM_FLIP_V;
1422
+ break;
1423
+ case EPEG_TRANSFORM_TRANSPOSE:
1424
+ transformoption.transform = JXFORM_TRANSPOSE;
1425
+ break;
1426
+ case EPEG_TRANSFORM_TRANSVERSE:
1427
+ transformoption.transform = JXFORM_TRANSVERSE;
1428
+ break;
1429
+ case EPEG_TRANSFORM_ROT_90:
1430
+ transformoption.transform = JXFORM_ROT_90;
1431
+ break;
1432
+ case EPEG_TRANSFORM_ROT_180:
1433
+ transformoption.transform = JXFORM_ROT_180;
1434
+ break;
1435
+ case EPEG_TRANSFORM_ROT_270:
1436
+ transformoption.transform = JXFORM_ROT_270;
1437
+ break;
1438
+ default:
1439
+ return 1;
1440
+ }
1441
+
1442
+ struct epeg_destination_mgr *dst_mgr = NULL;
1443
+ int ok = 0;
1444
+
1445
+ if ((im->out.w < 1) || (im->out.h < 1)) {
1446
+ return 1;
1447
+ }
1448
+ if (im->out.f) {
1449
+ return 1;
1450
+ }
1451
+
1452
+ if (im->out.file) {
1453
+ im->out.f = fopen(im->out.file, "wb");
1454
+ if (!im->out.f) {
1455
+ im->error = 1;
1456
+ return 1;
1457
+ }
1458
+ } else {
1459
+ im->out.f = NULL;
1460
+ }
1461
+
1462
+ im->out.jinfo.err = jpeg_std_error(&(im->jerr.pub));
1463
+ im->jerr.pub.error_exit = _epeg_fatal_error_handler;
1464
+ #ifdef NOWARNINGS
1465
+ im->jerr.pub.emit_message = _emit_message;
1466
+ im->jerr.pub.output_message = _output_message;
1467
+ im->jerr.pub.format_message = _format_message;
1468
+ #endif
1469
+
1470
+ if (setjmp(im->jerr.setjmp_buffer)) {
1471
+ im->jerr.pub.format_message((j_common_ptr)&(im->out.jinfo), im->error_msg);
1472
+
1473
+ ok = 1;
1474
+ im->error = 1;
1475
+ goto done;
1476
+ }
1477
+
1478
+ jpeg_create_compress(&(im->out.jinfo));
1479
+ if (im->out.f) {
1480
+ jpeg_stdio_dest(&(im->out.jinfo), im->out.f);
1481
+ } else {
1482
+ *(im->out.mem.data) = NULL;
1483
+ *(im->out.mem.size) = 0;
1484
+ /* Setup RAM destination manager */
1485
+ dst_mgr = calloc(1, sizeof(struct epeg_destination_mgr));
1486
+ if (!dst_mgr) {
1487
+ return 1;
1488
+ }
1489
+ dst_mgr->dst_mgr.init_destination = _jpeg_init_destination;
1490
+ dst_mgr->dst_mgr.empty_output_buffer = _jpeg_empty_output_buffer;
1491
+ dst_mgr->dst_mgr.term_destination = _jpeg_term_destination;
1492
+ dst_mgr->im = im;
1493
+ dst_mgr->buf = malloc(65536);
1494
+ if (!dst_mgr->buf) {
1495
+ ok = 1;
1496
+ im->error = 1;
1497
+ goto done;
1498
+ }
1499
+ im->out.jinfo.dest = (struct jpeg_destination_mgr *)dst_mgr;
1500
+ }
1501
+
1502
+ jcopy_markers_setup(&(im->in.jinfo), copyoption);
1503
+ jtransform_request_workspace(&(im->in.jinfo), &transformoption);
1504
+ src_coef_arrays = jpeg_read_coefficients(&(im->in.jinfo));
1505
+ jpeg_copy_critical_parameters(&(im->in.jinfo), &(im->out.jinfo));
1506
+ im->out.jinfo.write_JFIF_header = FALSE; // for Exif format
1507
+ dst_coef_arrays = jtransform_adjust_parameters(&(im->in.jinfo), &(im->out.jinfo),
1508
+ src_coef_arrays, &transformoption);
1509
+ jpeg_write_coefficients(&(im->out.jinfo), dst_coef_arrays);
1510
+ jcopy_markers_execute(&(im->in.jinfo), &(im->out.jinfo), copyoption);
1511
+ jtransform_execute_transformation(&(im->in.jinfo), &(im->out.jinfo),
1512
+ src_coef_arrays, &transformoption);
1513
+ jpeg_finish_compress(&(im->out.jinfo));
1514
+
1515
+ done:
1516
+ if ((im->in.f) || (im->in.mem.data != NULL)) {
1517
+ jpeg_destroy_decompress(&(im->in.jinfo));
1518
+ }
1519
+ if ((im->in.f) && (im->in.file)) {
1520
+ fclose(im->in.f);
1521
+ }
1522
+ if (dst_mgr) {
1523
+ if (dst_mgr->buf) {
1524
+ free(dst_mgr->buf);
1525
+ }
1526
+ free(dst_mgr);
1527
+ im->out.jinfo.dest = NULL;
1528
+ }
1529
+ jpeg_destroy_compress(&(im->out.jinfo));
1530
+ if ((im->out.f) && (im->out.file)) {
1531
+ fclose(im->out.f);
1532
+ }
1533
+ im->in.f = NULL;
1534
+ im->out.f = NULL;
1535
+
1536
+ return ok;
1537
+ }
1538
+
1539
+ static void
1540
+ _epeg_fatal_error_handler(j_common_ptr cinfo) {
1541
+ emptr errmgr;
1542
+
1543
+ errmgr = (emptr)cinfo->err;
1544
+ longjmp(errmgr->setjmp_buffer, 1);
1545
+ return;
1546
+ }
1547
+
1548
+ /* Source manager methods */
1549
+ METHODDEF(void)
1550
+ _jpeg_decompress_error_exit(j_common_ptr cinfo) {
1551
+ }
1552
+
1553
+
1554
+ METHODDEF(void)
1555
+ _jpeg_init_source(j_decompress_ptr cinfo) {
1556
+ }
1557
+
1558
+ METHODDEF(boolean)
1559
+ _jpeg_fill_input_buffer(j_decompress_ptr cinfo) {
1560
+ WARNMS(cinfo, JWRN_JPEG_EOF);
1561
+
1562
+ /* Insert a fake EOI marker */
1563
+ cinfo->src->next_input_byte = fake_EOI;
1564
+ cinfo->src->bytes_in_buffer = sizeof(fake_EOI);
1565
+ return TRUE;
1566
+ }
1567
+
1568
+
1569
+ METHODDEF(void)
1570
+ _jpeg_skip_input_data(j_decompress_ptr cinfo, long num_bytes) {
1571
+ if (num_bytes > (long)(cinfo)->src->bytes_in_buffer) {
1572
+ ERREXIT(cinfo, 0);
1573
+ }
1574
+
1575
+ (cinfo)->src->next_input_byte += num_bytes;
1576
+ (cinfo)->src->bytes_in_buffer -= num_bytes;
1577
+ }
1578
+
1579
+ METHODDEF(void)
1580
+ _jpeg_term_source(j_decompress_ptr cinfo) {
1581
+ }
1582
+
1583
+
1584
+ /* destination manager methods */
1585
+ METHODDEF(void)
1586
+ _jpeg_init_destination(j_compress_ptr cinfo) {
1587
+ struct epeg_destination_mgr *dst_mgr;
1588
+
1589
+ dst_mgr = (struct epeg_destination_mgr *)cinfo->dest;
1590
+ dst_mgr->dst_mgr.free_in_buffer = 65536;
1591
+ dst_mgr->dst_mgr.next_output_byte = (JOCTET *)dst_mgr->buf;
1592
+ }
1593
+
1594
+ METHODDEF(boolean)
1595
+ _jpeg_empty_output_buffer(j_compress_ptr cinfo) {
1596
+ struct epeg_destination_mgr *dst_mgr;
1597
+ unsigned char *p;
1598
+ int psize;
1599
+
1600
+ dst_mgr = (struct epeg_destination_mgr *)cinfo->dest;
1601
+ psize = *(dst_mgr->im->out.mem.size);
1602
+ *(dst_mgr->im->out.mem.size) += 65536;
1603
+ p = realloc(*(dst_mgr->im->out.mem.data), *(dst_mgr->im->out.mem.size));
1604
+ if (p) {
1605
+ *(dst_mgr->im->out.mem.data) = p;
1606
+ memcpy(p + psize, dst_mgr->buf, 65536);
1607
+ dst_mgr->dst_mgr.free_in_buffer = 65536;
1608
+ dst_mgr->dst_mgr.next_output_byte = (JOCTET *)dst_mgr->buf;
1609
+ } else {
1610
+ return FALSE;
1611
+ }
1612
+ return TRUE;
1613
+ }
1614
+
1615
+ METHODDEF(void)
1616
+ _jpeg_term_destination(j_compress_ptr cinfo) {
1617
+ struct epeg_destination_mgr *dst_mgr;
1618
+ unsigned char *p;
1619
+ int psize;
1620
+
1621
+ dst_mgr = (struct epeg_destination_mgr *)cinfo->dest;
1622
+ psize = *(dst_mgr->im->out.mem.size);
1623
+ *(dst_mgr->im->out.mem.size) += 65536 - dst_mgr->dst_mgr.free_in_buffer;
1624
+ p = realloc(*(dst_mgr->im->out.mem.data), *(dst_mgr->im->out.mem.size));
1625
+ if (p) {
1626
+ *(dst_mgr->im->out.mem.data) = p;
1627
+ memcpy(p + psize, dst_mgr->buf, 65536 - dst_mgr->dst_mgr.free_in_buffer);
1628
+ }
1629
+ }
1630
+
1631
+ /* be noisy - not */
1632
+ METHODDEF(void)
1633
+ _emit_message(j_common_ptr cinfo, int msg_level) {
1634
+ }
1635
+
1636
+ METHODDEF(void)
1637
+ _output_message(j_common_ptr cinfo) {
1638
+ }
1639
+
1640
+ METHODDEF(void)
1641
+ _format_message(j_common_ptr cinfo, char *buffer) {
1642
+ }