1 /*
2 * Copyright (c) 2002, 2003, Eric M. Johnston <emj@postal.net>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Eric M. Johnston.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * $Id: fuji.c,v 1.15 2004/12/23 20:38:52 ejohnst Exp $
33 */
34
35 /*
36 * Exif tag definitions for Fuji maker notes.
37 *
38 */
39
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <string.h>
43
44 #include "makers.h"
45
46
47 /* Sharpness. */
48
49 static struct descrip fuji_sharp[] = {
50 { 1, "Soft" },
51 { 2, "Soft" },
52 { 3, "Normal" },
53 { 4, "Hard" },
54 { 5, "Hard" },
55 { -1, "Unknown" },
56 };
57
58
59 /* White balance. */
60
61 static struct descrip fuji_white[] = {
62 { 0, "Auto" },
63 { 256, "Daylight" },
64 { 512, "Cloudy" },
65 { 768, "Daylight Color Fluorescence" },
66 { 769, "Daywhite Color Fluorescence" },
67 { 769, "White Fluorescence" },
68 { 1024, "Incandescence" },
69 { 3840, "Custom" },
70 { -1, "Unknown" },
71 };
72
73
74 /* Color & tone settings. */
75
76 static struct descrip fuji_color[] = {
77 { 0, "Normal" },
78 { 256, "High" },
79 { 512, "Low" },
80 { -1, "Unknown" },
81 };
82
83
84 /* Flash mode. */
85
86 static struct descrip fuji_flmode[] = {
87 { 0, "Auto" },
88 { 1, "On" },
89 { 2, "Off" },
90 { 3, "Red Eye Reduction" },
91 { -1, "Unknown" },
92 };
93
94
95 /* Generic boolean. */
96
97 static struct descrip fuji_bool[] = {
98 { 0, "Off" },
99 { 1, "On" },
100 { -1, "Unknown" },
101 };
102
103
104 /* Focus mode. */
105
106 static struct descrip fuji_focus[] = {
107 { 0, "Auto" },
108 { 1, "Manual" },
109 { -1, "Unknown" },
110 };
111
112
113 /* Picture mode. */
114
115 static struct descrip fuji_picture[] = {
116 { 0, "Auto" },
117 { 1, "Portrait" },
118 { 2, "Landscape" },
119 { 4, "Sports Scene" },
120 { 5, "Night Scene" },
121 { 6, "Program AE" },
122 { 256, "Aperture Prior AE" },
123 { 512, "Shutter Prior AE" },
124 { 768, "Manual Exposure" },
125 { -1, "Unknown" },
126 };
127
128
129 /* Blur warning. */
130
131 static struct descrip fuji_blurw[] = {
132 { 0, "OK" },
133 { 1, "Blur Warning" },
134 { -1, "Unknown" },
135 };
136
137
138 /* Focus warning. */
139
140 static struct descrip fuji_focusw[] = {
141 { 0, "OK" },
142 { 1, "Out of Focus" },
143 { -1, "Unknown" },
144 };
145
146
147 /* Auto exposure warning. */
148
149 static struct descrip fuji_aew[] = {
150 { 0, "OK" },
151 { 1, "Over Exposed" },
152 { -1, "Unknown" },
153 };
154
155
156 /* Maker note IFD tags. */
157
158 static struct exiftag fuji_tags[] = {
159 { 0x0000, TIFF_UNDEF, 4, ED_CAM, "FujiVersion",
160 "Maker Note Version", NULL },
161 { 0x1000, TIFF_ASCII, 8, ED_UNK, "FujiQuality",
162 "Quality Setting", NULL },
163 { 0x1001, TIFF_SHORT, 1, ED_IMG, "FujiSharpness",
164 "Sharpness", fuji_sharp },
165 { 0x1002, TIFF_SHORT, 1, ED_IMG, "FujiWhiteBal",
166 "White Balance", fuji_white },
167 { 0x1003, TIFF_SHORT, 1, ED_IMG, "FujiColor",
168 "Chroma Saturation", fuji_color },
169 { 0x1004, TIFF_SHORT, 1, ED_IMG, "FujiTone",
170 "Contrast", fuji_color },
171 { 0x1010, TIFF_SHORT, 1, ED_IMG, "FujiFlashMode",
172 "Flash Mode", fuji_flmode },
173 { 0x1011, TIFF_SRTNL, 1, ED_UNK, "FujiFlashStrength",
174 "Flash Strength", NULL },
175 { 0x1020, TIFF_SHORT, 1, ED_IMG, "FujiMacro",
176 "Macro Mode", fuji_bool },
177 { 0x1021, TIFF_SHORT, 1, ED_IMG, "FujiFocusMode",
178 "Focus Mode", fuji_focus },
179 { 0x1030, TIFF_SHORT, 1, ED_IMG, "FujiSlowSync",
180 "Slow Synchro Mode", fuji_bool },
181 { 0x1031, TIFF_SHORT, 1, ED_IMG, "FujiPicMode",
182 "Picture Mode", fuji_picture },
183 { 0x1100, TIFF_SHORT, 1, ED_IMG, "FujiBracket",
184 "Continuous/Bracketing Mode", fuji_bool },
185 { 0x1300, TIFF_SHORT, 1, ED_IMG, "FujiBlurWarn",
186 "Blur Status", fuji_blurw },
187 { 0x1301, TIFF_SHORT, 1, ED_IMG, "FujiFocusWarn",
188 "Focus Status", fuji_focusw },
189 { 0x1302, TIFF_SHORT, 1, ED_IMG, "FujiAEWarn",
190 "Auto Exposure Status", fuji_aew },
191 { 0xffff, TIFF_UNKN, 0, ED_UNK, "FujiUnknown",
192 "Fuji Unknown", NULL },
193 };
194
195
196 /*
197 * Process Fuji maker note tags.
198 */
199 void
fuji_prop(struct exifprop * prop,struct exiftags * t)200 fuji_prop(struct exifprop *prop, struct exiftags *t)
201 {
202
203 switch (prop->tag) {
204
205 /* Maker note version. */
206
207 case 0x0000:
208 if (prop->count != 4)
209 break;
210 exifstralloc(&prop->str, prop->count + 1);
211 byte4exif(prop->value, (unsigned char *)prop->str, LITTLE);
212 break;
213 }
214 }
215
216
217 /*
218 * Try to read a Fuji maker note IFD.
219 */
220 struct ifd *
fuji_ifd(u_int32_t offset,struct tiffmeta * md)221 fuji_ifd(u_int32_t offset, struct tiffmeta *md)
222 {
223 struct ifd *myifd;
224 int fujilen, fujioff;
225
226 fujilen = strlen("FUJIFILM");
227
228 /*
229 * The Fuji maker note appears to be in Intel byte order
230 * regardless of the rest of the file (!). Also, it seems that
231 * Fuji maker notes start with an ID string, followed by an IFD
232 * offset relative to the MakerNote tag.
233 */
234
235 if (!strncmp((const char *)(md->btiff + offset), "FUJIFILM", fujilen)) {
236 fujioff = exif2byte(md->btiff + offset + fujilen, LITTLE);
237 md->order = LITTLE;
238 readifd(offset + fujioff, &myifd, fuji_tags, md);
239 } else
240 readifd(offset, &myifd, fuji_tags, md);
241
242 return (myifd);
243 }
244