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,151 +0,0 @@
1
- /*
2
- * jdatadst.c
3
- *
4
- * Copyright (C) 1994-1996, 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 compression data destination routines for the case of
9
- * emitting JPEG data to a file (or any stdio stream). While these routines
10
- * are sufficient for most applications, some will want to use a different
11
- * destination manager.
12
- * IMPORTANT: we assume that fwrite() will correctly transcribe an array of
13
- * JOCTETs into 8-bit-wide elements on external storage. If char is wider
14
- * than 8 bits on your machine, you may need to do some tweaking.
15
- */
16
-
17
- /* this is not a core library module, so it doesn't define JPEG_INTERNALS */
18
- #include "jinclude.h"
19
- #include "jpeglib.h"
20
- #include "jerror.h"
21
-
22
-
23
- /* Expanded data destination object for stdio output */
24
-
25
- typedef struct {
26
- struct jpeg_destination_mgr pub; /* public fields */
27
-
28
- FILE * outfile; /* target stream */
29
- JOCTET * buffer; /* start of buffer */
30
- } my_destination_mgr;
31
-
32
- typedef my_destination_mgr * my_dest_ptr;
33
-
34
- #define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
35
-
36
-
37
- /*
38
- * Initialize destination --- called by jpeg_start_compress
39
- * before any data is actually written.
40
- */
41
-
42
- METHODDEF(void)
43
- init_destination (j_compress_ptr cinfo)
44
- {
45
- my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
46
-
47
- /* Allocate the output buffer --- it will be released when done with image */
48
- dest->buffer = (JOCTET *)
49
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
50
- OUTPUT_BUF_SIZE * SIZEOF(JOCTET));
51
-
52
- dest->pub.next_output_byte = dest->buffer;
53
- dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
54
- }
55
-
56
-
57
- /*
58
- * Empty the output buffer --- called whenever buffer fills up.
59
- *
60
- * In typical applications, this should write the entire output buffer
61
- * (ignoring the current state of next_output_byte & free_in_buffer),
62
- * reset the pointer & count to the start of the buffer, and return TRUE
63
- * indicating that the buffer has been dumped.
64
- *
65
- * In applications that need to be able to suspend compression due to output
66
- * overrun, a FALSE return indicates that the buffer cannot be emptied now.
67
- * In this situation, the compressor will return to its caller (possibly with
68
- * an indication that it has not accepted all the supplied scanlines). The
69
- * application should resume compression after it has made more room in the
70
- * output buffer. Note that there are substantial restrictions on the use of
71
- * suspension --- see the documentation.
72
- *
73
- * When suspending, the compressor will back up to a convenient restart point
74
- * (typically the start of the current MCU). next_output_byte & free_in_buffer
75
- * indicate where the restart point will be if the current call returns FALSE.
76
- * Data beyond this point will be regenerated after resumption, so do not
77
- * write it out when emptying the buffer externally.
78
- */
79
-
80
- METHODDEF(boolean)
81
- empty_output_buffer (j_compress_ptr cinfo)
82
- {
83
- my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
84
-
85
- if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) !=
86
- (size_t) OUTPUT_BUF_SIZE)
87
- ERREXIT(cinfo, JERR_FILE_WRITE);
88
-
89
- dest->pub.next_output_byte = dest->buffer;
90
- dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
91
-
92
- return TRUE;
93
- }
94
-
95
-
96
- /*
97
- * Terminate destination --- called by jpeg_finish_compress
98
- * after all data has been written. Usually needs to flush buffer.
99
- *
100
- * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding
101
- * application must deal with any cleanup that should happen even
102
- * for error exit.
103
- */
104
-
105
- METHODDEF(void)
106
- term_destination (j_compress_ptr cinfo)
107
- {
108
- my_dest_ptr dest = (my_dest_ptr) cinfo->dest;
109
- size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer;
110
-
111
- /* Write any data remaining in the buffer */
112
- if (datacount > 0) {
113
- if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount)
114
- ERREXIT(cinfo, JERR_FILE_WRITE);
115
- }
116
- fflush(dest->outfile);
117
- /* Make sure we wrote the output file OK */
118
- if (ferror(dest->outfile))
119
- ERREXIT(cinfo, JERR_FILE_WRITE);
120
- }
121
-
122
-
123
- /*
124
- * Prepare for output to a stdio stream.
125
- * The caller must have already opened the stream, and is responsible
126
- * for closing it after finishing compression.
127
- */
128
-
129
- GLOBAL(void)
130
- jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile)
131
- {
132
- my_dest_ptr dest;
133
-
134
- /* The destination object is made permanent so that multiple JPEG images
135
- * can be written to the same file without re-executing jpeg_stdio_dest.
136
- * This makes it dangerous to use this manager and a different destination
137
- * manager serially with the same JPEG object, because their private object
138
- * sizes may be different. Caveat programmer.
139
- */
140
- if (cinfo->dest == NULL) { /* first time for this JPEG object? */
141
- cinfo->dest = (struct jpeg_destination_mgr *)
142
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
143
- SIZEOF(my_destination_mgr));
144
- }
145
-
146
- dest = (my_dest_ptr) cinfo->dest;
147
- dest->pub.init_destination = init_destination;
148
- dest->pub.empty_output_buffer = empty_output_buffer;
149
- dest->pub.term_destination = term_destination;
150
- dest->outfile = outfile;
151
- }
@@ -1,212 +0,0 @@
1
- /*
2
- * jdatasrc.c
3
- *
4
- * Copyright (C) 1994-1996, 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 decompression data source routines for the case of
9
- * reading JPEG data from a file (or any stdio stream). While these routines
10
- * are sufficient for most applications, some will want to use a different
11
- * source manager.
12
- * IMPORTANT: we assume that fread() will correctly transcribe an array of
13
- * JOCTETs from 8-bit-wide elements on external storage. If char is wider
14
- * than 8 bits on your machine, you may need to do some tweaking.
15
- */
16
-
17
- /* this is not a core library module, so it doesn't define JPEG_INTERNALS */
18
- #include "jinclude.h"
19
- #include "jpeglib.h"
20
- #include "jerror.h"
21
-
22
-
23
- /* Expanded data source object for stdio input */
24
-
25
- typedef struct {
26
- struct jpeg_source_mgr pub; /* public fields */
27
-
28
- FILE * infile; /* source stream */
29
- JOCTET * buffer; /* start of buffer */
30
- boolean start_of_file; /* have we gotten any data yet? */
31
- } my_source_mgr;
32
-
33
- typedef my_source_mgr * my_src_ptr;
34
-
35
- #define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */
36
-
37
-
38
- /*
39
- * Initialize source --- called by jpeg_read_header
40
- * before any data is actually read.
41
- */
42
-
43
- METHODDEF(void)
44
- init_source (j_decompress_ptr cinfo)
45
- {
46
- my_src_ptr src = (my_src_ptr) cinfo->src;
47
-
48
- /* We reset the empty-input-file flag for each image,
49
- * but we don't clear the input buffer.
50
- * This is correct behavior for reading a series of images from one source.
51
- */
52
- src->start_of_file = TRUE;
53
- }
54
-
55
-
56
- /*
57
- * Fill the input buffer --- called whenever buffer is emptied.
58
- *
59
- * In typical applications, this should read fresh data into the buffer
60
- * (ignoring the current state of next_input_byte & bytes_in_buffer),
61
- * reset the pointer & count to the start of the buffer, and return TRUE
62
- * indicating that the buffer has been reloaded. It is not necessary to
63
- * fill the buffer entirely, only to obtain at least one more byte.
64
- *
65
- * There is no such thing as an EOF return. If the end of the file has been
66
- * reached, the routine has a choice of ERREXIT() or inserting fake data into
67
- * the buffer. In most cases, generating a warning message and inserting a
68
- * fake EOI marker is the best course of action --- this will allow the
69
- * decompressor to output however much of the image is there. However,
70
- * the resulting error message is misleading if the real problem is an empty
71
- * input file, so we handle that case specially.
72
- *
73
- * In applications that need to be able to suspend compression due to input
74
- * not being available yet, a FALSE return indicates that no more data can be
75
- * obtained right now, but more may be forthcoming later. In this situation,
76
- * the decompressor will return to its caller (with an indication of the
77
- * number of scanlines it has read, if any). The application should resume
78
- * decompression after it has loaded more data into the input buffer. Note
79
- * that there are substantial restrictions on the use of suspension --- see
80
- * the documentation.
81
- *
82
- * When suspending, the decompressor will back up to a convenient restart point
83
- * (typically the start of the current MCU). next_input_byte & bytes_in_buffer
84
- * indicate where the restart point will be if the current call returns FALSE.
85
- * Data beyond this point must be rescanned after resumption, so move it to
86
- * the front of the buffer rather than discarding it.
87
- */
88
-
89
- METHODDEF(boolean)
90
- fill_input_buffer (j_decompress_ptr cinfo)
91
- {
92
- my_src_ptr src = (my_src_ptr) cinfo->src;
93
- size_t nbytes;
94
-
95
- nbytes = JFREAD(src->infile, src->buffer, INPUT_BUF_SIZE);
96
-
97
- if (nbytes <= 0) {
98
- if (src->start_of_file) /* Treat empty input file as fatal error */
99
- ERREXIT(cinfo, JERR_INPUT_EMPTY);
100
- WARNMS(cinfo, JWRN_JPEG_EOF);
101
- /* Insert a fake EOI marker */
102
- src->buffer[0] = (JOCTET) 0xFF;
103
- src->buffer[1] = (JOCTET) JPEG_EOI;
104
- nbytes = 2;
105
- }
106
-
107
- src->pub.next_input_byte = src->buffer;
108
- src->pub.bytes_in_buffer = nbytes;
109
- src->start_of_file = FALSE;
110
-
111
- return TRUE;
112
- }
113
-
114
-
115
- /*
116
- * Skip data --- used to skip over a potentially large amount of
117
- * uninteresting data (such as an APPn marker).
118
- *
119
- * Writers of suspendable-input applications must note that skip_input_data
120
- * is not granted the right to give a suspension return. If the skip extends
121
- * beyond the data currently in the buffer, the buffer can be marked empty so
122
- * that the next read will cause a fill_input_buffer call that can suspend.
123
- * Arranging for additional bytes to be discarded before reloading the input
124
- * buffer is the application writer's problem.
125
- */
126
-
127
- METHODDEF(void)
128
- skip_input_data (j_decompress_ptr cinfo, long num_bytes)
129
- {
130
- my_src_ptr src = (my_src_ptr) cinfo->src;
131
-
132
- /* Just a dumb implementation for now. Could use fseek() except
133
- * it doesn't work on pipes. Not clear that being smart is worth
134
- * any trouble anyway --- large skips are infrequent.
135
- */
136
- if (num_bytes > 0) {
137
- while (num_bytes > (long) src->pub.bytes_in_buffer) {
138
- num_bytes -= (long) src->pub.bytes_in_buffer;
139
- (void) fill_input_buffer(cinfo);
140
- /* note we assume that fill_input_buffer will never return FALSE,
141
- * so suspension need not be handled.
142
- */
143
- }
144
- src->pub.next_input_byte += (size_t) num_bytes;
145
- src->pub.bytes_in_buffer -= (size_t) num_bytes;
146
- }
147
- }
148
-
149
-
150
- /*
151
- * An additional method that can be provided by data source modules is the
152
- * resync_to_restart method for error recovery in the presence of RST markers.
153
- * For the moment, this source module just uses the default resync method
154
- * provided by the JPEG library. That method assumes that no backtracking
155
- * is possible.
156
- */
157
-
158
-
159
- /*
160
- * Terminate source --- called by jpeg_finish_decompress
161
- * after all data has been read. Often a no-op.
162
- *
163
- * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding
164
- * application must deal with any cleanup that should happen even
165
- * for error exit.
166
- */
167
-
168
- METHODDEF(void)
169
- term_source (j_decompress_ptr cinfo)
170
- {
171
- /* no work necessary here */
172
- }
173
-
174
-
175
- /*
176
- * Prepare for input from a stdio stream.
177
- * The caller must have already opened the stream, and is responsible
178
- * for closing it after finishing decompression.
179
- */
180
-
181
- GLOBAL(void)
182
- jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile)
183
- {
184
- my_src_ptr src;
185
-
186
- /* The source object and input buffer are made permanent so that a series
187
- * of JPEG images can be read from the same file by calling jpeg_stdio_src
188
- * only before the first one. (If we discarded the buffer at the end of
189
- * one image, we'd likely lose the start of the next one.)
190
- * This makes it unsafe to use this manager and a different source
191
- * manager serially with the same JPEG object. Caveat programmer.
192
- */
193
- if (cinfo->src == NULL) { /* first time for this JPEG object? */
194
- cinfo->src = (struct jpeg_source_mgr *)
195
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
196
- SIZEOF(my_source_mgr));
197
- src = (my_src_ptr) cinfo->src;
198
- src->buffer = (JOCTET *)
199
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
200
- INPUT_BUF_SIZE * SIZEOF(JOCTET));
201
- }
202
-
203
- src = (my_src_ptr) cinfo->src;
204
- src->pub.init_source = init_source;
205
- src->pub.fill_input_buffer = fill_input_buffer;
206
- src->pub.skip_input_data = skip_input_data;
207
- src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */
208
- src->pub.term_source = term_source;
209
- src->infile = infile;
210
- src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */
211
- src->pub.next_input_byte = NULL; /* until buffer loaded */
212
- }
@@ -1,736 +0,0 @@
1
- /*
2
- * jdcoefct.c
3
- *
4
- * Copyright (C) 1994-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 the coefficient buffer controller for decompression.
9
- * This controller is the top level of the JPEG decompressor proper.
10
- * The coefficient buffer lies between entropy decoding and inverse-DCT steps.
11
- *
12
- * In buffered-image mode, this controller is the interface between
13
- * input-oriented processing and output-oriented processing.
14
- * Also, the input side (only) is used when reading a file for transcoding.
15
- */
16
-
17
- #define JPEG_INTERNALS
18
- #include "jinclude.h"
19
- #include "jpeglib.h"
20
-
21
- /* Block smoothing is only applicable for progressive JPEG, so: */
22
- #ifndef D_PROGRESSIVE_SUPPORTED
23
- #undef BLOCK_SMOOTHING_SUPPORTED
24
- #endif
25
-
26
- /* Private buffer controller object */
27
-
28
- typedef struct {
29
- struct jpeg_d_coef_controller pub; /* public fields */
30
-
31
- /* These variables keep track of the current location of the input side. */
32
- /* cinfo->input_iMCU_row is also used for this. */
33
- JDIMENSION MCU_ctr; /* counts MCUs processed in current row */
34
- int MCU_vert_offset; /* counts MCU rows within iMCU row */
35
- int MCU_rows_per_iMCU_row; /* number of such rows needed */
36
-
37
- /* The output side's location is represented by cinfo->output_iMCU_row. */
38
-
39
- /* In single-pass modes, it's sufficient to buffer just one MCU.
40
- * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks,
41
- * and let the entropy decoder write into that workspace each time.
42
- * (On 80x86, the workspace is FAR even though it's not really very big;
43
- * this is to keep the module interfaces unchanged when a large coefficient
44
- * buffer is necessary.)
45
- * In multi-pass modes, this array points to the current MCU's blocks
46
- * within the virtual arrays; it is used only by the input side.
47
- */
48
- JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU];
49
-
50
- #ifdef D_MULTISCAN_FILES_SUPPORTED
51
- /* In multi-pass modes, we need a virtual block array for each component. */
52
- jvirt_barray_ptr whole_image[MAX_COMPONENTS];
53
- #endif
54
-
55
- #ifdef BLOCK_SMOOTHING_SUPPORTED
56
- /* When doing block smoothing, we latch coefficient Al values here */
57
- int * coef_bits_latch;
58
- #define SAVED_COEFS 6 /* we save coef_bits[0..5] */
59
- #endif
60
- } my_coef_controller;
61
-
62
- typedef my_coef_controller * my_coef_ptr;
63
-
64
- /* Forward declarations */
65
- METHODDEF(int) decompress_onepass
66
- JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));
67
- #ifdef D_MULTISCAN_FILES_SUPPORTED
68
- METHODDEF(int) decompress_data
69
- JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));
70
- #endif
71
- #ifdef BLOCK_SMOOTHING_SUPPORTED
72
- LOCAL(boolean) smoothing_ok JPP((j_decompress_ptr cinfo));
73
- METHODDEF(int) decompress_smooth_data
74
- JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf));
75
- #endif
76
-
77
-
78
- LOCAL(void)
79
- start_iMCU_row (j_decompress_ptr cinfo)
80
- /* Reset within-iMCU-row counters for a new row (input side) */
81
- {
82
- my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
83
-
84
- /* In an interleaved scan, an MCU row is the same as an iMCU row.
85
- * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
86
- * But at the bottom of the image, process only what's left.
87
- */
88
- if (cinfo->comps_in_scan > 1) {
89
- coef->MCU_rows_per_iMCU_row = 1;
90
- } else {
91
- if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1))
92
- coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
93
- else
94
- coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
95
- }
96
-
97
- coef->MCU_ctr = 0;
98
- coef->MCU_vert_offset = 0;
99
- }
100
-
101
-
102
- /*
103
- * Initialize for an input processing pass.
104
- */
105
-
106
- METHODDEF(void)
107
- start_input_pass (j_decompress_ptr cinfo)
108
- {
109
- cinfo->input_iMCU_row = 0;
110
- start_iMCU_row(cinfo);
111
- }
112
-
113
-
114
- /*
115
- * Initialize for an output processing pass.
116
- */
117
-
118
- METHODDEF(void)
119
- start_output_pass (j_decompress_ptr cinfo)
120
- {
121
- #ifdef BLOCK_SMOOTHING_SUPPORTED
122
- my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
123
-
124
- /* If multipass, check to see whether to use block smoothing on this pass */
125
- if (coef->pub.coef_arrays != NULL) {
126
- if (cinfo->do_block_smoothing && smoothing_ok(cinfo))
127
- coef->pub.decompress_data = decompress_smooth_data;
128
- else
129
- coef->pub.decompress_data = decompress_data;
130
- }
131
- #endif
132
- cinfo->output_iMCU_row = 0;
133
- }
134
-
135
-
136
- /*
137
- * Decompress and return some data in the single-pass case.
138
- * Always attempts to emit one fully interleaved MCU row ("iMCU" row).
139
- * Input and output must run in lockstep since we have only a one-MCU buffer.
140
- * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.
141
- *
142
- * NB: output_buf contains a plane for each component in image,
143
- * which we index according to the component's SOF position.
144
- */
145
-
146
- METHODDEF(int)
147
- decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
148
- {
149
- my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
150
- JDIMENSION MCU_col_num; /* index of current MCU within row */
151
- JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
152
- JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
153
- int blkn, ci, xindex, yindex, yoffset, useful_width;
154
- JSAMPARRAY output_ptr;
155
- JDIMENSION start_col, output_col;
156
- jpeg_component_info *compptr;
157
- inverse_DCT_method_ptr inverse_DCT;
158
-
159
- /* Loop to process as much as one whole iMCU row */
160
- for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
161
- yoffset++) {
162
- for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
163
- MCU_col_num++) {
164
- /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */
165
- jzero_far((void FAR *) coef->MCU_buffer[0],
166
- (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK)));
167
- if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
168
- /* Suspension forced; update state counters and exit */
169
- coef->MCU_vert_offset = yoffset;
170
- coef->MCU_ctr = MCU_col_num;
171
- return JPEG_SUSPENDED;
172
- }
173
- /* Determine where data should go in output_buf and do the IDCT thing.
174
- * We skip dummy blocks at the right and bottom edges (but blkn gets
175
- * incremented past them!). Note the inner loop relies on having
176
- * allocated the MCU_buffer[] blocks sequentially.
177
- */
178
- blkn = 0; /* index of current DCT block within MCU */
179
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
180
- compptr = cinfo->cur_comp_info[ci];
181
- /* Don't bother to IDCT an uninteresting component. */
182
- if (! compptr->component_needed) {
183
- blkn += compptr->MCU_blocks;
184
- continue;
185
- }
186
- inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index];
187
- useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
188
- : compptr->last_col_width;
189
- output_ptr = output_buf[compptr->component_index] +
190
- yoffset * compptr->DCT_v_scaled_size;
191
- start_col = MCU_col_num * compptr->MCU_sample_width;
192
- for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
193
- if (cinfo->input_iMCU_row < last_iMCU_row ||
194
- yoffset+yindex < compptr->last_row_height) {
195
- output_col = start_col;
196
- for (xindex = 0; xindex < useful_width; xindex++) {
197
- (*inverse_DCT) (cinfo, compptr,
198
- (JCOEFPTR) coef->MCU_buffer[blkn+xindex],
199
- output_ptr, output_col);
200
- output_col += compptr->DCT_h_scaled_size;
201
- }
202
- }
203
- blkn += compptr->MCU_width;
204
- output_ptr += compptr->DCT_v_scaled_size;
205
- }
206
- }
207
- }
208
- /* Completed an MCU row, but perhaps not an iMCU row */
209
- coef->MCU_ctr = 0;
210
- }
211
- /* Completed the iMCU row, advance counters for next one */
212
- cinfo->output_iMCU_row++;
213
- if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
214
- start_iMCU_row(cinfo);
215
- return JPEG_ROW_COMPLETED;
216
- }
217
- /* Completed the scan */
218
- (*cinfo->inputctl->finish_input_pass) (cinfo);
219
- return JPEG_SCAN_COMPLETED;
220
- }
221
-
222
-
223
- /*
224
- * Dummy consume-input routine for single-pass operation.
225
- */
226
-
227
- METHODDEF(int)
228
- dummy_consume_data (j_decompress_ptr cinfo)
229
- {
230
- return JPEG_SUSPENDED; /* Always indicate nothing was done */
231
- }
232
-
233
-
234
- #ifdef D_MULTISCAN_FILES_SUPPORTED
235
-
236
- /*
237
- * Consume input data and store it in the full-image coefficient buffer.
238
- * We read as much as one fully interleaved MCU row ("iMCU" row) per call,
239
- * ie, v_samp_factor block rows for each component in the scan.
240
- * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.
241
- */
242
-
243
- METHODDEF(int)
244
- consume_data (j_decompress_ptr cinfo)
245
- {
246
- my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
247
- JDIMENSION MCU_col_num; /* index of current MCU within row */
248
- int blkn, ci, xindex, yindex, yoffset;
249
- JDIMENSION start_col;
250
- JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
251
- JBLOCKROW buffer_ptr;
252
- jpeg_component_info *compptr;
253
-
254
- /* Align the virtual buffers for the components used in this scan. */
255
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
256
- compptr = cinfo->cur_comp_info[ci];
257
- buffer[ci] = (*cinfo->mem->access_virt_barray)
258
- ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],
259
- cinfo->input_iMCU_row * compptr->v_samp_factor,
260
- (JDIMENSION) compptr->v_samp_factor, TRUE);
261
- /* Note: entropy decoder expects buffer to be zeroed,
262
- * but this is handled automatically by the memory manager
263
- * because we requested a pre-zeroed array.
264
- */
265
- }
266
-
267
- /* Loop to process one whole iMCU row */
268
- for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
269
- yoffset++) {
270
- for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
271
- MCU_col_num++) {
272
- /* Construct list of pointers to DCT blocks belonging to this MCU */
273
- blkn = 0; /* index of current DCT block within MCU */
274
- for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
275
- compptr = cinfo->cur_comp_info[ci];
276
- start_col = MCU_col_num * compptr->MCU_width;
277
- for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
278
- buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
279
- for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
280
- coef->MCU_buffer[blkn++] = buffer_ptr++;
281
- }
282
- }
283
- }
284
- /* Try to fetch the MCU. */
285
- if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
286
- /* Suspension forced; update state counters and exit */
287
- coef->MCU_vert_offset = yoffset;
288
- coef->MCU_ctr = MCU_col_num;
289
- return JPEG_SUSPENDED;
290
- }
291
- }
292
- /* Completed an MCU row, but perhaps not an iMCU row */
293
- coef->MCU_ctr = 0;
294
- }
295
- /* Completed the iMCU row, advance counters for next one */
296
- if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
297
- start_iMCU_row(cinfo);
298
- return JPEG_ROW_COMPLETED;
299
- }
300
- /* Completed the scan */
301
- (*cinfo->inputctl->finish_input_pass) (cinfo);
302
- return JPEG_SCAN_COMPLETED;
303
- }
304
-
305
-
306
- /*
307
- * Decompress and return some data in the multi-pass case.
308
- * Always attempts to emit one fully interleaved MCU row ("iMCU" row).
309
- * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.
310
- *
311
- * NB: output_buf contains a plane for each component in image.
312
- */
313
-
314
- METHODDEF(int)
315
- decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
316
- {
317
- my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
318
- JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
319
- JDIMENSION block_num;
320
- int ci, block_row, block_rows;
321
- JBLOCKARRAY buffer;
322
- JBLOCKROW buffer_ptr;
323
- JSAMPARRAY output_ptr;
324
- JDIMENSION output_col;
325
- jpeg_component_info *compptr;
326
- inverse_DCT_method_ptr inverse_DCT;
327
-
328
- /* Force some input to be done if we are getting ahead of the input. */
329
- while (cinfo->input_scan_number < cinfo->output_scan_number ||
330
- (cinfo->input_scan_number == cinfo->output_scan_number &&
331
- cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {
332
- if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)
333
- return JPEG_SUSPENDED;
334
- }
335
-
336
- /* OK, output from the virtual arrays. */
337
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
338
- ci++, compptr++) {
339
- /* Don't bother to IDCT an uninteresting component. */
340
- if (! compptr->component_needed)
341
- continue;
342
- /* Align the virtual buffer for this component. */
343
- buffer = (*cinfo->mem->access_virt_barray)
344
- ((j_common_ptr) cinfo, coef->whole_image[ci],
345
- cinfo->output_iMCU_row * compptr->v_samp_factor,
346
- (JDIMENSION) compptr->v_samp_factor, FALSE);
347
- /* Count non-dummy DCT block rows in this iMCU row. */
348
- if (cinfo->output_iMCU_row < last_iMCU_row)
349
- block_rows = compptr->v_samp_factor;
350
- else {
351
- /* NB: can't use last_row_height here; it is input-side-dependent! */
352
- block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
353
- if (block_rows == 0) block_rows = compptr->v_samp_factor;
354
- }
355
- inverse_DCT = cinfo->idct->inverse_DCT[ci];
356
- output_ptr = output_buf[ci];
357
- /* Loop over all DCT blocks to be processed. */
358
- for (block_row = 0; block_row < block_rows; block_row++) {
359
- buffer_ptr = buffer[block_row];
360
- output_col = 0;
361
- for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) {
362
- (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr,
363
- output_ptr, output_col);
364
- buffer_ptr++;
365
- output_col += compptr->DCT_h_scaled_size;
366
- }
367
- output_ptr += compptr->DCT_v_scaled_size;
368
- }
369
- }
370
-
371
- if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
372
- return JPEG_ROW_COMPLETED;
373
- return JPEG_SCAN_COMPLETED;
374
- }
375
-
376
- #endif /* D_MULTISCAN_FILES_SUPPORTED */
377
-
378
-
379
- #ifdef BLOCK_SMOOTHING_SUPPORTED
380
-
381
- /*
382
- * This code applies interblock smoothing as described by section K.8
383
- * of the JPEG standard: the first 5 AC coefficients are estimated from
384
- * the DC values of a DCT block and its 8 neighboring blocks.
385
- * We apply smoothing only for progressive JPEG decoding, and only if
386
- * the coefficients it can estimate are not yet known to full precision.
387
- */
388
-
389
- /* Natural-order array positions of the first 5 zigzag-order coefficients */
390
- #define Q01_POS 1
391
- #define Q10_POS 8
392
- #define Q20_POS 16
393
- #define Q11_POS 9
394
- #define Q02_POS 2
395
-
396
- /*
397
- * Determine whether block smoothing is applicable and safe.
398
- * We also latch the current states of the coef_bits[] entries for the
399
- * AC coefficients; otherwise, if the input side of the decompressor
400
- * advances into a new scan, we might think the coefficients are known
401
- * more accurately than they really are.
402
- */
403
-
404
- LOCAL(boolean)
405
- smoothing_ok (j_decompress_ptr cinfo)
406
- {
407
- my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
408
- boolean smoothing_useful = FALSE;
409
- int ci, coefi;
410
- jpeg_component_info *compptr;
411
- JQUANT_TBL * qtable;
412
- int * coef_bits;
413
- int * coef_bits_latch;
414
-
415
- if (! cinfo->progressive_mode || cinfo->coef_bits == NULL)
416
- return FALSE;
417
-
418
- /* Allocate latch area if not already done */
419
- if (coef->coef_bits_latch == NULL)
420
- coef->coef_bits_latch = (int *)
421
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
422
- cinfo->num_components *
423
- (SAVED_COEFS * SIZEOF(int)));
424
- coef_bits_latch = coef->coef_bits_latch;
425
-
426
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
427
- ci++, compptr++) {
428
- /* All components' quantization values must already be latched. */
429
- if ((qtable = compptr->quant_table) == NULL)
430
- return FALSE;
431
- /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */
432
- if (qtable->quantval[0] == 0 ||
433
- qtable->quantval[Q01_POS] == 0 ||
434
- qtable->quantval[Q10_POS] == 0 ||
435
- qtable->quantval[Q20_POS] == 0 ||
436
- qtable->quantval[Q11_POS] == 0 ||
437
- qtable->quantval[Q02_POS] == 0)
438
- return FALSE;
439
- /* DC values must be at least partly known for all components. */
440
- coef_bits = cinfo->coef_bits[ci];
441
- if (coef_bits[0] < 0)
442
- return FALSE;
443
- /* Block smoothing is helpful if some AC coefficients remain inaccurate. */
444
- for (coefi = 1; coefi <= 5; coefi++) {
445
- coef_bits_latch[coefi] = coef_bits[coefi];
446
- if (coef_bits[coefi] != 0)
447
- smoothing_useful = TRUE;
448
- }
449
- coef_bits_latch += SAVED_COEFS;
450
- }
451
-
452
- return smoothing_useful;
453
- }
454
-
455
-
456
- /*
457
- * Variant of decompress_data for use when doing block smoothing.
458
- */
459
-
460
- METHODDEF(int)
461
- decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf)
462
- {
463
- my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
464
- JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
465
- JDIMENSION block_num, last_block_column;
466
- int ci, block_row, block_rows, access_rows;
467
- JBLOCKARRAY buffer;
468
- JBLOCKROW buffer_ptr, prev_block_row, next_block_row;
469
- JSAMPARRAY output_ptr;
470
- JDIMENSION output_col;
471
- jpeg_component_info *compptr;
472
- inverse_DCT_method_ptr inverse_DCT;
473
- boolean first_row, last_row;
474
- JBLOCK workspace;
475
- int *coef_bits;
476
- JQUANT_TBL *quanttbl;
477
- INT32 Q00,Q01,Q02,Q10,Q11,Q20, num;
478
- int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9;
479
- int Al, pred;
480
-
481
- /* Force some input to be done if we are getting ahead of the input. */
482
- while (cinfo->input_scan_number <= cinfo->output_scan_number &&
483
- ! cinfo->inputctl->eoi_reached) {
484
- if (cinfo->input_scan_number == cinfo->output_scan_number) {
485
- /* If input is working on current scan, we ordinarily want it to
486
- * have completed the current row. But if input scan is DC,
487
- * we want it to keep one row ahead so that next block row's DC
488
- * values are up to date.
489
- */
490
- JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0;
491
- if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta)
492
- break;
493
- }
494
- if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED)
495
- return JPEG_SUSPENDED;
496
- }
497
-
498
- /* OK, output from the virtual arrays. */
499
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
500
- ci++, compptr++) {
501
- /* Don't bother to IDCT an uninteresting component. */
502
- if (! compptr->component_needed)
503
- continue;
504
- /* Count non-dummy DCT block rows in this iMCU row. */
505
- if (cinfo->output_iMCU_row < last_iMCU_row) {
506
- block_rows = compptr->v_samp_factor;
507
- access_rows = block_rows * 2; /* this and next iMCU row */
508
- last_row = FALSE;
509
- } else {
510
- /* NB: can't use last_row_height here; it is input-side-dependent! */
511
- block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
512
- if (block_rows == 0) block_rows = compptr->v_samp_factor;
513
- access_rows = block_rows; /* this iMCU row only */
514
- last_row = TRUE;
515
- }
516
- /* Align the virtual buffer for this component. */
517
- if (cinfo->output_iMCU_row > 0) {
518
- access_rows += compptr->v_samp_factor; /* prior iMCU row too */
519
- buffer = (*cinfo->mem->access_virt_barray)
520
- ((j_common_ptr) cinfo, coef->whole_image[ci],
521
- (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,
522
- (JDIMENSION) access_rows, FALSE);
523
- buffer += compptr->v_samp_factor; /* point to current iMCU row */
524
- first_row = FALSE;
525
- } else {
526
- buffer = (*cinfo->mem->access_virt_barray)
527
- ((j_common_ptr) cinfo, coef->whole_image[ci],
528
- (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE);
529
- first_row = TRUE;
530
- }
531
- /* Fetch component-dependent info */
532
- coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS);
533
- quanttbl = compptr->quant_table;
534
- Q00 = quanttbl->quantval[0];
535
- Q01 = quanttbl->quantval[Q01_POS];
536
- Q10 = quanttbl->quantval[Q10_POS];
537
- Q20 = quanttbl->quantval[Q20_POS];
538
- Q11 = quanttbl->quantval[Q11_POS];
539
- Q02 = quanttbl->quantval[Q02_POS];
540
- inverse_DCT = cinfo->idct->inverse_DCT[ci];
541
- output_ptr = output_buf[ci];
542
- /* Loop over all DCT blocks to be processed. */
543
- for (block_row = 0; block_row < block_rows; block_row++) {
544
- buffer_ptr = buffer[block_row];
545
- if (first_row && block_row == 0)
546
- prev_block_row = buffer_ptr;
547
- else
548
- prev_block_row = buffer[block_row-1];
549
- if (last_row && block_row == block_rows-1)
550
- next_block_row = buffer_ptr;
551
- else
552
- next_block_row = buffer[block_row+1];
553
- /* We fetch the surrounding DC values using a sliding-register approach.
554
- * Initialize all nine here so as to do the right thing on narrow pics.
555
- */
556
- DC1 = DC2 = DC3 = (int) prev_block_row[0][0];
557
- DC4 = DC5 = DC6 = (int) buffer_ptr[0][0];
558
- DC7 = DC8 = DC9 = (int) next_block_row[0][0];
559
- output_col = 0;
560
- last_block_column = compptr->width_in_blocks - 1;
561
- for (block_num = 0; block_num <= last_block_column; block_num++) {
562
- /* Fetch current DCT block into workspace so we can modify it. */
563
- jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1);
564
- /* Update DC values */
565
- if (block_num < last_block_column) {
566
- DC3 = (int) prev_block_row[1][0];
567
- DC6 = (int) buffer_ptr[1][0];
568
- DC9 = (int) next_block_row[1][0];
569
- }
570
- /* Compute coefficient estimates per K.8.
571
- * An estimate is applied only if coefficient is still zero,
572
- * and is not known to be fully accurate.
573
- */
574
- /* AC01 */
575
- if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) {
576
- num = 36 * Q00 * (DC4 - DC6);
577
- if (num >= 0) {
578
- pred = (int) (((Q01<<7) + num) / (Q01<<8));
579
- if (Al > 0 && pred >= (1<<Al))
580
- pred = (1<<Al)-1;
581
- } else {
582
- pred = (int) (((Q01<<7) - num) / (Q01<<8));
583
- if (Al > 0 && pred >= (1<<Al))
584
- pred = (1<<Al)-1;
585
- pred = -pred;
586
- }
587
- workspace[1] = (JCOEF) pred;
588
- }
589
- /* AC10 */
590
- if ((Al=coef_bits[2]) != 0 && workspace[8] == 0) {
591
- num = 36 * Q00 * (DC2 - DC8);
592
- if (num >= 0) {
593
- pred = (int) (((Q10<<7) + num) / (Q10<<8));
594
- if (Al > 0 && pred >= (1<<Al))
595
- pred = (1<<Al)-1;
596
- } else {
597
- pred = (int) (((Q10<<7) - num) / (Q10<<8));
598
- if (Al > 0 && pred >= (1<<Al))
599
- pred = (1<<Al)-1;
600
- pred = -pred;
601
- }
602
- workspace[8] = (JCOEF) pred;
603
- }
604
- /* AC20 */
605
- if ((Al=coef_bits[3]) != 0 && workspace[16] == 0) {
606
- num = 9 * Q00 * (DC2 + DC8 - 2*DC5);
607
- if (num >= 0) {
608
- pred = (int) (((Q20<<7) + num) / (Q20<<8));
609
- if (Al > 0 && pred >= (1<<Al))
610
- pred = (1<<Al)-1;
611
- } else {
612
- pred = (int) (((Q20<<7) - num) / (Q20<<8));
613
- if (Al > 0 && pred >= (1<<Al))
614
- pred = (1<<Al)-1;
615
- pred = -pred;
616
- }
617
- workspace[16] = (JCOEF) pred;
618
- }
619
- /* AC11 */
620
- if ((Al=coef_bits[4]) != 0 && workspace[9] == 0) {
621
- num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9);
622
- if (num >= 0) {
623
- pred = (int) (((Q11<<7) + num) / (Q11<<8));
624
- if (Al > 0 && pred >= (1<<Al))
625
- pred = (1<<Al)-1;
626
- } else {
627
- pred = (int) (((Q11<<7) - num) / (Q11<<8));
628
- if (Al > 0 && pred >= (1<<Al))
629
- pred = (1<<Al)-1;
630
- pred = -pred;
631
- }
632
- workspace[9] = (JCOEF) pred;
633
- }
634
- /* AC02 */
635
- if ((Al=coef_bits[5]) != 0 && workspace[2] == 0) {
636
- num = 9 * Q00 * (DC4 + DC6 - 2*DC5);
637
- if (num >= 0) {
638
- pred = (int) (((Q02<<7) + num) / (Q02<<8));
639
- if (Al > 0 && pred >= (1<<Al))
640
- pred = (1<<Al)-1;
641
- } else {
642
- pred = (int) (((Q02<<7) - num) / (Q02<<8));
643
- if (Al > 0 && pred >= (1<<Al))
644
- pred = (1<<Al)-1;
645
- pred = -pred;
646
- }
647
- workspace[2] = (JCOEF) pred;
648
- }
649
- /* OK, do the IDCT */
650
- (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) workspace,
651
- output_ptr, output_col);
652
- /* Advance for next column */
653
- DC1 = DC2; DC2 = DC3;
654
- DC4 = DC5; DC5 = DC6;
655
- DC7 = DC8; DC8 = DC9;
656
- buffer_ptr++, prev_block_row++, next_block_row++;
657
- output_col += compptr->DCT_h_scaled_size;
658
- }
659
- output_ptr += compptr->DCT_v_scaled_size;
660
- }
661
- }
662
-
663
- if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
664
- return JPEG_ROW_COMPLETED;
665
- return JPEG_SCAN_COMPLETED;
666
- }
667
-
668
- #endif /* BLOCK_SMOOTHING_SUPPORTED */
669
-
670
-
671
- /*
672
- * Initialize coefficient buffer controller.
673
- */
674
-
675
- GLOBAL(void)
676
- jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer)
677
- {
678
- my_coef_ptr coef;
679
-
680
- coef = (my_coef_ptr)
681
- (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
682
- SIZEOF(my_coef_controller));
683
- cinfo->coef = (struct jpeg_d_coef_controller *) coef;
684
- coef->pub.start_input_pass = start_input_pass;
685
- coef->pub.start_output_pass = start_output_pass;
686
- #ifdef BLOCK_SMOOTHING_SUPPORTED
687
- coef->coef_bits_latch = NULL;
688
- #endif
689
-
690
- /* Create the coefficient buffer. */
691
- if (need_full_buffer) {
692
- #ifdef D_MULTISCAN_FILES_SUPPORTED
693
- /* Allocate a full-image virtual array for each component, */
694
- /* padded to a multiple of samp_factor DCT blocks in each direction. */
695
- /* Note we ask for a pre-zeroed array. */
696
- int ci, access_rows;
697
- jpeg_component_info *compptr;
698
-
699
- for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
700
- ci++, compptr++) {
701
- access_rows = compptr->v_samp_factor;
702
- #ifdef BLOCK_SMOOTHING_SUPPORTED
703
- /* If block smoothing could be used, need a bigger window */
704
- if (cinfo->progressive_mode)
705
- access_rows *= 3;
706
- #endif
707
- coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
708
- ((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE,
709
- (JDIMENSION) jround_up((long) compptr->width_in_blocks,
710
- (long) compptr->h_samp_factor),
711
- (JDIMENSION) jround_up((long) compptr->height_in_blocks,
712
- (long) compptr->v_samp_factor),
713
- (JDIMENSION) access_rows);
714
- }
715
- coef->pub.consume_data = consume_data;
716
- coef->pub.decompress_data = decompress_data;
717
- coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */
718
- #else
719
- ERREXIT(cinfo, JERR_NOT_COMPILED);
720
- #endif
721
- } else {
722
- /* We only need a single-MCU buffer. */
723
- JBLOCKROW buffer;
724
- int i;
725
-
726
- buffer = (JBLOCKROW)
727
- (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
728
- D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
729
- for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
730
- coef->MCU_buffer[i] = buffer + i;
731
- }
732
- coef->pub.consume_data = dummy_consume_data;
733
- coef->pub.decompress_data = decompress_onepass;
734
- coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
735
- }
736
- }