ReactOS 0.4.16-dev-2617-g01a0906
tiffiop.h File Reference
#include "tif_config.h"
#include <fcntl.h>
#include <sys/types.h>
#include <string.h>
#include <assert.h>
#include "tif_hash_set.h"
#include "tiffio.h"
#include "tif_dir.h"
#include <limits.h>
Include dependency graph for tiffiop.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  client_info
 
struct  TIFFOffsetAndDirNumber
 
union  TIFFHeaderUnion
 
struct  tiff
 
struct  TIFFOpenOptions
 

Macros

#define TIFF_NON_EXISTENT_DIR_NUMBER   UINT_MAX
 
#define streq(a, b)   (strcmp(a, b) == 0)
 
#define strneq(a, b, n)   (strncmp(a, b, n) == 0)
 
#define TRUE   1
 
#define FALSE   0
 
#define TIFF_FILLORDER   0x00003U /* natural bit fill order for machine */
 
#define TIFF_DIRTYHEADER   0x00004U /* header must be written on close */
 
#define TIFF_DIRTYDIRECT   0x00008U /* current directory must be written */
 
#define TIFF_BUFFERSETUP   0x00010U /* data buffers setup */
 
#define TIFF_CODERSETUP   0x00020U /* encoder/decoder setup done */
 
#define TIFF_BEENWRITING   0x00040U /* written 1+ scanlines to file */
 
#define TIFF_SWAB   0x00080U /* byte swap file information */
 
#define TIFF_NOBITREV   0x00100U /* inhibit bit reversal logic */
 
#define TIFF_MYBUFFER   0x00200U /* my raw data buffer; free on close */
 
#define TIFF_ISTILED   0x00400U /* file is tile, not strip- based */
 
#define TIFF_MAPPED   0x00800U /* file is mapped into memory */
 
#define TIFF_POSTENCODE   0x01000U /* need call to postencode routine */
 
#define TIFF_INSUBIFD   0x02000U /* currently writing a subifd */
 
#define TIFF_UPSAMPLED   0x04000U /* library is doing data up-sampling */
 
#define TIFF_STRIPCHOP   0x08000U /* enable strip chopping support */
 
#define TIFF_HEADERONLY    0x10000U /* read header only, do not process the first directory */
 
#define TIFF_NOREADRAW    0x20000U /* skip reading of raw uncompressed image data */
 
#define TIFF_INCUSTOMIFD   0x40000U /* currently writing a custom IFD */
 
#define TIFF_BIGTIFF   0x80000U /* read/write bigtiff */
 
#define TIFF_BUF4WRITE   0x100000U /* rawcc bytes are for writing */
 
#define TIFF_DIRTYSTRIP   0x200000U /* stripoffsets/stripbytecount dirty*/
 
#define TIFF_PERSAMPLE   0x400000U /* get/set per sample tags as arrays */
 
#define TIFF_BUFFERMMAP    0x800000U /* read buffer (tif_rawdata) points into mmap() memory */
 
#define TIFF_DEFERSTRILELOAD    0x1000000U /* defer strip/tile offset/bytecount array loading. */
 
#define TIFF_LAZYSTRILELOAD
 
#define TIFF_CHOPPEDUPARRAYS
 
#define isPseudoTag(t)   (t > 0xffff) /* is tag value normal or pseudo */
 
#define isTiled(tif)   (((tif)->tif_flags & TIFF_ISTILED) != 0)
 
#define isMapped(tif)   (((tif)->tif_flags & TIFF_MAPPED) != 0)
 
#define isFillOrder(tif, o)   (((tif)->tif_flags & (o)) != 0)
 
#define isUpSampled(tif)   (((tif)->tif_flags & TIFF_UPSAMPLED) != 0)
 
#define TIFFReadFile(tif, buf, size)    ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))
 
#define TIFFWriteFile(tif, buf, size)    ((*(tif)->tif_writeproc)((tif)->tif_clientdata, (buf), (size)))
 
#define TIFFSeekFile(tif, off, whence)    ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))
 
#define TIFFCloseFile(tif)   ((*(tif)->tif_closeproc)((tif)->tif_clientdata))
 
#define TIFFGetFileSize(tif)   ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))
 
#define TIFFMapFileContents(tif, paddr, psize)    ((*(tif)->tif_mapproc)((tif)->tif_clientdata, (paddr), (psize)))
 
#define TIFFUnmapFileContents(tif, addr, size)    ((*(tif)->tif_unmapproc)((tif)->tif_clientdata, (addr), (size)))
 
#define ReadOK(tif, buf, size)   (TIFFReadFile((tif), (buf), (size)) == (size))
 
#define SeekOK(tif, off)   _TIFFSeekOK(tif, off)
 
#define WriteOK(tif, buf, size)   (TIFFWriteFile((tif), (buf), (size)) == (size))
 
#define TIFFhowmany_32(x, y)
 
#define TIFFhowmany_32_maxuint_compat(x, y)
 
#define TIFFhowmany8_32(x)    (((x)&0x07) ? ((uint32_t)(x) >> 3) + 1 : (uint32_t)(x) >> 3)
 
#define TIFFroundup_32(x, y)   (TIFFhowmany_32(x, y) * (y))
 
#define TIFFhowmany_64(x, y)    ((((uint64_t)(x)) + (((uint64_t)(y)) - 1)) / ((uint64_t)(y)))
 
#define TIFFhowmany8_64(x)    (((x)&0x07) ? ((uint64_t)(x) >> 3) + 1 : (uint64_t)(x) >> 3)
 
#define TIFFroundup_64(x, y)   (TIFFhowmany_64(x, y) * (y))
 
#define TIFFSafeMultiply(t, v, m)
 
#define TIFFmax(A, B)   ((A) > (B) ? (A) : (B))
 
#define TIFFmin(A, B)   ((A) < (B) ? (A) : (B))
 
#define TIFFArrayCount(a)   (sizeof(a) / sizeof((a)[0]))
 
#define fseek(stream, offset, whence)   fseeko(stream, offset, whence)
 
#define ftell(stream, offset, whence)   ftello(stream, offset, whence)
 
#define _TIFF_lseek_f(fildes, offset, whence)   lseek(fildes, offset, whence)
 
#define _TIFF_fseek_f(stream, offset, whence)   fseek(stream, offset, whence)
 
#define _TIFF_fstat_f(fildes, stat_buff)   fstat(fildes, stat_buff)
 
#define _TIFF_stat_s   struct stat
 
#define _TIFF_off_t   off_t
 
#define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW
 

Typedefs

typedef struct client_info TIFFClientInfoLink
 
typedef unsigned char tidataval_t
 
typedef tidataval_ttidata_t
 
typedef void(* TIFFVoidMethod) (TIFF *)
 
typedef int(* TIFFBoolMethod) (TIFF *)
 
typedef int(* TIFFPreMethod) (TIFF *, uint16_t)
 
typedef int(* TIFFCodeMethod) (TIFF *tif, uint8_t *buf, tmsize_t size, uint16_t sample)
 
typedef int(* TIFFSeekMethod) (TIFF *, uint32_t)
 
typedef void(* TIFFPostMethod) (TIFF *tif, uint8_t *buf, tmsize_t size)
 
typedef uint32_t(* TIFFStripMethod) (TIFF *, uint32_t)
 
typedef void(* TIFFTileMethod) (TIFF *, uint32_t *, uint32_t *)
 
typedef struct TIFFOffsetAndDirNumber TIFFOffsetAndDirNumber
 
typedef size_t TIFFIOSize_t
 

Functions

int _tiffDummyMapProc (thandle_t fd, void **pbase, toff_t *psize)
 
void _tiffDummyUnmapProc (thandle_t fd, void *base, toff_t size)
 
int _TIFFgetMode (TIFFOpenOptions *opts, thandle_t clientdata, const char *mode, const char *module)
 
int _TIFFNoRowEncode (TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
 
int _TIFFNoStripEncode (TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
 
int _TIFFNoTileEncode (TIFF *, uint8_t *pp, tmsize_t cc, uint16_t s)
 
int _TIFFNoRowDecode (TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
 
int _TIFFNoStripDecode (TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
 
int _TIFFNoTileDecode (TIFF *, uint8_t *pp, tmsize_t cc, uint16_t s)
 
void _TIFFNoPostDecode (TIFF *tif, uint8_t *buf, tmsize_t cc)
 
int _TIFFNoPreCode (TIFF *tif, uint16_t s)
 
int _TIFFNoSeek (TIFF *tif, uint32_t off)
 
void _TIFFSwab16BitData (TIFF *tif, uint8_t *buf, tmsize_t cc)
 
void _TIFFSwab24BitData (TIFF *tif, uint8_t *buf, tmsize_t cc)
 
void _TIFFSwab32BitData (TIFF *tif, uint8_t *buf, tmsize_t cc)
 
void _TIFFSwab64BitData (TIFF *tif, uint8_t *buf, tmsize_t cc)
 
int TIFFFlushData1 (TIFF *tif)
 
int TIFFDefaultDirectory (TIFF *tif)
 
void _TIFFSetDefaultCompressionState (TIFF *tif)
 
int _TIFFRewriteField (TIFF *, uint16_t, TIFFDataType, tmsize_t, void *)
 
int TIFFSetCompressionScheme (TIFF *tif, int scheme)
 
int TIFFSetDefaultCompressionState (TIFF *tif)
 
uint32_t _TIFFDefaultStripSize (TIFF *tif, uint32_t s)
 
void _TIFFDefaultTileSize (TIFF *tif, uint32_t *tw, uint32_t *th)
 
void _TIFFsetByteArray (void **, const void *, uint32_t)
 
void _TIFFsetByteArrayExt (TIFF *, void **, const void *, uint32_t)
 
void _TIFFsetShortArray (uint16_t **, const uint16_t *, uint32_t)
 
void _TIFFsetShortArrayExt (TIFF *, uint16_t **, const uint16_t *, uint32_t)
 
void _TIFFsetLongArray (uint32_t **, const uint32_t *, uint32_t)
 
void _TIFFsetLongArrayExt (TIFF *, uint32_t **, const uint32_t *, uint32_t)
 
void _TIFFsetFloatArray (float **, const float *, uint32_t)
 
void _TIFFsetFloatArrayExt (TIFF *, float **, const float *, uint32_t)
 
void _TIFFsetDoubleArray (double **, const double *, uint32_t)
 
void _TIFFsetDoubleArrayExt (TIFF *, double **, const double *, uint32_t)
 
void _TIFFprintAscii (FILE *, const char *)
 
void _TIFFprintAsciiTag (FILE *, const char *, const char *)
 
void _TIFFErrorEarly (TIFFOpenOptions *opts, thandle_t clientdata, const char *module, const char *fmt,...) TIFF_ATTRIBUTE((__format__(__printf__
 
void uint32_t _TIFFMultiply32 (TIFF *, uint32_t, uint32_t, const char *)
 
uint64_t _TIFFMultiply64 (TIFF *, uint64_t, uint64_t, const char *)
 
tmsize_t _TIFFMultiplySSize (TIFF *, tmsize_t, tmsize_t, const char *)
 
tmsize_t _TIFFCastUInt64ToSSize (TIFF *, uint64_t, const char *)
 
void_TIFFCheckMalloc (TIFF *, tmsize_t, tmsize_t, const char *)
 
void_TIFFCheckRealloc (TIFF *, void *, tmsize_t, tmsize_t, const char *)
 
float _TIFFClampDoubleToFloat (double)
 
uint32_t _TIFFClampDoubleToUInt32 (double)
 
void _TIFFCleanupIFDOffsetAndNumberMaps (TIFF *tif)
 
tmsize_t _TIFFReadEncodedStripAndAllocBuffer (TIFF *tif, uint32_t strip, void **buf, tmsize_t bufsizetoalloc, tmsize_t size_to_read)
 
tmsize_t _TIFFReadEncodedTileAndAllocBuffer (TIFF *tif, uint32_t tile, void **buf, tmsize_t bufsizetoalloc, tmsize_t size_to_read)
 
tmsize_t _TIFFReadTileAndAllocBuffer (TIFF *tif, void **buf, tmsize_t bufsizetoalloc, uint32_t x, uint32_t y, uint32_t z, uint16_t s)
 
int _TIFFSeekOK (TIFF *tif, toff_t off)
 
int TIFFInitDumpMode (TIFF *, int)
 
int TIFFInitPackBits (TIFF *, int)
 
int TIFFInitCCITTRLE (TIFF *, int)
 
int TIFFInitCCITTRLEW (TIFF *, int)
 
int TIFFInitCCITTFax3 (TIFF *, int)
 
int TIFFInitCCITTFax4 (TIFF *, int)
 
int TIFFInitThunderScan (TIFF *, int)
 
int TIFFInitNeXT (TIFF *, int)
 
int TIFFInitLZW (TIFF *, int)
 
int TIFFInitJPEG (TIFF *, int)
 
int TIFFJPEGIsFullStripRequired (TIFF *)
 
int TIFFInitZIP (TIFF *, int)
 
int TIFFInitPixarLog (TIFF *, int)
 
int TIFFInitSGILog (TIFF *, int)
 
void TIFFCIELab16ToXYZ (TIFFCIELabToRGB *, uint32_t l, int32_t a, int32_t b, float *, float *, float *)
 
void_TIFFmallocExt (TIFF *tif, tmsize_t s)
 
void_TIFFcallocExt (TIFF *tif, tmsize_t nmemb, tmsize_t siz)
 
void_TIFFreallocExt (TIFF *tif, void *p, tmsize_t s)
 
void _TIFFfreeExt (TIFF *tif, void *p)
 

Variables

TIFFErrorHandler _TIFFwarningHandler
 
TIFFErrorHandler _TIFFerrorHandler
 
TIFFErrorHandlerExt _TIFFwarningHandlerExt
 
TIFFErrorHandlerExt _TIFFerrorHandlerExt
 
const TIFFCodec _TIFFBuiltinCODECS []
 

Macro Definition Documentation

◆ _TIFF_fseek_f

#define _TIFF_fseek_f (   stream,
  offset,
  whence 
)    fseek(stream, offset, whence)

Definition at line 377 of file tiffiop.h.

◆ _TIFF_fstat_f

#define _TIFF_fstat_f (   fildes,
  stat_buff 
)    fstat(fildes, stat_buff)

Definition at line 378 of file tiffiop.h.

◆ _TIFF_lseek_f

#define _TIFF_lseek_f (   fildes,
  offset,
  whence 
)    lseek(fildes, offset, whence)

Definition at line 375 of file tiffiop.h.

◆ _TIFF_off_t

#define _TIFF_off_t   off_t

Definition at line 382 of file tiffiop.h.

◆ _TIFF_stat_s

#define _TIFF_stat_s   struct stat

Definition at line 381 of file tiffiop.h.

◆ FALSE

#define FALSE   0

Definition at line 71 of file tiffiop.h.

◆ fseek

#define fseek (   stream,
  offset,
  whence 
)    fseeko(stream, offset, whence)

Definition at line 354 of file tiffiop.h.

◆ ftell

#define ftell (   stream,
  offset,
  whence 
)    ftello(stream, offset, whence)

Definition at line 355 of file tiffiop.h.

◆ isFillOrder

#define isFillOrder (   tif,
 
)    (((tif)->tif_flags & (o)) != 0)

Definition at line 276 of file tiffiop.h.

◆ isMapped

#define isMapped (   tif)    (((tif)->tif_flags & TIFF_MAPPED) != 0)

Definition at line 275 of file tiffiop.h.

◆ isPseudoTag

#define isPseudoTag (   t)    (t > 0xffff) /* is tag value normal or pseudo */

Definition at line 272 of file tiffiop.h.

◆ isTiled

#define isTiled (   tif)    (((tif)->tif_flags & TIFF_ISTILED) != 0)

Definition at line 274 of file tiffiop.h.

◆ isUpSampled

#define isUpSampled (   tif)    (((tif)->tif_flags & TIFF_UPSAMPLED) != 0)

Definition at line 277 of file tiffiop.h.

◆ ReadOK

#define ReadOK (   tif,
  buf,
  size 
)    (TIFFReadFile((tif), (buf), (size)) == (size))

