entangledstate-isbn 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (290) hide show
  1. data/README +1 -1
  2. data/Rakefile +0 -18
  3. data/VERSION +1 -0
  4. data/isbn.gemspec +290 -7
  5. data/lib/isbn.rb +6 -6
  6. data/src/gocr-0.48/.cvsignore +6 -0
  7. data/src/gocr-0.48/AUTHORS +7 -0
  8. data/src/gocr-0.48/BUGS +55 -0
  9. data/src/gocr-0.48/CREDITS +17 -0
  10. data/src/gocr-0.48/HISTORY +243 -0
  11. data/src/gocr-0.48/INSTALL +83 -0
  12. data/src/gocr-0.48/Makefile +193 -0
  13. data/src/gocr-0.48/Makefile.in +193 -0
  14. data/src/gocr-0.48/README +165 -0
  15. data/src/gocr-0.48/READMEde.txt +80 -0
  16. data/src/gocr-0.48/REMARK.txt +18 -0
  17. data/src/gocr-0.48/REVIEW +538 -0
  18. data/src/gocr-0.48/TODO +65 -0
  19. data/src/gocr-0.48/bin/.cvsignore +2 -0
  20. data/src/gocr-0.48/bin/create_db +38 -0
  21. data/src/gocr-0.48/bin/gocr.tcl +527 -0
  22. data/src/gocr-0.48/bin/gocr_chk.sh +44 -0
  23. data/src/gocr-0.48/configure +4689 -0
  24. data/src/gocr-0.48/configure.in +71 -0
  25. data/src/gocr-0.48/doc/.#Makefile.1.6 +39 -0
  26. data/src/gocr-0.48/doc/.cvsignore +2 -0
  27. data/src/gocr-0.48/doc/Makefile +39 -0
  28. data/src/gocr-0.48/doc/Makefile.in +39 -0
  29. data/src/gocr-0.48/doc/example.dtd +53 -0
  30. data/src/gocr-0.48/doc/example.xml +21 -0
  31. data/src/gocr-0.48/doc/examples.txt +67 -0
  32. data/src/gocr-0.48/doc/gocr.html +578 -0
  33. data/src/gocr-0.48/doc/unicode.txt +57 -0
  34. data/src/gocr-0.48/examples/.#Makefile.1.22 +166 -0
  35. data/src/gocr-0.48/examples/4x6.png +0 -0
  36. data/src/gocr-0.48/examples/4x6.txt +2 -0
  37. data/src/gocr-0.48/examples/5x7.png +0 -0
  38. data/src/gocr-0.48/examples/5x7.png.txt +2 -0
  39. data/src/gocr-0.48/examples/5x8.png +0 -0
  40. data/src/gocr-0.48/examples/5x8.png.txt +2 -0
  41. data/src/gocr-0.48/examples/Makefile +166 -0
  42. data/src/gocr-0.48/examples/color.fig +20 -0
  43. data/src/gocr-0.48/examples/ex.fig +16 -0
  44. data/src/gocr-0.48/examples/font.tex +22 -0
  45. data/src/gocr-0.48/examples/font1.tex +46 -0
  46. data/src/gocr-0.48/examples/font2.fig +27 -0
  47. data/src/gocr-0.48/examples/font_nw.tex +24 -0
  48. data/src/gocr-0.48/examples/handwrt1.jpg +0 -0
  49. data/src/gocr-0.48/examples/handwrt1.txt +10 -0
  50. data/src/gocr-0.48/examples/inverse.fig +20 -0
  51. data/src/gocr-0.48/examples/matrix.jpg +0 -0
  52. data/src/gocr-0.48/examples/ocr-a-subset.png +0 -0
  53. data/src/gocr-0.48/examples/ocr-a-subset.png.txt +4 -0
  54. data/src/gocr-0.48/examples/ocr-a.png +0 -0
  55. data/src/gocr-0.48/examples/ocr-a.txt +6 -0
  56. data/src/gocr-0.48/examples/ocr-b.png +0 -0
  57. data/src/gocr-0.48/examples/ocr-b.png.txt +4 -0
  58. data/src/gocr-0.48/examples/polish.tex +28 -0
  59. data/src/gocr-0.48/examples/rotate45.fig +14 -0
  60. data/src/gocr-0.48/examples/score +36 -0
  61. data/src/gocr-0.48/examples/text.tex +28 -0
  62. data/src/gocr-0.48/gocr.spec +143 -0
  63. data/src/gocr-0.48/gpl.html +537 -0
  64. data/src/gocr-0.48/include/.cvsignore +2 -0
  65. data/src/gocr-0.48/include/config.h +36 -0
  66. data/src/gocr-0.48/include/config.h.in +36 -0
  67. data/src/gocr-0.48/include/version.h +2 -0
  68. data/src/gocr-0.48/install-sh +3 -0
  69. data/src/gocr-0.48/make.bat +57 -0
  70. data/src/gocr-0.48/man/.cvsignore +2 -0
  71. data/src/gocr-0.48/man/Makefile +29 -0
  72. data/src/gocr-0.48/man/Makefile.in +29 -0
  73. data/src/gocr-0.48/man/man1/gocr.1 +166 -0
  74. data/src/gocr-0.48/src/.cvsignore +4 -0
  75. data/src/gocr-0.48/src/Makefile +132 -0
  76. data/src/gocr-0.48/src/Makefile.in +132 -0
  77. data/src/gocr-0.48/src/amiga.h +31 -0
  78. data/src/gocr-0.48/src/barcode.c +846 -0
  79. data/src/gocr-0.48/src/barcode.c.orig +593 -0
  80. data/src/gocr-0.48/src/barcode.h +11 -0
  81. data/src/gocr-0.48/src/box.c +372 -0
  82. data/src/gocr-0.48/src/database.c +462 -0
  83. data/src/gocr-0.48/src/detect.c +943 -0
  84. data/src/gocr-0.48/src/gocr.c +373 -0
  85. data/src/gocr-0.48/src/gocr.h +288 -0
  86. data/src/gocr-0.48/src/jconv.c +168 -0
  87. data/src/gocr-0.48/src/job.c +84 -0
  88. data/src/gocr-0.48/src/lines.c +350 -0
  89. data/src/gocr-0.48/src/list.c +334 -0
  90. data/src/gocr-0.48/src/list.h +90 -0
  91. data/src/gocr-0.48/src/ocr0.c +6756 -0
  92. data/src/gocr-0.48/src/ocr0.h +63 -0
  93. data/src/gocr-0.48/src/ocr0n.c +1475 -0
  94. data/src/gocr-0.48/src/ocr1.c +85 -0
  95. data/src/gocr-0.48/src/ocr1.h +3 -0
  96. data/src/gocr-0.48/src/otsu.c +289 -0
  97. data/src/gocr-0.48/src/otsu.h +23 -0
  98. data/src/gocr-0.48/src/output.c +289 -0
  99. data/src/gocr-0.48/src/output.h +37 -0
  100. data/src/gocr-0.48/src/pcx.c +153 -0
  101. data/src/gocr-0.48/src/pcx.h +9 -0
  102. data/src/gocr-0.48/src/pgm2asc.c +2893 -0
  103. data/src/gocr-0.48/src/pgm2asc.h +105 -0
  104. data/src/gocr-0.48/src/pixel.c +537 -0
  105. data/src/gocr-0.48/src/pnm.c +533 -0
  106. data/src/gocr-0.48/src/pnm.h +35 -0
  107. data/src/gocr-0.48/src/progress.c +87 -0
  108. data/src/gocr-0.48/src/progress.h +42 -0
  109. data/src/gocr-0.48/src/remove.c +703 -0
  110. data/src/gocr-0.48/src/tga.c +87 -0
  111. data/src/gocr-0.48/src/tga.h +6 -0
  112. data/src/gocr-0.48/src/unicode.c +1314 -0
  113. data/src/gocr-0.48/src/unicode.h +1257 -0
  114. data/src/jpeg-7/Makefile.am +133 -0
  115. data/src/jpeg-7/Makefile.in +1089 -0
  116. data/src/jpeg-7/README +322 -0
  117. data/src/jpeg-7/aclocal.m4 +8990 -0
  118. data/src/jpeg-7/ansi2knr.1 +36 -0
  119. data/src/jpeg-7/ansi2knr.c +739 -0
  120. data/src/jpeg-7/cderror.h +132 -0
  121. data/src/jpeg-7/cdjpeg.c +181 -0
  122. data/src/jpeg-7/cdjpeg.h +187 -0
  123. data/src/jpeg-7/change.log +270 -0
  124. data/src/jpeg-7/cjpeg.1 +325 -0
  125. data/src/jpeg-7/cjpeg.c +616 -0
  126. data/src/jpeg-7/ckconfig.c +402 -0
  127. data/src/jpeg-7/coderules.txt +118 -0
  128. data/src/jpeg-7/config.guess +1561 -0
  129. data/src/jpeg-7/config.sub +1686 -0
  130. data/src/jpeg-7/configure +17139 -0
  131. data/src/jpeg-7/configure.ac +317 -0
  132. data/src/jpeg-7/depcomp +630 -0
  133. data/src/jpeg-7/djpeg.1 +251 -0
  134. data/src/jpeg-7/djpeg.c +617 -0
  135. data/src/jpeg-7/example.c +433 -0
  136. data/src/jpeg-7/filelist.txt +215 -0
  137. data/src/jpeg-7/install-sh +520 -0
  138. data/src/jpeg-7/install.txt +1097 -0
  139. data/src/jpeg-7/jaricom.c +148 -0
  140. data/src/jpeg-7/jcapimin.c +282 -0
  141. data/src/jpeg-7/jcapistd.c +161 -0
  142. data/src/jpeg-7/jcarith.c +921 -0
  143. data/src/jpeg-7/jccoefct.c +453 -0
  144. data/src/jpeg-7/jccolor.c +459 -0
  145. data/src/jpeg-7/jcdctmgr.c +482 -0
  146. data/src/jpeg-7/jchuff.c +1612 -0
  147. data/src/jpeg-7/jcinit.c +65 -0
  148. data/src/jpeg-7/jcmainct.c +293 -0
  149. data/src/jpeg-7/jcmarker.c +667 -0
  150. data/src/jpeg-7/jcmaster.c +770 -0
  151. data/src/jpeg-7/jcomapi.c +106 -0
  152. data/src/jpeg-7/jconfig.bcc +48 -0
  153. data/src/jpeg-7/jconfig.cfg +45 -0
  154. data/src/jpeg-7/jconfig.dj +38 -0
  155. data/src/jpeg-7/jconfig.mac +43 -0
  156. data/src/jpeg-7/jconfig.manx +43 -0
  157. data/src/jpeg-7/jconfig.mc6 +52 -0
  158. data/src/jpeg-7/jconfig.sas +43 -0
  159. data/src/jpeg-7/jconfig.st +42 -0
  160. data/src/jpeg-7/jconfig.txt +155 -0
  161. data/src/jpeg-7/jconfig.vc +45 -0
  162. data/src/jpeg-7/jconfig.vms +37 -0
  163. data/src/jpeg-7/jconfig.wat +38 -0
  164. data/src/jpeg-7/jcparam.c +632 -0
  165. data/src/jpeg-7/jcprepct.c +358 -0
  166. data/src/jpeg-7/jcsample.c +545 -0
  167. data/src/jpeg-7/jctrans.c +381 -0
  168. data/src/jpeg-7/jdapimin.c +396 -0
  169. data/src/jpeg-7/jdapistd.c +275 -0
  170. data/src/jpeg-7/jdarith.c +762 -0
  171. data/src/jpeg-7/jdatadst.c +151 -0
  172. data/src/jpeg-7/jdatasrc.c +212 -0
  173. data/src/jpeg-7/jdcoefct.c +736 -0
  174. data/src/jpeg-7/jdcolor.c +396 -0
  175. data/src/jpeg-7/jdct.h +393 -0
  176. data/src/jpeg-7/jddctmgr.c +382 -0
  177. data/src/jpeg-7/jdhuff.c +1309 -0
  178. data/src/jpeg-7/jdinput.c +384 -0
  179. data/src/jpeg-7/jdmainct.c +512 -0
  180. data/src/jpeg-7/jdmarker.c +1360 -0
  181. data/src/jpeg-7/jdmaster.c +663 -0
  182. data/src/jpeg-7/jdmerge.c +400 -0
  183. data/src/jpeg-7/jdpostct.c +290 -0
  184. data/src/jpeg-7/jdsample.c +361 -0
  185. data/src/jpeg-7/jdtrans.c +136 -0
  186. data/src/jpeg-7/jerror.c +252 -0
  187. data/src/jpeg-7/jerror.h +304 -0
  188. data/src/jpeg-7/jfdctflt.c +174 -0
  189. data/src/jpeg-7/jfdctfst.c +230 -0
  190. data/src/jpeg-7/jfdctint.c +4348 -0
  191. data/src/jpeg-7/jidctflt.c +242 -0
  192. data/src/jpeg-7/jidctfst.c +368 -0
  193. data/src/jpeg-7/jidctint.c +5137 -0
  194. data/src/jpeg-7/jinclude.h +91 -0
  195. data/src/jpeg-7/jmemansi.c +167 -0
  196. data/src/jpeg-7/jmemdos.c +638 -0
  197. data/src/jpeg-7/jmemdosa.asm +379 -0
  198. data/src/jpeg-7/jmemmac.c +289 -0
  199. data/src/jpeg-7/jmemmgr.c +1118 -0
  200. data/src/jpeg-7/jmemname.c +276 -0
  201. data/src/jpeg-7/jmemnobs.c +109 -0
  202. data/src/jpeg-7/jmemsys.h +198 -0
  203. data/src/jpeg-7/jmorecfg.h +369 -0
  204. data/src/jpeg-7/jpegint.h +395 -0
  205. data/src/jpeg-7/jpeglib.h +1135 -0
  206. data/src/jpeg-7/jpegtran.1 +272 -0
  207. data/src/jpeg-7/jpegtran.c +546 -0
  208. data/src/jpeg-7/jquant1.c +856 -0
  209. data/src/jpeg-7/jquant2.c +1310 -0
  210. data/src/jpeg-7/jutils.c +179 -0
  211. data/src/jpeg-7/jversion.h +14 -0
  212. data/src/jpeg-7/libjpeg.map +4 -0
  213. data/src/jpeg-7/libjpeg.txt +3067 -0
  214. data/src/jpeg-7/ltmain.sh +8406 -0
  215. data/src/jpeg-7/makcjpeg.st +36 -0
  216. data/src/jpeg-7/makdjpeg.st +36 -0
  217. data/src/jpeg-7/makeadsw.vc6 +77 -0
  218. data/src/jpeg-7/makeasln.vc9 +33 -0
  219. data/src/jpeg-7/makecdep.vc6 +82 -0
  220. data/src/jpeg-7/makecdsp.vc6 +130 -0
  221. data/src/jpeg-7/makecmak.vc6 +159 -0
  222. data/src/jpeg-7/makecvcp.vc9 +186 -0
  223. data/src/jpeg-7/makeddep.vc6 +82 -0
  224. data/src/jpeg-7/makeddsp.vc6 +130 -0
  225. data/src/jpeg-7/makedmak.vc6 +159 -0
  226. data/src/jpeg-7/makedvcp.vc9 +186 -0
  227. data/src/jpeg-7/makefile.ansi +220 -0
  228. data/src/jpeg-7/makefile.bcc +291 -0
  229. data/src/jpeg-7/makefile.dj +226 -0
  230. data/src/jpeg-7/makefile.manx +220 -0
  231. data/src/jpeg-7/makefile.mc6 +255 -0
  232. data/src/jpeg-7/makefile.mms +224 -0
  233. data/src/jpeg-7/makefile.sas +258 -0
  234. data/src/jpeg-7/makefile.unix +234 -0
  235. data/src/jpeg-7/makefile.vc +217 -0
  236. data/src/jpeg-7/makefile.vms +142 -0
  237. data/src/jpeg-7/makefile.wat +239 -0
  238. data/src/jpeg-7/makejdep.vc6 +423 -0
  239. data/src/jpeg-7/makejdsp.vc6 +285 -0
  240. data/src/jpeg-7/makejdsw.vc6 +29 -0
  241. data/src/jpeg-7/makejmak.vc6 +425 -0
  242. data/src/jpeg-7/makejsln.vc9 +17 -0
  243. data/src/jpeg-7/makejvcp.vc9 +328 -0
  244. data/src/jpeg-7/makeproj.mac +213 -0
  245. data/src/jpeg-7/makerdep.vc6 +6 -0
  246. data/src/jpeg-7/makerdsp.vc6 +78 -0
  247. data/src/jpeg-7/makermak.vc6 +110 -0
  248. data/src/jpeg-7/makervcp.vc9 +133 -0
  249. data/src/jpeg-7/maketdep.vc6 +43 -0
  250. data/src/jpeg-7/maketdsp.vc6 +122 -0
  251. data/src/jpeg-7/maketmak.vc6 +131 -0
  252. data/src/jpeg-7/maketvcp.vc9 +178 -0
  253. data/src/jpeg-7/makewdep.vc6 +6 -0
  254. data/src/jpeg-7/makewdsp.vc6 +78 -0
  255. data/src/jpeg-7/makewmak.vc6 +110 -0
  256. data/src/jpeg-7/makewvcp.vc9 +133 -0
  257. data/src/jpeg-7/makljpeg.st +68 -0
  258. data/src/jpeg-7/maktjpeg.st +30 -0
  259. data/src/jpeg-7/makvms.opt +4 -0
  260. data/src/jpeg-7/missing +376 -0
  261. data/src/jpeg-7/rdbmp.c +439 -0
  262. data/src/jpeg-7/rdcolmap.c +253 -0
  263. data/src/jpeg-7/rdgif.c +38 -0
  264. data/src/jpeg-7/rdjpgcom.1 +63 -0
  265. data/src/jpeg-7/rdjpgcom.c +515 -0
  266. data/src/jpeg-7/rdppm.c +459 -0
  267. data/src/jpeg-7/rdrle.c +387 -0
  268. data/src/jpeg-7/rdswitch.c +365 -0
  269. data/src/jpeg-7/rdtarga.c +500 -0
  270. data/src/jpeg-7/structure.txt +945 -0
  271. data/src/jpeg-7/testimg.bmp +0 -0
  272. data/src/jpeg-7/testimg.jpg +0 -0
  273. data/src/jpeg-7/testimg.ppm +4 -0
  274. data/src/jpeg-7/testimgp.jpg +0 -0
  275. data/src/jpeg-7/testorig.jpg +0 -0
  276. data/src/jpeg-7/testprog.jpg +0 -0
  277. data/src/jpeg-7/transupp.c +1533 -0
  278. data/src/jpeg-7/transupp.h +205 -0
  279. data/src/jpeg-7/usage.txt +605 -0
  280. data/src/jpeg-7/wizard.txt +211 -0
  281. data/src/jpeg-7/wrbmp.c +442 -0
  282. data/src/jpeg-7/wrgif.c +399 -0
  283. data/src/jpeg-7/wrjpgcom.1 +103 -0
  284. data/src/jpeg-7/wrjpgcom.c +583 -0
  285. data/src/jpeg-7/wrppm.c +269 -0
  286. data/src/jpeg-7/wrrle.c +305 -0
  287. data/src/jpeg-7/wrtarga.c +253 -0
  288. metadata +287 -6
  289. data/LICENSE +0 -20
  290. data/VERSION.yml +0 -4
