Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/tiff/libtiff/tiffiop.h
8869 views
1
/*
2
* Copyright (c) 1988-1997 Sam Leffler
3
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
4
*
5
* Permission to use, copy, modify, distribute, and sell this software and
6
* its documentation for any purpose is hereby granted without fee, provided
7
* that (i) the above copyright notices and this permission notice appear in
8
* all copies of the software and related documentation, and (ii) the names of
9
* Sam Leffler and Silicon Graphics may not be used in any advertising or
10
* publicity relating to the software without the specific, prior written
11
* permission of Sam Leffler and Silicon Graphics.
12
*
13
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
14
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
16
*
17
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
18
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22
* OF THIS SOFTWARE.
23
*/
24
25
#ifndef _TIFFIOP_
26
#define _TIFFIOP_
27
/*
28
* ``Library-private'' definitions.
29
*/
30
31
#include "tif_config.h"
32
33
#ifdef HAVE_FCNTL_H
34
#include <fcntl.h>
35
#endif
36
37
#ifdef HAVE_SYS_TYPES_H
38
#include <sys/types.h>
39
#endif
40
41
#include <string.h>
42
43
#ifdef HAVE_ASSERT_H
44
#include <assert.h>
45
#else
46
#define assert(x)
47
#endif
48
49
#include "tif_hash_set.h"
50
#include "tiffio.h"
51
52
#include "tif_dir.h"
53
54
#include <limits.h>
55
56
#ifndef STRIP_SIZE_DEFAULT
57
#define STRIP_SIZE_DEFAULT 8192
58
#endif
59
60
#ifndef TIFF_MAX_DIR_COUNT
61
#define TIFF_MAX_DIR_COUNT 1048576
62
#endif
63
64
#define TIFF_NON_EXISTENT_DIR_NUMBER UINT_MAX
65
66
#define streq(a, b) (strcmp(a, b) == 0)
67
#define strneq(a, b, n) (strncmp(a, b, n) == 0)
68
69
#ifndef TRUE
70
#define TRUE 1
71
#define FALSE 0
72
#endif
73
74
typedef struct client_info
75
{
76
struct client_info *next;
77
void *data;
78
char *name;
79
} TIFFClientInfoLink;
80
81
/*
82
* Typedefs for ``method pointers'' used internally.
83
* these are deprecated and provided only for backwards compatibility.
84
*/
85
typedef unsigned char tidataval_t; /* internal image data value type */
86
typedef tidataval_t *tidata_t; /* reference to internal image data */
87
88
typedef void (*TIFFVoidMethod)(TIFF *);
89
typedef int (*TIFFBoolMethod)(TIFF *);
90
typedef int (*TIFFPreMethod)(TIFF *, uint16_t);
91
typedef int (*TIFFCodeMethod)(TIFF *tif, uint8_t *buf, tmsize_t size,
92
uint16_t sample);
93
typedef int (*TIFFSeekMethod)(TIFF *, uint32_t);
94
typedef void (*TIFFPostMethod)(TIFF *tif, uint8_t *buf, tmsize_t size);
95
typedef uint32_t (*TIFFStripMethod)(TIFF *, uint32_t);
96
typedef void (*TIFFTileMethod)(TIFF *, uint32_t *, uint32_t *);
97
98
struct TIFFOffsetAndDirNumber
99
{
100
uint64_t offset;
101
tdir_t dirNumber;
102
};
103
typedef struct TIFFOffsetAndDirNumber TIFFOffsetAndDirNumber;
104
105
typedef union
106
{
107
TIFFHeaderCommon common;
108
TIFFHeaderClassic classic;
109
TIFFHeaderBig big;
110
} TIFFHeaderUnion;
111
112
struct tiff
113
{
114
char *tif_name; /* name of open file */
115
int tif_fd; /* open file descriptor */
116
int tif_mode; /* open mode (O_*) */
117
uint32_t tif_flags;
118
#define TIFF_FILLORDER 0x00003U /* natural bit fill order for machine */
119
#define TIFF_DIRTYHEADER 0x00004U /* header must be written on close */
120
#define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */
121
#define TIFF_BUFFERSETUP 0x00010U /* data buffers setup */
122
#define TIFF_CODERSETUP 0x00020U /* encoder/decoder setup done */
123
#define TIFF_BEENWRITING 0x00040U /* written 1+ scanlines to file */
124
#define TIFF_SWAB 0x00080U /* byte swap file information */
125
#define TIFF_NOBITREV 0x00100U /* inhibit bit reversal logic */
126
#define TIFF_MYBUFFER 0x00200U /* my raw data buffer; free on close */
127
#define TIFF_ISTILED 0x00400U /* file is tile, not strip- based */
128
#define TIFF_MAPPED 0x00800U /* file is mapped into memory */
129
#define TIFF_POSTENCODE 0x01000U /* need call to postencode routine */
130
#define TIFF_INSUBIFD 0x02000U /* currently writing a subifd */
131
#define TIFF_UPSAMPLED 0x04000U /* library is doing data up-sampling */
132
#define TIFF_STRIPCHOP 0x08000U /* enable strip chopping support */
133
#define TIFF_HEADERONLY \
134
0x10000U /* read header only, do not process the first directory */
135
#define TIFF_NOREADRAW \
136
0x20000U /* skip reading of raw uncompressed image data */
137
#define TIFF_INCUSTOMIFD 0x40000U /* currently writing a custom IFD */
138
#define TIFF_BIGTIFF 0x80000U /* read/write bigtiff */
139
#define TIFF_BUF4WRITE 0x100000U /* rawcc bytes are for writing */
140
#define TIFF_DIRTYSTRIP 0x200000U /* stripoffsets/stripbytecount dirty*/
141
#define TIFF_PERSAMPLE 0x400000U /* get/set per sample tags as arrays */
142
#define TIFF_BUFFERMMAP \
143
0x800000U /* read buffer (tif_rawdata) points into mmap() memory */
144
#define TIFF_DEFERSTRILELOAD \
145
0x1000000U /* defer strip/tile offset/bytecount array loading. */
146
#define TIFF_LAZYSTRILELOAD \
147
0x2000000U /* lazy/ondemand loading of strip/tile offset/bytecount values. \
148
Only used if TIFF_DEFERSTRILELOAD is set and in read-only \
149
mode */
150
#define TIFF_CHOPPEDUPARRAYS \
151
0x4000000U /* set when allocChoppedUpStripArrays() has modified strip \
152
array */
153
uint64_t tif_diroff; /* file offset of current directory */
154
uint64_t tif_nextdiroff; /* file offset of following directory */
155
uint64_t tif_lastdiroff; /* file offset of last directory written so far */
156
TIFFHashSet *tif_map_dir_offset_to_number;
157
TIFFHashSet *tif_map_dir_number_to_offset;
158
int tif_setdirectory_force_absolute; /* switch between relative and absolute
159
stepping in TIFFSetDirectory() */
160
TIFFDirectory tif_dir; /* internal rep of current directory */
161
TIFFDirectory
162
tif_customdir; /* custom IFDs are separated from the main ones */
163
TIFFHeaderUnion tif_header; /* file's header block Classic/BigTIFF union */
164
uint16_t tif_header_size; /* file's header block and its length */
165
uint32_t tif_row; /* current scanline */
166
167
/* There are IFDs in the file and an "active" IFD in memory,
168
* from which fields are "set" and "get".
169
* tif_curdir is set to:
170
* a) TIFF_NON_EXISTENT_DIR_NUMBER if there is no IFD in the file
171
* or the state is unknown,
172
* or the last read (i.e. TIFFFetchDirectory()) failed,
173
* or a custom directory was written.
174
* b) IFD index of last IFD written in the file. In this case the
175
* active IFD is a new (empty) one and tif_diroff is zero.
176
* If writing fails, tif_curdir is not changed.
177
* c) IFD index of IFD read from file into memory (=active IFD),
178
* even if IFD is corrupt and TIFFReadDirectory() returns 0.
179
* Then tif_diroff contains the offset of the IFD in the file.
180
* d) IFD index 0, whenever a custom directory or an unchained SubIFD
181
* was read. */
182
tdir_t tif_curdir; /* current directory (index) */
183
/* tif_curdircount: number of directories (main-IFDs) in file:
184
* - TIFF_NON_EXISTENT_DIR_NUMBER means 'dont know number of IFDs'.
185
* - 0 means 'empty file opened for writing, but no IFD written yet' */
186
tdir_t tif_curdircount;
187
uint32_t tif_curstrip; /* current strip for read/write */
188
uint64_t tif_curoff; /* current offset for read/write */
189
uint64_t tif_lastvalidoff; /* last valid offset allowed for rewrite in
190
place. Used only by TIFFAppendToStrip() */
191
uint64_t tif_dataoff; /* current offset for writing dir (IFD) */
192
/* SubIFD support */
193
uint16_t tif_nsubifd; /* remaining subifds to write */
194
uint64_t tif_subifdoff; /* offset for patching SubIFD link */
195
/* tiling support */
196
uint32_t tif_col; /* current column (offset by row too) */
197
uint32_t tif_curtile; /* current tile for read/write */
198
tmsize_t tif_tilesize; /* # of bytes in a tile */
199
/* compression scheme hooks */
200
int tif_decodestatus;
201
TIFFBoolMethod tif_fixuptags; /* called in TIFFReadDirectory */
202
TIFFBoolMethod tif_setupdecode; /* called once before predecode */
203
TIFFPreMethod tif_predecode; /* pre- row/strip/tile decoding */
204
TIFFBoolMethod tif_setupencode; /* called once before preencode */
205
int tif_encodestatus;
206
TIFFPreMethod tif_preencode; /* pre- row/strip/tile encoding */
207
TIFFBoolMethod tif_postencode; /* post- row/strip/tile encoding */
208
TIFFCodeMethod tif_decoderow; /* scanline decoding routine */
209
TIFFCodeMethod tif_encoderow; /* scanline encoding routine */
210
TIFFCodeMethod tif_decodestrip; /* strip decoding routine */
211
TIFFCodeMethod tif_encodestrip; /* strip encoding routine */
212
TIFFCodeMethod tif_decodetile; /* tile decoding routine */
213
TIFFCodeMethod tif_encodetile; /* tile encoding routine */
214
TIFFVoidMethod tif_close; /* cleanup-on-close routine */
215
TIFFSeekMethod tif_seek; /* position within a strip routine */
216
TIFFVoidMethod tif_cleanup; /* cleanup state routine */
217
TIFFStripMethod tif_defstripsize; /* calculate/constrain strip size */
218
TIFFTileMethod tif_deftilesize; /* calculate/constrain tile size */
219
uint8_t *tif_data; /* compression scheme private data */
220
/* input/output buffering */
221
tmsize_t tif_scanlinesize; /* # of bytes in a scanline */
222
tmsize_t tif_scanlineskew; /* scanline skew for reading strips */
223
uint8_t *tif_rawdata; /* raw data buffer */
224
tmsize_t tif_rawdatasize; /* # of bytes in raw data buffer */
225
tmsize_t tif_rawdataoff; /* rawdata offset within strip */
226
tmsize_t tif_rawdataloaded; /* amount of data in rawdata */
227
uint8_t *tif_rawcp; /* current spot in raw buffer */
228
tmsize_t tif_rawcc; /* bytes unread from raw buffer */
229
/* memory-mapped file support */
230
uint8_t *tif_base; /* base of mapped file */
231
tmsize_t tif_size; /* size of mapped file region (bytes, thus tmsize_t) */
232
TIFFMapFileProc tif_mapproc; /* map file method */
233
TIFFUnmapFileProc tif_unmapproc; /* unmap file method */
234
/* input/output callback methods */
235
thandle_t tif_clientdata; /* callback parameter */
236
TIFFReadWriteProc tif_readproc; /* read method */
237
TIFFReadWriteProc tif_writeproc; /* write method */
238
TIFFSeekProc tif_seekproc; /* lseek method */
239
TIFFCloseProc tif_closeproc; /* close method */
240
TIFFSizeProc tif_sizeproc; /* filesize method */
241
/* post-decoding support */
242
TIFFPostMethod tif_postdecode; /* post decoding routine */
243
/* tag support */
244
TIFFField **tif_fields; /* sorted table of registered tags */
245
size_t tif_nfields; /* # entries in registered tag table */
246
const TIFFField *tif_foundfield; /* cached pointer to already found tag */
247
TIFFTagMethods tif_tagmethods; /* tag get/set/print routines */
248
TIFFClientInfoLink *tif_clientinfo; /* extra client information. */
249
/* Backward compatibility stuff. We need these two fields for
250
* setting up an old tag extension scheme. */
251
TIFFFieldArray *tif_fieldscompat;
252
size_t tif_nfieldscompat;
253
/* Error handler support */
254
TIFFErrorHandlerExtR tif_errorhandler;
255
void *tif_errorhandler_user_data;
256
TIFFErrorHandlerExtR tif_warnhandler;
257
void *tif_warnhandler_user_data;
258
tmsize_t tif_max_single_mem_alloc; /* in bytes. 0 for unlimited */
259
tmsize_t tif_max_cumulated_mem_alloc; /* in bytes. 0 for unlimited */
260
tmsize_t tif_cur_cumulated_mem_alloc; /* in bytes */
261
int tif_warn_about_unknown_tags;
262
};
263
264
struct TIFFOpenOptions
265
{
266
TIFFErrorHandlerExtR errorhandler; /* may be NULL */
267
void *errorhandler_user_data; /* may be NULL */
268
TIFFErrorHandlerExtR warnhandler; /* may be NULL */
269
void *warnhandler_user_data; /* may be NULL */
270
tmsize_t max_single_mem_alloc; /* in bytes. 0 for unlimited */
271
tmsize_t max_cumulated_mem_alloc; /* in bytes. 0 for unlimited */
272
int warn_about_unknown_tags;
273
};
274
275
#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */
276
277
#define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0)
278
#define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0)
279
#define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0)
280
#define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0)
281
#define TIFFReadFile(tif, buf, size) \
282
((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
283
#define TIFFWriteFile(tif, buf, size) \
284
((*(tif)->tif_writeproc)((tif)->tif_clientdata, (buf), (size)))
285
#define TIFFSeekFile(tif, off, whence) \
286
((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
287
#define TIFFCloseFile(tif) ((*(tif)->tif_closeproc)((tif)->tif_clientdata))
288
#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
289
#define TIFFMapFileContents(tif, paddr, psize) \
290
((*(tif)->tif_mapproc)((tif)->tif_clientdata, (paddr), (psize)))
291
#define TIFFUnmapFileContents(tif, addr, size) \
292
((*(tif)->tif_unmapproc)((tif)->tif_clientdata, (addr), (size)))
293
294
/*
295
* Default Read/Seek/Write definitions.
296
*/
297
#ifndef ReadOK
298
#define ReadOK(tif, buf, size) (TIFFReadFile((tif), (buf), (size)) == (size))
299
#endif
300
#ifndef SeekOK
301
#define SeekOK(tif, off) _TIFFSeekOK(tif, off)
302
#endif
303
#ifndef WriteOK
304
#define WriteOK(tif, buf, size) (TIFFWriteFile((tif), (buf), (size)) == (size))
305
#endif
306
307
/* NB: the uint32_t casts are to silence certain ANSI-C compilers */
308
#define TIFFhowmany_32(x, y) \
309
(((uint32_t)x < (0xffffffff - (uint32_t)(y - 1))) \
310
? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y))) \
311
: 0U)
312
/* Variant of TIFFhowmany_32() that doesn't return 0 if x close to MAXUINT. */
313
/* Caution: TIFFhowmany_32_maxuint_compat(x,y)*y might overflow */
314
#define TIFFhowmany_32_maxuint_compat(x, y) \
315
(((uint32_t)(x) / (uint32_t)(y)) + \
316
((((uint32_t)(x) % (uint32_t)(y)) != 0) ? 1 : 0))
317
#define TIFFhowmany8_32(x) \
318
(((x)&0x07) ? ((uint32_t)(x) >> 3) + 1 : (uint32_t)(x) >> 3)
319
#define TIFFroundup_32(x, y) (TIFFhowmany_32(x, y) * (y))
320
#define TIFFhowmany_64(x, y) \
321
((((uint64_t)(x)) + (((uint64_t)(y)) - 1)) / ((uint64_t)(y)))
322
#define TIFFhowmany8_64(x) \
323
(((x)&0x07) ? ((uint64_t)(x) >> 3) + 1 : (uint64_t)(x) >> 3)
324
#define TIFFroundup_64(x, y) (TIFFhowmany_64(x, y) * (y))
325
326
/* Safe multiply which returns zero if there is an *unsigned* integer overflow.
327
* This macro is not safe for *signed* integer types */
328
#define TIFFSafeMultiply(t, v, m) \
329
((((t)(m) != (t)0) && (((t)(((v) * (m)) / (m))) == (t)(v))) \
330
? (t)((v) * (m)) \
331
: (t)0)
332
333
#define TIFFmax(A, B) ((A) > (B) ? (A) : (B))
334
#define TIFFmin(A, B) ((A) < (B) ? (A) : (B))
335
336
#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0]))
337
338
/*
339
Support for large files.
340
341
Windows read/write APIs support only 'unsigned int' rather than 'size_t'.
342
Windows off_t is only 32-bit, even in 64-bit builds.
343
*/
344
#if defined(HAVE_FSEEKO)
345
/*
346
Use fseeko() and ftello() if they are available since they use
347
'off_t' rather than 'long'. It is wrong to use fseeko() and
348
ftello() only on systems with special LFS support since some systems
349
(e.g. FreeBSD) support a 64-bit off_t by default.
350
351
For MinGW, __MSVCRT_VERSION__ must be at least 0x800 to expose these
352
interfaces. The MinGW compiler must support the requested version. MinGW
353
does not distribute the CRT (it is supplied by Microsoft) so the correct CRT
354
must be available on the target computer in order for the program to run.
355
*/
356
#if defined(HAVE_FSEEKO)
357
#define fseek(stream, offset, whence) fseeko(stream, offset, whence)
358
#define ftell(stream, offset, whence) ftello(stream, offset, whence)
359
#endif
360
#endif
361
#if defined(_WIN32) && \
362
!(defined(__MSVCRT_VERSION__) && __MSVCRT_VERSION__ < 0x800)
363
typedef unsigned int TIFFIOSize_t;
364
#define _TIFF_lseek_f(fildes, offset, whence) \
365
_lseeki64(fildes, /* __int64 */ offset, whence)
366
/* #define _TIFF_tell_f(fildes) /\* __int64 *\/ _telli64(fildes) */
367
#define _TIFF_fseek_f(stream, offset, whence) \
368
_fseeki64(stream, /* __int64 */ offset, whence)
369
#define _TIFF_fstat_f(fildes, stat_buff) \
370
_fstati64(fildes, /* struct _stati64 */ stat_buff)
371
/* #define _TIFF_ftell_f(stream) /\* __int64 *\/ _ftelli64(stream) */
372
/* #define _TIFF_stat_f(path,stat_buff) _stati64(path,/\* struct _stati64 *\/
373
* stat_buff) */
374
#define _TIFF_stat_s struct _stati64
375
#define _TIFF_off_t __int64
376
#else
377
typedef size_t TIFFIOSize_t;
378
#define _TIFF_lseek_f(fildes, offset, whence) lseek(fildes, offset, whence)
379
/* #define _TIFF_tell_f(fildes) (_TIFF_lseek_f(fildes,0,SEEK_CUR)) */
380
#define _TIFF_fseek_f(stream, offset, whence) fseek(stream, offset, whence)
381
#define _TIFF_fstat_f(fildes, stat_buff) fstat(fildes, stat_buff)
382
/* #define _TIFF_ftell_f(stream) ftell(stream) */
383
/* #define _TIFF_stat_f(path,stat_buff) stat(path,stat_buff) */
384
#define _TIFF_stat_s struct stat
385
#define _TIFF_off_t off_t
386
#endif
387
388
#if defined(__has_attribute) && defined(__clang__)
389
#if __has_attribute(no_sanitize)
390
#define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW \
391
__attribute__((no_sanitize("unsigned-integer-overflow")))
392
#else
393
#define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
394
#endif
395
#else
396
#define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
397
#endif
398
399
#if defined(__cplusplus)
400
extern "C"
401
{
402
#endif
403
extern int _tiffDummyMapProc(thandle_t fd, void **pbase, toff_t *psize);
404
extern void _tiffDummyUnmapProc(thandle_t fd, void *base, toff_t size);
405
extern int _TIFFgetMode(TIFFOpenOptions *opts, thandle_t clientdata,
406
const char *mode, const char *module);
407
extern int _TIFFNoRowEncode(TIFF *tif, uint8_t *pp, tmsize_t cc,
408
uint16_t s);
409
extern int _TIFFNoStripEncode(TIFF *tif, uint8_t *pp, tmsize_t cc,
410
uint16_t s);
411
extern int _TIFFNoTileEncode(TIFF *, uint8_t *pp, tmsize_t cc, uint16_t s);
412
extern int _TIFFNoRowDecode(TIFF *tif, uint8_t *pp, tmsize_t cc,
413
uint16_t s);
414
extern int _TIFFNoStripDecode(TIFF *tif, uint8_t *pp, tmsize_t cc,
415
uint16_t s);
416
extern int _TIFFNoTileDecode(TIFF *, uint8_t *pp, tmsize_t cc, uint16_t s);
417
extern void _TIFFNoPostDecode(TIFF *tif, uint8_t *buf, tmsize_t cc);
418
extern int _TIFFNoPreCode(TIFF *tif, uint16_t s);
419
extern int _TIFFNoSeek(TIFF *tif, uint32_t off);
420
extern void _TIFFSwab16BitData(TIFF *tif, uint8_t *buf, tmsize_t cc);
421
extern void _TIFFSwab24BitData(TIFF *tif, uint8_t *buf, tmsize_t cc);
422
extern void _TIFFSwab32BitData(TIFF *tif, uint8_t *buf, tmsize_t cc);
423
extern void _TIFFSwab64BitData(TIFF *tif, uint8_t *buf, tmsize_t cc);
424
extern int TIFFFlushData1(TIFF *tif);
425
extern int TIFFDefaultDirectory(TIFF *tif);
426
extern void _TIFFSetDefaultCompressionState(TIFF *tif);
427
extern int _TIFFRewriteField(TIFF *, uint16_t, TIFFDataType, tmsize_t,
428
void *);
429
extern int TIFFSetCompressionScheme(TIFF *tif, int scheme);
430
extern int TIFFSetDefaultCompressionState(TIFF *tif);
431
extern uint32_t _TIFFDefaultStripSize(TIFF *tif, uint32_t s);
432
extern void _TIFFDefaultTileSize(TIFF *tif, uint32_t *tw, uint32_t *th);
433
434
extern void _TIFFsetByteArray(void **, const void *, uint32_t);
435
extern void _TIFFsetByteArrayExt(TIFF *, void **, const void *, uint32_t);
436
extern void _TIFFsetShortArray(uint16_t **, const uint16_t *, uint32_t);
437
extern void _TIFFsetShortArrayExt(TIFF *, uint16_t **, const uint16_t *,
438
uint32_t);
439
extern void _TIFFsetLongArray(uint32_t **, const uint32_t *, uint32_t);
440
extern void _TIFFsetLongArrayExt(TIFF *, uint32_t **, const uint32_t *,
441
uint32_t);
442
extern void _TIFFsetFloatArray(float **, const float *, uint32_t);
443
extern void _TIFFsetFloatArrayExt(TIFF *, float **, const float *,
444
uint32_t);
445
extern void _TIFFsetDoubleArray(double **, const double *, uint32_t);
446
extern void _TIFFsetDoubleArrayExt(TIFF *, double **, const double *,
447
uint32_t);
448
449
extern void _TIFFprintAscii(FILE *, const char *);
450
extern void _TIFFprintAsciiTag(FILE *, const char *, const char *);
451
452
extern TIFFErrorHandler _TIFFwarningHandler;
453
extern TIFFErrorHandler _TIFFerrorHandler;
454
extern TIFFErrorHandlerExt _TIFFwarningHandlerExt;
455
extern TIFFErrorHandlerExt _TIFFerrorHandlerExt;
456
void _TIFFErrorEarly(TIFFOpenOptions *opts, thandle_t clientdata,
457
const char *module, const char *fmt, ...)
458
TIFF_ATTRIBUTE((__format__(__printf__, 4, 5)));
459
460
extern uint32_t _TIFFMultiply32(TIFF *, uint32_t, uint32_t, const char *);
461
extern uint64_t _TIFFMultiply64(TIFF *, uint64_t, uint64_t, const char *);
462
extern tmsize_t _TIFFMultiplySSize(TIFF *, tmsize_t, tmsize_t,
463
const char *);
464
extern tmsize_t _TIFFCastUInt64ToSSize(TIFF *, uint64_t, const char *);
465
extern void *_TIFFCheckMalloc(TIFF *, tmsize_t, tmsize_t, const char *);
466
extern void *_TIFFCheckRealloc(TIFF *, void *, tmsize_t, tmsize_t,
467
const char *);
468
469
extern float _TIFFClampDoubleToFloat(double);
470
extern uint32_t _TIFFClampDoubleToUInt32(double);
471
472
extern void _TIFFCleanupIFDOffsetAndNumberMaps(TIFF *tif);
473
474
extern tmsize_t _TIFFReadEncodedStripAndAllocBuffer(TIFF *tif,
475
uint32_t strip,
476
void **buf,
477
tmsize_t bufsizetoalloc,
478
tmsize_t size_to_read);
479
extern tmsize_t _TIFFReadEncodedTileAndAllocBuffer(TIFF *tif, uint32_t tile,
480
void **buf,
481
tmsize_t bufsizetoalloc,
482
tmsize_t size_to_read);
483
extern tmsize_t _TIFFReadTileAndAllocBuffer(TIFF *tif, void **buf,
484
tmsize_t bufsizetoalloc,
485
uint32_t x, uint32_t y,
486
uint32_t z, uint16_t s);
487
extern int _TIFFSeekOK(TIFF *tif, toff_t off);
488
489
extern int TIFFInitDumpMode(TIFF *, int);
490
#ifdef PACKBITS_SUPPORT
491
extern int TIFFInitPackBits(TIFF *, int);
492
#endif
493
#ifdef CCITT_SUPPORT
494
extern int TIFFInitCCITTRLE(TIFF *, int), TIFFInitCCITTRLEW(TIFF *, int);
495
extern int TIFFInitCCITTFax3(TIFF *, int), TIFFInitCCITTFax4(TIFF *, int);
496
#endif
497
#ifdef THUNDER_SUPPORT
498
extern int TIFFInitThunderScan(TIFF *, int);
499
#endif
500
#ifdef NEXT_SUPPORT
501
extern int TIFFInitNeXT(TIFF *, int);
502
#endif
503
#ifdef LZW_SUPPORT
504
extern int TIFFInitLZW(TIFF *, int);
505
#endif
506
#ifdef OJPEG_SUPPORT
507
extern int TIFFInitOJPEG(TIFF *, int);
508
#endif
509
#ifdef JPEG_SUPPORT
510
extern int TIFFInitJPEG(TIFF *, int);
511
extern int TIFFJPEGIsFullStripRequired(TIFF *);
512
#endif
513
#ifdef JBIG_SUPPORT
514
extern int TIFFInitJBIG(TIFF *, int);
515
#endif
516
#ifdef ZIP_SUPPORT
517
extern int TIFFInitZIP(TIFF *, int);
518
#endif
519
#ifdef PIXARLOG_SUPPORT
520
extern int TIFFInitPixarLog(TIFF *, int);
521
#endif
522
#ifdef LOGLUV_SUPPORT
523
extern int TIFFInitSGILog(TIFF *, int);
524
#endif
525
#ifdef LERC_SUPPORT
526
extern int TIFFInitLERC(TIFF *tif, int);
527
#endif
528
#ifdef LZMA_SUPPORT
529
extern int TIFFInitLZMA(TIFF *, int);
530
#endif
531
#ifdef ZSTD_SUPPORT
532
extern int TIFFInitZSTD(TIFF *, int);
533
#endif
534
#ifdef WEBP_SUPPORT
535
extern int TIFFInitWebP(TIFF *, int);
536
#endif
537
extern const TIFFCodec _TIFFBuiltinCODECS[];
538
extern void TIFFCIELab16ToXYZ(TIFFCIELabToRGB *, uint32_t l, int32_t a,
539
int32_t b, float *, float *, float *);
540
541
extern void *_TIFFmallocExt(TIFF *tif, tmsize_t s);
542
extern void *_TIFFcallocExt(TIFF *tif, tmsize_t nmemb, tmsize_t siz);
543
extern void *_TIFFreallocExt(TIFF *tif, void *p, tmsize_t s);
544
extern void _TIFFfreeExt(TIFF *tif, void *p);
545
546
#if defined(__cplusplus)
547
}
548
#endif
549
#endif /* _TIFFIOP_ */
550
551