Definition at line 295 of file tiffiop.h.

◆ SeekOK

#define SeekOK (   tif,
  off 
)    _TIFFSeekOK(tif, off)

Definition at line 298 of file tiffiop.h.

◆ streq

#define streq (   a,
  b 
)    (strcmp(a, b) == 0)

Definition at line 66 of file tiffiop.h.

◆ strneq

#define strneq (   a,
  b,
  n 
)    (strncmp(a, b, n) == 0)

Definition at line 67 of file tiffiop.h.

◆ TIFF_BEENWRITING

#define TIFF_BEENWRITING   0x00040U /* written 1+ scanlines to file */

Definition at line 123 of file tiffiop.h.

◆ TIFF_BIGTIFF

#define TIFF_BIGTIFF   0x80000U /* read/write bigtiff */

Definition at line 138 of file tiffiop.h.

◆ TIFF_BUF4WRITE

#define TIFF_BUF4WRITE   0x100000U /* rawcc bytes are for writing */

Definition at line 139 of file tiffiop.h.

◆ TIFF_BUFFERMMAP

#define TIFF_BUFFERMMAP    0x800000U /* read buffer (tif_rawdata) points into mmap() memory */

Definition at line 142 of file tiffiop.h.

◆ TIFF_BUFFERSETUP

#define TIFF_BUFFERSETUP   0x00010U /* data buffers setup */

Definition at line 121 of file tiffiop.h.

◆ TIFF_CHOPPEDUPARRAYS

#define TIFF_CHOPPEDUPARRAYS
Value:
0x4000000U /* set when allocChoppedUpStripArrays() has modified strip \
array */

Definition at line 148 of file tiffiop.h.

◆ TIFF_CODERSETUP

#define TIFF_CODERSETUP   0x00020U /* encoder/decoder setup done */

Definition at line 122 of file tiffiop.h.

◆ TIFF_DEFERSTRILELOAD

#define TIFF_DEFERSTRILELOAD    0x1000000U /* defer strip/tile offset/bytecount array loading. */

Definition at line 144 of file tiffiop.h.

◆ TIFF_DIRTYDIRECT

#define TIFF_DIRTYDIRECT   0x00008U /* current directory must be written */

Definition at line 120 of file tiffiop.h.

◆ TIFF_DIRTYHEADER

#define TIFF_DIRTYHEADER   0x00004U /* header must be written on close */

Definition at line 119 of file tiffiop.h.

◆ TIFF_DIRTYSTRIP

#define TIFF_DIRTYSTRIP   0x200000U /* stripoffsets/stripbytecount dirty*/

Definition at line 140 of file tiffiop.h.

◆ TIFF_FILLORDER

#define TIFF_FILLORDER   0x00003U /* natural bit fill order for machine */

Definition at line 118 of file tiffiop.h.

◆ TIFF_HEADERONLY

#define TIFF_HEADERONLY    0x10000U /* read header only, do not process the first directory */

Definition at line 133 of file tiffiop.h.

◆ TIFF_INCUSTOMIFD

#define TIFF_INCUSTOMIFD   0x40000U /* currently writing a custom IFD */

Definition at line 137 of file tiffiop.h.

◆ TIFF_INSUBIFD

#define TIFF_INSUBIFD   0x02000U /* currently writing a subifd */

Definition at line 130 of file tiffiop.h.

◆ TIFF_ISTILED

#define TIFF_ISTILED   0x00400U /* file is tile, not strip- based */

Definition at line 127 of file tiffiop.h.

◆ TIFF_LAZYSTRILELOAD

#define TIFF_LAZYSTRILELOAD
Value:
0x2000000U /* lazy/ondemand loading of strip/tile offset/bytecount values. \
Only used if TIFF_DEFERSTRILELOAD is set and in read-only \
mode */

Definition at line 146 of file tiffiop.h.

◆ TIFF_MAPPED

#define TIFF_MAPPED   0x00800U /* file is mapped into memory */

Definition at line 128 of file tiffiop.h.

◆ TIFF_MYBUFFER

#define TIFF_MYBUFFER   0x00200U /* my raw data buffer; free on close */

Definition at line 126 of file tiffiop.h.

◆ TIFF_NOBITREV

#define TIFF_NOBITREV   0x00100U /* inhibit bit reversal logic */

Definition at line 125 of file tiffiop.h.

◆ TIFF_NON_EXISTENT_DIR_NUMBER

#define TIFF_NON_EXISTENT_DIR_NUMBER   UINT_MAX

Definition at line 64 of file tiffiop.h.

◆ TIFF_NOREADRAW

#define TIFF_NOREADRAW    0x20000U /* skip reading of raw uncompressed image data */

Definition at line 135 of file tiffiop.h.

◆ TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW

#define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW

Definition at line 393 of file tiffiop.h.

◆ TIFF_PERSAMPLE

#define TIFF_PERSAMPLE   0x400000U /* get/set per sample tags as arrays */

Definition at line 141 of file tiffiop.h.

◆ TIFF_POSTENCODE

#define TIFF_POSTENCODE   0x01000U /* need call to postencode routine */

Definition at line 129 of file tiffiop.h.

◆ TIFF_STRIPCHOP

#define TIFF_STRIPCHOP   0x08000U /* enable strip chopping support */

Definition at line 132 of file tiffiop.h.

◆ TIFF_SWAB

#define TIFF_SWAB   0x00080U /* byte swap file information */

Definition at line 124 of file tiffiop.h.

◆ TIFF_UPSAMPLED

#define TIFF_UPSAMPLED   0x04000U /* library is doing data up-sampling */

Definition at line 131 of file tiffiop.h.

◆ TIFFArrayCount

#define TIFFArrayCount (   a)    (sizeof(a) / sizeof((a)[0]))

Definition at line 333 of file tiffiop.h.

◆ TIFFCloseFile

#define TIFFCloseFile (   tif)    ((*(tif)->tif_closeproc)((tif)->tif_clientdata))

Definition at line 284 of file tiffiop.h.

◆ TIFFGetFileSize

#define TIFFGetFileSize (   tif)    ((*(tif)->tif_sizeproc)((tif)->tif_clientdata))

Definition at line 285 of file tiffiop.h.

◆ TIFFhowmany8_32

#define TIFFhowmany8_32 (   x)     (((x)&0x07) ? ((uint32_t)(x) >> 3) + 1 : (uint32_t)(x) >> 3)

Definition at line 314 of file tiffiop.h.

◆ TIFFhowmany8_64

#define TIFFhowmany8_64 (   x)     (((x)&0x07) ? ((uint64_t)(x) >> 3) + 1 : (uint64_t)(x) >> 3)

Definition at line 319 of file tiffiop.h.

◆ TIFFhowmany_32

#define TIFFhowmany_32 (   x,
  y 
)
Value:
(((uint32_t)x < (0xffffffff - (uint32_t)(y - 1))) \
? ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y))) \
: 0U)
#define U(x)
Definition: wordpad.c:45
UINT32 uint32_t
Definition: types.h:75
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define uint32_t
Definition: nsiface.idl:61

Definition at line 305 of file tiffiop.h.

◆ TIFFhowmany_32_maxuint_compat

#define TIFFhowmany_32_maxuint_compat (   x,
  y 
)
Value:
(((uint32_t)(x) / (uint32_t)(y)) + \
((((uint32_t)(x) % (uint32_t)(y)) != 0) ? 1 : 0))

Definition at line 311 of file tiffiop.h.

◆ TIFFhowmany_64

#define TIFFhowmany_64 (   x,
  y 
)     ((((uint64_t)(x)) + (((uint64_t)(y)) - 1)) / ((uint64_t)(y)))

Definition at line 317 of file tiffiop.h.

◆ TIFFMapFileContents

#define TIFFMapFileContents (   tif,
  paddr,
  psize 
)     ((*(tif)->tif_mapproc)((tif)->tif_clientdata, (paddr), (psize)))

Definition at line 286 of file tiffiop.h.

◆ TIFFmax

#define TIFFmax (   A,
  B 
)    ((A) > (B) ? (A) : (B))

Definition at line 330 of file tiffiop.h.

◆ TIFFmin

#define TIFFmin (   A,
  B 
)    ((A) < (B) ? (A) : (B))

Definition at line 331 of file tiffiop.h.

◆ TIFFReadFile

#define TIFFReadFile (   tif,
  buf,
  size 
)     ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size)))

Definition at line 278 of file tiffiop.h.

◆ TIFFroundup_32

#define TIFFroundup_32 (   x,
  y 
)    (TIFFhowmany_32(x, y) * (y))

Definition at line 316 of file tiffiop.h.

◆ TIFFroundup_64

#define TIFFroundup_64 (   x,
  y 
)    (TIFFhowmany_64(x, y) * (y))

Definition at line 321 of file tiffiop.h.

◆ TIFFSafeMultiply

#define TIFFSafeMultiply (   t,
  v,
  m 
)
Value:
((((t)(m) != (t)0) && (((t)(((v) * (m)) / (m))) == (t)(v))) \
? (t)((v) * (m)) \
: (t)0)
const GLdouble * v
Definition: gl.h:2040
GLdouble GLdouble t
Definition: gl.h:2047
const GLfloat * m
Definition: glext.h:10848

Definition at line 325 of file tiffiop.h.

◆ TIFFSeekFile

#define TIFFSeekFile (   tif,
  off,
  whence 
)     ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence)))

Definition at line 282 of file tiffiop.h.

◆ TIFFUnmapFileContents

#define TIFFUnmapFileContents (   tif,
  addr,
  size 
)     ((*(tif)->tif_unmapproc)((tif)->tif_clientdata, (addr), (size)))

Definition at line 288 of file tiffiop.h.

◆ TIFFWriteFile

#define TIFFWriteFile (   tif,
  buf,
  size 
)     ((*(tif)->tif_writeproc)((tif)->tif_clientdata, (buf), (size)))

Definition at line 280 of file tiffiop.h.

◆ TRUE

#define TRUE   1

Definition at line 70 of file tiffiop.h.

◆ WriteOK

#define WriteOK (   tif,
  buf,
  size 
)    (TIFFWriteFile((tif), (buf), (size)) == (size))

Definition at line 301 of file tiffiop.h.

Typedef Documentation

◆ tidata_t

Definition at line 86 of file tiffiop.h.

◆ tidataval_t

Definition at line 85 of file tiffiop.h.

◆ TIFFBoolMethod

typedef int(* TIFFBoolMethod) (TIFF *)

Definition at line 89 of file tiffiop.h.

◆ TIFFClientInfoLink

◆ TIFFCodeMethod

