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.
- data/{README → README.md} +5 -11
- data/Rakefile +20 -14
- data/isbn.gemspec +23 -0
- data/lib/isbn.rb +2 -0
- data/test/isbn_spec.rb +1 -1
- metadata +29 -316
- data/VERSION +0 -1
- data/src/gocr-0.48/.cvsignore +0 -6
- data/src/gocr-0.48/AUTHORS +0 -7
- data/src/gocr-0.48/BUGS +0 -55
- data/src/gocr-0.48/CREDITS +0 -17
- data/src/gocr-0.48/HISTORY +0 -243
- data/src/gocr-0.48/INSTALL +0 -83
- data/src/gocr-0.48/Makefile +0 -193
- data/src/gocr-0.48/Makefile.in +0 -193
- data/src/gocr-0.48/README +0 -165
- data/src/gocr-0.48/READMEde.txt +0 -80
- data/src/gocr-0.48/REMARK.txt +0 -18
- data/src/gocr-0.48/REVIEW +0 -538
- data/src/gocr-0.48/TODO +0 -65
- data/src/gocr-0.48/bin/.cvsignore +0 -2
- data/src/gocr-0.48/bin/create_db +0 -38
- data/src/gocr-0.48/bin/gocr.tcl +0 -527
- data/src/gocr-0.48/bin/gocr_chk.sh +0 -44
- data/src/gocr-0.48/configure +0 -4689
- data/src/gocr-0.48/configure.in +0 -71
- data/src/gocr-0.48/doc/.#Makefile.1.6 +0 -39
- data/src/gocr-0.48/doc/.cvsignore +0 -2
- data/src/gocr-0.48/doc/Makefile +0 -39
- data/src/gocr-0.48/doc/Makefile.in +0 -39
- data/src/gocr-0.48/doc/example.dtd +0 -53
- data/src/gocr-0.48/doc/example.xml +0 -21
- data/src/gocr-0.48/doc/examples.txt +0 -67
- data/src/gocr-0.48/doc/gocr.html +0 -578
- data/src/gocr-0.48/doc/unicode.txt +0 -57
- data/src/gocr-0.48/examples/.#Makefile.1.22 +0 -166
- data/src/gocr-0.48/examples/4x6.png +0 -0
- data/src/gocr-0.48/examples/4x6.txt +0 -2
- data/src/gocr-0.48/examples/5x7.png +0 -0
- data/src/gocr-0.48/examples/5x7.png.txt +0 -2
- data/src/gocr-0.48/examples/5x8.png +0 -0
- data/src/gocr-0.48/examples/5x8.png.txt +0 -2
- data/src/gocr-0.48/examples/Makefile +0 -166
- data/src/gocr-0.48/examples/color.fig +0 -20
- data/src/gocr-0.48/examples/ex.fig +0 -16
- data/src/gocr-0.48/examples/font.tex +0 -22
- data/src/gocr-0.48/examples/font1.tex +0 -46
- data/src/gocr-0.48/examples/font2.fig +0 -27
- data/src/gocr-0.48/examples/font_nw.tex +0 -24
- data/src/gocr-0.48/examples/handwrt1.jpg +0 -0
- data/src/gocr-0.48/examples/handwrt1.txt +0 -10
- data/src/gocr-0.48/examples/inverse.fig +0 -20
- data/src/gocr-0.48/examples/matrix.jpg +0 -0
- data/src/gocr-0.48/examples/ocr-a-subset.png +0 -0
- data/src/gocr-0.48/examples/ocr-a-subset.png.txt +0 -4
- data/src/gocr-0.48/examples/ocr-a.png +0 -0
- data/src/gocr-0.48/examples/ocr-a.txt +0 -6
- data/src/gocr-0.48/examples/ocr-b.png +0 -0
- data/src/gocr-0.48/examples/ocr-b.png.txt +0 -4
- data/src/gocr-0.48/examples/polish.tex +0 -28
- data/src/gocr-0.48/examples/rotate45.fig +0 -14
- data/src/gocr-0.48/examples/score +0 -36
- data/src/gocr-0.48/examples/text.tex +0 -28
- data/src/gocr-0.48/gpl.html +0 -537
- data/src/gocr-0.48/include/.cvsignore +0 -2
- data/src/gocr-0.48/include/config.h +0 -36
- data/src/gocr-0.48/include/config.h.in +0 -36
- data/src/gocr-0.48/include/version.h +0 -2
- data/src/gocr-0.48/install-sh +0 -3
- data/src/gocr-0.48/make.bat +0 -57
- data/src/gocr-0.48/man/.cvsignore +0 -2
- data/src/gocr-0.48/man/Makefile +0 -29
- data/src/gocr-0.48/man/Makefile.in +0 -29
- data/src/gocr-0.48/man/man1/gocr.1 +0 -166
- data/src/gocr-0.48/src/.cvsignore +0 -4
- data/src/gocr-0.48/src/Makefile +0 -132
- data/src/gocr-0.48/src/Makefile.in +0 -132
- data/src/gocr-0.48/src/amiga.h +0 -31
- data/src/gocr-0.48/src/barcode.c +0 -846
- data/src/gocr-0.48/src/barcode.c.orig +0 -593
- data/src/gocr-0.48/src/barcode.h +0 -11
- data/src/gocr-0.48/src/box.c +0 -372
- data/src/gocr-0.48/src/database.c +0 -462
- data/src/gocr-0.48/src/detect.c +0 -943
- data/src/gocr-0.48/src/gocr.c +0 -373
- data/src/gocr-0.48/src/gocr.h +0 -288
- data/src/gocr-0.48/src/jconv.c +0 -168
- data/src/gocr-0.48/src/job.c +0 -84
- data/src/gocr-0.48/src/lines.c +0 -350
- data/src/gocr-0.48/src/list.c +0 -334
- data/src/gocr-0.48/src/list.h +0 -90
- data/src/gocr-0.48/src/ocr0.c +0 -6756
- data/src/gocr-0.48/src/ocr0.h +0 -63
- data/src/gocr-0.48/src/ocr0n.c +0 -1475
- data/src/gocr-0.48/src/ocr1.c +0 -85
- data/src/gocr-0.48/src/ocr1.h +0 -3
- data/src/gocr-0.48/src/otsu.c +0 -289
- data/src/gocr-0.48/src/otsu.h +0 -23
- data/src/gocr-0.48/src/output.c +0 -289
- data/src/gocr-0.48/src/output.h +0 -37
- data/src/gocr-0.48/src/pcx.c +0 -153
- data/src/gocr-0.48/src/pcx.h +0 -9
- data/src/gocr-0.48/src/pgm2asc.c +0 -2893
- data/src/gocr-0.48/src/pgm2asc.h +0 -105
- data/src/gocr-0.48/src/pixel.c +0 -537
- data/src/gocr-0.48/src/pnm.c +0 -533
- data/src/gocr-0.48/src/pnm.h +0 -35
- data/src/gocr-0.48/src/progress.c +0 -87
- data/src/gocr-0.48/src/progress.h +0 -42
- data/src/gocr-0.48/src/remove.c +0 -703
- data/src/gocr-0.48/src/tga.c +0 -87
- data/src/gocr-0.48/src/tga.h +0 -6
- data/src/gocr-0.48/src/unicode.c +0 -1314
- data/src/gocr-0.48/src/unicode.h +0 -1257
- data/src/jpeg-7/Makefile.am +0 -133
- data/src/jpeg-7/Makefile.in +0 -1089
- data/src/jpeg-7/README +0 -322
- data/src/jpeg-7/aclocal.m4 +0 -8990
- data/src/jpeg-7/ansi2knr.1 +0 -36
- data/src/jpeg-7/ansi2knr.c +0 -739
- data/src/jpeg-7/cderror.h +0 -132
- data/src/jpeg-7/cdjpeg.c +0 -181
- data/src/jpeg-7/cdjpeg.h +0 -187
- data/src/jpeg-7/change.log +0 -270
- data/src/jpeg-7/cjpeg.1 +0 -325
- data/src/jpeg-7/cjpeg.c +0 -616
- data/src/jpeg-7/ckconfig.c +0 -402
- data/src/jpeg-7/coderules.txt +0 -118
- data/src/jpeg-7/config.guess +0 -1561
- data/src/jpeg-7/config.sub +0 -1686
- data/src/jpeg-7/configure +0 -17139
- data/src/jpeg-7/configure.ac +0 -317
- data/src/jpeg-7/depcomp +0 -630
- data/src/jpeg-7/djpeg.1 +0 -251
- data/src/jpeg-7/djpeg.c +0 -617
- data/src/jpeg-7/example.c +0 -433
- data/src/jpeg-7/filelist.txt +0 -215
- data/src/jpeg-7/install-sh +0 -520
- data/src/jpeg-7/install.txt +0 -1097
- data/src/jpeg-7/jaricom.c +0 -148
- data/src/jpeg-7/jcapimin.c +0 -282
- data/src/jpeg-7/jcapistd.c +0 -161
- data/src/jpeg-7/jcarith.c +0 -921
- data/src/jpeg-7/jccoefct.c +0 -453
- data/src/jpeg-7/jccolor.c +0 -459
- data/src/jpeg-7/jcdctmgr.c +0 -482
- data/src/jpeg-7/jchuff.c +0 -1612
- data/src/jpeg-7/jcinit.c +0 -65
- data/src/jpeg-7/jcmainct.c +0 -293
- data/src/jpeg-7/jcmarker.c +0 -667
- data/src/jpeg-7/jcmaster.c +0 -770
- data/src/jpeg-7/jcomapi.c +0 -106
- data/src/jpeg-7/jconfig.bcc +0 -48
- data/src/jpeg-7/jconfig.cfg +0 -45
- data/src/jpeg-7/jconfig.dj +0 -38
- data/src/jpeg-7/jconfig.mac +0 -43
- data/src/jpeg-7/jconfig.manx +0 -43
- data/src/jpeg-7/jconfig.mc6 +0 -52
- data/src/jpeg-7/jconfig.sas +0 -43
- data/src/jpeg-7/jconfig.st +0 -42
- data/src/jpeg-7/jconfig.txt +0 -155
- data/src/jpeg-7/jconfig.vc +0 -45
- data/src/jpeg-7/jconfig.vms +0 -37
- data/src/jpeg-7/jconfig.wat +0 -38
- data/src/jpeg-7/jcparam.c +0 -632
- data/src/jpeg-7/jcprepct.c +0 -358
- data/src/jpeg-7/jcsample.c +0 -545
- data/src/jpeg-7/jctrans.c +0 -381
- data/src/jpeg-7/jdapimin.c +0 -396
- data/src/jpeg-7/jdapistd.c +0 -275
- data/src/jpeg-7/jdarith.c +0 -762
- data/src/jpeg-7/jdatadst.c +0 -151
- data/src/jpeg-7/jdatasrc.c +0 -212
- data/src/jpeg-7/jdcoefct.c +0 -736
- data/src/jpeg-7/jdcolor.c +0 -396
- data/src/jpeg-7/jdct.h +0 -393
- data/src/jpeg-7/jddctmgr.c +0 -382
- data/src/jpeg-7/jdhuff.c +0 -1309
- data/src/jpeg-7/jdinput.c +0 -384
- data/src/jpeg-7/jdmainct.c +0 -512
- data/src/jpeg-7/jdmarker.c +0 -1360
- data/src/jpeg-7/jdmaster.c +0 -663
- data/src/jpeg-7/jdmerge.c +0 -400
- data/src/jpeg-7/jdpostct.c +0 -290
- data/src/jpeg-7/jdsample.c +0 -361
- data/src/jpeg-7/jdtrans.c +0 -136
- data/src/jpeg-7/jerror.c +0 -252
- data/src/jpeg-7/jerror.h +0 -304
- data/src/jpeg-7/jfdctflt.c +0 -174
- data/src/jpeg-7/jfdctfst.c +0 -230
- data/src/jpeg-7/jfdctint.c +0 -4348
- data/src/jpeg-7/jidctflt.c +0 -242
- data/src/jpeg-7/jidctfst.c +0 -368
- data/src/jpeg-7/jidctint.c +0 -5137
- data/src/jpeg-7/jinclude.h +0 -91
- data/src/jpeg-7/jmemansi.c +0 -167
- data/src/jpeg-7/jmemdos.c +0 -638
- data/src/jpeg-7/jmemdosa.asm +0 -379
- data/src/jpeg-7/jmemmac.c +0 -289
- data/src/jpeg-7/jmemmgr.c +0 -1118
- data/src/jpeg-7/jmemname.c +0 -276
- data/src/jpeg-7/jmemnobs.c +0 -109
- data/src/jpeg-7/jmemsys.h +0 -198
- data/src/jpeg-7/jmorecfg.h +0 -369
- data/src/jpeg-7/jpegint.h +0 -395
- data/src/jpeg-7/jpeglib.h +0 -1135
- data/src/jpeg-7/jpegtran.1 +0 -272
- data/src/jpeg-7/jpegtran.c +0 -546
- data/src/jpeg-7/jquant1.c +0 -856
- data/src/jpeg-7/jquant2.c +0 -1310
- data/src/jpeg-7/jutils.c +0 -179
- data/src/jpeg-7/jversion.h +0 -14
- data/src/jpeg-7/libjpeg.map +0 -4
- data/src/jpeg-7/libjpeg.txt +0 -3067
- data/src/jpeg-7/ltmain.sh +0 -8406
- data/src/jpeg-7/makcjpeg.st +0 -36
- data/src/jpeg-7/makdjpeg.st +0 -36
- data/src/jpeg-7/makeadsw.vc6 +0 -77
- data/src/jpeg-7/makeasln.vc9 +0 -33
- data/src/jpeg-7/makecdep.vc6 +0 -82
- data/src/jpeg-7/makecdsp.vc6 +0 -130
- data/src/jpeg-7/makecmak.vc6 +0 -159
- data/src/jpeg-7/makecvcp.vc9 +0 -186
- data/src/jpeg-7/makeddep.vc6 +0 -82
- data/src/jpeg-7/makeddsp.vc6 +0 -130
- data/src/jpeg-7/makedmak.vc6 +0 -159
- data/src/jpeg-7/makedvcp.vc9 +0 -186
- data/src/jpeg-7/makefile.ansi +0 -220
- data/src/jpeg-7/makefile.bcc +0 -291
- data/src/jpeg-7/makefile.dj +0 -226
- data/src/jpeg-7/makefile.manx +0 -220
- data/src/jpeg-7/makefile.mc6 +0 -255
- data/src/jpeg-7/makefile.mms +0 -224
- data/src/jpeg-7/makefile.sas +0 -258
- data/src/jpeg-7/makefile.unix +0 -234
- data/src/jpeg-7/makefile.vc +0 -217
- data/src/jpeg-7/makefile.vms +0 -142
- data/src/jpeg-7/makefile.wat +0 -239
- data/src/jpeg-7/makejdep.vc6 +0 -423
- data/src/jpeg-7/makejdsp.vc6 +0 -285
- data/src/jpeg-7/makejdsw.vc6 +0 -29
- data/src/jpeg-7/makejmak.vc6 +0 -425
- data/src/jpeg-7/makejsln.vc9 +0 -17
- data/src/jpeg-7/makejvcp.vc9 +0 -328
- data/src/jpeg-7/makeproj.mac +0 -213
- data/src/jpeg-7/makerdep.vc6 +0 -6
- data/src/jpeg-7/makerdsp.vc6 +0 -78
- data/src/jpeg-7/makermak.vc6 +0 -110
- data/src/jpeg-7/makervcp.vc9 +0 -133
- data/src/jpeg-7/maketdep.vc6 +0 -43
- data/src/jpeg-7/maketdsp.vc6 +0 -122
- data/src/jpeg-7/maketmak.vc6 +0 -131
- data/src/jpeg-7/maketvcp.vc9 +0 -178
- data/src/jpeg-7/makewdep.vc6 +0 -6
- data/src/jpeg-7/makewdsp.vc6 +0 -78
- data/src/jpeg-7/makewmak.vc6 +0 -110
- data/src/jpeg-7/makewvcp.vc9 +0 -133
- data/src/jpeg-7/makljpeg.st +0 -68
- data/src/jpeg-7/maktjpeg.st +0 -30
- data/src/jpeg-7/makvms.opt +0 -4
- data/src/jpeg-7/missing +0 -376
- data/src/jpeg-7/rdbmp.c +0 -439
- data/src/jpeg-7/rdcolmap.c +0 -253
- data/src/jpeg-7/rdgif.c +0 -38
- data/src/jpeg-7/rdjpgcom.1 +0 -63
- data/src/jpeg-7/rdjpgcom.c +0 -515
- data/src/jpeg-7/rdppm.c +0 -459
- data/src/jpeg-7/rdrle.c +0 -387
- data/src/jpeg-7/rdswitch.c +0 -365
- data/src/jpeg-7/rdtarga.c +0 -500
- data/src/jpeg-7/structure.txt +0 -945
- data/src/jpeg-7/testimg.bmp +0 -0
- data/src/jpeg-7/testimg.jpg +0 -0
- data/src/jpeg-7/testimg.ppm +0 -4
- data/src/jpeg-7/testimgp.jpg +0 -0
- data/src/jpeg-7/testorig.jpg +0 -0
- data/src/jpeg-7/testprog.jpg +0 -0
- data/src/jpeg-7/transupp.c +0 -1533
- data/src/jpeg-7/transupp.h +0 -205
- data/src/jpeg-7/usage.txt +0 -605
- data/src/jpeg-7/wizard.txt +0 -211
- data/src/jpeg-7/wrbmp.c +0 -442
- data/src/jpeg-7/wrgif.c +0 -399
- data/src/jpeg-7/wrjpgcom.1 +0 -103
- data/src/jpeg-7/wrjpgcom.c +0 -583
- data/src/jpeg-7/wrppm.c +0 -269
- data/src/jpeg-7/wrrle.c +0 -305
- data/src/jpeg-7/wrtarga.c +0 -253
data/src/jpeg-7/jcinit.c
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* jcinit.c
|
3
|
-
*
|
4
|
-
* Copyright (C) 1991-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 initialization logic for the JPEG compressor.
|
9
|
-
* This routine is in charge of selecting the modules to be executed and
|
10
|
-
* making an initialization call to each one.
|
11
|
-
*
|
12
|
-
* Logically, this code belongs in jcmaster.c. It's split out because
|
13
|
-
* linking this routine implies linking the entire compression library.
|
14
|
-
* For a transcoding-only application, we want to be able to use jcmaster.c
|
15
|
-
* without linking in the whole library.
|
16
|
-
*/
|
17
|
-
|
18
|
-
#define JPEG_INTERNALS
|
19
|
-
#include "jinclude.h"
|
20
|
-
#include "jpeglib.h"
|
21
|
-
|
22
|
-
|
23
|
-
/*
|
24
|
-
* Master selection of compression modules.
|
25
|
-
* This is done once at the start of processing an image. We determine
|
26
|
-
* which modules will be used and give them appropriate initialization calls.
|
27
|
-
*/
|
28
|
-
|
29
|
-
GLOBAL(void)
|
30
|
-
jinit_compress_master (j_compress_ptr cinfo)
|
31
|
-
{
|
32
|
-
/* Initialize master control (includes parameter checking/processing) */
|
33
|
-
jinit_c_master_control(cinfo, FALSE /* full compression */);
|
34
|
-
|
35
|
-
/* Preprocessing */
|
36
|
-
if (! cinfo->raw_data_in) {
|
37
|
-
jinit_color_converter(cinfo);
|
38
|
-
jinit_downsampler(cinfo);
|
39
|
-
jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */);
|
40
|
-
}
|
41
|
-
/* Forward DCT */
|
42
|
-
jinit_forward_dct(cinfo);
|
43
|
-
/* Entropy encoding: either Huffman or arithmetic coding. */
|
44
|
-
if (cinfo->arith_code)
|
45
|
-
jinit_arith_encoder(cinfo);
|
46
|
-
else {
|
47
|
-
jinit_huff_encoder(cinfo);
|
48
|
-
}
|
49
|
-
|
50
|
-
/* Need a full-image coefficient buffer in any multi-pass mode. */
|
51
|
-
jinit_c_coef_controller(cinfo,
|
52
|
-
(boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding));
|
53
|
-
jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */);
|
54
|
-
|
55
|
-
jinit_marker_writer(cinfo);
|
56
|
-
|
57
|
-
/* We can now tell the memory manager to allocate virtual arrays. */
|
58
|
-
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
|
59
|
-
|
60
|
-
/* Write the datastream header (SOI) immediately.
|
61
|
-
* Frame and scan headers are postponed till later.
|
62
|
-
* This lets application insert special markers after the SOI.
|
63
|
-
*/
|
64
|
-
(*cinfo->marker->write_file_header) (cinfo);
|
65
|
-
}
|
data/src/jpeg-7/jcmainct.c
DELETED
@@ -1,293 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* jcmainct.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 the main buffer controller for compression.
|
9
|
-
* The main buffer lies between the pre-processor and the JPEG
|
10
|
-
* compressor proper; it holds downsampled data in the JPEG colorspace.
|
11
|
-
*/
|
12
|
-
|
13
|
-
#define JPEG_INTERNALS
|
14
|
-
#include "jinclude.h"
|
15
|
-
#include "jpeglib.h"
|
16
|
-
|
17
|
-
|
18
|
-
/* Note: currently, there is no operating mode in which a full-image buffer
|
19
|
-
* is needed at this step. If there were, that mode could not be used with
|
20
|
-
* "raw data" input, since this module is bypassed in that case. However,
|
21
|
-
* we've left the code here for possible use in special applications.
|
22
|
-
*/
|
23
|
-
#undef FULL_MAIN_BUFFER_SUPPORTED
|
24
|
-
|
25
|
-
|
26
|
-
/* Private buffer controller object */
|
27
|
-
|
28
|
-
typedef struct {
|
29
|
-
struct jpeg_c_main_controller pub; /* public fields */
|
30
|
-
|
31
|
-
JDIMENSION cur_iMCU_row; /* number of current iMCU row */
|
32
|
-
JDIMENSION rowgroup_ctr; /* counts row groups received in iMCU row */
|
33
|
-
boolean suspended; /* remember if we suspended output */
|
34
|
-
J_BUF_MODE pass_mode; /* current operating mode */
|
35
|
-
|
36
|
-
/* If using just a strip buffer, this points to the entire set of buffers
|
37
|
-
* (we allocate one for each component). In the full-image case, this
|
38
|
-
* points to the currently accessible strips of the virtual arrays.
|
39
|
-
*/
|
40
|
-
JSAMPARRAY buffer[MAX_COMPONENTS];
|
41
|
-
|
42
|
-
#ifdef FULL_MAIN_BUFFER_SUPPORTED
|
43
|
-
/* If using full-image storage, this array holds pointers to virtual-array
|
44
|
-
* control blocks for each component. Unused if not full-image storage.
|
45
|
-
*/
|
46
|
-
jvirt_sarray_ptr whole_image[MAX_COMPONENTS];
|
47
|
-
#endif
|
48
|
-
} my_main_controller;
|
49
|
-
|
50
|
-
typedef my_main_controller * my_main_ptr;
|
51
|
-
|
52
|
-
|
53
|
-
/* Forward declarations */
|
54
|
-
METHODDEF(void) process_data_simple_main
|
55
|
-
JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
56
|
-
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail));
|
57
|
-
#ifdef FULL_MAIN_BUFFER_SUPPORTED
|
58
|
-
METHODDEF(void) process_data_buffer_main
|
59
|
-
JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf,
|
60
|
-
JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail));
|
61
|
-
#endif
|
62
|
-
|
63
|
-
|
64
|
-
/*
|
65
|
-
* Initialize for a processing pass.
|
66
|
-
*/
|
67
|
-
|
68
|
-
METHODDEF(void)
|
69
|
-
start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
70
|
-
{
|
71
|
-
my_main_ptr main = (my_main_ptr) cinfo->main;
|
72
|
-
|
73
|
-
/* Do nothing in raw-data mode. */
|
74
|
-
if (cinfo->raw_data_in)
|
75
|
-
return;
|
76
|
-
|
77
|
-
main->cur_iMCU_row = 0; /* initialize counters */
|
78
|
-
main->rowgroup_ctr = 0;
|
79
|
-
main->suspended = FALSE;
|
80
|
-
main->pass_mode = pass_mode; /* save mode for use by process_data */
|
81
|
-
|
82
|
-
switch (pass_mode) {
|
83
|
-
case JBUF_PASS_THRU:
|
84
|
-
#ifdef FULL_MAIN_BUFFER_SUPPORTED
|
85
|
-
if (main->whole_image[0] != NULL)
|
86
|
-
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
87
|
-
#endif
|
88
|
-
main->pub.process_data = process_data_simple_main;
|
89
|
-
break;
|
90
|
-
#ifdef FULL_MAIN_BUFFER_SUPPORTED
|
91
|
-
case JBUF_SAVE_SOURCE:
|
92
|
-
case JBUF_CRANK_DEST:
|
93
|
-
case JBUF_SAVE_AND_PASS:
|
94
|
-
if (main->whole_image[0] == NULL)
|
95
|
-
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
96
|
-
main->pub.process_data = process_data_buffer_main;
|
97
|
-
break;
|
98
|
-
#endif
|
99
|
-
default:
|
100
|
-
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
101
|
-
break;
|
102
|
-
}
|
103
|
-
}
|
104
|
-
|
105
|
-
|
106
|
-
/*
|
107
|
-
* Process some data.
|
108
|
-
* This routine handles the simple pass-through mode,
|
109
|
-
* where we have only a strip buffer.
|
110
|
-
*/
|
111
|
-
|
112
|
-
METHODDEF(void)
|
113
|
-
process_data_simple_main (j_compress_ptr cinfo,
|
114
|
-
JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
|
115
|
-
JDIMENSION in_rows_avail)
|
116
|
-
{
|
117
|
-
my_main_ptr main = (my_main_ptr) cinfo->main;
|
118
|
-
|
119
|
-
while (main->cur_iMCU_row < cinfo->total_iMCU_rows) {
|
120
|
-
/* Read input data if we haven't filled the main buffer yet */
|
121
|
-
if (main->rowgroup_ctr < (JDIMENSION) cinfo->min_DCT_v_scaled_size)
|
122
|
-
(*cinfo->prep->pre_process_data) (cinfo,
|
123
|
-
input_buf, in_row_ctr, in_rows_avail,
|
124
|
-
main->buffer, &main->rowgroup_ctr,
|
125
|
-
(JDIMENSION) cinfo->min_DCT_v_scaled_size);
|
126
|
-
|
127
|
-
/* If we don't have a full iMCU row buffered, return to application for
|
128
|
-
* more data. Note that preprocessor will always pad to fill the iMCU row
|
129
|
-
* at the bottom of the image.
|
130
|
-
*/
|
131
|
-
if (main->rowgroup_ctr != (JDIMENSION) cinfo->min_DCT_v_scaled_size)
|
132
|
-
return;
|
133
|
-
|
134
|
-
/* Send the completed row to the compressor */
|
135
|
-
if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) {
|
136
|
-
/* If compressor did not consume the whole row, then we must need to
|
137
|
-
* suspend processing and return to the application. In this situation
|
138
|
-
* we pretend we didn't yet consume the last input row; otherwise, if
|
139
|
-
* it happened to be the last row of the image, the application would
|
140
|
-
* think we were done.
|
141
|
-
*/
|
142
|
-
if (! main->suspended) {
|
143
|
-
(*in_row_ctr)--;
|
144
|
-
main->suspended = TRUE;
|
145
|
-
}
|
146
|
-
return;
|
147
|
-
}
|
148
|
-
/* We did finish the row. Undo our little suspension hack if a previous
|
149
|
-
* call suspended; then mark the main buffer empty.
|
150
|
-
*/
|
151
|
-
if (main->suspended) {
|
152
|
-
(*in_row_ctr)++;
|
153
|
-
main->suspended = FALSE;
|
154
|
-
}
|
155
|
-
main->rowgroup_ctr = 0;
|
156
|
-
main->cur_iMCU_row++;
|
157
|
-
}
|
158
|
-
}
|
159
|
-
|
160
|
-
|
161
|
-
#ifdef FULL_MAIN_BUFFER_SUPPORTED
|
162
|
-
|
163
|
-
/*
|
164
|
-
* Process some data.
|
165
|
-
* This routine handles all of the modes that use a full-size buffer.
|
166
|
-
*/
|
167
|
-
|
168
|
-
METHODDEF(void)
|
169
|
-
process_data_buffer_main (j_compress_ptr cinfo,
|
170
|
-
JSAMPARRAY input_buf, JDIMENSION *in_row_ctr,
|
171
|
-
JDIMENSION in_rows_avail)
|
172
|
-
{
|
173
|
-
my_main_ptr main = (my_main_ptr) cinfo->main;
|
174
|
-
int ci;
|
175
|
-
jpeg_component_info *compptr;
|
176
|
-
boolean writing = (main->pass_mode != JBUF_CRANK_DEST);
|
177
|
-
|
178
|
-
while (main->cur_iMCU_row < cinfo->total_iMCU_rows) {
|
179
|
-
/* Realign the virtual buffers if at the start of an iMCU row. */
|
180
|
-
if (main->rowgroup_ctr == 0) {
|
181
|
-
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
182
|
-
ci++, compptr++) {
|
183
|
-
main->buffer[ci] = (*cinfo->mem->access_virt_sarray)
|
184
|
-
((j_common_ptr) cinfo, main->whole_image[ci],
|
185
|
-
main->cur_iMCU_row * (compptr->v_samp_factor * DCTSIZE),
|
186
|
-
(JDIMENSION) (compptr->v_samp_factor * DCTSIZE), writing);
|
187
|
-
}
|
188
|
-
/* In a read pass, pretend we just read some source data. */
|
189
|
-
if (! writing) {
|
190
|
-
*in_row_ctr += cinfo->max_v_samp_factor * DCTSIZE;
|
191
|
-
main->rowgroup_ctr = DCTSIZE;
|
192
|
-
}
|
193
|
-
}
|
194
|
-
|
195
|
-
/* If a write pass, read input data until the current iMCU row is full. */
|
196
|
-
/* Note: preprocessor will pad if necessary to fill the last iMCU row. */
|
197
|
-
if (writing) {
|
198
|
-
(*cinfo->prep->pre_process_data) (cinfo,
|
199
|
-
input_buf, in_row_ctr, in_rows_avail,
|
200
|
-
main->buffer, &main->rowgroup_ctr,
|
201
|
-
(JDIMENSION) DCTSIZE);
|
202
|
-
/* Return to application if we need more data to fill the iMCU row. */
|
203
|
-
if (main->rowgroup_ctr < DCTSIZE)
|
204
|
-
return;
|
205
|
-
}
|
206
|
-
|
207
|
-
/* Emit data, unless this is a sink-only pass. */
|
208
|
-
if (main->pass_mode != JBUF_SAVE_SOURCE) {
|
209
|
-
if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) {
|
210
|
-
/* If compressor did not consume the whole row, then we must need to
|
211
|
-
* suspend processing and return to the application. In this situation
|
212
|
-
* we pretend we didn't yet consume the last input row; otherwise, if
|
213
|
-
* it happened to be the last row of the image, the application would
|
214
|
-
* think we were done.
|
215
|
-
*/
|
216
|
-
if (! main->suspended) {
|
217
|
-
(*in_row_ctr)--;
|
218
|
-
main->suspended = TRUE;
|
219
|
-
}
|
220
|
-
return;
|
221
|
-
}
|
222
|
-
/* We did finish the row. Undo our little suspension hack if a previous
|
223
|
-
* call suspended; then mark the main buffer empty.
|
224
|
-
*/
|
225
|
-
if (main->suspended) {
|
226
|
-
(*in_row_ctr)++;
|
227
|
-
main->suspended = FALSE;
|
228
|
-
}
|
229
|
-
}
|
230
|
-
|
231
|
-
/* If get here, we are done with this iMCU row. Mark buffer empty. */
|
232
|
-
main->rowgroup_ctr = 0;
|
233
|
-
main->cur_iMCU_row++;
|
234
|
-
}
|
235
|
-
}
|
236
|
-
|
237
|
-
#endif /* FULL_MAIN_BUFFER_SUPPORTED */
|
238
|
-
|
239
|
-
|
240
|
-
/*
|
241
|
-
* Initialize main buffer controller.
|
242
|
-
*/
|
243
|
-
|
244
|
-
GLOBAL(void)
|
245
|
-
jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer)
|
246
|
-
{
|
247
|
-
my_main_ptr main;
|
248
|
-
int ci;
|
249
|
-
jpeg_component_info *compptr;
|
250
|
-
|
251
|
-
main = (my_main_ptr)
|
252
|
-
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
253
|
-
SIZEOF(my_main_controller));
|
254
|
-
cinfo->main = (struct jpeg_c_main_controller *) main;
|
255
|
-
main->pub.start_pass = start_pass_main;
|
256
|
-
|
257
|
-
/* We don't need to create a buffer in raw-data mode. */
|
258
|
-
if (cinfo->raw_data_in)
|
259
|
-
return;
|
260
|
-
|
261
|
-
/* Create the buffer. It holds downsampled data, so each component
|
262
|
-
* may be of a different size.
|
263
|
-
*/
|
264
|
-
if (need_full_buffer) {
|
265
|
-
#ifdef FULL_MAIN_BUFFER_SUPPORTED
|
266
|
-
/* Allocate a full-image virtual array for each component */
|
267
|
-
/* Note we pad the bottom to a multiple of the iMCU height */
|
268
|
-
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
269
|
-
ci++, compptr++) {
|
270
|
-
main->whole_image[ci] = (*cinfo->mem->request_virt_sarray)
|
271
|
-
((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE,
|
272
|
-
compptr->width_in_blocks * compptr->DCT_h_scaled_size,
|
273
|
-
(JDIMENSION) jround_up((long) compptr->height_in_blocks,
|
274
|
-
(long) compptr->v_samp_factor) * DCTSIZE,
|
275
|
-
(JDIMENSION) (compptr->v_samp_factor * compptr->DCT_v_scaled_size));
|
276
|
-
}
|
277
|
-
#else
|
278
|
-
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
279
|
-
#endif
|
280
|
-
} else {
|
281
|
-
#ifdef FULL_MAIN_BUFFER_SUPPORTED
|
282
|
-
main->whole_image[0] = NULL; /* flag for no virtual arrays */
|
283
|
-
#endif
|
284
|
-
/* Allocate a strip buffer for each component */
|
285
|
-
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
286
|
-
ci++, compptr++) {
|
287
|
-
main->buffer[ci] = (*cinfo->mem->alloc_sarray)
|
288
|
-
((j_common_ptr) cinfo, JPOOL_IMAGE,
|
289
|
-
compptr->width_in_blocks * compptr->DCT_h_scaled_size,
|
290
|
-
(JDIMENSION) (compptr->v_samp_factor * compptr->DCT_v_scaled_size));
|
291
|
-
}
|
292
|
-
}
|
293
|
-
}
|
data/src/jpeg-7/jcmarker.c
DELETED
@@ -1,667 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* jcmarker.c
|
3
|
-
*
|
4
|
-
* Copyright (C) 1991-1998, 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 routines to write JPEG datastream markers.
|
9
|
-
*/
|
10
|
-
|
11
|
-
#define JPEG_INTERNALS
|
12
|
-
#include "jinclude.h"
|
13
|
-
#include "jpeglib.h"
|
14
|
-
|
15
|
-
|
16
|
-
typedef enum { /* JPEG marker codes */
|
17
|
-
M_SOF0 = 0xc0,
|
18
|
-
M_SOF1 = 0xc1,
|
19
|
-
M_SOF2 = 0xc2,
|
20
|
-
M_SOF3 = 0xc3,
|
21
|
-
|
22
|
-
M_SOF5 = 0xc5,
|
23
|
-
M_SOF6 = 0xc6,
|
24
|
-
M_SOF7 = 0xc7,
|
25
|
-
|
26
|
-
M_JPG = 0xc8,
|
27
|
-
M_SOF9 = 0xc9,
|
28
|
-
M_SOF10 = 0xca,
|
29
|
-
M_SOF11 = 0xcb,
|
30
|
-
|
31
|
-
M_SOF13 = 0xcd,
|
32
|
-
M_SOF14 = 0xce,
|
33
|
-
M_SOF15 = 0xcf,
|
34
|
-
|
35
|
-
M_DHT = 0xc4,
|
36
|
-
|
37
|
-
M_DAC = 0xcc,
|
38
|
-
|
39
|
-
M_RST0 = 0xd0,
|
40
|
-
M_RST1 = 0xd1,
|
41
|
-
M_RST2 = 0xd2,
|
42
|
-
M_RST3 = 0xd3,
|
43
|
-
M_RST4 = 0xd4,
|
44
|
-
M_RST5 = 0xd5,
|
45
|
-
M_RST6 = 0xd6,
|
46
|
-
M_RST7 = 0xd7,
|
47
|
-
|
48
|
-
M_SOI = 0xd8,
|
49
|
-
M_EOI = 0xd9,
|
50
|
-
M_SOS = 0xda,
|
51
|
-
M_DQT = 0xdb,
|
52
|
-
M_DNL = 0xdc,
|
53
|
-
M_DRI = 0xdd,
|
54
|
-
M_DHP = 0xde,
|
55
|
-
M_EXP = 0xdf,
|
56
|
-
|
57
|
-
M_APP0 = 0xe0,
|
58
|
-
M_APP1 = 0xe1,
|
59
|
-
M_APP2 = 0xe2,
|
60
|
-
M_APP3 = 0xe3,
|
61
|
-
M_APP4 = 0xe4,
|
62
|
-
M_APP5 = 0xe5,
|
63
|
-
M_APP6 = 0xe6,
|
64
|
-
M_APP7 = 0xe7,
|
65
|
-
M_APP8 = 0xe8,
|
66
|
-
M_APP9 = 0xe9,
|
67
|
-
M_APP10 = 0xea,
|
68
|
-
M_APP11 = 0xeb,
|
69
|
-
M_APP12 = 0xec,
|
70
|
-
M_APP13 = 0xed,
|
71
|
-
M_APP14 = 0xee,
|
72
|
-
M_APP15 = 0xef,
|
73
|
-
|
74
|
-
M_JPG0 = 0xf0,
|
75
|
-
M_JPG13 = 0xfd,
|
76
|
-
M_COM = 0xfe,
|
77
|
-
|
78
|
-
M_TEM = 0x01,
|
79
|
-
|
80
|
-
M_ERROR = 0x100
|
81
|
-
} JPEG_MARKER;
|
82
|
-
|
83
|
-
|
84
|
-
/* Private state */
|
85
|
-
|
86
|
-
typedef struct {
|
87
|
-
struct jpeg_marker_writer pub; /* public fields */
|
88
|
-
|
89
|
-
unsigned int last_restart_interval; /* last DRI value emitted; 0 after SOI */
|
90
|
-
} my_marker_writer;
|
91
|
-
|
92
|
-
typedef my_marker_writer * my_marker_ptr;
|
93
|
-
|
94
|
-
|
95
|
-
/*
|
96
|
-
* Basic output routines.
|
97
|
-
*
|
98
|
-
* Note that we do not support suspension while writing a marker.
|
99
|
-
* Therefore, an application using suspension must ensure that there is
|
100
|
-
* enough buffer space for the initial markers (typ. 600-700 bytes) before
|
101
|
-
* calling jpeg_start_compress, and enough space to write the trailing EOI
|
102
|
-
* (a few bytes) before calling jpeg_finish_compress. Multipass compression
|
103
|
-
* modes are not supported at all with suspension, so those two are the only
|
104
|
-
* points where markers will be written.
|
105
|
-
*/
|
106
|
-
|
107
|
-
LOCAL(void)
|
108
|
-
emit_byte (j_compress_ptr cinfo, int val)
|
109
|
-
/* Emit a byte */
|
110
|
-
{
|
111
|
-
struct jpeg_destination_mgr * dest = cinfo->dest;
|
112
|
-
|
113
|
-
*(dest->next_output_byte)++ = (JOCTET) val;
|
114
|
-
if (--dest->free_in_buffer == 0) {
|
115
|
-
if (! (*dest->empty_output_buffer) (cinfo))
|
116
|
-
ERREXIT(cinfo, JERR_CANT_SUSPEND);
|
117
|
-
}
|
118
|
-
}
|
119
|
-
|
120
|
-
|
121
|
-
LOCAL(void)
|
122
|
-
emit_marker (j_compress_ptr cinfo, JPEG_MARKER mark)
|
123
|
-
/* Emit a marker code */
|
124
|
-
{
|
125
|
-
emit_byte(cinfo, 0xFF);
|
126
|
-
emit_byte(cinfo, (int) mark);
|
127
|
-
}
|
128
|
-
|
129
|
-
|
130
|
-
LOCAL(void)
|
131
|
-
emit_2bytes (j_compress_ptr cinfo, int value)
|
132
|
-
/* Emit a 2-byte integer; these are always MSB first in JPEG files */
|
133
|
-
{
|
134
|
-
emit_byte(cinfo, (value >> 8) & 0xFF);
|
135
|
-
emit_byte(cinfo, value & 0xFF);
|
136
|
-
}
|
137
|
-
|
138
|
-
|
139
|
-
/*
|
140
|
-
* Routines to write specific marker types.
|
141
|
-
*/
|
142
|
-
|
143
|
-
LOCAL(int)
|
144
|
-
emit_dqt (j_compress_ptr cinfo, int index)
|
145
|
-
/* Emit a DQT marker */
|
146
|
-
/* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */
|
147
|
-
{
|
148
|
-
JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[index];
|
149
|
-
int prec;
|
150
|
-
int i;
|
151
|
-
|
152
|
-
if (qtbl == NULL)
|
153
|
-
ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index);
|
154
|
-
|
155
|
-
prec = 0;
|
156
|
-
for (i = 0; i < DCTSIZE2; i++) {
|
157
|
-
if (qtbl->quantval[i] > 255)
|
158
|
-
prec = 1;
|
159
|
-
}
|
160
|
-
|
161
|
-
if (! qtbl->sent_table) {
|
162
|
-
emit_marker(cinfo, M_DQT);
|
163
|
-
|
164
|
-
emit_2bytes(cinfo, prec ? DCTSIZE2*2 + 1 + 2 : DCTSIZE2 + 1 + 2);
|
165
|
-
|
166
|
-
emit_byte(cinfo, index + (prec<<4));
|
167
|
-
|
168
|
-
for (i = 0; i < DCTSIZE2; i++) {
|
169
|
-
/* The table entries must be emitted in zigzag order. */
|
170
|
-
unsigned int qval = qtbl->quantval[jpeg_natural_order[i]];
|
171
|
-
if (prec)
|
172
|
-
emit_byte(cinfo, (int) (qval >> 8));
|
173
|
-
emit_byte(cinfo, (int) (qval & 0xFF));
|
174
|
-
}
|
175
|
-
|
176
|
-
qtbl->sent_table = TRUE;
|
177
|
-
}
|
178
|
-
|
179
|
-
return prec;
|
180
|
-
}
|
181
|
-
|
182
|
-
|
183
|
-
LOCAL(void)
|
184
|
-
emit_dht (j_compress_ptr cinfo, int index, boolean is_ac)
|
185
|
-
/* Emit a DHT marker */
|
186
|
-
{
|
187
|
-
JHUFF_TBL * htbl;
|
188
|
-
int length, i;
|
189
|
-
|
190
|
-
if (is_ac) {
|
191
|
-
htbl = cinfo->ac_huff_tbl_ptrs[index];
|
192
|
-
index += 0x10; /* output index has AC bit set */
|
193
|
-
} else {
|
194
|
-
htbl = cinfo->dc_huff_tbl_ptrs[index];
|
195
|
-
}
|
196
|
-
|
197
|
-
if (htbl == NULL)
|
198
|
-
ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index);
|
199
|
-
|
200
|
-
if (! htbl->sent_table) {
|
201
|
-
emit_marker(cinfo, M_DHT);
|
202
|
-
|
203
|
-
length = 0;
|
204
|
-
for (i = 1; i <= 16; i++)
|
205
|
-
length += htbl->bits[i];
|
206
|
-
|
207
|
-
emit_2bytes(cinfo, length + 2 + 1 + 16);
|
208
|
-
emit_byte(cinfo, index);
|
209
|
-
|
210
|
-
for (i = 1; i <= 16; i++)
|
211
|
-
emit_byte(cinfo, htbl->bits[i]);
|
212
|
-
|
213
|
-
for (i = 0; i < length; i++)
|
214
|
-
emit_byte(cinfo, htbl->huffval[i]);
|
215
|
-
|
216
|
-
htbl->sent_table = TRUE;
|
217
|
-
}
|
218
|
-
}
|
219
|
-
|
220
|
-
|
221
|
-
LOCAL(void)
|
222
|
-
emit_dac (j_compress_ptr cinfo)
|
223
|
-
/* Emit a DAC marker */
|
224
|
-
/* Since the useful info is so small, we want to emit all the tables in */
|
225
|
-
/* one DAC marker. Therefore this routine does its own scan of the table. */
|
226
|
-
{
|
227
|
-
#ifdef C_ARITH_CODING_SUPPORTED
|
228
|
-
char dc_in_use[NUM_ARITH_TBLS];
|
229
|
-
char ac_in_use[NUM_ARITH_TBLS];
|
230
|
-
int length, i;
|
231
|
-
jpeg_component_info *compptr;
|
232
|
-
|
233
|
-
for (i = 0; i < NUM_ARITH_TBLS; i++)
|
234
|
-
dc_in_use[i] = ac_in_use[i] = 0;
|
235
|
-
|
236
|
-
for (i = 0; i < cinfo->comps_in_scan; i++) {
|
237
|
-
compptr = cinfo->cur_comp_info[i];
|
238
|
-
dc_in_use[compptr->dc_tbl_no] = 1;
|
239
|
-
ac_in_use[compptr->ac_tbl_no] = 1;
|
240
|
-
}
|
241
|
-
|
242
|
-
length = 0;
|
243
|
-
for (i = 0; i < NUM_ARITH_TBLS; i++)
|
244
|
-
length += dc_in_use[i] + ac_in_use[i];
|
245
|
-
|
246
|
-
emit_marker(cinfo, M_DAC);
|
247
|
-
|
248
|
-
emit_2bytes(cinfo, length*2 + 2);
|
249
|
-
|
250
|
-
for (i = 0; i < NUM_ARITH_TBLS; i++) {
|
251
|
-
if (dc_in_use[i]) {
|
252
|
-
emit_byte(cinfo, i);
|
253
|
-
emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4));
|
254
|
-
}
|
255
|
-
if (ac_in_use[i]) {
|
256
|
-
emit_byte(cinfo, i + 0x10);
|
257
|
-
emit_byte(cinfo, cinfo->arith_ac_K[i]);
|
258
|
-
}
|
259
|
-
}
|
260
|
-
#endif /* C_ARITH_CODING_SUPPORTED */
|
261
|
-
}
|
262
|
-
|
263
|
-
|
264
|
-
LOCAL(void)
|
265
|
-
emit_dri (j_compress_ptr cinfo)
|
266
|
-
/* Emit a DRI marker */
|
267
|
-
{
|
268
|
-
emit_marker(cinfo, M_DRI);
|
269
|
-
|
270
|
-
emit_2bytes(cinfo, 4); /* fixed length */
|
271
|
-
|
272
|
-
emit_2bytes(cinfo, (int) cinfo->restart_interval);
|
273
|
-
}
|
274
|
-
|
275
|
-
|
276
|
-
LOCAL(void)
|
277
|
-
emit_sof (j_compress_ptr cinfo, JPEG_MARKER code)
|
278
|
-
/* Emit a SOF marker */
|
279
|
-
{
|
280
|
-
int ci;
|
281
|
-
jpeg_component_info *compptr;
|
282
|
-
|
283
|
-
emit_marker(cinfo, code);
|
284
|
-
|
285
|
-
emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */
|
286
|
-
|
287
|
-
/* Make sure image isn't bigger than SOF field can handle */
|
288
|
-
if ((long) cinfo->jpeg_height > 65535L ||
|
289
|
-
(long) cinfo->jpeg_width > 65535L)
|
290
|
-
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535);
|
291
|
-
|
292
|
-
emit_byte(cinfo, cinfo->data_precision);
|
293
|
-
emit_2bytes(cinfo, (int) cinfo->jpeg_height);
|
294
|
-
emit_2bytes(cinfo, (int) cinfo->jpeg_width);
|
295
|
-
|
296
|
-
emit_byte(cinfo, cinfo->num_components);
|
297
|
-
|
298
|
-
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
299
|
-
ci++, compptr++) {
|
300
|
-
emit_byte(cinfo, compptr->component_id);
|
301
|
-
emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor);
|
302
|
-
emit_byte(cinfo, compptr->quant_tbl_no);
|
303
|
-
}
|
304
|
-
}
|
305
|
-
|
306
|
-
|
307
|
-
LOCAL(void)
|
308
|
-
emit_sos (j_compress_ptr cinfo)
|
309
|
-
/* Emit a SOS marker */
|
310
|
-
{
|
311
|
-
int i, td, ta;
|
312
|
-
jpeg_component_info *compptr;
|
313
|
-
|
314
|
-
emit_marker(cinfo, M_SOS);
|
315
|
-
|
316
|
-
emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */
|
317
|
-
|
318
|
-
emit_byte(cinfo, cinfo->comps_in_scan);
|
319
|
-
|
320
|
-
for (i = 0; i < cinfo->comps_in_scan; i++) {
|
321
|
-
compptr = cinfo->cur_comp_info[i];
|
322
|
-
emit_byte(cinfo, compptr->component_id);
|
323
|
-
td = compptr->dc_tbl_no;
|
324
|
-
ta = compptr->ac_tbl_no;
|
325
|
-
if (cinfo->progressive_mode) {
|
326
|
-
/* Progressive mode: only DC or only AC tables are used in one scan;
|
327
|
-
* furthermore, Huffman coding of DC refinement uses no table at all.
|
328
|
-
* We emit 0 for unused field(s); this is recommended by the P&M text
|
329
|
-
* but does not seem to be specified in the standard.
|
330
|
-
*/
|
331
|
-
if (cinfo->Ss == 0) {
|
332
|
-
ta = 0; /* DC scan */
|
333
|
-
if (cinfo->Ah != 0 && !cinfo->arith_code)
|
334
|
-
td = 0; /* no DC table either */
|
335
|
-
} else {
|
336
|
-
td = 0; /* AC scan */
|
337
|
-
}
|
338
|
-
}
|
339
|
-
emit_byte(cinfo, (td << 4) + ta);
|
340
|
-
}
|
341
|
-
|
342
|
-
emit_byte(cinfo, cinfo->Ss);
|
343
|
-
emit_byte(cinfo, cinfo->Se);
|
344
|
-
emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al);
|
345
|
-
}
|
346
|
-
|
347
|
-
|
348
|
-
LOCAL(void)
|
349
|
-
emit_jfif_app0 (j_compress_ptr cinfo)
|
350
|
-
/* Emit a JFIF-compliant APP0 marker */
|
351
|
-
{
|
352
|
-
/*
|
353
|
-
* Length of APP0 block (2 bytes)
|
354
|
-
* Block ID (4 bytes - ASCII "JFIF")
|
355
|
-
* Zero byte (1 byte to terminate the ID string)
|
356
|
-
* Version Major, Minor (2 bytes - major first)
|
357
|
-
* Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm)
|
358
|
-
* Xdpu (2 bytes - dots per unit horizontal)
|
359
|
-
* Ydpu (2 bytes - dots per unit vertical)
|
360
|
-
* Thumbnail X size (1 byte)
|
361
|
-
* Thumbnail Y size (1 byte)
|
362
|
-
*/
|
363
|
-
|
364
|
-
emit_marker(cinfo, M_APP0);
|
365
|
-
|
366
|
-
emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */
|
367
|
-
|
368
|
-
emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */
|
369
|
-
emit_byte(cinfo, 0x46);
|
370
|
-
emit_byte(cinfo, 0x49);
|
371
|
-
emit_byte(cinfo, 0x46);
|
372
|
-
emit_byte(cinfo, 0);
|
373
|
-
emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */
|
374
|
-
emit_byte(cinfo, cinfo->JFIF_minor_version);
|
375
|
-
emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */
|
376
|
-
emit_2bytes(cinfo, (int) cinfo->X_density);
|
377
|
-
emit_2bytes(cinfo, (int) cinfo->Y_density);
|
378
|
-
emit_byte(cinfo, 0); /* No thumbnail image */
|
379
|
-
emit_byte(cinfo, 0);
|
380
|
-
}
|
381
|
-
|
382
|
-
|
383
|
-
LOCAL(void)
|
384
|
-
emit_adobe_app14 (j_compress_ptr cinfo)
|
385
|
-
/* Emit an Adobe APP14 marker */
|
386
|
-
{
|
387
|
-
/*
|
388
|
-
* Length of APP14 block (2 bytes)
|
389
|
-
* Block ID (5 bytes - ASCII "Adobe")
|
390
|
-
* Version Number (2 bytes - currently 100)
|
391
|
-
* Flags0 (2 bytes - currently 0)
|
392
|
-
* Flags1 (2 bytes - currently 0)
|
393
|
-
* Color transform (1 byte)
|
394
|
-
*
|
395
|
-
* Although Adobe TN 5116 mentions Version = 101, all the Adobe files
|
396
|
-
* now in circulation seem to use Version = 100, so that's what we write.
|
397
|
-
*
|
398
|
-
* We write the color transform byte as 1 if the JPEG color space is
|
399
|
-
* YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with
|
400
|
-
* whether the encoder performed a transformation, which is pretty useless.
|
401
|
-
*/
|
402
|
-
|
403
|
-
emit_marker(cinfo, M_APP14);
|
404
|
-
|
405
|
-
emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */
|
406
|
-
|
407
|
-
emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */
|
408
|
-
emit_byte(cinfo, 0x64);
|
409
|
-
emit_byte(cinfo, 0x6F);
|
410
|
-
emit_byte(cinfo, 0x62);
|
411
|
-
emit_byte(cinfo, 0x65);
|
412
|
-
emit_2bytes(cinfo, 100); /* Version */
|
413
|
-
emit_2bytes(cinfo, 0); /* Flags0 */
|
414
|
-
emit_2bytes(cinfo, 0); /* Flags1 */
|
415
|
-
switch (cinfo->jpeg_color_space) {
|
416
|
-
case JCS_YCbCr:
|
417
|
-
emit_byte(cinfo, 1); /* Color transform = 1 */
|
418
|
-
break;
|
419
|
-
case JCS_YCCK:
|
420
|
-
emit_byte(cinfo, 2); /* Color transform = 2 */
|
421
|
-
break;
|
422
|
-
default:
|
423
|
-
emit_byte(cinfo, 0); /* Color transform = 0 */
|
424
|
-
break;
|
425
|
-
}
|
426
|
-
}
|
427
|
-
|
428
|
-
|
429
|
-
/*
|
430
|
-
* These routines allow writing an arbitrary marker with parameters.
|
431
|
-
* The only intended use is to emit COM or APPn markers after calling
|
432
|
-
* write_file_header and before calling write_frame_header.
|
433
|
-
* Other uses are not guaranteed to produce desirable results.
|
434
|
-
* Counting the parameter bytes properly is the caller's responsibility.
|
435
|
-
*/
|
436
|
-
|
437
|
-
METHODDEF(void)
|
438
|
-
write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen)
|
439
|
-
/* Emit an arbitrary marker header */
|
440
|
-
{
|
441
|
-
if (datalen > (unsigned int) 65533) /* safety check */
|
442
|
-
ERREXIT(cinfo, JERR_BAD_LENGTH);
|
443
|
-
|
444
|
-
emit_marker(cinfo, (JPEG_MARKER) marker);
|
445
|
-
|
446
|
-
emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */
|
447
|
-
}
|
448
|
-
|
449
|
-
METHODDEF(void)
|
450
|
-
write_marker_byte (j_compress_ptr cinfo, int val)
|
451
|
-
/* Emit one byte of marker parameters following write_marker_header */
|
452
|
-
{
|
453
|
-
emit_byte(cinfo, val);
|
454
|
-
}
|
455
|
-
|
456
|
-
|
457
|
-
/*
|
458
|
-
* Write datastream header.
|
459
|
-
* This consists of an SOI and optional APPn markers.
|
460
|
-
* We recommend use of the JFIF marker, but not the Adobe marker,
|
461
|
-
* when using YCbCr or grayscale data. The JFIF marker should NOT
|
462
|
-
* be used for any other JPEG colorspace. The Adobe marker is helpful
|
463
|
-
* to distinguish RGB, CMYK, and YCCK colorspaces.
|
464
|
-
* Note that an application can write additional header markers after
|
465
|
-
* jpeg_start_compress returns.
|
466
|
-
*/
|
467
|
-
|
468
|
-
METHODDEF(void)
|
469
|
-
write_file_header (j_compress_ptr cinfo)
|
470
|
-
{
|
471
|
-
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
|
472
|
-
|
473
|
-
emit_marker(cinfo, M_SOI); /* first the SOI */
|
474
|
-
|
475
|
-
/* SOI is defined to reset restart interval to 0 */
|
476
|
-
marker->last_restart_interval = 0;
|
477
|
-
|
478
|
-
if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */
|
479
|
-
emit_jfif_app0(cinfo);
|
480
|
-
if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */
|
481
|
-
emit_adobe_app14(cinfo);
|
482
|
-
}
|
483
|
-
|
484
|
-
|
485
|
-
/*
|
486
|
-
* Write frame header.
|
487
|
-
* This consists of DQT and SOFn markers.
|
488
|
-
* Note that we do not emit the SOF until we have emitted the DQT(s).
|
489
|
-
* This avoids compatibility problems with incorrect implementations that
|
490
|
-
* try to error-check the quant table numbers as soon as they see the SOF.
|
491
|
-
*/
|
492
|
-
|
493
|
-
METHODDEF(void)
|
494
|
-
write_frame_header (j_compress_ptr cinfo)
|
495
|
-
{
|
496
|
-
int ci, prec;
|
497
|
-
boolean is_baseline;
|
498
|
-
jpeg_component_info *compptr;
|
499
|
-
|
500
|
-
/* Emit DQT for each quantization table.
|
501
|
-
* Note that emit_dqt() suppresses any duplicate tables.
|
502
|
-
*/
|
503
|
-
prec = 0;
|
504
|
-
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
505
|
-
ci++, compptr++) {
|
506
|
-
prec += emit_dqt(cinfo, compptr->quant_tbl_no);
|
507
|
-
}
|
508
|
-
/* now prec is nonzero iff there are any 16-bit quant tables. */
|
509
|
-
|
510
|
-
/* Check for a non-baseline specification.
|
511
|
-
* Note we assume that Huffman table numbers won't be changed later.
|
512
|
-
*/
|
513
|
-
if (cinfo->arith_code || cinfo->progressive_mode ||
|
514
|
-
cinfo->data_precision != 8) {
|
515
|
-
is_baseline = FALSE;
|
516
|
-
} else {
|
517
|
-
is_baseline = TRUE;
|
518
|
-
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
|
519
|
-
ci++, compptr++) {
|
520
|
-
if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1)
|
521
|
-
is_baseline = FALSE;
|
522
|
-
}
|
523
|
-
if (prec && is_baseline) {
|
524
|
-
is_baseline = FALSE;
|
525
|
-
/* If it's baseline except for quantizer size, warn the user */
|
526
|
-
TRACEMS(cinfo, 0, JTRC_16BIT_TABLES);
|
527
|
-
}
|
528
|
-
}
|
529
|
-
|
530
|
-
/* Emit the proper SOF marker */
|
531
|
-
if (cinfo->arith_code) {
|
532
|
-
if (cinfo->progressive_mode)
|
533
|
-
emit_sof(cinfo, M_SOF10); /* SOF code for progressive arithmetic */
|
534
|
-
else
|
535
|
-
emit_sof(cinfo, M_SOF9); /* SOF code for sequential arithmetic */
|
536
|
-
} else {
|
537
|
-
if (cinfo->progressive_mode)
|
538
|
-
emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */
|
539
|
-
else if (is_baseline)
|
540
|
-
emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */
|
541
|
-
else
|
542
|
-
emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */
|
543
|
-
}
|
544
|
-
}
|
545
|
-
|
546
|
-
|
547
|
-
/*
|
548
|
-
* Write scan header.
|
549
|
-
* This consists of DHT or DAC markers, optional DRI, and SOS.
|
550
|
-
* Compressed data will be written following the SOS.
|
551
|
-
*/
|
552
|
-
|
553
|
-
METHODDEF(void)
|
554
|
-
write_scan_header (j_compress_ptr cinfo)
|
555
|
-
{
|
556
|
-
my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
|
557
|
-
int i;
|
558
|
-
jpeg_component_info *compptr;
|
559
|
-
|
560
|
-
if (cinfo->arith_code) {
|
561
|
-
/* Emit arith conditioning info. We may have some duplication
|
562
|
-
* if the file has multiple scans, but it's so small it's hardly
|
563
|
-
* worth worrying about.
|
564
|
-
*/
|
565
|
-
emit_dac(cinfo);
|
566
|
-
} else {
|
567
|
-
/* Emit Huffman tables.
|
568
|
-
* Note that emit_dht() suppresses any duplicate tables.
|
569
|
-
*/
|
570
|
-
for (i = 0; i < cinfo->comps_in_scan; i++) {
|
571
|
-
compptr = cinfo->cur_comp_info[i];
|
572
|
-
if (cinfo->progressive_mode) {
|
573
|
-
/* Progressive mode: only DC or only AC tables are used in one scan */
|
574
|
-
if (cinfo->Ss == 0) {
|
575
|
-
if (cinfo->Ah == 0) /* DC needs no table for refinement scan */
|
576
|
-
emit_dht(cinfo, compptr->dc_tbl_no, FALSE);
|
577
|
-
} else {
|
578
|
-
emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
|
579
|
-
}
|
580
|
-
} else {
|
581
|
-
/* Sequential mode: need both DC and AC tables */
|
582
|
-
emit_dht(cinfo, compptr->dc_tbl_no, FALSE);
|
583
|
-
emit_dht(cinfo, compptr->ac_tbl_no, TRUE);
|
584
|
-
}
|
585
|
-
}
|
586
|
-
}
|
587
|
-
|
588
|
-
/* Emit DRI if required --- note that DRI value could change for each scan.
|
589
|
-
* We avoid wasting space with unnecessary DRIs, however.
|
590
|
-
*/
|
591
|
-
if (cinfo->restart_interval != marker->last_restart_interval) {
|
592
|
-
emit_dri(cinfo);
|
593
|
-
marker->last_restart_interval = cinfo->restart_interval;
|
594
|
-
}
|
595
|
-
|
596
|
-
emit_sos(cinfo);
|
597
|
-
}
|
598
|
-
|
599
|
-
|
600
|
-
/*
|
601
|
-
* Write datastream trailer.
|
602
|
-
*/
|
603
|
-
|
604
|
-
METHODDEF(void)
|
605
|
-
write_file_trailer (j_compress_ptr cinfo)
|
606
|
-
{
|
607
|
-
emit_marker(cinfo, M_EOI);
|
608
|
-
}
|
609
|
-
|
610
|
-
|
611
|
-
/*
|
612
|
-
* Write an abbreviated table-specification datastream.
|
613
|
-
* This consists of SOI, DQT and DHT tables, and EOI.
|
614
|
-
* Any table that is defined and not marked sent_table = TRUE will be
|
615
|
-
* emitted. Note that all tables will be marked sent_table = TRUE at exit.
|
616
|
-
*/
|
617
|
-
|
618
|
-
METHODDEF(void)
|
619
|
-
write_tables_only (j_compress_ptr cinfo)
|
620
|
-
{
|
621
|
-
int i;
|
622
|
-
|
623
|
-
emit_marker(cinfo, M_SOI);
|
624
|
-
|
625
|
-
for (i = 0; i < NUM_QUANT_TBLS; i++) {
|
626
|
-
if (cinfo->quant_tbl_ptrs[i] != NULL)
|
627
|
-
(void) emit_dqt(cinfo, i);
|
628
|
-
}
|
629
|
-
|
630
|
-
if (! cinfo->arith_code) {
|
631
|
-
for (i = 0; i < NUM_HUFF_TBLS; i++) {
|
632
|
-
if (cinfo->dc_huff_tbl_ptrs[i] != NULL)
|
633
|
-
emit_dht(cinfo, i, FALSE);
|
634
|
-
if (cinfo->ac_huff_tbl_ptrs[i] != NULL)
|
635
|
-
emit_dht(cinfo, i, TRUE);
|
636
|
-
}
|
637
|
-
}
|
638
|
-
|
639
|
-
emit_marker(cinfo, M_EOI);
|
640
|
-
}
|
641
|
-
|
642
|
-
|
643
|
-
/*
|
644
|
-
* Initialize the marker writer module.
|
645
|
-
*/
|
646
|
-
|
647
|
-
GLOBAL(void)
|
648
|
-
jinit_marker_writer (j_compress_ptr cinfo)
|
649
|
-
{
|
650
|
-
my_marker_ptr marker;
|
651
|
-
|
652
|
-
/* Create the subobject */
|
653
|
-
marker = (my_marker_ptr)
|
654
|
-
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
655
|
-
SIZEOF(my_marker_writer));
|
656
|
-
cinfo->marker = (struct jpeg_marker_writer *) marker;
|
657
|
-
/* Initialize method pointers */
|
658
|
-
marker->pub.write_file_header = write_file_header;
|
659
|
-
marker->pub.write_frame_header = write_frame_header;
|
660
|
-
marker->pub.write_scan_header = write_scan_header;
|
661
|
-
marker->pub.write_file_trailer = write_file_trailer;
|
662
|
-
marker->pub.write_tables_only = write_tables_only;
|
663
|
-
marker->pub.write_marker_header = write_marker_header;
|
664
|
-
marker->pub.write_marker_byte = write_marker_byte;
|
665
|
-
/* Initialize private state */
|
666
|
-
marker->last_restart_interval = 0;
|
667
|
-
}
|