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/jctrans.c
DELETED
|
@@ -1,381 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* jctrans.c
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 1995-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 library routines for transcoding compression,
|
|
9
|
-
* that is, writing raw DCT coefficient arrays to an output JPEG file.
|
|
10
|
-
* The routines in jcapimin.c will also be needed by a transcoder.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
#define JPEG_INTERNALS
|
|
14
|
-
#include "jinclude.h"
|
|
15
|
-
#include "jpeglib.h"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/* Forward declarations */
|
|
19
|
-
LOCAL(void) transencode_master_selection
|
|
20
|
-
JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays));
|
|
21
|
-
LOCAL(void) transencode_coef_controller
|
|
22
|
-
JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays));
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/*
|
|
26
|
-
* Compression initialization for writing raw-coefficient data.
|
|
27
|
-
* Before calling this, all parameters and a data destination must be set up.
|
|
28
|
-
* Call jpeg_finish_compress() to actually write the data.
|
|
29
|
-
*
|
|
30
|
-
* The number of passed virtual arrays must match cinfo->num_components.
|
|
31
|
-
* Note that the virtual arrays need not be filled or even realized at
|
|
32
|
-
* the time write_coefficients is called; indeed, if the virtual arrays
|
|
33
|
-
* were requested from this compression object's memory manager, they
|
|
34
|
-
* typically will be realized during this routine and filled afterwards.
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
GLOBAL(void)
|
|
38
|
-
jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)
|
|
39
|
-
{
|
|
40
|
-
if (cinfo->global_state != CSTATE_START)
|
|
41
|
-
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
|
42
|
-
/* Mark all tables to be written */
|
|
43
|
-
jpeg_suppress_tables(cinfo, FALSE);
|
|
44
|
-
/* (Re)initialize error mgr and destination modules */
|
|
45
|
-
(*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
|
|
46
|
-
(*cinfo->dest->init_destination) (cinfo);
|
|
47
|
-
/* Perform master selection of active modules */
|
|
48
|
-
transencode_master_selection(cinfo, coef_arrays);
|
|
49
|
-
/* Wait for jpeg_finish_compress() call */
|
|
50
|
-
cinfo->next_scanline = 0; /* so jpeg_write_marker works */
|
|
51
|
-
cinfo->global_state = CSTATE_WRCOEFS;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
/*
|
|
56
|
-
* Initialize the compression object with default parameters,
|
|
57
|
-
* then copy from the source object all parameters needed for lossless
|
|
58
|
-
* transcoding. Parameters that can be varied without loss (such as
|
|
59
|
-
* scan script and Huffman optimization) are left in their default states.
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
GLOBAL(void)
|
|
63
|
-
jpeg_copy_critical_parameters (j_decompress_ptr srcinfo,
|
|
64
|
-
j_compress_ptr dstinfo)
|
|
65
|
-
{
|
|
66
|
-
JQUANT_TBL ** qtblptr;
|
|
67
|
-
jpeg_component_info *incomp, *outcomp;
|
|
68
|
-
JQUANT_TBL *c_quant, *slot_quant;
|
|
69
|
-
int tblno, ci, coefi;
|
|
70
|
-
|
|
71
|
-
/* Safety check to ensure start_compress not called yet. */
|
|
72
|
-
if (dstinfo->global_state != CSTATE_START)
|
|
73
|
-
ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state);
|
|
74
|
-
/* Copy fundamental image dimensions */
|
|
75
|
-
dstinfo->image_width = srcinfo->image_width;
|
|
76
|
-
dstinfo->image_height = srcinfo->image_height;
|
|
77
|
-
dstinfo->input_components = srcinfo->num_components;
|
|
78
|
-
dstinfo->in_color_space = srcinfo->jpeg_color_space;
|
|
79
|
-
/* Initialize all parameters to default values */
|
|
80
|
-
jpeg_set_defaults(dstinfo);
|
|
81
|
-
/* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB.
|
|
82
|
-
* Fix it to get the right header markers for the image colorspace.
|
|
83
|
-
*/
|
|
84
|
-
jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space);
|
|
85
|
-
dstinfo->data_precision = srcinfo->data_precision;
|
|
86
|
-
dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling;
|
|
87
|
-
/* Copy the source's quantization tables. */
|
|
88
|
-
for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) {
|
|
89
|
-
if (srcinfo->quant_tbl_ptrs[tblno] != NULL) {
|
|
90
|
-
qtblptr = & dstinfo->quant_tbl_ptrs[tblno];
|
|
91
|
-
if (*qtblptr == NULL)
|
|
92
|
-
*qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo);
|
|
93
|
-
MEMCOPY((*qtblptr)->quantval,
|
|
94
|
-
srcinfo->quant_tbl_ptrs[tblno]->quantval,
|
|
95
|
-
SIZEOF((*qtblptr)->quantval));
|
|
96
|
-
(*qtblptr)->sent_table = FALSE;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
/* Copy the source's per-component info.
|
|
100
|
-
* Note we assume jpeg_set_defaults has allocated the dest comp_info array.
|
|
101
|
-
*/
|
|
102
|
-
dstinfo->num_components = srcinfo->num_components;
|
|
103
|
-
if (dstinfo->num_components < 1 || dstinfo->num_components > MAX_COMPONENTS)
|
|
104
|
-
ERREXIT2(dstinfo, JERR_COMPONENT_COUNT, dstinfo->num_components,
|
|
105
|
-
MAX_COMPONENTS);
|
|
106
|
-
for (ci = 0, incomp = srcinfo->comp_info, outcomp = dstinfo->comp_info;
|
|
107
|
-
ci < dstinfo->num_components; ci++, incomp++, outcomp++) {
|
|
108
|
-
outcomp->component_id = incomp->component_id;
|
|
109
|
-
outcomp->h_samp_factor = incomp->h_samp_factor;
|
|
110
|
-
outcomp->v_samp_factor = incomp->v_samp_factor;
|
|
111
|
-
outcomp->quant_tbl_no = incomp->quant_tbl_no;
|
|
112
|
-
/* Make sure saved quantization table for component matches the qtable
|
|
113
|
-
* slot. If not, the input file re-used this qtable slot.
|
|
114
|
-
* IJG encoder currently cannot duplicate this.
|
|
115
|
-
*/
|
|
116
|
-
tblno = outcomp->quant_tbl_no;
|
|
117
|
-
if (tblno < 0 || tblno >= NUM_QUANT_TBLS ||
|
|
118
|
-
srcinfo->quant_tbl_ptrs[tblno] == NULL)
|
|
119
|
-
ERREXIT1(dstinfo, JERR_NO_QUANT_TABLE, tblno);
|
|
120
|
-
slot_quant = srcinfo->quant_tbl_ptrs[tblno];
|
|
121
|
-
c_quant = incomp->quant_table;
|
|
122
|
-
if (c_quant != NULL) {
|
|
123
|
-
for (coefi = 0; coefi < DCTSIZE2; coefi++) {
|
|
124
|
-
if (c_quant->quantval[coefi] != slot_quant->quantval[coefi])
|
|
125
|
-
ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/* Note: we do not copy the source's Huffman table assignments;
|
|
129
|
-
* instead we rely on jpeg_set_colorspace to have made a suitable choice.
|
|
130
|
-
*/
|
|
131
|
-
}
|
|
132
|
-
/* Also copy JFIF version and resolution information, if available.
|
|
133
|
-
* Strictly speaking this isn't "critical" info, but it's nearly
|
|
134
|
-
* always appropriate to copy it if available. In particular,
|
|
135
|
-
* if the application chooses to copy JFIF 1.02 extension markers from
|
|
136
|
-
* the source file, we need to copy the version to make sure we don't
|
|
137
|
-
* emit a file that has 1.02 extensions but a claimed version of 1.01.
|
|
138
|
-
* We will *not*, however, copy version info from mislabeled "2.01" files.
|
|
139
|
-
*/
|
|
140
|
-
if (srcinfo->saw_JFIF_marker) {
|
|
141
|
-
if (srcinfo->JFIF_major_version == 1) {
|
|
142
|
-
dstinfo->JFIF_major_version = srcinfo->JFIF_major_version;
|
|
143
|
-
dstinfo->JFIF_minor_version = srcinfo->JFIF_minor_version;
|
|
144
|
-
}
|
|
145
|
-
dstinfo->density_unit = srcinfo->density_unit;
|
|
146
|
-
dstinfo->X_density = srcinfo->X_density;
|
|
147
|
-
dstinfo->Y_density = srcinfo->Y_density;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
/*
|
|
153
|
-
* Master selection of compression modules for transcoding.
|
|
154
|
-
* This substitutes for jcinit.c's initialization of the full compressor.
|
|
155
|
-
*/
|
|
156
|
-
|
|
157
|
-
LOCAL(void)
|
|
158
|
-
transencode_master_selection (j_compress_ptr cinfo,
|
|
159
|
-
jvirt_barray_ptr * coef_arrays)
|
|
160
|
-
{
|
|
161
|
-
/* Although we don't actually use input_components for transcoding,
|
|
162
|
-
* jcmaster.c's initial_setup will complain if input_components is 0.
|
|
163
|
-
*/
|
|
164
|
-
cinfo->input_components = 1;
|
|
165
|
-
/* Initialize master control (includes parameter checking/processing) */
|
|
166
|
-
jinit_c_master_control(cinfo, TRUE /* transcode only */);
|
|
167
|
-
|
|
168
|
-
/* Entropy encoding: either Huffman or arithmetic coding. */
|
|
169
|
-
if (cinfo->arith_code) {
|
|
170
|
-
jinit_arith_encoder(cinfo);
|
|
171
|
-
} else {
|
|
172
|
-
jinit_huff_encoder(cinfo);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/* We need a special coefficient buffer controller. */
|
|
176
|
-
transencode_coef_controller(cinfo, coef_arrays);
|
|
177
|
-
|
|
178
|
-
jinit_marker_writer(cinfo);
|
|
179
|
-
|
|
180
|
-
/* We can now tell the memory manager to allocate virtual arrays. */
|
|
181
|
-
(*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);
|
|
182
|
-
|
|
183
|
-
/* Write the datastream header (SOI, JFIF) immediately.
|
|
184
|
-
* Frame and scan headers are postponed till later.
|
|
185
|
-
* This lets application insert special markers after the SOI.
|
|
186
|
-
*/
|
|
187
|
-
(*cinfo->marker->write_file_header) (cinfo);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
/*
|
|
192
|
-
* The rest of this file is a special implementation of the coefficient
|
|
193
|
-
* buffer controller. This is similar to jccoefct.c, but it handles only
|
|
194
|
-
* output from presupplied virtual arrays. Furthermore, we generate any
|
|
195
|
-
* dummy padding blocks on-the-fly rather than expecting them to be present
|
|
196
|
-
* in the arrays.
|
|
197
|
-
*/
|
|
198
|
-
|
|
199
|
-
/* Private buffer controller object */
|
|
200
|
-
|
|
201
|
-
typedef struct {
|
|
202
|
-
struct jpeg_c_coef_controller pub; /* public fields */
|
|
203
|
-
|
|
204
|
-
JDIMENSION iMCU_row_num; /* iMCU row # within image */
|
|
205
|
-
JDIMENSION mcu_ctr; /* counts MCUs processed in current row */
|
|
206
|
-
int MCU_vert_offset; /* counts MCU rows within iMCU row */
|
|
207
|
-
int MCU_rows_per_iMCU_row; /* number of such rows needed */
|
|
208
|
-
|
|
209
|
-
/* Virtual block array for each component. */
|
|
210
|
-
jvirt_barray_ptr * whole_image;
|
|
211
|
-
|
|
212
|
-
/* Workspace for constructing dummy blocks at right/bottom edges. */
|
|
213
|
-
JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU];
|
|
214
|
-
} my_coef_controller;
|
|
215
|
-
|
|
216
|
-
typedef my_coef_controller * my_coef_ptr;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
LOCAL(void)
|
|
220
|
-
start_iMCU_row (j_compress_ptr cinfo)
|
|
221
|
-
/* Reset within-iMCU-row counters for a new row */
|
|
222
|
-
{
|
|
223
|
-
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
|
224
|
-
|
|
225
|
-
/* In an interleaved scan, an MCU row is the same as an iMCU row.
|
|
226
|
-
* In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.
|
|
227
|
-
* But at the bottom of the image, process only what's left.
|
|
228
|
-
*/
|
|
229
|
-
if (cinfo->comps_in_scan > 1) {
|
|
230
|
-
coef->MCU_rows_per_iMCU_row = 1;
|
|
231
|
-
} else {
|
|
232
|
-
if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1))
|
|
233
|
-
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;
|
|
234
|
-
else
|
|
235
|
-
coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
coef->mcu_ctr = 0;
|
|
239
|
-
coef->MCU_vert_offset = 0;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
/*
|
|
244
|
-
* Initialize for a processing pass.
|
|
245
|
-
*/
|
|
246
|
-
|
|
247
|
-
METHODDEF(void)
|
|
248
|
-
start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode)
|
|
249
|
-
{
|
|
250
|
-
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
|
251
|
-
|
|
252
|
-
if (pass_mode != JBUF_CRANK_DEST)
|
|
253
|
-
ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
|
|
254
|
-
|
|
255
|
-
coef->iMCU_row_num = 0;
|
|
256
|
-
start_iMCU_row(cinfo);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
/*
|
|
261
|
-
* Process some data.
|
|
262
|
-
* We process the equivalent of one fully interleaved MCU row ("iMCU" row)
|
|
263
|
-
* per call, ie, v_samp_factor block rows for each component in the scan.
|
|
264
|
-
* The data is obtained from the virtual arrays and fed to the entropy coder.
|
|
265
|
-
* Returns TRUE if the iMCU row is completed, FALSE if suspended.
|
|
266
|
-
*
|
|
267
|
-
* NB: input_buf is ignored; it is likely to be a NULL pointer.
|
|
268
|
-
*/
|
|
269
|
-
|
|
270
|
-
METHODDEF(boolean)
|
|
271
|
-
compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf)
|
|
272
|
-
{
|
|
273
|
-
my_coef_ptr coef = (my_coef_ptr) cinfo->coef;
|
|
274
|
-
JDIMENSION MCU_col_num; /* index of current MCU within row */
|
|
275
|
-
JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
|
|
276
|
-
JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
|
|
277
|
-
int blkn, ci, xindex, yindex, yoffset, blockcnt;
|
|
278
|
-
JDIMENSION start_col;
|
|
279
|
-
JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
|
|
280
|
-
JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU];
|
|
281
|
-
JBLOCKROW buffer_ptr;
|
|
282
|
-
jpeg_component_info *compptr;
|
|
283
|
-
|
|
284
|
-
/* Align the virtual buffers for the components used in this scan. */
|
|
285
|
-
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
|
286
|
-
compptr = cinfo->cur_comp_info[ci];
|
|
287
|
-
buffer[ci] = (*cinfo->mem->access_virt_barray)
|
|
288
|
-
((j_common_ptr) cinfo, coef->whole_image[compptr->component_index],
|
|
289
|
-
coef->iMCU_row_num * compptr->v_samp_factor,
|
|
290
|
-
(JDIMENSION) compptr->v_samp_factor, FALSE);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/* Loop to process one whole iMCU row */
|
|
294
|
-
for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
|
|
295
|
-
yoffset++) {
|
|
296
|
-
for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row;
|
|
297
|
-
MCU_col_num++) {
|
|
298
|
-
/* Construct list of pointers to DCT blocks belonging to this MCU */
|
|
299
|
-
blkn = 0; /* index of current DCT block within MCU */
|
|
300
|
-
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
|
|
301
|
-
compptr = cinfo->cur_comp_info[ci];
|
|
302
|
-
start_col = MCU_col_num * compptr->MCU_width;
|
|
303
|
-
blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width
|
|
304
|
-
: compptr->last_col_width;
|
|
305
|
-
for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
|
|
306
|
-
if (coef->iMCU_row_num < last_iMCU_row ||
|
|
307
|
-
yindex+yoffset < compptr->last_row_height) {
|
|
308
|
-
/* Fill in pointers to real blocks in this row */
|
|
309
|
-
buffer_ptr = buffer[ci][yindex+yoffset] + start_col;
|
|
310
|
-
for (xindex = 0; xindex < blockcnt; xindex++)
|
|
311
|
-
MCU_buffer[blkn++] = buffer_ptr++;
|
|
312
|
-
} else {
|
|
313
|
-
/* At bottom of image, need a whole row of dummy blocks */
|
|
314
|
-
xindex = 0;
|
|
315
|
-
}
|
|
316
|
-
/* Fill in any dummy blocks needed in this row.
|
|
317
|
-
* Dummy blocks are filled in the same way as in jccoefct.c:
|
|
318
|
-
* all zeroes in the AC entries, DC entries equal to previous
|
|
319
|
-
* block's DC value. The init routine has already zeroed the
|
|
320
|
-
* AC entries, so we need only set the DC entries correctly.
|
|
321
|
-
*/
|
|
322
|
-
for (; xindex < compptr->MCU_width; xindex++) {
|
|
323
|
-
MCU_buffer[blkn] = coef->dummy_buffer[blkn];
|
|
324
|
-
MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0];
|
|
325
|
-
blkn++;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
/* Try to write the MCU. */
|
|
330
|
-
if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) {
|
|
331
|
-
/* Suspension forced; update state counters and exit */
|
|
332
|
-
coef->MCU_vert_offset = yoffset;
|
|
333
|
-
coef->mcu_ctr = MCU_col_num;
|
|
334
|
-
return FALSE;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
/* Completed an MCU row, but perhaps not an iMCU row */
|
|
338
|
-
coef->mcu_ctr = 0;
|
|
339
|
-
}
|
|
340
|
-
/* Completed the iMCU row, advance counters for next one */
|
|
341
|
-
coef->iMCU_row_num++;
|
|
342
|
-
start_iMCU_row(cinfo);
|
|
343
|
-
return TRUE;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
/*
|
|
348
|
-
* Initialize coefficient buffer controller.
|
|
349
|
-
*
|
|
350
|
-
* Each passed coefficient array must be the right size for that
|
|
351
|
-
* coefficient: width_in_blocks wide and height_in_blocks high,
|
|
352
|
-
* with unitheight at least v_samp_factor.
|
|
353
|
-
*/
|
|
354
|
-
|
|
355
|
-
LOCAL(void)
|
|
356
|
-
transencode_coef_controller (j_compress_ptr cinfo,
|
|
357
|
-
jvirt_barray_ptr * coef_arrays)
|
|
358
|
-
{
|
|
359
|
-
my_coef_ptr coef;
|
|
360
|
-
JBLOCKROW buffer;
|
|
361
|
-
int i;
|
|
362
|
-
|
|
363
|
-
coef = (my_coef_ptr)
|
|
364
|
-
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
|
365
|
-
SIZEOF(my_coef_controller));
|
|
366
|
-
cinfo->coef = (struct jpeg_c_coef_controller *) coef;
|
|
367
|
-
coef->pub.start_pass = start_pass_coef;
|
|
368
|
-
coef->pub.compress_data = compress_output;
|
|
369
|
-
|
|
370
|
-
/* Save pointer to virtual arrays */
|
|
371
|
-
coef->whole_image = coef_arrays;
|
|
372
|
-
|
|
373
|
-
/* Allocate and pre-zero space for dummy DCT blocks. */
|
|
374
|
-
buffer = (JBLOCKROW)
|
|
375
|
-
(*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
|
376
|
-
C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
|
|
377
|
-
jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));
|
|
378
|
-
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
|
|
379
|
-
coef->dummy_buffer[i] = buffer + i;
|
|
380
|
-
}
|
|
381
|
-
}
|
data/src/jpeg-7/jdapimin.c
DELETED
|
@@ -1,396 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* jdapimin.c
|
|
3
|
-
*
|
|
4
|
-
* Copyright (C) 1994-1998, Thomas G. Lane.
|
|
5
|
-
* Modified 2009 by Guido Vollbeding.
|
|
6
|
-
* This file is part of the Independent JPEG Group's software.
|
|
7
|
-
* For conditions of distribution and use, see the accompanying README file.
|
|
8
|
-
*
|
|
9
|
-
* This file contains application interface code for the decompression half
|
|
10
|
-
* of the JPEG library. These are the "minimum" API routines that may be
|
|
11
|
-
* needed in either the normal full-decompression case or the
|
|
12
|
-
* transcoding-only case.
|
|
13
|
-
*
|
|
14
|
-
* Most of the routines intended to be called directly by an application
|
|
15
|
-
* are in this file or in jdapistd.c. But also see jcomapi.c for routines
|
|
16
|
-
* shared by compression and decompression, and jdtrans.c for the transcoding
|
|
17
|
-
* case.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
#define JPEG_INTERNALS
|
|
21
|
-
#include "jinclude.h"
|
|
22
|
-
#include "jpeglib.h"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/*
|
|
26
|
-
* Initialization of a JPEG decompression object.
|
|
27
|
-
* The error manager must already be set up (in case memory manager fails).
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
GLOBAL(void)
|
|
31
|
-
jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize)
|
|
32
|
-
{
|
|
33
|
-
int i;
|
|
34
|
-
|
|
35
|
-
/* Guard against version mismatches between library and caller. */
|
|
36
|
-
cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */
|
|
37
|
-
if (version != JPEG_LIB_VERSION)
|
|
38
|
-
ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version);
|
|
39
|
-
if (structsize != SIZEOF(struct jpeg_decompress_struct))
|
|
40
|
-
ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE,
|
|
41
|
-
(int) SIZEOF(struct jpeg_decompress_struct), (int) structsize);
|
|
42
|
-
|
|
43
|
-
/* For debugging purposes, we zero the whole master structure.
|
|
44
|
-
* But the application has already set the err pointer, and may have set
|
|
45
|
-
* client_data, so we have to save and restore those fields.
|
|
46
|
-
* Note: if application hasn't set client_data, tools like Purify may
|
|
47
|
-
* complain here.
|
|
48
|
-
*/
|
|
49
|
-
{
|
|
50
|
-
struct jpeg_error_mgr * err = cinfo->err;
|
|
51
|
-
void * client_data = cinfo->client_data; /* ignore Purify complaint here */
|
|
52
|
-
MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct));
|
|
53
|
-
cinfo->err = err;
|
|
54
|
-
cinfo->client_data = client_data;
|
|
55
|
-
}
|
|
56
|
-
cinfo->is_decompressor = TRUE;
|
|
57
|
-
|
|
58
|
-
/* Initialize a memory manager instance for this object */
|
|
59
|
-
jinit_memory_mgr((j_common_ptr) cinfo);
|
|
60
|
-
|
|
61
|
-
/* Zero out pointers to permanent structures. */
|
|
62
|
-
cinfo->progress = NULL;
|
|
63
|
-
cinfo->src = NULL;
|
|
64
|
-
|
|
65
|
-
for (i = 0; i < NUM_QUANT_TBLS; i++)
|
|
66
|
-
cinfo->quant_tbl_ptrs[i] = NULL;
|
|
67
|
-
|
|
68
|
-
for (i = 0; i < NUM_HUFF_TBLS; i++) {
|
|
69
|
-
cinfo->dc_huff_tbl_ptrs[i] = NULL;
|
|
70
|
-
cinfo->ac_huff_tbl_ptrs[i] = NULL;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/* Initialize marker processor so application can override methods
|
|
74
|
-
* for COM, APPn markers before calling jpeg_read_header.
|
|
75
|
-
*/
|
|
76
|
-
cinfo->marker_list = NULL;
|
|
77
|
-
jinit_marker_reader(cinfo);
|
|
78
|
-
|
|
79
|
-
/* And initialize the overall input controller. */
|
|
80
|
-
jinit_input_controller(cinfo);
|
|
81
|
-
|
|
82
|
-
/* OK, I'm ready */
|
|
83
|
-
cinfo->global_state = DSTATE_START;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
/*
|
|
88
|
-
* Destruction of a JPEG decompression object
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
GLOBAL(void)
|
|
92
|
-
jpeg_destroy_decompress (j_decompress_ptr cinfo)
|
|
93
|
-
{
|
|
94
|
-
jpeg_destroy((j_common_ptr) cinfo); /* use common routine */
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
/*
|
|
99
|
-
* Abort processing of a JPEG decompression operation,
|
|
100
|
-
* but don't destroy the object itself.
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
GLOBAL(void)
|
|
104
|
-
jpeg_abort_decompress (j_decompress_ptr cinfo)
|
|
105
|
-
{
|
|
106
|
-
jpeg_abort((j_common_ptr) cinfo); /* use common routine */
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
/*
|
|
111
|
-
* Set default decompression parameters.
|
|
112
|
-
*/
|
|
113
|
-
|
|
114
|
-
LOCAL(void)
|
|
115
|
-
default_decompress_parms (j_decompress_ptr cinfo)
|
|
116
|
-
{
|
|
117
|
-
/* Guess the input colorspace, and set output colorspace accordingly. */
|
|
118
|
-
/* (Wish JPEG committee had provided a real way to specify this...) */
|
|
119
|
-
/* Note application may override our guesses. */
|
|
120
|
-
switch (cinfo->num_components) {
|
|
121
|
-
case 1:
|
|
122
|
-
cinfo->jpeg_color_space = JCS_GRAYSCALE;
|
|
123
|
-
cinfo->out_color_space = JCS_GRAYSCALE;
|
|
124
|
-
break;
|
|
125
|
-
|
|
126
|
-
case 3:
|
|
127
|
-
if (cinfo->saw_JFIF_marker) {
|
|
128
|
-
cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */
|
|
129
|
-
} else if (cinfo->saw_Adobe_marker) {
|
|
130
|
-
switch (cinfo->Adobe_transform) {
|
|
131
|
-
case 0:
|
|
132
|
-
cinfo->jpeg_color_space = JCS_RGB;
|
|
133
|
-
break;
|
|
134
|
-
case 1:
|
|
135
|
-
cinfo->jpeg_color_space = JCS_YCbCr;
|
|
136
|
-
break;
|
|
137
|
-
default:
|
|
138
|
-
WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
|
|
139
|
-
cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
143
|
-
/* Saw no special markers, try to guess from the component IDs */
|
|
144
|
-
int cid0 = cinfo->comp_info[0].component_id;
|
|
145
|
-
int cid1 = cinfo->comp_info[1].component_id;
|
|
146
|
-
int cid2 = cinfo->comp_info[2].component_id;
|
|
147
|
-
|
|
148
|
-
if (cid0 == 1 && cid1 == 2 && cid2 == 3)
|
|
149
|
-
cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */
|
|
150
|
-
else if (cid0 == 82 && cid1 == 71 && cid2 == 66)
|
|
151
|
-
cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */
|
|
152
|
-
else {
|
|
153
|
-
TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2);
|
|
154
|
-
cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
/* Always guess RGB is proper output colorspace. */
|
|
158
|
-
cinfo->out_color_space = JCS_RGB;
|
|
159
|
-
break;
|
|
160
|
-
|
|
161
|
-
case 4:
|
|
162
|
-
if (cinfo->saw_Adobe_marker) {
|
|
163
|
-
switch (cinfo->Adobe_transform) {
|
|
164
|
-
case 0:
|
|
165
|
-
cinfo->jpeg_color_space = JCS_CMYK;
|
|
166
|
-
break;
|
|
167
|
-
case 2:
|
|
168
|
-
cinfo->jpeg_color_space = JCS_YCCK;
|
|
169
|
-
break;
|
|
170
|
-
default:
|
|
171
|
-
WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform);
|
|
172
|
-
cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */
|
|
173
|
-
break;
|
|
174
|
-
}
|
|
175
|
-
} else {
|
|
176
|
-
/* No special markers, assume straight CMYK. */
|
|
177
|
-
cinfo->jpeg_color_space = JCS_CMYK;
|
|
178
|
-
}
|
|
179
|
-
cinfo->out_color_space = JCS_CMYK;
|
|
180
|
-
break;
|
|
181
|
-
|
|
182
|
-
default:
|
|
183
|
-
cinfo->jpeg_color_space = JCS_UNKNOWN;
|
|
184
|
-
cinfo->out_color_space = JCS_UNKNOWN;
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/* Set defaults for other decompression parameters. */
|
|
189
|
-
cinfo->scale_num = DCTSIZE; /* 1:1 scaling */
|
|
190
|
-
cinfo->scale_denom = DCTSIZE;
|
|
191
|
-
cinfo->output_gamma = 1.0;
|
|
192
|
-
cinfo->buffered_image = FALSE;
|
|
193
|
-
cinfo->raw_data_out = FALSE;
|
|
194
|
-
cinfo->dct_method = JDCT_DEFAULT;
|
|
195
|
-
cinfo->do_fancy_upsampling = TRUE;
|
|
196
|
-
cinfo->do_block_smoothing = TRUE;
|
|
197
|
-
cinfo->quantize_colors = FALSE;
|
|
198
|
-
/* We set these in case application only sets quantize_colors. */
|
|
199
|
-
cinfo->dither_mode = JDITHER_FS;
|
|
200
|
-
#ifdef QUANT_2PASS_SUPPORTED
|
|
201
|
-
cinfo->two_pass_quantize = TRUE;
|
|
202
|
-
#else
|
|
203
|
-
cinfo->two_pass_quantize = FALSE;
|
|
204
|
-
#endif
|
|
205
|
-
cinfo->desired_number_of_colors = 256;
|
|
206
|
-
cinfo->colormap = NULL;
|
|
207
|
-
/* Initialize for no mode change in buffered-image mode. */
|
|
208
|
-
cinfo->enable_1pass_quant = FALSE;
|
|
209
|
-
cinfo->enable_external_quant = FALSE;
|
|
210
|
-
cinfo->enable_2pass_quant = FALSE;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
/*
|
|
215
|
-
* Decompression startup: read start of JPEG datastream to see what's there.
|
|
216
|
-
* Need only initialize JPEG object and supply a data source before calling.
|
|
217
|
-
*
|
|
218
|
-
* This routine will read as far as the first SOS marker (ie, actual start of
|
|
219
|
-
* compressed data), and will save all tables and parameters in the JPEG
|
|
220
|
-
* object. It will also initialize the decompression parameters to default
|
|
221
|
-
* values, and finally return JPEG_HEADER_OK. On return, the application may
|
|
222
|
-
* adjust the decompression parameters and then call jpeg_start_decompress.
|
|
223
|
-
* (Or, if the application only wanted to determine the image parameters,
|
|
224
|
-
* the data need not be decompressed. In that case, call jpeg_abort or
|
|
225
|
-
* jpeg_destroy to release any temporary space.)
|
|
226
|
-
* If an abbreviated (tables only) datastream is presented, the routine will
|
|
227
|
-
* return JPEG_HEADER_TABLES_ONLY upon reaching EOI. The application may then
|
|
228
|
-
* re-use the JPEG object to read the abbreviated image datastream(s).
|
|
229
|
-
* It is unnecessary (but OK) to call jpeg_abort in this case.
|
|
230
|
-
* The JPEG_SUSPENDED return code only occurs if the data source module
|
|
231
|
-
* requests suspension of the decompressor. In this case the application
|
|
232
|
-
* should load more source data and then re-call jpeg_read_header to resume
|
|
233
|
-
* processing.
|
|
234
|
-
* If a non-suspending data source is used and require_image is TRUE, then the
|
|
235
|
-
* return code need not be inspected since only JPEG_HEADER_OK is possible.
|
|
236
|
-
*
|
|
237
|
-
* This routine is now just a front end to jpeg_consume_input, with some
|
|
238
|
-
* extra error checking.
|
|
239
|
-
*/
|
|
240
|
-
|
|
241
|
-
GLOBAL(int)
|
|
242
|
-
jpeg_read_header (j_decompress_ptr cinfo, boolean require_image)
|
|
243
|
-
{
|
|
244
|
-
int retcode;
|
|
245
|
-
|
|
246
|
-
if (cinfo->global_state != DSTATE_START &&
|
|
247
|
-
cinfo->global_state != DSTATE_INHEADER)
|
|
248
|
-
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
|
249
|
-
|
|
250
|
-
retcode = jpeg_consume_input(cinfo);
|
|
251
|
-
|
|
252
|
-
switch (retcode) {
|
|
253
|
-
case JPEG_REACHED_SOS:
|
|
254
|
-
retcode = JPEG_HEADER_OK;
|
|
255
|
-
break;
|
|
256
|
-
case JPEG_REACHED_EOI:
|
|
257
|
-
if (require_image) /* Complain if application wanted an image */
|
|
258
|
-
ERREXIT(cinfo, JERR_NO_IMAGE);
|
|
259
|
-
/* Reset to start state; it would be safer to require the application to
|
|
260
|
-
* call jpeg_abort, but we can't change it now for compatibility reasons.
|
|
261
|
-
* A side effect is to free any temporary memory (there shouldn't be any).
|
|
262
|
-
*/
|
|
263
|
-
jpeg_abort((j_common_ptr) cinfo); /* sets state = DSTATE_START */
|
|
264
|
-
retcode = JPEG_HEADER_TABLES_ONLY;
|
|
265
|
-
break;
|
|
266
|
-
case JPEG_SUSPENDED:
|
|
267
|
-
/* no work */
|
|
268
|
-
break;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
return retcode;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
/*
|
|
276
|
-
* Consume data in advance of what the decompressor requires.
|
|
277
|
-
* This can be called at any time once the decompressor object has
|
|
278
|
-
* been created and a data source has been set up.
|
|
279
|
-
*
|
|
280
|
-
* This routine is essentially a state machine that handles a couple
|
|
281
|
-
* of critical state-transition actions, namely initial setup and
|
|
282
|
-
* transition from header scanning to ready-for-start_decompress.
|
|
283
|
-
* All the actual input is done via the input controller's consume_input
|
|
284
|
-
* method.
|
|
285
|
-
*/
|
|
286
|
-
|
|
287
|
-
GLOBAL(int)
|
|
288
|
-
jpeg_consume_input (j_decompress_ptr cinfo)
|
|
289
|
-
{
|
|
290
|
-
int retcode = JPEG_SUSPENDED;
|
|
291
|
-
|
|
292
|
-
/* NB: every possible DSTATE value should be listed in this switch */
|
|
293
|
-
switch (cinfo->global_state) {
|
|
294
|
-
case DSTATE_START:
|
|
295
|
-
/* Start-of-datastream actions: reset appropriate modules */
|
|
296
|
-
(*cinfo->inputctl->reset_input_controller) (cinfo);
|
|
297
|
-
/* Initialize application's data source module */
|
|
298
|
-
(*cinfo->src->init_source) (cinfo);
|
|
299
|
-
cinfo->global_state = DSTATE_INHEADER;
|
|
300
|
-
/*FALLTHROUGH*/
|
|
301
|
-
case DSTATE_INHEADER:
|
|
302
|
-
retcode = (*cinfo->inputctl->consume_input) (cinfo);
|
|
303
|
-
if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */
|
|
304
|
-
/* Set up default parameters based on header data */
|
|
305
|
-
default_decompress_parms(cinfo);
|
|
306
|
-
/* Set global state: ready for start_decompress */
|
|
307
|
-
cinfo->global_state = DSTATE_READY;
|
|
308
|
-
}
|
|
309
|
-
break;
|
|
310
|
-
case DSTATE_READY:
|
|
311
|
-
/* Can't advance past first SOS until start_decompress is called */
|
|
312
|
-
retcode = JPEG_REACHED_SOS;
|
|
313
|
-
break;
|
|
314
|
-
case DSTATE_PRELOAD:
|
|
315
|
-
case DSTATE_PRESCAN:
|
|
316
|
-
case DSTATE_SCANNING:
|
|
317
|
-
case DSTATE_RAW_OK:
|
|
318
|
-
case DSTATE_BUFIMAGE:
|
|
319
|
-
case DSTATE_BUFPOST:
|
|
320
|
-
case DSTATE_STOPPING:
|
|
321
|
-
retcode = (*cinfo->inputctl->consume_input) (cinfo);
|
|
322
|
-
break;
|
|
323
|
-
default:
|
|
324
|
-
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
|
325
|
-
}
|
|
326
|
-
return retcode;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
/*
|
|
331
|
-
* Have we finished reading the input file?
|
|
332
|
-
*/
|
|
333
|
-
|
|
334
|
-
GLOBAL(boolean)
|
|
335
|
-
jpeg_input_complete (j_decompress_ptr cinfo)
|
|
336
|
-
{
|
|
337
|
-
/* Check for valid jpeg object */
|
|
338
|
-
if (cinfo->global_state < DSTATE_START ||
|
|
339
|
-
cinfo->global_state > DSTATE_STOPPING)
|
|
340
|
-
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
|
341
|
-
return cinfo->inputctl->eoi_reached;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
/*
|
|
346
|
-
* Is there more than one scan?
|
|
347
|
-
*/
|
|
348
|
-
|
|
349
|
-
GLOBAL(boolean)
|
|
350
|
-
jpeg_has_multiple_scans (j_decompress_ptr cinfo)
|
|
351
|
-
{
|
|
352
|
-
/* Only valid after jpeg_read_header completes */
|
|
353
|
-
if (cinfo->global_state < DSTATE_READY ||
|
|
354
|
-
cinfo->global_state > DSTATE_STOPPING)
|
|
355
|
-
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
|
356
|
-
return cinfo->inputctl->has_multiple_scans;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
/*
|
|
361
|
-
* Finish JPEG decompression.
|
|
362
|
-
*
|
|
363
|
-
* This will normally just verify the file trailer and release temp storage.
|
|
364
|
-
*
|
|
365
|
-
* Returns FALSE if suspended. The return value need be inspected only if
|
|
366
|
-
* a suspending data source is used.
|
|
367
|
-
*/
|
|
368
|
-
|
|
369
|
-
GLOBAL(boolean)
|
|
370
|
-
jpeg_finish_decompress (j_decompress_ptr cinfo)
|
|
371
|
-
{
|
|
372
|
-
if ((cinfo->global_state == DSTATE_SCANNING ||
|
|
373
|
-
cinfo->global_state == DSTATE_RAW_OK) && ! cinfo->buffered_image) {
|
|
374
|
-
/* Terminate final pass of non-buffered mode */
|
|
375
|
-
if (cinfo->output_scanline < cinfo->output_height)
|
|
376
|
-
ERREXIT(cinfo, JERR_TOO_LITTLE_DATA);
|
|
377
|
-
(*cinfo->master->finish_output_pass) (cinfo);
|
|
378
|
-
cinfo->global_state = DSTATE_STOPPING;
|
|
379
|
-
} else if (cinfo->global_state == DSTATE_BUFIMAGE) {
|
|
380
|
-
/* Finishing after a buffered-image operation */
|
|
381
|
-
cinfo->global_state = DSTATE_STOPPING;
|
|
382
|
-
} else if (cinfo->global_state != DSTATE_STOPPING) {
|
|
383
|
-
/* STOPPING = repeat call after a suspension, anything else is error */
|
|
384
|
-
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
|
|
385
|
-
}
|
|
386
|
-
/* Read until EOI */
|
|
387
|
-
while (! cinfo->inputctl->eoi_reached) {
|
|
388
|
-
if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
|
|
389
|
-
return FALSE; /* Suspend, come back later */
|
|
390
|
-
}
|
|
391
|
-
/* Do final cleanup */
|
|
392
|
-
(*cinfo->src->term_source) (cinfo);
|
|
393
|
-
/* We can use jpeg_abort to release memory and reset global_state */
|
|
394
|
-
jpeg_abort((j_common_ptr) cinfo);
|
|
395
|
-
return TRUE;
|
|
396
|
-
}
|