Skip to content

Commit 8df28c1

Browse files
authored
Merge pull request #1437 from hassec/NikonLensData800
Implement Nikon LensData version 8 handler (0.27->master)
2 parents 6d16caa + 4c2ac99 commit 8df28c1

File tree

6 files changed

+143
-1
lines changed

6 files changed

+143
-1
lines changed

src/makernote_int.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,8 @@ namespace Exiv2 {
11711171
{ 0x0098, "0202", 0, 1, 4 },
11721172
{ 0x0098, "0203", 0, 1, 4 },
11731173
{ 0x0098, "0204", 0, 2, 4 },
1174+
{ 0x0098, "0800", 0, 3, 4 }, // for e.g. Z6/7
1175+
{ 0x0098, "0801", 0, 3, 4 }, // for e.g. Z6/7
11741176
// NikonFl
11751177
{ 0x00a8, "0100", 0, 0, NA },
11761178
{ 0x00a8, "0101", 0, 0, NA },

src/nikonmn_int.cpp

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,37 @@ namespace Exiv2 {
14651465
return tagInfoLd3_;
14661466
}
14671467

1468+
// Nikon3 Lens Data 4 Tag Info
1469+
// based on https://exiftool.org/TagNames/Nikon.html#LensData0800
1470+
const TagInfo Nikon3MakerNote::tagInfoLd4_[] = {
1471+
TagInfo( 0, "Version", N_("Version"), N_("Version"), nikonLd4Id, makerTags, undefined, 4, printExifVersion),
1472+
TagInfo( 4, "ExitPupilPosition", N_("Exit Pupil Position"), N_("Exit pupil position"), nikonLd4Id, makerTags, unsignedByte, 1, printExitPupilPosition),
1473+
TagInfo( 5, "AFAperture", N_("AF Aperture"), N_("AF aperture"), nikonLd4Id, makerTags, unsignedByte, 1, printAperture),
1474+
TagInfo( 9, "FocusPosition", N_("Focus Position"), N_("Focus position"), nikonLd4Id, makerTags, unsignedByte, 1, printValue),
1475+
TagInfo(11, "FocusDistance", N_("Focus Distance"), N_("Focus distance"), nikonLd4Id, makerTags, unsignedByte, 1, printFocusDistance),
1476+
TagInfo(12, "FocalLength", N_("Focal Length"), N_("Focal length"), nikonLd4Id, makerTags, unsignedByte, 1, printFocal),
1477+
TagInfo(13, "LensIDNumber", N_("Lens ID Number"), N_("Lens ID number"), nikonLd4Id, makerTags, unsignedByte, 1, printLensId4),
1478+
TagInfo(14, "LensFStops", N_("Lens F-Stops"), N_("Lens F-stops"), nikonLd4Id, makerTags, unsignedByte, 1, printFStops),
1479+
TagInfo(15, "MinFocalLength", N_("Min Focal Length"), N_("Min focal length"), nikonLd4Id, makerTags, unsignedByte, 1, printFocal),
1480+
TagInfo(16, "MaxFocalLength", N_("Max Focal Length"), N_("Max focal length"), nikonLd4Id, makerTags, unsignedByte, 1, printFocal),
1481+
TagInfo(17, "MaxApertureAtMinFocal", N_("Max Aperture At Min Focal"), N_("Max aperture at min focal length"), nikonLd4Id, makerTags, unsignedByte, 1, printAperture),
1482+
TagInfo(18, "MaxApertureAtMaxFocal", N_("Max Aperture At Max Focal"), N_("Max aperture at max focal length"), nikonLd4Id, makerTags, unsignedByte, 1, printAperture),
1483+
TagInfo(19, "MCUVersion", N_("MCU Version"), N_("MCU version"), nikonLd4Id, makerTags, unsignedByte, 1, printValue),
1484+
TagInfo(20, "EffectiveMaxAperture", N_("Effective Max Aperture"), N_("Effective max aperture"), nikonLd4Id, makerTags, unsignedByte, 1, printAperture),
1485+
TagInfo(48, "LensID", N_("LensID"), N_("Lens ID"), nikonLd4Id, makerTags, unsignedShort, 1, printLensId4ZMount),
1486+
TagInfo(54, "MaxAperture", N_("Max Aperture"), N_("Max aperture"), nikonLd4Id, makerTags, unsignedShort, 1, printApertureLd4),
1487+
TagInfo(56, "FNumber", N_("F-Number"), N_("F-Number"), nikonLd4Id, makerTags, unsignedShort, 1, printApertureLd4),
1488+
TagInfo(60, "FocalLength", N_("Focal Length"), N_("Focal length"), nikonLd4Id, makerTags, unsignedShort, 1, printFocalLd4),
1489+
TagInfo(79, "FocusDistance", N_("Focus Distance"), N_("Focus distance"), nikonLd4Id, makerTags, unsignedByte, 1, printFocusDistance),
1490+
// End of list marker
1491+
TagInfo(0xffff, "(UnknownNikonLd4Tag)", "(UnknownNikonLd4Tag)", N_("Unknown Nikon Lens Data 3 Tag"), nikonLd4Id, makerTags, unsignedByte, 1, printValue)
1492+
};
1493+
1494+
const TagInfo* Nikon3MakerNote::tagListLd4()
1495+
{
1496+
return tagInfoLd4_;
1497+
}
1498+
14681499
std::ostream& Nikon3MakerNote::printIiIso(std::ostream& os,
14691500
const Value& value,
14701501
const ExifData*)
@@ -1790,6 +1821,13 @@ namespace Exiv2 {
17901821
return testConfigFile(os,value) ? os : printLensId(os, value, metadata, "NikonLd3");
17911822
}
17921823

1824+
std::ostream& Nikon3MakerNote::printLensId4(std::ostream& os,
1825+
const Value& value,
1826+
const ExifData* metadata)
1827+
{
1828+
return testConfigFile(os,value) ? os : printLensId(os, value, metadata, "NikonLd4");
1829+
}
1830+
17931831
std::ostream& Nikon3MakerNote::printLensId(std::ostream& os,
17941832
const Value& value,
17951833
const ExifData* metadata,
@@ -2876,4 +2914,71 @@ fmountlens[] = {
28762914
return os << s;
28772915
}
28782916

2917+
std::ostream& Nikon3MakerNote::printLensId4ZMount(std::ostream& os,
2918+
const Value& value,
2919+
const ExifData*)
2920+
{
2921+
if (value.count() != 1 || value.typeId() != unsignedShort) {
2922+
return os << "(" << value << ")";
2923+
}
2924+
2925+
// from https://github.com/exiftool/exiftool/blob/12.12/lib/Image/ExifTool/Nikon.pm#L4646
2926+
static const struct ZMntLens {uint16_t lid; const char *manuf, *lensname;}
2927+
zmountlens[] = {
2928+
{1 , "Nikon", "Nikkor Z 24-70mm f/4 S"},
2929+
{2 , "Nikon", "Nikkor Z 14-30mm f/4 S"},
2930+
{4 , "Nikon", "Nikkor Z 35mm f/1.8 S"},
2931+
{8 , "Nikon", "Nikkor Z 58mm f/0.95 S Noct"}, //IB
2932+
{9 , "Nikon", "Nikkor Z 50mm f/1.8 S"},
2933+
{11 , "Nikon", "Nikkor Z DX 16-50mm f/3.5-6.3 VR"},
2934+
{12 , "Nikon", "Nikkor Z DX 50-250mm f/4.5-6.3 VR"},
2935+
{13 , "Nikon", "Nikkor Z 24-70mm f/2.8 S"},
2936+
{14 , "Nikon", "Nikkor Z 85mm f/1.8 S"},
2937+
{15 , "Nikon", "Nikkor Z 24mm f/1.8 S"}, //IB
2938+
{16 , "Nikon", "Nikkor Z 70-200mm f/2.8 VR S"}, //IB
2939+
{17 , "Nikon", "Nikkor Z 20mm f/1.8 S"}, //IB
2940+
{18 , "Nikon", "Nikkor Z 24-200mm f/4-6.3 VR"}, //IB
2941+
{21 , "Nikon", "Nikkor Z 50mm f/1.2 S"}, //IB
2942+
{22 , "Nikon", "Nikkor Z 24-50mm f/4-6.3"}, //IB
2943+
{23 , "Nikon", "Nikkor Z 14-24mm f/2.8 S"}, //IB
2944+
{0 , "", ""} //end of array
2945+
};
2946+
2947+
uint16_t lid = static_cast<uint16_t>(value.toLong());
2948+
for(int i = 0; zmountlens[i].lid != 0; ++i){
2949+
if ( zmountlens[i].lid == lid ) return os << zmountlens[i].manuf << " " << zmountlens[i].lensname;
2950+
}
2951+
return os << lid;
2952+
}
2953+
2954+
std::ostream& Nikon3MakerNote::printApertureLd4(std::ostream& os,
2955+
const Value& value,
2956+
const ExifData*)
2957+
{
2958+
if (value.count() != 1 || value.typeId() != unsignedShort) {
2959+
return os << "(" << value << ")";
2960+
}
2961+
2962+
double aperture = pow(2.0, value.toLong()/384.0 - 1.0);
2963+
std::ostringstream oss;
2964+
oss.copyfmt(os);
2965+
os << std::fixed << std::setprecision(1) << "F" << aperture;
2966+
os.copyfmt(oss);
2967+
return os;
2968+
}
2969+
std::ostream& Nikon3MakerNote::printFocalLd4(std::ostream& os,
2970+
const Value& value,
2971+
const ExifData*)
2972+
{
2973+
if (value.count() != 1 || value.typeId() != unsignedShort) {
2974+
return os << "(" << value << ")";
2975+
}
2976+
std::ostringstream oss;
2977+
oss.copyfmt(os);
2978+
os << std::fixed << std::setprecision(1) << value.toLong() << " mm";
2979+
os.copyfmt(oss);
2980+
return os;
2981+
}
2982+
2983+
28792984
}} // namespace Internal, Exiv2

