Skip to content

Commit ef598ad

Browse files
authored
Merge pull request #900 from Exiv2/fix646_NikonAF22
fix646_NikonAF22
2 parents 1eab4e0 + db3a260 commit ef598ad

File tree

10 files changed

+144
-30
lines changed

10 files changed

+144
-30
lines changed

src/makernote_int.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,15 @@ namespace Exiv2 {
11851185
return aix == 0 ? -1 : aix->idx_;
11861186
}
11871187

1188+
int nikonAf2Selector(uint16_t tag, const byte* /*pData*/, uint32_t size, TiffComponent* const /*pRoot*/)
1189+
{
1190+
int result = tag == 0x00b7 ? 0 : -1 ;
1191+
if (result > -1 && size == 84 ) {
1192+
result = 1;
1193+
}
1194+
return result;
1195+
}
1196+
11881197
DataBuf nikonCrypt(uint16_t tag, const byte* pData, uint32_t size, TiffComponent* const pRoot)
11891198
{
11901199
DataBuf buf;

src/makernote_int.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,17 @@ namespace Exiv2 {
741741
*/
742742
int nikonSelector(uint16_t tag, const byte* pData, uint32_t size, TiffComponent* const pRoot);
743743

744+
/*!
745+
@brief Function to select cfg + def of a Nikon complex binary array.
746+
747+
@param tag Tag number of the binary array
748+
@param pData Pointer to the raw array data.
749+
@param size Size of the array data.
750+
@param pRoot Pointer to the root component of the TIFF tree.
751+
@return An index into the array set, -1 if no match was found.
752+
*/
753+
int nikonAf2Selector(uint16_t tag, const byte* pData, uint32_t size, TiffComponent* const pRoot);
754+
744755
/*!
745756
@brief Encrypt and decrypt Nikon data.
746757

src/nikonmn_int.cpp

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -889,29 +889,54 @@ namespace Exiv2 {
889889
};
890890

891891
// Nikon3 Auto Focus Tag Info
892-
const TagInfo Nikon3MakerNote::tagInfoAf2_[] = {
893-
TagInfo( 0, "Version", N_("Version"), N_("Version"), nikonAf2Id, makerTags, undefined, 4, printExifVersion),
894-
TagInfo( 4, "ContrastDetectAF", N_("Contrast Detect AF"), N_("Contrast detect AF"), nikonAf2Id, makerTags, unsignedByte, 1, EXV_PRINT_TAG(nikonOffOn)),
895-
TagInfo( 5, "AFAreaMode", N_("AF Area Mode"), N_("AF area mode"), nikonAf2Id, makerTags, unsignedByte, 1, printValue),
896-
TagInfo( 6, "PhaseDetectAF", N_("Phase Detect AF"), N_("Phase detect AF"), nikonAf2Id, makerTags, unsignedByte, 1, EXV_PRINT_TAG(nikonPhaseDetectAF)),
897-
TagInfo( 7, "PrimaryAFPoint", N_("Primary AF Point"), N_("Primary AF point"), nikonAf2Id, makerTags, unsignedByte, 1, printValue),
898-
TagInfo( 8, "AFPointsUsed", N_("AF Points Used"), N_("AF points used"), nikonAf2Id, makerTags, unsignedByte, 7, printValue),
899-
TagInfo( 16, "AFImageWidth", N_("AF Image Width"), N_("AF image width"), nikonAf2Id, makerTags, unsignedShort, 1, printValue),
900-
TagInfo( 18, "AFImageHeight", N_("AF Image Height"), N_("AF image height"), nikonAf2Id, makerTags, unsignedShort, 1, printValue),
901-
TagInfo( 20, "AFAreaXPosition", N_("AF Area X Position"), N_("AF area x position"), nikonAf2Id, makerTags, unsignedShort, 1, printValue),
902-
TagInfo( 22, "AFAreaYPosition", N_("AF Area Y Position"), N_("AF area y position"), nikonAf2Id, makerTags, unsignedShort, 1, printValue),
903-
TagInfo( 24, "AFAreaWidth", N_("AF Area Width"), N_("AF area width"), nikonAf2Id, makerTags, unsignedShort, 1, printValue),
904-
TagInfo( 26, "AFAreaHeight", N_("AF Area Height"), N_("AF area height"), nikonAf2Id, makerTags, unsignedShort, 1, printValue),
905-
TagInfo( 28, "ContrastDetectAFInFocus", N_("Contrast Detect AF In Focus"), N_("Contrast detect AF in focus"), nikonAf2Id, makerTags, unsignedShort, 1, printValue),
892+
const TagInfo Nikon3MakerNote::tagInfoAf21_[] = {
893+
TagInfo( 0, "Version", N_("Version"), N_("Version"), nikonAf21Id, makerTags, undefined, 4, printExifVersion),
894+
TagInfo( 4, "ContrastDetectAF", N_("Contrast Detect AF"), N_("Contrast detect AF"), nikonAf21Id, makerTags, unsignedByte, 1, EXV_PRINT_TAG(nikonOffOn)),
895+
TagInfo( 5, "AFAreaMode", N_("AF Area Mode"), N_("AF area mode"), nikonAf21Id, makerTags, unsignedByte, 1, printValue),
896+
TagInfo( 6, "PhaseDetectAF", N_("Phase Detect AF"), N_("Phase detect AF"), nikonAf21Id, makerTags, unsignedByte, 1, EXV_PRINT_TAG(nikonPhaseDetectAF)),
897+
TagInfo( 7, "PrimaryAFPoint", N_("Primary AF Point"), N_("Primary AF point"), nikonAf21Id, makerTags, unsignedByte, 1, printValue),
898+
TagInfo( 8, "AFPointsUsed", N_("AF Points Used"), N_("AF points used"), nikonAf21Id, makerTags, unsignedByte, 7, printValue),
899+
TagInfo( 16, "AFImageWidth", N_("AF Image Width"), N_("AF image width"), nikonAf21Id, makerTags, unsignedShort, 1, printValue),
900+
TagInfo( 18, "AFImageHeight", N_("AF Image Height"), N_("AF image height"), nikonAf21Id, makerTags, unsignedShort, 1, printValue),
901+
TagInfo( 20, "AFAreaXPosition", N_("AF Area X Position"), N_("AF area x position"), nikonAf21Id, makerTags, unsignedShort, 1, printValue),
902+
TagInfo( 22, "AFAreaYPosition", N_("AF Area Y Position"), N_("AF area y position"), nikonAf21Id, makerTags, unsignedShort, 1, printValue),
903+
TagInfo( 24, "AFAreaWidth", N_("AF Area Width"), N_("AF area width"), nikonAf21Id, makerTags, unsignedShort, 1, printValue),
904+
TagInfo( 26, "AFAreaHeight", N_("AF Area Height"), N_("AF area height"), nikonAf21Id, makerTags, unsignedShort, 1, printValue),
905+
TagInfo( 28, "ContrastDetectAFInFocus", N_("Contrast Detect AF In Focus"), N_("Contrast detect AF in focus"), nikonAf21Id, makerTags, unsignedShort, 1, printValue),
906906
// End of list marker
907-
TagInfo(0xffff, "(UnknownNikonAf2Tag)", "(UnknownNikonAf2Tag)", N_("Unknown Nikon Auto Focus 2 Tag"), nikonAf2Id, makerTags, unsignedByte, 1, printValue)
907+
TagInfo(0xffff, "(UnknownNikonAf2Tag)", "(UnknownNikonAf2Tag)", N_("Unknown Nikon Auto Focus 2 Tag"), nikonAf21Id, makerTags, unsignedByte, 1, printValue)
908908
};
909909

910-
const TagInfo* Nikon3MakerNote::tagListAf2()
910+
const TagInfo* Nikon3MakerNote::tagListAf21()
911911
{
912-
return tagInfoAf2_;
912+
return tagInfoAf21_;
913913
}
914914

915+
// Nikon3 Auto Focus Tag Info Version 1.01 https://github.com/Exiv2/exiv2/pull/900
916+
const TagInfo Nikon3MakerNote::tagInfoAf22_[] = {
917+
TagInfo( 0, "Version", N_("Version"), N_("Version"), nikonAf22Id, makerTags, undefined, 4, printExifVersion),
918+
TagInfo( 4, "ContrastDetectAF", N_("Contrast Detect AF"), N_("Contrast detect AF"), nikonAf22Id, makerTags, unsignedByte, 1, EXV_PRINT_TAG(nikonOffOn)),
919+
TagInfo( 5, "AFAreaMode", N_("AF Area Mode"), N_("AF area mode"), nikonAf22Id, makerTags, unsignedByte, 1, printValue),
920+
TagInfo( 6, "PhaseDetectAF", N_("Phase Detect AF"), N_("Phase detect AF"), nikonAf22Id, makerTags, unsignedByte, 1, EXV_PRINT_TAG(nikonPhaseDetectAF)),
921+
TagInfo( 7, "PrimaryAFPoint", N_("Primary AF Point"), N_("Primary AF point"), nikonAf22Id, makerTags, unsignedByte, 1, printValue),
922+
TagInfo( 8, "AFPointsUsed", N_("AF Points Used"), N_("AF points used"), nikonAf22Id, makerTags, unsignedByte, 7, printValue),
923+
TagInfo( 70, "AFImageWidth", N_("AF Image Width"), N_("AF image width"), nikonAf22Id, makerTags, unsignedShort, 1, printValue),
924+
TagInfo( 72, "AFImageHeight", N_("AF Image Height"), N_("AF image height"), nikonAf22Id, makerTags, unsignedShort, 1, printValue),
925+
TagInfo( 74, "AFAreaXPosition", N_("AF Area X Position"), N_("AF area x position"), nikonAf22Id, makerTags, unsignedShort, 1, printValue),
926+
TagInfo( 76, "AFAreaYPosition", N_("AF Area Y Position"), N_("AF area y position"), nikonAf22Id, makerTags, unsignedShort, 1, printValue),
927+
TagInfo( 78, "AFAreaWidth", N_("AF Area Width"), N_("AF area width"), nikonAf22Id, makerTags, unsignedShort, 1, printValue),
928+
TagInfo( 80, "AFAreaHeight", N_("AF Area Height"), N_("AF area height"), nikonAf22Id, makerTags, unsignedShort, 1, printValue),
929+
TagInfo( 82, "ContrastDetectAFInFocus", N_("Contrast Detect AF In Focus"), N_("Contrast detect AF in focus"), nikonAf22Id, makerTags, unsignedShort, 1, printValue),
930+
// End of list marker
931+
TagInfo(0xffff, "(UnknownNikonAf2Tag)", "(UnknownNikonAf2Tag)", N_("Unknown Nikon Auto Focus 2 Tag"), nikonAf22Id, makerTags, unsignedByte, 1, printValue)
932+
};
933+
934+
const TagInfo* Nikon3MakerNote::tagListAf22()
935+
{
936+
return tagInfoAf22_;
937+
}
938+
939+
915940
// Nikon3 File Info Tag Info
916941
const TagInfo Nikon3MakerNote::tagInfoFi_[] = {
917942
TagInfo( 0, "Version", N_("Version"), N_("Version"), nikonFiId, makerTags, undefined, 4, printExifVersion),

src/nikonmn_int.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ namespace Exiv2 {
124124
//! Return read-only list of built-in Auto Focus tags
125125
static const TagInfo* tagListAf();
126126
//! Return read-only list of built-in Auto Focus 2 tags
127-
static const TagInfo* tagListAf2();
127+
static const TagInfo* tagListAf21();
128+
//! Return read-only list of built-in Auto Focus 2 tags
129+
static const TagInfo* tagListAf22();
128130
//! Return read-only list of built-in AF Fine Tune tags
129131
static const TagInfo* tagListAFT();
130132
//! Return read-only list of built-in File Info tags
@@ -235,7 +237,9 @@ namespace Exiv2 {
235237
//! Auto Focus tag information
236238
static const TagInfo tagInfoAf_[];
237239
//! Auto Focus tag 2 information
238-
static const TagInfo tagInfoAf2_[];
240+
static const TagInfo tagInfoAf21_[];
241+
//! Auto Focus tag 2 information
242+
static const TagInfo tagInfoAf22_[];
239243
//! AF Fine Tune tag information
240244
static const TagInfo tagInfoAFT_[];
241245
//! File Info tag information

src/tags_int.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ namespace Exiv2 {
106106
{ nikonWtId, "Makernote", "NikonWt", Nikon3MakerNote::tagListWt },
107107
{ nikonIiId, "Makernote", "NikonIi", Nikon3MakerNote::tagListIi },
108108
{ nikonAfId, "Makernote", "NikonAf", Nikon3MakerNote::tagListAf },
109-
{ nikonAf2Id, "Makernote", "NikonAf2", Nikon3MakerNote::tagListAf2 },
109+
{ nikonAf21Id, "Makernote", "NikonAf2", Nikon3MakerNote::tagListAf21 },
110+
{ nikonAf22Id, "Makernote", "NikonAf22", Nikon3MakerNote::tagListAf22 },
110111
{ nikonAFTId, "Makernote", "NikonAFT", Nikon3MakerNote::tagListAFT },
111112
{ nikonFiId, "Makernote", "NikonFi", Nikon3MakerNote::tagListFi },
112113
{ nikonMeId, "Makernote", "NikonMe", Nikon3MakerNote::tagListMe },

src/tags_int.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ namespace Exiv2 {
9999
nikonWtId,
100100
nikonIiId,
101101
nikonAfId,
102-
nikonAf2Id,
102+
nikonAf21Id,
103+
nikonAf22Id,
103104
nikonAFTId,
104105
nikonFiId,
105106
nikonMeId,

src/tiffimage_int.cpp

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ namespace Exiv2 {
221221
{ 2, ttUnsignedShort, 1 } // The array contains 4 bytes
222222
};
223223

224-
//! Nikon Auto Focus 2 binary array - configuration
225-
extern const ArrayCfg nikonAf2Cfg = {
226-
nikonAf2Id, // Group for the elements
224+
//! Nikon Auto Focus 21 binary array - configuration
225+
extern const ArrayCfg nikonAf21Cfg = {
226+
nikonAf21Id, // Group for the elements
227227
invalidByteOrder, // Use byte order from parent
228228
ttUndefined, // Type for array entry
229229
notEncrypted, // Not encrypted
@@ -232,8 +232,8 @@ namespace Exiv2 {
232232
true, // Concatenate gaps
233233
{ 0, ttUnsignedByte, 1 }
234234
};
235-
//! Nikon Auto Focus 2 binary array - definition
236-
extern const ArrayDef nikonAf2Def[] = {
235+
//! Nikon Auto Focus 21 binary array - definition
236+
extern const ArrayDef nikonAf21Def[] = {
237237
{ 0, ttUndefined, 4 }, // Version
238238
{ 4, ttUnsignedByte, 1 }, // ContrastDetectAF
239239
{ 5, ttUnsignedByte, 1 }, // AFAreaMode
@@ -248,6 +248,39 @@ namespace Exiv2 {
248248
{ 26, ttUnsignedShort, 1 }, // AFAreaHeight
249249
{ 28, ttUnsignedShort, 1 }, // ContrastDetectAFInFocus
250250
};
251+
//! Nikon Auto Focus 22 binary array - configuration
252+
extern const ArrayCfg nikonAf22Cfg = {
253+
nikonAf22Id, // Group for the elements
254+
invalidByteOrder, // Byte order
255+
ttUndefined, // Type for array entry
256+
notEncrypted, // Not encrypted
257+
false, // No size element
258+
true, // Write all tags
259+
true, // Concatenate gaps
260+
{ 0, ttUnsignedByte, 1 }
261+
};
262+
//! Nikon Auto Focus 22 binary array - definition
263+
extern const ArrayDef nikonAf22Def[] = {
264+
{ 0, ttUndefined, 4 }, // Version
265+
{ 4, ttUnsignedByte, 1 }, // ContrastDetectAF
266+
{ 5, ttUnsignedByte, 1 }, // AFAreaMode
267+
{ 6, ttUnsignedByte, 1 }, // PhaseDetectAF
268+
{ 7, ttUnsignedByte, 1 }, // PrimaryAFPoint
269+
{ 8, ttUnsignedByte, 7 }, // AFPointsUsed
270+
{ 70, ttUnsignedShort, 1 }, // AFImageWidth
271+
{ 72, ttUnsignedShort, 1 }, // AFImageHeight
272+
{ 74, ttUnsignedShort, 1 }, // AFAreaXPosition
273+
{ 76, ttUnsignedShort, 1 }, // AFAreaYPosition
274+
{ 78, ttUnsignedShort, 1 }, // AFAreaWidth
275+
{ 80, ttUnsignedShort, 1 }, // AFAreaHeight
276+
};
277+
278+
//! Nikon AF2 configuration and definitions
279+
// https://github.com/Exiv2/exiv2/issues/646
280+
extern const ArraySet nikonAf2Set[] = {
281+
{ nikonAf21Cfg, nikonAf21Def, EXV_COUNTOF(nikonAf21Def) },
282+
{ nikonAf22Cfg, nikonAf22Def, EXV_COUNTOF(nikonAf22Def) },
283+
};
251284

252285
//! Nikon AF Fine Tune binary array - configuration
253286
extern const ArrayCfg nikonAFTCfg = {
@@ -932,7 +965,8 @@ namespace Exiv2 {
932965
{ Tag::root, nikonLd2Id, nikon3Id, 0x0098 },
933966
{ Tag::root, nikonLd3Id, nikon3Id, 0x0098 },
934967
{ Tag::root, nikonMeId, nikon3Id, 0x00b0 },
935-
{ Tag::root, nikonAf2Id, nikon3Id, 0x00b7 },
968+
{ Tag::root, nikonAf21Id, nikon3Id, 0x00b7 },
969+
{ Tag::root, nikonAf22Id, nikon3Id, 0x00b7 },
936970
{ Tag::root, nikonFiId, nikon3Id, 0x00b8 },
937971
{ Tag::root, nikonAFTId, nikon3Id, 0x00b9 },
938972
{ Tag::root, nikonFl1Id, nikon3Id, 0x00a8 },
@@ -1274,7 +1308,7 @@ namespace Exiv2 {
12741308
{ 0x0098, nikon3Id, EXV_COMPLEX_BINARY_ARRAY(nikonLdSet, nikonSelector) },
12751309
{ 0x00a8, nikon3Id, EXV_COMPLEX_BINARY_ARRAY(nikonFlSet, nikonSelector) },
12761310
{ 0x00b0, nikon3Id, EXV_BINARY_ARRAY(nikonMeCfg, nikonMeDef) },
1277-
{ 0x00b7, nikon3Id, EXV_BINARY_ARRAY(nikonAf2Cfg, nikonAf2Def)},
1311+
{ 0x00b7, nikon3Id, EXV_COMPLEX_BINARY_ARRAY(nikonAf2Set, nikonAf2Selector) },
12781312
{ 0x00b8, nikon3Id, EXV_BINARY_ARRAY(nikonFiCfg, nikonFiDef) },
12791313
{ 0x00b9, nikon3Id, EXV_BINARY_ARRAY(nikonAFTCfg, nikonAFTDef) },
12801314
{ Tag::all, nikon3Id, newTiffEntry },
@@ -1301,7 +1335,8 @@ namespace Exiv2 {
13011335
{ Tag::all, nikonAfId, newTiffBinaryElement },
13021336

13031337
// Nikon3 auto focus 2
1304-
{ Tag::all, nikonAf2Id, newTiffBinaryElement },
1338+
{ Tag::all, nikonAf21Id, newTiffBinaryElement },
1339+
{ Tag::all, nikonAf22Id, newTiffBinaryElement },
13051340

13061341
// Nikon3 AF Fine Tune
13071342
{ Tag::all, nikonAFTId, newTiffBinaryElement },

src/tiffvisitor_int.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,6 @@ namespace Exiv2 {
15821582
postList_.push_back(object);
15831583
return;
15841584
}
1585-
15861585
// Check duplicates
15871586
TiffFinder finder(object->tag(), object->group());
15881587
pRoot_->accept(finder);

test/data/_DSC8437.exv

11.1 KB
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from system_tests import CaseMeta, path
4+
5+
class Fix646_NikonAF22(metaclass=CaseMeta):
6+
7+
url = "http://dev.exiv2.org/issues/646"
8+
filename = "$data_path/_DSC8437.exv"
9+
commands = [
10+
"$exiv2 -pa --grep NikonAf $filename"
11+
]
12+
stdout = [
13+
"""Exif.NikonAf22.Version Undefined 4 1.01
14+
Exif.NikonAf22.ContrastDetectAF Byte 1 On
15+
Exif.NikonAf22.AFAreaMode Byte 1 1
16+
Exif.NikonAf22.PhaseDetectAF Byte 1 Off
17+
Exif.NikonAf22.PrimaryAFPoint Byte 1 0
18+
Exif.NikonAf22.AFPointsUsed Byte 7 0 0 0 0 0 0 0
19+
Exif.NikonAf22.AFImageWidth Short 1 8256
20+
Exif.NikonAf22.AFImageHeight Short 1 5504
21+
Exif.NikonAf22.AFAreaXPosition Short 1 3950
22+
Exif.NikonAf22.AFAreaYPosition Short 1 2871
23+
Exif.NikonAf22.AFAreaWidth Short 1 435
24+
Exif.NikonAf22.AFAreaHeight Short 1 360
25+
Exif.NikonAf22.ContrastDetectAFInFocus Byte 2 1 0
26+
"""
27+
]
28+
stderr = [ "" ] * len(commands)
29+
retval = [ 0 ] * len(commands)

0 commit comments

Comments
 (0)