Blame libtiff/tif_dir.h

Packit 7838c8
/* $Id: tif_dir.h,v 1.55 2017-06-01 12:44:04 erouault Exp $ */
Packit 7838c8
Packit 7838c8
/*
Packit 7838c8
 * Copyright (c) 1988-1997 Sam Leffler
Packit 7838c8
 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
Packit 7838c8
 *
Packit 7838c8
 * Permission to use, copy, modify, distribute, and sell this software and 
Packit 7838c8
 * its documentation for any purpose is hereby granted without fee, provided
Packit 7838c8
 * that (i) the above copyright notices and this permission notice appear in
Packit 7838c8
 * all copies of the software and related documentation, and (ii) the names of
Packit 7838c8
 * Sam Leffler and Silicon Graphics may not be used in any advertising or
Packit 7838c8
 * publicity relating to the software without the specific, prior written
Packit 7838c8
 * permission of Sam Leffler and Silicon Graphics.
Packit 7838c8
 * 
Packit 7838c8
 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
Packit 7838c8
 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
Packit 7838c8
 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
Packit 7838c8
 * 
Packit 7838c8
 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
Packit 7838c8
 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
Packit 7838c8
 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
Packit 7838c8
 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
Packit 7838c8
 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
Packit 7838c8
 * OF THIS SOFTWARE.
Packit 7838c8
 */
Packit 7838c8
Packit 7838c8
#ifndef _TIFFDIR_
Packit 7838c8
#define	_TIFFDIR_
Packit 7838c8
/*
Packit 7838c8
 * ``Library-private'' Directory-related Definitions.
Packit 7838c8
 */
Packit 7838c8
Packit 7838c8
typedef struct {
Packit 7838c8
	const TIFFField *info;
Packit 7838c8
	int             count;
Packit 7838c8
	void           *value;
Packit 7838c8
} TIFFTagValue;
Packit 7838c8
Packit 7838c8
/*
Packit 7838c8
 * TIFF Image File Directories are comprised of a table of field
Packit 7838c8
 * descriptors of the form shown below.  The table is sorted in
Packit 7838c8
 * ascending order by tag.  The values associated with each entry are
Packit 7838c8
 * disjoint and may appear anywhere in the file (so long as they are
Packit 7838c8
 * placed on a word boundary).
Packit 7838c8
 *
Packit 7838c8
 * If the value is 4 bytes or less, in ClassicTIFF, or 8 bytes or less in
Packit 7838c8
 * BigTIFF, then it is placed in the offset field to save space. If so,
Packit 7838c8
 * it is left-justified in the offset field.
Packit 7838c8
 */
Packit 7838c8
typedef struct {
Packit 7838c8
	uint16 tdir_tag;        /* see below */
Packit 7838c8
	uint16 tdir_type;       /* data type; see below */
Packit 7838c8
	uint64 tdir_count;      /* number of items; length in spec */
Packit 7838c8
	union {
Packit 7838c8
		uint16 toff_short;
Packit 7838c8
		uint32 toff_long;
Packit 7838c8
		uint64 toff_long8;
Packit 7838c8
	} tdir_offset;		/* either offset or the data itself if fits */
Packit 7838c8
} TIFFDirEntry;
Packit 7838c8
Packit 7838c8
/*
Packit 7838c8
 * Internal format of a TIFF directory entry.
Packit 7838c8
 */
