winex11: Don't use the vulkan driver interface for xrandr.
[wine.git] / libs / tiff / libtiff / tif_dir.h
blob9eaf22f8e62d56eafc3e504f2872138366856f2a
1 /*
2 * Copyright (c) 1988-1997 Sam Leffler
3 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
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.
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.
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.
25 #ifndef _TIFFDIR_
26 #define _TIFFDIR_
28 #include "tiff.h"
29 #include "tiffio.h"
32 * ``Library-private'' Directory-related Definitions.
35 typedef struct
37 const TIFFField *info;
38 int count;
39 void *value;
40 } TIFFTagValue;
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).
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.
53 typedef struct
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
60 uint16_t toff_short;
61 uint32_t toff_long;
62 uint64_t toff_long8;
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 */
66 } TIFFDirEntry;
69 * Internal format of a TIFF directory entry.
71 typedef struct
73 #define FIELDSET_ITEMS 4
74 /* bit vector of fields that are set */
75 uint32_t td_fieldsset[FIELDSET_ITEMS];
77 uint32_t td_imagewidth, td_imagelength, td_imagedepth;
78 uint32_t td_tilewidth, td_tilelength, td_tiledepth;
79 uint32_t td_subfiletype;
80 uint16_t td_bitspersample;
81 uint16_t td_sampleformat;
82 uint16_t td_compression;
83 uint16_t td_photometric;
84 uint16_t td_threshholding;
85 uint16_t td_fillorder;
86 uint16_t td_orientation;
87 uint16_t td_samplesperpixel;
88 uint32_t td_rowsperstrip;
89 uint16_t td_minsamplevalue, td_maxsamplevalue;
90 double *td_sminsamplevalue;
91 double *td_smaxsamplevalue;
92 float td_xresolution, td_yresolution;
93 uint16_t td_resolutionunit;
94 uint16_t td_planarconfig;
95 float td_xposition, td_yposition;
96 uint16_t td_pagenumber[2];
97 uint16_t *td_colormap[3];
98 uint16_t td_halftonehints[2];
99 uint16_t td_extrasamples;
100 uint16_t *td_sampleinfo;
101 /* even though the name is misleading, td_stripsperimage is the number
102 * of striles (=strips or tiles) per plane, and td_nstrips the total
103 * number of striles */
104 uint32_t td_stripsperimage;
105 uint32_t td_nstrips; /* size of offset & bytecount arrays */
106 uint64_t
107 *td_stripoffset_p; /* should be accessed with TIFFGetStrileOffset */
108 uint64_t *td_stripbytecount_p; /* should be accessed with
109 TIFFGetStrileByteCount */
110 uint32_t
111 td_stripoffsetbyteallocsize; /* number of elements currently allocated
112 for td_stripoffset/td_stripbytecount.
113 Only used if TIFF_LAZYSTRILELOAD is set
115 #ifdef STRIPBYTECOUNTSORTED_UNUSED
116 int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */
117 #endif
118 TIFFDirEntry td_stripoffset_entry; /* for deferred loading */
119 TIFFDirEntry td_stripbytecount_entry; /* for deferred loading */
120 uint16_t td_nsubifd;
121 uint64_t *td_subifd;
122 /* YCbCr parameters */
123 uint16_t td_ycbcrsubsampling[2];
124 uint16_t td_ycbcrpositioning;
125 /* Colorimetry parameters */
126 uint16_t *td_transferfunction[3];
127 float *td_refblackwhite;
128 /* CMYK parameters */
129 int td_inknameslen;
130 char *td_inknames;
131 uint16_t td_numberofinks; /* number of inks in InkNames string */
133 int td_customValueCount;
134 TIFFTagValue *td_customValues;
136 unsigned char
137 td_deferstrilearraywriting; /* see TIFFDeferStrileArrayWriting() */
138 } TIFFDirectory;
141 * Field flags used to indicate fields that have been set in a directory, and
142 * to reference fields when manipulating a directory.
146 * FIELD_IGNORE is used to signify tags that are to be processed but otherwise
147 * ignored. This permits antiquated tags to be quietly read and discarded.
148 * Note that a bit *is* allocated for ignored tags; this is understood by the
149 * directory reading logic which uses this fact to avoid special-case handling
151 #define FIELD_IGNORE 0
153 /* multi-item fields */
154 #define FIELD_IMAGEDIMENSIONS 1
155 #define FIELD_TILEDIMENSIONS 2
156 #define FIELD_RESOLUTION 3
157 #define FIELD_POSITION 4
159 /* single-item fields */
160 #define FIELD_SUBFILETYPE 5
161 #define FIELD_BITSPERSAMPLE 6
162 #define FIELD_COMPRESSION 7
163 #define FIELD_PHOTOMETRIC 8
164 #define FIELD_THRESHHOLDING 9
165 #define FIELD_FILLORDER 10
166 #define FIELD_ORIENTATION 15
167 #define FIELD_SAMPLESPERPIXEL 16
168 #define FIELD_ROWSPERSTRIP 17
169 #define FIELD_MINSAMPLEVALUE 18
170 #define FIELD_MAXSAMPLEVALUE 19
171 #define FIELD_PLANARCONFIG 20
172 #define FIELD_RESOLUTIONUNIT 22
173 #define FIELD_PAGENUMBER 23
174 #define FIELD_STRIPBYTECOUNTS 24
175 #define FIELD_STRIPOFFSETS 25
176 #define FIELD_COLORMAP 26
177 #define FIELD_EXTRASAMPLES 31
178 #define FIELD_SAMPLEFORMAT 32
179 #define FIELD_SMINSAMPLEVALUE 33
180 #define FIELD_SMAXSAMPLEVALUE 34
181 #define FIELD_IMAGEDEPTH 35
182 #define FIELD_TILEDEPTH 36
183 #define FIELD_HALFTONEHINTS 37
184 #define FIELD_YCBCRSUBSAMPLING 39
185 #define FIELD_YCBCRPOSITIONING 40
186 #define FIELD_REFBLACKWHITE 41
187 #define FIELD_TRANSFERFUNCTION 44
188 #define FIELD_INKNAMES 46
189 #define FIELD_SUBIFD 49
190 #define FIELD_NUMBEROFINKS 50
191 /* FIELD_CUSTOM (see tiffio.h) 65 */
192 /* end of support for well-known tags; codec-private tags follow */
193 #define FIELD_CODEC 66 /* base of codec-private tags */
196 * Pseudo-tags don't normally need field bits since they are not written to an
197 * output file (by definition). The library also has express logic to always
198 * query a codec for a pseudo-tag so allocating a field bit for one is a
199 * waste. If codec wants to promote the notion of a pseudo-tag being ``set''
200 * or ``unset'' then it can do using internal state flags without polluting
201 * the field bit space defined for real tags.
203 #define FIELD_PSEUDO 0
205 #define FIELD_LAST (32 * FIELDSET_ITEMS - 1)
207 #define BITn(n) (((uint32_t)1L) << ((n)&0x1f))
208 #define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32])
209 #define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field))
210 #define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field))
211 #define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field))
213 #define FieldSet(fields, f) (fields[(f) / 32] & BITn(f))
214 #define ResetFieldBit(fields, f) (fields[(f) / 32] &= ~BITn(f))
216 typedef enum
218 TIFF_SETGET_UNDEFINED = 0,
219 TIFF_SETGET_ASCII = 1,
220 TIFF_SETGET_UINT8 = 2,
221 TIFF_SETGET_SINT8 = 3,
222 TIFF_SETGET_UINT16 = 4,
223 TIFF_SETGET_SINT16 = 5,
224 TIFF_SETGET_UINT32 = 6,
225 TIFF_SETGET_SINT32 = 7,
226 TIFF_SETGET_UINT64 = 8,
227 TIFF_SETGET_SINT64 = 9,
228 TIFF_SETGET_FLOAT = 10,
229 TIFF_SETGET_DOUBLE = 11,
230 TIFF_SETGET_IFD8 = 12,
231 TIFF_SETGET_INT = 13,
232 TIFF_SETGET_UINT16_PAIR = 14,
233 TIFF_SETGET_C0_ASCII = 15,
234 TIFF_SETGET_C0_UINT8 = 16,
235 TIFF_SETGET_C0_SINT8 = 17,
236 TIFF_SETGET_C0_UINT16 = 18,
237 TIFF_SETGET_C0_SINT16 = 19,
238 TIFF_SETGET_C0_UINT32 = 20,
239 TIFF_SETGET_C0_SINT32 = 21,
240 TIFF_SETGET_C0_UINT64 = 22,
241 TIFF_SETGET_C0_SINT64 = 23,
242 TIFF_SETGET_C0_FLOAT = 24,
243 TIFF_SETGET_C0_DOUBLE = 25,
244 TIFF_SETGET_C0_IFD8 = 26,
245 TIFF_SETGET_C16_ASCII = 27,
246 TIFF_SETGET_C16_UINT8 = 28,
247 TIFF_SETGET_C16_SINT8 = 29,
248 TIFF_SETGET_C16_UINT16 = 30,
249 TIFF_SETGET_C16_SINT16 = 31,
250 TIFF_SETGET_C16_UINT32 = 32,
251 TIFF_SETGET_C16_SINT32 = 33,
252 TIFF_SETGET_C16_UINT64 = 34,
253 TIFF_SETGET_C16_SINT64 = 35,
254 TIFF_SETGET_C16_FLOAT = 36,
255 TIFF_SETGET_C16_DOUBLE = 37,
256 TIFF_SETGET_C16_IFD8 = 38,
257 TIFF_SETGET_C32_ASCII = 39,
258 TIFF_SETGET_C32_UINT8 = 40,
259 TIFF_SETGET_C32_SINT8 = 41,
260 TIFF_SETGET_C32_UINT16 = 42,
261 TIFF_SETGET_C32_SINT16 = 43,
262 TIFF_SETGET_C32_UINT32 = 44,
263 TIFF_SETGET_C32_SINT32 = 45,
264 TIFF_SETGET_C32_UINT64 = 46,
265 TIFF_SETGET_C32_SINT64 = 47,
266 TIFF_SETGET_C32_FLOAT = 48,
267 TIFF_SETGET_C32_DOUBLE = 49,
268 TIFF_SETGET_C32_IFD8 = 50,
269 TIFF_SETGET_OTHER = 51
270 } TIFFSetGetFieldType;
272 #if defined(__cplusplus)
273 extern "C"
275 #endif
277 extern const TIFFFieldArray *_TIFFGetFields(void);
278 extern const TIFFFieldArray *_TIFFGetExifFields(void);
279 extern const TIFFFieldArray *_TIFFGetGpsFields(void);
280 extern void _TIFFSetupFields(TIFF *tif, const TIFFFieldArray *infoarray);
281 extern void _TIFFPrintFieldInfo(TIFF *, FILE *);
283 extern int _TIFFFillStriles(TIFF *);
285 typedef enum
287 tfiatImage,
288 tfiatExif,
289 tfiatGps, /* EXIF-GPS fields array type */
290 tfiatOther
291 } TIFFFieldArrayType;
293 struct _TIFFFieldArray
295 TIFFFieldArrayType type; /* array type, will be used to determine if IFD
296 is image and such */
297 uint32_t allocated_size; /* 0 if array is constant, other if modified by
298 future definition extension support */
299 uint32_t count; /* number of elements in fields array */
300 TIFFField *fields; /* actual field info */
303 struct _TIFFField
305 uint32_t field_tag; /* field's tag */
306 short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */
307 short field_writecount; /* write count/TIFF_VARIABLE */
308 TIFFDataType field_type; /* type of associated data */
309 uint32_t
310 field_anonymous; /* if true, this is a unknown / anonymous tag */
311 TIFFSetGetFieldType
312 set_field_type; /* type to be passed to TIFFSetField */
313 TIFFSetGetFieldType
314 get_field_type; /* type to be passed to TIFFGetField */
315 unsigned short field_bit; /* bit in fieldsset bit vector */
316 unsigned char field_oktochange; /* if true, can change while writing */
317 unsigned char field_passcount; /* if true, pass dir count on set */
318 char *field_name; /* ASCII name */
319 TIFFFieldArray *field_subfields; /* if field points to child ifds, child
320 ifd field definition array */
323 extern int _TIFFMergeFields(TIFF *, const TIFFField[], uint32_t);
324 extern const TIFFField *_TIFFFindOrRegisterField(TIFF *, uint32_t,
325 TIFFDataType);
326 extern TIFFField *_TIFFCreateAnonField(TIFF *, uint32_t, TIFFDataType);
327 extern int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag);
328 extern int _TIFFCheckDirNumberAndOffset(TIFF *tif, tdir_t dirn,
329 uint64_t diroff);
330 extern int _TIFFGetDirNumberFromOffset(TIFF *tif, uint64_t diroff,
331 tdir_t *dirn);
332 extern int _TIFFGetOffsetFromDirNumber(TIFF *tif, tdir_t dirn,
333 uint64_t *diroff);
334 extern int _TIFFRemoveEntryFromDirectoryListByOffset(TIFF *tif,
335 uint64_t diroff);
337 #if defined(__cplusplus)
339 #endif
340 #endif /* _TIFFDIR_ */