isbn 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. data/{README → README.md} +5 -11
  2. data/Rakefile +20 -14
  3. data/isbn.gemspec +23 -0
  4. data/lib/isbn.rb +2 -0
  5. data/test/isbn_spec.rb +1 -1
  6. metadata +29 -316
  7. data/VERSION +0 -1
  8. data/src/gocr-0.48/.cvsignore +0 -6
  9. data/src/gocr-0.48/AUTHORS +0 -7
  10. data/src/gocr-0.48/BUGS +0 -55
  11. data/src/gocr-0.48/CREDITS +0 -17
  12. data/src/gocr-0.48/HISTORY +0 -243
  13. data/src/gocr-0.48/INSTALL +0 -83
  14. data/src/gocr-0.48/Makefile +0 -193
  15. data/src/gocr-0.48/Makefile.in +0 -193
  16. data/src/gocr-0.48/README +0 -165
  17. data/src/gocr-0.48/READMEde.txt +0 -80
  18. data/src/gocr-0.48/REMARK.txt +0 -18
  19. data/src/gocr-0.48/REVIEW +0 -538
  20. data/src/gocr-0.48/TODO +0 -65
  21. data/src/gocr-0.48/bin/.cvsignore +0 -2
  22. data/src/gocr-0.48/bin/create_db +0 -38
  23. data/src/gocr-0.48/bin/gocr.tcl +0 -527
  24. data/src/gocr-0.48/bin/gocr_chk.sh +0 -44
  25. data/src/gocr-0.48/configure +0 -4689
  26. data/src/gocr-0.48/configure.in +0 -71
  27. data/src/gocr-0.48/doc/.#Makefile.1.6 +0 -39
  28. data/src/gocr-0.48/doc/.cvsignore +0 -2
  29. data/src/gocr-0.48/doc/Makefile +0 -39
  30. data/src/gocr-0.48/doc/Makefile.in +0 -39
  31. data/src/gocr-0.48/doc/example.dtd +0 -53
  32. data/src/gocr-0.48/doc/example.xml +0 -21
  33. data/src/gocr-0.48/doc/examples.txt +0 -67
  34. data/src/gocr-0.48/doc/gocr.html +0 -578
  35. data/src/gocr-0.48/doc/unicode.txt +0 -57
  36. data/src/gocr-0.48/examples/.#Makefile.1.22 +0 -166
  37. data/src/gocr-0.48/examples/4x6.png +0 -0
  38. data/src/gocr-0.48/examples/4x6.txt +0 -2
  39. data/src/gocr-0.48/examples/5x7.png +0 -0
  40. data/src/gocr-0.48/examples/5x7.png.txt +0 -2
  41. data/src/gocr-0.48/examples/5x8.png +0 -0
  42. data/src/gocr-0.48/examples/5x8.png.txt +0 -2
  43. data/src/gocr-0.48/examples/Makefile +0 -166
  44. data/src/gocr-0.48/examples/color.fig +0 -20
  45. data/src/gocr-0.48/examples/ex.fig +0 -16
  46. data/src/gocr-0.48/examples/font.tex +0 -22
  47. data/src/gocr-0.48/examples/font1.tex +0 -46
  48. data/src/gocr-0.48/examples/font2.fig +0 -27
  49. data/src/gocr-0.48/examples/font_nw.tex +0 -24
  50. data/src/gocr-0.48/examples/handwrt1.jpg +0 -0
  51. data/src/gocr-0.48/examples/handwrt1.txt +0 -10
  52. data/src/gocr-0.48/examples/inverse.fig +0 -20
  53. data/src/gocr-0.48/examples/matrix.jpg +0 -0
  54. data/src/gocr-0.48/examples/ocr-a-subset.png +0 -0
  55. data/src/gocr-0.48/examples/ocr-a-subset.png.txt +0 -4
  56. data/src/gocr-0.48/examples/ocr-a.png +0 -0
  57. data/src/gocr-0.48/examples/ocr-a.txt +0 -6
  58. data/src/gocr-0.48/examples/ocr-b.png +0 -0
  59. data/src/gocr-0.48/examples/ocr-b.png.txt +0 -4
  60. data/src/gocr-0.48/examples/polish.tex +0 -28
  61. data/src/gocr-0.48/examples/rotate45.fig +0 -14
  62. data/src/gocr-0.48/examples/score +0 -36
  63. data/src/gocr-0.48/examples/text.tex +0 -28
  64. data/src/gocr-0.48/gpl.html +0 -537
  65. data/src/gocr-0.48/include/.cvsignore +0 -2
  66. data/src/gocr-0.48/include/config.h +0 -36
  67. data/src/gocr-0.48/include/config.h.in +0 -36
  68. data/src/gocr-0.48/include/version.h +0 -2
  69. data/src/gocr-0.48/install-sh +0 -3
  70. data/src/gocr-0.48/make.bat +0 -57
  71. data/src/gocr-0.48/man/.cvsignore +0 -2
  72. data/src/gocr-0.48/man/Makefile +0 -29
  73. data/src/gocr-0.48/man/Makefile.in +0 -29
  74. data/src/gocr-0.48/man/man1/gocr.1 +0 -166
  75. data/src/gocr-0.48/src/.cvsignore +0 -4
  76. data/src/gocr-0.48/src/Makefile +0 -132
  77. data/src/gocr-0.48/src/Makefile.in +0 -132
  78. data/src/gocr-0.48/src/amiga.h +0 -31
  79. data/src/gocr-0.48/src/barcode.c +0 -846
  80. data/src/gocr-0.48/src/barcode.c.orig +0 -593
  81. data/src/gocr-0.48/src/barcode.h +0 -11
  82. data/src/gocr-0.48/src/box.c +0 -372
  83. data/src/gocr-0.48/src/database.c +0 -462
  84. data/src/gocr-0.48/src/detect.c +0 -943
  85. data/src/gocr-0.48/src/gocr.c +0 -373
  86. data/src/gocr-0.48/src/gocr.h +0 -288
  87. data/src/gocr-0.48/src/jconv.c +0 -168
  88. data/src/gocr-0.48/src/job.c +0 -84
  89. data/src/gocr-0.48/src/lines.c +0 -350
  90. data/src/gocr-0.48/src/list.c +0 -334
  91. data/src/gocr-0.48/src/list.h +0 -90
  92. data/src/gocr-0.48/src/ocr0.c +0 -6756
  93. data/src/gocr-0.48/src/ocr0.h +0 -63
  94. data/src/gocr-0.48/src/ocr0n.c +0 -1475
  95. data/src/gocr-0.48/src/ocr1.c +0 -85
  96. data/src/gocr-0.48/src/ocr1.h +0 -3
  97. data/src/gocr-0.48/src/otsu.c +0 -289
  98. data/src/gocr-0.48/src/otsu.h +0 -23
  99. data/src/gocr-0.48/src/output.c +0 -289
  100. data/src/gocr-0.48/src/output.h +0 -37
  101. data/src/gocr-0.48/src/pcx.c +0 -153
  102. data/src/gocr-0.48/src/pcx.h +0 -9
  103. data/src/gocr-0.48/src/pgm2asc.c +0 -2893
  104. data/src/gocr-0.48/src/pgm2asc.h +0 -105
  105. data/src/gocr-0.48/src/pixel.c +0 -537
  106. data/src/gocr-0.48/src/pnm.c +0 -533
  107. data/src/gocr-0.48/src/pnm.h +0 -35
  108. data/src/gocr-0.48/src/progress.c +0 -87
  109. data/src/gocr-0.48/src/progress.h +0 -42
  110. data/src/gocr-0.48/src/remove.c +0 -703
  111. data/src/gocr-0.48/src/tga.c +0 -87
  112. data/src/gocr-0.48/src/tga.h +0 -6
  113. data/src/gocr-0.48/src/unicode.c +0 -1314
  114. data/src/gocr-0.48/src/unicode.h +0 -1257
  115. data/src/jpeg-7/Makefile.am +0 -133
  116. data/src/jpeg-7/Makefile.in +0 -1089
  117. data/src/jpeg-7/README +0 -322
  118. data/src/jpeg-7/aclocal.m4 +0 -8990
  119. data/src/jpeg-7/ansi2knr.1 +0 -36
  120. data/src/jpeg-7/ansi2knr.c +0 -739
  121. data/src/jpeg-7/cderror.h +0 -132
  122. data/src/jpeg-7/cdjpeg.c +0 -181
  123. data/src/jpeg-7/cdjpeg.h +0 -187
  124. data/src/jpeg-7/change.log +0 -270
  125. data/src/jpeg-7/cjpeg.1 +0 -325
  126. data/src/jpeg-7/cjpeg.c +0 -616
  127. data/src/jpeg-7/ckconfig.c +0 -402
  128. data/src/jpeg-7/coderules.txt +0 -118
  129. data/src/jpeg-7/config.guess +0 -1561
  130. data/src/jpeg-7/config.sub +0 -1686
  131. data/src/jpeg-7/configure +0 -17139
  132. data/src/jpeg-7/configure.ac +0 -317
  133. data/src/jpeg-7/depcomp +0 -630
  134. data/src/jpeg-7/djpeg.1 +0 -251
  135. data/src/jpeg-7/djpeg.c +0 -617
  136. data/src/jpeg-7/example.c +0 -433
  137. data/src/jpeg-7/filelist.txt +0 -215
  138. data/src/jpeg-7/install-sh +0 -520
  139. data/src/jpeg-7/install.txt +0 -1097
  140. data/src/jpeg-7/jaricom.c +0 -148
  141. data/src/jpeg-7/jcapimin.c +0 -282
  142. data/src/jpeg-7/jcapistd.c +0 -161
  143. data/src/jpeg-7/jcarith.c +0 -921
  144. data/src/jpeg-7/jccoefct.c +0 -453
  145. data/src/jpeg-7/jccolor.c +0 -459
  146. data/src/jpeg-7/jcdctmgr.c +0 -482
  147. data/src/jpeg-7/jchuff.c +0 -1612
  148. data/src/jpeg-7/jcinit.c +0 -65
  149. data/src/jpeg-7/jcmainct.c +0 -293
  150. data/src/jpeg-7/jcmarker.c +0 -667
  151. data/src/jpeg-7/jcmaster.c +0 -770
  152. data/src/jpeg-7/jcomapi.c +0 -106
  153. data/src/jpeg-7/jconfig.bcc +0 -48
  154. data/src/jpeg-7/jconfig.cfg +0 -45
  155. data/src/jpeg-7/jconfig.dj +0 -38
  156. data/src/jpeg-7/jconfig.mac +0 -43
  157. data/src/jpeg-7/jconfig.manx +0 -43
  158. data/src/jpeg-7/jconfig.mc6 +0 -52
  159. data/src/jpeg-7/jconfig.sas +0 -43
  160. data/src/jpeg-7/jconfig.st +0 -42
  161. data/src/jpeg-7/jconfig.txt +0 -155
  162. data/src/jpeg-7/jconfig.vc +0 -45
  163. data/src/jpeg-7/jconfig.vms +0 -37
  164. data/src/jpeg-7/jconfig.wat +0 -38
  165. data/src/jpeg-7/jcparam.c +0 -632
  166. data/src/jpeg-7/jcprepct.c +0 -358
  167. data/src/jpeg-7/jcsample.c +0 -545
  168. data/src/jpeg-7/jctrans.c +0 -381
  169. data/src/jpeg-7/jdapimin.c +0 -396
  170. data/src/jpeg-7/jdapistd.c +0 -275
  171. data/src/jpeg-7/jdarith.c +0 -762
  172. data/src/jpeg-7/jdatadst.c +0 -151
  173. data/src/jpeg-7/jdatasrc.c +0 -212
  174. data/src/jpeg-7/jdcoefct.c +0 -736
  175. data/src/jpeg-7/jdcolor.c +0 -396
  176. data/src/jpeg-7/jdct.h +0 -393
  177. data/src/jpeg-7/jddctmgr.c +0 -382
  178. data/src/jpeg-7/jdhuff.c +0 -1309
  179. data/src/jpeg-7/jdinput.c +0 -384
  180. data/src/jpeg-7/jdmainct.c +0 -512
  181. data/src/jpeg-7/jdmarker.c +0 -1360
  182. data/src/jpeg-7/jdmaster.c +0 -663
  183. data/src/jpeg-7/jdmerge.c +0 -400
  184. data/src/jpeg-7/jdpostct.c +0 -290
  185. data/src/jpeg-7/jdsample.c +0 -361
  186. data/src/jpeg-7/jdtrans.c +0 -136
  187. data/src/jpeg-7/jerror.c +0 -252
  188. data/src/jpeg-7/jerror.h +0 -304
  189. data/src/jpeg-7/jfdctflt.c +0 -174
  190. data/src/jpeg-7/jfdctfst.c +0 -230
  191. data/src/jpeg-7/jfdctint.c +0 -4348
  192. data/src/jpeg-7/jidctflt.c +0 -242
  193. data/src/jpeg-7/jidctfst.c +0 -368
  194. data/src/jpeg-7/jidctint.c +0 -5137
  195. data/src/jpeg-7/jinclude.h +0 -91
  196. data/src/jpeg-7/jmemansi.c +0 -167
  197. data/src/jpeg-7/jmemdos.c +0 -638
  198. data/src/jpeg-7/jmemdosa.asm +0 -379
  199. data/src/jpeg-7/jmemmac.c +0 -289
  200. data/src/jpeg-7/jmemmgr.c +0 -1118
  201. data/src/jpeg-7/jmemname.c +0 -276
  202. data/src/jpeg-7/jmemnobs.c +0 -109
  203. data/src/jpeg-7/jmemsys.h +0 -198
  204. data/src/jpeg-7/jmorecfg.h +0 -369
  205. data/src/jpeg-7/jpegint.h +0 -395
  206. data/src/jpeg-7/jpeglib.h +0 -1135
  207. data/src/jpeg-7/jpegtran.1 +0 -272
  208. data/src/jpeg-7/jpegtran.c +0 -546
  209. data/src/jpeg-7/jquant1.c +0 -856
  210. data/src/jpeg-7/jquant2.c +0 -1310
  211. data/src/jpeg-7/jutils.c +0 -179
  212. data/src/jpeg-7/jversion.h +0 -14
  213. data/src/jpeg-7/libjpeg.map +0 -4
  214. data/src/jpeg-7/libjpeg.txt +0 -3067
  215. data/src/jpeg-7/ltmain.sh +0 -8406
  216. data/src/jpeg-7/makcjpeg.st +0 -36
  217. data/src/jpeg-7/makdjpeg.st +0 -36
  218. data/src/jpeg-7/makeadsw.vc6 +0 -77
  219. data/src/jpeg-7/makeasln.vc9 +0 -33
  220. data/src/jpeg-7/makecdep.vc6 +0 -82
  221. data/src/jpeg-7/makecdsp.vc6 +0 -130
  222. data/src/jpeg-7/makecmak.vc6 +0 -159
  223. data/src/jpeg-7/makecvcp.vc9 +0 -186
  224. data/src/jpeg-7/makeddep.vc6 +0 -82
  225. data/src/jpeg-7/makeddsp.vc6 +0 -130
  226. data/src/jpeg-7/makedmak.vc6 +0 -159
  227. data/src/jpeg-7/makedvcp.vc9 +0 -186
  228. data/src/jpeg-7/makefile.ansi +0 -220
  229. data/src/jpeg-7/makefile.bcc +0 -291
  230. data/src/jpeg-7/makefile.dj +0 -226
  231. data/src/jpeg-7/makefile.manx +0 -220
  232. data/src/jpeg-7/makefile.mc6 +0 -255
  233. data/src/jpeg-7/makefile.mms +0 -224
  234. data/src/jpeg-7/makefile.sas +0 -258
  235. data/src/jpeg-7/makefile.unix +0 -234
  236. data/src/jpeg-7/makefile.vc +0 -217
  237. data/src/jpeg-7/makefile.vms +0 -142
  238. data/src/jpeg-7/makefile.wat +0 -239
  239. data/src/jpeg-7/makejdep.vc6 +0 -423
  240. data/src/jpeg-7/makejdsp.vc6 +0 -285
  241. data/src/jpeg-7/makejdsw.vc6 +0 -29
  242. data/src/jpeg-7/makejmak.vc6 +0 -425
  243. data/src/jpeg-7/makejsln.vc9 +0 -17
  244. data/src/jpeg-7/makejvcp.vc9 +0 -328
  245. data/src/jpeg-7/makeproj.mac +0 -213
  246. data/src/jpeg-7/makerdep.vc6 +0 -6
  247. data/src/jpeg-7/makerdsp.vc6 +0 -78
  248. data/src/jpeg-7/makermak.vc6 +0 -110
  249. data/src/jpeg-7/makervcp.vc9 +0 -133
  250. data/src/jpeg-7/maketdep.vc6 +0 -43
  251. data/src/jpeg-7/maketdsp.vc6 +0 -122
  252. data/src/jpeg-7/maketmak.vc6 +0 -131
  253. data/src/jpeg-7/maketvcp.vc9 +0 -178
  254. data/src/jpeg-7/makewdep.vc6 +0 -6
  255. data/src/jpeg-7/makewdsp.vc6 +0 -78
  256. data/src/jpeg-7/makewmak.vc6 +0 -110
  257. data/src/jpeg-7/makewvcp.vc9 +0 -133
  258. data/src/jpeg-7/makljpeg.st +0 -68
  259. data/src/jpeg-7/maktjpeg.st +0 -30
  260. data/src/jpeg-7/makvms.opt +0 -4
  261. data/src/jpeg-7/missing +0 -376
  262. data/src/jpeg-7/rdbmp.c +0 -439
  263. data/src/jpeg-7/rdcolmap.c +0 -253
  264. data/src/jpeg-7/rdgif.c +0 -38
  265. data/src/jpeg-7/rdjpgcom.1 +0 -63
  266. data/src/jpeg-7/rdjpgcom.c +0 -515
  267. data/src/jpeg-7/rdppm.c +0 -459
  268. data/src/jpeg-7/rdrle.c +0 -387
  269. data/src/jpeg-7/rdswitch.c +0 -365
  270. data/src/jpeg-7/rdtarga.c +0 -500
  271. data/src/jpeg-7/structure.txt +0 -945
  272. data/src/jpeg-7/testimg.bmp +0 -0
  273. data/src/jpeg-7/testimg.jpg +0 -0
  274. data/src/jpeg-7/testimg.ppm +0 -4
  275. data/src/jpeg-7/testimgp.jpg +0 -0
  276. data/src/jpeg-7/testorig.jpg +0 -0
  277. data/src/jpeg-7/testprog.jpg +0 -0
  278. data/src/jpeg-7/transupp.c +0 -1533
  279. data/src/jpeg-7/transupp.h +0 -205
  280. data/src/jpeg-7/usage.txt +0 -605
  281. data/src/jpeg-7/wizard.txt +0 -211
  282. data/src/jpeg-7/wrbmp.c +0 -442
  283. data/src/jpeg-7/wrgif.c +0 -399
  284. data/src/jpeg-7/wrjpgcom.1 +0 -103
  285. data/src/jpeg-7/wrjpgcom.c +0 -583
  286. data/src/jpeg-7/wrppm.c +0 -269
  287. data/src/jpeg-7/wrrle.c +0 -305
  288. data/src/jpeg-7/wrtarga.c +0 -253