@@ -0,0 +1,361 @@
1
+ /*
2
+ * jdsample.c
3
+ *
4
+ * Copyright (C) 1991-1996, Thomas G. Lane.
5
+ * Modified 2002-2008 by Guido Vollbeding.
6
+ * This file is part of the Independent JPEG Group's software.
7
+ * For conditions of distribution and use, see the accompanying README file.
8
+ *
9
+ * This file contains upsampling routines.
10
+ *
11
+ * Upsampling input data is counted in "row groups". A row group
12
+ * is defined to be (v_samp_factor * DCT_v_scaled_size / min_DCT_v_scaled_size)
13
+ * sample rows of each component. Upsampling will normally produce
14
+ * max_v_samp_factor pixel rows from each row group (but this could vary
15
+ * if the upsampler is applying a scale factor of its own).
16
+ *
17
+ * An excellent reference for image resampling is
18
+ * Digital Image Warping, George Wolberg, 1990.
19
+ * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7.
20
+ */
21
+
22
+ #define JPEG_INTERNALS
23
+ #include "jinclude.h"
24
+ #include "jpeglib.h"
25
+
26
+
27
+ /* Pointer to routine to upsample a single component */
28
+ typedef JMETHOD(void, upsample1_ptr,
29
+ (j_decompress_ptr cinfo, jpeg_component_info * compptr,
30
+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr));
31
+
32
+ /* Private subobject */
33
+
34
+ typedef struct {
35
+ struct jpeg_upsampler pub; /* public fields */
36
+
37
+ /* Color conversion buffer. When using separate upsampling and color
38
+ * conversion steps, this buffer holds one upsampled row group until it
39
+ * has been color converted and output.
40
+ * Note: we do not allocate any storage for component(s) which are full-size,
41
+ * ie do not need rescaling. The corresponding entry of color_buf[] is
42
+ * simply set to point to the input data array, thereby avoiding copying.
43
+ */
44
+ JSAMPARRAY color_buf[MAX_COMPONENTS];
45
+
46
+ /* Per-component upsampling method pointers */
47
+ upsample1_ptr methods[MAX_COMPONENTS];
48
+
49
+ int next_row_out; /* counts rows emitted from color_buf */
50
+ JDIMENSION rows_to_go; /* counts rows remaining in image */
51
+
52
+ /* Height of an input row group for each component. */
53
+ int rowgroup_height[MAX_COMPONENTS];
54
+
55
+ /* These arrays save pixel expansion factors so that int_expand need not
56
+ * recompute them each time. They are unused for other upsampling methods.
57
+ */
58
+ UINT8 h_expand[MAX_COMPONENTS];
59
+ UINT8 v_expand[MAX_COMPONENTS];
60
+ } my_upsampler;
61
+
62
+ typedef my_upsampler * my_upsample_ptr;
63
+
64
+
65
+ /*
66
+ * Initialize for an upsampling pass.
67
+ */
68
+
69
+ METHODDEF(void)
70
+ start_pass_upsample (j_decompress_ptr cinfo)
71
+ {
72
+ my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
73
+
74
+ /* Mark the conversion buffer empty */
75
+ upsample->next_row_out = cinfo->max_v_samp_factor;
76
+ /* Initialize total-height counter for detecting bottom of image */
77
+ upsample->rows_to_go = cinfo->output_height;
78
+ }
79
+
80
+
81
+ /*
82
+ * Control routine to do upsampling (and color conversion).
83
+ *
84
+ * In this version we upsample each component independently.
85
+ * We upsample one row group into the conversion buffer, then apply
86
+ * color conversion a row at a time.
87
+ */
88
+
89
+ METHODDEF(void)
90
+ sep_upsample (j_decompress_ptr cinfo,
91
+ JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
92
+ JDIMENSION in_row_groups_avail,
93
+ JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
94
+ JDIMENSION out_rows_avail)
95
+ {
96
+ my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
97
+ int ci;
98
+ jpeg_component_info * compptr;
99
+ JDIMENSION num_rows;
100
+
101
+ /* Fill the conversion buffer, if it's empty */
102
+ if (upsample->next_row_out >= cinfo->max_v_samp_factor) {
103
+ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
104
+ ci++, compptr++) {
105
+ /* Invoke per-component upsample method. Notice we pass a POINTER
106
+ * to color_buf[ci], so that fullsize_upsample can change it.
107
+ */
108
+ (*upsample->methods[ci]) (cinfo, compptr,
109
+ input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]),
110
+ upsample->color_buf + ci);
111
+ }
112
+ upsample->next_row_out = 0;
113
+ }
114
+
115
+ /* Color-convert and emit rows */
116
+
117
+ /* How many we have in the buffer: */
118
+ num_rows = (JDIMENSION) (cinfo->max_v_samp_factor - upsample->next_row_out);
119
+ /* Not more than the distance to the end of the image. Need this test
120
+ * in case the image height is not a multiple of max_v_samp_factor:
121
+ */
122
+ if (num_rows > upsample->rows_to_go)
123
+ num_rows = upsample->rows_to_go;
124
+ /* And not more than what the client can accept: */
125
+ out_rows_avail -= *out_row_ctr;
126
+ if (num_rows > out_rows_avail)
127
+ num_rows = out_rows_avail;
128
+
129
+ (*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf,
130
+ (JDIMENSION) upsample->next_row_out,
131
+ output_buf + *out_row_ctr,
132
+ (int) num_rows);
133
+
134
+ /* Adjust counts */
135
+ *out_row_ctr += num_rows;
136
+ upsample->rows_to_go -= num_rows;
137
+ upsample->next_row_out += num_rows;
138
+ /* When the buffer is emptied, declare this input row group consumed */
139
+ if (upsample->next_row_out >= cinfo->max_v_samp_factor)
140
+ (*in_row_group_ctr)++;
141
+ }
142
+
143
+
144
+ /*
145
+ * These are the routines invoked by sep_upsample to upsample pixel values
146
+ * of a single component. One row group is processed per call.
147
+ */
148
+
149
+
150
+ /*
151
+ * For full-size components, we just make color_buf[ci] point at the
152
+ * input buffer, and thus avoid copying any data. Note that this is
153
+ * safe only because sep_upsample doesn't declare the input row group
154
+ * "consumed" until we are done color converting and emitting it.
155
+ */
156
+
157
+ METHODDEF(void)
158
+ fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
159
+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
160
+ {
161
+ *output_data_ptr = input_data;
162
+ }
163
+
164
+
165
+ /*
166
+ * This is a no-op version used for "uninteresting" components.
167
+ * These components will not be referenced by color conversion.
168
+ */
169
+
170
+ METHODDEF(void)
171
+ noop_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
172
+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
173
+ {
174
+ *output_data_ptr = NULL; /* safety check */
175
+ }
176
+
177
+
178
+ /*
179
+ * This version handles any integral sampling ratios.
180
+ * This is not used for typical JPEG files, so it need not be fast.
181
+ * Nor, for that matter, is it particularly accurate: the algorithm is
182
+ * simple replication of the input pixel onto the corresponding output
183
+ * pixels. The hi-falutin sampling literature refers to this as a
184
+ * "box filter". A box filter tends to introduce visible artifacts,
185
+ * so if you are actually going to use 3:1 or 4:1 sampling ratios
186
+ * you would be well advised to improve this code.
187
+ */
188
+
189
+ METHODDEF(void)
190
+ int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
191
+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
192
+ {
193
+ my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample;
194
+ JSAMPARRAY output_data = *output_data_ptr;
195
+ register JSAMPROW inptr, outptr;
196
+ register JSAMPLE invalue;
197
+ register int h;
198
+ JSAMPROW outend;
199
+ int h_expand, v_expand;
200
+ int inrow, outrow;
201
+
202
+ h_expand = upsample->h_expand[compptr->component_index];
203
+ v_expand = upsample->v_expand[compptr->component_index];
204
+
205
+ inrow = outrow = 0;
206
+ while (outrow < cinfo->max_v_samp_factor) {
207
+ /* Generate one output row with proper horizontal expansion */
208
+ inptr = input_data[inrow];
209
+ outptr = output_data[outrow];
210
+ outend = outptr + cinfo->output_width;
211
+ while (outptr < outend) {
212
+ invalue = *inptr++; /* don't need GETJSAMPLE() here */
213
+ for (h = h_expand; h > 0; h--) {
214
+ *outptr++ = invalue;
215
+ }
216
+ }
217
+ /* Generate any additional output rows by duplicating the first one */
218
+ if (v_expand > 1) {
219
+ jcopy_sample_rows(output_data, outrow, output_data, outrow+1,
220
+ v_expand-1, cinfo->output_width);
221
+ }
222
+ inrow++;
223
+ outrow += v_expand;
224
+ }
225
+ }
226
+
227
+
228
+ /*
229
+ * Fast processing for the common case of 2:1 horizontal and 1:1 vertical.
230
+ * It's still a box filter.
231
+ */
232
+
233
+ METHODDEF(void)
234
+ h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
235
+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
236
+ {
237
+ JSAMPARRAY output_data = *output_data_ptr;
238
+ register JSAMPROW inptr, outptr;
239
+ register JSAMPLE invalue;
240
+ JSAMPROW outend;
241
+ int outrow;
242
+
243
+ for (outrow = 0; outrow < cinfo->max_v_samp_factor; outrow++) {
244
+ inptr = input_data[outrow];
245
+ outptr = output_data[outrow];
246
+ outend = outptr + cinfo->output_width;
247
+ while (outptr < outend) {
248
+ invalue = *inptr++; /* don't need GETJSAMPLE() here */
249
+ *outptr++ = invalue;
250
+ *outptr++ = invalue;
251
+ }
252
+ }
253
+ }
254
+
255
+
256
+ /*
257
+ * Fast processing for the common case of 2:1 horizontal and 2:1 vertical.
258
+ * It's still a box filter.
259
+ */
260
+
261
+ METHODDEF(void)
262
+ h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr,
263
+ JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)
264
+ {
265
+ JSAMPARRAY output_data = *output_data_ptr;
266
+ register JSAMPROW inptr, outptr;
267
+ register JSAMPLE invalue;
268
+ JSAMPROW outend;
269
+ int inrow, outrow;
270
+
271
+ inrow = outrow = 0;
272
+ while (outrow < cinfo->max_v_samp_factor) {
273
+ inptr = input_data[inrow];
274
+ outptr = output_data[outrow];
275
+ outend = outptr + cinfo->output_width;
276
+ while (outptr < outend) {
277
+ invalue = *inptr++; /* don't need GETJSAMPLE() here */
278
+ *outptr++ = invalue;
279
+ *outptr++ = invalue;
280
+ }
281
+ jcopy_sample_rows(output_data, outrow, output_data, outrow+1,
282
+ 1, cinfo->output_width);
283
+ inrow++;
284
+ outrow += 2;
285
+ }
286
+ }
287
+
288
+
289
+ /*
290
+ * Module initialization routine for upsampling.
291
+ */
292
+
293
+ GLOBAL(void)
294
+ jinit_upsampler (j_decompress_ptr cinfo)
295
+ {
296
+ my_upsample_ptr upsample;
297
+ int ci;
298
+ jpeg_component_info * compptr;
299
+ boolean need_buffer;
300
+ int h_in_group, v_in_group, h_out_group, v_out_group;
301
+
302
+ upsample = (my_upsample_ptr)
303
+ (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
304
+ SIZEOF(my_upsampler));
305
+ cinfo->upsample = (struct jpeg_upsampler *) upsample;
306
+ upsample->pub.start_pass = start_pass_upsample;
307
+ upsample->pub.upsample = sep_upsample;
308
+ upsample->pub.need_context_rows = FALSE; /* until we find out differently */
309
+
310
+ if (cinfo->CCIR601_sampling) /* this isn't supported */
311
+ ERREXIT(cinfo, JERR_CCIR601_NOTIMPL);
312
+
313
+ /* Verify we can handle the sampling factors, select per-component methods,
314
+ * and create storage as needed.
315
+ */
316
+ for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
317
+ ci++, compptr++) {
318
+ /* Compute size of an "input group" after IDCT scaling. This many samples
319
+ * are to be converted to max_h_samp_factor * max_v_samp_factor pixels.
320
+ */
321
+ h_in_group = (compptr->h_samp_factor * compptr->DCT_h_scaled_size) /
322
+ cinfo->min_DCT_h_scaled_size;
323
+ v_in_group = (compptr->v_samp_factor * compptr->DCT_v_scaled_size) /
324
+ cinfo->min_DCT_v_scaled_size;
325
+ h_out_group = cinfo->max_h_samp_factor;
326
+ v_out_group = cinfo->max_v_samp_factor;
327
+ upsample->rowgroup_height[ci] = v_in_group; /* save for use later */
328
+ need_buffer = TRUE;
329
+ if (! compptr->component_needed) {
330
+ /* Don't bother to upsample an uninteresting component. */
331
+ upsample->methods[ci] = noop_upsample;
332
+ need_buffer = FALSE;
333
+ } else if (h_in_group == h_out_group && v_in_group == v_out_group) {
334
+ /* Fullsize components can be processed without any work. */
335
+ upsample->methods[ci] = fullsize_upsample;
336
+ need_buffer = FALSE;
337
+ } else if (h_in_group * 2 == h_out_group &&
338
+ v_in_group == v_out_group) {
339
+ /* Special case for 2h1v upsampling */
340
+ upsample->methods[ci] = h2v1_upsample;
341
+ } else if (h_in_group * 2 == h_out_group &&
342
+ v_in_group * 2 == v_out_group) {
343
+ /* Special case for 2h2v upsampling */
344
+ upsample->methods[ci] = h2v2_upsample;
345
+ } else if ((h_out_group % h_in_group) == 0 &&
346
+ (v_out_group % v_in_group) == 0) {
347
+ /* Generic integral-factors upsampling method */
348
+ upsample->methods[ci] = int_upsample;
349
+ upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group);
350
+ upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group);
351
+ } else
352
+ ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL);
353
+ if (need_buffer) {
354
+ upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray)
355
+ ((j_common_ptr) cinfo, JPOOL_IMAGE,
356
+ (JDIMENSION) jround_up((long) cinfo->output_width,
357
+ (long) cinfo->max_h_samp_factor),
358
+ (JDIMENSION) cinfo->max_v_samp_factor);
359
+ }
360
+ }
361
+ }
@@ -0,0 +1,136 @@
1
+ /*
2
+ * jdtrans.c
3
+ *
4
+ * Copyright (C) 1995-1997, Thomas G. Lane.
5
+ * This file is part of the Independent JPEG Group's software.
6
+ * For conditions of distribution and use, see the accompanying README file.
7
+ *
8
+ * This file contains library routines for transcoding decompression,
9
+ * that is, reading raw DCT coefficient arrays from an input JPEG file.
10
+ * The routines in jdapimin.c will also be needed by a transcoder.
11
+ */
12
+
13
+ #define JPEG_INTERNALS
14
+ #include "jinclude.h"
15
+ #include "jpeglib.h"
16
+
17
+
18
+ /* Forward declarations */
19
+ LOCAL(void) transdecode_master_selection JPP((j_decompress_ptr cinfo));
20
+
21
+
22
+ /*
23
+ * Read the coefficient arrays from a JPEG file.
24
+ * jpeg_read_header must be completed before calling this.
25
+ *
26
+ * The entire image is read into a set of virtual coefficient-block arrays,
27
+ * one per component. The return value is a pointer to the array of
28
+ * virtual-array descriptors. These can be manipulated directly via the
29
+ * JPEG memory manager, or handed off to jpeg_write_coefficients().
30
+ * To release the memory occupied by the virtual arrays, call
31
+ * jpeg_finish_decompress() when done with the data.
32
+ *
33
+ * An alternative usage is to simply obtain access to the coefficient arrays
34
+ * during a buffered-image-mode decompression operation. This is allowed
35
+ * after any jpeg_finish_output() call. The arrays can be accessed until
36
+ * jpeg_finish_decompress() is called. (Note that any call to the library
37
+ * may reposition the arrays, so don't rely on access_virt_barray() results
38
+ * to stay valid across library calls.)
39
+ *
40
+ * Returns NULL if suspended. This case need be checked only if
41
+ * a suspending data source is used.
42
+ */
43
+
44
+ GLOBAL(jvirt_barray_ptr *)
45
+ jpeg_read_coefficients (j_decompress_ptr cinfo)
46
+ {
47
+ if (cinfo->global_state == DSTATE_READY) {
48
+ /* First call: initialize active modules */
49
+ transdecode_master_selection(cinfo);
50
+ cinfo->global_state = DSTATE_RDCOEFS;
51
+ }
52
+ if (cinfo->global_state == DSTATE_RDCOEFS) {
53
+ /* Absorb whole file into the coef buffer */
54
+ for (;;) {
55
+ int retcode;
56
+ /* Call progress monitor hook if present */
57
+ if (cinfo->progress != NULL)
58
+ (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
59
+ /* Absorb some more input */
60
+ retcode = (*cinfo->inputctl->consume_input) (cinfo);
61
+ if (retcode == JPEG_SUSPENDED)
62
+ return NULL;
63
+ if (retcode == JPEG_REACHED_EOI)
64
+ break;
65
+ /* Advance progress counter if appropriate */
66
+ if (cinfo->progress != NULL &&
67
+ (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
68
+ if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
69
+ /* startup underestimated number of scans; ratchet up one scan */
70
+ cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;
71
+ }
72
+ }
73
+ }
74
+ /* Set state so that jpeg_finish_decompress does the right thing */
75
+ cinfo->global_state = DSTATE_STOPPING;
76
+ }
77
+ /* At this point we should be in state DSTATE_STOPPING if being used
78
+ * standalone, or in state DSTATE_BUFIMAGE if being invoked to get access
79
+ * to the coefficients during a full buffered-image-mode decompression.
80
+ */
81
+ if ((cinfo->global_state == DSTATE_STOPPING ||
82
+ cinfo->global_state == DSTATE_BUFIMAGE) && cinfo->buffered_image) {
83
+ return cinfo->coef->coef_arrays;
84
+ }
85
+ /* Oops, improper usage */
86
+ ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
87
+ return NULL; /* keep compiler happy */
88
+ }
89
+
90
+
91
+ /*
92
+ * Master selection of decompression modules for transcoding.
93
+ * This substitutes for jdmaster.c's initialization of the full decompressor.
94
+ */
95
+
96
+ LOCAL(void)
97
+ transdecode_master_selection (j_decompress_ptr cinfo)
98
+ {
99
+ /* This is effectively a buffered-image operation. */
100
+ cinfo->buffered_image = TRUE;
101
+
102
+ /* Entropy decoding: either Huffman or arithmetic coding. */
103
+ if (cinfo->arith_code)
104
+ jinit_arith_decoder(cinfo);
105
+ else {
106
+ jinit_huff_decoder(cinfo);
107
+ }
108
+
109
+ /* Always get a full-image coefficient buffer. */
110
+ jinit_d_coef_controller(cinfo, TRUE);
111
+
112
+ /* We can now tell the memory manager to allocate virtual arrays. */
113
+ (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
114
+
115
+ /* Initialize input side of decompressor to consume first scan. */
116
+ (*cinfo->inputctl->start_input_pass) (cinfo);
117
+
118
+ /* Initialize progress monitoring. */
119
+ if (cinfo->progress != NULL) {
120
+ int nscans;
121
+ /* Estimate number of scans to set pass_limit. */
122
+ if (cinfo->progressive_mode) {
123
+ /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */
124
+ nscans = 2 + 3 * cinfo->num_components;
125
+ } else if (cinfo->inputctl->has_multiple_scans) {
126
+ /* For a nonprogressive multiscan file, estimate 1 scan per component. */
127
+ nscans = cinfo->num_components;
128
+ } else {
129
+ nscans = 1;
130
+ }
131
+ cinfo->progress->pass_counter = 0L;
132
+ cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;
133
+ cinfo->progress->completed_passes = 0;
134
+ cinfo->progress->total_passes = 1;
135
+ }
136
+ }