Skip to content

Commit 83d7915

Browse files
Update Exif.SonyMisc3c.* and Exif.Sony(1|2).SonyModelID (#2420)
* Update `Exif.SonyMisc3c group` * Update `Exif.Sony(1|2).SonyModelID`
1 parent 026cee3 commit 83d7915

File tree

2 files changed

+55
-63
lines changed

2 files changed

+55
-63
lines changed

src/makernote_int.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,8 @@ int sonyMisc2bSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/,
993993
return -1;
994994
}
995995
int sonyMisc3cSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* pRoot) {
996-
// From Exiftool (Tag 9400c): https://github.com/exiftool/exiftool/blob/master/lib/Image/ExifTool/Sony.pm
997-
// > first byte decoded: 62, 48, 215, 28, 106 respectively
996+
// For condition, see Exiftool (Tag 9400c):
997+
// https://github.com/exiftool/exiftool/blob/7368629751669ba170511419b3d1e05bf0076d0e/lib/Image/ExifTool/Sony.pm#L1681
998998

999999
// Get the value from the image format that is being used
10001000
auto value = getExifValue(pRoot, 0x9400, Exiv2::IfdId::sony1Id);
@@ -1007,12 +1007,13 @@ int sonyMisc3cSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/,
10071007
if (value->count() < 1)
10081008
return -1;
10091009

1010-
switch (value->toInt64()) { // Using encrypted values
1011-
case 35: // 35 == 62
1012-
case 36: // 36 == 48
1013-
case 38: // 38 == 215
1014-
case 40: // 40 == 28
1015-
case 49: // 112 == 106
1010+
switch (value->toInt64()) {
1011+
case 35:
1012+
case 36:
1013+
case 38:
1014+
case 40:
1015+
case 49:
1016+
case 50:
10161017
return 0;
10171018
default:
10181019
break;

src/sonymn_int.cpp

Lines changed: 46 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ constexpr TagDetails sonyModelId[] = {{0, N_("Multiple camera models")},
430430
{387, "ILCE-7RM4A"},
431431
{388, "ILCE-7M4"},
432432
{389, "ZV-1F"},
433+
{390, "ILCE-7RM5"},
433434
{391, "ILME-FX30"}};
434435

435436
//! Lookup table to translate Sony creative style (main group) values to readable labels
@@ -2020,6 +2021,13 @@ constexpr TagDetails sonyMisc3cSequenceLength2[] = {{0, N_("Continuous")}, {1, N
20202021
constexpr TagDetails sonyMisc3cCameraOrientation[] = {
20212022
{1, N_("Horizontal (normal)")}, {3, N_("Rotate 180°")}, {6, N_("Rotate 90° CW")}, {8, N_("Rotate 270° CW")}};
20222023

2024+
//! Lookup table to translate SonyMisc3c Quality2 (a) values to readable labels
2025+
constexpr TagDetails sonyMisc3cQuality2a[] = {
2026+
{1, "JPEG"}, {2, "Raw"}, {3, "Raw + JPEG"}, {4, "HEIF"}, {6, "Raw + HEIF"}};
2027+
2028+
//! Lookup table to translate SonyMisc3c Quality2 (b) values to readable labels
2029+
constexpr TagDetails sonyMisc3cQuality2b[] = {{0, "JPEG"}, {1, "Raw"}, {2, "Raw + JPEG"}, {3, "Raw + MPO"}};
2030+
20232031
//! SonyMisc3c tags (Tag 9400c)
20242032
constexpr TagInfo SonyMakerNote::tagInfoSonyMisc3c_[] = {
20252033
{9, "ReleaseMode2", N_("Release mode 2"), N_("Release mode 2"), IfdId::sonyMisc3cId, SectionId::makerTags,
@@ -2029,12 +2037,12 @@ constexpr TagInfo SonyMakerNote::tagInfoSonyMisc3c_[] = {
20292037
unsignedLong, -1, printSonyMisc3cShotNumberSincePowerUp},
20302038
{18, "SequenceImageNumber", N_("Sequence image number"), N_("Number of images captured in burst sequence"),
20312039
IfdId::sonyMisc3cId, SectionId::makerTags, unsignedLong, -1, printSonyMisc3cSequenceNumber},
2032-
// In Exiftool, "SequenceLength1" is called "SequenceLength. Renamed due to clash of names."
2040+
// In Exiftool, "SequenceLength1" is called "SequenceLength (22). Renamed due to clash of names."
20332041
{22, "SequenceLength1", N_("Sequence length 1"), N_("Length of the sequence of photos taken"), IfdId::sonyMisc3cId,
20342042
SectionId::makerTags, unsignedByte, -1, EXV_PRINT_TAG(sonyMisc3cSequenceLength1)},
20352043
{26, "SequenceFileNumber", N_("Sequence file number"), N_("File number in burst sequence"), IfdId::sonyMisc3cId,
20362044
SectionId::makerTags, unsignedLong, -1, printSonyMisc3cSequenceNumber},
2037-
// In Exiftool, "SequenceLength2" is called "SequenceLength". Renamed due to clash of names."
2045+
// In Exiftool, "SequenceLength2" is called "SequenceLength" (30). Renamed due to clash of names."
20382046
{30, "SequenceLength2", N_("Sequence length 2"), N_("Length of the sequence of photos taken"), IfdId::sonyMisc3cId,
20392047
SectionId::makerTags, unsignedByte, -1, EXV_PRINT_TAG(sonyMisc3cSequenceLength2)},
20402048
{41, "CameraOrientation", N_("Camera orientation"), N_("Orientation of the camera when the photo was taken"),
@@ -2056,7 +2064,7 @@ const TagInfo* SonyMakerNote::tagListSonyMisc3c() {
20562064

20572065
std::ostream& SonyMakerNote::printSonyMisc3cShotNumberSincePowerUp(std::ostream& os, const Value& value,
20582066
const ExifData* metadata) {
2059-
if (value.count() != 1)
2067+
if (value.count() != 1 || value.typeId() != unsignedLong)
20602068
return os << "(" << value << ")";
20612069

20622070
std::string model;
@@ -2065,27 +2073,29 @@ std::ostream& SonyMakerNote::printSonyMisc3cShotNumberSincePowerUp(std::ostream&
20652073
return os;
20662074
}
20672075

2068-
// Models that support this tag
2076+
// Tag only valid for certain camera models. See
2077+
// https://github.com/exiftool/exiftool/blob/7368629751669ba170511419b3d1e05bf0076d0e/lib/Image/ExifTool/Sony.pm#L8170
20692078
static constexpr auto models = std::array{
2070-
"ILCA-68", "ILCA-77M2", "ILCA-99M2", "ILCE-5000", "ILCE-5100", "ILCE-6000", "ILCE-6300",
2071-
"ILCE-6500", "ILCE-7", "ILCE-7M2", "ILCE-7R", "ILCE-7RM2", "ILCE-7S", "ILCE-7SM2",
2072-
"ILCE-QX1", "DSC-HX350", "DSC-HX400V", "DSC-HX60V", "DSC-HX80", "DSC-HX90", "DSC-HX90V",
2073-
"DSC-QX30", "DSC-RX0", "DSC-RX1RM2", "DSC-RX10", "DSC-RX10M2", "DSC-RX10M3", "DSC-RX100M3",
2074-
"DSC-RX100M4", "DSC-RX100M5", "DSC-WX220", "DSC-WX350", "DSC-WX500",
2079+
"ILCA-68", "ILCA-77M2", "ILCA-99M2", "ILCE-5000", "ILCE-5100", "ILCE-6000", "ILCE-6300",
2080+
"ILCE-6500", "ILCE-7", "ILCE-7M2", "ILCE-7R", "ILCE-7RM2", "ILCE-7S", "ILCE-7SM2",
2081+
"ILCE-7SM5", "ILCE-QX1", "DSC-HX350", "DSC-HX400V", "DSC-HX60V", "DSC-HX80", "DSC-HX90",
2082+
"DSC-HX90V", "DSC-QX30", "DSC-RX0", "DSC-RX1RM2", "DSC-RX10", "DSC-RX10M2", "DSC-RX10M3",
2083+
"DSC-RX100M3", "DSC-RX100M4", "DSC-RX100M5", "DSC-WX220", "DSC-WX350", "DSC-WX500",
20752084
};
20762085

2077-
bool f = std::find(models.begin(), models.end(), model) != models.end();
2078-
if (f)
2086+
if (std::any_of(models.begin(), models.end(), [&model](auto& m) { return (model == m); })) {
20792087
return os << value.toInt64();
2088+
}
20802089
return os << N_("n/a");
20812090
}
20822091

20832092
std::ostream& SonyMakerNote::printSonyMisc3cSequenceNumber(std::ostream& os, const Value& value, const ExifData*) {
2084-
return (value.count() != 1) ? os << "(" << value << ")" : os << (value.toInt64() + 1);
2093+
return (value.count() != 1 || value.typeId() != unsignedLong) ? os << "(" << value << ")"
2094+
: os << (value.toInt64() + 1);
20852095
}
20862096

20872097
std::ostream& SonyMakerNote::printSonyMisc3cQuality2(std::ostream& os, const Value& value, const ExifData* metadata) {
2088-
if (value.count() != 1)
2098+
if (value.count() != 1 || value.typeId() != unsignedByte)
20892099
return os << "(" << value << ")";
20902100

20912101
std::string model;
@@ -2096,44 +2106,21 @@ std::ostream& SonyMakerNote::printSonyMisc3cQuality2(std::ostream& os, const Val
20962106

20972107
const auto val = value.toInt64();
20982108

2099-
// Value is interpreted differently if model is in list or not
2100-
for (auto& m : {"ILCE-1", "ILCE-7SM3", "ILME-FX3"}) {
2101-
if (m == model) {
2102-
switch (val) {
2103-
case 1:
2104-
return os << N_("JPEG");
2105-
case 2:
2106-
return os << N_("Raw");
2107-
case 3:
2108-
return os << N_("Raw + JPEG");
2109-
case 4:
2110-
return os << N_("HEIF");
2111-
case 6:
2112-
return os << N_("Raw + HEIF");
2113-
default:
2114-
return os << "(" << val << ")";
2115-
}
2116-
}
2117-
}
2109+
// Tag only valid for certain camera models. See
2110+
// https://github.com/exiftool/exiftool/blob/7368629751669ba170511419b3d1e05bf0076d0e/lib/Image/ExifTool/Sony.pm#L8219
2111+
constexpr std::array models{"ILCE-1", "ILCE-7M4", "ILCE-7RM5", "ILCE-7SM3", "ILME-FX3"};
21182112

2119-
switch (val) {
2120-
case 0:
2121-
return os << N_("JPEG");
2122-
case 1:
2123-
return os << N_("Raw");
2124-
case 2:
2125-
return os << N_("Raw + JPEG");
2126-
case 3:
2127-
return os << N_("Raw + MPO");
2128-
default:
2129-
os << "(" << val << ")";
2113+
if (std::any_of(models.begin(), models.end(), [&model](auto& m) { return (model == m); })) {
2114+
EXV_PRINT_TAG(sonyMisc3cQuality2a)(os, val, metadata);
2115+
return os;
21302116
}
2131-
return os;
2117+
2118+
return EXV_PRINT_TAG(sonyMisc3cQuality2b)(os, val, metadata);
21322119
}
21332120

21342121
std::ostream& SonyMakerNote::printSonyMisc3cSonyImageHeight(std::ostream& os, const Value& value,
21352122
const ExifData* metadata) {
2136-
if (value.count() != 1)
2123+
if (value.count() != 1 || value.typeId() != unsignedShort)
21372124
return os << "(" << value << ")";
21382125

21392126
std::string model;
@@ -2142,19 +2129,21 @@ std::ostream& SonyMakerNote::printSonyMisc3cSonyImageHeight(std::ostream& os, co
21422129
return os;
21432130
}
21442131

2145-
// Models that do not support this tag
2146-
const auto models = std::array{"ILCE-1", "ILCE-7SM3", "ILME-FX3"};
2147-
bool f = std::find(models.begin(), models.end(), model) != models.end();
2148-
if (f)
2149-
return os << N_("n/a");
2132+
// Tag only valid for certain camera models. See
2133+
// https://github.com/exiftool/exiftool/blob/7368629751669ba170511419b3d1e05bf0076d0e/lib/Image/ExifTool/Sony.pm#L8239
2134+
constexpr std::array models{"ILCE-1", "ILCE-7M4", "ILCE-7RM5", "ILCE-7SM3", "ILME-FX3"};
21502135

2136+
if (std::any_of(models.begin(), models.end(), [&model](auto& m) { return (model == m); })) {
2137+
return os << N_("n/a");
2138+
}
21512139
const auto val = value.toInt64();
2140+
21522141
return val > 0 ? os << (8 * val) : os << N_("n/a");
21532142
}
21542143

21552144
std::ostream& SonyMakerNote::printSonyMisc3cModelReleaseYear(std::ostream& os, const Value& value,
21562145
const ExifData* metadata) {
2157-
if (value.count() != 1)
2146+
if (value.count() != 1 || value.typeId() != unsignedByte)
21582147
return os << "(" << value << ")";
21592148

21602149
std::string model;
@@ -2163,11 +2152,13 @@ std::ostream& SonyMakerNote::printSonyMisc3cModelReleaseYear(std::ostream& os, c
21632152
return os;
21642153
}
21652154

2166-
// Models that do not support this tag
2167-
const auto models = std::array{"ILCE-1", "ILCE-7SM3", "ILME-FX3"};
2168-
bool f = std::find(models.begin(), models.end(), model) != models.end();
2169-
if (f)
2155+
// Tag only valid for certain camera models. See
2156+
// https://github.com/exiftool/exiftool/blob/7368629751669ba170511419b3d1e05bf0076d0e/lib/Image/ExifTool/Sony.pm#L8245
2157+
constexpr std::array models{"ILCE-1", "ILCE-7M4", "ILCE-7RM5", "ILCE-7SM3", "ILME-FX3"};
2158+
2159+
if (std::any_of(models.begin(), models.end(), [&model](auto& m) { return (model == m); })) {
21702160
return os << N_("n/a");
2161+
}
21712162

21722163
const auto val = value.toInt64();
21732164
if (val > 99)

0 commit comments

Comments
 (0)