#include "tiffiop.h"
#include <float.h>
#include <math.h>
#ifdef HAVE_IEEEFP
#define TIFFCvtNativeToIEEEFloat(tif, n, fp) …
#define TIFFCvtNativeToIEEEDouble(tif, n, dp) …
#else
extern void TIFFCvtNativeToIEEEFloat(TIFF *tif, uint32_t n, float *fp);
extern void TIFFCvtNativeToIEEEDouble(TIFF *tif, uint32_t n, double *dp);
#endif
static int TIFFWriteDirectorySec(TIFF *tif, int isimage, int imagedone,
uint64_t *pdiroff);
static int TIFFWriteDirectoryTagSampleformatArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
double *value);
static int TIFFWriteDirectoryTagAscii(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, char *value);
static int TIFFWriteDirectoryTagUndefinedArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, uint8_t *value);
static int TIFFWriteDirectoryTagByteArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, uint8_t *value);
static int TIFFWriteDirectoryTagSbyteArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, int8_t *value);
static int TIFFWriteDirectoryTagShort(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint16_t value);
static int TIFFWriteDirectoryTagShortArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, uint16_t *value);
static int TIFFWriteDirectoryTagShortPerSample(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint16_t value);
static int TIFFWriteDirectoryTagSshortArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, int16_t *value);
static int TIFFWriteDirectoryTagLong(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t value);
static int TIFFWriteDirectoryTagLongArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, uint32_t *value);
static int TIFFWriteDirectoryTagSlongArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, int32_t *value);
static int TIFFWriteDirectoryTagLong8Array(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, uint64_t *value);
static int TIFFWriteDirectoryTagSlong8Array(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, int64_t *value);
static int TIFFWriteDirectoryTagRational(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
double value);
static int TIFFWriteDirectoryTagRationalArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, float *value);
static int TIFFWriteDirectoryTagSrationalArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, float *value);
static int TIFFWriteDirectoryTagFloatArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, float *value);
static int TIFFWriteDirectoryTagDoubleArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, double *value);
static int TIFFWriteDirectoryTagIfdArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, uint32_t *value);
static int TIFFWriteDirectoryTagShortLong(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t value);
static int TIFFWriteDirectoryTagLongLong8Array(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, uint64_t *value);
static int TIFFWriteDirectoryTagIfdIfd8Array(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, uint64_t *value);
static int TIFFWriteDirectoryTagColormap(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir);
static int TIFFWriteDirectoryTagTransferfunction(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir);
static int TIFFWriteDirectoryTagSubifd(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir);
static int TIFFWriteDirectoryTagCheckedAscii(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, char *value);
static int TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag,
uint32_t count,
uint8_t *value);
static int TIFFWriteDirectoryTagCheckedByteArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
uint8_t *value);
static int TIFFWriteDirectoryTagCheckedSbyteArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
int8_t *value);
static int TIFFWriteDirectoryTagCheckedShort(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint16_t value);
static int TIFFWriteDirectoryTagCheckedShortArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
uint16_t *value);
static int TIFFWriteDirectoryTagCheckedSshortArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
int16_t *value);
static int TIFFWriteDirectoryTagCheckedLong(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t value);
static int TIFFWriteDirectoryTagCheckedLongArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
uint32_t *value);
static int TIFFWriteDirectoryTagCheckedSlongArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
int32_t *value);
static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
uint64_t *value);
static int TIFFWriteDirectoryTagCheckedSlong8Array(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
int64_t *value);
static int TIFFWriteDirectoryTagCheckedRational(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
double value);
static int TIFFWriteDirectoryTagCheckedRationalArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag,
uint32_t count,
float *value);
static int TIFFWriteDirectoryTagCheckedSrationalArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag,
uint32_t count,
float *value);
static int TIFFWriteDirectoryTagRationalDoubleArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag,
uint32_t count,
double *value);
static int TIFFWriteDirectoryTagSrationalDoubleArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag,
uint32_t count,
double *value);
static int
TIFFWriteDirectoryTagCheckedRationalDoubleArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, double *value);
static int TIFFWriteDirectoryTagCheckedSrationalDoubleArray(
TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count,
double *value);
static void DoubleToRational(double value, uint32_t *num, uint32_t *denom);
static void DoubleToSrational(double value, int32_t *num, int32_t *denom);
static int TIFFWriteDirectoryTagCheckedFloatArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
float *value);
static int TIFFWriteDirectoryTagCheckedDoubleArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
double *value);
static int TIFFWriteDirectoryTagCheckedIfdArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count,
uint32_t *value);
static int TIFFWriteDirectoryTagCheckedIfd8Array(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
uint64_t *value);
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint16_t datatype, uint32_t count,
uint32_t datalength, void *data);
static int TIFFLinkDirectory(TIFF *);
int TIFFWriteDirectory(TIFF *tif)
{ … }
int TIFFDeferStrileArrayWriting(TIFF *tif)
{ … }
int TIFFCheckpointDirectory(TIFF *tif)
{ … }
int TIFFWriteCustomDirectory(TIFF *tif, uint64_t *pdiroff)
{ … }
int TIFFRewriteDirectory(TIFF *tif)
{ … }
static int TIFFWriteDirectorySec(TIFF *tif, int isimage, int imagedone,
uint64_t *pdiroff)
{ … }
static int8_t TIFFClampDoubleToInt8(double val)
{ … }
static int16_t TIFFClampDoubleToInt16(double val)
{ … }
static int32_t TIFFClampDoubleToInt32(double val)
{ … }
static uint8_t TIFFClampDoubleToUInt8(double val)
{ … }
static uint16_t TIFFClampDoubleToUInt16(double val)
{ … }
static uint32_t TIFFClampDoubleToUInt32(double val)
{ … }
static int TIFFWriteDirectoryTagSampleformatArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
double *value)
{ … }
static int TIFFWriteDirectoryTagAscii(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, char *value)
{ … }
static int TIFFWriteDirectoryTagUndefinedArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, uint8_t *value)
{ … }
static int TIFFWriteDirectoryTagByteArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, uint8_t *value)
{ … }
static int TIFFWriteDirectoryTagSbyteArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, int8_t *value)
{ … }
static int TIFFWriteDirectoryTagShort(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint16_t value)
{ … }
static int TIFFWriteDirectoryTagShortArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, uint16_t *value)
{ … }
static int TIFFWriteDirectoryTagShortPerSample(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint16_t value)
{ … }
static int TIFFWriteDirectoryTagSshortArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, int16_t *value)
{ … }
static int TIFFWriteDirectoryTagLong(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t value)
{ … }
static int TIFFWriteDirectoryTagLongArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, uint32_t *value)
{ … }
static int TIFFWriteDirectoryTagSlongArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, int32_t *value)
{ … }
static int TIFFWriteDirectoryTagLong8Array(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, uint64_t *value)
{ … }
static int TIFFWriteDirectoryTagSlong8Array(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, int64_t *value)
{ … }
static int TIFFWriteDirectoryTagRational(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
double value)
{ … }
static int TIFFWriteDirectoryTagRationalArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, float *value)
{ … }
static int TIFFWriteDirectoryTagSrationalArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, float *value)
{ … }
static int TIFFWriteDirectoryTagRationalDoubleArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag,
uint32_t count,
double *value)
{ … }
static int TIFFWriteDirectoryTagSrationalDoubleArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag,
uint32_t count,
double *value)
{ … }
static int TIFFWriteDirectoryTagFloatArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, float *value)
{ … }
static int TIFFWriteDirectoryTagDoubleArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, double *value)
{ … }
static int TIFFWriteDirectoryTagIfdArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, uint32_t *value)
{ … }
static int TIFFWriteDirectoryTagShortLong(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t value)
{ … }
static int _WriteAsType(TIFF *tif, uint64_t strile_size,
uint64_t uncompressed_threshold)
{ … }
static int WriteAsLong8(TIFF *tif, uint64_t strile_size)
{ … }
static int WriteAsLong4(TIFF *tif, uint64_t strile_size)
{ … }
static int TIFFWriteDirectoryTagLongLong8Array(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, uint64_t *value)
{ … }
static int TIFFWriteDirectoryTagIfdIfd8Array(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, uint64_t *value)
{ … }
static int TIFFWriteDirectoryTagColormap(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir)
{ … }
static int TIFFWriteDirectoryTagTransferfunction(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir)
{ … }
static int TIFFWriteDirectoryTagSubifd(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir)
{ … }
static int TIFFWriteDirectoryTagCheckedAscii(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, char *value)
{ … }
static int TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag,
uint32_t count,
uint8_t *value)
{ … }
static int TIFFWriteDirectoryTagCheckedByteArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
uint8_t *value)
{ … }
static int TIFFWriteDirectoryTagCheckedSbyteArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
int8_t *value)
{ … }
static int TIFFWriteDirectoryTagCheckedShort(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint16_t value)
{ … }
static int TIFFWriteDirectoryTagCheckedShortArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
uint16_t *value)
{ … }
static int TIFFWriteDirectoryTagCheckedSshortArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
int16_t *value)
{ … }
static int TIFFWriteDirectoryTagCheckedLong(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t value)
{ … }
static int TIFFWriteDirectoryTagCheckedLongArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
uint32_t *value)
{ … }
static int TIFFWriteDirectoryTagCheckedSlongArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
int32_t *value)
{ … }
static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
uint64_t *value)
{ … }
static int TIFFWriteDirectoryTagCheckedSlong8Array(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
int64_t *value)
{ … }
static int TIFFWriteDirectoryTagCheckedRational(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
double value)
{ … }
static int TIFFWriteDirectoryTagCheckedRationalArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag,
uint32_t count,
float *value)
{ … }
static int TIFFWriteDirectoryTagCheckedSrationalArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag,
uint32_t count,
float *value)
{ … }
static int
TIFFWriteDirectoryTagCheckedRationalDoubleArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, double *value)
{ … }
static int TIFFWriteDirectoryTagCheckedSrationalDoubleArray(
TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count,
double *value)
{ … }
static void ToRationalEuclideanGCD(double value, int blnUseSignedRange,
int blnUseSmallRange, uint64_t *ullNum,
uint64_t *ullDenom)
{ … }
static void DoubleToRational(double value, uint32_t *num, uint32_t *denom)
{ … }
static void DoubleToSrational(double value, int32_t *num, int32_t *denom)
{ … }
static int TIFFWriteDirectoryTagCheckedFloatArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
float *value)
{ … }
static int TIFFWriteDirectoryTagCheckedDoubleArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
double *value)
{ … }
static int TIFFWriteDirectoryTagCheckedIfdArray(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint32_t count, uint32_t *value)
{ … }
static int TIFFWriteDirectoryTagCheckedIfd8Array(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir,
uint16_t tag, uint32_t count,
uint64_t *value)
{ … }
static int TIFFWriteDirectoryTagData(TIFF *tif, uint32_t *ndir,
TIFFDirEntry *dir, uint16_t tag,
uint16_t datatype, uint32_t count,
uint32_t datalength, void *data)
{ … }
static int TIFFLinkDirectory(TIFF *tif)
{ … }
int _TIFFRewriteField(TIFF *tif, uint16_t tag, TIFFDataType in_datatype,
tmsize_t count, void *data)
{ … }