@@ -1,663 +0,0 @@
1
- /*
2
- * jdmaster.c
3
- *
4
- * Copyright (C) 1991-1997, 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 master control logic for the JPEG decompressor.
10
- * These routines are concerned with selecting the modules to be executed
11
- * and with determining the number of passes and the work to be done in each
12
- * pass.
13
- */
14
-
15
- #define JPEG_INTERNALS
16
- #include "jinclude.h"
17
- #include "jpeglib.h"
18
-
19
-
20
- /* Private state */
21
-
22
- typedef struct {
23
- struct jpeg_decomp_master pub; /* public fields */
24
-
25
- int pass_number; /* # of passes completed */
26
-
27
- boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */
28
-
29
- /* Saved references to initialized quantizer modules,
30
- * in case we need to switch modes.
31
- */
32
- struct jpeg_color_quantizer * quantizer_1pass;
33
- struct jpeg_color_quantizer * quantizer_2pass;
34
- } my_decomp_master;
35
-
36
- typedef my_decomp_master * my_master_ptr;
37
-
38
-
39
- /*
40
- * Determine whether merged upsample/color conversion should be used.
41
- * CRUCIAL: this must match the actual capabilities of jdmerge.c!
42
- */
43
-
44
- LOCAL(boolean)
45
- use_merged_upsample (j_decompress_ptr cinfo)
46
- {
47
- #ifdef UPSAMPLE_MERGING_SUPPORTED
48
- /* Merging is the equivalent of plain box-filter upsampling */
49
- if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling)
50
- return FALSE;
51
- /* jdmerge.c only supports YCC=>RGB color conversion */
52
- if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 ||
53
- cinfo->out_color_space != JCS_RGB ||
54
- cinfo->out_color_components != RGB_PIXELSIZE)
55
- return FALSE;
56
- /* and it only handles 2h1v or 2h2v sampling ratios */
57
- if (cinfo->comp_info[0].h_samp_factor != 2 ||
58
- cinfo->comp_info[1].h_samp_factor != 1 ||
59
- cinfo->comp_info[2].h_samp_factor != 1 ||
60
- cinfo->comp_info[0].v_samp_factor > 2 ||
61
- cinfo->comp_info[1].v_samp_factor != 1 ||
62
- cinfo->comp_info[2].v_samp_factor != 1)
63
- return FALSE;
64
- /* furthermore, it doesn't work if we've scaled the IDCTs differently */
65
- if (cinfo->comp_info[0].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size ||
66
- cinfo->comp_info[1].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size ||
67
- cinfo->comp_info[2].DCT_h_scaled_size != cinfo->min_DCT_h_scaled_size ||
68
- cinfo->comp_info[0].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size ||
69
- cinfo->comp_info[1].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size ||
70
- cinfo->comp_info[2].DCT_v_scaled_size != cinfo->min_DCT_v_scaled_size)
71
- return FALSE;
72
- /* ??? also need to test for upsample-time rescaling, when & if supported */
73
- return TRUE; /* by golly, it'll work... */
74
- #else
75
- return FALSE;
76
- #endif
77
- }
78
-
79
-
80
- /*
81
- * Compute output image dimensions and related values.
82
- * NOTE: this is exported for possible use by application.
83
- * Hence it mustn't do anything that can't be done twice.
84
- * Also note that it may be called before the master module is initialized!
85
- */
86
-
87
- GLOBAL(void)
88
- jpeg_calc_output_dimensions (j_decompress_ptr cinfo)
89
- /* Do computations that are needed before master selection phase */
90
- {
91
- #ifdef IDCT_SCALING_SUPPORTED
92
- int ci;
93
- jpeg_component_info *compptr;
94
- #endif
95
-
96
- /* Prevent application from calling me at wrong times */
97
- if (cinfo->global_state != DSTATE_READY)
98
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
99
-
100
- #ifdef IDCT_SCALING_SUPPORTED
101
-
102
- /* Compute actual output image dimensions and DCT scaling choices. */
103
- if (cinfo->scale_num * 8 <= cinfo->scale_denom) {
104
- /* Provide 1/8 scaling */
105
- cinfo->output_width = (JDIMENSION)
106
- jdiv_round_up((long) cinfo->image_width, 8L);
107
- cinfo->output_height = (JDIMENSION)
108
- jdiv_round_up((long) cinfo->image_height, 8L);
109
- cinfo->min_DCT_h_scaled_size = 1;
110
- cinfo->min_DCT_v_scaled_size = 1;
111
- } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) {
112
- /* Provide 1/4 scaling */
113
- cinfo->output_width = (JDIMENSION)
114
- jdiv_round_up((long) cinfo->image_width, 4L);
115
- cinfo->output_height = (JDIMENSION)
116
- jdiv_round_up((long) cinfo->image_height, 4L);
117
- cinfo->min_DCT_h_scaled_size = 2;
118
- cinfo->min_DCT_v_scaled_size = 2;
119
- } else if (cinfo->scale_num * 8 <= cinfo->scale_denom * 3) {
120
- /* Provide 3/8 scaling */
121
- cinfo->output_width = (JDIMENSION)
122
- jdiv_round_up((long) cinfo->image_width * 3L, 8L);
123
- cinfo->output_height = (JDIMENSION)
124
- jdiv_round_up((long) cinfo->image_height * 3L, 8L);
125
- cinfo->min_DCT_h_scaled_size = 3;
126
- cinfo->min_DCT_v_scaled_size = 3;
127
- } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) {
128
- /* Provide 1/2 scaling */
129
- cinfo->output_width = (JDIMENSION)
130
- jdiv_round_up((long) cinfo->image_width, 2L);
131
- cinfo->output_height = (JDIMENSION)
132
- jdiv_round_up((long) cinfo->image_height, 2L);
133
- cinfo->min_DCT_h_scaled_size = 4;
134
- cinfo->min_DCT_v_scaled_size = 4;
135
- } else if (cinfo->scale_num * 8 <= cinfo->scale_denom * 5) {
136
- /* Provide 5/8 scaling */
137
- cinfo->output_width = (JDIMENSION)
138
- jdiv_round_up((long) cinfo->image_width * 5L, 8L);
139
- cinfo->output_height = (JDIMENSION)
140
- jdiv_round_up((long) cinfo->image_height * 5L, 8L);
141
- cinfo->min_DCT_h_scaled_size = 5;
142
- cinfo->min_DCT_v_scaled_size = 5;
143
- } else if (cinfo->scale_num * 4 <= cinfo->scale_denom * 3) {
144
- /* Provide 3/4 scaling */
145
- cinfo->output_width = (JDIMENSION)
146
- jdiv_round_up((long) cinfo->image_width * 3L, 4L);
147
- cinfo->output_height = (JDIMENSION)
148
- jdiv_round_up((long) cinfo->image_height * 3L, 4L);
149
- cinfo->min_DCT_h_scaled_size = 6;
150
- cinfo->min_DCT_v_scaled_size = 6;
151
- } else if (cinfo->scale_num * 8 <= cinfo->scale_denom * 7) {
152
- /* Provide 7/8 scaling */
153
- cinfo->output_width = (JDIMENSION)
154
- jdiv_round_up((long) cinfo->image_width * 7L, 8L);
155
- cinfo->output_height = (JDIMENSION)
156
- jdiv_round_up((long) cinfo->image_height * 7L, 8L);
157
- cinfo->min_DCT_h_scaled_size = 7;
158
- cinfo->min_DCT_v_scaled_size = 7;
159
- } else if (cinfo->scale_num <= cinfo->scale_denom) {
160
- /* Provide 1/1 scaling */
161
- cinfo->output_width = cinfo->image_width;
162
- cinfo->output_height = cinfo->image_height;
163
- cinfo->min_DCT_h_scaled_size = DCTSIZE;
164
- cinfo->min_DCT_v_scaled_size = DCTSIZE;
165
- } else if (cinfo->scale_num * 8 <= cinfo->scale_denom * 9) {
166
- /* Provide 9/8 scaling */
167
- cinfo->output_width = cinfo->image_width + (JDIMENSION)
168
- jdiv_round_up((long) cinfo->image_width, 8L);
169
- cinfo->output_height = cinfo->image_height + (JDIMENSION)
170
- jdiv_round_up((long) cinfo->image_height, 8L);
171
- cinfo->min_DCT_h_scaled_size = 9;
172
- cinfo->min_DCT_v_scaled_size = 9;
173
- } else if (cinfo->scale_num * 4 <= cinfo->scale_denom * 5) {
174
- /* Provide 5/4 scaling */
175
- cinfo->output_width = cinfo->image_width + (JDIMENSION)
176
- jdiv_round_up((long) cinfo->image_width, 4L);
177
- cinfo->output_height = cinfo->image_height + (JDIMENSION)
178
- jdiv_round_up((long) cinfo->image_height, 4L);
179
- cinfo->min_DCT_h_scaled_size = 10;
180
- cinfo->min_DCT_v_scaled_size = 10;
181
- } else if (cinfo->scale_num * 8 <= cinfo->scale_denom * 11) {
182
- /* Provide 11/8 scaling */
183
- cinfo->output_width = cinfo->image_width + (JDIMENSION)
184
- jdiv_round_up((long) cinfo->image_width * 3L, 8L);
185
- cinfo->output_height = cinfo->image_height + (JDIMENSION)
186
- jdiv_round_up((long) cinfo->image_height * 3L, 8L);
187
- cinfo->min_DCT_h_scaled_size = 11;
188
- cinfo->min_DCT_v_scaled_size = 11;
189
- } else if (cinfo->scale_num * 2 <= cinfo->scale_denom * 3) {
190
- /* Provide 3/2 scaling */
191
- cinfo->output_width = cinfo->image_width + (JDIMENSION)
192
- jdiv_round_up((long) cinfo->image_width, 2L);
193
- cinfo->output_height = cinfo->image_height + (JDIMENSION)
194
- jdiv_round_up((long) cinfo->image_height, 2L);
195
- cinfo->min_DCT_h_scaled_size = 12;
196
- cinfo->min_DCT_v_scaled_size = 12;
197
- } else if (cinfo->scale_num * 8 <= cinfo->scale_denom * 13) {
198
- /* Provide 13/8 scaling */
199
- cinfo->output_width = cinfo->image_width + (JDIMENSION)
200
- jdiv_round_up((long) cinfo->image_width * 5L, 8L);
201
- cinfo->output_height = cinfo->image_height + (JDIMENSION)
202
- jdiv_round_up((long) cinfo->image_height * 5L, 8L);
203
- cinfo->min_DCT_h_scaled_size = 13;
204
- cinfo->min_DCT_v_scaled_size = 13;
205
- } else if (cinfo->scale_num * 4 <= cinfo->scale_denom * 7) {
206
- /* Provide 7/4 scaling */
207
- cinfo->output_width = cinfo->image_width + (JDIMENSION)
208
- jdiv_round_up((long) cinfo->image_width * 3L, 4L);
209
- cinfo->output_height = cinfo->image_height + (JDIMENSION)
210
- jdiv_round_up((long) cinfo->image_height * 3L, 4L);
211
- cinfo->min_DCT_h_scaled_size = 14;
212
- cinfo->min_DCT_v_scaled_size = 14;
213
- } else if (cinfo->scale_num * 8 <= cinfo->scale_denom * 15) {
214
- /* Provide 15/8 scaling */
215
- cinfo->output_width = cinfo->image_width + (JDIMENSION)
216
- jdiv_round_up((long) cinfo->image_width * 7L, 8L);
217
- cinfo->output_height = cinfo->image_height + (JDIMENSION)
218
- jdiv_round_up((long) cinfo->image_height * 7L, 8L);
219
- cinfo->min_DCT_h_scaled_size = 15;
220
- cinfo->min_DCT_v_scaled_size = 15;
221
- } else {
222
- /* Provide 2/1 scaling */
223
- cinfo->output_width = cinfo->image_width << 1;
224
- cinfo->output_height = cinfo->image_height << 1;
225
- cinfo->min_DCT_h_scaled_size = 16;
226
- cinfo->min_DCT_v_scaled_size = 16;
227
- }
228
- /* In selecting the actual DCT scaling for each component, we try to
229
- * scale up the chroma components via IDCT scaling rather than upsampling.
230
- * This saves time if the upsampler gets to use 1:1 scaling.
231
- * Note this code adapts subsampling ratios which are powers of 2.
232
- */
233
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
234
- ci++, compptr++) {
235
- int ssize = 1;
236
- while (cinfo->min_DCT_h_scaled_size * ssize <=
237
- (cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
238
- (cinfo->max_h_samp_factor % (compptr->h_samp_factor * ssize * 2)) == 0) {
239
- ssize = ssize * 2;
240
- }
241
- compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size * ssize;
242
- ssize = 1;
243
- while (cinfo->min_DCT_v_scaled_size * ssize <=
244
- (cinfo->do_fancy_upsampling ? DCTSIZE : DCTSIZE / 2) &&
245
- (cinfo->max_v_samp_factor % (compptr->v_samp_factor * ssize * 2)) == 0) {
246
- ssize = ssize * 2;
247
- }
248
- compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size * ssize;
249
-
250
- /* We don't support IDCT ratios larger than 2. */
251
- if (compptr->DCT_h_scaled_size > compptr->DCT_v_scaled_size * 2)
252
- compptr->DCT_h_scaled_size = compptr->DCT_v_scaled_size * 2;
253
- else if (compptr->DCT_v_scaled_size > compptr->DCT_h_scaled_size * 2)
254
- compptr->DCT_v_scaled_size = compptr->DCT_h_scaled_size * 2;
255
- }
256
-
257
- /* Recompute downsampled dimensions of components;
258
- * application needs to know these if using raw downsampled data.
259
- */
260
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
261
- ci++, compptr++) {
262
- /* Size in samples, after IDCT scaling */
263
- compptr->downsampled_width = (JDIMENSION)
264
- jdiv_round_up((long) cinfo->image_width *
265
- (long) (compptr->h_samp_factor * compptr->DCT_h_scaled_size),
266
- (long) (cinfo->max_h_samp_factor * DCTSIZE));
267
- compptr->downsampled_height = (JDIMENSION)
268
- jdiv_round_up((long) cinfo->image_height *
269
- (long) (compptr->v_samp_factor * compptr->DCT_v_scaled_size),
270
- (long) (cinfo->max_v_samp_factor * DCTSIZE));
271
- }
272
-
273
- #else /* !IDCT_SCALING_SUPPORTED */
274
-
275
- /* Hardwire it to "no scaling" */
276
- cinfo->output_width = cinfo->image_width;
277
- cinfo->output_height = cinfo->image_height;
278
- /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE,
279
- * and has computed unscaled downsampled_width and downsampled_height.
280
- */
281
-
282
- #endif /* IDCT_SCALING_SUPPORTED */
283
-
284
- /* Report number of components in selected colorspace. */
285
- /* Probably this should be in the color conversion module... */
286
- switch (cinfo->out_color_space) {
287
- case JCS_GRAYSCALE:
288
- cinfo->out_color_components = 1;
289
- break;
290
- case JCS_RGB:
291
- #if RGB_PIXELSIZE != 3
292
- cinfo->out_color_components = RGB_PIXELSIZE;
293
- break;
294
- #endif /* else share code with YCbCr */
295
- case JCS_YCbCr:
296
- cinfo->out_color_components = 3;
297
- break;
298
- case JCS_CMYK:
299
- case JCS_YCCK:
300
- cinfo->out_color_components = 4;
301
- break;
302
- default: /* else must be same colorspace as in file */
303
- cinfo->out_color_components = cinfo->num_components;
304
- break;
305
- }
306
- cinfo->output_components = (cinfo->quantize_colors ? 1 :
307
- cinfo->out_color_components);
308
-
309
- /* See if upsampler will want to emit more than one row at a time */
310
- if (use_merged_upsample(cinfo))
311
- cinfo->rec_outbuf_height = cinfo->max_v_samp_factor;
312
- else
313
- cinfo->rec_outbuf_height = 1;
314
- }
315
-
316
-
317
- /*
318
- * Several decompression processes need to range-limit values to the range
319
- * 0..MAXJSAMPLE; the input value may fall somewhat outside this range
320
- * due to noise introduced by quantization, roundoff error, etc. These
321
- * processes are inner loops and need to be as fast as possible. On most
322
- * machines, particularly CPUs with pipelines or instruction prefetch,
323
- * a (subscript-check-less) C table lookup
324
- * x = sample_range_limit[x];
325
- * is faster than explicit tests
326
- * if (x < 0) x = 0;
327
- * else if (x > MAXJSAMPLE) x = MAXJSAMPLE;
328
- * These processes all use a common table prepared by the routine below.
329
- *
330
- * For most steps we can mathematically guarantee that the initial value
331
- * of x is within MAXJSAMPLE+1 of the legal range, so a table running from
332
- * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial
333
- * limiting step (just after the IDCT), a wildly out-of-range value is
334
- * possible if the input data is corrupt. To avoid any chance of indexing
335
- * off the end of memory and getting a bad-pointer trap, we perform the
336
- * post-IDCT limiting thus:
337
- * x = range_limit[x & MASK];
338
- * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit
339
- * samples. Under normal circumstances this is more than enough range and
340
- * a correct output will be generated; with bogus input data the mask will
341
- * cause wraparound, and we will safely generate a bogus-but-in-range output.
342
- * For the post-IDCT step, we want to convert the data from signed to unsigned
343
- * representation by adding CENTERJSAMPLE at the same time that we limit it.
344
- * So the post-IDCT limiting table ends up looking like this:
345
- * CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE,
346
- * MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
347
- * 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times),
348
- * 0,1,...,CENTERJSAMPLE-1
349
- * Negative inputs select values from the upper half of the table after
350
- * masking.
351
- *
352
- * We can save some space by overlapping the start of the post-IDCT table
353
- * with the simpler range limiting table. The post-IDCT table begins at
354
- * sample_range_limit + CENTERJSAMPLE.
355
- *
356
- * Note that the table is allocated in near data space on PCs; it's small
357
- * enough and used often enough to justify this.
358
- */
359
-
360
- LOCAL(void)
361
- prepare_range_limit_table (j_decompress_ptr cinfo)
362
- /* Allocate and fill in the sample_range_limit table */
363
- {
364
- JSAMPLE * table;
365
- int i;
366
-
367
- table = (JSAMPLE *)
368
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
369
- (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE));
370
- table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */
371
- cinfo->sample_range_limit = table;
372
- /* First segment of "simple" table: limit[x] = 0 for x < 0 */
373
- MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE));
374
- /* Main part of "simple" table: limit[x] = x */
375
- for (i = 0; i <= MAXJSAMPLE; i++)
376
- table[i] = (JSAMPLE) i;
377
- table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */
378
- /* End of simple table, rest of first half of post-IDCT table */
379
- for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++)
380
- table[i] = MAXJSAMPLE;
381
- /* Second half of post-IDCT table */
382
- MEMZERO(table + (2 * (MAXJSAMPLE+1)),
383
- (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE));
384
- MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE),
385
- cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE));
386
- }
387
-
388
-
389
- /*
390
- * Master selection of decompression modules.
391
- * This is done once at jpeg_start_decompress time. We determine
392
- * which modules will be used and give them appropriate initialization calls.
393
- * We also initialize the decompressor input side to begin consuming data.
394
- *
395
- * Since jpeg_read_header has finished, we know what is in the SOF
396
- * and (first) SOS markers. We also have all the application parameter
397
- * settings.
398
- */
399
-
400
- LOCAL(void)
401
- master_selection (j_decompress_ptr cinfo)
402
- {
403
- my_master_ptr master = (my_master_ptr) cinfo->master;
404
- boolean use_c_buffer;
405
- long samplesperrow;
406
- JDIMENSION jd_samplesperrow;
407
-
408
- /* Initialize dimensions and other stuff */
409
- jpeg_calc_output_dimensions(cinfo);
410
- prepare_range_limit_table(cinfo);
411
-
412
- /* Width of an output scanline must be representable as JDIMENSION. */
413
- samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components;
414
- jd_samplesperrow = (JDIMENSION) samplesperrow;
415
- if ((long) jd_samplesperrow != samplesperrow)
416
- ERREXIT(cinfo, JERR_WIDTH_OVERFLOW);
417
-
418
- /* Initialize my private state */
419
- master->pass_number = 0;
420
- master->using_merged_upsample = use_merged_upsample(cinfo);
421
-
422
- /* Color quantizer selection */
423
- master->quantizer_1pass = NULL;
424
- master->quantizer_2pass = NULL;
425
- /* No mode changes if not using buffered-image mode. */
426
- if (! cinfo->quantize_colors || ! cinfo->buffered_image) {
427
- cinfo->enable_1pass_quant = FALSE;
428
- cinfo->enable_external_quant = FALSE;
429
- cinfo->enable_2pass_quant = FALSE;
430
- }
431
- if (cinfo->quantize_colors) {
432
- if (cinfo->raw_data_out)
433
- ERREXIT(cinfo, JERR_NOTIMPL);
434
- /* 2-pass quantizer only works in 3-component color space. */
435
- if (cinfo->out_color_components != 3) {
436
- cinfo->enable_1pass_quant = TRUE;
437
- cinfo->enable_external_quant = FALSE;
438
- cinfo->enable_2pass_quant = FALSE;
439
- cinfo->colormap = NULL;
440
- } else if (cinfo->colormap != NULL) {
441
- cinfo->enable_external_quant = TRUE;
442
- } else if (cinfo->two_pass_quantize) {
443
- cinfo->enable_2pass_quant = TRUE;
444
- } else {
445
- cinfo->enable_1pass_quant = TRUE;
446
- }
447
-
448
- if (cinfo->enable_1pass_quant) {
449
- #ifdef QUANT_1PASS_SUPPORTED
450
- jinit_1pass_quantizer(cinfo);
451
- master->quantizer_1pass = cinfo->cquantize;
452
- #else
453
- ERREXIT(cinfo, JERR_NOT_COMPILED);
454
- #endif
455
- }
456
-
457
- /* We use the 2-pass code to map to external colormaps. */
458
- if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) {
459
- #ifdef QUANT_2PASS_SUPPORTED
460
- jinit_2pass_quantizer(cinfo);
461
- master->quantizer_2pass = cinfo->cquantize;
462
- #else
463
- ERREXIT(cinfo, JERR_NOT_COMPILED);
464
- #endif
465
- }
466
- /* If both quantizers are initialized, the 2-pass one is left active;
467
- * this is necessary for starting with quantization to an external map.
468
- */
469
- }
470
-
471
- /* Post-processing: in particular, color conversion first */
472
- if (! cinfo->raw_data_out) {
473
- if (master->using_merged_upsample) {
474
- #ifdef UPSAMPLE_MERGING_SUPPORTED
475
- jinit_merged_upsampler(cinfo); /* does color conversion too */
476
- #else
477
- ERREXIT(cinfo, JERR_NOT_COMPILED);
478
- #endif
479
- } else {
480
- jinit_color_deconverter(cinfo);
481
- jinit_upsampler(cinfo);
482
- }
483
- jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant);
484
- }
485
- /* Inverse DCT */
486
- jinit_inverse_dct(cinfo);
487
- /* Entropy decoding: either Huffman or arithmetic coding. */
488
- if (cinfo->arith_code) {
489
- jinit_arith_decoder(cinfo);
490
- } else {
491
- jinit_huff_decoder(cinfo);
492
- }
493
-
494
- /* Initialize principal buffer controllers. */
495
- use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image;
496
- jinit_d_coef_controller(cinfo, use_c_buffer);
497
-
498
- if (! cinfo->raw_data_out)
499
- jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */);
500
-
501
- /* We can now tell the memory manager to allocate virtual arrays. */
502
- (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
503
-
504
- /* Initialize input side of decompressor to consume first scan. */
505
- (*cinfo->inputctl->start_input_pass) (cinfo);
506
-
507
- #ifdef D_MULTISCAN_FILES_SUPPORTED
508
- /* If jpeg_start_decompress will read the whole file, initialize
509
- * progress monitoring appropriately. The input step is counted
510
- * as one pass.
511
- */
512
- if (cinfo->progress != NULL && ! cinfo->buffered_image &&
513
- cinfo->inputctl->has_multiple_scans) {
514
- int nscans;
515
- /* Estimate number of scans to set pass_limit. */
516
- if (cinfo->progressive_mode) {
517
- /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */
518
- nscans = 2 + 3 * cinfo->num_components;
519
- } else {
520
- /* For a nonprogressive multiscan file, estimate 1 scan per component. */
521
- nscans = cinfo->num_components;
522
- }
523
- cinfo->progress->pass_counter = 0L;
524
- cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans;
525
- cinfo->progress->completed_passes = 0;
526
- cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2);
527
- /* Count the input pass as done */
528
- master->pass_number++;
529
- }
530
- #endif /* D_MULTISCAN_FILES_SUPPORTED */
531
- }
532
-
533
-
534
- /*
535
- * Per-pass setup.
536
- * This is called at the beginning of each output pass. We determine which
537
- * modules will be active during this pass and give them appropriate
538
- * start_pass calls. We also set is_dummy_pass to indicate whether this
539
- * is a "real" output pass or a dummy pass for color quantization.
540
- * (In the latter case, jdapistd.c will crank the pass to completion.)
541
- */
542
-
543
- METHODDEF(void)
544
- prepare_for_output_pass (j_decompress_ptr cinfo)
545
- {
546
- my_master_ptr master = (my_master_ptr) cinfo->master;
547
-
548
- if (master->pub.is_dummy_pass) {
549
- #ifdef QUANT_2PASS_SUPPORTED
550
- /* Final pass of 2-pass quantization */
551
- master->pub.is_dummy_pass = FALSE;
552
- (*cinfo->cquantize->start_pass) (cinfo, FALSE);
553
- (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST);
554
- (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST);
555
- #else
556
- ERREXIT(cinfo, JERR_NOT_COMPILED);
557
- #endif /* QUANT_2PASS_SUPPORTED */
558
- } else {
559
- if (cinfo->quantize_colors && cinfo->colormap == NULL) {
560
- /* Select new quantization method */
561
- if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) {
562
- cinfo->cquantize = master->quantizer_2pass;
563
- master->pub.is_dummy_pass = TRUE;
564
- } else if (cinfo->enable_1pass_quant) {
565
- cinfo->cquantize = master->quantizer_1pass;
566
- } else {
567
- ERREXIT(cinfo, JERR_MODE_CHANGE);
568
- }
569
- }
570
- (*cinfo->idct->start_pass) (cinfo);
571
- (*cinfo->coef->start_output_pass) (cinfo);
572
- if (! cinfo->raw_data_out) {
573
- if (! master->using_merged_upsample)
574
- (*cinfo->cconvert->start_pass) (cinfo);
575
- (*cinfo->upsample->start_pass) (cinfo);
576
- if (cinfo->quantize_colors)
577
- (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass);
578
- (*cinfo->post->start_pass) (cinfo,
579
- (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU));
580
- (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU);
581
- }
582
- }
583
-
584
- /* Set up progress monitor's pass info if present */
585
- if (cinfo->progress != NULL) {
586
- cinfo->progress->completed_passes = master->pass_number;
587
- cinfo->progress->total_passes = master->pass_number +
588
- (master->pub.is_dummy_pass ? 2 : 1);
589
- /* In buffered-image mode, we assume one more output pass if EOI not
590
- * yet reached, but no more passes if EOI has been reached.
591
- */
592
- if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) {
593
- cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1);
594
- }
595
- }
596
- }
597
-
598
-
599
- /*
600
- * Finish up at end of an output pass.
601
- */
602
-
603
- METHODDEF(void)
604
- finish_output_pass (j_decompress_ptr cinfo)
605
- {
606
- my_master_ptr master = (my_master_ptr) cinfo->master;
607
-
608
- if (cinfo->quantize_colors)
609
- (*cinfo->cquantize->finish_pass) (cinfo);
610
- master->pass_number++;
611
- }
612
-
613
-
614
- #ifdef D_MULTISCAN_FILES_SUPPORTED
615
-
616
- /*
617
- * Switch to a new external colormap between output passes.
618
- */
619
-
620
- GLOBAL(void)
621
- jpeg_new_colormap (j_decompress_ptr cinfo)
622
- {
623
- my_master_ptr master = (my_master_ptr) cinfo->master;
624
-
625
- /* Prevent application from calling me at wrong times */
626
- if (cinfo->global_state != DSTATE_BUFIMAGE)
627
- ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
628
-
629
- if (cinfo->quantize_colors && cinfo->enable_external_quant &&
630
- cinfo->colormap != NULL) {
631
- /* Select 2-pass quantizer for external colormap use */
632
- cinfo->cquantize = master->quantizer_2pass;
633
- /* Notify quantizer of colormap change */
634
- (*cinfo->cquantize->new_color_map) (cinfo);
635
- master->pub.is_dummy_pass = FALSE; /* just in case */
636
- } else
637
- ERREXIT(cinfo, JERR_MODE_CHANGE);
638
- }
639
-
640
- #endif /* D_MULTISCAN_FILES_SUPPORTED */
641
-
642
-
643
- /*
644
- * Initialize master decompression control and select active modules.
645
- * This is performed at the start of jpeg_start_decompress.
646
- */
647
-
648
- GLOBAL(void)
649
- jinit_master_decompress (j_decompress_ptr cinfo)
650
- {
651
- my_master_ptr master;
652
-
653
- master = (my_master_ptr)
654
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
655
- SIZEOF(my_decomp_master));
656
- cinfo->master = (struct jpeg_decomp_master *) master;
657
- master->pub.prepare_for_output_pass = prepare_for_output_pass;
658
- master->pub.finish_output_pass = finish_output_pass;
659
-
660
- master->pub.is_dummy_pass = FALSE;
661
-
662
- master_selection(cinfo);
663
- }