typedef int(* TIFFCodeMethod) (TIFF *tif, uint8_t *buf, tmsize_t size, uint16_t sample)

Definition at line 91 of file tiffiop.h.

◆ TIFFIOSize_t

Definition at line 374 of file tiffiop.h.

◆ TIFFOffsetAndDirNumber

Definition at line 103 of file tiffiop.h.

◆ TIFFPostMethod

typedef void(* TIFFPostMethod) (TIFF *tif, uint8_t *buf, tmsize_t size)

Definition at line 94 of file tiffiop.h.

◆ TIFFPreMethod

typedef int(* TIFFPreMethod) (TIFF *, uint16_t)

Definition at line 90 of file tiffiop.h.

◆ TIFFSeekMethod

typedef int(* TIFFSeekMethod) (TIFF *, uint32_t)

Definition at line 93 of file tiffiop.h.

◆ TIFFStripMethod

typedef uint32_t(* TIFFStripMethod) (TIFF *, uint32_t)

Definition at line 95 of file tiffiop.h.

◆ TIFFTileMethod

typedef void(* TIFFTileMethod) (TIFF *, uint32_t *, uint32_t *)

Definition at line 96 of file tiffiop.h.

◆ TIFFVoidMethod

typedef void(* TIFFVoidMethod) (TIFF *)

Definition at line 88 of file tiffiop.h.

Function Documentation

◆ _TIFFcallocExt()

void * _TIFFcallocExt ( TIFF tif,
tmsize_t  nmemb,
tmsize_t  siz 
)

calloc() version that takes into account memory-specific open options

Definition at line 201 of file tif_open.c.

