PBRT
/home/felix/UBC/projects/AdaptiveLightfieldSampling/pbrt_v2/src/3rdparty/tiff-3.9.4/tif_dir.h
00001 /* $Id: tif_dir.h,v 1.30.2.3 2010-06-09 21:15:27 bfriesen Exp $ */
00002 
00003 /*
00004  * Copyright (c) 1988-1997 Sam Leffler
00005  * Copyright (c) 1991-1997 Silicon Graphics, Inc.
00006  *
00007  * Permission to use, copy, modify, distribute, and sell this software and 
00008  * its documentation for any purpose is hereby granted without fee, provided
00009  * that (i) the above copyright notices and this permission notice appear in
00010  * all copies of the software and related documentation, and (ii) the names of
00011  * Sam Leffler and Silicon Graphics may not be used in any advertising or
00012  * publicity relating to the software without the specific, prior written
00013  * permission of Sam Leffler and Silicon Graphics.
00014  * 
00015  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
00016  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
00017  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
00018  * 
00019  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
00020  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
00021  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
00022  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
00023  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
00024  * OF THIS SOFTWARE.
00025  */
00026 
00027 #ifndef _TIFFDIR_
00028 #define _TIFFDIR_
00029 /*
00030  * ``Library-private'' Directory-related Definitions.
00031  */
00032 
00033 /*
00034  * Internal format of a TIFF directory entry.
00035  */
00036 typedef struct {
00037 #define FIELD_SETLONGS  4
00038         /* bit vector of fields that are set */
00039         unsigned long   td_fieldsset[FIELD_SETLONGS];
00040 
00041         uint32  td_imagewidth, td_imagelength, td_imagedepth;
00042         uint32  td_tilewidth, td_tilelength, td_tiledepth;
00043         uint32  td_subfiletype;
00044         uint16  td_bitspersample;
00045         uint16  td_sampleformat;
00046         uint16  td_compression;
00047         uint16  td_photometric;
00048         uint16  td_threshholding;
00049         uint16  td_fillorder;
00050         uint16  td_orientation;
00051         uint16  td_samplesperpixel;
00052         uint32  td_rowsperstrip;
00053         uint16  td_minsamplevalue, td_maxsamplevalue;
00054         double  td_sminsamplevalue, td_smaxsamplevalue;
00055         float   td_xresolution, td_yresolution;
00056         uint16  td_resolutionunit;
00057         uint16  td_planarconfig;
00058         float   td_xposition, td_yposition;
00059         uint16  td_pagenumber[2];
00060         uint16* td_colormap[3];
00061         uint16  td_halftonehints[2];
00062         uint16  td_extrasamples;
00063         uint16* td_sampleinfo;
00064         /* even though the name is misleading, td_stripsperimage is the number
00065          * of striles (=strips or tiles) per plane, and td_nstrips the total
00066          * number of striles */
00067         tstrile_t td_stripsperimage;
00068         tstrile_t td_nstrips;            /* size of offset & bytecount arrays */
00069         toff_t* td_stripoffset;
00070         toff_t* td_stripbytecount;       /* FIXME: it should be tsize_t array */
00071         int     td_stripbytecountsorted; /* is the bytecount array sorted ascending? */
00072         uint16  td_nsubifd;
00073         uint32* td_subifd;
00074         /* YCbCr parameters */
00075         uint16  td_ycbcrsubsampling[2];
00076         uint16  td_ycbcrpositioning;
00077         /* Colorimetry parameters */
00078         float*  td_refblackwhite;
00079         uint16* td_transferfunction[3];
00080         /* CMYK parameters */
00081         int     td_inknameslen;
00082         char*   td_inknames;
00083 
00084         int     td_customValueCount;
00085         TIFFTagValue *td_customValues;
00086 } TIFFDirectory;
00087 
00088 /*
00089  * Field flags used to indicate fields that have
00090  * been set in a directory, and to reference fields
00091  * when manipulating a directory.
00092  */
00093 
00094 /*
00095  * FIELD_IGNORE is used to signify tags that are to
00096  * be processed but otherwise ignored.  This permits
00097  * antiquated tags to be quietly read and discarded.
00098  * Note that a bit *is* allocated for ignored tags;
00099  * this is understood by the directory reading logic
00100  * which uses this fact to avoid special-case handling
00101  */ 
00102 #define FIELD_IGNORE                    0
00103 
00104 /* multi-item fields */
00105 #define FIELD_IMAGEDIMENSIONS           1
00106 #define FIELD_TILEDIMENSIONS            2
00107 #define FIELD_RESOLUTION                3
00108 #define FIELD_POSITION                  4
00109 
00110 /* single-item fields */
00111 #define FIELD_SUBFILETYPE               5
00112 #define FIELD_BITSPERSAMPLE             6
00113 #define FIELD_COMPRESSION               7
00114 #define FIELD_PHOTOMETRIC               8
00115 #define FIELD_THRESHHOLDING             9
00116 #define FIELD_FILLORDER                 10
00117 #define FIELD_ORIENTATION               15
00118 #define FIELD_SAMPLESPERPIXEL           16
00119 #define FIELD_ROWSPERSTRIP              17
00120 #define FIELD_MINSAMPLEVALUE            18
00121 #define FIELD_MAXSAMPLEVALUE            19
00122 #define FIELD_PLANARCONFIG              20
00123 #define FIELD_RESOLUTIONUNIT            22
00124 #define FIELD_PAGENUMBER                23
00125 #define FIELD_STRIPBYTECOUNTS           24
00126 #define FIELD_STRIPOFFSETS              25
00127 #define FIELD_COLORMAP                  26
00128 #define FIELD_EXTRASAMPLES              31
00129 #define FIELD_SAMPLEFORMAT              32
00130 #define FIELD_SMINSAMPLEVALUE           33
00131 #define FIELD_SMAXSAMPLEVALUE           34
00132 #define FIELD_IMAGEDEPTH                35
00133 #define FIELD_TILEDEPTH                 36
00134 #define FIELD_HALFTONEHINTS             37
00135 #define FIELD_YCBCRSUBSAMPLING          39
00136 #define FIELD_YCBCRPOSITIONING          40
00137 #define FIELD_REFBLACKWHITE             41
00138 #define FIELD_TRANSFERFUNCTION          44
00139 #define FIELD_INKNAMES                  46
00140 #define FIELD_SUBIFD                    49
00141 /*      FIELD_CUSTOM (see tiffio.h)     65 */
00142 /* end of support for well-known tags; codec-private tags follow */
00143 #define FIELD_CODEC                     66      /* base of codec-private tags */
00144 
00145 
00146 /*
00147  * Pseudo-tags don't normally need field bits since they
00148  * are not written to an output file (by definition).
00149  * The library also has express logic to always query a
00150  * codec for a pseudo-tag so allocating a field bit for
00151  * one is a waste.   If codec wants to promote the notion
00152  * of a pseudo-tag being ``set'' or ``unset'' then it can
00153  * do using internal state flags without polluting the
00154  * field bit space defined for real tags.
00155  */
00156 #define FIELD_PSEUDO                    0
00157 
00158 #define FIELD_LAST                      (32*FIELD_SETLONGS-1)
00159 
00160 #define TIFFExtractData(tif, type, v) \
00161     ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \
00162         ((v) >> (tif)->tif_typeshift[type]) & (tif)->tif_typemask[type] : \
00163         (v) & (tif)->tif_typemask[type]))
00164 #define TIFFInsertData(tif, type, v) \
00165     ((uint32) ((tif)->tif_header.tiff_magic == TIFF_BIGENDIAN ? \
00166         ((v) & (tif)->tif_typemask[type]) << (tif)->tif_typeshift[type] : \
00167         (v) & (tif)->tif_typemask[type]))
00168 
00169 
00170 #define BITn(n)                         (((unsigned long)1L)<<((n)&0x1f)) 
00171 #define BITFIELDn(tif, n)               ((tif)->tif_dir.td_fieldsset[(n)/32]) 
00172 #define TIFFFieldSet(tif, field)        (BITFIELDn(tif, field) & BITn(field)) 
00173 #define TIFFSetFieldBit(tif, field)     (BITFIELDn(tif, field) |= BITn(field))
00174 #define TIFFClrFieldBit(tif, field)     (BITFIELDn(tif, field) &= ~BITn(field))
00175 
00176 #define FieldSet(fields, f)             (fields[(f)/32] & BITn(f))
00177 #define ResetFieldBit(fields, f)        (fields[(f)/32] &= ~BITn(f))
00178 
00179 #if defined(__cplusplus)
00180 extern "C" {
00181 #endif
00182 extern  const TIFFFieldInfo *_TIFFGetFieldInfo(size_t *);
00183 extern  const TIFFFieldInfo *_TIFFGetExifFieldInfo(size_t *);
00184 extern  void _TIFFSetupFieldInfo(TIFF*, const TIFFFieldInfo[], size_t);
00185 extern  int _TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], int);
00186 extern  void _TIFFPrintFieldInfo(TIFF*, FILE*);
00187 extern  TIFFDataType _TIFFSampleToTagType(TIFF*);
00188 extern  const TIFFFieldInfo* _TIFFFindOrRegisterFieldInfo( TIFF *tif,
00189                                                            ttag_t tag,
00190                                                            TIFFDataType dt );
00191 extern  TIFFFieldInfo* _TIFFCreateAnonFieldInfo( TIFF *tif, ttag_t tag,
00192                                                  TIFFDataType dt );
00193 
00194 #define _TIFFFindFieldInfo          TIFFFindFieldInfo
00195 #define _TIFFFindFieldInfoByName    TIFFFindFieldInfoByName
00196 #define _TIFFFieldWithTag           TIFFFieldWithTag
00197 #define _TIFFFieldWithName          TIFFFieldWithName
00198 
00199 #if defined(__cplusplus)
00200 }
00201 #endif
00202 #endif /* _TIFFDIR_ */
00203 
00204 /* vim: set ts=8 sts=8 sw=8 noet: */
00205 /*
00206  * Local Variables:
00207  * mode: c
00208  * c-basic-offset: 8
00209  * fill-column: 78
00210  * End:
00211  */