Changeset 13061 in josm for trunk/src/com/drew/metadata/exif/makernotes/CanonMakernoteDirectory.java
- Timestamp:
- 2017-10-30T22:46:09+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/drew/metadata/exif/makernotes/CanonMakernoteDirectory.java
r10862 r13061 1 1 /* 2 * Copyright 2002-201 6Drew Noakes2 * Copyright 2002-2017 Drew Noakes 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 35 35 * @author Drew Noakes https://drewnoakes.com 36 36 */ 37 @SuppressWarnings("WeakerAccess") 37 38 public class CanonMakernoteDirectory extends Directory 38 39 { … … 159 160 public static final int TAG_FOCUS_MODE_1 = OFFSET + 0x07; 160 161 public static final int TAG_UNKNOWN_3 = OFFSET + 0x08; 161 public static final int TAG_ UNKNOWN_4= OFFSET + 0x09;162 public static final int TAG_RECORD_MODE = OFFSET + 0x09; 162 163 /** 163 164 * 0 = Large … … 249 250 public static final int TAG_SHORT_FOCAL_LENGTH = OFFSET + 0x18; 250 251 public static final int TAG_FOCAL_UNITS_PER_MM = OFFSET + 0x19; 251 public static final int TAG_ UNKNOWN_9= OFFSET + 0x1A;252 public static final int TAG_ UNKNOWN_10= OFFSET + 0x1B;252 public static final int TAG_MAX_APERTURE = OFFSET + 0x1A; 253 public static final int TAG_MIN_APERTURE = OFFSET + 0x1B; 253 254 /** 254 255 * 0 = Flash Did Not Fire … … 257 258 public static final int TAG_FLASH_ACTIVITY = OFFSET + 0x1C; 258 259 public static final int TAG_FLASH_DETAILS = OFFSET + 0x1D; 259 public static final int TAG_ UNKNOWN_12= OFFSET + 0x1E;260 public static final int TAG_ UNKNOWN_13= OFFSET + 0x1F;260 public static final int TAG_FOCUS_CONTINUOUS = OFFSET + 0x1E; 261 public static final int TAG_AE_SETTING = OFFSET + 0x1F; 261 262 /** 262 263 * 0 = Focus Mode: Single … … 264 265 */ 265 266 public static final int TAG_FOCUS_MODE_2 = OFFSET + 0x20; 267 268 public static final int TAG_DISPLAY_APERTURE = OFFSET + 0x21; 269 public static final int TAG_ZOOM_SOURCE_WIDTH = OFFSET + 0x22; 270 public static final int TAG_ZOOM_TARGET_WIDTH = OFFSET + 0x23; 271 272 public static final int TAG_SPOT_METERING_MODE = OFFSET + 0x25; 273 public static final int TAG_PHOTO_EFFECT = OFFSET + 0x26; 274 public static final int TAG_MANUAL_FLASH_OUTPUT = OFFSET + 0x27; 275 276 public static final int TAG_COLOR_TONE = OFFSET + 0x29; 277 public static final int TAG_SRAW_QUALITY = OFFSET + 0x2D; 266 278 } 267 279 … … 515 527 _tagNameMap.put(CameraSettings.TAG_UNKNOWN_2, "Unknown Camera Setting 2"); 516 528 _tagNameMap.put(CameraSettings.TAG_UNKNOWN_3, "Unknown Camera Setting 3"); 517 _tagNameMap.put(CameraSettings.TAG_ UNKNOWN_4, "Unknown Camera Setting 4");529 _tagNameMap.put(CameraSettings.TAG_RECORD_MODE, "Record Mode"); 518 530 _tagNameMap.put(CameraSettings.TAG_DIGITAL_ZOOM, "Digital Zoom"); 519 531 _tagNameMap.put(CameraSettings.TAG_FOCUS_TYPE, "Focus Type"); 520 532 _tagNameMap.put(CameraSettings.TAG_UNKNOWN_7, "Unknown Camera Setting 7"); 521 533 _tagNameMap.put(CameraSettings.TAG_LENS_TYPE, "Lens Type"); 522 _tagNameMap.put(CameraSettings.TAG_ UNKNOWN_9, "Unknown Camera Setting 9");523 _tagNameMap.put(CameraSettings.TAG_ UNKNOWN_10, "Unknown Camera Setting 10");534 _tagNameMap.put(CameraSettings.TAG_MAX_APERTURE, "Max Aperture"); 535 _tagNameMap.put(CameraSettings.TAG_MIN_APERTURE, "Min Aperture"); 524 536 _tagNameMap.put(CameraSettings.TAG_FLASH_ACTIVITY, "Flash Activity"); 525 _tagNameMap.put(CameraSettings.TAG_UNKNOWN_12, "Unknown Camera Setting 12"); 526 _tagNameMap.put(CameraSettings.TAG_UNKNOWN_13, "Unknown Camera Setting 13"); 537 _tagNameMap.put(CameraSettings.TAG_FOCUS_CONTINUOUS, "Focus Continuous"); 538 _tagNameMap.put(CameraSettings.TAG_AE_SETTING, "AE Setting"); 539 _tagNameMap.put(CameraSettings.TAG_DISPLAY_APERTURE, "Display Aperture"); 540 _tagNameMap.put(CameraSettings.TAG_ZOOM_SOURCE_WIDTH, "Zoom Source Width"); 541 _tagNameMap.put(CameraSettings.TAG_ZOOM_TARGET_WIDTH, "Zoom Target Width"); 542 _tagNameMap.put(CameraSettings.TAG_SPOT_METERING_MODE, "Spot Metering Mode"); 543 _tagNameMap.put(CameraSettings.TAG_PHOTO_EFFECT, "Photo Effect"); 544 _tagNameMap.put(CameraSettings.TAG_MANUAL_FLASH_OUTPUT, "Manual Flash Output"); 545 _tagNameMap.put(CameraSettings.TAG_COLOR_TONE, "Color Tone"); 546 _tagNameMap.put(CameraSettings.TAG_SRAW_QUALITY, "SRAW Quality"); 527 547 528 548 _tagNameMap.put(FocalLength.TAG_WHITE_BALANCE, "White Balance"); … … 576 596 _tagNameMap.put(AFInfo.TAG_AF_AREA_X_POSITIONS, "AF Area X Positions"); 577 597 _tagNameMap.put(AFInfo.TAG_AF_AREA_Y_POSITIONS, "AF Area Y Positions"); 578 _tagNameMap.put(AFInfo.TAG_AF_POINTS_IN_FOCUS, "AF Points in Focus Count");598 _tagNameMap.put(AFInfo.TAG_AF_POINTS_IN_FOCUS, "AF Points in Focus"); 579 599 _tagNameMap.put(AFInfo.TAG_PRIMARY_AF_POINT_1, "Primary AF Point 1"); 580 600 _tagNameMap.put(AFInfo.TAG_PRIMARY_AF_POINT_2, "Primary AF Point 2"); … … 672 692 // TODO is there some way to drop out 'null' or 'zero' values that are present in the array to reduce the noise? 673 693 694 if (!(array instanceof int[])) { 695 // no special handling... 696 super.setObjectArray(tagType, array); 697 return; 698 } 699 674 700 // Certain Canon tags contain arrays of values that we split into 'fake' tags as each 675 701 // index in the array has its own meaning and decoding. … … 709 735 // break; 710 736 case TAG_AF_INFO_ARRAY: { 711 int[] ints = (int[])array; 712 for (int i = 0; i < ints.length; i++) 713 setInt(AFInfo.OFFSET + i, ints[i]); 737 // Notes from Exiftool 10.10 by Phil Harvey, lib\Image\Exiftool\Canon.pm: 738 // Auto-focus information used by many older Canon models. The values in this 739 // record are sequential, and some have variable sizes based on the value of 740 // numafpoints (which may be 1,5,7,9,15,45, or 53). The AFArea coordinates are 741 // given in a system where the image has dimensions given by AFImageWidth and 742 // AFImageHeight, and 0,0 is the image center. The direction of the Y axis 743 // depends on the camera model, with positive Y upwards for EOS models, but 744 // apparently downwards for PowerShot models. 745 746 // AFInfo is another array with 'fake' tags. The first int of the array contains 747 // the number of AF points. Iterate through the array one byte at a time, generally 748 // assuming one byte corresponds to one tag UNLESS certain tag numbers are encountered. 749 // For these, read specific subsequent bytes from the array based on the tag type. The 750 // number of bytes read can vary. 751 752 int[] values = (int[])array; 753 int numafpoints = values[0]; 754 int tagnumber = 0; 755 for (int i = 0; i < values.length; i++) 756 { 757 // These two tags store 'numafpoints' bytes of data in the array 758 if (AFInfo.OFFSET + tagnumber == AFInfo.TAG_AF_AREA_X_POSITIONS || 759 AFInfo.OFFSET + tagnumber == AFInfo.TAG_AF_AREA_Y_POSITIONS) 760 { 761 // There could be incorrect data in the array, so boundary check 762 if (values.length - 1 >= (i + numafpoints)) 763 { 764 short[] areaPositions = new short[numafpoints]; 765 for (int j = 0; j < areaPositions.length; j++) 766 areaPositions[j] = (short)values[i + j]; 767 768 super.setObjectArray(AFInfo.OFFSET + tagnumber, areaPositions); 769 } 770 i += numafpoints - 1; // assume these bytes are processed and skip 771 } 772 else if (AFInfo.OFFSET + tagnumber == AFInfo.TAG_AF_POINTS_IN_FOCUS) 773 { 774 short[] pointsInFocus = new short[((numafpoints + 15) / 16)]; 775 776 // There could be incorrect data in the array, so boundary check 777 if (values.length - 1 >= (i + pointsInFocus.length)) 778 { 779 for (int j = 0; j < pointsInFocus.length; j++) 780 pointsInFocus[j] = (short)values[i + j]; 781 782 super.setObjectArray(AFInfo.OFFSET + tagnumber, pointsInFocus); 783 } 784 i += pointsInFocus.length - 1; // assume these bytes are processed and skip 785 } 786 else 787 super.setObjectArray(AFInfo.OFFSET + tagnumber, values[i]); 788 tagnumber++; 789 } 714 790 break; 715 791 }
Note:
See TracChangeset
for help on using the changeset viewer.