202{
203 if (nmemb <= 0 || siz <= 0 || nmemb > TIFF_TMSIZE_T_MAX / siz)
204 return NULL;
205 if (tif != NULL && tif->tif_max_single_mem_alloc > 0)
206 {
207 if (nmemb * siz > tif->tif_max_single_mem_alloc)
208 {
209 _TIFFEmitErrorAboveMaxSingleMemAlloc(tif, "_TIFFcallocExt",
210 nmemb * siz);
211 return NULL;
212 }
213 }
214 if (tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
215 {
216 const tmsize_t s = nmemb * siz;
217 if (s > tif->tif_max_cumulated_mem_alloc -
220 {
221 _TIFFEmitErrorAboveMaxCumulatedMemAlloc(tif, "_TIFFcallocExt", s);
222 return NULL;
223 }
225 if (!ptr)
226 return NULL;
228 memcpy(ptr, &s, sizeof(s));
229 return (char *)ptr + LEADING_AREA_TO_STORE_ALLOC_SIZE;
230 }
231 return _TIFFcalloc(nmemb, siz);
232}
#define NULL
Definition: types.h:112
GLdouble s
Definition: gl.h:2039
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
tmsize_t tif_max_single_mem_alloc
Definition: tiffiop.h:255
tmsize_t tif_cur_cumulated_mem_alloc
Definition: tiffiop.h:257
tmsize_t tif_max_cumulated_mem_alloc
Definition: tiffiop.h:256
static void _TIFFEmitErrorAboveMaxCumulatedMemAlloc(TIFF *tif, const char *pszFunction, tmsize_t s)
Definition: tif_open.c:148
static void _TIFFEmitErrorAboveMaxSingleMemAlloc(TIFF *tif, const char *pszFunction, tmsize_t s)
Definition: tif_open.c:137
#define LEADING_AREA_TO_STORE_ALLOC_SIZE
Definition: tif_open.c:170
void * _TIFFcalloc(tmsize_t nmemb, tmsize_t siz)
Definition: tif_unix.c:341
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:67
#define TIFF_TMSIZE_T_MAX
Definition: tiffio.h:68

Referenced by TIFFReadBufferSetup(), and TIFFReadDirectory().

◆ _TIFFCastUInt64ToSSize()

tmsize_t _TIFFCastUInt64ToSSize ( TIFF tif,
uint64_t  val,
const char module 
)

Definition at line 84 of file tif_aux.c.

85{
87 {
88 if (tif != NULL && module != NULL)
89 {
90 TIFFErrorExtR(tif, module, "Integer overflow");
91 }
92 return 0;
93 }
94 return (tmsize_t)val;
95}
UINT64 uint64_t
Definition: types.h:77
GLuint GLfloat * val
Definition: glext.h:7180
void TIFFErrorExtR(TIFF *tif, const char *module, const char *fmt,...)
Definition: tif_error.c:107

Referenced by TIFFRasterScanlineSize(), TIFFReadRawStrip(), TIFFReadRawTile(), TIFFScanlineSize(), TIFFStripSize(), TIFFTileRowSize(), TIFFTileSize(), TIFFVStripSize(), and TIFFVTileSize().

◆ _TIFFCheckMalloc()

void * _TIFFCheckMalloc ( TIFF tif,
tmsize_t  nmemb,
tmsize_t  elem_size,
const char what 
)

Definition at line 122 of file tif_aux.c.

124{
125 return _TIFFCheckRealloc(tif, NULL, nmemb, elem_size, what);
126}
void * _TIFFCheckRealloc(TIFF *tif, void *buffer, tmsize_t nmemb, tmsize_t elem_size, const char *what)
Definition: tif_aux.c:97

Referenced by _TIFFMergeFields(), _TIFFRewriteField(), _TIFFVSetField(), allocChoppedUpStripArrays(), EstimateStripByteCounts(), TIFFFetchDirectory(), TIFFFetchStripThing(), TIFFMergeFieldInfo(), TIFFReadDirEntryArrayWithLimit(), and TIFFSetupStrips().

◆ _TIFFCheckRealloc()

void * _TIFFCheckRealloc ( TIFF tif,
void buffer,
tmsize_t  nmemb,
tmsize_t  elem_size,
const char what 
)

Definition at line 97 of file tif_aux.c.

99{
100 void *cp = NULL;
101 tmsize_t count = _TIFFMultiplySSize(tif, nmemb, elem_size, NULL);
102 /*
103 * Check for integer overflow.
104 */
105 if (count != 0)
106 {
108 }
109
110 if (cp == NULL)
111 {
112 TIFFErrorExtR(tif, tif->tif_name,
113 "Failed to allocate memory for %s "
114 "(%" TIFF_SSIZE_FORMAT " elements of %" TIFF_SSIZE_FORMAT
115 " bytes each)",
116 what, nmemb, elem_size);
117 }
118
119 return cp;
120}
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
POINT cp
Definition: magnifier.c:59
char * tif_name
Definition: tiffiop.h:114
tmsize_t _TIFFMultiplySSize(TIFF *tif, tmsize_t first, tmsize_t second, const char *where)
Definition: tif_aux.c:59
#define TIFF_SSIZE_FORMAT
Definition: tif_config.h:176
void * _TIFFreallocExt(TIFF *tif, void *p, tmsize_t s)
Definition: tif_open.c:235

Referenced by _TIFFCheckMalloc(), _TIFFMergeFields(), and TIFFMergeFieldInfo().

◆ _TIFFClampDoubleToFloat()

float _TIFFClampDoubleToFloat ( double  val)

Definition at line 391 of file tif_aux.c.

392{
393 if (val > FLT_MAX)
394 return FLT_MAX;
395 if (val < -FLT_MAX)
396 return -FLT_MAX;
397 return (float)val;
398}
#define FLT_MAX
Definition: float.h:37

Referenced by _TIFFVSetField(), and TIFFWriteDirectoryTagSampleformatArray().

◆ _TIFFClampDoubleToUInt32()

uint32_t _TIFFClampDoubleToUInt32 ( double  val)

Definition at line 400 of file tif_aux.c.

401{
402 if (val < 0)
403 return 0;
404 if (val > 0xFFFFFFFFU || val != val)
405 return 0xFFFFFFFFU;
406 return (uint32_t)val;
407}

◆ _TIFFCleanupIFDOffsetAndNumberMaps()

void _TIFFCleanupIFDOffsetAndNumberMaps ( TIFF tif)

Definition at line 127 of file tif_close.c.

128{
130 {
133 }
135 {
138 }
139}
TIFFHashSet * tif_map_dir_number_to_offset
Definition: tiffiop.h:154
TIFFHashSet * tif_map_dir_offset_to_number
Definition: tiffiop.h:153
void TIFFHashSetDestroy(TIFFHashSet *set)
Definition: tif_hash_set.c:285

Referenced by TIFFCleanup(), TIFFCreateCustomDirectory(), TIFFSetDirectory(), TIFFSetSubDirectory(), and TIFFUnlinkDirectory().

◆ _TIFFDefaultStripSize()

uint32_t _TIFFDefaultStripSize ( TIFF tif,
uint32_t  s 
)

Definition at line 223 of file tif_strip.c.

224{
225 if ((int32_t)s < 1)
226 {
227 /*
228 * If RowsPerStrip is unspecified, try to break the
229 * image up into strips that are approximately
230 * STRIP_SIZE_DEFAULT bytes long.
231 */
232 uint64_t scanlinesize;
233 uint64_t rows;
234 scanlinesize = TIFFScanlineSize64(tif);
235 if (scanlinesize == 0)
236 scanlinesize = 1;
237 rows = (uint64_t)STRIP_SIZE_DEFAULT / scanlinesize;
238 if (rows == 0)
239 rows = 1;
240 else if (rows > 0xFFFFFFFF)
241 rows = 0xFFFFFFFF;
242 s = (uint32_t)rows;
243 }
244 return (s);
245}
INT32 int32_t
Definition: types.h:71
#define uint64_t
Definition: nsiface.idl:62
#define STRIP_SIZE_DEFAULT
Definition: tif_config.h:127
uint64_t TIFFScanlineSize64(TIFF *tif)
Definition: tif_strip.c:257

Referenced by _TIFFSetDefaultCompressionState().

◆ _TIFFDefaultTileSize()

void _TIFFDefaultTileSize ( TIFF tif,
uint32_t tw,
uint32_t th 
)

Definition at line 272 of file tif_tile.c.

273{
274 (void)tif;
275 if (*(int32_t *)tw < 1)
276 *tw = 256;
277 if (*(int32_t *)th < 1)
278 *th = 256;
279 /* roundup to a multiple of 16 per the spec */
280 if (*tw & 0xf)
281 *tw = TIFFroundup_32(*tw, 16);
282 if (*th & 0xf)
283 *th = TIFFroundup_32(*th, 16);
284}
#define TIFFroundup_32(x, y)
Definition: tiffiop.h:316

Referenced by _TIFFSetDefaultCompressionState().

◆ _tiffDummyMapProc()

int _tiffDummyMapProc ( thandle_t  fd,
void **  pbase,
toff_t psize 
)

Definition at line 40 of file tif_open.c.

41{
42 (void)fd;
43 (void)pbase;
44 (void)psize;
45 return (0);
46}
_Must_inspect_result_ _Out_ LPSIZE psize
Definition: ntgdi.h:1569
static int fd
Definition: io.c:51

Referenced by TIFFClientOpenExt(), and TIFFFdOpenExt().

◆ _tiffDummyUnmapProc()

void _tiffDummyUnmapProc ( thandle_t  fd,
void base,
toff_t  size 
)

Definition at line 48 of file tif_open.c.

49{
50 (void)fd;
51 (void)base;
52 (void)size;
53}
GLsizeiptr size
Definition: glext.h:5919

Referenced by TIFFClientOpenExt(), and TIFFFdOpenExt().

◆ _TIFFErrorEarly()

void _TIFFErrorEarly ( TIFFOpenOptions opts,
thandle_t  clientdata,
const char module,
const char fmt,
  ... 
)

◆ _TIFFfreeExt()

void _TIFFfreeExt ( TIFF tif,
void p 
)

free() version that takes into account memory-specific open options

Definition at line 275 of file tif_open.c.

276{
277 if (p != NULL && tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
278 {
279 void *oldPtr = (char *)p - LEADING_AREA_TO_STORE_ALLOC_SIZE;
280 tmsize_t oldSize;
281 memcpy(&oldSize, oldPtr, sizeof(oldSize));
282 assert(oldSize <= tif->tif_cur_cumulated_mem_alloc);
283 tif->tif_cur_cumulated_mem_alloc -= oldSize;
284 p = oldPtr;
285 }
286 _TIFFfree(p);
287}
#define assert(_expr)
Definition: assert.h:32
GLfloat GLfloat p
Definition: glext.h:8902
void _TIFFfree(void *p)
Definition: tif_unix.c:349

Referenced by _TIFFCreateAnonField(), _TIFFFetchStrileValue(), _TIFFFillStrilesInternal(), _TIFFRewriteField(), _TIFFSetupFields(), _TIFFVSetField(), allocChoppedUpStripArrays(), EstimateStripByteCounts(), fpAcc(), fpDiff(), gtStripContig(), gtStripSeparate(), gtTileContig(), gtTileSeparate(), initCIELabConversion(), PredictorEncodeRow(), PredictorEncodeTile(), setByteArray(), setDoubleArrayOneValue(), setExtraSamples(), setupMap(), TIFFAppendToStrip(), TIFFCleanup(), TIFFClientOpenExt(), TIFFDefaultDirectory(), TIFFDefaultTransferFunction(), TIFFFetchDirectory(), TIFFFetchNormalTag(), TIFFFetchStripThing(), TIFFFillStrip(), TIFFFillTile(), TIFFFreeDirectory(), TIFFGetConfiguredCODECs(), TIFFGrowStrips(), TIFFPrintDirectory(), TIFFReadAndRealloc(), TIFFReadBufferSetup(), TIFFReadCustomDirectory(), TIFFReadDirectory(), TIFFReadDirEntryArrayWithLimit(), TIFFReadDirEntryByteArray(), TIFFReadDirEntryDoubleArray(), TIFFReadDirEntryFloatArray(), TIFFReadDirEntryIfd8Array(), TIFFReadDirEntryLong8ArrayWithLimit(), TIFFReadDirEntryLongArray(), TIFFReadDirEntryPersampleShort(), TIFFReadDirEntrySbyteArray(), TIFFReadDirEntryShortArray(), TIFFReadDirEntrySlong8Array(), TIFFReadDirEntrySlongArray(), TIFFReadDirEntrySshortArray(), TIFFRGBAImageEnd(), TIFFSetupStrips(), TIFFUnlinkDirectory(), TIFFUnRegisterCODEC(), TIFFUnsetField(), TIFFWriteBufferSetup(), TIFFWriteDirectorySec(), TIFFWriteDirectoryTagCheckedRationalArray(), TIFFWriteDirectoryTagCheckedRationalDoubleArray(), TIFFWriteDirectoryTagCheckedSrationalArray(), TIFFWriteDirectoryTagCheckedSrationalDoubleArray(), TIFFWriteDirectoryTagColormap(), TIFFWriteDirectoryTagIfdIfd8Array(), TIFFWriteDirectoryTagLong8Array(), TIFFWriteDirectoryTagLongLong8Array(), TIFFWriteDirectoryTagSampleformatArray(), TIFFWriteDirectoryTagShortPerSample(), TIFFWriteDirectoryTagSlong8Array(), TIFFWriteDirectoryTagSubifd(), and TIFFWriteDirectoryTagTransferfunction().

◆ _TIFFgetMode()

int _TIFFgetMode ( TIFFOpenOptions opts,
thandle_t  clientdata,
const char mode,
const char module 
)

Definition at line 55 of file tif_open.c.

57{
58 int m = -1;
59
60 switch (mode[0])
61 {
62 case 'r':
63 m = O_RDONLY;
64 if (mode[1] == '+')
65 m = O_RDWR;
66 break;
67 case 'w':
68 case 'a':
69 m = O_RDWR | O_CREAT;
70 if (mode[0] == 'w')
71 m |= O_TRUNC;
72 break;
73 default:
74 _TIFFErrorEarly(opts, clientdata, module, "\"%s\": Bad mode", mode);
75 break;
76 }
77 return (m);
78}
#define O_CREAT
Definition: fcntl.h:43
#define O_RDONLY
Definition: fcntl.h:34
#define O_RDWR
Definition: fcntl.h:36
#define O_TRUNC
Definition: fcntl.h:44
GLenum mode
Definition: glext.h:6217
void _TIFFErrorEarly(TIFFOpenOptions *opts, thandle_t clientdata, const char *module, const char *fmt,...)
Definition: tif_error.c:80

Referenced by TIFFClientOpenExt(), TIFFOpenExt(), and TIFFOpenWExt().

◆ _TIFFmallocExt()

void * _TIFFmallocExt ( TIFF tif,
tmsize_t  s 
)

malloc() version that takes into account memory-specific open options

Definition at line 173 of file tif_open.c.

174{
175 if (tif != NULL && tif->tif_max_single_mem_alloc > 0 &&
177 {
178 _TIFFEmitErrorAboveMaxSingleMemAlloc(tif, "_TIFFmallocExt", s);
179 return NULL;
180 }
181 if (tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
182 {
183 if (s > tif->tif_max_cumulated_mem_alloc -
186 {
187 _TIFFEmitErrorAboveMaxCumulatedMemAlloc(tif, "_TIFFmallocExt", s);
188 return NULL;
189 }
191 if (!ptr)
192 return NULL;
194 memcpy(ptr, &s, sizeof(s));
195 return (char *)ptr + LEADING_AREA_TO_STORE_ALLOC_SIZE;
196 }
197 return _TIFFmalloc(s);
198}
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:333

Referenced by _TIFFCreateAnonField(), _TIFFReadEncodedStripAndAllocBuffer(), _TIFFReadEncodedTileAndAllocBuffer(), BuildMapBitdepth16To8(), BuildMapUaToAa(), fpAcc(), fpDiff(), initCIELabConversion(), initYCbCrConversion(), makebwmap(), makecmap(), PredictorEncodeRow(), PredictorEncodeTile(), setByteArray(), setDoubleArrayOneValue(), setupMap(), TIFFAppendToStrip(), TIFFClientOpenExt(), TIFFDefaultRefBlackWhite(), TIFFDefaultTransferFunction(), TIFFFetchNormalTag(), TIFFPrintDirectory(), TIFFReadCustomDirectory(), TIFFReadDirectory(), TIFFReadDirEntryByteArray(), TIFFReadDirEntryDoubleArray(), TIFFReadDirEntryFloatArray(), TIFFReadDirEntryIfd8Array(), TIFFReadDirEntryLong8ArrayWithLimit(), TIFFReadDirEntryLongArray(), TIFFReadDirEntrySbyteArray(), TIFFReadDirEntryShortArray(), TIFFReadDirEntrySlong8Array(), TIFFReadDirEntrySlongArray(), TIFFReadDirEntrySshortArray(), TIFFRegisterCODEC(), TIFFRGBAImageBegin(), TIFFSetClientInfo(), TIFFWriteBufferSetup(), TIFFWriteDirectorySec(), TIFFWriteDirectoryTagCheckedRationalArray(), TIFFWriteDirectoryTagCheckedRationalDoubleArray(), TIFFWriteDirectoryTagCheckedSrationalArray(), TIFFWriteDirectoryTagCheckedSrationalDoubleArray(), TIFFWriteDirectoryTagColormap(), TIFFWriteDirectoryTagIfdIfd8Array(), TIFFWriteDirectoryTagLong8Array(), TIFFWriteDirectoryTagLongLong8Array(), TIFFWriteDirectoryTagSampleformatArray(), TIFFWriteDirectoryTagShortPerSample(), TIFFWriteDirectoryTagSlong8Array(), TIFFWriteDirectoryTagSubifd(), and TIFFWriteDirectoryTagTransferfunction().

◆ _TIFFMultiply32()

void uint32_t _TIFFMultiply32 ( TIFF tif,
uint32_t  first,
uint32_t  second,
const char where 
)

Definition at line 35 of file tif_aux.c.

37{
38 if (second && first > UINT32_MAX / second)
39 {
40 TIFFErrorExtR(tif, where, "Integer overflow in %s", where);
41 return 0;
42 }
43
44 return first * second;
45}
#define UINT32_MAX
Definition: stdint.h:85
const GLint * first
Definition: glext.h:5794

Referenced by TIFFNumberOfStrips(), and TIFFNumberOfTiles().

◆ _TIFFMultiply64()

uint64_t _TIFFMultiply64 ( TIFF tif,
uint64_t  first,
uint64_t  second,
const char where 
)

Definition at line 47 of file tif_aux.c.

49{
50 if (second && first > UINT64_MAX / second)
51 {
52 TIFFErrorExtR(tif, where, "Integer overflow in %s", where);
53 return 0;
54 }
55
56 return first * second;
57}
#define UINT64_MAX
Definition: stdint.h:86

Referenced by TIFFRasterScanlineSize64(), TIFFScanlineSize64(), TIFFTileRowSize64(), TIFFVStripSize64(), and TIFFVTileSize64().

◆ _TIFFMultiplySSize()

tmsize_t _TIFFMultiplySSize ( TIFF tif,
tmsize_t  first,
tmsize_t  second,
const char where 
)

Definition at line 59 of file tif_aux.c.

61{
62 if (first <= 0 || second <= 0)
63 {
64 if (tif != NULL && where != NULL)
65 {
66 TIFFErrorExtR(tif, where,
67 "Invalid argument to _TIFFMultiplySSize() in %s",
68 where);
69 }
70 return 0;
71 }
72
73 if (first > TIFF_TMSIZE_T_MAX / second)
74 {
75 if (tif != NULL && where != NULL)
76 {
77 TIFFErrorExtR(tif, where, "Integer overflow in %s", where);
78 }
79 return 0;
80 }
81 return first * second;
82}

Referenced by _TIFFCheckRealloc(), gtStripSeparate(), gtTileSeparate(), and setByteArray().

◆ _TIFFNoPostDecode()

void _TIFFNoPostDecode ( TIFF tif,
uint8_t buf,
tmsize_t  cc 
)

Definition at line 1648 of file tif_read.c.

1649{
1650 (void)tif;
1651 (void)buf;
1652 (void)cc;
1653}
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
uint32_t cc
Definition: isohybrid.c:75

Referenced by _TIFFVSetField(), PredictorSetupDecode(), PredictorSetupEncode(), and TIFFDefaultDirectory().

◆ _TIFFNoPreCode()

int _TIFFNoPreCode ( TIFF tif,
uint16_t  s 
)

Definition at line 128 of file tif_compress.c.

129{
130 (void)tif;
131 (void)s;
132 return (1);
133}

Referenced by _TIFFSetDefaultCompressionState().

◆ _TIFFNoRowDecode()

int _TIFFNoRowDecode ( TIFF tif,
uint8_t pp,
tmsize_t  cc,
uint16_t  s 
)

Definition at line 96 of file tif_compress.c.

97{
98 (void)pp;
99 (void)cc;
100 (void)s;
101 return (TIFFNoDecode(tif, "scanline"));
102}
static int TIFFNoDecode(TIFF *tif, const char *method)
Definition: tif_compress.c:75

Referenced by _TIFFSetDefaultCompressionState().

◆ _TIFFNoRowEncode()

int _TIFFNoRowEncode ( TIFF tif,
uint8_t pp,
tmsize_t  cc,
uint16_t  s 
)

Definition at line 51 of file tif_compress.c.

52{
53 (void)pp;
54 (void)cc;
55 (void)s;
56 return (TIFFNoEncode(tif, "scanline"));
57}
static int TIFFNoEncode(TIFF *tif, const char *method)
Definition: tif_compress.c:32

Referenced by _TIFFSetDefaultCompressionState().

◆ _TIFFNoSeek()

int _TIFFNoSeek ( TIFF tif,
uint32_t  off 
)

Definition at line 120 of file tif_compress.c.

121{
122 (void)off;
123 TIFFErrorExtR(tif, tif->tif_name,
124 "Compression algorithm does not support random access");
125 return (0);
126}

Referenced by _TIFFSetDefaultCompressionState().

◆ _TIFFNoStripDecode()

int _TIFFNoStripDecode ( TIFF tif,
uint8_t pp,
tmsize_t  cc,
uint16_t  s 
)

Definition at line 104 of file tif_compress.c.

105{
106 (void)pp;
107 (void)cc;
108 (void)s;
109 return (TIFFNoDecode(tif, "strip"));
110}

Referenced by _TIFFSetDefaultCompressionState().

◆ _TIFFNoStripEncode()

int _TIFFNoStripEncode ( TIFF tif,
uint8_t pp,
tmsize_t  cc,
uint16_t  s 
)

Definition at line 59 of file tif_compress.c.

60{
61 (void)pp;
62 (void)cc;
63 (void)s;
64 return (TIFFNoEncode(tif, "strip"));
65}

Referenced by _TIFFSetDefaultCompressionState().

◆ _TIFFNoTileDecode()

int _TIFFNoTileDecode ( TIFF tif,
uint8_t pp,
tmsize_t  cc,
uint16_t  s 
)

Definition at line 112 of file tif_compress.c.

113{
114 (void)pp;
115 (void)cc;
116 (void)s;
117 return (TIFFNoDecode(tif, "tile"));
118}

Referenced by _TIFFSetDefaultCompressionState().

◆ _TIFFNoTileEncode()

int _TIFFNoTileEncode ( TIFF tif,
uint8_t pp,
tmsize_t  cc,
uint16_t  s 
)

Definition at line 67 of file tif_compress.c.

68{
69 (void)pp;
70 (void)cc;
71 (void)s;
72 return (TIFFNoEncode(tif, "tile"));
73}

Referenced by _TIFFSetDefaultCompressionState().

◆ _TIFFprintAscii()

void _TIFFprintAscii ( FILE fd,
const char cp 
)

Definition at line 725 of file tif_print.c.

726{
728}
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
static void _TIFFprintAsciiBounded(FILE *fd, const char *cp, size_t max_chars)
Definition: tif_print.c:730

Referenced by _TIFFprintAsciiTag().

◆ _TIFFprintAsciiTag()

void _TIFFprintAsciiTag ( FILE fd,
const char name,
const char value 
)

Definition at line 751 of file tif_print.c.

752{
753 fprintf(fd, " %s: \"", name);
755 fprintf(fd, "\"\n");
756}
int WINAPIV fprintf(FILE *file, const char *format,...)
Definition: file.c:5549
Definition: name.c:39
void _TIFFprintAscii(FILE *fd, const char *cp)
Definition: tif_print.c:725
Definition: pdh_main.c:96

◆ _TIFFReadEncodedStripAndAllocBuffer()

tmsize_t _TIFFReadEncodedStripAndAllocBuffer ( TIFF tif,
uint32_t  strip,
void **  buf,
tmsize_t  bufsizetoalloc,
tmsize_t  size_to_read 
)

Definition at line 584 of file tif_read.c.

588{
589 tmsize_t this_stripsize;
591
592 if (*buf != NULL)
593 {
594 return TIFFReadEncodedStrip(tif, strip, *buf, size_to_read);
595 }
596
597 this_stripsize = TIFFReadEncodedStripGetStripSize(tif, strip, &plane);
598 if (this_stripsize == ((tmsize_t)(-1)))
599 return ((tmsize_t)(-1));
600
601 if ((size_to_read != (tmsize_t)(-1)) && (size_to_read < this_stripsize))
602 this_stripsize = size_to_read;
603 if (!TIFFFillStrip(tif, strip))
604 return ((tmsize_t)(-1));
605
606 *buf = _TIFFmallocExt(tif, bufsizetoalloc);
607 if (*buf == NULL)
608 {
609 TIFFErrorExtR(tif, TIFFFileName(tif), "No space for strip buffer");
610 return ((tmsize_t)(-1));
611 }
612 _TIFFmemset(*buf, 0, bufsizetoalloc);
613
614 if ((*tif->tif_decodestrip)(tif, *buf, this_stripsize, plane) <= 0)
615 return ((tmsize_t)(-1));
616 (*tif->tif_postdecode)(tif, *buf, this_stripsize);
617 return (this_stripsize);
618}
unsigned short uint16_t
Definition: stdint.h:35
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum GLint const GLfloat GLenum GLint const GLushort GLint GLint GLsizei GLsizei GLenum GLsizei GLsizei GLenum GLenum const GLvoid GLenum plane
Definition: glfuncs.h:270
TIFFCodeMethod tif_decodestrip
Definition: tiffiop.h:207
TIFFPostMethod tif_postdecode
Definition: tiffiop.h:239
const char * TIFFFileName(TIFF *tif)
Definition: tif_open.c:798
void * _TIFFmallocExt(TIFF *tif, tmsize_t s)
Definition: tif_open.c:173
static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF *tif, uint32_t strip, uint16_t *pplane)
Definition: tif_read.c:488
tmsize_t TIFFReadEncodedStrip(TIFF *tif, uint32_t strip, void *buf, tmsize_t size)
Definition: tif_read.c:534
int TIFFFillStrip(TIFF *tif, uint32_t strip)
Definition: tif_read.c:759
void _TIFFmemset(void *p, int v, tmsize_t c)
Definition: tif_unix.c:353

Referenced by gtStripContig(), and gtStripSeparate().

◆ _TIFFReadEncodedTileAndAllocBuffer()

tmsize_t _TIFFReadEncodedTileAndAllocBuffer ( TIFF tif,
uint32_t  tile,
void **  buf,
tmsize_t  bufsizetoalloc,
tmsize_t  size_to_read 
)

Definition at line 1029 of file tif_read.c.

1032{
1033 static const char module[] = "_TIFFReadEncodedTileAndAllocBuffer";
1034 TIFFDirectory *td = &tif->tif_dir;
1035 tmsize_t tilesize = tif->tif_tilesize;
1036
1037 if (*buf != NULL)
1038 {
1039 return TIFFReadEncodedTile(tif, tile, *buf, size_to_read);
1040 }
1041
1042 if (!TIFFCheckRead(tif, 1))
1043 return ((tmsize_t)(-1));
1044 if (tile >= td->td_nstrips)
1045 {
1046 TIFFErrorExtR(tif, module,
1047 "%" PRIu32 ": Tile out of range, max %" PRIu32, tile,
1048 td->td_nstrips);
1049 return ((tmsize_t)(-1));
1050 }
1051
1052 if (!TIFFFillTile(tif, tile))
1053 return ((tmsize_t)(-1));
1054
1055 /* Sanity checks to avoid excessive memory allocation */
1056 /* Cf https://gitlab.com/libtiff/libtiff/-/issues/479 */
1058 {
1059 if (tif->tif_rawdatasize != tilesize)
1060 {
1061 TIFFErrorExtR(tif, TIFFFileName(tif),
1062 "Invalid tile byte count for tile %u. "
1063 "Expected %" PRIu64 ", got %" PRIu64,
1064 tile, (uint64_t)tilesize,
1066 return ((tmsize_t)(-1));
1067 }
1068 }
1069 else
1070 {
1071 /* Max compression ratio experimentally determined. Might be fragile...
1072 * Only apply this heuristics to situations where the memory allocation
1073 * would be big, to avoid breaking nominal use cases.
1074 */
1075 const int maxCompressionRatio =
1076 td->td_compression == COMPRESSION_ZSTD ? 33000
1078 ?
1079 /* Evaluated on a 8000x8000 tile */
1080 25000 * (td->td_planarconfig == PLANARCONFIG_CONTIG
1081 ? td->td_samplesperpixel
1082 : 1)
1083 : td->td_compression == COMPRESSION_LZMA ? 7000 : 1000;
1084 if (bufsizetoalloc > 100 * 1000 * 1000 &&
1085 tif->tif_rawdatasize < tilesize / maxCompressionRatio)
1086 {
1087 TIFFErrorExtR(tif, TIFFFileName(tif),
1088 "Likely invalid tile byte count for tile %u. "
1089 "Uncompressed tile size is %" PRIu64 ", "
1090 "compressed one is %" PRIu64,
1091 tile, (uint64_t)tilesize,
1093 return ((tmsize_t)(-1));
1094 }
1095 }
1096
1097 *buf = _TIFFmallocExt(tif, bufsizetoalloc);
1098 if (*buf == NULL)
1099 {
1100 TIFFErrorExtR(tif, TIFFFileName(tif), "No space for tile buffer");
1101 return ((tmsize_t)(-1));
1102 }
1103 _TIFFmemset(*buf, 0, bufsizetoalloc);
1104
1105 if (size_to_read == (tmsize_t)(-1))
1106 size_to_read = tilesize;
1107 else if (size_to_read > tilesize)
1108 size_to_read = tilesize;
1109 if ((*tif->tif_decodetile)(tif, (uint8_t *)*buf, size_to_read,
1110 (uint16_t)(tile / td->td_stripsperimage)))
1111 {
1112 (*tif->tif_postdecode)(tif, (uint8_t *)*buf, size_to_read);
1113 return (size_to_read);
1114 }
1115 else
1116 return ((tmsize_t)(-1));
1117}
#define PRIu32
Definition: inttypes.h:84
#define PRIu64
Definition: inttypes.h:28
unsigned char uint8_t
Definition: stdint.h:33
if(dx< 0)
Definition: linetemp.h:194
uint16_t td_compression
Definition: tif_dir.h:88
uint32_t td_stripsperimage
Definition: tif_dir.h:110
uint16_t td_planarconfig
Definition: tif_dir.h:100
uint16_t td_samplesperpixel
Definition: tif_dir.h:93
uint32_t td_nstrips
Definition: tif_dir.h:111
TIFFDirectory tif_dir
Definition: tiffiop.h:157
tmsize_t tif_rawdatasize
Definition: tiffiop.h:221
tmsize_t tif_tilesize
Definition: tiffiop.h:195
TIFFCodeMethod tif_decodetile
Definition: tiffiop.h:209
static int TIFFCheckRead(TIFF *, int)
Definition: tif_read.c:1519
int TIFFFillTile(TIFF *tif, uint32_t tile)
Definition: tif_read.c:1215
tmsize_t TIFFReadEncodedTile(TIFF *tif, uint32_t tile, void *buf, tmsize_t size)
Definition: tif_read.c:953
#define COMPRESSION_NONE
Definition: tiff.h:182
#define COMPRESSION_ZSTD
Definition: tiff.h:216
#define COMPRESSION_JXL
Definition: tiff.h:218
#define COMPRESSION_LZMA
Definition: tiff.h:215
#define PLANARCONFIG_CONTIG
Definition: tiff.h:265

Referenced by _TIFFReadTileAndAllocBuffer().

◆ _TIFFReadTileAndAllocBuffer()

tmsize_t _TIFFReadTileAndAllocBuffer ( TIFF tif,
void **  buf,
tmsize_t  bufsizetoalloc,
uint32_t  x,
uint32_t  y,
uint32_t  z,
uint16_t  s 
)

Definition at line 1012 of file tif_read.c.

1015{
1016 if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s))
1017 return ((tmsize_t)(-1));
1019 tif, TIFFComputeTile(tif, x, y, z, s), buf, bufsizetoalloc,
1020 (tmsize_t)(-1)));
1021}
GLdouble GLdouble z
Definition: glext.h:5874
tmsize_t _TIFFReadEncodedTileAndAllocBuffer(TIFF *tif, uint32_t tile, void **buf, tmsize_t bufsizetoalloc, tmsize_t size_to_read)
Definition: tif_read.c:1029
uint32_t TIFFComputeTile(TIFF *tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s)
Definition: tif_tile.c:35
int TIFFCheckTile(TIFF *tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s)
Definition: tif_tile.c:71

Referenced by gtTileContig(), and gtTileSeparate().

◆ _TIFFreallocExt()

void * _TIFFreallocExt ( TIFF tif,
void p,
tmsize_t  s 
)

realloc() version that takes into account memory-specific open options

Definition at line 235 of file tif_open.c.

236{
237 if (tif != NULL && tif->tif_max_single_mem_alloc > 0 &&
239 {
240 _TIFFEmitErrorAboveMaxSingleMemAlloc(tif, "_TIFFreallocExt", s);
241 return NULL;
242 }
243 if (tif != NULL && tif->tif_max_cumulated_mem_alloc > 0)
244 {
245 void *oldPtr = p;
246 tmsize_t oldSize = 0;
247 if (p)
248 {
249 oldPtr = (char *)p - LEADING_AREA_TO_STORE_ALLOC_SIZE;
250 memcpy(&oldSize, oldPtr, sizeof(oldSize));
251 assert(oldSize <= tif->tif_cur_cumulated_mem_alloc);
252 }
253 if (s > oldSize &&
255 (tif->tif_cur_cumulated_mem_alloc - oldSize) ||
257 {
258 _TIFFEmitErrorAboveMaxCumulatedMemAlloc(tif, "_TIFFreallocExt",
259 s - oldSize);
260 return NULL;
261 }
262 void *newPtr =
264 if (newPtr == NULL)
265 return NULL;
266 tif->tif_cur_cumulated_mem_alloc -= oldSize;
268 memcpy(newPtr, &s, sizeof(s));
269 return (char *)newPtr + LEADING_AREA_TO_STORE_ALLOC_SIZE;
270 }
271 return _TIFFrealloc(p, s);
272}
void * _TIFFrealloc(void *p, tmsize_t s)
Definition: tif_unix.c:351

Referenced by _TIFFCheckRealloc(), _TIFFFetchStrileValue(), _TIFFVSetField(), TIFFGetConfiguredCODECs(), TIFFGrowStrips(), TIFFReadAndRealloc(), and TIFFReadDirEntryDataAndRealloc().

◆ _TIFFRewriteField()

int _TIFFRewriteField ( TIFF tif,
uint16_t  tag,
TIFFDataType  in_datatype,
tmsize_t  count,
void data 
)

Definition at line 3377 of file tif_dirwrite.c.

3379{
3380 static const char module[] = "TIFFResetField";
3381 /* const TIFFField* fip = NULL; */
3382 uint16_t dircount;
3383 tmsize_t dirsize;
3384 uint8_t direntry_raw[20];
3385 uint16_t entry_tag = 0;
3386 uint16_t entry_type = 0;
3387 uint64_t entry_count = 0;
3388 uint64_t entry_offset = 0;
3389 int value_in_entry = 0;
3390 uint64_t read_offset;
3391 uint8_t *buf_to_write = NULL;
3392 TIFFDataType datatype;
3393
3394 /* -------------------------------------------------------------------- */
3395 /* Find field definition. */
3396 /* -------------------------------------------------------------------- */
3397 /*fip =*/TIFFFindField(tif, tag, TIFF_ANY);
3398
3399 /* -------------------------------------------------------------------- */
3400 /* Do some checking this is a straight forward case. */
3401 /* -------------------------------------------------------------------- */
3402 if (isMapped(tif))
3403 {
3404 TIFFErrorExtR(tif, module,
3405 "Memory mapped files not currently supported for "
3406 "this operation.");
3407 return 0;
3408 }
3409
3410 if (tif->tif_diroff == 0)
3411 {
3413 tif, module,
3414 "Attempt to reset field on directory not already on disk.");
3415 return 0;
3416 }
3417
3418 /* -------------------------------------------------------------------- */
3419 /* Read the directory entry count. */
3420 /* -------------------------------------------------------------------- */
3421 if (!SeekOK(tif, tif->tif_diroff))
3422 {
3423 TIFFErrorExtR(tif, module, "%s: Seek error accessing TIFF directory",
3424 tif->tif_name);
3425 return 0;
3426 }
3427
3428 read_offset = tif->tif_diroff;
3429
3430 if (!(tif->tif_flags & TIFF_BIGTIFF))
3431 {
3432 if (!ReadOK(tif, &dircount, sizeof(uint16_t)))
3433 {
3434 TIFFErrorExtR(tif, module, "%s: Can not read TIFF directory count",
3435 tif->tif_name);
3436 return 0;
3437 }
3438 if (tif->tif_flags & TIFF_SWAB)
3439 TIFFSwabShort(&dircount);
3440 dirsize = 12;
3441 read_offset += 2;
3442 }
3443 else
3444 {
3445 uint64_t dircount64;
3446 if (!ReadOK(tif, &dircount64, sizeof(uint64_t)))
3447 {
3448 TIFFErrorExtR(tif, module, "%s: Can not read TIFF directory count",
3449 tif->tif_name);
3450 return 0;
3451 }
3452 if (tif->tif_flags & TIFF_SWAB)
3453 TIFFSwabLong8(&dircount64);
3454 dircount = (uint16_t)dircount64;
3455 dirsize = 20;
3456 read_offset += 8;
3457 }
3458
3459 /* -------------------------------------------------------------------- */
3460 /* Read through directory to find target tag. */
3461 /* -------------------------------------------------------------------- */
3462 while (dircount > 0)
3463 {
3464 if (!ReadOK(tif, direntry_raw, dirsize))
3465 {
3466 TIFFErrorExtR(tif, module, "%s: Can not read TIFF directory entry.",
3467 tif->tif_name);
3468 return 0;
3469 }
3470
3471 memcpy(&entry_tag, direntry_raw + 0, sizeof(uint16_t));
3472 if (tif->tif_flags & TIFF_SWAB)
3473 TIFFSwabShort(&entry_tag);
3474
3475 if (entry_tag == tag)
3476 break;
3477
3478 read_offset += dirsize;
3479 }
3480
3481 if (entry_tag != tag)
3482 {
3483 TIFFErrorExtR(tif, module, "%s: Could not find tag %" PRIu16 ".",
3484 tif->tif_name, tag);
3485 return 0;
3486 }
3487
3488 /* -------------------------------------------------------------------- */
3489 /* Extract the type, count and offset for this entry. */
3490 /* -------------------------------------------------------------------- */
3491 memcpy(&entry_type, direntry_raw + 2, sizeof(uint16_t));
3492 if (tif->tif_flags & TIFF_SWAB)
3493 TIFFSwabShort(&entry_type);
3494
3495 if (!(tif->tif_flags & TIFF_BIGTIFF))
3496 {
3498
3499 memcpy(&value, direntry_raw + 4, sizeof(uint32_t));
3500 if (tif->tif_flags & TIFF_SWAB)
3502 entry_count = value;
3503
3504 memcpy(&value, direntry_raw + 8, sizeof(uint32_t));
3505 if (tif->tif_flags & TIFF_SWAB)
3507 entry_offset = value;
3508 }
3509 else
3510 {
3511 memcpy(&entry_count, direntry_raw + 4, sizeof(uint64_t));
3512 if (tif->tif_flags & TIFF_SWAB)
3513 TIFFSwabLong8(&entry_count);
3514
3515 memcpy(&entry_offset, direntry_raw + 12, sizeof(uint64_t));
3516 if (tif->tif_flags & TIFF_SWAB)
3517 TIFFSwabLong8(&entry_offset);
3518 }
3519
3520 /* -------------------------------------------------------------------- */
3521 /* When a dummy tag was written due to TIFFDeferStrileArrayWriting() */
3522 /* -------------------------------------------------------------------- */
3523 if (entry_offset == 0 && entry_count == 0 && entry_type == 0)
3524 {
3526 {
3527 entry_type =
3529 }
3530 else
3531 {
3532 int write_aslong8 = 1;
3533 if (count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS)
3534 {
3535 write_aslong8 = WriteAsLong8(tif, TIFFStripSize64(tif));
3536 }
3537 else if (count > 1 && tag == TIFFTAG_TILEBYTECOUNTS)
3538 {
3539 write_aslong8 = WriteAsLong8(tif, TIFFTileSize64(tif));
3540 }
3541 if (write_aslong8)
3542 {
3543 entry_type = TIFF_LONG8;
3544 }
3545 else
3546 {
3547 int write_aslong4 = 1;
3548 if (count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS)
3549 {
3550 write_aslong4 = WriteAsLong4(tif, TIFFStripSize64(tif));
3551 }
3552 else if (count > 1 && tag == TIFFTAG_TILEBYTECOUNTS)
3553 {
3554 write_aslong4 = WriteAsLong4(tif, TIFFTileSize64(tif));
3555 }
3556 if (write_aslong4)
3557 {
3558 entry_type = TIFF_LONG;
3559 }
3560 else
3561 {
3562 entry_type = TIFF_SHORT;
3563 }
3564 }
3565 }
3566 }
3567
3568 /* -------------------------------------------------------------------- */
3569 /* What data type do we want to write this as? */
3570 /* -------------------------------------------------------------------- */
3571 if (TIFFDataWidth(in_datatype) == 8 && !(tif->tif_flags & TIFF_BIGTIFF))
3572 {
3573 if (in_datatype == TIFF_LONG8)
3574 datatype = entry_type == TIFF_SHORT ? TIFF_SHORT : TIFF_LONG;
3575 else if (in_datatype == TIFF_SLONG8)
3576 datatype = TIFF_SLONG;
3577 else if (in_datatype == TIFF_IFD8)
3578 datatype = TIFF_IFD;
3579 else
3580 datatype = in_datatype;
3581 }
3582 else
3583 {
3584 if (in_datatype == TIFF_LONG8 &&
3585 (entry_type == TIFF_SHORT || entry_type == TIFF_LONG ||
3586 entry_type == TIFF_LONG8))
3587 datatype = entry_type;
3588 else if (in_datatype == TIFF_SLONG8 &&
3589 (entry_type == TIFF_SLONG || entry_type == TIFF_SLONG8))
3590 datatype = entry_type;
3591 else if (in_datatype == TIFF_IFD8 &&
3592 (entry_type == TIFF_IFD || entry_type == TIFF_IFD8))
3593 datatype = entry_type;
3594 else
3595 datatype = in_datatype;
3596 }
3597
3598 /* -------------------------------------------------------------------- */
3599 /* Prepare buffer of actual data to write. This includes */
3600 /* swabbing as needed. */
3601 /* -------------------------------------------------------------------- */
3602 buf_to_write = (uint8_t *)_TIFFCheckMalloc(
3603 tif, count, TIFFDataWidth(datatype), "for field buffer.");
3604 if (!buf_to_write)
3605 return 0;
3606
3607 if (datatype == in_datatype)
3608 memcpy(buf_to_write, data, count * TIFFDataWidth(datatype));
3609 else if (datatype == TIFF_SLONG && in_datatype == TIFF_SLONG8)
3610 {
3611 tmsize_t i;
3612
3613 for (i = 0; i < count; i++)
3614 {
3615 ((int32_t *)buf_to_write)[i] = (int32_t)((int64_t *)data)[i];
3616 if ((int64_t)((int32_t *)buf_to_write)[i] != ((int64_t *)data)[i])
3617 {
3618 _TIFFfreeExt(tif, buf_to_write);
3619 TIFFErrorExtR(tif, module,
3620 "Value exceeds 32bit range of output type.");
3621 return 0;
3622 }
3623 }
3624 }
3625 else if ((datatype == TIFF_LONG && in_datatype == TIFF_LONG8) ||
3626 (datatype == TIFF_IFD && in_datatype == TIFF_IFD8))
3627 {
3628 tmsize_t i;
3629
3630 for (i = 0; i < count; i++)
3631 {
3632 ((uint32_t *)buf_to_write)[i] = (uint32_t)((uint64_t *)data)[i];
3633 if ((uint64_t)((uint32_t *)buf_to_write)[i] !=
3634 ((uint64_t *)data)[i])
3635 {
3636 _TIFFfreeExt(tif, buf_to_write);
3637 TIFFErrorExtR(tif, module,
3638 "Value exceeds 32bit range of output type.");
3639 return 0;
3640 }
3641 }
3642 }
3643 else if (datatype == TIFF_SHORT && in_datatype == TIFF_LONG8)
3644 {
3645 tmsize_t i;
3646
3647 for (i = 0; i < count; i++)
3648 {
3649 ((uint16_t *)buf_to_write)[i] = (uint16_t)((uint64_t *)data)[i];
3650 if ((uint64_t)((uint16_t *)buf_to_write)[i] !=
3651 ((uint64_t *)data)[i])
3652 {
3653 _TIFFfreeExt(tif, buf_to_write);
3654 TIFFErrorExtR(tif, module,
3655 "Value exceeds 16bit range of output type.");
3656 return 0;
3657 }
3658 }
3659 }
3660 else
3661 {
3662 TIFFErrorExtR(tif, module, "Unhandled type conversion.");
3663 return 0;
3664 }
3665
3666 if (TIFFDataWidth(datatype) > 1 && (tif->tif_flags & TIFF_SWAB))
3667 {
3668 if (TIFFDataWidth(datatype) == 2)
3669 TIFFSwabArrayOfShort((uint16_t *)buf_to_write, count);
3670 else if (TIFFDataWidth(datatype) == 4)
3671 TIFFSwabArrayOfLong((uint32_t *)buf_to_write, count);
3672 else if (TIFFDataWidth(datatype) == 8)
3673 TIFFSwabArrayOfLong8((uint64_t *)buf_to_write, count);
3674 }
3675
3676 /* -------------------------------------------------------------------- */
3677 /* Is this a value that fits into the directory entry? */
3678 /* -------------------------------------------------------------------- */
3679 if (!(tif->tif_flags & TIFF_BIGTIFF))
3680 {
3681 if (TIFFDataWidth(datatype) * count <= 4)
3682 {
3683 entry_offset = read_offset + 8;
3684 value_in_entry = 1;
3685 }
3686 }
3687 else
3688 {
3689 if (TIFFDataWidth(datatype) * count <= 8)
3690 {
3691 entry_offset = read_offset + 12;
3692 value_in_entry = 1;
3693 }
3694 }
3695
3700 {
3701 tif->tif_dir.td_stripoffset_entry.tdir_type = datatype;
3703 }
3704 else if ((tag == TIFFTAG_TILEBYTECOUNTS ||
3709 {
3712 }
3713
3714 /* -------------------------------------------------------------------- */
3715 /* If the tag type, and count match, then we just write it out */
3716 /* over the old values without altering the directory entry at */
3717 /* all. */
3718 /* -------------------------------------------------------------------- */
3719 if (entry_count == (uint64_t)count && entry_type == (uint16_t)datatype)
3720 {
3721 if (!SeekOK(tif, entry_offset))
3722 {
3723 _TIFFfreeExt(tif, buf_to_write);
3724 TIFFErrorExtR(tif, module,
3725 "%s: Seek error accessing TIFF directory",
3726 tif->tif_name);
3727 return 0;
3728 }
3729 if (!WriteOK(tif, buf_to_write, count * TIFFDataWidth(datatype)))
3730 {
3731 _TIFFfreeExt(tif, buf_to_write);
3732 TIFFErrorExtR(tif, module, "Error writing directory link");
3733 return (0);
3734 }
3735
3736 _TIFFfreeExt(tif, buf_to_write);
3737 return 1;
3738 }
3739
3740 /* -------------------------------------------------------------------- */
3741 /* Otherwise, we write the new tag data at the end of the file. */
3742 /* -------------------------------------------------------------------- */
3743 if (!value_in_entry)
3744 {
3745 entry_offset = TIFFSeekFile(tif, 0, SEEK_END);
3746
3747 if (!WriteOK(tif, buf_to_write, count * TIFFDataWidth(datatype)))
3748 {
3749 _TIFFfreeExt(tif, buf_to_write);
3750 TIFFErrorExtR(tif, module, "Error writing directory link");
3751 return (0);
3752 }
3753 }
3754 else
3755 {
3756 if (count * TIFFDataWidth(datatype) == 4)
3757 {
3759 memcpy(&value, buf_to_write, count * TIFFDataWidth(datatype));
3760 entry_offset = value;
3761 }
3762 else
3763 {
3764 memcpy(&entry_offset, buf_to_write,
3765 count * TIFFDataWidth(datatype));
3766 }
3767 }
3768
3769 _TIFFfreeExt(tif, buf_to_write);
3770 buf_to_write = 0;
3771
3772 /* -------------------------------------------------------------------- */
3773 /* Adjust the directory entry. */
3774 /* -------------------------------------------------------------------- */
3775 entry_type = datatype;
3776 entry_count = (uint64_t)count;
3777 memcpy(direntry_raw + 2, &entry_type, sizeof(uint16_t));
3778 if (tif->tif_flags & TIFF_SWAB)
3779 TIFFSwabShort((uint16_t *)(direntry_raw + 2));
3780
3781 if (!(tif->tif_flags & TIFF_BIGTIFF))
3782 {
3784
3785 value = (uint32_t)entry_count;
3786 memcpy(direntry_raw + 4, &value, sizeof(uint32_t));
3787 if (tif->tif_flags & TIFF_SWAB)
3788 TIFFSwabLong((uint32_t *)(direntry_raw + 4));
3789
3790 value = (uint32_t)entry_offset;
3791 memcpy(direntry_raw + 8, &value, sizeof(uint32_t));
3792 if (tif->tif_flags & TIFF_SWAB)
3793 TIFFSwabLong((uint32_t *)(direntry_raw + 8));
3794 }
3795 else
3796 {
3797 memcpy(direntry_raw + 4, &entry_count, sizeof(uint64_t));
3798 if (tif->tif_flags & TIFF_SWAB)
3799 TIFFSwabLong8((uint64_t *)(direntry_raw + 4));
3800
3801 memcpy(direntry_raw + 12, &entry_offset, sizeof(uint64_t));
3802 if (tif->tif_flags & TIFF_SWAB)
3803 TIFFSwabLong8((uint64_t *)(direntry_raw + 12));
3804 }
3805
3806 /* -------------------------------------------------------------------- */
3807 /* Write the directory entry out to disk. */
3808 /* -------------------------------------------------------------------- */
3809 if (!SeekOK(tif, read_offset))
3810 {
3811 TIFFErrorExtR(tif, module, "%s: Seek error accessing TIFF directory",
3812 tif->tif_name);
3813 return 0;
3814 }
3815
3816 if (!WriteOK(tif, direntry_raw, dirsize))
3817 {
3818 TIFFErrorExtR(tif, module, "%s: Can not write TIFF directory entry.",
3819 tif->tif_name);
3820 return 0;
3821 }
3822
3823 return 1;
3824}
#define SEEK_END
Definition: cabinet.c:29
INT64 int64_t
Definition: types.h:72
#define PRIu16
Definition: inttypes.h:83
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define int32_t
Definition: nsiface.idl:56
#define uint16_t
Definition: nsiface.idl:60
uint64_t tdir_count
Definition: tif_dir.h:57
uint16_t tdir_type
Definition: tif_dir.h:56
union TIFFDirEntry::@3701 tdir_offset
uint64_t toff_long8
Definition: tif_dir.h:62
TIFFDirEntry td_stripoffset_entry
Definition: tif_dir.h:127
TIFFDirEntry td_stripbytecount_entry
Definition: tif_dir.h:128
Definition: ecma_167.h:138
uint64_t tif_diroff
Definition: tiffiop.h:150
uint32_t tif_flags
Definition: tiffiop.h:117
void * _TIFFCheckMalloc(TIFF *tif, tmsize_t nmemb, tmsize_t elem_size, const char *what)
Definition: tif_aux.c:122
int TIFFDataWidth(TIFFDataType type)
Definition: tif_dirinfo.c:637
const TIFFField * TIFFFindField(TIFF *tif, uint32_t tag, TIFFDataType dt)
Definition: tif_dirinfo.c:795
static int WriteAsLong4(TIFF *tif, uint64_t strile_size)
static int WriteAsLong8(TIFF *tif, uint64_t strile_size)
void _TIFFfreeExt(TIFF *tif, void *p)
Definition: tif_open.c:275
uint64_t TIFFStripSize64(TIFF *tif)
Definition: tif_strip.c:196
void TIFFSwabArrayOfLong(register uint32_t *lp, tmsize_t n)
Definition: tif_swab.c:117
void TIFFSwabLong8(uint64_t *lp)
Definition: tif_swab.c:60
void TIFFSwabShort(uint16_t *wp)
Definition: tif_swab.c:33
void TIFFSwabArrayOfLong8(register uint64_t *lp, tmsize_t n)
Definition: tif_swab.c:138
void TIFFSwabLong(uint32_t *lp)
Definition: tif_swab.c:45
void TIFFSwabArrayOfShort(register uint16_t *wp, tmsize_t n)
Definition: tif_swab.c:81
uint64_t TIFFTileSize64(TIFF *tif)
Definition: tif_tile.c:249
TIFFDataType
Definition: tiff.h:146
@ TIFF_SLONG
Definition: tiff.h:156
@ TIFF_IFD
Definition: tiff.h:160
@ TIFF_SHORT
Definition: tiff.h:150
@ TIFF_LONG
Definition: tiff.h:151
@ TIFF_SLONG8
Definition: tiff.h:162
@ TIFF_LONG8
Definition: tiff.h:161
@ TIFF_IFD8
Definition: tiff.h:163
#define TIFFTAG_TILEBYTECOUNTS
Definition: tiff.h:314
#define TIFFTAG_STRIPBYTECOUNTS
Definition: tiff.h:259
#define TIFFTAG_TILEOFFSETS
Definition: tiff.h:313
#define TIFFTAG_STRIPOFFSETS
Definition: tiff.h:247
#define TIFF_ANY
Definition: tiffio.h:341
#define WriteOK(tif, buf, size)
Definition: tiffiop.h:301
#define ReadOK(tif, buf, size)
Definition: tiffiop.h:295
#define SeekOK(tif, off)
Definition: tiffiop.h:298
#define isMapped(tif)
Definition: tiffiop.h:275
#define TIFFSeekFile(tif, off, whence)
Definition: tiffiop.h:282
#define TIFF_BIGTIFF
Definition: tiffiop.h:138
#define TIFF_SWAB
Definition: tiffiop.h:124

Referenced by TIFFForceStrileArrayWriting().

◆ _TIFFSeekOK()

int _TIFFSeekOK ( TIFF tif,
toff_t  off 
)

Definition at line 409 of file tif_aux.c.

410{
411 /* Huge offsets, especially -1 / UINT64_MAX, can cause issues */
412 /* See http://bugzilla.maptools.org/show_bug.cgi?id=2726 */
413 return off <= (~(uint64_t)0) / 2 && TIFFSeekFile(tif, off, SEEK_SET) == off;
414}
#define SEEK_SET
Definition: jmemansi.c:26

◆ _TIFFsetByteArray()

void _TIFFsetByteArray ( void **  vpp,
const void vp,
uint32_t  n 
)

Definition at line 60 of file tif_dir.c.

61{
62 setByteArray(NULL, vpp, vp, n, 1);
63}
GLdouble n
Definition: glext.h:7729
static void setByteArray(TIFF *tif, void **vpp, const void *vp, size_t nmemb, size_t elem_size)
Definition: tif_dir.c:43

◆ _TIFFsetByteArrayExt()

void _TIFFsetByteArrayExt ( TIFF tif,
void **  vpp,
const void vp,
uint32_t  n 
)

Definition at line 64 of file tif_dir.c.

65{
66 setByteArray(tif, vpp, vp, n, 1);
67}

◆ _TIFFSetDefaultCompressionState()

void _TIFFSetDefaultCompressionState ( TIFF tif)

Definition at line 142 of file tif_compress.c.

143{
145 tif->tif_decodestatus = TRUE;
151 tif->tif_encodestatus = TRUE;
158 tif->tif_close = _TIFFvoid;
159 tif->tif_seek = _TIFFNoSeek;
160 tif->tif_cleanup = _TIFFvoid;
164}
#define TRUE
Definition: types.h:120
TIFFTileMethod tif_deftilesize
Definition: tiffiop.h:215
TIFFCodeMethod tif_encodestrip
Definition: tiffiop.h:208
TIFFSeekMethod tif_seek
Definition: tiffiop.h:212
TIFFCodeMethod tif_encodetile
Definition: tiffiop.h:210
TIFFPreMethod tif_preencode
Definition: tiffiop.h:203
TIFFBoolMethod tif_fixuptags
Definition: tiffiop.h:198
TIFFPreMethod tif_predecode
Definition: tiffiop.h:200
TIFFStripMethod tif_defstripsize
Definition: tiffiop.h:214
TIFFCodeMethod tif_decoderow
Definition: tiffiop.h:205
TIFFBoolMethod tif_setupencode
Definition: tiffiop.h:201
TIFFBoolMethod tif_postencode
Definition: tiffiop.h:204
TIFFCodeMethod tif_encoderow
Definition: tiffiop.h:206
TIFFVoidMethod tif_close
Definition: tiffiop.h:211
int tif_decodestatus
Definition: tiffiop.h:197
int tif_encodestatus
Definition: tiffiop.h:202
TIFFVoidMethod tif_cleanup
Definition: tiffiop.h:213
TIFFBoolMethod tif_setupdecode
Definition: tiffiop.h:199
static void _TIFFvoid(TIFF *tif)
Definition: tif_compress.c:140
int _TIFFNoTileEncode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
Definition: tif_compress.c:67
static int _TIFFtrue(TIFF *tif)
Definition: tif_compress.c:135
int _TIFFNoTileDecode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
Definition: tif_compress.c:112
static int _TIFFNoFixupTags(TIFF *tif)
Definition: tif_compress.c:90
int _TIFFNoRowDecode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
Definition: tif_compress.c:96
int _TIFFNoRowEncode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
Definition: tif_compress.c:51
int _TIFFNoStripEncode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
Definition: tif_compress.c:59
int _TIFFNoStripDecode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
Definition: tif_compress.c:104
int _TIFFNoPreCode(TIFF *tif, uint16_t s)
Definition: tif_compress.c:128
int _TIFFNoSeek(TIFF *tif, uint32_t off)
Definition: tif_compress.c:120
uint32_t _TIFFDefaultStripSize(TIFF *tif, uint32_t s)
Definition: tif_strip.c:223
void _TIFFDefaultTileSize(TIFF *tif, uint32_t *tw, uint32_t *th)
Definition: tif_tile.c:272
#define TIFF_NOREADRAW
Definition: tiffiop.h:135
#define TIFF_NOBITREV
Definition: tiffiop.h:125

Referenced by TIFFClientOpenExt(), and TIFFSetCompressionScheme().

◆ _TIFFsetDoubleArray()

void _TIFFsetDoubleArray ( double **  dpp,
const double dp,
uint32_t  n 
)

Definition at line 109 of file tif_dir.c.

110{
111 setByteArray(NULL, (void **)dpp, dp, n, sizeof(double));
112}

◆ _TIFFsetDoubleArrayExt()

void _TIFFsetDoubleArrayExt ( TIFF tif,
double **  dpp,
const double dp,
uint32_t  n 
)

Definition at line 113 of file tif_dir.c.

115{
116 setByteArray(tif, (void **)dpp, dp, n, sizeof(double));
117}

Referenced by _TIFFVSetField().

◆ _TIFFsetFloatArray()

void _TIFFsetFloatArray ( float **  fpp,
const float fp,
uint32_t  n 
)

Definition at line 100 of file tif_dir.c.

101{
102 setByteArray(NULL, (void **)fpp, fp, n, sizeof(float));
103}

◆ _TIFFsetFloatArrayExt()

void _TIFFsetFloatArrayExt ( TIFF tif,
float **  fpp,
const float fp,
uint32_t  n 
)

Definition at line 104 of file tif_dir.c.

105{
106 setByteArray(tif, (void **)fpp, fp, n, sizeof(float));
107}

Referenced by _TIFFVSetField().

◆ _TIFFsetLongArray()

void _TIFFsetLongArray ( uint32_t **  lpp,
const uint32_t lp,
uint32_t  n 
)

Definition at line 84 of file tif_dir.c.

85{
86 setByteArray(NULL, (void **)lpp, lp, n, sizeof(uint32_t));
87}

◆ _TIFFsetLongArrayExt()

void _TIFFsetLongArrayExt ( TIFF tif,
uint32_t **  lpp,
const uint32_t lp,
uint32_t  n 
)

Definition at line 88 of file tif_dir.c.

90{
91 setByteArray(tif, (void **)lpp, lp, n, sizeof(uint32_t));
92}

◆ _TIFFsetShortArray()

void _TIFFsetShortArray ( uint16_t **  wpp,
const uint16_t wp,
uint32_t  n 
)

Definition at line 74 of file tif_dir.c.

75{
76 setByteArray(NULL, (void **)wpp, wp, n, sizeof(uint16_t));
77}

◆ _TIFFsetShortArrayExt()

void _TIFFsetShortArrayExt ( TIFF tif,
uint16_t **  wpp,
const uint16_t wp,
uint32_t  n 
)

Definition at line 78 of file tif_dir.c.

80{
81 setByteArray(tif, (void **)wpp, wp, n, sizeof(uint16_t));
82}

Referenced by _TIFFVSetField(), setExtraSamples(), and TIFFReadDirectory().

◆ _TIFFSwab16BitData()

void _TIFFSwab16BitData ( TIFF tif,
uint8_t buf,
tmsize_t  cc 
)

Definition at line 1655 of file tif_read.c.

1656{
1657 (void)tif;
1658 assert((cc & 1) == 0);
1660}

Referenced by _TIFFVSetField().

◆ _TIFFSwab24BitData()

void _TIFFSwab24BitData ( TIFF tif,
uint8_t buf,
tmsize_t  cc 
)

Definition at line 1662 of file tif_read.c.

1663{
1664 (void)tif;
1665 assert((cc % 3) == 0);
1667}
void TIFFSwabArrayOfTriples(register uint8_t *tp, tmsize_t n)
Definition: tif_swab.c:99

Referenced by _TIFFVSetField().

◆ _TIFFSwab32BitData()

void _TIFFSwab32BitData ( TIFF tif,
uint8_t buf,
tmsize_t  cc 
)

Definition at line 1669 of file tif_read.c.

1670{
1671 (void)tif;
1672 assert((cc & 3) == 0);
1674}

Referenced by _TIFFVSetField().

◆ _TIFFSwab64BitData()

void _TIFFSwab64BitData ( TIFF tif,
uint8_t buf,
tmsize_t  cc 
)

Definition at line 1676 of file tif_read.c.

1677{
1678 (void)tif;
1679 assert((cc & 7) == 0);
1680 TIFFSwabArrayOfDouble((double *)buf, cc / 8);
1681}
void TIFFSwabArrayOfDouble(double *dp, tmsize_t n)
Definition: tif_swab.c:222

Referenced by _TIFFVSetField().

◆ TIFFCIELab16ToXYZ()

void TIFFCIELab16ToXYZ ( TIFFCIELabToRGB cielab,
uint32_t  l,
int32_t  a,
int32_t  b,
float X,
float Y,
float Z 
)

Definition at line 55 of file tif_color.c.

57{
58 float L = (float)l * 100.0F / 65535.0F;
59 float cby, tmp;
60
61 if (L < 8.856F)
62 {
63 *Y = (L * cielab->Y0) / 903.292F;
64 cby = 7.787F * (*Y / cielab->Y0) + 16.0F / 116.0F;
65 }
66 else
67 {
68 cby = (L + 16.0F) / 116.0F;
69 *Y = cielab->Y0 * cby * cby * cby;
70 }
71
72 tmp = (float)a / 256.0F / 500.0F + cby;
73 if (tmp < 0.2069F)
74 *X = cielab->X0 * (tmp - 0.13793F) / 7.787F;
75 else
76 *X = cielab->X0 * tmp * tmp * tmp;
77
78 tmp = cby - (float)b / 256.0F / 200.0F;
79 if (tmp < 0.2069F)
80 *Z = cielab->Z0 * (tmp - 0.13793F) / 7.787F;
81 else
82 *Z = cielab->Z0 * tmp * tmp * tmp;
83}
r l[0]
Definition: byte_order.h:168
#define Z(I)
#define Y(I)
#define L(x)
Definition: resources.c:13
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
static float(__cdecl *square_half_float)(float x

Referenced by DECLAREContigPutFunc(), and TIFFCIELabToXYZ().

◆ TIFFDefaultDirectory()

int TIFFDefaultDirectory ( TIFF tif)

Definition at line 1752 of file tif_dir.c.

1753{
1754 register TIFFDirectory *td = &tif->tif_dir;
1756
1759
1760 _TIFFmemset(td, 0, sizeof(*td));
1762 td->td_bitspersample = 1;
1765 td->td_samplesperpixel = 1;
1766 td->td_rowsperstrip = (uint32_t)-1;
1767 td->td_tilewidth = 0;
1768 td->td_tilelength = 0;
1769 td->td_tiledepth = 1;
1770#ifdef STRIPBYTECOUNTSORTED_UNUSED
1771 td->td_stripbytecountsorted = 1; /* Our own arrays always sorted. */
1772#endif
1775 td->td_imagedepth = 1;
1776 td->td_ycbcrsubsampling[0] = 2;
1777 td->td_ycbcrsubsampling[1] = 2;
1780 tif->tif_foundfield = NULL;
1784 /* additional default values */
1787 td->td_subfiletype = 0;
1788 td->td_minsamplevalue = 0;
1789 /* td_bitspersample=1 is always set in TIFFDefaultDirectory().
1790 * Therefore, td_maxsamplevalue has to be re-calculated in
1791 * TIFFGetFieldDefaulted(). */
1792 td->td_maxsamplevalue = 1; /* Default for td_bitspersample=1 */
1793 td->td_extrasamples = 0;
1794 td->td_sampleinfo = NULL;
1795
1796 /*
1797 * Give client code a chance to install their own
1798 * tag extensions & methods, prior to compression overloads,
1799 * but do some prior cleanup first.
1800 * (http://trac.osgeo.org/gdal/ticket/5054)
1801 */
1802 if (tif->tif_nfieldscompat > 0)
1803 {
1804 uint32_t i;
1805
1806 for (i = 0; i < tif->tif_nfieldscompat; i++)
1807 {
1810 }
1811 _TIFFfreeExt(tif, tif->tif_fieldscompat);
1812 tif->tif_nfieldscompat = 0;
1813 tif->tif_fieldscompat = NULL;
1814 }
1815 if (_TIFFextender)
1816 (*_TIFFextender)(tif);
1818 /*
1819 * NB: The directory is marked dirty as a result of setting
1820 * up the default compression scheme. However, this really
1821 * isn't correct -- we want TIFF_DIRTYDIRECT to be set only
1822 * if the user does something. We could just do the setup
1823 * by hand, but it seems better to use the normal mechanism
1824 * (i.e. TIFFSetField).
1825 */
1826 tif->tif_flags &= ~TIFF_DIRTYDIRECT;
1827
1828 /*
1829 * As per http://bugzilla.remotesensing.org/show_bug.cgi?id=19
1830 * we clear the ISTILED flag when setting up a new directory.
1831 * Should we also be clearing stuff like INSUBIFD?
1832 */
1833 tif->tif_flags &= ~TIFF_ISTILED;
1834
1835 return (1);
1836}
uint32_t td_tiledepth
Definition: tif_dir.h:84
uint16_t td_fillorder
Definition: tif_dir.h:91
uint16_t * td_sampleinfo
Definition: tif_dir.h:106
uint32_t td_rowsperstrip
Definition: tif_dir.h:94
uint32_t td_tilewidth
Definition: tif_dir.h:84
uint16_t td_extrasamples
Definition: tif_dir.h:105
uint16_t td_threshholding
Definition: tif_dir.h:90
uint16_t td_minsamplevalue
Definition: tif_dir.h:95
uint16_t td_bitspersample
Definition: tif_dir.h:86
uint16_t td_maxsamplevalue
Definition: tif_dir.h:95
uint32_t td_imagedepth
Definition: tif_dir.h:83
uint16_t td_orientation
Definition: tif_dir.h:92
uint16_t td_resolutionunit
Definition: tif_dir.h:99
uint16_t td_sampleformat
Definition: tif_dir.h:87
uint16_t td_ycbcrsubsampling[2]
Definition: tif_dir.h:132
uint32_t td_subfiletype
Definition: tif_dir.h:85
uint32_t td_tilelength
Definition: tif_dir.h:84
uint16_t td_ycbcrpositioning
Definition: tif_dir.h:133
TIFFVGetMethod vgetfield
Definition: tiffio.h:376
TIFFVSetMethod vsetfield
Definition: tiffio.h:375
TIFFPrintMethod printdir
Definition: tiffio.h:377
uint32_t allocated_size
Definition: tif_dir.h:324
TIFFField * fields
Definition: tif_dir.h:327
const TIFFField * tif_foundfield
Definition: tiffiop.h:243
TIFFTagMethods tif_tagmethods
Definition: tiffiop.h:244
size_t tif_nfieldscompat
Definition: tiffiop.h:249
TIFFFieldArray * tif_fieldscompat
Definition: tiffiop.h:248
int TIFFSetField(TIFF *tif, uint32_t tag,...)
Definition: tif_dir.c:1146
static int _TIFFVGetField(TIFF *tif, uint32_t tag, va_list ap)
Definition: tif_dir.c:1212
static int _TIFFVSetField(TIFF *tif, uint32_t tag, va_list ap)
Definition: tif_dir.c:220
static TIFFExtendProc _TIFFextender
Definition: tif_dir.c:1673
const TIFFFieldArray * _TIFFGetFields(void)
Definition: tif_dirinfo.c:507
static const TIFFFieldArray tiffFieldArray
Definition: tif_dirinfo.c:48
void _TIFFSetupFields(TIFF *tif, const TIFFFieldArray *fieldarray)
Definition: tif_dirinfo.c:513
void _TIFFNoPostDecode(TIFF *tif, uint8_t *buf, tmsize_t cc)
Definition: tif_read.c:1648
#define YCBCRPOSITION_CENTERED
Definition: tiff.h:390
#define ORIENTATION_TOPLEFT
Definition: tiff.h:249
#define SAMPLEFORMAT_UINT
Definition: tiff.h:334
#define FILLORDER_MSB2LSB
Definition: tiff.h:241
#define RESUNIT_INCH
Definition: tiff.h:289
#define THRESHHOLD_BILEVEL
Definition: tiff.h:235
#define TIFFTAG_COMPRESSION
Definition: tiff.h:181

Referenced by TIFFClientOpenExt(), TIFFCreateCustomDirectory(), TIFFCreateDirectory(), TIFFReadCustomDirectory(), TIFFReadDirectory(), and TIFFUnlinkDirectory().

◆ TIFFFlushData1()

int TIFFFlushData1 ( TIFF tif)

Definition at line 931 of file tif_write.c.

932{
933 if (tif->tif_rawcc > 0 && tif->tif_flags & TIFF_BUF4WRITE)
934 {
935 if (!isFillOrder(tif, tif->tif_dir.td_fillorder) &&
936 (tif->tif_flags & TIFF_NOBITREV) == 0)
939 tif, isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip,
940 tif->tif_rawdata, tif->tif_rawcc))
941 {
942 /* We update those variables even in case of error since there's */
943 /* code that doesn't really check the return code of this */
944 /* function */
945 tif->tif_rawcc = 0;
946 tif->tif_rawcp = tif->tif_rawdata;
947 return (0);
948 }
949 tif->tif_rawcc = 0;
950 tif->tif_rawcp = tif->tif_rawdata;
951 }
952 return (1);
953}
uint32_t tif_curtile
Definition: tiffiop.h:194
tmsize_t tif_rawcc
Definition: tiffiop.h:225
uint8_t * tif_rawcp
Definition: tiffiop.h:224
uint8_t * tif_rawdata
Definition: tiffiop.h:220
uint32_t tif_curstrip
Definition: tiffiop.h:184
void TIFFReverseBits(uint8_t *cp, tmsize_t n)
Definition: tif_swab.c:310
static int TIFFAppendToStrip(TIFF *tif, uint32_t strip, uint8_t *data, tmsize_t cc)
Definition: tif_write.c:764
#define isTiled(tif)
Definition: tiffiop.h:274
#define TIFF_BUF4WRITE
Definition: tiffiop.h:139
#define isFillOrder(tif, o)
Definition: tiffiop.h:276

Referenced by DumpModeEncode(), TIFFFlushData(), and TIFFWriteDirectorySec().

◆ TIFFInitCCITTFax3()

int TIFFInitCCITTFax3 ( TIFF ,
int   
)

◆ TIFFInitCCITTFax4()

int TIFFInitCCITTFax4 ( TIFF ,
int   
)

◆ TIFFInitCCITTRLE()

int TIFFInitCCITTRLE ( TIFF ,
int   
)

◆ TIFFInitCCITTRLEW()

int TIFFInitCCITTRLEW ( TIFF ,
int   
)

◆ TIFFInitDumpMode()

int TIFFInitDumpMode ( TIFF tif,
int  scheme 
)

Definition at line 110 of file tif_dumpmode.c.

111{
112 (void)scheme;
120 tif->tif_seek = DumpModeSeek;
121 return (1);
122}
DWORD scheme
static int DumpModeSeek(TIFF *tif, uint32_t nrows)
Definition: tif_dumpmode.c:100
static int DumpModeDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s)
Definition: tif_dumpmode.c:73
static int DumpFixupTags(TIFF *tif)
Definition: tif_dumpmode.c:32
static int DumpModeEncode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
Definition: tif_dumpmode.c:41

◆ TIFFInitJPEG()

int TIFFInitJPEG ( TIFF ,
int   
)

◆ TIFFInitLZW()

int TIFFInitLZW ( TIFF ,
int   
)

◆ TIFFInitNeXT()

int TIFFInitNeXT ( TIFF ,
int   
)

◆ TIFFInitPackBits()

int TIFFInitPackBits ( TIFF ,
int   
)

◆ TIFFInitPixarLog()

int TIFFInitPixarLog ( TIFF ,
int   
)

◆ TIFFInitSGILog()

int TIFFInitSGILog ( TIFF ,
int   
)

◆ TIFFInitThunderScan()

int TIFFInitThunderScan ( TIFF ,
int   
)

◆ TIFFInitZIP()

int TIFFInitZIP ( TIFF ,
int   
)

◆ TIFFJPEGIsFullStripRequired()

int TIFFJPEGIsFullStripRequired ( TIFF )

Referenced by TIFFFillStripPartial().

◆ TIFFSetCompressionScheme()

int TIFFSetCompressionScheme ( TIFF tif,
int  scheme 
)

Definition at line 166 of file tif_compress.c.

167{
169
171 /*
172 * Don't treat an unknown compression scheme as an error.
173 * This permits applications to open files with data that
174 * the library does not have builtin support for, but which
175 * may still be meaningful.
176 */
177 return (c ? (*c->init)(tif, scheme) : 1);
178}
const GLubyte * c
Definition: glext.h:8905
const TIFFCodec * TIFFFindCODEC(uint16_t scheme)
Definition: tif_compress.c:192
void _TIFFSetDefaultCompressionState(TIFF *tif)
Definition: tif_compress.c:142

Referenced by _TIFFVSetField().

◆ TIFFSetDefaultCompressionState()

int TIFFSetDefaultCompressionState ( TIFF tif)

Variable Documentation

◆ _TIFFBuiltinCODECS

const TIFFCodec _TIFFBuiltinCODECS[]
extern

Definition at line 86 of file tif_codec.c.

Referenced by TIFFFindCODEC(), and TIFFGetConfiguredCODECs().

◆ _TIFFerrorHandler

TIFFErrorHandler _TIFFerrorHandler
extern

◆ _TIFFerrorHandlerExt

TIFFErrorHandlerExt _TIFFerrorHandlerExt
extern

◆ _TIFFwarningHandler

TIFFErrorHandler _TIFFwarningHandler
extern

Definition at line 373 of file tif_unix.c.

Referenced by TIFFSetWarningHandler(), TIFFWarning(), TIFFWarningExt(), and TIFFWarningExtR().

◆ _TIFFwarningHandlerExt

TIFFErrorHandlerExt _TIFFwarningHandlerExt
extern