epeg 1.0

Sign up to get free protection for your applications and to get access to all the features.
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,1105 @@
1
+ /*
2
+ * jcphuff.c
3
+ *
4
+ * This file was part of the Independent JPEG Group's software:
5
+ * Copyright (C) 1995-1997, Thomas G. Lane.
6
+ * libjpeg-turbo Modifications:
7
+ * Copyright (C) 2011, 2015, 2018, D. R. Commander.
8
+ * Copyright (C) 2016, 2018, Matthieu Darbois.
9
+ * For conditions of distribution and use, see the accompanying README.ijg
10
+ * file.
11
+ *
12
+ * This file contains Huffman entropy encoding routines for progressive JPEG.
13
+ *
14
+ * We do not support output suspension in this module, since the library
15
+ * currently does not allow multiple-scan files to be written with output
16
+ * suspension.
17
+ */
18
+
19
+ #define JPEG_INTERNALS
20
+ #include "jinclude.h"
21
+ #include "jpeglib.h"
22
+ #include "jsimd.h"
23
+ #include "jconfigint.h"
24
+ #include <limits.h>
25
+
26
+ #ifdef HAVE_INTRIN_H
27
+ #include <intrin.h>
28
+ #ifdef _MSC_VER
29
+ #ifdef HAVE_BITSCANFORWARD64
30
+ #pragma intrinsic(_BitScanForward64)
31
+ #endif
32
+ #ifdef HAVE_BITSCANFORWARD
33
+ #pragma intrinsic(_BitScanForward)
34
+ #endif
35
+ #endif
36
+ #endif
37
+
38
+ #ifdef C_PROGRESSIVE_SUPPORTED
39
+
40
+ /*
41
+ * NOTE: If USE_CLZ_INTRINSIC is defined, then clz/bsr instructions will be
42
+ * used for bit counting rather than the lookup table. This will reduce the
43
+ * memory footprint by 64k, which is important for some mobile applications
44
+ * that create many isolated instances of libjpeg-turbo (web browsers, for
45
+ * instance.) This may improve performance on some mobile platforms as well.
46
+ * This feature is enabled by default only on ARM processors, because some x86
47
+ * chips have a slow implementation of bsr, and the use of clz/bsr cannot be
48
+ * shown to have a significant performance impact even on the x86 chips that
49
+ * have a fast implementation of it. When building for ARMv6, you can
50
+ * explicitly disable the use of clz/bsr by adding -mthumb to the compiler
51
+ * flags (this defines __thumb__).
52
+ */
53
+
54
+ /* NOTE: Both GCC and Clang define __GNUC__ */
55
+ #if defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))
56
+ #if !defined(__thumb__) || defined(__thumb2__)
57
+ #define USE_CLZ_INTRINSIC
58
+ #endif
59
+ #endif
60
+
61
+ #ifdef USE_CLZ_INTRINSIC
62
+ #define JPEG_NBITS_NONZERO(x) (32 - __builtin_clz(x))
63
+ #define JPEG_NBITS(x) (x ? JPEG_NBITS_NONZERO(x) : 0)
64
+ #else
65
+ #include "jpeg_nbits_table.h"
66
+ #define JPEG_NBITS(x) (jpeg_nbits_table[x])
67
+ #define JPEG_NBITS_NONZERO(x) JPEG_NBITS(x)
68
+ #endif
69
+
70
+
71
+ /* Expanded entropy encoder object for progressive Huffman encoding. */
72
+
73
+ typedef struct {
74
+ struct jpeg_entropy_encoder pub; /* public fields */
75
+
76
+ /* Pointer to routine to prepare data for encode_mcu_AC_first() */
77
+ void (*AC_first_prepare) (const JCOEF *block,
78
+ const int *jpeg_natural_order_start, int Sl,
79
+ int Al, JCOEF *values, size_t *zerobits);
80
+ /* Pointer to routine to prepare data for encode_mcu_AC_refine() */
81
+ int (*AC_refine_prepare) (const JCOEF *block,
82
+ const int *jpeg_natural_order_start, int Sl,
83
+ int Al, JCOEF *absvalues, size_t *bits);
84
+
85
+ /* Mode flag: TRUE for optimization, FALSE for actual data output */
86
+ boolean gather_statistics;
87
+
88
+ /* Bit-level coding status.
89
+ * next_output_byte/free_in_buffer are local copies of cinfo->dest fields.
90
+ */
91
+ JOCTET *next_output_byte; /* => next byte to write in buffer */
92
+ size_t free_in_buffer; /* # of byte spaces remaining in buffer */
93
+ size_t put_buffer; /* current bit-accumulation buffer */
94
+ int put_bits; /* # of bits now in it */
95
+ j_compress_ptr cinfo; /* link to cinfo (needed for dump_buffer) */
96
+
97
+ /* Coding status for DC components */
98
+ int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
99
+
100
+ /* Coding status for AC components */
101
+ int ac_tbl_no; /* the table number of the single component */
102
+ unsigned int EOBRUN; /* run length of EOBs */
103
+ unsigned int BE; /* # of buffered correction bits before MCU */
104
+ char *bit_buffer; /* buffer for correction bits (1 per char) */
105
+ /* packing correction bits tightly would save some space but cost time... */
106
+
107
+ unsigned int restarts_to_go; /* MCUs left in this restart interval */
108
+ int next_restart_num; /* next restart number to write (0-7) */
109
+
110
+ /* Pointers to derived tables (these workspaces have image lifespan).
111
+ * Since any one scan codes only DC or only AC, we only need one set
112
+ * of tables, not one for DC and one for AC.
113
+ */
114
+ c_derived_tbl *derived_tbls[NUM_HUFF_TBLS];
115
+
116
+ /* Statistics tables for optimization; again, one set is enough */
117
+ long *count_ptrs[NUM_HUFF_TBLS];
118
+ } phuff_entropy_encoder;
119
+
120
+ typedef phuff_entropy_encoder *phuff_entropy_ptr;
121
+
122
+ /* MAX_CORR_BITS is the number of bits the AC refinement correction-bit
123
+ * buffer can hold. Larger sizes may slightly improve compression, but
124
+ * 1000 is already well into the realm of overkill.
125
+ * The minimum safe size is 64 bits.
126
+ */
127
+
128
+ #define MAX_CORR_BITS 1000 /* Max # of correction bits I can buffer */
129
+
130
+ /* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than JLONG.
131
+ * We assume that int right shift is unsigned if JLONG right shift is,
132
+ * which should be safe.
133
+ */
134
+
135
+ #ifdef RIGHT_SHIFT_IS_UNSIGNED
136
+ #define ISHIFT_TEMPS int ishift_temp;
137
+ #define IRIGHT_SHIFT(x, shft) \
138
+ ((ishift_temp = (x)) < 0 ? \
139
+ (ishift_temp >> (shft)) | ((~0) << (16 - (shft))) : \
140
+ (ishift_temp >> (shft)))
141
+ #else
142
+ #define ISHIFT_TEMPS
143
+ #define IRIGHT_SHIFT(x, shft) ((x) >> (shft))
144
+ #endif
145
+
146
+ #define PAD(v, p) ((v + (p) - 1) & (~((p) - 1)))
147
+
148
+ /* Forward declarations */
149
+ METHODDEF(boolean) encode_mcu_DC_first(j_compress_ptr cinfo,
150
+ JBLOCKROW *MCU_data);
151
+ METHODDEF(void) encode_mcu_AC_first_prepare
152
+ (const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
153
+ JCOEF *values, size_t *zerobits);
154
+ METHODDEF(boolean) encode_mcu_AC_first(j_compress_ptr cinfo,
155
+ JBLOCKROW *MCU_data);
156
+ METHODDEF(boolean) encode_mcu_DC_refine(j_compress_ptr cinfo,
157
+ JBLOCKROW *MCU_data);
158
+ METHODDEF(int) encode_mcu_AC_refine_prepare
159
+ (const JCOEF *block, const int *jpeg_natural_order_start, int Sl, int Al,
160
+ JCOEF *absvalues, size_t *bits);
161
+ METHODDEF(boolean) encode_mcu_AC_refine(j_compress_ptr cinfo,
162
+ JBLOCKROW *MCU_data);
163
+ METHODDEF(void) finish_pass_phuff(j_compress_ptr cinfo);
164
+ METHODDEF(void) finish_pass_gather_phuff(j_compress_ptr cinfo);
165
+
166
+
167
+ /* Count bit loop zeroes */
168
+ INLINE
169
+ METHODDEF(int)
170
+ count_zeroes(size_t *x)
171
+ {
172
+ int result;
173
+ #if defined(HAVE_BUILTIN_CTZL)
174
+ result = __builtin_ctzl(*x);
175
+ *x >>= result;
176
+ #elif defined(HAVE_BITSCANFORWARD64)
177
+ _BitScanForward64(&result, *x);
178
+ *x >>= result;
179
+ #elif defined(HAVE_BITSCANFORWARD)
180
+ _BitScanForward(&result, *x);
181
+ *x >>= result;
182
+ #else
183
+ result = 0;
184
+ while ((*x & 1) == 0) {
185
+ ++result;
186
+ *x >>= 1;
187
+ }
188
+ #endif
189
+ return result;
190
+ }
191
+
192
+
193
+ /*
194
+ * Initialize for a Huffman-compressed scan using progressive JPEG.
195
+ */
196
+
197
+ METHODDEF(void)
198
+ start_pass_phuff(j_compress_ptr cinfo, boolean gather_statistics)
199
+ {
200
+ phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
201
+ boolean is_DC_band;
202
+ int ci, tbl;
203
+ jpeg_component_info *compptr;
204
+
205
+ entropy->cinfo = cinfo;
206
+ entropy->gather_statistics = gather_statistics;
207
+
208
+ is_DC_band = (cinfo->Ss == 0);
209
+
210
+ /* We assume jcmaster.c already validated the scan parameters. */
211
+
212
+ /* Select execution routines */
213
+ if (cinfo->Ah == 0) {
214
+ if (is_DC_band)
215
+ entropy->pub.encode_mcu = encode_mcu_DC_first;
216
+ else
217
+ entropy->pub.encode_mcu = encode_mcu_AC_first;
218
+ if (jsimd_can_encode_mcu_AC_first_prepare())
219
+ entropy->AC_first_prepare = jsimd_encode_mcu_AC_first_prepare;
220
+ else
221
+ entropy->AC_first_prepare = encode_mcu_AC_first_prepare;
222
+ } else {
223
+ if (is_DC_band)
224
+ entropy->pub.encode_mcu = encode_mcu_DC_refine;
225
+ else {
226
+ entropy->pub.encode_mcu = encode_mcu_AC_refine;
227
+ if (jsimd_can_encode_mcu_AC_refine_prepare())
228
+ entropy->AC_refine_prepare = jsimd_encode_mcu_AC_refine_prepare;
229
+ else
230
+ entropy->AC_refine_prepare = encode_mcu_AC_refine_prepare;
231
+ /* AC refinement needs a correction bit buffer */
232
+ if (entropy->bit_buffer == NULL)
233
+ entropy->bit_buffer = (char *)
234
+ (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
235
+ MAX_CORR_BITS * sizeof(char));
236
+ }
237
+ }
238
+ if (gather_statistics)
239
+ entropy->pub.finish_pass = finish_pass_gather_phuff;
240
+ else
241
+ entropy->pub.finish_pass = finish_pass_phuff;
242
+
243
+ /* Only DC coefficients may be interleaved, so cinfo->comps_in_scan = 1
244
+ * for AC coefficients.
245
+ */
246
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
247
+ compptr = cinfo->cur_comp_info[ci];
248
+ /* Initialize DC predictions to 0 */
249
+ entropy->last_dc_val[ci] = 0;
250
+ /* Get table index */
251
+ if (is_DC_band) {
252
+ if (cinfo->Ah != 0) /* DC refinement needs no table */
253
+ continue;
254
+ tbl = compptr->dc_tbl_no;
255
+ } else {
256
+ entropy->ac_tbl_no = tbl = compptr->ac_tbl_no;
257
+ }
258
+ if (gather_statistics) {
259
+ /* Check for invalid table index */
260
+ /* (make_c_derived_tbl does this in the other path) */
261
+ if (tbl < 0 || tbl >= NUM_HUFF_TBLS)
262
+ ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);
263
+ /* Allocate and zero the statistics tables */
264
+ /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */
265
+ if (entropy->count_ptrs[tbl] == NULL)
266
+ entropy->count_ptrs[tbl] = (long *)
267
+ (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
268
+ 257 * sizeof(long));
269
+ MEMZERO(entropy->count_ptrs[tbl], 257 * sizeof(long));
270
+ } else {
271
+ /* Compute derived values for Huffman table */
272
+ /* We may do this more than once for a table, but it's not expensive */
273
+ jpeg_make_c_derived_tbl(cinfo, is_DC_band, tbl,
274
+ &entropy->derived_tbls[tbl]);
275
+ }
276
+ }
277
+
278
+ /* Initialize AC stuff */
279
+ entropy->EOBRUN = 0;
280
+ entropy->BE = 0;
281
+
282
+ /* Initialize bit buffer to empty */
283
+ entropy->put_buffer = 0;
284
+ entropy->put_bits = 0;
285
+
286
+ /* Initialize restart stuff */
287
+ entropy->restarts_to_go = cinfo->restart_interval;
288
+ entropy->next_restart_num = 0;
289
+ }
290
+
291
+
292
+ /* Outputting bytes to the file.
293
+ * NB: these must be called only when actually outputting,
294
+ * that is, entropy->gather_statistics == FALSE.
295
+ */
296
+
297
+ /* Emit a byte */
298
+ #define emit_byte(entropy, val) { \
299
+ *(entropy)->next_output_byte++ = (JOCTET)(val); \
300
+ if (--(entropy)->free_in_buffer == 0) \
301
+ dump_buffer(entropy); \
302
+ }
303
+
304
+
305
+ LOCAL(void)
306
+ dump_buffer(phuff_entropy_ptr entropy)
307
+ /* Empty the output buffer; we do not support suspension in this module. */
308
+ {
309
+ struct jpeg_destination_mgr *dest = entropy->cinfo->dest;
310
+
311
+ if (!(*dest->empty_output_buffer) (entropy->cinfo))
312
+ ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND);
313
+ /* After a successful buffer dump, must reset buffer pointers */
314
+ entropy->next_output_byte = dest->next_output_byte;
315
+ entropy->free_in_buffer = dest->free_in_buffer;
316
+ }
317
+
318
+
319
+ /* Outputting bits to the file */
320
+
321
+ /* Only the right 24 bits of put_buffer are used; the valid bits are
322
+ * left-justified in this part. At most 16 bits can be passed to emit_bits
323
+ * in one call, and we never retain more than 7 bits in put_buffer
324
+ * between calls, so 24 bits are sufficient.
325
+ */
326
+
327
+ LOCAL(void)
328
+ emit_bits(phuff_entropy_ptr entropy, unsigned int code, int size)
329
+ /* Emit some bits, unless we are in gather mode */
330
+ {
331
+ /* This routine is heavily used, so it's worth coding tightly. */
332
+ register size_t put_buffer = (size_t)code;
333
+ register int put_bits = entropy->put_bits;
334
+
335
+ /* if size is 0, caller used an invalid Huffman table entry */
336
+ if (size == 0)
337
+ ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);
338
+
339
+ if (entropy->gather_statistics)
340
+ return; /* do nothing if we're only getting stats */
341
+
342
+ put_buffer &= (((size_t)1) << size) - 1; /* mask off any extra bits in code */
343
+
344
+ put_bits += size; /* new number of bits in buffer */
345
+
346
+ put_buffer <<= 24 - put_bits; /* align incoming bits */
347
+
348
+ put_buffer |= entropy->put_buffer; /* and merge with old buffer contents */
349
+
350
+ while (put_bits >= 8) {
351
+ int c = (int)((put_buffer >> 16) & 0xFF);
352
+
353
+ emit_byte(entropy, c);
354
+ if (c == 0xFF) { /* need to stuff a zero byte? */
355
+ emit_byte(entropy, 0);
356
+ }
357
+ put_buffer <<= 8;
358
+ put_bits -= 8;
359
+ }
360
+
361
+ entropy->put_buffer = put_buffer; /* update variables */
362
+ entropy->put_bits = put_bits;
363
+ }
364
+
365
+
366
+ LOCAL(void)
367
+ flush_bits(phuff_entropy_ptr entropy)
368
+ {
369
+ emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */
370
+ entropy->put_buffer = 0; /* and reset bit-buffer to empty */
371
+ entropy->put_bits = 0;
372
+ }
373
+
374
+
375
+ /*
376
+ * Emit (or just count) a Huffman symbol.
377
+ */
378
+
379
+ LOCAL(void)
380
+ emit_symbol(phuff_entropy_ptr entropy, int tbl_no, int symbol)
381
+ {
382
+ if (entropy->gather_statistics)
383
+ entropy->count_ptrs[tbl_no][symbol]++;
384
+ else {
385
+ c_derived_tbl *tbl = entropy->derived_tbls[tbl_no];
386
+ emit_bits(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]);
387
+ }
388
+ }
389
+
390
+
391
+ /*
392
+ * Emit bits from a correction bit buffer.
393
+ */
394
+
395
+ LOCAL(void)
396
+ emit_buffered_bits(phuff_entropy_ptr entropy, char *bufstart,
397
+ unsigned int nbits)
398
+ {
399
+ if (entropy->gather_statistics)
400
+ return; /* no real work */
401
+
402
+ while (nbits > 0) {
403
+ emit_bits(entropy, (unsigned int)(*bufstart), 1);
404
+ bufstart++;
405
+ nbits--;
406
+ }
407
+ }
408
+
409
+
410
+ /*
411
+ * Emit any pending EOBRUN symbol.
412
+ */
413
+
414
+ LOCAL(void)
415
+ emit_eobrun(phuff_entropy_ptr entropy)
416
+ {
417
+ register int temp, nbits;
418
+
419
+ if (entropy->EOBRUN > 0) { /* if there is any pending EOBRUN */
420
+ temp = entropy->EOBRUN;
421
+ nbits = JPEG_NBITS_NONZERO(temp) - 1;
422
+ /* safety check: shouldn't happen given limited correction-bit buffer */
423
+ if (nbits > 14)
424
+ ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);
425
+
426
+ emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4);
427
+ if (nbits)
428
+ emit_bits(entropy, entropy->EOBRUN, nbits);
429
+
430
+ entropy->EOBRUN = 0;
431
+
432
+ /* Emit any buffered correction bits */
433
+ emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE);
434
+ entropy->BE = 0;
435
+ }
436
+ }
437
+
438
+
439
+ /*
440
+ * Emit a restart marker & resynchronize predictions.
441
+ */
442
+
443
+ LOCAL(void)
444
+ emit_restart(phuff_entropy_ptr entropy, int restart_num)
445
+ {
446
+ int ci;
447
+
448
+ emit_eobrun(entropy);
449
+
450
+ if (!entropy->gather_statistics) {
451
+ flush_bits(entropy);
452
+ emit_byte(entropy, 0xFF);
453
+ emit_byte(entropy, JPEG_RST0 + restart_num);
454
+ }
455
+
456
+ if (entropy->cinfo->Ss == 0) {
457
+ /* Re-initialize DC predictions to 0 */
458
+ for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++)
459
+ entropy->last_dc_val[ci] = 0;
460
+ } else {
461
+ /* Re-initialize all AC-related fields to 0 */
462
+ entropy->EOBRUN = 0;
463
+ entropy->BE = 0;
464
+ }
465
+ }
466
+
467
+
468
+ /*
469
+ * MCU encoding for DC initial scan (either spectral selection,
470
+ * or first pass of successive approximation).
471
+ */
472
+
473
+ METHODDEF(boolean)
474
+ encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
475
+ {
476
+ phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
477
+ register int temp, temp2, temp3;
478
+ register int nbits;
479
+ int blkn, ci;
480
+ int Al = cinfo->Al;
481
+ JBLOCKROW block;
482
+ jpeg_component_info *compptr;
483
+ ISHIFT_TEMPS
484
+
485
+ entropy->next_output_byte = cinfo->dest->next_output_byte;
486
+ entropy->free_in_buffer = cinfo->dest->free_in_buffer;
487
+
488
+ /* Emit restart marker if needed */
489
+ if (cinfo->restart_interval)
490
+ if (entropy->restarts_to_go == 0)
491
+ emit_restart(entropy, entropy->next_restart_num);
492
+
493
+ /* Encode the MCU data blocks */
494
+ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
495
+ block = MCU_data[blkn];
496
+ ci = cinfo->MCU_membership[blkn];
497
+ compptr = cinfo->cur_comp_info[ci];
498
+
499
+ /* Compute the DC value after the required point transform by Al.
500
+ * This is simply an arithmetic right shift.
501
+ */
502
+ temp2 = IRIGHT_SHIFT((int)((*block)[0]), Al);
503
+
504
+ /* DC differences are figured on the point-transformed values. */
505
+ temp = temp2 - entropy->last_dc_val[ci];
506
+ entropy->last_dc_val[ci] = temp2;
507
+
508
+ /* Encode the DC coefficient difference per section G.1.2.1 */
509
+
510
+ /* This is a well-known technique for obtaining the absolute value without
511
+ * a branch. It is derived from an assembly language technique presented
512
+ * in "How to Optimize for the Pentium Processors", Copyright (c) 1996,
513
+ * 1997 by Agner Fog.
514
+ */
515
+ temp3 = temp >> (CHAR_BIT * sizeof(int) - 1);
516
+ temp ^= temp3;
517
+ temp -= temp3; /* temp is abs value of input */
518
+ /* For a negative input, want temp2 = bitwise complement of abs(input) */
519
+ temp2 = temp ^ temp3;
520
+
521
+ /* Find the number of bits needed for the magnitude of the coefficient */
522
+ nbits = JPEG_NBITS(temp);
523
+ /* Check for out-of-range coefficient values.
524
+ * Since we're encoding a difference, the range limit is twice as much.
525
+ */
526
+ if (nbits > MAX_COEF_BITS + 1)
527
+ ERREXIT(cinfo, JERR_BAD_DCT_COEF);
528
+
529
+ /* Count/emit the Huffman-coded symbol for the number of bits */
530
+ emit_symbol(entropy, compptr->dc_tbl_no, nbits);
531
+
532
+ /* Emit that number of bits of the value, if positive, */
533
+ /* or the complement of its magnitude, if negative. */
534
+ if (nbits) /* emit_bits rejects calls with size 0 */
535
+ emit_bits(entropy, (unsigned int)temp2, nbits);
536
+ }
537
+
538
+ cinfo->dest->next_output_byte = entropy->next_output_byte;
539
+ cinfo->dest->free_in_buffer = entropy->free_in_buffer;
540
+
541
+ /* Update restart-interval state too */
542
+ if (cinfo->restart_interval) {
543
+ if (entropy->restarts_to_go == 0) {
544
+ entropy->restarts_to_go = cinfo->restart_interval;
545
+ entropy->next_restart_num++;
546
+ entropy->next_restart_num &= 7;
547
+ }
548
+ entropy->restarts_to_go--;
549
+ }
550
+
551
+ return TRUE;
552
+ }
553
+
554
+
555
+ /*
556
+ * Data preparation for encode_mcu_AC_first().
557
+ */
558
+
559
+ #define COMPUTE_ABSVALUES_AC_FIRST(Sl) { \
560
+ for (k = 0; k < Sl; k++) { \
561
+ temp = block[jpeg_natural_order_start[k]]; \
562
+ if (temp == 0) \
563
+ continue; \
564
+ /* We must apply the point transform by Al. For AC coefficients this \
565
+ * is an integer division with rounding towards 0. To do this portably \
566
+ * in C, we shift after obtaining the absolute value; so the code is \
567
+ * interwoven with finding the abs value (temp) and output bits (temp2). \
568
+ */ \
569
+ temp2 = temp >> (CHAR_BIT * sizeof(int) - 1); \
570
+ temp ^= temp2; \
571
+ temp -= temp2; /* temp is abs value of input */ \
572
+ temp >>= Al; /* apply the point transform */ \
573
+ /* Watch out for case that nonzero coef is zero after point transform */ \
574
+ if (temp == 0) \
575
+ continue; \
576
+ /* For a negative coef, want temp2 = bitwise complement of abs(coef) */ \
577
+ temp2 ^= temp; \
578
+ values[k] = temp; \
579
+ values[k + DCTSIZE2] = temp2; \
580
+ zerobits |= ((size_t)1U) << k; \
581
+ } \
582
+ }
583
+
584
+ METHODDEF(void)
585
+ encode_mcu_AC_first_prepare(const JCOEF *block,
586
+ const int *jpeg_natural_order_start, int Sl,
587
+ int Al, JCOEF *values, size_t *bits)
588
+ {
589
+ register int k, temp, temp2;
590
+ size_t zerobits = 0U;
591
+ int Sl0 = Sl;
592
+
593
+ #if SIZEOF_SIZE_T == 4
594
+ if (Sl0 > 32)
595
+ Sl0 = 32;
596
+ #endif
597
+
598
+ COMPUTE_ABSVALUES_AC_FIRST(Sl0);
599
+
600
+ bits[0] = zerobits;
601
+ #if SIZEOF_SIZE_T == 4
602
+ zerobits = 0U;
603
+
604
+ if (Sl > 32) {
605
+ Sl -= 32;
606
+ jpeg_natural_order_start += 32;
607
+ values += 32;
608
+
609
+ COMPUTE_ABSVALUES_AC_FIRST(Sl);
610
+ }
611
+ bits[1] = zerobits;
612
+ #endif
613
+ }
614
+
615
+ /*
616
+ * MCU encoding for AC initial scan (either spectral selection,
617
+ * or first pass of successive approximation).
618
+ */
619
+
620
+ #define ENCODE_COEFS_AC_FIRST(label) { \
621
+ while (zerobits) { \
622
+ r = count_zeroes(&zerobits); \
623
+ cvalue += r; \
624
+ label \
625
+ temp = cvalue[0]; \
626
+ temp2 = cvalue[DCTSIZE2]; \
627
+ \
628
+ /* if run length > 15, must emit special run-length-16 codes (0xF0) */ \
629
+ while (r > 15) { \
630
+ emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); \
631
+ r -= 16; \
632
+ } \
633
+ \
634
+ /* Find the number of bits needed for the magnitude of the coefficient */ \
635
+ nbits = JPEG_NBITS_NONZERO(temp); /* there must be at least one 1 bit */ \
636
+ /* Check for out-of-range coefficient values */ \
637
+ if (nbits > MAX_COEF_BITS) \
638
+ ERREXIT(cinfo, JERR_BAD_DCT_COEF); \
639
+ \
640
+ /* Count/emit Huffman symbol for run length / number of bits */ \
641
+ emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits); \
642
+ \
643
+ /* Emit that number of bits of the value, if positive, */ \
644
+ /* or the complement of its magnitude, if negative. */ \
645
+ emit_bits(entropy, (unsigned int)temp2, nbits); \
646
+ \
647
+ cvalue++; \
648
+ zerobits >>= 1; \
649
+ } \
650
+ }
651
+
652
+ METHODDEF(boolean)
653
+ encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
654
+ {
655
+ phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
656
+ register int temp, temp2;
657
+ register int nbits, r;
658
+ int Sl = cinfo->Se - cinfo->Ss + 1;
659
+ int Al = cinfo->Al;
660
+ JCOEF values_unaligned[2 * DCTSIZE2 + 15];
661
+ JCOEF *values;
662
+ const JCOEF *cvalue;
663
+ size_t zerobits;
664
+ size_t bits[8 / SIZEOF_SIZE_T];
665
+
666
+ entropy->next_output_byte = cinfo->dest->next_output_byte;
667
+ entropy->free_in_buffer = cinfo->dest->free_in_buffer;
668
+
669
+ /* Emit restart marker if needed */
670
+ if (cinfo->restart_interval)
671
+ if (entropy->restarts_to_go == 0)
672
+ emit_restart(entropy, entropy->next_restart_num);
673
+
674
+ #ifdef WITH_SIMD
675
+ cvalue = values = (JCOEF *)PAD((size_t)values_unaligned, 16);
676
+ #else
677
+ /* Not using SIMD, so alignment is not needed */
678
+ cvalue = values = values_unaligned;
679
+ #endif
680
+
681
+ /* Prepare data */
682
+ entropy->AC_first_prepare(MCU_data[0][0], jpeg_natural_order + cinfo->Ss,
683
+ Sl, Al, values, bits);
684
+
685
+ zerobits = bits[0];
686
+ #if SIZEOF_SIZE_T == 4
687
+ zerobits |= bits[1];
688
+ #endif
689
+
690
+ /* Emit any pending EOBRUN */
691
+ if (zerobits && (entropy->EOBRUN > 0))
692
+ emit_eobrun(entropy);
693
+
694
+ #if SIZEOF_SIZE_T == 4
695
+ zerobits = bits[0];
696
+ #endif
697
+
698
+ /* Encode the AC coefficients per section G.1.2.2, fig. G.3 */
699
+
700
+ ENCODE_COEFS_AC_FIRST((void)0;);
701
+
702
+ #if SIZEOF_SIZE_T == 4
703
+ zerobits = bits[1];
704
+ if (zerobits) {
705
+ int diff = ((values + DCTSIZE2 / 2) - cvalue);
706
+ r = count_zeroes(&zerobits);
707
+ r += diff;
708
+ cvalue += r;
709
+ goto first_iter_ac_first;
710
+ }
711
+
712
+ ENCODE_COEFS_AC_FIRST(first_iter_ac_first:);
713
+ #endif
714
+
715
+ if (cvalue < (values + Sl)) { /* If there are trailing zeroes, */
716
+ entropy->EOBRUN++; /* count an EOB */
717
+ if (entropy->EOBRUN == 0x7FFF)
718
+ emit_eobrun(entropy); /* force it out to avoid overflow */
719
+ }
720
+
721
+ cinfo->dest->next_output_byte = entropy->next_output_byte;
722
+ cinfo->dest->free_in_buffer = entropy->free_in_buffer;
723
+
724
+ /* Update restart-interval state too */
725
+ if (cinfo->restart_interval) {
726
+ if (entropy->restarts_to_go == 0) {
727
+ entropy->restarts_to_go = cinfo->restart_interval;
728
+ entropy->next_restart_num++;
729
+ entropy->next_restart_num &= 7;
730
+ }
731
+ entropy->restarts_to_go--;
732
+ }
733
+
734
+ return TRUE;
735
+ }
736
+
737
+
738
+ /*
739
+ * MCU encoding for DC successive approximation refinement scan.
740
+ * Note: we assume such scans can be multi-component, although the spec
741
+ * is not very clear on the point.
742
+ */
743
+
744
+ METHODDEF(boolean)
745
+ encode_mcu_DC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
746
+ {
747
+ phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
748
+ register int temp;
749
+ int blkn;
750
+ int Al = cinfo->Al;
751
+ JBLOCKROW block;
752
+
753
+ entropy->next_output_byte = cinfo->dest->next_output_byte;
754
+ entropy->free_in_buffer = cinfo->dest->free_in_buffer;
755
+
756
+ /* Emit restart marker if needed */
757
+ if (cinfo->restart_interval)
758
+ if (entropy->restarts_to_go == 0)
759
+ emit_restart(entropy, entropy->next_restart_num);
760
+
761
+ /* Encode the MCU data blocks */
762
+ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
763
+ block = MCU_data[blkn];
764
+
765
+ /* We simply emit the Al'th bit of the DC coefficient value. */
766
+ temp = (*block)[0];
767
+ emit_bits(entropy, (unsigned int)(temp >> Al), 1);
768
+ }
769
+
770
+ cinfo->dest->next_output_byte = entropy->next_output_byte;
771
+ cinfo->dest->free_in_buffer = entropy->free_in_buffer;
772
+
773
+ /* Update restart-interval state too */
774
+ if (cinfo->restart_interval) {
775
+ if (entropy->restarts_to_go == 0) {
776
+ entropy->restarts_to_go = cinfo->restart_interval;
777
+ entropy->next_restart_num++;
778
+ entropy->next_restart_num &= 7;
779
+ }
780
+ entropy->restarts_to_go--;
781
+ }
782
+
783
+ return TRUE;
784
+ }
785
+
786
+
787
+ /*
788
+ * Data preparation for encode_mcu_AC_refine().
789
+ */
790
+
791
+ #define COMPUTE_ABSVALUES_AC_REFINE(Sl, koffset) { \
792
+ /* It is convenient to make a pre-pass to determine the transformed \
793
+ * coefficients' absolute values and the EOB position. \
794
+ */ \
795
+ for (k = 0; k < Sl; k++) { \
796
+ temp = block[jpeg_natural_order_start[k]]; \
797
+ /* We must apply the point transform by Al. For AC coefficients this \
798
+ * is an integer division with rounding towards 0. To do this portably \
799
+ * in C, we shift after obtaining the absolute value. \
800
+ */ \
801
+ temp2 = temp >> (CHAR_BIT * sizeof(int) - 1); \
802
+ temp ^= temp2; \
803
+ temp -= temp2; /* temp is abs value of input */ \
804
+ temp >>= Al; /* apply the point transform */ \
805
+ if (temp != 0) { \
806
+ zerobits |= ((size_t)1U) << k; \
807
+ signbits |= ((size_t)(temp2 + 1)) << k; \
808
+ } \
809
+ absvalues[k] = (JCOEF)temp; /* save abs value for main pass */ \
810
+ if (temp == 1) \
811
+ EOB = k + koffset; /* EOB = index of last newly-nonzero coef */ \
812
+ } \
813
+ }
814
+
815
+ METHODDEF(int)
816
+ encode_mcu_AC_refine_prepare(const JCOEF *block,
817
+ const int *jpeg_natural_order_start, int Sl,
818
+ int Al, JCOEF *absvalues, size_t *bits)
819
+ {
820
+ register int k, temp, temp2;
821
+ int EOB = 0;
822
+ size_t zerobits = 0U, signbits = 0U;
823
+ int Sl0 = Sl;
824
+
825
+ #if SIZEOF_SIZE_T == 4
826
+ if (Sl0 > 32)
827
+ Sl0 = 32;
828
+ #endif
829
+
830
+ COMPUTE_ABSVALUES_AC_REFINE(Sl0, 0);
831
+
832
+ bits[0] = zerobits;
833
+ #if SIZEOF_SIZE_T == 8
834
+ bits[1] = signbits;
835
+ #else
836
+ bits[2] = signbits;
837
+
838
+ zerobits = 0U;
839
+ signbits = 0U;
840
+
841
+ if (Sl > 32) {
842
+ Sl -= 32;
843
+ jpeg_natural_order_start += 32;
844
+ absvalues += 32;
845
+
846
+ COMPUTE_ABSVALUES_AC_REFINE(Sl, 32);
847
+ }
848
+
849
+ bits[1] = zerobits;
850
+ bits[3] = signbits;
851
+ #endif
852
+
853
+ return EOB;
854
+ }
855
+
856
+
857
+ /*
858
+ * MCU encoding for AC successive approximation refinement scan.
859
+ */
860
+
861
+ #define ENCODE_COEFS_AC_REFINE(label) { \
862
+ while (zerobits) { \
863
+ int idx = count_zeroes(&zerobits); \
864
+ r += idx; \
865
+ cabsvalue += idx; \
866
+ signbits >>= idx; \
867
+ label \
868
+ /* Emit any required ZRLs, but not if they can be folded into EOB */ \
869
+ while (r > 15 && (cabsvalue <= EOBPTR)) { \
870
+ /* emit any pending EOBRUN and the BE correction bits */ \
871
+ emit_eobrun(entropy); \
872
+ /* Emit ZRL */ \
873
+ emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); \
874
+ r -= 16; \
875
+ /* Emit buffered correction bits that must be associated with ZRL */ \
876
+ emit_buffered_bits(entropy, BR_buffer, BR); \
877
+ BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ \
878
+ BR = 0; \
879
+ } \
880
+ \
881
+ temp = *cabsvalue++; \
882
+ \
883
+ /* If the coef was previously nonzero, it only needs a correction bit. \
884
+ * NOTE: a straight translation of the spec's figure G.7 would suggest \
885
+ * that we also need to test r > 15. But if r > 15, we can only get here \
886
+ * if k > EOB, which implies that this coefficient is not 1. \
887
+ */ \
888
+ if (temp > 1) { \
889
+ /* The correction bit is the next bit of the absolute value. */ \
890
+ BR_buffer[BR++] = (char)(temp & 1); \
891
+ signbits >>= 1; \
892
+ zerobits >>= 1; \
893
+ continue; \
894
+ } \
895
+ \
896
+ /* Emit any pending EOBRUN and the BE correction bits */ \
897
+ emit_eobrun(entropy); \
898
+ \
899
+ /* Count/emit Huffman symbol for run length / number of bits */ \
900
+ emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1); \
901
+ \
902
+ /* Emit output bit for newly-nonzero coef */ \
903
+ temp = signbits & 1; /* ((*block)[jpeg_natural_order_start[k]] < 0) ? 0 : 1 */ \
904
+ emit_bits(entropy, (unsigned int)temp, 1); \
905
+ \
906
+ /* Emit buffered correction bits that must be associated with this code */ \
907
+ emit_buffered_bits(entropy, BR_buffer, BR); \
908
+ BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ \
909
+ BR = 0; \
910
+ r = 0; /* reset zero run length */ \
911
+ signbits >>= 1; \
912
+ zerobits >>= 1; \
913
+ } \
914
+ }
915
+
916
+ METHODDEF(boolean)
917
+ encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
918
+ {
919
+ phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
920
+ register int temp, r;
921
+ char *BR_buffer;
922
+ unsigned int BR;
923
+ int Sl = cinfo->Se - cinfo->Ss + 1;
924
+ int Al = cinfo->Al;
925
+ JCOEF absvalues_unaligned[DCTSIZE2 + 15];
926
+ JCOEF *absvalues;
927
+ const JCOEF *cabsvalue, *EOBPTR;
928
+ size_t zerobits, signbits;
929
+ size_t bits[16 / SIZEOF_SIZE_T];
930
+
931
+ entropy->next_output_byte = cinfo->dest->next_output_byte;
932
+ entropy->free_in_buffer = cinfo->dest->free_in_buffer;
933
+
934
+ /* Emit restart marker if needed */
935
+ if (cinfo->restart_interval)
936
+ if (entropy->restarts_to_go == 0)
937
+ emit_restart(entropy, entropy->next_restart_num);
938
+
939
+ #ifdef WITH_SIMD
940
+ cabsvalue = absvalues = (JCOEF *)PAD((size_t)absvalues_unaligned, 16);
941
+ #else
942
+ /* Not using SIMD, so alignment is not needed */
943
+ cabsvalue = absvalues = absvalues_unaligned;
944
+ #endif
945
+
946
+ /* Prepare data */
947
+ EOBPTR = absvalues +
948
+ entropy->AC_refine_prepare(MCU_data[0][0], jpeg_natural_order + cinfo->Ss,
949
+ Sl, Al, absvalues, bits);
950
+
951
+ /* Encode the AC coefficients per section G.1.2.3, fig. G.7 */
952
+
953
+ r = 0; /* r = run length of zeros */
954
+ BR = 0; /* BR = count of buffered bits added now */
955
+ BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */
956
+
957
+ zerobits = bits[0];
958
+ #if SIZEOF_SIZE_T == 8
959
+ signbits = bits[1];
960
+ #else
961
+ signbits = bits[2];
962
+ #endif
963
+ ENCODE_COEFS_AC_REFINE((void)0;);
964
+
965
+ #if SIZEOF_SIZE_T == 4
966
+ zerobits = bits[1];
967
+ signbits = bits[3];
968
+
969
+ if (zerobits) {
970
+ int diff = ((absvalues + DCTSIZE2 / 2) - cabsvalue);
971
+ int idx = count_zeroes(&zerobits);
972
+ signbits >>= idx;
973
+ idx += diff;
974
+ r += idx;
975
+ cabsvalue += idx;
976
+ goto first_iter_ac_refine;
977
+ }
978
+
979
+ ENCODE_COEFS_AC_REFINE(first_iter_ac_refine:);
980
+ #endif
981
+
982
+ r |= (int)((absvalues + Sl) - cabsvalue);
983
+
984
+ if (r > 0 || BR > 0) { /* If there are trailing zeroes, */
985
+ entropy->EOBRUN++; /* count an EOB */
986
+ entropy->BE += BR; /* concat my correction bits to older ones */
987
+ /* We force out the EOB if we risk either:
988
+ * 1. overflow of the EOB counter;
989
+ * 2. overflow of the correction bit buffer during the next MCU.
990
+ */
991
+ if (entropy->EOBRUN == 0x7FFF ||
992
+ entropy->BE > (MAX_CORR_BITS - DCTSIZE2 + 1))
993
+ emit_eobrun(entropy);
994
+ }
995
+
996
+ cinfo->dest->next_output_byte = entropy->next_output_byte;
997
+ cinfo->dest->free_in_buffer = entropy->free_in_buffer;
998
+
999
+ /* Update restart-interval state too */
1000
+ if (cinfo->restart_interval) {
1001
+ if (entropy->restarts_to_go == 0) {
1002
+ entropy->restarts_to_go = cinfo->restart_interval;
1003
+ entropy->next_restart_num++;
1004
+ entropy->next_restart_num &= 7;
1005
+ }
1006
+ entropy->restarts_to_go--;
1007
+ }
1008
+
1009
+ return TRUE;
1010
+ }
1011
+
1012
+
1013
+ /*
1014
+ * Finish up at the end of a Huffman-compressed progressive scan.
1015
+ */
1016
+
1017
+ METHODDEF(void)
1018
+ finish_pass_phuff(j_compress_ptr cinfo)
1019
+ {
1020
+ phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
1021
+
1022
+ entropy->next_output_byte = cinfo->dest->next_output_byte;
1023
+ entropy->free_in_buffer = cinfo->dest->free_in_buffer;
1024
+
1025
+ /* Flush out any buffered data */
1026
+ emit_eobrun(entropy);
1027
+ flush_bits(entropy);
1028
+
1029
+ cinfo->dest->next_output_byte = entropy->next_output_byte;
1030
+ cinfo->dest->free_in_buffer = entropy->free_in_buffer;
1031
+ }
1032
+
1033
+
1034
+ /*
1035
+ * Finish up a statistics-gathering pass and create the new Huffman tables.
1036
+ */
1037
+
1038
+ METHODDEF(void)
1039
+ finish_pass_gather_phuff(j_compress_ptr cinfo)
1040
+ {
1041
+ phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy;
1042
+ boolean is_DC_band;
1043
+ int ci, tbl;
1044
+ jpeg_component_info *compptr;
1045
+ JHUFF_TBL **htblptr;
1046
+ boolean did[NUM_HUFF_TBLS];
1047
+
1048
+ /* Flush out buffered data (all we care about is counting the EOB symbol) */
1049
+ emit_eobrun(entropy);
1050
+
1051
+ is_DC_band = (cinfo->Ss == 0);
1052
+
1053
+ /* It's important not to apply jpeg_gen_optimal_table more than once
1054
+ * per table, because it clobbers the input frequency counts!
1055
+ */
1056
+ MEMZERO(did, sizeof(did));
1057
+
1058
+ for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
1059
+ compptr = cinfo->cur_comp_info[ci];
1060
+ if (is_DC_band) {
1061
+ if (cinfo->Ah != 0) /* DC refinement needs no table */
1062
+ continue;
1063
+ tbl = compptr->dc_tbl_no;
1064
+ } else {
1065
+ tbl = compptr->ac_tbl_no;
1066
+ }
1067
+ if (!did[tbl]) {
1068
+ if (is_DC_band)
1069
+ htblptr = &cinfo->dc_huff_tbl_ptrs[tbl];
1070
+ else
1071
+ htblptr = &cinfo->ac_huff_tbl_ptrs[tbl];
1072
+ if (*htblptr == NULL)
1073
+ *htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
1074
+ jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]);
1075
+ did[tbl] = TRUE;
1076
+ }
1077
+ }
1078
+ }
1079
+
1080
+
1081
+ /*
1082
+ * Module initialization routine for progressive Huffman entropy encoding.
1083
+ */
1084
+
1085
+ GLOBAL(void)
1086
+ jinit_phuff_encoder(j_compress_ptr cinfo)
1087
+ {
1088
+ phuff_entropy_ptr entropy;
1089
+ int i;
1090
+
1091
+ entropy = (phuff_entropy_ptr)
1092
+ (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
1093
+ sizeof(phuff_entropy_encoder));
1094
+ cinfo->entropy = (struct jpeg_entropy_encoder *)entropy;
1095
+ entropy->pub.start_pass = start_pass_phuff;
1096
+
1097
+ /* Mark tables unallocated */
1098
+ for (i = 0; i < NUM_HUFF_TBLS; i++) {
1099
+ entropy->derived_tbls[i] = NULL;
1100
+ entropy->count_ptrs[i] = NULL;
1101
+ }
1102
+ entropy->bit_buffer = NULL; /* needed only in AC refinement scan */
1103
+ }
1104
+
1105
+ #endif /* C_PROGRESSIVE_SUPPORTED */