Packit 7838c8
typedef struct {
Packit 7838c8
#define FIELD_SETLONGS 4
Packit 7838c8
	/* bit vector of fields that are set */
Packit 7838c8
	unsigned long td_fieldsset[FIELD_SETLONGS];
Packit 7838c8
Packit 7838c8
	uint32  td_imagewidth, td_imagelength, td_imagedepth;
Packit 7838c8
	uint32  td_tilewidth, td_tilelength, td_tiledepth;
Packit 7838c8
	uint32  td_subfiletype;
Packit 7838c8
	uint16  td_bitspersample;
Packit 7838c8
	uint16  td_sampleformat;
Packit 7838c8
	uint16  td_compression;
Packit 7838c8
	uint16  td_photometric;
Packit 7838c8
	uint16  td_threshholding;
Packit 7838c8
	uint16  td_fillorder;
Packit 7838c8
	uint16  td_orientation;
Packit 7838c8
	uint16  td_samplesperpixel;
Packit 7838c8
	uint32  td_rowsperstrip;
Packit 7838c8
	uint16  td_minsamplevalue, td_maxsamplevalue;
Packit 7838c8
	double* td_sminsamplevalue;
Packit 7838c8
	double* td_smaxsamplevalue;
Packit 7838c8
	float   td_xresolution, td_yresolution;
Packit 7838c8
	uint16  td_resolutionunit;
Packit 7838c8
	uint16  td_planarconfig;
Packit 7838c8
	float   td_xposition, td_yposition;
Packit 7838c8
	uint16  td_pagenumber[2];
Packit 7838c8
	uint16* td_colormap[3];
Packit 7838c8
	uint16  td_halftonehints[2];
Packit 7838c8
	uint16  td_extrasamples;
Packit 7838c8
	uint16* td_sampleinfo;
Packit 7838c8
	/* even though the name is misleading, td_stripsperimage is the number
Packit 7838c8
	 * of striles (=strips or tiles) per plane, and td_nstrips the total
Packit 7838c8
	 * number of striles */
Packit 7838c8
	uint32  td_stripsperimage;  
Packit 7838c8
	uint32  td_nstrips;              /* size of offset & bytecount arrays */
Packit 7838c8
	uint64* td_stripoffset;
Packit 7838c8
	uint64* td_stripbytecount;
Packit 7838c8
	int     td_stripbytecountsorted; /* is the bytecount array sorted ascending? */
Packit 7838c8
#if defined(DEFER_STRILE_LOAD)
Packit 7838c8
        TIFFDirEntry td_stripoffset_entry;    /* for deferred loading */
Packit 7838c8
        TIFFDirEntry td_stripbytecount_entry; /* for deferred loading */
Packit 7838c8
#endif
Packit 7838c8
	uint16  td_nsubifd;
Packit 7838c8
	uint64* td_subifd;
Packit 7838c8
	/* YCbCr parameters */
Packit 7838c8
	uint16  td_ycbcrsubsampling[2];
Packit 7838c8
	uint16  td_ycbcrpositioning;
Packit 7838c8
	/* Colorimetry parameters */
Packit 7838c8
	uint16* td_transferfunction[3];
Packit 7838c8
	float*	td_refblackwhite;
Packit 7838c8
	/* CMYK parameters */
Packit 7838c8
	int     td_inknameslen;
Packit 7838c8
	char*   td_inknames;
Packit 7838c8
Packit 7838c8
	int     td_customValueCount;
Packit 7838c8
        TIFFTagValue *td_customValues;
Packit 7838c8
} TIFFDirectory;
Packit 7838c8
Packit 7838c8
/*
Packit 7838c8
 * Field flags used to indicate fields that have been set in a directory, and
Packit 7838c8
 * to reference fields when manipulating a directory.
Packit 7838c8
 */
Packit 7838c8
Packit 7838c8
/*
Packit 7838c8
 * FIELD_IGNORE is used to signify tags that are to be processed but otherwise
Packit 7838c8
 * ignored.  This permits antiquated tags to be quietly read and discarded.
Packit 7838c8
 * Note that a bit *is* allocated for ignored tags; this is understood by the
Packit 7838c8
 * directory reading logic which uses this fact to avoid special-case handling
Packit 7838c8
 */
