]>
Commit | Line | Data |
---|---|---|
b47c832e RR |
1 | /* $Header$ */ |
2 | ||
3 | /* | |
4 | * Copyright (c) 1988-1997 Sam Leffler | |
5 | * Copyright (c) 1991-1997 Silicon Graphics, Inc. | |
6 | * | |
94fbea12 | 7 | * Permission to use, copy, modify, distribute, and sell this software and |
b47c832e RR |
8 | * its documentation for any purpose is hereby granted without fee, provided |
9 | * that (i) the above copyright notices and this permission notice appear in | |
10 | * all copies of the software and related documentation, and (ii) the names of | |
11 | * Sam Leffler and Silicon Graphics may not be used in any advertising or | |
12 | * publicity relating to the software without the specific, prior written | |
13 | * permission of Sam Leffler and Silicon Graphics. | |
94fbea12 DW |
14 | * |
15 | * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, | |
16 | * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY | |
17 | * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. | |
18 | * | |
b47c832e RR |
19 | * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR |
20 | * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, | |
21 | * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |
94fbea12 DW |
22 | * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF |
23 | * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE | |
b47c832e RR |
24 | * OF THIS SOFTWARE. |
25 | */ | |
26 | ||
27 | #ifndef _TIFFIOP_ | |
28 | #define _TIFFIOP_ | |
29 | /* | |
30 | * ``Library-private'' definitions. | |
31 | */ | |
32 | /* | |
33 | * UNIX systems should run the configure script to generate | |
34 | * a port.h file that reflects the system capabilities. | |
35 | * Doing this obviates all the dreck done in tiffcomp.h. | |
36 | */ | |
37 | #if defined(unix) || defined(__unix) | |
38 | #include "port.h" | |
39 | #include "tiffconf.h" | |
40 | #else | |
41 | #include "tiffconf.h" | |
42 | #include "tiffcomp.h" | |
43 | #endif | |
44 | #include "tiffio.h" | |
45 | #include "tif_dir.h" | |
46 | ||
47 | #ifndef TRUE | |
48 | #define TRUE 1 | |
49 | #define FALSE 0 | |
50 | #endif | |
51 | ||
52 | /* | |
53 | * Typedefs for ``method pointers'' used internally. | |
54 | */ | |
55 | typedef unsigned char tidataval_t; /* internal image data value type */ | |
56 | typedef tidataval_t* tidata_t; /* reference to internal image data */ | |
57 | ||
58 | typedef void (*TIFFVoidMethod)(TIFF*); | |
59 | typedef int (*TIFFBoolMethod)(TIFF*); | |
60 | typedef int (*TIFFPreMethod)(TIFF*, tsample_t); | |
94fbea12 DW |
61 | typedef int (LINKAGEMODE *TIFFCodeMethod)(TIFF*, tidata_t, tsize_t, tsample_t); |
62 | typedef int (LINKAGEMODE *TIFFSeekMethod)(TIFF*, uint32); | |
63 | typedef void (LINKAGEMODE *TIFFPostMethod)(TIFF*, tidata_t, tsize_t); | |
b47c832e RR |
64 | typedef int (*TIFFVSetMethod)(TIFF*, ttag_t, va_list); |
65 | typedef int (*TIFFVGetMethod)(TIFF*, ttag_t, va_list); | |
94fbea12 DW |
66 | typedef void (LINKAGEMODE *TIFFPrintMethod)(TIFF*, FILE*, long); |
67 | typedef uint32 (LINKAGEMODE *TIFFStripMethod)(TIFF*, uint32); | |
68 | typedef void (LINKAGEMODE *TIFFTileMethod)(TIFF*, uint32*, uint32*); | |
b47c832e RR |
69 | |
70 | struct tiff { | |
71 | char* tif_name; /* name of open file */ | |
72 | int tif_fd; /* open file descriptor */ | |
73 | int tif_mode; /* open mode (O_*) */ | |
74 | uint32 tif_flags; | |
75 | #define TIFF_FILLORDER 0x0003 /* natural bit fill order for machine */ | |
76 | #define TIFF_DIRTYHEADER 0x0004 /* header must be written on close */ | |
77 | #define TIFF_DIRTYDIRECT 0x0008 /* current directory must be written */ | |
78 | #define TIFF_BUFFERSETUP 0x0010 /* data buffers setup */ | |
79 | #define TIFF_CODERSETUP 0x0020 /* encoder/decoder setup done */ | |
80 | #define TIFF_BEENWRITING 0x0040 /* written 1+ scanlines to file */ | |
81 | #define TIFF_SWAB 0x0080 /* byte swap file information */ | |
82 | #define TIFF_NOBITREV 0x0100 /* inhibit bit reversal logic */ | |
83 | #define TIFF_MYBUFFER 0x0200 /* my raw data buffer; free on close */ | |
84 | #define TIFF_ISTILED 0x0400 /* file is tile, not strip- based */ | |
85 | #define TIFF_MAPPED 0x0800 /* file is mapped into memory */ | |
86 | #define TIFF_POSTENCODE 0x1000 /* need call to postencode routine */ | |
87 | #define TIFF_INSUBIFD 0x2000 /* currently writing a subifd */ | |
94fbea12 | 88 | #define TIFF_UPSAMPLED 0x4000 /* library is doing data up-sampling */ |
b47c832e RR |
89 | #define TIFF_STRIPCHOP 0x8000 /* enable strip chopping support */ |
90 | toff_t tif_diroff; /* file offset of current directory */ | |
91 | toff_t tif_nextdiroff; /* file offset of following directory */ | |
92 | TIFFDirectory tif_dir; /* internal rep of current directory */ | |
93 | TIFFHeader tif_header; /* file's header block */ | |
94 | tidata_t tif_clientdir; /* client TIFF directory */ | |
95 | const int* tif_typeshift; /* data type shift counts */ | |
96 | const long* tif_typemask; /* data type masks */ | |
97 | uint32 tif_row; /* current scanline */ | |
98 | tdir_t tif_curdir; /* current directory (index) */ | |
99 | tstrip_t tif_curstrip; /* current strip for read/write */ | |
100 | toff_t tif_curoff; /* current offset for read/write */ | |
101 | toff_t tif_dataoff; /* current offset for writing dir */ | |
102 | #if SUBIFD_SUPPORT | |
103 | uint16 tif_nsubifd; /* remaining subifds to write */ | |
104 | toff_t tif_subifdoff; /* offset for patching SubIFD link */ | |
105 | #endif | |
106 | /* tiling support */ | |
107 | uint32 tif_col; /* current column (offset by row too) */ | |
108 | ttile_t tif_curtile; /* current tile for read/write */ | |
109 | tsize_t tif_tilesize; /* # of bytes in a tile */ | |
110 | /* compression scheme hooks */ | |
111 | TIFFBoolMethod tif_setupdecode;/* called once before predecode */ | |
112 | TIFFPreMethod tif_predecode; /* pre- row/strip/tile decoding */ | |
113 | TIFFBoolMethod tif_setupencode;/* called once before preencode */ | |
114 | TIFFPreMethod tif_preencode; /* pre- row/strip/tile encoding */ | |
115 | TIFFBoolMethod tif_postencode; /* post- row/strip/tile encoding */ | |
116 | TIFFCodeMethod tif_decoderow; /* scanline decoding routine */ | |
117 | TIFFCodeMethod tif_encoderow; /* scanline encoding routine */ | |
118 | TIFFCodeMethod tif_decodestrip;/* strip decoding routine */ | |
119 | TIFFCodeMethod tif_encodestrip;/* strip encoding routine */ | |
120 | TIFFCodeMethod tif_decodetile; /* tile decoding routine */ | |
121 | TIFFCodeMethod tif_encodetile; /* tile encoding routine */ | |
122 | TIFFVoidMethod tif_close; /* cleanup-on-close routine */ | |
123 | TIFFSeekMethod tif_seek; /* position within a strip routine */ | |
124 | TIFFVoidMethod tif_cleanup; /* cleanup state routine */ | |
125 | TIFFStripMethod tif_defstripsize;/* calculate/constrain strip size */ | |
126 | TIFFTileMethod tif_deftilesize;/* calculate/constrain tile size */ | |
127 | tidata_t tif_data; /* compression scheme private data */ | |
128 | /* input/output buffering */ | |
129 | tsize_t tif_scanlinesize;/* # of bytes in a scanline */ | |
130 | tsize_t tif_scanlineskew;/* scanline skew for reading strips */ | |
131 | tidata_t tif_rawdata; /* raw data buffer */ | |
132 | tsize_t tif_rawdatasize;/* # of bytes in raw data buffer */ | |
133 | tidata_t tif_rawcp; /* current spot in raw buffer */ | |
134 | tsize_t tif_rawcc; /* bytes unread from raw buffer */ | |
135 | /* memory-mapped file support */ | |
136 | tidata_t tif_base; /* base of mapped file */ | |
137 | toff_t tif_size; /* size of mapped file region (bytes) */ | |
138 | TIFFMapFileProc tif_mapproc; /* map file method */ | |
139 | TIFFUnmapFileProc tif_unmapproc;/* unmap file method */ | |
140 | /* input/output callback methods */ | |
141 | thandle_t tif_clientdata; /* callback parameter */ | |
142 | TIFFReadWriteProc tif_readproc; /* read method */ | |
143 | TIFFReadWriteProc tif_writeproc;/* write method */ | |
144 | TIFFSeekProc tif_seekproc; /* lseek method */ | |
145 | TIFFCloseProc tif_closeproc; /* close method */ | |
146 | TIFFSizeProc tif_sizeproc; /* filesize method */ | |
147 | /* post-decoding support */ | |
148 | TIFFPostMethod tif_postdecode; /* post decoding routine */ | |
149 | /* tag support */ | |
150 | TIFFFieldInfo** tif_fieldinfo; /* sorted table of registered tags */ | |
151 | int tif_nfields; /* # entries in registered tag table */ | |
152 | TIFFVSetMethod tif_vsetfield; /* tag set routine */ | |
153 | TIFFVGetMethod tif_vgetfield; /* tag get routine */ | |
154 | TIFFPrintMethod tif_printdir; /* directory print routine */ | |
155 | }; | |
156 | ||
157 | #define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */ | |
158 | ||
159 | #define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0) | |
160 | #define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0) | |
161 | #define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0) | |
162 | #define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0) | |
163 | #define TIFFReadFile(tif, buf, size) \ | |
164 | ((*(tif)->tif_readproc)((tif)->tif_clientdata,buf,size)) | |
165 | #define TIFFWriteFile(tif, buf, size) \ | |
166 | ((*(tif)->tif_writeproc)((tif)->tif_clientdata,buf,size)) | |
167 | #define TIFFSeekFile(tif, off, whence) \ | |
168 | ((*(tif)->tif_seekproc)((tif)->tif_clientdata,(toff_t)(off),whence)) | |
169 | #define TIFFCloseFile(tif) \ | |
170 | ((*(tif)->tif_closeproc)((tif)->tif_clientdata)) | |
171 | #define TIFFGetFileSize(tif) \ | |
172 | ((*(tif)->tif_sizeproc)((tif)->tif_clientdata)) | |
173 | #define TIFFMapFileContents(tif, paddr, psize) \ | |
174 | ((*(tif)->tif_mapproc)((tif)->tif_clientdata,paddr,psize)) | |
175 | #define TIFFUnmapFileContents(tif, addr, size) \ | |
176 | ((*(tif)->tif_unmapproc)((tif)->tif_clientdata,addr,size)) | |
177 | ||
178 | /* | |
179 | * Default Read/Seek/Write definitions. | |
180 | */ | |
181 | #ifndef ReadOK | |
182 | #define ReadOK(tif, buf, size) \ | |
183 | (TIFFReadFile(tif, (tdata_t) buf, (tsize_t) size) == (tsize_t) size) | |
184 | #endif | |
185 | #ifndef SeekOK | |
186 | #define SeekOK(tif, off) \ | |
187 | (TIFFSeekFile(tif, (toff_t) off, SEEK_SET) == (toff_t) off) | |
188 | #endif | |
189 | #ifndef WriteOK | |
190 | #define WriteOK(tif, buf, size) \ | |
191 | (TIFFWriteFile(tif, (tdata_t) buf, (tsize_t) size) == (tsize_t) size) | |
192 | #endif | |
193 | ||
194 | /* NB: the uint32 casts are to silence certain ANSI-C compilers */ | |
195 | #define TIFFhowmany(x, y) ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) | |
196 | #define TIFFroundup(x, y) (TIFFhowmany(x,y)*((uint32)(y))) | |
197 | ||
198 | #if defined(__cplusplus) | |
199 | extern "C" { | |
200 | #endif | |
201 | extern int _TIFFgetMode(const char*, const char*); | |
202 | extern int _TIFFNoRowEncode(TIFF*, tidata_t, tsize_t, tsample_t); | |
203 | extern int _TIFFNoStripEncode(TIFF*, tidata_t, tsize_t, tsample_t); | |
204 | extern int _TIFFNoTileEncode(TIFF*, tidata_t, tsize_t, tsample_t); | |
205 | extern int _TIFFNoRowDecode(TIFF*, tidata_t, tsize_t, tsample_t); | |
206 | extern int _TIFFNoStripDecode(TIFF*, tidata_t, tsize_t, tsample_t); | |
207 | extern int _TIFFNoTileDecode(TIFF*, tidata_t, tsize_t, tsample_t); | |
208 | extern void _TIFFNoPostDecode(TIFF*, tidata_t, tsize_t); | |
209 | extern int _TIFFNoSeek(TIFF*, uint32); | |
210 | extern void _TIFFSwab16BitData(TIFF*, tidata_t, tsize_t); | |
211 | extern void _TIFFSwab32BitData(TIFF*, tidata_t, tsize_t); | |
212 | extern void _TIFFSwab64BitData(TIFF*, tidata_t, tsize_t); | |
94fbea12 DW |
213 | extern int TIFFFlushData1(TIFF*); |
214 | extern void TIFFFreeDirectory(TIFF*); | |
215 | extern int TIFFDefaultDirectory(TIFF*); | |
216 | extern int TIFFSetCompressionScheme(TIFF*, int); | |
217 | extern int TIFFSetDefaultCompressionState(TIFF*); | |
b47c832e RR |
218 | extern uint32 _TIFFDefaultStripSize(TIFF*, uint32); |
219 | extern void _TIFFDefaultTileSize(TIFF*, uint32*, uint32*); | |
220 | ||
221 | extern void _TIFFsetByteArray(void**, void*, long); | |
222 | extern void _TIFFsetString(char**, char*); | |
223 | extern void _TIFFsetShortArray(uint16**, uint16*, long); | |
224 | extern void _TIFFsetLongArray(uint32**, uint32*, long); | |
225 | extern void _TIFFsetFloatArray(float**, float*, long); | |
226 | extern void _TIFFsetDoubleArray(double**, double*, long); | |
227 | ||
228 | extern void _TIFFprintAscii(FILE*, const char*); | |
229 | extern void _TIFFprintAsciiTag(FILE*, const char*, const char*); | |
230 | ||
231 | GLOBALDATA(TIFFErrorHandler,_TIFFwarningHandler); | |
232 | GLOBALDATA(TIFFErrorHandler,_TIFFerrorHandler); | |
233 | ||
94fbea12 | 234 | extern int TIFFInitDumpMode(TIFF*, int); |
b47c832e RR |
235 | #ifdef PACKBITS_SUPPORT |
236 | extern int TIFFInitPackBits(TIFF*, int); | |
237 | #endif | |
238 | #ifdef CCITT_SUPPORT | |
239 | extern int TIFFInitCCITTRLE(TIFF*, int), TIFFInitCCITTRLEW(TIFF*, int); | |
240 | extern int TIFFInitCCITTFax3(TIFF*, int), TIFFInitCCITTFax4(TIFF*, int); | |
241 | #endif | |
242 | #ifdef THUNDER_SUPPORT | |
243 | extern int TIFFInitThunderScan(TIFF*, int); | |
244 | #endif | |
245 | #ifdef NEXT_SUPPORT | |
246 | extern int TIFFInitNeXT(TIFF*, int); | |
247 | #endif | |
248 | #ifdef LZW_SUPPORT | |
249 | extern int TIFFInitLZW(TIFF*, int); | |
250 | #endif | |
251 | #ifdef OJPEG_SUPPORT | |
252 | extern int TIFFInitOJPEG(TIFF*, int); | |
253 | #endif | |
254 | #ifdef JPEG_SUPPORT | |
255 | extern int TIFFInitJPEG(TIFF*, int); | |
256 | #endif | |
257 | #ifdef JBIG_SUPPORT | |
258 | extern int TIFFInitJBIG(TIFF*, int); | |
259 | #endif | |
260 | #ifdef ZIP_SUPPORT | |
261 | extern int TIFFInitZIP(TIFF*, int); | |
262 | #endif | |
263 | #ifdef PIXARLOG_SUPPORT | |
264 | extern int TIFFInitPixarLog(TIFF*, int); | |
265 | #endif | |
266 | #ifdef LOGLUV_SUPPORT | |
267 | extern int TIFFInitSGILog(TIFF*, int); | |
268 | #endif | |
269 | #ifdef VMS | |
270 | extern const TIFFCodec _TIFFBuiltinCODECS[]; | |
271 | #else | |
272 | extern TIFFCodec _TIFFBuiltinCODECS[]; | |
273 | #endif | |
274 | ||
275 | #if defined(__cplusplus) | |
276 | } | |
277 | #endif | |
278 | #endif /* _TIFFIOP_ */ |