1 /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
2 /*          EXIFPROBE - TIFF/JPEG/EXIF image file probe               */
3 /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
4 /* Copyright (C) 2002 by Duane H. Hesser. All rights reserved.        */
5 /*                                                                    */
6 /* See the file LICENSE.EXIFPROBE for terms of use.                   */
7 /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
8 
9 /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
10 /* @(#) $Id: summary.h,v 1.9 2005/07/24 21:15:04 alex Exp $" */
11 /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
12 
13 /* Definitions for image summarys                                     */
14 
15 #ifndef SUMMARY_INCLUDED
16 #define SUMMARY_INCLUDED
17 
18 /* FILE formats                                                       */
19 #define FILEFMT_TIFF                PROBE_TIFFMAGIC
20 #define FILEFMT_ORF1                PROBE_ORF1MAGIC
21 #define FILEFMT_ORF2                PROBE_ORF2MAGIC
22 #define FILEFMT_JPEG                PROBE_JPEGMAGIC
23 #define FILEFMT_JP2                 PROBE_JP2MAGIC
24 #define FILEFMT_CIFF                PROBE_CIFFMAGIC
25 #define FILEFMT_MRW                 PROBE_MRWMAGIC
26 #define FILEFMT_RAF                 PROBE_RAFMAGIC
27 #define FILEFMT_X3F                 PROBE_X3FMAGIC
28 
29 /* FILE formats modifiers                                             */
30 #define FILESUBFMT_TIFF             0x00001
31 #define FILESUBFMT_TIFFOLD          0x00002
32 #define FILESUBFMT_TIFFEP           0x00004
33 #define FILESUBFMT_JPEG             0x00008
34 #define FILESUBFMT_EXIF             0x00010
35 #define FILESUBFMT_NEF              0x00020
36 #define FILESUBFMT_CR2              0x00040
37 #define FILESUBFMT_DNG              0x00080
38 /* ADD DCR, KDC? ###%%% */
39 
40 #define FILESUBFMT_MNOTE            0x00100
41 #define FILESUBFMT_MNSUBIFD         0x00200
42 
43 #define FILESUBFMT_CIFF             0x00400 /* may be used in APP0    */
44 #define FILESUBFMT_GEOTIFF          0x00800 /* not used yet           */
45 
46 #define FILESUBFMT_JFIF             0x01000
47 #define FILESUBFMT_JFXX             0x02000
48 #define FILESUBFMT_FPIX             0x04000
49 #define FILESUBFMT_APPN             0x08000
50 /* ADD Meta(APP3)? ###%%% */
51 
52 #define FILESUBFMT_TIFFUSED         0x003ff
53 
54 /* IMAGE formats                                                      */
55 #define IMGFMT_NOIMAGE  0
56 #define IMGFMT_TIFF                 PROBE_TIFFMAGIC /* including ORF  */
57 #define IMGFMT_JPEG                 PROBE_JPEGMAGIC
58 #define IMGFMT_JPEG2000             PROBE_JP2MAGIC
59 #define IMGFMT_CRW                  PROBE_CIFFMAGIC
60 #define IMGFMT_MRW                  PROBE_MRWMAGIC
61 #define IMGFMT_RAF                  PROBE_RAFMAGIC
62 #define IMGFMT_X3F                  PROBE_X3FMAGIC
63 #define IMGFMT_MISMARKED            0x10000000  /* for CR2 "JPEG" RGB */
64 
65 /* IMAGE format modifiers                                             */
66 /* TIFF Photometric values; first 16 bits if 17th bit                 */
67 #define IMGSUBFMT_CFA               0x18023     /* 32803 */
68 #define IMGSUBFMT_MINISWHITE        0x10000
69 #define IMGSUBFMT_MINISBLACK        0x10001
70 #define IMGSUBFMT_RGB               0x10002
71 #define IMGSUBFMT_PALETTE           0x10003
72 #define IMGSUBFMT_MASK              0x10004
73 #define IMGSUBFMT_SEPARATED         0x10005
74 #define IMGSUBFMT_YCBCR             0x10006
75 #define IMGSUBFMT_CIELAB            0x10008
76 #define IMGSUBFMT_ICCLAB            0x10009
77 #define IMGSUBFMT_ITULAB            0x10010
78 #define IMGSUBFMT_LOGL              0x1804c     /* 32844 */
79 #define IMGSUBFMT_LOGLUV            0x1804d     /* 32845 */
80 #define IMGSUBFMT_LINEARRAW         0x1884c     /* 38492 */
81 #define IMGSUBFMT_PMIMASK           0x0ffff
82 
83 /* If this bit is set, the PMIMASKED value is the                     */
84 /* PhotoMetricInterpretation                                          */
85 #define IMGSUBFMT_VALUE_IS_PMI      0x10000
86 
87 /* If PMI bit isn't set                                               */
88 #define IMGSUBFMT_JPEGTABLES        0x015b
89 #define IMGSUBFMT_HUFF_COMPRESSED_RGB   0x20001
90 #define IMGSUBFMT_JPEG_COMPRESSED_RGB   0x20002
91 #define IMGSUBFMT_X3F_UNSPECIFIED       0x20003
92 #define IMGSUBFMT_X3F_COMPRESSED        0x20004
93 
94 #if 0
95 #define IMGSUBFMT_CMY               0x1000
96 #define IMGSUBFMT_GREYSCALE         0x00e1
97 #define IMGSUBFMT_BILEVEL           0x0010
98 #endif
99 
100 #define IMGSUBFMT_TRUNCATED         0x10000000
101 #define IMGSUBFMT_JPEG_EARLY_EOI    0x20000000
102 #define IMGSUBFMT_NO_JPEG           0x40000000  /* no SOI             */
103 #define IMGSUBFMT_JPEGFAILED        0x80000000  /* failed after SOI   */
104 #define IMGSUBFMT_ERRORMASK         0xf0000000
105 
106 #define MAXSAMPLE                   16  /* size of bps array          */
107 
108 struct image_summary {
109     struct image_summary *prev_entry;
110     struct image_summary *next_entry;
111     int entry_lock;     /* If set, entry is used, add a new one       */
112 
113     /* per file                                                       */
114     int fileformat;         /* identifies image FILE format           */
115     int filesubformat;      /* file format modifier bits              */
116     int filesubformatAPPN[16];   /* APPn sections present in file     */
117     unsigned long primary_width; /* size of the primary image         */
118     unsigned long primary_height;
119 
120     /* per image                                                      */
121     unsigned long pixel_width;
122     unsigned long pixel_height;
123     unsigned long imageformat;    /* IMAGE: JPEG, CFA, JP2, TIFF,...  */
124     unsigned long imagesubformat; /* image format modifiers           */
125     unsigned long offset;         /* file offset of start of image    */
126     unsigned long length;         /* image length in bytes            */
127 
128     /* These are used to process individually jpeg-compressed tiles   */
129     unsigned long offset_loc;  /* location of offset table            */
130     unsigned long length_loc;  /* location of bytecount table         */
131     unsigned long chunkhow;    /* strips or tiles                     */
132     unsigned long chunktype;   /* short or long                       */
133     int noffsets;              /* number of strips, tiles             */
134 
135     int subfiletype;        /* PRIMARY, THUMBNAIL, etc.               */
136     int compression;        /* interpret according to imageformat     */
137 
138     /* This stuff is experimental; not used everywhere                */
139     int spp;                /* samples per pixel                      */
140     int bps[MAXSAMPLE];     /* one for each conponent                 */
141     int sample_size;        /* assume all are the same size           */
142     float compress_percent; /* calulate in scan_summary()             */
143 
144     /* datatype describes the data structure from which the current   */
145     /* image is described. For some file types this may be just the   */
146     /* file type, for TIFF it will be the type of IFD (e.g. TIFF_IFD, */
147     /* SubIFD, Exif, Interop, etc.                                    */
148     int datatype; /* TIFF, EXIF, Interop, GPS, SubIFD...   */
149 
150     /* Used only for TIFF                                             */
151     int ifdnum;         /* parent idfnum if subifd                    */
152     int subifdnum;
153 };
154 
155 #endif	/* SUMMARY INCLUDED */
156