Packit 7838c8
#define FIELD_IGNORE                   0
Packit 7838c8
Packit 7838c8
/* multi-item fields */
Packit 7838c8
#define FIELD_IMAGEDIMENSIONS          1
Packit 7838c8
#define FIELD_TILEDIMENSIONS           2
Packit 7838c8
#define FIELD_RESOLUTION               3
Packit 7838c8
#define FIELD_POSITION                 4
Packit 7838c8
Packit 7838c8
/* single-item fields */
Packit 7838c8
#define FIELD_SUBFILETYPE              5
Packit 7838c8
#define FIELD_BITSPERSAMPLE            6
Packit 7838c8
#define FIELD_COMPRESSION              7
Packit 7838c8
#define FIELD_PHOTOMETRIC              8
Packit 7838c8
#define FIELD_THRESHHOLDING            9
Packit 7838c8
#define FIELD_FILLORDER                10
Packit 7838c8
#define FIELD_ORIENTATION              15
Packit 7838c8
#define FIELD_SAMPLESPERPIXEL          16
Packit 7838c8
#define FIELD_ROWSPERSTRIP             17
Packit 7838c8
#define FIELD_MINSAMPLEVALUE           18
Packit 7838c8
#define FIELD_MAXSAMPLEVALUE           19
Packit 7838c8
#define FIELD_PLANARCONFIG             20
Packit 7838c8
#define FIELD_RESOLUTIONUNIT           22
Packit 7838c8
#define FIELD_PAGENUMBER               23
Packit 7838c8
#define FIELD_STRIPBYTECOUNTS          24
Packit 7838c8
#define FIELD_STRIPOFFSETS             25
Packit 7838c8
#define FIELD_COLORMAP                 26
Packit 7838c8
#define FIELD_EXTRASAMPLES             31
Packit 7838c8
#define FIELD_SAMPLEFORMAT             32
Packit 7838c8
#define FIELD_SMINSAMPLEVALUE          33
Packit 7838c8
#define FIELD_SMAXSAMPLEVALUE          34
Packit 7838c8
#define FIELD_IMAGEDEPTH               35
Packit 7838c8
#define FIELD_TILEDEPTH                36
Packit 7838c8
#define FIELD_HALFTONEHINTS            37
Packit 7838c8
#define FIELD_YCBCRSUBSAMPLING         39
Packit 7838c8
#define FIELD_YCBCRPOSITIONING         40
Packit 7838c8
#define	FIELD_REFBLACKWHITE            41
Packit 7838c8
#define FIELD_TRANSFERFUNCTION         44
Packit 7838c8
#define FIELD_INKNAMES                 46
Packit 7838c8
#define FIELD_SUBIFD                   49
Packit 7838c8
/*      FIELD_CUSTOM (see tiffio.h)    65 */
Packit 7838c8
/* end of support for well-known tags; codec-private tags follow */
Packit 7838c8
#define FIELD_CODEC                    66  /* base of codec-private tags */
Packit 7838c8
Packit 7838c8
Packit 7838c8
/*
Packit 7838c8
 * Pseudo-tags don't normally need field bits since they are not written to an
Packit 7838c8
 * output file (by definition). The library also has express logic to always
Packit 7838c8
 * query a codec for a pseudo-tag so allocating a field bit for one is a
Packit 7838c8
 * waste.   If codec wants to promote the notion of a pseudo-tag being ``set''
Packit 7838c8
 * or ``unset'' then it can do using internal state flags without polluting
Packit 7838c8
 * the field bit space defined for real tags.
Packit 7838c8
 */
Packit 7838c8
#define FIELD_PSEUDO			0
Packit 7838c8
Packit 7838c8
#define FIELD_LAST			(32*FIELD_SETLONGS-1)
Packit 7838c8
Packit 7838c8
#define BITn(n)				(((unsigned long)1L)<<((n)&0x1f))
Packit 7838c8
#define BITFIELDn(tif, n)		((tif)->tif_dir.td_fieldsset[(n)/32])
Packit 7838c8
#define TIFFFieldSet(tif, field)	(BITFIELDn(tif, field) & BITn(field))
Packit 7838c8
#define TIFFSetFieldBit(tif, field)	(BITFIELDn(tif, field) |= BITn(field))
Packit 7838c8
#define TIFFClrFieldBit(tif, field)	(BITFIELDn(tif, field) &= ~BITn(field))
Packit 7838c8
Packit 7838c8
#define FieldSet(fields, f)		(fields[(f)/32] & BITn(f))
Packit 7838c8
#define ResetFieldBit(fields, f)	(fields[(f)/32] &= ~BITn(f))
Packit 7838c8
Packit 7838c8
typedef enum {
Packit 7838c8
	TIFF_SETGET_UNDEFINED = 0,
Packit 7838c8
	TIFF_SETGET_ASCII = 1,
Packit 7838c8
	TIFF_SETGET_UINT8 = 2,
Packit 7838c8
	TIFF_SETGET_SINT8 = 3,
Packit 7838c8
	TIFF_SETGET_UINT16 = 4,
Packit 7838c8
	TIFF_SETGET_SINT16 = 5,
Packit 7838c8
	TIFF_SETGET_UINT32 = 6,
Packit 7838c8
	TIFF_SETGET_SINT32 = 7,
Packit 7838c8
	TIFF_SETGET_UINT64 = 8,
Packit 7838c8
	TIFF_SETGET_SINT64 = 9,
Packit 7838c8
	TIFF_SETGET_FLOAT = 10,
Packit 7838c8
	TIFF_SETGET_DOUBLE = 11,
Packit 7838c8
	TIFF_SETGET_IFD8 = 12,
Packit 7838c8
	TIFF_SETGET_INT = 13,
Packit 7838c8
	TIFF_SETGET_UINT16_PAIR = 14,
Packit 7838c8
	TIFF_SETGET_C0_ASCII = 15,
Packit 7838c8
	TIFF_SETGET_C0_UINT8 = 16,
Packit 7838c8
	TIFF_SETGET_C0_SINT8 = 17,
Packit 7838c8
	TIFF_SETGET_C0_UINT16 = 18,
Packit 7838c8
	TIFF_SETGET_C0_SINT16 = 19,
Packit 7838c8
	TIFF_SETGET_C0_UINT32 = 20,
Packit 7838c8
	TIFF_SETGET_C0_SINT32 = 21,
Packit 7838c8
	TIFF_SETGET_C0_UINT64 = 22,
Packit 7838c8
	TIFF_SETGET_C0_SINT64 = 23,
Packit 7838c8
	TIFF_SETGET_C0_FLOAT = 24,
Packit 7838c8
	TIFF_SETGET_C0_DOUBLE = 25,
Packit 7838c8
	TIFF_SETGET_C0_IFD8 = 26,
Packit 7838c8
	TIFF_SETGET_C16_ASCII = 27,
Packit 7838c8
	TIFF_SETGET_C16_UINT8 = 28,
Packit 7838c8
	TIFF_SETGET_C16_SINT8 = 29,
Packit 7838c8
	TIFF_SETGET_C16_UINT16 = 30,
Packit 7838c8
	TIFF_SETGET_C16_SINT16 = 31,
Packit 7838c8
	TIFF_SETGET_C16_UINT32 = 32,
Packit 7838c8
	TIFF_SETGET_C16_SINT32 = 33,
Packit 7838c8
	TIFF_SETGET_C16_UINT64 = 34,
Packit 7838c8
	TIFF_SETGET_C16_SINT64 = 35,
Packit 7838c8
	TIFF_SETGET_C16_FLOAT = 36,
Packit 7838c8
	TIFF_SETGET_C16_DOUBLE = 37,
Packit 7838c8
	TIFF_SETGET_C16_IFD8 = 38,
Packit 7838c8
	TIFF_SETGET_C32_ASCII = 39,
Packit 7838c8
	TIFF_SETGET_C32_UINT8 = 40,
Packit 7838c8
	TIFF_SETGET_C32_SINT8 = 41,
Packit 7838c8
	TIFF_SETGET_C32_UINT16 = 42,
Packit 7838c8
	TIFF_SETGET_C32_SINT16 = 43,
Packit 7838c8
	TIFF_SETGET_C32_UINT32 = 44,
Packit 7838c8
	TIFF_SETGET_C32_SINT32 = 45,
Packit 7838c8
	TIFF_SETGET_C32_UINT64 = 46,
Packit 7838c8
	TIFF_SETGET_C32_SINT64 = 47,
Packit 7838c8
	TIFF_SETGET_C32_FLOAT = 48,
Packit 7838c8
	TIFF_SETGET_C32_DOUBLE = 49,
Packit 7838c8
	TIFF_SETGET_C32_IFD8 = 50,
Packit 7838c8
	TIFF_SETGET_OTHER = 51
Packit 7838c8
} TIFFSetGetFieldType;
Packit 7838c8
Packit 7838c8
#if defined(__cplusplus)
Packit 7838c8
extern "C" {
Packit 7838c8
#endif
Packit 7838c8
Packit 7838c8
extern const TIFFFieldArray* _TIFFGetFields(void);
Packit 7838c8
extern const TIFFFieldArray* _TIFFGetExifFields(void);
Packit 7838c8
extern void _TIFFSetupFields(TIFF* tif, const TIFFFieldArray* infoarray);
Packit 7838c8
extern void _TIFFPrintFieldInfo(TIFF*, FILE*);
Packit 7838c8
Packit 7838c8
extern int _TIFFFillStriles(TIFF*);        
Packit 7838c8
Packit 7838c8
typedef enum {
Packit 7838c8
	tfiatImage,
Packit 7838c8
	tfiatExif,
Packit 7838c8
	tfiatOther
Packit 7838c8
} TIFFFieldArrayType;
Packit 7838c8
Packit 7838c8
struct _TIFFFieldArray {
Packit 7838c8
	TIFFFieldArrayType type;    /* array type, will be used to determine if IFD is image and such */
Packit 7838c8
	uint32 allocated_size;      /* 0 if array is constant, other if modified by future definition extension support */
Packit 7838c8
	uint32 count;               /* number of elements in fields array */
Packit 7838c8
	TIFFField* fields;          /* actual field info */
Packit 7838c8
};
Packit 7838c8
Packit 7838c8
struct _TIFFField {
Packit 7838c8
	uint32 field_tag;                       /* field's tag */
Packit 7838c8
	short field_readcount;                  /* read count/TIFF_VARIABLE/TIFF_SPP */
Packit 7838c8
	short field_writecount;                 /* write count/TIFF_VARIABLE */
Packit 7838c8
	TIFFDataType field_type;                /* type of associated data */
Packit 7838c8
	uint32 reserved;                        /* reserved for future extension */
Packit 7838c8
	TIFFSetGetFieldType set_field_type;     /* type to be passed to TIFFSetField */
Packit 7838c8
	TIFFSetGetFieldType get_field_type;     /* type to be passed to TIFFGetField */
Packit 7838c8
	unsigned short field_bit;               /* bit in fieldsset bit vector */
Packit 7838c8
	unsigned char field_oktochange;         /* if true, can change while writing */
Packit 7838c8
	unsigned char field_passcount;          /* if true, pass dir count on set */
Packit 7838c8
	char* field_name;                       /* ASCII name */
Packit 7838c8
	TIFFFieldArray* field_subfields;        /* if field points to child ifds, child ifd field definition array */
Packit 7838c8
};
Packit 7838c8
Packit 7838c8
extern int _TIFFMergeFields(TIFF*, const TIFFField[], uint32);
Packit 7838c8
extern const TIFFField* _TIFFFindOrRegisterField(TIFF *, uint32, TIFFDataType);
Packit 7838c8
extern  TIFFField* _TIFFCreateAnonField(TIFF *, uint32, TIFFDataType);
Packit 7838c8
extern int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag);
Packit 7838c8
Packit 7838c8
#if defined(__cplusplus)
Packit 7838c8
}
Packit 7838c8
#endif
Packit 7838c8
#endif /* _TIFFDIR_ */
Packit 7838c8
Packit 7838c8
/* vim: set ts=8 sts=8 sw=8 noet: */
Packit 7838c8
Packit 7838c8
/*
Packit 7838c8
 * Local Variables:
Packit 7838c8
 * mode: c
Packit 7838c8
 * c-basic-offset: 8
Packit 7838c8
 * fill-column: 78
Packit 7838c8
 * End:
Packit 7838c8
 */