src/nikonmn_int.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ namespace Exiv2 {
167167
static const TagInfo* tagListLd2();
168168
//! Return read-only list of built-in Lens Data 3 tags
169169
static const TagInfo* tagListLd3();
170+
//! Return read-only list of built-in Lens Data 4 tags
171+
static const TagInfo* tagListLd4();
170172

171173
//! @name Print functions for Nikon3 %MakerNote tags
172174
//@{
@@ -195,12 +197,19 @@ namespace Exiv2 {
195197
static std::ostream& printLensId1(std::ostream& os, const Value& value, const ExifData* metadata);
196198
static std::ostream& printLensId2(std::ostream& os, const Value& value, const ExifData* metadata);
197199
static std::ostream& printLensId3(std::ostream& os, const Value& value, const ExifData* metadata);
200+
static std::ostream& printLensId4(std::ostream& os, const Value& value, const ExifData* metadata);
201+
//! Print lensname for ZMount Lens in new LensData as used for e.g. Nikon Z 6/7
202+
static std::ostream& printLensId4ZMount(std::ostream& os, const Value& value, const ExifData*);
198203
//! Print focus distance
199204
static std::ostream& printFocusDistance(std::ostream& os, const Value& value, const ExifData*);
200205
//! Print lens aperture value
201206
static std::ostream& printAperture(std::ostream& os, const Value& value, const ExifData*);
207+
//! Print lens aperture value for new LensData as used for e.g. Nikon Z 6/7
208+
static std::ostream& printApertureLd4(std::ostream& os, const Value& value, const ExifData*);
202209
//! Print lens focal length
203210
static std::ostream& printFocal(std::ostream& os, const Value& value, const ExifData*);
211+
//! Print Focal length value for new LensData as used for e.g. Nikon Z 6/7
212+
static std::ostream& printFocalLd4(std::ostream& os, const Value& value, const ExifData*);
204213
//! Print lens f-stops
205214
static std::ostream& printFStops(std::ostream& os, const Value& value, const ExifData*);
206215
//! Print exit pupil position
@@ -280,6 +289,8 @@ namespace Exiv2 {
280289
static const TagInfo tagInfoLd2_[];
281290
//! Lens Data 3 tag information
282291
static const TagInfo tagInfoLd3_[];
292+
//! Lens Data 4 tag information
293+
static const TagInfo tagInfoLd4_[];
283294

284295
}; // class Nikon3MakerNote
285296

src/tags_int.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ namespace Exiv2 {
129129
{ nikonLd1Id, "Makernote", "NikonLd1", Nikon3MakerNote::tagListLd1 },
130130
{ nikonLd2Id, "Makernote", "NikonLd2", Nikon3MakerNote::tagListLd2 },
131131
{ nikonLd3Id, "Makernote", "NikonLd3", Nikon3MakerNote::tagListLd3 },
132+
{ nikonLd4Id, "Makernote", "NikonLd4", Nikon3MakerNote::tagListLd4 },
132133
{ olympusId, "Makernote", "Olympus", OlympusMakerNote::tagList },
133134
{ olympus2Id, "Makernote", "Olympus2", OlympusMakerNote::tagList },
134135
{ olympusCsId, "Makernote", "OlympusCs", OlympusMakerNote::tagListCs },

src/tags_int.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ namespace Exiv2 {
116116
nikonLd1Id,
117117
nikonLd2Id,
118118
nikonLd3Id,
119+
nikonLd4Id,
119120
nikonCb1Id,
120121
nikonCb2Id,
121122
nikonCb2aId,

src/tiffimage_int.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,15 +563,35 @@ namespace Exiv2 {
563563
false, // Don't concatenate gaps
564564
{ 0, ttUnsignedByte, 1 }
565565
};
566+
//! Nikon Lens Data binary array - configuration 3
567+
extern const ArrayCfg nikonLd4Cfg = {
568+
nikonLd4Id, // Group for the elements
569+
invalidByteOrder, // Use byte order from parent
570+
ttUndefined, // Type for array entry
571+
nikonCrypt, // Encryption function
572+
false, // No size element
573+
true, // Write all tags
574+
false, // Don't concatenate gaps
575+
{ 0, ttUnsignedByte, 1 }
576+
};
566577
//! Nikon Lens Data binary array - definition
567578
extern const ArrayDef nikonLdDef[] = {
568579
{ 0, ttUndefined, 4 } // Version
569580
};
581+
//! Nikon Lens Data binary array - definition
582+
extern const ArrayDef nikonLd4Def[] = {
583+
{ 0, ttUndefined, 4 }, // Version
584+
{ 48, ttUnsignedShort, 1 }, // LensID
585+
{ 54, ttUnsignedShort, 1 }, // MacAperture
586+
{ 56, ttUnsignedShort, 1 }, // FNumber
587+
{ 60, ttUnsignedShort, 1 } // FocalLength
588+
};
570589
//! Nikon Lens Data configurations and definitions
571590
extern const ArraySet nikonLdSet[] = {
572591
{ nikonLd1Cfg, nikonLdDef, EXV_COUNTOF(nikonLdDef) },
573592
{ nikonLd2Cfg, nikonLdDef, EXV_COUNTOF(nikonLdDef) },
574-
{ nikonLd3Cfg, nikonLdDef, EXV_COUNTOF(nikonLdDef) }
593+
{ nikonLd3Cfg, nikonLdDef, EXV_COUNTOF(nikonLdDef) },
594+
{ nikonLd4Cfg, nikonLd4Def, EXV_COUNTOF(nikonLd4Def) }
575595
};
576596

577597
//! Nikon Color Balance binary array - configuration 1
@@ -1037,6 +1057,7 @@ namespace Exiv2 {
10371057
{ Tag::root, nikonLd1Id, nikon3Id, 0x0098 },
10381058
{ Tag::root, nikonLd2Id, nikon3Id, 0x0098 },
10391059
{ Tag::root, nikonLd3Id, nikon3Id, 0x0098 },
1060+
{ Tag::root, nikonLd4Id, nikon3Id, 0x0098 },
10401061
{ Tag::root, nikonMeId, nikon3Id, 0x00b0 },
10411062
{ Tag::root, nikonAf21Id, nikon3Id, 0x00b7 },
10421063
{ Tag::root, nikonAf22Id, nikon3Id, 0x00b7 },
@@ -1453,6 +1474,7 @@ namespace Exiv2 {
14531474
{ Tag::all, nikonLd1Id, newTiffBinaryElement },
14541475
{ Tag::all, nikonLd2Id, newTiffBinaryElement },
14551476
{ Tag::all, nikonLd3Id, newTiffBinaryElement },
1477+
{ Tag::all, nikonLd4Id, newTiffBinaryElement },
14561478

14571479
// Panasonic makernote
14581480
{ Tag::next, panasonicId, ignoreTiffComponent },

0 commit comments

Comments
 (0)