Commit 4c255f5a authored by Alexandre Julliard's avatar Alexandre Julliard

tiff: Import upstream release 4.5.0.

parent f93e53c9
......@@ -15,6 +15,7 @@ C_SRCS = \
libtiff/tif_fax3.c \
libtiff/tif_fax3sm.c \
libtiff/tif_flush.c \
libtiff/tif_hash_set.c \
libtiff/tif_jpeg.c \
libtiff/tif_luv.c \
libtiff/tif_lzw.c \
......
......@@ -41,8 +41,7 @@
* @param tif A TIFF pointer.
*/
void
TIFFCleanup(TIFF* tif)
void TIFFCleanup(TIFF *tif)
{
/*
* Flush buffered data and directory (if dirty).
......@@ -52,60 +51,67 @@ TIFFCleanup(TIFF* tif)
(*tif->tif_cleanup)(tif);
TIFFFreeDirectory(tif);
if (tif->tif_dirlist)
_TIFFfree(tif->tif_dirlist);
TIFFHashSetDestroy(tif->tif_map_dir_offset_to_number);
TIFFHashSetDestroy(tif->tif_map_dir_number_to_offset);
/*
* Clean up client info links.
*/
while( tif->tif_clientinfo )
while (tif->tif_clientinfo)
{
TIFFClientInfoLink *psLink = tif->tif_clientinfo;
tif->tif_clientinfo = psLink->next;
_TIFFfree( psLink->name );
_TIFFfree( psLink );
_TIFFfreeExt(tif, psLink->name);
_TIFFfreeExt(tif, psLink);
}
if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER))
_TIFFfree(tif->tif_rawdata);
if (tif->tif_rawdata && (tif->tif_flags & TIFF_MYBUFFER))
_TIFFfreeExt(tif, tif->tif_rawdata);
if (isMapped(tif))
TIFFUnmapFileContents(tif, tif->tif_base, (toff_t)tif->tif_size);
/*
* Clean up custom fields.
*/
if (tif->tif_fields && tif->tif_nfields > 0) {
if (tif->tif_fields && tif->tif_nfields > 0)
{
uint32_t i;
for (i = 0; i < tif->tif_nfields; i++) {
for (i = 0; i < tif->tif_nfields; i++)
{
TIFFField *fld = tif->tif_fields[i];
if (fld->field_name != NULL) {
if (fld->field_name != NULL)
{
if (fld->field_bit == FIELD_CUSTOM &&
/* caution: tif_fields[i] must not be the beginning of a fields-array.
* Otherwise the following tags are also freed with the first free().
/* caution: tif_fields[i] must not be the beginning of a
* fields-array. Otherwise the following tags are also freed
* with the first free().
*/
TIFFFieldIsAnonymous(fld)) {
_TIFFfree(fld->field_name);
_TIFFfree(fld);
TIFFFieldIsAnonymous(fld))
{
_TIFFfreeExt(tif, fld->field_name);
_TIFFfreeExt(tif, fld);
}
}
}
_TIFFfree(tif->tif_fields);
_TIFFfreeExt(tif, tif->tif_fields);
}
if (tif->tif_nfieldscompat > 0) {
if (tif->tif_nfieldscompat > 0)
{
uint32_t i;
for (i = 0; i < tif->tif_nfieldscompat; i++) {
for (i = 0; i < tif->tif_nfieldscompat; i++)
{
if (tif->tif_fieldscompat[i].allocated_size)
_TIFFfree(tif->tif_fieldscompat[i].fields);
_TIFFfreeExt(tif, tif->tif_fieldscompat[i].fields);
}
_TIFFfree(tif->tif_fieldscompat);
_TIFFfreeExt(tif, tif->tif_fieldscompat);
}
_TIFFfree(tif);
_TIFFfreeExt(NULL, tif);
}
/************************************************************************/
......@@ -122,22 +128,11 @@ TIFFCleanup(TIFF* tif)
* @param tif A TIFF pointer.
*/
void
TIFFClose(TIFF* tif)
void TIFFClose(TIFF *tif)
{
TIFFCloseProc closeproc = tif->tif_closeproc;
thandle_t fd = tif->tif_clientdata;
TIFFCleanup(tif);
(void) (*closeproc)(fd);
(void)(*closeproc)(fd);
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/
......@@ -29,7 +29,7 @@
*/
#include "tiffiop.h"
static int NotConfigured(TIFF*, int);
static int NotConfigured(TIFF *, int);
#ifndef LZW_SUPPORT
#define TIFFInitLZW NotConfigured
......@@ -84,47 +84,45 @@ static int NotConfigured(TIFF*, int);
* Compression schemes statically built into the library.
*/
const TIFFCodec _TIFFBuiltinCODECS[] = {
{ "None", COMPRESSION_NONE, TIFFInitDumpMode },
{ "LZW", COMPRESSION_LZW, TIFFInitLZW },
{ "PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits },
{ "ThunderScan", COMPRESSION_THUNDERSCAN,TIFFInitThunderScan },
{ "NeXT", COMPRESSION_NEXT, TIFFInitNeXT },
{ "JPEG", COMPRESSION_JPEG, TIFFInitJPEG },
{ "Old-style JPEG", COMPRESSION_OJPEG, TIFFInitOJPEG },
{ "CCITT RLE", COMPRESSION_CCITTRLE, TIFFInitCCITTRLE },
{ "CCITT RLE/W", COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW },
{ "CCITT Group 3", COMPRESSION_CCITTFAX3, TIFFInitCCITTFax3 },
{ "CCITT Group 4", COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4 },
{ "ISO JBIG", COMPRESSION_JBIG, TIFFInitJBIG },
{ "Deflate", COMPRESSION_DEFLATE, TIFFInitZIP },
{ "AdobeDeflate", COMPRESSION_ADOBE_DEFLATE , TIFFInitZIP },
{ "PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog },
{ "SGILog", COMPRESSION_SGILOG, TIFFInitSGILog },
{ "SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog },
{ "LZMA", COMPRESSION_LZMA, TIFFInitLZMA },
{ "ZSTD", COMPRESSION_ZSTD, TIFFInitZSTD },
{ "WEBP", COMPRESSION_WEBP, TIFFInitWebP },
{ "LERC", COMPRESSION_LERC, TIFFInitLERC },
{ NULL, 0, NULL }
};
{"None", COMPRESSION_NONE, TIFFInitDumpMode},
{"LZW", COMPRESSION_LZW, TIFFInitLZW},
{"PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits},
{"ThunderScan", COMPRESSION_THUNDERSCAN, TIFFInitThunderScan},
{"NeXT", COMPRESSION_NEXT, TIFFInitNeXT},
{"JPEG", COMPRESSION_JPEG, TIFFInitJPEG},
{"Old-style JPEG", COMPRESSION_OJPEG, TIFFInitOJPEG},
{"CCITT RLE", COMPRESSION_CCITTRLE, TIFFInitCCITTRLE},
{"CCITT RLE/W", COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW},
{"CCITT Group 3", COMPRESSION_CCITTFAX3, TIFFInitCCITTFax3},
{"CCITT Group 4", COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4},
{"ISO JBIG", COMPRESSION_JBIG, TIFFInitJBIG},
{"Deflate", COMPRESSION_DEFLATE, TIFFInitZIP},
{"AdobeDeflate", COMPRESSION_ADOBE_DEFLATE, TIFFInitZIP},
{"PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog},
{"SGILog", COMPRESSION_SGILOG, TIFFInitSGILog},
{"SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog},
{"LZMA", COMPRESSION_LZMA, TIFFInitLZMA},
{"ZSTD", COMPRESSION_ZSTD, TIFFInitZSTD},
{"WEBP", COMPRESSION_WEBP, TIFFInitWebP},
{"LERC", COMPRESSION_LERC, TIFFInitLERC},
{NULL, 0, NULL}};
static int
_notConfigured(TIFF* tif)
static int _notConfigured(TIFF *tif)
{
const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
const TIFFCodec *c = TIFFFindCODEC(tif->tif_dir.td_compression);
char compression_code[20];
sprintf(compression_code, "%"PRIu16, tif->tif_dir.td_compression );
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
snprintf(compression_code, sizeof(compression_code), "%" PRIu16,
tif->tif_dir.td_compression);
TIFFErrorExtR(tif, tif->tif_name,
"%s compression support is not configured",
c ? c->name : compression_code );
c ? c->name : compression_code);
return (0);
}
static int
NotConfigured(TIFF* tif, int scheme)
static int NotConfigured(TIFF *tif, int scheme)
{
(void) scheme;
(void)scheme;
tif->tif_fixuptags = _notConfigured;
tif->tif_decodestatus = FALSE;
......@@ -145,27 +143,21 @@ NotConfigured(TIFF* tif, int scheme)
* 0 will be returned.
*/
int
TIFFIsCODECConfigured(uint16_t scheme)
int TIFFIsCODECConfigured(uint16_t scheme)
{
const TIFFCodec* codec = TIFFFindCODEC(scheme);
const TIFFCodec *codec = TIFFFindCODEC(scheme);
if(codec == NULL) {
if (codec == NULL)
{
return 0;
}
if(codec->init == NULL) {
if (codec->init == NULL)
{
return 0;
}
if(codec->init != NotConfigured){
if (codec->init != NotConfigured)
{
return 1;
}
return 0;
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/
......@@ -99,7 +99,7 @@
#define PACKAGE_NAME "LibTIFF Software"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "LibTIFF Software 4.4.0"
#define PACKAGE_STRING "LibTIFF Software 4.5.0"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "tiff"
......@@ -108,7 +108,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "4.4.0"
#define PACKAGE_VERSION "4.5.0"
/* The size of `size_t', as computed by sizeof. */
#define SIZEOF_SIZE_T 4
......@@ -120,7 +120,7 @@
#define USE_WIN32_FILEIO 1
/* Version number of package */
#define VERSION "4.4.0"
#define VERSION "4.5.0"
/* Support webp compression */
/* #undef WEBP_SUPPORT */
......
......@@ -32,7 +32,8 @@
* ``Library-private'' Directory-related Definitions.
*/
typedef struct {
typedef struct
{
const TIFFField *info;
int count;
void *value;
......@@ -49,22 +50,26 @@ typedef struct {
* BigTIFF, then it is placed in the offset field to save space. If so,
* it is left-justified in the offset field.
*/
typedef struct {
typedef struct
{
uint16_t tdir_tag; /* see below */
uint16_t tdir_type; /* data type; see below */
uint64_t tdir_count; /* number of items; length in spec */
union {
union
{
uint16_t toff_short;
uint32_t toff_long;
uint64_t toff_long8;
} tdir_offset; /* either offset or the data itself if fits */
uint8_t tdir_ignore; /* flag status to ignore tag when parsing tags in tif_dirread.c */
uint8_t tdir_ignore; /* flag status to ignore tag when parsing tags in
tif_dirread.c */
} TIFFDirEntry;
/*
* Internal format of a TIFF directory entry.
*/
typedef struct {
typedef struct
{
#define FIELD_SETLONGS 4
/* bit vector of fields that are set */
unsigned long td_fieldsset[FIELD_SETLONGS];
......@@ -82,46 +87,54 @@ typedef struct {
uint16_t td_samplesperpixel;
uint32_t td_rowsperstrip;
uint16_t td_minsamplevalue, td_maxsamplevalue;
double* td_sminsamplevalue;
double* td_smaxsamplevalue;
double *td_sminsamplevalue;
double *td_smaxsamplevalue;
float td_xresolution, td_yresolution;
uint16_t td_resolutionunit;
uint16_t td_planarconfig;
float td_xposition, td_yposition;
uint16_t td_pagenumber[2];
uint16_t* td_colormap[3];
uint16_t *td_colormap[3];
uint16_t td_halftonehints[2];
uint16_t td_extrasamples;
uint16_t* td_sampleinfo;
uint16_t *td_sampleinfo;
/* even though the name is misleading, td_stripsperimage is the number
* of striles (=strips or tiles) per plane, and td_nstrips the total
* number of striles */
uint32_t td_stripsperimage;
uint32_t td_nstrips; /* size of offset & bytecount arrays */
uint64_t* td_stripoffset_p; /* should be accessed with TIFFGetStrileOffset */
uint64_t* td_stripbytecount_p; /* should be accessed with TIFFGetStrileByteCount */
uint32_t td_stripoffsetbyteallocsize; /* number of elements currently allocated for td_stripoffset/td_stripbytecount. Only used if TIFF_LAZYSTRILELOAD is set */
uint64_t
*td_stripoffset_p; /* should be accessed with TIFFGetStrileOffset */
uint64_t *td_stripbytecount_p; /* should be accessed with
TIFFGetStrileByteCount */
uint32_t
td_stripoffsetbyteallocsize; /* number of elements currently allocated
for td_stripoffset/td_stripbytecount.
Only used if TIFF_LAZYSTRILELOAD is set
*/
#ifdef STRIPBYTECOUNTSORTED_UNUSED
int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */
#endif
TIFFDirEntry td_stripoffset_entry; /* for deferred loading */
TIFFDirEntry td_stripbytecount_entry; /* for deferred loading */
uint16_t td_nsubifd;
uint64_t* td_subifd;
uint64_t *td_subifd;
/* YCbCr parameters */
uint16_t td_ycbcrsubsampling[2];
uint16_t td_ycbcrpositioning;
/* Colorimetry parameters */
uint16_t* td_transferfunction[3];
float* td_refblackwhite;
uint16_t *td_transferfunction[3];
float *td_refblackwhite;
/* CMYK parameters */
int td_inknameslen;
char* td_inknames;
char *td_inknames;
uint16_t td_numberofinks; /* number of inks in InkNames string */
int td_customValueCount;
TIFFTagValue *td_customValues;
unsigned char td_deferstrilearraywriting; /* see TIFFDeferStrileArrayWriting() */
unsigned char
td_deferstrilearraywriting; /* see TIFFDeferStrileArrayWriting() */
} TIFFDirectory;
/*
......@@ -174,11 +187,11 @@ typedef struct {
#define FIELD_TRANSFERFUNCTION 44
#define FIELD_INKNAMES 46
#define FIELD_SUBIFD 49
#define FIELD_NUMBEROFINKS 50
/* FIELD_CUSTOM (see tiffio.h) 65 */
/* end of support for well-known tags; codec-private tags follow */
#define FIELD_CODEC 66 /* base of codec-private tags */
/*
* Pseudo-tags don't normally need field bits since they are not written to an
* output file (by definition). The library also has express logic to always
......@@ -189,18 +202,19 @@ typedef struct {
*/
#define FIELD_PSEUDO 0
#define FIELD_LAST (32*FIELD_SETLONGS-1)
#define FIELD_LAST (32 * FIELD_SETLONGS - 1)
#define BITn(n) (((unsigned long)1L)<<((n)&0x1f))
#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n)/32])
#define BITn(n) (((unsigned long)1L) << ((n)&0x1f))
#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
#define FieldSet(fields, f) (fields[(f)/32] & BITn(f))
#define ResetFieldBit(fields, f) (fields[(f)/32] &= ~BITn(f))
#define FieldSet(fields, f) (fields[(f) / 32] & BITn(f))
#define ResetFieldBit(fields, f) (fields[(f) / 32] &= ~BITn(f))
typedef enum {
typedef enum
{
TIFF_SETGET_UNDEFINED = 0,
TIFF_SETGET_ASCII = 1,
TIFF_SETGET_UINT8 = 2,
......@@ -256,62 +270,67 @@ typedef enum {
} TIFFSetGetFieldType;
#if defined(__cplusplus)
extern "C" {
extern "C"
{
#endif
extern const TIFFFieldArray* _TIFFGetFields(void);
extern const TIFFFieldArray* _TIFFGetExifFields(void);
extern const TIFFFieldArray* _TIFFGetGpsFields(void);
extern void _TIFFSetupFields(TIFF* tif, const TIFFFieldArray* infoarray);
extern void _TIFFPrintFieldInfo(TIFF*, FILE*);
extern const TIFFFieldArray *_TIFFGetFields(void);
extern const TIFFFieldArray *_TIFFGetExifFields(void);
extern const TIFFFieldArray *_TIFFGetGpsFields(void);
extern void _TIFFSetupFields(TIFF *tif, const TIFFFieldArray *infoarray);
extern void _TIFFPrintFieldInfo(TIFF *, FILE *);
extern int _TIFFFillStriles(TIFF*);
extern int _TIFFFillStriles(TIFF *);
typedef enum {
typedef enum
{
tfiatImage,
tfiatExif,
tfiatGps, /* EXIF-GPS fields array type */
tfiatOther
} TIFFFieldArrayType;
} TIFFFieldArrayType;
struct _TIFFFieldArray {
TIFFFieldArrayType type; /* array type, will be used to determine if IFD is image and such */
uint32_t allocated_size; /* 0 if array is constant, other if modified by future definition extension support */
struct _TIFFFieldArray
{
TIFFFieldArrayType type; /* array type, will be used to determine if IFD
is image and such */
uint32_t allocated_size; /* 0 if array is constant, other if modified by
future definition extension support */
uint32_t count; /* number of elements in fields array */
TIFFField* fields; /* actual field info */
};
TIFFField *fields; /* actual field info */
};
struct _TIFFField {
struct _TIFFField
{
uint32_t field_tag; /* field's tag */
short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
short field_writecount; /* write count/TIFF_VARIABLE */
TIFFDataType field_type; /* type of associated data */
uint32_t field_anonymous; /* if true, this is a unknown / anonymous tag */
TIFFSetGetFieldType set_field_type; /* type to be passed to TIFFSetField */
TIFFSetGetFieldType get_field_type; /* type to be passed to TIFFGetField */
uint32_t
field_anonymous; /* if true, this is a unknown / anonymous tag */
TIFFSetGetFieldType
set_field_type; /* type to be passed to TIFFSetField */
TIFFSetGetFieldType
get_field_type; /* type to be passed to TIFFGetField */
unsigned short field_bit; /* bit in fieldsset bit vector */
unsigned char field_oktochange; /* if true, can change while writing */
unsigned char field_passcount; /* if true, pass dir count on set */
char* field_name; /* ASCII name */
TIFFFieldArray* field_subfields; /* if field points to child ifds, child ifd field definition array */
};
char *field_name; /* ASCII name */
TIFFFieldArray *field_subfields; /* if field points to child ifds, child
ifd field definition array */
};
extern int _TIFFMergeFields(TIFF*, const TIFFField[], uint32_t);
extern const TIFFField* _TIFFFindOrRegisterField(TIFF *, uint32_t, TIFFDataType);
extern TIFFField* _TIFFCreateAnonField(TIFF *, uint32_t, TIFFDataType);
extern int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag);
extern int _TIFFMergeFields(TIFF *, const TIFFField[], uint32_t);
extern const TIFFField *_TIFFFindOrRegisterField(TIFF *, uint32_t,
TIFFDataType);
extern TIFFField *_TIFFCreateAnonField(TIFF *, uint32_t, TIFFDataType);
extern int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag);
extern int _TIFFCheckDirNumberAndOffset(TIFF *tif, tdir_t dirn,
uint64_t diroff);
extern int _TIFFGetDirNumberFromOffset(TIFF *tif, uint64_t diroff,
tdir_t *dirn);
#if defined(__cplusplus)
}
#endif
#endif /* _TIFFDIR_ */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -29,28 +29,27 @@
*/
#include "tiffiop.h"
static int
DumpFixupTags(TIFF* tif)
static int DumpFixupTags(TIFF *tif)
{
(void) tif;
(void)tif;
return (1);
}
/*
* Encode a hunk of pixels.
*/
static int
DumpModeEncode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s)
static int DumpModeEncode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
{
(void) s;
while (cc > 0) {
(void)s;
while (cc > 0)
{
tmsize_t n;
n = cc;
if (tif->tif_rawcc + n > tif->tif_rawdatasize)
n = tif->tif_rawdatasize - tif->tif_rawcc;
assert( n > 0 );
assert(n > 0);
/*
* Avoid copy if client has setup raw
......@@ -62,8 +61,7 @@ DumpModeEncode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s)
tif->tif_rawcc += n;
pp += n;
cc -= n;
if (tif->tif_rawcc >= tif->tif_rawdatasize &&
!TIFFFlushData1(tif))
if (tif->tif_rawcc >= tif->tif_rawdatasize && !TIFFFlushData1(tif))
return (0);
}
return (1);
......@@ -72,17 +70,17 @@ DumpModeEncode(TIFF* tif, uint8_t* pp, tmsize_t cc, uint16_t s)
/*
* Decode a hunk of pixels.
*/
static int
DumpModeDecode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s)
static int DumpModeDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s)
{
static const char module[] = "DumpModeDecode";
(void) s;
if (tif->tif_rawcc < cc) {
TIFFErrorExt(tif->tif_clientdata, module,
"Not enough data for scanline %"PRIu32", expected a request for at most %"TIFF_SSIZE_FORMAT" bytes, got a request for %"TIFF_SSIZE_FORMAT" bytes",
tif->tif_row,
tif->tif_rawcc,
cc);
(void)s;
if (tif->tif_rawcc < cc)
{
TIFFErrorExtR(tif, module,
"Not enough data for scanline %" PRIu32
", expected a request for at most %" TIFF_SSIZE_FORMAT
" bytes, got a request for %" TIFF_SSIZE_FORMAT " bytes",
tif->tif_row, tif->tif_rawcc, cc);
return (0);
}
/*
......@@ -99,8 +97,7 @@ DumpModeDecode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s)
/*
* Seek forwards nrows in the current strip.
*/
static int
DumpModeSeek(TIFF* tif, uint32_t nrows)
static int DumpModeSeek(TIFF *tif, uint32_t nrows)
{
tif->tif_rawcp += nrows * tif->tif_scanlinesize;
tif->tif_rawcc -= nrows * tif->tif_scanlinesize;
......@@ -110,10 +107,9 @@ DumpModeSeek(TIFF* tif, uint32_t nrows)
/*
* Initialize dump mode.
*/
int
TIFFInitDumpMode(TIFF* tif, int scheme)
int TIFFInitDumpMode(TIFF *tif, int scheme)
{
(void) scheme;
(void)scheme;
tif->tif_fixuptags = DumpFixupTags;
tif->tif_decoderow = DumpModeDecode;
tif->tif_decodestrip = DumpModeDecode;
......@@ -124,10 +120,3 @@ TIFFInitDumpMode(TIFF* tif, int scheme)
tif->tif_seek = DumpModeSeek;
return (1);
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/
......@@ -29,58 +29,104 @@
TIFFErrorHandlerExt _TIFFerrorHandlerExt = NULL;
TIFFErrorHandler
TIFFSetErrorHandler(TIFFErrorHandler handler)
TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler handler)
{
TIFFErrorHandler prev = _TIFFerrorHandler;
_TIFFerrorHandler = handler;
return (prev);
}
TIFFErrorHandlerExt
TIFFSetErrorHandlerExt(TIFFErrorHandlerExt handler)
TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt handler)
{
TIFFErrorHandlerExt prev = _TIFFerrorHandlerExt;
_TIFFerrorHandlerExt = handler;
return (prev);
}
void
TIFFError(const char* module, const char* fmt, ...)
void TIFFError(const char *module, const char *fmt, ...)
{
va_list ap;
if (_TIFFerrorHandler) {
if (_TIFFerrorHandler)
{
va_start(ap, fmt);
(*_TIFFerrorHandler)(module, fmt, ap);
va_end(ap);
}
if (_TIFFerrorHandlerExt) {
if (_TIFFerrorHandlerExt)
{
va_start(ap, fmt);
(*_TIFFerrorHandlerExt)(0, module, fmt, ap);
va_end(ap);
}
}
void
TIFFErrorExt(thandle_t fd, const char* module, const char* fmt, ...)
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt, ...)
{
va_list ap;
if (_TIFFerrorHandler) {
if (_TIFFerrorHandler)
{
va_start(ap, fmt);
(*_TIFFerrorHandler)(module, fmt, ap);
va_end(ap);
}
if (_TIFFerrorHandlerExt) {
if (_TIFFerrorHandlerExt)
{
va_start(ap, fmt);
(*_TIFFerrorHandlerExt)(fd, module, fmt, ap);
va_end(ap);
}
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/
void _TIFFErrorEarly(TIFFOpenOptions *opts, thandle_t clientdata,
const char *module, const char *fmt, ...)
{
va_list ap;
if (opts && opts->errorhandler)
{
va_start(ap, fmt);
int stop = opts->errorhandler(NULL, opts->errorhandler_user_data,
module, fmt, ap);
va_end(ap);
if (stop)
return;
}
if (_TIFFerrorHandler)
{
va_start(ap, fmt);
(*_TIFFerrorHandler)(module, fmt, ap);
va_end(ap);
}
if (_TIFFerrorHandlerExt)
{
va_start(ap, fmt);
(*_TIFFerrorHandlerExt)(clientdata, module, fmt, ap);
va_end(ap);
}
}
void TIFFErrorExtR(TIFF *tif, const char *module, const char *fmt, ...)
{
va_list ap;
if (tif && tif->tif_errorhandler)
{
va_start(ap, fmt);
int stop = (*tif->tif_errorhandler)(
tif, tif->tif_errorhandler_user_data, module, fmt, ap);
va_end(ap);
if (stop)
return;
}
if (_TIFFerrorHandler)
{
va_start(ap, fmt);
(*_TIFFerrorHandler)(module, fmt, ap);
va_end(ap);
}
if (_TIFFerrorHandlerExt)
{
va_start(ap, fmt);
(*_TIFFerrorHandlerExt)(tif ? tif->tif_clientdata : NULL, module, fmt,
ap);
va_end(ap);
}
}
......@@ -27,10 +27,9 @@
*/
#include "tiffiop.h"
int
TIFFFlush(TIFF* tif)
int TIFFFlush(TIFF *tif)
{
if( tif->tif_mode == O_RDONLY )
if (tif->tif_mode == O_RDONLY)
return 1;
if (!TIFFFlushData(tif))
......@@ -41,16 +40,15 @@ TIFFFlush(TIFF* tif)
rewrite only that portion of the directory without
making any other changes */
if( (tif->tif_flags & TIFF_DIRTYSTRIP)
&& !(tif->tif_flags & TIFF_DIRTYDIRECT)
&& tif->tif_mode == O_RDWR )
if ((tif->tif_flags & TIFF_DIRTYSTRIP) &&
!(tif->tif_flags & TIFF_DIRTYDIRECT) && tif->tif_mode == O_RDWR)
{
if( TIFFForceStrileArrayWriting(tif) )
if (TIFFForceStrileArrayWriting(tif))
return 1;
}
if ((tif->tif_flags & (TIFF_DIRTYDIRECT|TIFF_DIRTYSTRIP))
&& !TIFFRewriteDirectory(tif))
if ((tif->tif_flags & (TIFF_DIRTYDIRECT | TIFF_DIRTYSTRIP)) &&
!TIFFRewriteDirectory(tif))
return (0);
return (1);
......@@ -75,43 +73,41 @@ TIFFFlush(TIFF* tif)
*
* Returns 1 in case of success, 0 otherwise.
*/
int TIFFForceStrileArrayWriting(TIFF* tif)
int TIFFForceStrileArrayWriting(TIFF *tif)
{
static const char module[] = "TIFFForceStrileArrayWriting";
const int isTiled = TIFFIsTiled(tif);
if (tif->tif_mode == O_RDONLY)
{
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"File opened in read-only mode");
TIFFErrorExtR(tif, tif->tif_name, "File opened in read-only mode");
return 0;
}
if( tif->tif_diroff == 0 )
if (tif->tif_diroff == 0)
{
TIFFErrorExt(tif->tif_clientdata, module,
"Directory has not yet been written");
TIFFErrorExtR(tif, module, "Directory has not yet been written");
return 0;
}
if( (tif->tif_flags & TIFF_DIRTYDIRECT) != 0 )
if ((tif->tif_flags & TIFF_DIRTYDIRECT) != 0)
{
TIFFErrorExt(tif->tif_clientdata, module,
TIFFErrorExtR(tif, module,
"Directory has changes other than the strile arrays. "
"TIFFRewriteDirectory() should be called instead");
return 0;
}
if( !(tif->tif_flags & TIFF_DIRTYSTRIP) )
if (!(tif->tif_flags & TIFF_DIRTYSTRIP))
{
if( !(tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 &&
if (!(tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 &&
tif->tif_dir.td_stripoffset_entry.tdir_count == 0 &&
tif->tif_dir.td_stripoffset_entry.tdir_type == 0 &&
tif->tif_dir.td_stripoffset_entry.tdir_offset.toff_long8 == 0 &&
tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0 &&
tif->tif_dir.td_stripbytecount_entry.tdir_count == 0 &&
tif->tif_dir.td_stripbytecount_entry.tdir_type == 0 &&
tif->tif_dir.td_stripbytecount_entry.tdir_offset.toff_long8 == 0) )
tif->tif_dir.td_stripbytecount_entry.tdir_offset.toff_long8 == 0))
{
TIFFErrorExt(tif->tif_clientdata, module,
TIFFErrorExtR(tif, module,
"Function not called together with "
"TIFFDeferStrileArrayWriting()");
return 0;
......@@ -121,18 +117,14 @@ int TIFFForceStrileArrayWriting(TIFF* tif)
return 0;
}
if( _TIFFRewriteField( tif,
isTiled ? TIFFTAG_TILEOFFSETS :
TIFFTAG_STRIPOFFSETS,
TIFF_LONG8,
tif->tif_dir.td_nstrips,
tif->tif_dir.td_stripoffset_p )
&& _TIFFRewriteField( tif,
isTiled ? TIFFTAG_TILEBYTECOUNTS :
TIFFTAG_STRIPBYTECOUNTS,
TIFF_LONG8,
tif->tif_dir.td_nstrips,
tif->tif_dir.td_stripbytecount_p ) )
if (_TIFFRewriteField(tif,
isTiled ? TIFFTAG_TILEOFFSETS : TIFFTAG_STRIPOFFSETS,
TIFF_LONG8, tif->tif_dir.td_nstrips,
tif->tif_dir.td_stripoffset_p) &&
_TIFFRewriteField(
tif, isTiled ? TIFFTAG_TILEBYTECOUNTS : TIFFTAG_STRIPBYTECOUNTS,
TIFF_LONG8, tif->tif_dir.td_nstrips,
tif->tif_dir.td_stripbytecount_p))
{
tif->tif_flags &= ~TIFF_DIRTYSTRIP;
tif->tif_flags &= ~TIFF_BEENWRITING;
......@@ -151,24 +143,15 @@ int TIFFForceStrileArrayWriting(TIFF* tif)
* been writing isn't exactly a an error. Hopefully this doesn't cause
* problems for other people.
*/
int
TIFFFlushData(TIFF* tif)
int TIFFFlushData(TIFF *tif)
{
if ((tif->tif_flags & TIFF_BEENWRITING) == 0)
return (1);
if (tif->tif_flags & TIFF_POSTENCODE) {
if (tif->tif_flags & TIFF_POSTENCODE)
{
tif->tif_flags &= ~TIFF_POSTENCODE;
if (!(*tif->tif_postencode)(tif))
return (0);
}
return (TIFFFlushData1(tif));
}
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/
/**********************************************************************
* $Id$
*
* Name: tif_hash_set.h
* Project: TIFF - Common Portability Library
* Purpose: Hash set functions.
* Author: Even Rouault, <even dot rouault at spatialys.com>
*
**********************************************************************
* Copyright (c) 2008-2009, Even Rouault <even dot rouault at spatialys.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#ifndef TIFF_HASH_SET_H_INCLUDED
#define TIFF_HASH_SET_H_INCLUDED
#include <stdbool.h>
/**
* \file tif_hash_set.h
*
* Hash set implementation.
*
* An hash set is a data structure that holds elements that are unique
* according to a comparison function. Operations on the hash set, such as
* insertion, removal or lookup, are supposed to be fast if an efficient
* "hash" function is provided.
*/
#ifdef __cplusplus
extern "C"
{
#endif
/* Types */
/** Opaque type for a hash set */
typedef struct _TIFFHashSet TIFFHashSet;
/** TIFFHashSetHashFunc */
typedef unsigned long (*TIFFHashSetHashFunc)(const void *elt);
/** TIFFHashSetEqualFunc */
typedef bool (*TIFFHashSetEqualFunc)(const void *elt1, const void *elt2);
/** TIFFHashSetFreeEltFunc */
typedef void (*TIFFHashSetFreeEltFunc)(void *elt);
/* Functions */
TIFFHashSet *TIFFHashSetNew(TIFFHashSetHashFunc fnHashFunc,
TIFFHashSetEqualFunc fnEqualFunc,
TIFFHashSetFreeEltFunc fnFreeEltFunc);
void TIFFHashSetDestroy(TIFFHashSet *set);
#ifdef notused
void TIFFHashSetClear(TIFFHashSet *set);
int TIFFHashSetSize(const TIFFHashSet *set);
/** TIFFHashSetIterEltFunc */
typedef int (*TIFFHashSetIterEltFunc)(void *elt, void *user_data);
void TIFFHashSetForeach(TIFFHashSet *set, TIFFHashSetIterEltFunc fnIterFunc,
void *user_data);
#endif
bool TIFFHashSetInsert(TIFFHashSet *set, void *elt);
void *TIFFHashSetLookup(TIFFHashSet *set, const void *elt);
bool TIFFHashSetRemove(TIFFHashSet *set, const void *elt);
#ifdef notused
bool TIFFHashSetRemoveDeferRehash(TIFFHashSet *set, const void *elt);
#endif
#ifdef __cplusplus
}
#endif
#endif /* TIFF_HASH_SET_H_INCLUDED */
......@@ -30,35 +30,45 @@
* NeXT 2-bit Grey Scale Compression Algorithm Support
*/
#define SETPIXEL(op, v) { \
switch (npixels++ & 3) { \
case 0: op[0] = (unsigned char) ((v) << 6); break; \
case 1: op[0] |= (v) << 4; break; \
case 2: op[0] |= (v) << 2; break; \
case 3: *op++ |= (v); op_offset++; break; \
#define SETPIXEL(op, v) \
{ \
switch (npixels++ & 3) \
{ \
case 0: \
op[0] = (unsigned char)((v) << 6); \
break; \
case 1: \
op[0] |= (v) << 4; \
break; \
case 2: \
op[0] |= (v) << 2; \
break; \
case 3: \
*op++ |= (v); \
op_offset++; \
break; \
} \
}
}
#define LITERALROW 0x00
#define LITERALSPAN 0x40
#define WHITE ((1<<2)-1)
#define WHITE ((1 << 2) - 1)
static int
NeXTDecode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
static int NeXTDecode(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s)
{
static const char module[] = "NeXTDecode";
unsigned char *bp, *op;
tmsize_t cc;
uint8_t* row;
uint8_t *row;
tmsize_t scanline, n;
(void) s;
(void)s;
/*
* Each scanline is assumed to start off as all
* white (we assume a PhotometricInterpretation
* of ``min-is-black'').
*/
for (op = (unsigned char*) buf, cc = occ; cc-- > 0;)
for (op = (unsigned char *)buf, cc = occ; cc-- > 0;)
*op++ = 0xff;
bp = (unsigned char *)tif->tif_rawcp;
......@@ -66,13 +76,15 @@ NeXTDecode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
scanline = tif->tif_scanlinesize;
if (occ % scanline)
{
TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read");
TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
return (0);
}
for (row = buf; cc > 0 && occ > 0; occ -= scanline, row += scanline) {
for (row = buf; cc > 0 && occ > 0; occ -= scanline, row += scanline)
{
n = *bp++;
cc--;
switch (n) {
switch (n)
{
case LITERALROW:
/*
* The entire scanline is given as literal values.
......@@ -83,28 +95,30 @@ NeXTDecode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
bp += scanline;
cc -= scanline;
break;
case LITERALSPAN: {
case LITERALSPAN:
{
tmsize_t off;
/*
* The scanline has a literal span that begins at some
* offset.
*/
if( cc < 4 )
if (cc < 4)
goto bad;
off = (bp[0] * 256) + bp[1];
n = (bp[2] * 256) + bp[3];
if (cc < 4+n || off+n > scanline)
if (cc < 4 + n || off + n > scanline)
goto bad;
_TIFFmemcpy(row+off, bp+4, n);
bp += 4+n;
cc -= 4+n;
_TIFFmemcpy(row + off, bp + 4, n);
bp += 4 + n;
cc -= 4 + n;
break;
}
default: {
default:
{
uint32_t npixels = 0, grey;
tmsize_t op_offset = 0;
uint32_t imagewidth = tif->tif_dir.td_imagewidth;
if( isTiled(tif) )
if (isTiled(tif))
imagewidth = tif->tif_dir.td_tilewidth;
/*
......@@ -114,7 +128,8 @@ NeXTDecode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
* <color><npixels> until we've filled the scanline.
*/
op = row;
for (;;) {
for (;;)
{
grey = (uint32_t)((n >> 6) & 0x3);
n &= 0x3f;
/*
......@@ -122,12 +137,15 @@ NeXTDecode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
* bounds, potentially resulting in a security
* issue.
*/
while (n-- > 0 && npixels < imagewidth && op_offset < scanline)
while (n-- > 0 && npixels < imagewidth &&
op_offset < scanline)
SETPIXEL(op, grey);
if (npixels >= imagewidth)
break;
if (op_offset >= scanline ) {
TIFFErrorExt(tif->tif_clientdata, module, "Invalid data for scanline %"PRIu32,
if (op_offset >= scanline)
{
TIFFErrorExtR(tif, module,
"Invalid data for scanline %" PRIu32,
tif->tif_row);
return (0);
}
......@@ -140,35 +158,33 @@ NeXTDecode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
}
}
}
tif->tif_rawcp = (uint8_t*) bp;
tif->tif_rawcp = (uint8_t *)bp;
tif->tif_rawcc = cc;
return (1);
bad:
TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %"PRIu32,
TIFFErrorExtR(tif, module, "Not enough data for scanline %" PRIu32,
tif->tif_row);
return (0);
}
static int
NeXTPreDecode(TIFF* tif, uint16_t s)
static int NeXTPreDecode(TIFF *tif, uint16_t s)
{
static const char module[] = "NeXTPreDecode";
TIFFDirectory *td = &tif->tif_dir;
(void)s;
if( td->td_bitspersample != 2 )
if (td->td_bitspersample != 2)
{
TIFFErrorExt(tif->tif_clientdata, module, "Unsupported BitsPerSample = %"PRIu16,
TIFFErrorExtR(tif, module, "Unsupported BitsPerSample = %" PRIu16,
td->td_bitspersample);
return (0);
}
return (1);
}
int
TIFFInitNeXT(TIFF* tif, int scheme)
int TIFFInitNeXT(TIFF *tif, int scheme)
{
(void) scheme;
(void)scheme;
tif->tif_predecode = NeXTPreDecode;
tif->tif_decoderow = NeXTDecode;
tif->tif_decodestrip = NeXTDecode;
......@@ -176,12 +192,3 @@ TIFFInitNeXT(TIFF* tif, int scheme)
return (1);
}
#endif /* NEXT_SUPPORT */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/
......@@ -32,14 +32,15 @@
* ``Library-private'' Support for the Predictor Tag
*/
typedef int (*TIFFEncodeDecodeMethod)(TIFF* tif, uint8_t* buf, tmsize_t size);
typedef int (*TIFFEncodeDecodeMethod)(TIFF *tif, uint8_t *buf, tmsize_t size);
/*
* Codecs that want to support the Predictor tag must place
* this structure first in their private state block so that
* the predictor code can cast tif_data to find its state.
*/
typedef struct {
typedef struct
{
int predictor; /* predictor tag value */
tmsize_t stride; /* sample stride over data */
tmsize_t rowsize; /* tile/strip row size */
......@@ -62,20 +63,12 @@ typedef struct {
} TIFFPredictorState;
#if defined(__cplusplus)
extern "C" {
extern "C"
{
#endif
extern int TIFFPredictorInit(TIFF*);
extern int TIFFPredictorCleanup(TIFF*);
extern int TIFFPredictorInit(TIFF *);
extern int TIFFPredictorCleanup(TIFF *);
#if defined(__cplusplus)
}
#endif
#endif /* _TIFFPREDICT_ */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/
......@@ -51,39 +51,38 @@
#define DELTA3_SKIP 4 /* skip code for 3-bit deltas */
#define THUNDER_RAW 0xc0 /* raw data encoded */
static const int twobitdeltas[4] = { 0, 1, 0, -1 };
static const int threebitdeltas[8] = { 0, 1, 2, 3, 0, -3, -2, -1 };
static const int twobitdeltas[4] = {0, 1, 0, -1};
static const int threebitdeltas[8] = {0, 1, 2, 3, 0, -3, -2, -1};
#define SETPIXEL(op, v) { \
lastpixel = (v) & 0xf; \
if ( npixels < maxpixels ) \
#define SETPIXEL(op, v) \
{ \
lastpixel = (v)&0xf; \
if (npixels < maxpixels) \
{ \
if (npixels++ & 1) \
*op++ |= lastpixel; \
else \
op[0] = (uint8_t) (lastpixel << 4); \
op[0] = (uint8_t)(lastpixel << 4); \
} \
}
}
static int
ThunderSetupDecode(TIFF* tif)
static int ThunderSetupDecode(TIFF *tif)
{
static const char module[] = "ThunderSetupDecode";
if( tif->tif_dir.td_bitspersample != 4 )
if (tif->tif_dir.td_bitspersample != 4)
{
TIFFErrorExt(tif->tif_clientdata, module,
"Wrong bitspersample value (%d), Thunder decoder only supports 4bits per sample.",
(int) tif->tif_dir.td_bitspersample );
TIFFErrorExtR(tif, module,
"Wrong bitspersample value (%d), Thunder decoder only "
"supports 4bits per sample.",
(int)tif->tif_dir.td_bitspersample);
return 0;
}
return (1);
}
static int
ThunderDecode(TIFF* tif, uint8_t* op, tmsize_t maxpixels)
static int ThunderDecode(TIFF *tif, uint8_t *op, tmsize_t maxpixels)
{
static const char module[] = "ThunderDecode";
register unsigned char *bp;
......@@ -95,26 +94,33 @@ ThunderDecode(TIFF* tif, uint8_t* op, tmsize_t maxpixels)
cc = tif->tif_rawcc;
lastpixel = 0;
npixels = 0;
while (cc > 0 && npixels < maxpixels) {
while (cc > 0 && npixels < maxpixels)
{
int n, delta;
n = *bp++;
cc--;
switch (n & THUNDER_CODE) {
switch (n & THUNDER_CODE)
{
case THUNDER_RUN: /* pixel run */
/*
* Replicate the last pixel n times,
* where n is the lower-order 6 bits.
*/
if (npixels & 1) {
if (npixels & 1)
{
op[0] |= lastpixel;
lastpixel = *op++; npixels++; n--;
} else
lastpixel = *op++;
npixels++;
n--;
}
else
lastpixel |= lastpixel << 4;
npixels += n;
if (npixels < maxpixels) {
if (npixels < maxpixels)
{
for (; n > 0; n -= 2)
*op++ = (uint8_t) lastpixel;
*op++ = (uint8_t)lastpixel;
}
if (n == -1)
*--op &= 0xf0;
......@@ -122,51 +128,56 @@ ThunderDecode(TIFF* tif, uint8_t* op, tmsize_t maxpixels)
break;
case THUNDER_2BITDELTAS: /* 2-bit deltas */
if ((delta = ((n >> 4) & 3)) != DELTA2_SKIP)
SETPIXEL(op, (unsigned)((int)lastpixel + twobitdeltas[delta]));
SETPIXEL(op,
(unsigned)((int)lastpixel + twobitdeltas[delta]));
if ((delta = ((n >> 2) & 3)) != DELTA2_SKIP)
SETPIXEL(op, (unsigned)((int)lastpixel + twobitdeltas[delta]));
SETPIXEL(op,
(unsigned)((int)lastpixel + twobitdeltas[delta]));
if ((delta = (n & 3)) != DELTA2_SKIP)
SETPIXEL(op, (unsigned)((int)lastpixel + twobitdeltas[delta]));
SETPIXEL(op,
(unsigned)((int)lastpixel + twobitdeltas[delta]));
break;
case THUNDER_3BITDELTAS: /* 3-bit deltas */
if ((delta = ((n >> 3) & 7)) != DELTA3_SKIP)
SETPIXEL(op, (unsigned)((int)lastpixel + threebitdeltas[delta]));
SETPIXEL(
op, (unsigned)((int)lastpixel + threebitdeltas[delta]));
if ((delta = (n & 7)) != DELTA3_SKIP)
SETPIXEL(op, (unsigned)((int)lastpixel + threebitdeltas[delta]));
SETPIXEL(
op, (unsigned)((int)lastpixel + threebitdeltas[delta]));
break;
case THUNDER_RAW: /* raw data */
SETPIXEL(op, n);
break;
}
}
tif->tif_rawcp = (uint8_t*) bp;
tif->tif_rawcp = (uint8_t *)bp;
tif->tif_rawcc = cc;
if (npixels != maxpixels) {
TIFFErrorExt(tif->tif_clientdata, module,
"%s data at scanline %lu (%"PRIu64" != %"PRIu64")",
if (npixels != maxpixels)
{
TIFFErrorExtR(tif, module,
"%s data at scanline %lu (%" PRIu64 " != %" PRIu64 ")",
npixels < maxpixels ? "Not enough" : "Too much",
(unsigned long) tif->tif_row,
(uint64_t) npixels,
(uint64_t) maxpixels);
(unsigned long)tif->tif_row, (uint64_t)npixels,
(uint64_t)maxpixels);
return (0);
}
return (1);
}
static int
ThunderDecodeRow(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
static int ThunderDecodeRow(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s)
{
static const char module[] = "ThunderDecodeRow";
uint8_t* row = buf;
uint8_t *row = buf;
(void) s;
(void)s;
if (occ % tif->tif_scanlinesize)
{
TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read");
TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read");
return (0);
}
while (occ > 0) {
while (occ > 0)
{
if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth))
return (0);
occ -= tif->tif_scanlinesize;
......@@ -175,10 +186,9 @@ ThunderDecodeRow(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
return (1);
}
int
TIFFInitThunderScan(TIFF* tif, int scheme)
int TIFFInitThunderScan(TIFF *tif, int scheme)
{
(void) scheme;
(void)scheme;
tif->tif_setupdecode = ThunderSetupDecode;
tif->tif_decoderow = ThunderDecodeRow;
......@@ -186,12 +196,3 @@ TIFFInitThunderScan(TIFF* tif, int scheme)
return (1);
}
#endif /* THUNDER_SUPPORT */
/* vim: set ts=8 sts=8 sw=8 noet: */
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/
......@@ -29,59 +29,77 @@
TIFFErrorHandlerExt _TIFFwarningHandlerExt = NULL;
TIFFErrorHandler
TIFFSetWarningHandler(TIFFErrorHandler handler)
TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler handler)
{
TIFFErrorHandler prev = _TIFFwarningHandler;
_TIFFwarningHandler = handler;
return (prev);
}
TIFFErrorHandlerExt
TIFFSetWarningHandlerExt(TIFFErrorHandlerExt handler)
TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt handler)
{
TIFFErrorHandlerExt prev = _TIFFwarningHandlerExt;
_TIFFwarningHandlerExt = handler;
return (prev);
}
void
TIFFWarning(const char* module, const char* fmt, ...)
void TIFFWarning(const char *module, const char *fmt, ...)
{
va_list ap;
if (_TIFFwarningHandler) {
if (_TIFFwarningHandler)
{
va_start(ap, fmt);
(*_TIFFwarningHandler)(module, fmt, ap);
va_end(ap);
}
if (_TIFFwarningHandlerExt) {
if (_TIFFwarningHandlerExt)
{
va_start(ap, fmt);
(*_TIFFwarningHandlerExt)(0, module, fmt, ap);
va_end(ap);
}
}
void
TIFFWarningExt(thandle_t fd, const char* module, const char* fmt, ...)
void TIFFWarningExt(thandle_t fd, const char *module, const char *fmt, ...)
{
va_list ap;
if (_TIFFwarningHandler) {
if (_TIFFwarningHandler)
{
va_start(ap, fmt);
(*_TIFFwarningHandler)(module, fmt, ap);
va_end(ap);
}
if (_TIFFwarningHandlerExt) {
if (_TIFFwarningHandlerExt)
{
va_start(ap, fmt);
(*_TIFFwarningHandlerExt)(fd, module, fmt, ap);
va_end(ap);
}
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 8
* fill-column: 78
* End:
*/
void TIFFWarningExtR(TIFF *tif, const char *module, const char *fmt, ...)
{
va_list ap;
if (tif && tif->tif_warnhandler)
{
va_start(ap, fmt);
int stop = (*tif->tif_warnhandler)(tif, tif->tif_warnhandler_user_data,
module, fmt, ap);
va_end(ap);
if (stop)
return;
}
if (_TIFFwarningHandler)
{
va_start(ap, fmt);
(*_TIFFwarningHandler)(module, fmt, ap);
va_end(ap);
}
if (_TIFFwarningHandlerExt)
{
va_start(ap, fmt);
(*_TIFFwarningHandlerExt)(tif ? tif->tif_clientdata : 0, module, fmt,
ap);
va_end(ap);
}
}
......@@ -12,6 +12,7 @@
#include <stddef.h>
#include <stdint.h>
#include <inttypes.h>
#include <sys/types.h>
/* Signed 16-bit type */
......
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.4.0\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
/* clang-format off */
/* clang-format disabled because FindTIFF.cmake is very sensitive to the
* formatting of below line being a single line.
*/
#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.5.0\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc."
/*
* This define can be used in code that requires
* compilation-related definitions specific to a
......@@ -6,4 +11,20 @@
* version checking should be done based on the
* string returned by TIFFGetVersion.
*/
#define TIFFLIB_VERSION 20220520
#define TIFFLIB_VERSION 20221213
/* The following defines have been added in 4.5.0 */
#define TIFFLIB_MAJOR_VERSION 4
#define TIFFLIB_MINOR_VERSION 5
#define TIFFLIB_MICRO_VERSION 0
/* Macro added in 4.5.0. Returns TRUE if the current libtiff version is
* greater or equal to major.minor.micro
*/
#define TIFFLIB_AT_LEAST(major, minor, micro) \
(TIFFLIB_MAJOR_VERSION > (major) || \
(TIFFLIB_MAJOR_VERSION == (major) && TIFFLIB_MINOR_VERSION > (minor)) || \
(TIFFLIB_MAJOR_VERSION == (major) && TIFFLIB_MINOR_VERSION == (minor) && \
TIFFLIB_MICRO_VERSION >= (micro)))
/* clang-format on */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment