ReactOS 0.4.16-dev-2617-g01a0906
tif_dir.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 1988-1997 Sam Leffler
3 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
4 *
5 * Permission to use, copy, modify, distribute, and sell this software and
6 * its documentation for any purpose is hereby granted without fee, provided
7 * that (i) the above copyright notices and this permission notice appear in
8 * all copies of the software and related documentation, and (ii) the names of
9 * Sam Leffler and Silicon Graphics may not be used in any advertising or
10 * publicity relating to the software without the specific, prior written
11 * permission of Sam Leffler and Silicon Graphics.
12 *
13 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
14 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
16 *
17 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
18 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22 * OF THIS SOFTWARE.
23 */
24
25#ifndef _TIFFDIR_
26#define _TIFFDIR_
27
28#include "tiff.h"
29#include "tiffio.h"
30
31/*
32 * ``Library-private'' Directory-related Definitions.
33 */
34
35typedef struct
36{
38 int count;
39 void *value;
41
42/*
43 * TIFF Image File Directories are comprised of a table of field
44 * descriptors of the form shown below. The table is sorted in
45 * ascending order by tag. The values associated with each entry are
46 * disjoint and may appear anywhere in the file (so long as they are
47 * placed on a word boundary).
48 *
49 * If the value is 4 bytes or less, in ClassicTIFF, or 8 bytes or less in
50 * BigTIFF, then it is placed in the offset field to save space. If so,
51 * it is left-justified in the offset field.
52 */
53typedef struct
54{
55 uint16_t tdir_tag; /* see below */
56 uint16_t tdir_type; /* data type; see below */
57 uint64_t tdir_count; /* number of items; length in spec */
58 union
59 {
63 } tdir_offset; /* either offset or the data itself if fits */
64 uint8_t tdir_ignore; /* flag status to ignore tag when parsing tags in
65 tif_dirread.c */
67
68typedef struct
69{
72} TIFFEntryOffsetAndLength; /* auxiliary for evaluating size of IFD data */
73
74/*
75 * Internal format of a TIFF directory entry.
76 */
77typedef struct
78{
79#define FIELDSET_ITEMS 4
80 /* bit vector of fields that are set */
81 uint32_t td_fieldsset[FIELDSET_ITEMS];
82
83 uint32_t td_imagewidth, td_imagelength, td_imagedepth;
84 uint32_t td_tilewidth, td_tilelength, td_tiledepth;
95 uint16_t td_minsamplevalue, td_maxsamplevalue;
98 float td_xresolution, td_yresolution;
101 float td_xposition, td_yposition;
102 uint16_t td_pagenumber[2];
103 uint16_t *td_colormap[3];
104 uint16_t td_halftonehints[2];
107 /* even though the name is misleading, td_stripsperimage is the number
108 * of striles (=strips or tiles) per plane, and td_nstrips the total
109 * number of striles */
111 uint32_t td_nstrips; /* size of offset & bytecount arrays */
113 *td_stripoffset_p; /* should be accessed with TIFFGetStrileOffset */
114 uint64_t *td_stripbytecount_p; /* should be accessed with
115 TIFFGetStrileByteCount */
117 td_stripoffsetbyteallocsize; /* number of elements currently allocated
118 for td_stripoffset/td_stripbytecount.
119 Only used if TIFF_LAZYSTRILELOAD is set
120 */
121#ifdef STRIPBYTECOUNTSORTED_UNUSED
122 int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */
123#endif
124 /* Be aware that the parameters of td_stripoffset_entry and
125 * td_stripbytecount_entry are swapped but tdir_offset is not
126 * and has to be swapped when used. */
127 TIFFDirEntry td_stripoffset_entry; /* for deferred loading */
128 TIFFDirEntry td_stripbytecount_entry; /* for deferred loading */
131 /* YCbCr parameters */
132 uint16_t td_ycbcrsubsampling[2];
134 /* Colorimetry parameters */
135 uint16_t *td_transferfunction[3];
137 /* CMYK parameters */
140 uint16_t td_numberofinks; /* number of inks in InkNames string */
141
144
145 unsigned char
146 td_deferstrilearraywriting; /* see TIFFDeferStrileArrayWriting() */
147
148 unsigned char
149 td_iswrittentofile; /* indicates if current IFD is present on file */
150
151 /* LibTIFF writes all data that does not fit into the IFD entries directly
152 * after the IFD tag entry part. When reading, only the IFD data directly
153 * and continuously behind the IFD tags is taken into account for the IFD
154 * data size.*/
155 uint64_t td_dirdatasize_write; /* auxiliary for evaluating size of IFD data
156 to be written */
157 uint64_t td_dirdatasize_read; /* auxiliary for evaluating size of IFD data
158 read from file */
159 uint32_t td_dirdatasize_Noffsets; /* auxiliary counter for
160 tif_dir.td_dirdatasize_offsets array */
162 *td_dirdatasize_offsets; /* auxiliary array for all offsets of IFD tag
163 entries with data outside the IFD tag
164 entries. */
166
167/*
168 * Field flags used to indicate fields that have been set in a directory, and
169 * to reference fields when manipulating a directory.
170 */
171
172/*
173 * FIELD_IGNORE is used to signify tags that are to be processed but otherwise
174 * ignored. This permits antiquated tags to be quietly read and discarded.
175 * Note that a bit *is* allocated for ignored tags; this is understood by the
176 * directory reading logic which uses this fact to avoid special-case handling
177 */
178#define FIELD_IGNORE 0
179
180/* multi-item fields */
181#define FIELD_IMAGEDIMENSIONS 1
182#define FIELD_TILEDIMENSIONS 2
183#define FIELD_RESOLUTION 3
184#define FIELD_POSITION 4
185
186/* single-item fields */
187#define FIELD_SUBFILETYPE 5
188#define FIELD_BITSPERSAMPLE 6
189#define FIELD_COMPRESSION 7
190#define FIELD_PHOTOMETRIC 8
191#define FIELD_THRESHHOLDING 9
192#define FIELD_FILLORDER 10
193#define FIELD_ORIENTATION 15
194#define FIELD_SAMPLESPERPIXEL 16
195#define FIELD_ROWSPERSTRIP 17
196#define FIELD_MINSAMPLEVALUE 18
197#define FIELD_MAXSAMPLEVALUE 19
198#define FIELD_PLANARCONFIG 20
199#define FIELD_RESOLUTIONUNIT 22
200#define FIELD_PAGENUMBER 23
201#define FIELD_STRIPBYTECOUNTS 24
202#define FIELD_STRIPOFFSETS 25
203#define FIELD_COLORMAP 26
204#define FIELD_EXTRASAMPLES 31
205#define FIELD_SAMPLEFORMAT 32
206#define FIELD_SMINSAMPLEVALUE 33
207#define FIELD_SMAXSAMPLEVALUE 34
208#define FIELD_IMAGEDEPTH 35
209#define FIELD_TILEDEPTH 36
210#define FIELD_HALFTONEHINTS 37
211#define FIELD_YCBCRSUBSAMPLING 39
212#define FIELD_YCBCRPOSITIONING 40
213#define FIELD_REFBLACKWHITE 41
214#define FIELD_TRANSFERFUNCTION 44
215#define FIELD_INKNAMES 46
216#define FIELD_SUBIFD 49
217#define FIELD_NUMBEROFINKS 50
218/* FIELD_CUSTOM (see tiffio.h) 65 */
219/* end of support for well-known tags; codec-private tags follow */
220#define FIELD_CODEC 66 /* base of codec-private tags */
221
222/*
223 * Pseudo-tags don't normally need field bits since they are not written to an
224 * output file (by definition). The library also has express logic to always
225 * query a codec for a pseudo-tag so allocating a field bit for one is a
226 * waste. If codec wants to promote the notion of a pseudo-tag being ``set''
227 * or ``unset'' then it can do using internal state flags without polluting
228 * the field bit space defined for real tags.
229 */
230#define FIELD_PSEUDO 0
231
232#define FIELD_LAST (32 * FIELDSET_ITEMS - 1)
233
234#define BITn(n) (((uint32_t)1L) << ((n)&0x1f))
235#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
236#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
237#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
238#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
239
240#define FieldSet(fields, f) (fields[(f) / 32] & BITn(f))
241#define ResetFieldBit(fields, f) (fields[(f) / 32] &= ~BITn(f))
242
243typedef enum
244{
298
299#if defined(__cplusplus)
300extern "C"
301{
302#endif
303
304 extern const TIFFFieldArray *_TIFFGetFields(void);
305 extern const TIFFFieldArray *_TIFFGetExifFields(void);
306 extern const TIFFFieldArray *_TIFFGetGpsFields(void);
307 extern void _TIFFSetupFields(TIFF *tif, const TIFFFieldArray *infoarray);
308 extern void _TIFFPrintFieldInfo(TIFF *, FILE *);
309
310 extern int _TIFFFillStriles(TIFF *);
311
312 typedef enum
313 {
316 tfiatGps, /* EXIF-GPS fields array type */
319
321 {
322 TIFFFieldArrayType type; /* array type, will be used to determine if IFD
323 is image and such */
324 uint32_t allocated_size; /* 0 if array is constant, other if modified by
325 future definition extension support */
326 uint32_t count; /* number of elements in fields array */
327 TIFFField *fields; /* actual field info */
328 };
329
331 {
332 uint32_t field_tag; /* field's tag */
333 short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
334 short field_writecount; /* write count/TIFF_VARIABLE */
335 TIFFDataType field_type; /* type of associated data */
336 uint32_t field_anonymous; /* if true, this is a unknown /
337 anonymous tag */
339 TIFFSetField, TIFFGetField */
340 unsigned short field_bit; /* bit in fieldsset bit vector */
341 unsigned char field_oktochange; /* if true, can change while writing */
342 unsigned char field_passcount; /* if true, pass dir count on set */
343 char *field_name; /* ASCII name */
344 TIFFFieldArray *field_subfields; /* if field points to child ifds, child
345 ifd field definition array */
346 };
347
348 extern int _TIFFMergeFields(TIFF *, const TIFFField[], uint32_t);
353 extern int _TIFFCheckDirNumberAndOffset(TIFF *tif, tdir_t dirn,
354 uint64_t diroff);
355 extern int _TIFFGetDirNumberFromOffset(TIFF *tif, uint64_t diroff,
356 tdir_t *dirn);
357 extern int _TIFFGetOffsetFromDirNumber(TIFF *tif, tdir_t dirn,
358 uint64_t *diroff);
360 uint64_t diroff);
361
362#if defined(__cplusplus)
363}
364#endif
365#endif /* _TIFFDIR_ */
UINT32 uint32_t
Definition: types.h:75
UINT64 uint64_t
Definition: types.h:77
unsigned short uint16_t
Definition: stdint.h:35
unsigned char uint8_t
Definition: stdint.h:33
uint64_t tdir_count
Definition: tif_dir.h:57
uint16_t toff_short
Definition: tif_dir.h:60
uint16_t tdir_type
Definition: tif_dir.h:56
uint64_t toff_long8
Definition: tif_dir.h:62
uint16_t tdir_tag
Definition: tif_dir.h:55
uint8_t tdir_ignore
Definition: tif_dir.h:64
uint32_t toff_long
Definition: tif_dir.h:61
int td_customValueCount
Definition: tif_dir.h:142
float td_xposition
Definition: tif_dir.h:101
uint32_t td_tiledepth
Definition: tif_dir.h:84
uint16_t td_fillorder
Definition: tif_dir.h:91
uint32_t td_dirdatasize_Noffsets
Definition: tif_dir.h:159
float td_xresolution
Definition: tif_dir.h:98
uint64_t td_dirdatasize_read
Definition: tif_dir.h:157
int td_inknameslen
Definition: tif_dir.h:138
uint16_t * td_sampleinfo
Definition: tif_dir.h:106
float * td_refblackwhite
Definition: tif_dir.h:136
uint32_t td_rowsperstrip
Definition: tif_dir.h:94
uint16_t td_compression
Definition: tif_dir.h:88
uint16_t td_photometric
Definition: tif_dir.h:89
uint16_t td_extrasamples
Definition: tif_dir.h:105
uint16_t td_threshholding
Definition: tif_dir.h:90
double * td_sminsamplevalue
Definition: tif_dir.h:96
uint16_t td_bitspersample
Definition: tif_dir.h:86
char * td_inknames
Definition: tif_dir.h:139
TIFFDirEntry td_stripoffset_entry
Definition: tif_dir.h:127
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
uint32_t td_stripsperimage
Definition: tif_dir.h:110
uint16_t td_resolutionunit
Definition: tif_dir.h:99
uint16_t td_planarconfig
Definition: tif_dir.h:100
TIFFTagValue * td_customValues
Definition: tif_dir.h:143
double * td_smaxsamplevalue
Definition: tif_dir.h:97
uint64_t * td_stripbytecount_p
Definition: tif_dir.h:114
unsigned char td_iswrittentofile
Definition: tif_dir.h:149
uint64_t * td_stripoffset_p
Definition: tif_dir.h:113
uint16_t td_sampleformat
Definition: tif_dir.h:87
uint64_t td_dirdatasize_write
Definition: tif_dir.h:155
unsigned char td_deferstrilearraywriting
Definition: tif_dir.h:146
uint16_t td_samplesperpixel
Definition: tif_dir.h:93
uint32_t td_subfiletype
Definition: tif_dir.h:85
uint32_t td_nstrips
Definition: tif_dir.h:111
uint16_t td_numberofinks
Definition: tif_dir.h:140
TIFFDirEntry td_stripbytecount_entry
Definition: tif_dir.h:128
uint32_t td_stripoffsetbyteallocsize
Definition: tif_dir.h:117
TIFFEntryOffsetAndLength * td_dirdatasize_offsets
Definition: tif_dir.h:162
uint16_t td_nsubifd
Definition: tif_dir.h:129
uint64_t * td_subifd
Definition: tif_dir.h:130
uint16_t td_ycbcrpositioning
Definition: tif_dir.h:133
void * value
Definition: tif_dir.h:39
int count
Definition: tif_dir.h:38
const TIFFField * info
Definition: tif_dir.h:37
TIFFFieldArrayType type
Definition: tif_dir.h:322
uint32_t count
Definition: tif_dir.h:326
uint32_t allocated_size
Definition: tif_dir.h:324
TIFFField * fields
Definition: tif_dir.h:327
unsigned char field_oktochange
Definition: tif_dir.h:341
TIFFDataType field_type
Definition: tif_dir.h:335
unsigned char field_passcount
Definition: tif_dir.h:342
char * field_name
Definition: tif_dir.h:343
unsigned short field_bit
Definition: tif_dir.h:340
uint32_t field_anonymous
Definition: tif_dir.h:336
uint32_t field_tag
Definition: tif_dir.h:332
short field_readcount
Definition: tif_dir.h:333
TIFFSetGetFieldType set_get_field_type
Definition: tif_dir.h:338
TIFFFieldArray * field_subfields
Definition: tif_dir.h:344
short field_writecount
Definition: tif_dir.h:334
Definition: ecma_167.h:138
Definition: tiffiop.h:113
int _TIFFRemoveEntryFromDirectoryListByOffset(TIFF *tif, uint64_t diroff)
Definition: tif_dirread.c:5900
void _TIFFSetupFields(TIFF *tif, const TIFFFieldArray *infoarray)
Definition: tif_dirinfo.c:513
int _TIFFCheckDirNumberAndOffset(TIFF *tif, tdir_t dirn, uint64_t diroff)
Definition: tif_dirread.c:5665
const TIFFField * _TIFFFindOrRegisterField(TIFF *, uint32_t, TIFFDataType)
Definition: tif_dirinfo.c:881
int _TIFFFillStriles(TIFF *)
Definition: tif_dirread.c:8381
TIFFField * _TIFFCreateAnonField(TIFF *, uint32_t, TIFFDataType)
Definition: tif_dirinfo.c:898
int _TIFFGetOffsetFromDirNumber(TIFF *tif, tdir_t dirn, uint64_t *diroff)
Definition: tif_dirread.c:5873
int _TIFFGetDirNumberFromOffset(TIFF *tif, uint64_t diroff, tdir_t *dirn)
Definition: tif_dirread.c:5828
const TIFFFieldArray * _TIFFGetFields(void)
Definition: tif_dirinfo.c:507
TIFFFieldArrayType
Definition: tif_dir.h:313
@ tfiatGps
Definition: tif_dir.h:316
@ tfiatOther
Definition: tif_dir.h:317
@ tfiatImage
Definition: tif_dir.h:314
@ tfiatExif
Definition: tif_dir.h:315
void _TIFFPrintFieldInfo(TIFF *, FILE *)
Definition: tif_dirinfo.c:618
const TIFFFieldArray * _TIFFGetGpsFields(void)
Definition: tif_dirinfo.c:511
#define FIELDSET_ITEMS
Definition: tif_dir.h:79
int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag)
Definition: tif_dirinfo.c:1247
TIFFSetGetFieldType
Definition: tif_dir.h:244
@ TIFF_SETGET_C16_UINT8
Definition: tif_dir.h:273
@ TIFF_SETGET_C0_SINT64
Definition: tif_dir.h:268
@ TIFF_SETGET_DOUBLE
Definition: tif_dir.h:256
@ TIFF_SETGET_SINT64
Definition: tif_dir.h:254
@ TIFF_SETGET_C32_SINT32
Definition: tif_dir.h:290
@ TIFF_SETGET_C16_FLOAT
Definition: tif_dir.h:281
@ TIFF_SETGET_UNDEFINED
Definition: tif_dir.h:245
@ TIFF_SETGET_SINT8
Definition: tif_dir.h:248
@ TIFF_SETGET_C32_ASCII
Definition: tif_dir.h:284
@ TIFF_SETGET_INT
Definition: tif_dir.h:258
@ TIFF_SETGET_C32_UINT8
Definition: tif_dir.h:285
@ TIFF_SETGET_IFD8
Definition: tif_dir.h:257
@ TIFF_SETGET_C32_UINT16
Definition: tif_dir.h:287
@ TIFF_SETGET_C16_DOUBLE
Definition: tif_dir.h:282
@ TIFF_SETGET_UINT64
Definition: tif_dir.h:253
@ TIFF_SETGET_C0_UINT32
Definition: tif_dir.h:265
@ TIFF_SETGET_C16_UINT32
Definition: tif_dir.h:277
@ TIFF_SETGET_UINT16_PAIR
Definition: tif_dir.h:259
@ TIFF_SETGET_C32_SINT16
Definition: tif_dir.h:288
@ TIFF_SETGET_C16_UINT16
Definition: tif_dir.h:275
@ TIFF_SETGET_C16_SINT64
Definition: tif_dir.h:280
@ TIFF_SETGET_C0_FLOAT
Definition: tif_dir.h:269
@ TIFF_SETGET_C0_SINT32
Definition: tif_dir.h:266
@ TIFF_SETGET_C16_UINT64
Definition: tif_dir.h:279
@ TIFF_SETGET_C32_UINT32
Definition: tif_dir.h:289
@ TIFF_SETGET_C0_ASCII
Definition: tif_dir.h:260
@ TIFF_SETGET_C32_SINT8
Definition: tif_dir.h:286
@ TIFF_SETGET_UINT16
Definition: tif_dir.h:249
@ TIFF_SETGET_C16_SINT16
Definition: tif_dir.h:276
@ TIFF_SETGET_C0_UINT8
Definition: tif_dir.h:261
@ TIFF_SETGET_ASCII
Definition: tif_dir.h:246
@ TIFF_SETGET_C0_SINT8
Definition: tif_dir.h:262
@ TIFF_SETGET_C16_SINT8
Definition: tif_dir.h:274
@ TIFF_SETGET_OTHER
Definition: tif_dir.h:296
@ TIFF_SETGET_C0_UINT64
Definition: tif_dir.h:267
@ TIFF_SETGET_FLOAT
Definition: tif_dir.h:255
@ TIFF_SETGET_C16_SINT32
Definition: tif_dir.h:278
@ TIFF_SETGET_SINT16
Definition: tif_dir.h:250
@ TIFF_SETGET_C0_SINT16
Definition: tif_dir.h:264
@ TIFF_SETGET_C32_IFD8
Definition: tif_dir.h:295
@ TIFF_SETGET_UINT32
Definition: tif_dir.h:251
@ TIFF_SETGET_C32_SINT64
Definition: tif_dir.h:292
@ TIFF_SETGET_C16_ASCII
Definition: tif_dir.h:272
@ TIFF_SETGET_C32_DOUBLE
Definition: tif_dir.h:294
@ TIFF_SETGET_UINT8
Definition: tif_dir.h:247
@ TIFF_SETGET_C0_UINT16
Definition: tif_dir.h:263
@ TIFF_SETGET_C32_UINT64
Definition: tif_dir.h:291
@ TIFF_SETGET_C0_IFD8
Definition: tif_dir.h:271
@ TIFF_SETGET_C16_IFD8
Definition: tif_dir.h:283
@ TIFF_SETGET_SINT32
Definition: tif_dir.h:252
@ TIFF_SETGET_C32_FLOAT
Definition: tif_dir.h:293
@ TIFF_SETGET_C0_DOUBLE
Definition: tif_dir.h:270
int _TIFFMergeFields(TIFF *, const TIFFField[], uint32_t)
Definition: tif_dirinfo.c:573
const TIFFFieldArray * _TIFFGetExifFields(void)
Definition: tif_dirinfo.c:509
TIFFDataType
Definition: tiff.h:146
uint32_t tdir_t
Definition: tiffio.h:71
uint32_t ttag_t
Definition: tiffio.h:75