source: josm/trunk/src/com/drew/metadata/exif/CanonMakernoteDirectory.java@ 4665

Last change on this file since 4665 was 4231, checked in by stoecker, 13 years ago

add signpost and metadata extractor code to repository directly

File size: 17.2 KB
Line 
1/*
2 * This is public domain software - that is, you can do whatever you want
3 * with it, and include it software that is licensed under the GNU or the
4 * BSD license, or whatever other licence you choose, including proprietary
5 * closed source licenses. I do ask that you leave this header in tact.
6 *
7 * If you make modifications to this code that you think would benefit the
8 * wider community, please send me a copy and I'll post it on my site.
9 *
10 * If you make use of this code, I'd appreciate hearing about it.
11 * drew@drewnoakes.com
12 * Latest version of this software kept at
13 * http://drewnoakes.com/
14 *
15 * Created by dnoakes on 27-Nov-2002 10:10:47 using IntelliJ IDEA.
16 */
17package com.drew.metadata.exif;
18
19import com.drew.metadata.Directory;
20
21import java.util.HashMap;
22
23/**
24 * Describes tags specific to Canon cameras.
25 *
26 * Thanks to Bill Richards for his contribution to this makernote directory.
27 *
28 * Many tag definitions explained here: http://www.ozhiker.com/electronics/pjmt/jpeg_info/canon_mn.html
29 */
30public class CanonMakernoteDirectory extends Directory
31{
32 // CANON cameras have some funny bespoke fields that need further processing...
33 public static final int TAG_CANON_CAMERA_STATE_1 = 0x0001;
34 public static final int TAG_CANON_CAMERA_STATE_2 = 0x0004;
35
36 public static final int TAG_CANON_IMAGE_TYPE = 0x0006;
37 public static final int TAG_CANON_FIRMWARE_VERSION = 0x0007;
38 public static final int TAG_CANON_IMAGE_NUMBER = 0x0008;
39 public static final int TAG_CANON_OWNER_NAME = 0x0009;
40 /**
41 * To display serial number as on camera use: printf( "%04X%05d", highbyte, lowbyte )
42 * TODO handle this in CanonMakernoteDescriptor
43 */
44 public static final int TAG_CANON_SERIAL_NUMBER = 0x000C;
45 public static final int TAG_CANON_UNKNOWN_1 = 0x000D;
46 public static final int TAG_CANON_CUSTOM_FUNCTIONS = 0x000F;
47
48 // These 'sub'-tag values have been created for consistency -- they don't exist within the exif segment
49 /**
50 * 1 = Macro
51 * 2 = Normal
52 */
53 public static final int TAG_CANON_STATE1_MACRO_MODE = 0xC101;
54 public static final int TAG_CANON_STATE1_SELF_TIMER_DELAY = 0xC102;
55 /**
56 * 2 = Normal
57 * 3 = Fine
58 * 5 = Superfine
59 */
60 public static final int TAG_CANON_STATE1_QUALITY = 0xC103;
61 /**
62 * 0 = Flash Not Fired
63 * 1 = Auto
64 * 2 = On
65 * 3 = Red Eye Reduction
66 * 4 = Slow Synchro
67 * 5 = Auto + Red Eye Reduction
68 * 6 = On + Red Eye Reduction
69 * 16 = External Flash
70 */
71 public static final int TAG_CANON_STATE1_FLASH_MODE = 0xC104;
72 /**
73 * 0 = Single Frame or Timer Mode
74 * 1 = Continuous
75 */
76 public static final int TAG_CANON_STATE1_CONTINUOUS_DRIVE_MODE = 0xC105;
77 public static final int TAG_CANON_STATE1_UNKNOWN_2 = 0xC106;
78 /**
79 * 0 = One-Shot
80 * 1 = AI Servo
81 * 2 = AI Focus
82 * 3 = Manual Focus
83 * 4 = Single
84 * 5 = Continuous
85 * 6 = Manual Focus
86 */
87 public static final int TAG_CANON_STATE1_FOCUS_MODE_1 = 0xC107;
88 public static final int TAG_CANON_STATE1_UNKNOWN_3 = 0xC108;
89 public static final int TAG_CANON_STATE1_UNKNOWN_4 = 0xC109;
90 /**
91 * 0 = Large
92 * 1 = Medium
93 * 2 = Small
94 */
95 public static final int TAG_CANON_STATE1_IMAGE_SIZE = 0xC10A;
96 /**
97 * 0 = Full Auto
98 * 1 = Manual
99 * 2 = Landscape
100 * 3 = Fast Shutter
101 * 4 = Slow Shutter
102 * 5 = Night
103 * 6 = Black & White
104 * 7 = Sepia
105 * 8 = Portrait
106 * 9 = Sports
107 * 10 = Macro / Close-Up
108 * 11 = Pan Focus
109 */
110 public static final int TAG_CANON_STATE1_EASY_SHOOTING_MODE = 0xC10B;
111 /**
112 * 0 = No Digital Zoom
113 * 1 = 2x
114 * 2 = 4x
115 */
116 public static final int TAG_CANON_STATE1_DIGITAL_ZOOM = 0xC10C;
117 /**
118 * 0 = Normal
119 * 1 = High
120 * 65535 = Low
121 */
122 public static final int TAG_CANON_STATE1_CONTRAST = 0xC10D;
123 /**
124 * 0 = Normal
125 * 1 = High
126 * 65535 = Low
127 */
128 public static final int TAG_CANON_STATE1_SATURATION = 0xC10E;
129 /**
130 * 0 = Normal
131 * 1 = High
132 * 65535 = Low
133 */
134 public static final int TAG_CANON_STATE1_SHARPNESS = 0xC10F;
135 /**
136 * 0 = Check ISOSpeedRatings EXIF tag for ISO Speed
137 * 15 = Auto ISO
138 * 16 = ISO 50
139 * 17 = ISO 100
140 * 18 = ISO 200
141 * 19 = ISO 400
142 */
143 public static final int TAG_CANON_STATE1_ISO = 0xC110;
144 /**
145 * 3 = Evaluative
146 * 4 = Partial
147 * 5 = Centre Weighted
148 */
149 public static final int TAG_CANON_STATE1_METERING_MODE = 0xC111;
150 /**
151 * 0 = Manual
152 * 1 = Auto
153 * 3 = Close-up (Macro)
154 * 8 = Locked (Pan Mode)
155 */
156 public static final int TAG_CANON_STATE1_FOCUS_TYPE = 0xC112;
157 /**
158 * 12288 = None (Manual Focus)
159 * 12289 = Auto Selected
160 * 12290 = Right
161 * 12291 = Centre
162 * 12292 = Left
163 */
164 public static final int TAG_CANON_STATE1_AF_POINT_SELECTED = 0xC113;
165 /**
166 * 0 = Easy Shooting (See Easy Shooting Mode)
167 * 1 = Program
168 * 2 = Tv-Priority
169 * 3 = Av-Priority
170 * 4 = Manual
171 * 5 = A-DEP
172 */
173 public static final int TAG_CANON_STATE1_EXPOSURE_MODE = 0xC114;
174 public static final int TAG_CANON_STATE1_UNKNOWN_7 = 0xC115;
175 public static final int TAG_CANON_STATE1_UNKNOWN_8 = 0xC116;
176 public static final int TAG_CANON_STATE1_LONG_FOCAL_LENGTH = 0xC117;
177 public static final int TAG_CANON_STATE1_SHORT_FOCAL_LENGTH = 0xC118;
178 public static final int TAG_CANON_STATE1_FOCAL_UNITS_PER_MM = 0xC119;
179 public static final int TAG_CANON_STATE1_UNKNOWN_9 = 0xC11A;
180 public static final int TAG_CANON_STATE1_UNKNOWN_10 = 0xC11B;
181 /**
182 * 0 = Flash Did Not Fire
183 * 1 = Flash Fired
184 */
185 public static final int TAG_CANON_STATE1_FLASH_ACTIVITY = 0xC11C;
186 public static final int TAG_CANON_STATE1_FLASH_DETAILS = 0xC11D;
187 public static final int TAG_CANON_STATE1_UNKNOWN_12 = 0xC11E;
188 public static final int TAG_CANON_STATE1_UNKNOWN_13 = 0xC11F;
189 /**
190 * 0 = Focus Mode: Single
191 * 1 = Focus Mode: Continuous
192 */
193 public static final int TAG_CANON_STATE1_FOCUS_MODE_2 = 0xC120;
194
195 /**
196 * 0 = Auto
197 * 1 = Sunny
198 * 2 = Cloudy
199 * 3 = Tungsten
200 * 4 = Flourescent
201 * 5 = Flash
202 * 6 = Custom
203 */
204 public static final int TAG_CANON_STATE2_WHITE_BALANCE = 0xC207;
205 public static final int TAG_CANON_STATE2_SEQUENCE_NUMBER = 0xC209;
206 public static final int TAG_CANON_STATE2_AF_POINT_USED = 0xC20E;
207 /**
208 * The value of this tag may be translated into a flash bias value, in EV.
209 *
210 * 0xffc0 = -2 EV
211 * 0xffcc = -1.67 EV
212 * 0xffd0 = -1.5 EV
213 * 0xffd4 = -1.33 EV
214 * 0xffe0 = -1 EV
215 * 0xffec = -0.67 EV
216 * 0xfff0 = -0.5 EV
217 * 0xfff4 = -0.33 EV
218 * 0x0000 = 0 EV
219 * 0x000c = 0.33 EV
220 * 0x0010 = 0.5 EV
221 * 0x0014 = 0.67 EV
222 * 0x0020 = 1 EV
223 * 0x002c = 1.33 EV
224 * 0x0030 = 1.5 EV
225 * 0x0034 = 1.67 EV
226 * 0x0040 = 2 EV
227 */
228 public static final int TAG_CANON_STATE2_FLASH_BIAS = 0xC20F;
229 public static final int TAG_CANON_STATE2_AUTO_EXPOSURE_BRACKETING = 0xC210;
230 public static final int TAG_CANON_STATE2_AEB_BRACKET_VALUE = 0xC211;
231 public static final int TAG_CANON_STATE2_SUBJECT_DISTANCE = 0xC213;
232
233 /**
234 * Long Exposure Noise Reduction
235 * 0 = Off
236 * 1 = On
237 */
238 public static final int TAG_CANON_CUSTOM_FUNCTION_LONG_EXPOSURE_NOISE_REDUCTION = 0xC301;
239
240 /**
241 * Shutter/Auto Exposure-lock buttons
242 * 0 = AF/AE lock
243 * 1 = AE lock/AF
244 * 2 = AF/AF lock
245 * 3 = AE+release/AE+AF
246 */
247 public static final int TAG_CANON_CUSTOM_FUNCTION_SHUTTER_AUTO_EXPOSURE_LOCK_BUTTONS = 0xC302;
248
249 /**
250 * Mirror lockup
251 * 0 = Disable
252 * 1 = Enable
253 */
254 public static final int TAG_CANON_CUSTOM_FUNCTION_MIRROR_LOCKUP = 0xC303;
255
256 /**
257 * Tv/Av and exposure level
258 * 0 = 1/2 stop
259 * 1 = 1/3 stop
260 */
261 public static final int TAG_CANON_CUSTOM_FUNCTION_TV_AV_AND_EXPOSURE_LEVEL = 0xC304;
262
263 /**
264 * AF-assist light
265 * 0 = On (Auto)
266 * 1 = Off
267 */
268 public static final int TAG_CANON_CUSTOM_FUNCTION_AF_ASSIST_LIGHT = 0xC305;
269
270 /**
271 * Shutter speed in Av mode
272 * 0 = Automatic
273 * 1 = 1/200 (fixed)
274 */
275 public static final int TAG_CANON_CUSTOM_FUNCTION_SHUTTER_SPEED_IN_AV_MODE = 0xC306;
276
277 /**
278 * Auto-Exposure Bracketting sequence/auto cancellation
279 * 0 = 0,-,+ / Enabled
280 * 1 = 0,-,+ / Disabled
281 * 2 = -,0,+ / Enabled
282 * 3 = -,0,+ / Disabled
283 */
284 public static final int TAG_CANON_CUSTOM_FUNCTION_BRACKETTING = 0xC307;
285
286 /**
287 * Shutter Curtain Sync
288 * 0 = 1st Curtain Sync
289 * 1 = 2nd Curtain Sync
290 */
291 public static final int TAG_CANON_CUSTOM_FUNCTION_SHUTTER_CURTAIN_SYNC = 0xC308;
292
293 /**
294 * Lens Auto-Focus stop button Function Switch
295 * 0 = AF stop
296 * 1 = Operate AF
297 * 2 = Lock AE and start timer
298 */
299 public static final int TAG_CANON_CUSTOM_FUNCTION_AF_STOP = 0xC309;
300
301 /**
302 * Auto reduction of fill flash
303 * 0 = Enable
304 * 1 = Disable
305 */
306 public static final int TAG_CANON_CUSTOM_FUNCTION_FILL_FLASH_REDUCTION = 0xC30A;
307
308 /**
309 * Menu button return position
310 * 0 = Top
311 * 1 = Previous (volatile)
312 * 2 = Previous
313 */
314 public static final int TAG_CANON_CUSTOM_FUNCTION_MENU_BUTTON_RETURN = 0xC30B;
315
316 /**
317 * SET button function when shooting
318 * 0 = Not Assigned
319 * 1 = Change Quality
320 * 2 = Change ISO Speed
321 * 3 = Select Parameters
322 */
323 public static final int TAG_CANON_CUSTOM_FUNCTION_SET_BUTTON_FUNCTION = 0xC30C;
324
325 /**
326 * Sensor cleaning
327 * 0 = Disable
328 * 1 = Enable
329 */
330 public static final int TAG_CANON_CUSTOM_FUNCTION_SENSOR_CLEANING = 0xC30D;
331
332 // 9 A B C D E F 10 11 12 13
333 // 9 10 11 12 13 14 15 16 17 18 19
334 protected static final HashMap _tagNameMap = new HashMap();
335
336 static
337 {
338 _tagNameMap.put(new Integer(TAG_CANON_FIRMWARE_VERSION), "Firmware Version");
339 _tagNameMap.put(new Integer(TAG_CANON_IMAGE_NUMBER), "Image Number");
340 _tagNameMap.put(new Integer(TAG_CANON_IMAGE_TYPE), "Image Type");
341 _tagNameMap.put(new Integer(TAG_CANON_OWNER_NAME), "Owner Name");
342 _tagNameMap.put(new Integer(TAG_CANON_UNKNOWN_1), "Makernote Unknown 1");
343 _tagNameMap.put(new Integer(TAG_CANON_CUSTOM_FUNCTIONS), "Custom Functions");
344 _tagNameMap.put(new Integer(TAG_CANON_SERIAL_NUMBER), "Camera Serial Number");
345 _tagNameMap.put(new Integer(TAG_CANON_STATE1_AF_POINT_SELECTED), "AF Point Selected");
346 _tagNameMap.put(new Integer(TAG_CANON_STATE1_CONTINUOUS_DRIVE_MODE), "Continuous Drive Mode");
347 _tagNameMap.put(new Integer(TAG_CANON_STATE1_CONTRAST), "Contrast");
348 _tagNameMap.put(new Integer(TAG_CANON_STATE1_EASY_SHOOTING_MODE), "Easy Shooting Mode");
349 _tagNameMap.put(new Integer(TAG_CANON_STATE1_EXPOSURE_MODE), "Exposure Mode");
350 _tagNameMap.put(new Integer(TAG_CANON_STATE1_FLASH_DETAILS), "Flash Details");
351 _tagNameMap.put(new Integer(TAG_CANON_STATE1_FLASH_MODE), "Flash Mode");
352 _tagNameMap.put(new Integer(TAG_CANON_STATE1_FOCAL_UNITS_PER_MM), "Focal Units per mm");
353 _tagNameMap.put(new Integer(TAG_CANON_STATE1_FOCUS_MODE_1), "Focus Mode");
354 _tagNameMap.put(new Integer(TAG_CANON_STATE1_FOCUS_MODE_2), "Focus Mode");
355 _tagNameMap.put(new Integer(TAG_CANON_STATE1_IMAGE_SIZE), "Image Size");
356 _tagNameMap.put(new Integer(TAG_CANON_STATE1_ISO), "Iso");
357 _tagNameMap.put(new Integer(TAG_CANON_STATE1_LONG_FOCAL_LENGTH), "Long Focal Length");
358 _tagNameMap.put(new Integer(TAG_CANON_STATE1_MACRO_MODE), "Macro Mode");
359 _tagNameMap.put(new Integer(TAG_CANON_STATE1_METERING_MODE), "Metering Mode");
360 _tagNameMap.put(new Integer(TAG_CANON_STATE1_SATURATION), "Saturation");
361 _tagNameMap.put(new Integer(TAG_CANON_STATE1_SELF_TIMER_DELAY), "Self Timer Delay");
362 _tagNameMap.put(new Integer(TAG_CANON_STATE1_SHARPNESS), "Sharpness");
363 _tagNameMap.put(new Integer(TAG_CANON_STATE1_SHORT_FOCAL_LENGTH), "Short Focal Length");
364 _tagNameMap.put(new Integer(TAG_CANON_STATE1_QUALITY), "Quality");
365 _tagNameMap.put(new Integer(TAG_CANON_STATE1_UNKNOWN_2), "Unknown Camera State 2");
366 _tagNameMap.put(new Integer(TAG_CANON_STATE1_UNKNOWN_3), "Unknown Camera State 3");
367 _tagNameMap.put(new Integer(TAG_CANON_STATE1_UNKNOWN_4), "Unknown Camera State 4");
368 _tagNameMap.put(new Integer(TAG_CANON_STATE1_DIGITAL_ZOOM), "Digital Zoom");
369 _tagNameMap.put(new Integer(TAG_CANON_STATE1_FOCUS_TYPE), "Focus Type");
370 _tagNameMap.put(new Integer(TAG_CANON_STATE1_UNKNOWN_7), "Unknown Camera State 7");
371 _tagNameMap.put(new Integer(TAG_CANON_STATE1_UNKNOWN_8), "Unknown Camera State 8");
372 _tagNameMap.put(new Integer(TAG_CANON_STATE1_UNKNOWN_9), "Unknown Camera State 9");
373 _tagNameMap.put(new Integer(TAG_CANON_STATE1_UNKNOWN_10), "Unknown Camera State 10");
374 _tagNameMap.put(new Integer(TAG_CANON_STATE1_FLASH_ACTIVITY), "Flash Activity");
375 _tagNameMap.put(new Integer(TAG_CANON_STATE1_UNKNOWN_12), "Unknown Camera State 12");
376 _tagNameMap.put(new Integer(TAG_CANON_STATE1_UNKNOWN_13), "Unknown Camera State 13");
377 _tagNameMap.put(new Integer(TAG_CANON_STATE2_WHITE_BALANCE), "White Balance");
378 _tagNameMap.put(new Integer(TAG_CANON_STATE2_SEQUENCE_NUMBER), "Sequence Number");
379 _tagNameMap.put(new Integer(TAG_CANON_STATE2_AF_POINT_USED), "AF Point Used");
380 _tagNameMap.put(new Integer(TAG_CANON_STATE2_FLASH_BIAS), "Flash Bias");
381 _tagNameMap.put(new Integer(TAG_CANON_STATE2_AUTO_EXPOSURE_BRACKETING), "Auto Exposure Bracketing");
382 _tagNameMap.put(new Integer(TAG_CANON_STATE2_AEB_BRACKET_VALUE), "AEB Bracket Value");
383 _tagNameMap.put(new Integer(TAG_CANON_STATE2_SUBJECT_DISTANCE), "Subject Distance");
384
385 _tagNameMap.put(new Integer(TAG_CANON_CUSTOM_FUNCTION_LONG_EXPOSURE_NOISE_REDUCTION), "Long Exposure Noise Reduction");
386 _tagNameMap.put(new Integer(TAG_CANON_CUSTOM_FUNCTION_SHUTTER_AUTO_EXPOSURE_LOCK_BUTTONS), "Shutter/Auto Exposure-lock Buttons");
387 _tagNameMap.put(new Integer(TAG_CANON_CUSTOM_FUNCTION_MIRROR_LOCKUP), "Mirror Lockup");
388 _tagNameMap.put(new Integer(TAG_CANON_CUSTOM_FUNCTION_TV_AV_AND_EXPOSURE_LEVEL), "Tv/Av And Exposure Level");
389 _tagNameMap.put(new Integer(TAG_CANON_CUSTOM_FUNCTION_AF_ASSIST_LIGHT), "AF-Assist Light");
390 _tagNameMap.put(new Integer(TAG_CANON_CUSTOM_FUNCTION_SHUTTER_SPEED_IN_AV_MODE), "Shutter Speed in Av Mode");
391 _tagNameMap.put(new Integer(TAG_CANON_CUSTOM_FUNCTION_BRACKETTING), "Auto-Exposure Bracketting Sequence/Auto Cancellation");
392 _tagNameMap.put(new Integer(TAG_CANON_CUSTOM_FUNCTION_SHUTTER_CURTAIN_SYNC), "Shutter Curtain Sync");
393 _tagNameMap.put(new Integer(TAG_CANON_CUSTOM_FUNCTION_AF_STOP), "Lens Auto-Focus Stop Button Function Switch");
394 _tagNameMap.put(new Integer(TAG_CANON_CUSTOM_FUNCTION_FILL_FLASH_REDUCTION), "Auto Reduction of Fill Flash");
395 _tagNameMap.put(new Integer(TAG_CANON_CUSTOM_FUNCTION_MENU_BUTTON_RETURN), "Menu Button Return Position");
396 _tagNameMap.put(new Integer(TAG_CANON_CUSTOM_FUNCTION_SET_BUTTON_FUNCTION), "SET Button Function When Shooting");
397 _tagNameMap.put(new Integer(TAG_CANON_CUSTOM_FUNCTION_SENSOR_CLEANING), "Sensor Cleaning");
398 }
399
400 public CanonMakernoteDirectory()
401 {
402 this.setDescriptor(new CanonMakernoteDescriptor(this));
403 }
404
405 public String getName()
406 {
407 return "Canon Makernote";
408 }
409
410 protected HashMap getTagNameMap()
411 {
412 return _tagNameMap;
413 }
414
415 /**
416 * We need special handling for selected tags.
417 * @param tagType
418 * @param ints
419 */
420 public void setIntArray(int tagType, int[] ints)
421 {
422 if (tagType == TAG_CANON_CAMERA_STATE_1) {
423 // this single tag has multiple values within
424 int subTagTypeBase = 0xC100;
425 // we intentionally skip the first array member
426 for (int i = 1; i < ints.length; i++) {
427 setInt(subTagTypeBase + i, ints[i]);
428 }
429 } else if (tagType == TAG_CANON_CAMERA_STATE_2) {
430 // this single tag has multiple values within
431 int subTagTypeBase = 0xC200;
432 // we intentionally skip the first array member
433 for (int i = 1; i < ints.length; i++) {
434 setInt(subTagTypeBase + i, ints[i]);
435 }
436 } if (tagType == TAG_CANON_CUSTOM_FUNCTIONS) {
437 // this single tag has multiple values within
438 int subTagTypeBase = 0xC300;
439 // we intentionally skip the first array member
440 for (int i = 1; i < ints.length; i++) {
441 setInt(subTagTypeBase + i + 1, ints[i] & 0x0F);
442 }
443 } else {
444 // no special handling...
445 super.setIntArray(tagType, ints);
446 }
447 }
448}
Note: See TracBrowser for help on using the repository browser.