tiffiop.h 23 KB

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