std::array conversions

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 3 years ago
parent 4fa8827844
commit 9cb1fcef5c

@ -912,7 +912,7 @@ int sony2010eSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/,
"NEX-6", "VG30E", "VG900", "DSC-RX100", "DSC-RX1", "DSC-RX1R", "DSC-HX300", "NEX-6", "VG30E", "VG900", "DSC-RX100", "DSC-RX1", "DSC-RX1R", "DSC-HX300",
"DSC-HX50V", "DSC-TX30", "DSC-WX60", "DSC-WX200", "DSC-WX300", "DSC-HX50V", "DSC-TX30", "DSC-WX60", "DSC-WX200", "DSC-WX300",
}; };
return std::find(models.begin(), models.end(), getExifModel(pRoot)) != std::end(models) ? 0 : -1; return std::find(models.begin(), models.end(), getExifModel(pRoot)) != models.end() ? 0 : -1;
} }
int sony2FpSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* const pRoot) { int sony2FpSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* const pRoot) {

@ -3242,32 +3242,30 @@ std::ostream& Nikon3MakerNote::printLensId4ZMount(std::ostream& os, const Value&
} }
// from https://github.com/exiftool/exiftool/blob/12.12/lib/Image/ExifTool/Nikon.pm#L4646 // from https://github.com/exiftool/exiftool/blob/12.12/lib/Image/ExifTool/Nikon.pm#L4646
static const struct ZMntLens { using ZMntLens = std::tuple<uint16_t, const char*, const char*>;
uint16_t lid; static constexpr auto zmountlens = std::array{
const char *manuf, *lensname; ZMntLens(1, "Nikon", "Nikkor Z 24-70mm f/4 S"),
} zmountlens[] = { ZMntLens(2, "Nikon", "Nikkor Z 14-30mm f/4 S"),
{1, "Nikon", "Nikkor Z 24-70mm f/4 S"}, ZMntLens(4, "Nikon", "Nikkor Z 35mm f/1.8 S"),
{2, "Nikon", "Nikkor Z 14-30mm f/4 S"}, ZMntLens(8, "Nikon", "Nikkor Z 58mm f/0.95 S Noct"), // IB
{4, "Nikon", "Nikkor Z 35mm f/1.8 S"}, ZMntLens(9, "Nikon", "Nikkor Z 50mm f/1.8 S"),
{8, "Nikon", "Nikkor Z 58mm f/0.95 S Noct"}, // IB ZMntLens(11, "Nikon", "Nikkor Z DX 16-50mm f/3.5-6.3 VR"),
{9, "Nikon", "Nikkor Z 50mm f/1.8 S"}, ZMntLens(12, "Nikon", "Nikkor Z DX 50-250mm f/4.5-6.3 VR"),
{11, "Nikon", "Nikkor Z DX 16-50mm f/3.5-6.3 VR"}, ZMntLens(13, "Nikon", "Nikkor Z 24-70mm f/2.8 S"),
{12, "Nikon", "Nikkor Z DX 50-250mm f/4.5-6.3 VR"}, ZMntLens(14, "Nikon", "Nikkor Z 85mm f/1.8 S"),
{13, "Nikon", "Nikkor Z 24-70mm f/2.8 S"}, ZMntLens(15, "Nikon", "Nikkor Z 24mm f/1.8 S"), // IB
{14, "Nikon", "Nikkor Z 85mm f/1.8 S"}, ZMntLens(16, "Nikon", "Nikkor Z 70-200mm f/2.8 VR S"), // IB
{15, "Nikon", "Nikkor Z 24mm f/1.8 S"}, // IB ZMntLens(17, "Nikon", "Nikkor Z 20mm f/1.8 S"), // IB
{16, "Nikon", "Nikkor Z 70-200mm f/2.8 VR S"}, // IB ZMntLens(18, "Nikon", "Nikkor Z 24-200mm f/4-6.3 VR"), // IB
{17, "Nikon", "Nikkor Z 20mm f/1.8 S"}, // IB ZMntLens(21, "Nikon", "Nikkor Z 50mm f/1.2 S"), // IB
{18, "Nikon", "Nikkor Z 24-200mm f/4-6.3 VR"}, // IB ZMntLens(22, "Nikon", "Nikkor Z 24-50mm f/4-6.3"), // IB
{21, "Nikon", "Nikkor Z 50mm f/1.2 S"}, // IB ZMntLens(23, "Nikon", "Nikkor Z 14-24mm f/2.8 S"), // IB
{22, "Nikon", "Nikkor Z 24-50mm f/4-6.3"}, // IB
{23, "Nikon", "Nikkor Z 14-24mm f/2.8 S"}, // IB
}; };
auto lid = static_cast<uint16_t>(value.toInt64()); auto lid = static_cast<uint16_t>(value.toInt64());
auto it = std::find_if(std::begin(zmountlens), std::end(zmountlens), [=](const ZMntLens& z) { return z.lid == lid; }); for (auto&& [l, manuf, lensname] : zmountlens)
if (it != std::end(zmountlens)) if (l == lid)
return os << it->manuf << " " << it->lensname; return os << manuf << " " << lensname;
return os << lid; return os << lid;
} }

@ -372,46 +372,43 @@ void TiffDecoder::decodeCanonAFInfo(const TiffEntryBase* object) {
const uint16_t nMasks = (nPoints + 15) / (sizeof(uint16_t) * 8); const uint16_t nMasks = (nPoints + 15) / (sizeof(uint16_t) * 8);
int nStart = 0; int nStart = 0;
static const struct { using record = std::tuple<uint16_t, uint16_t, bool>;
uint16_t tag; static const auto records = std::array{
uint16_t size; record(0x2600, 1, true), // AFInfoSize
bool bSigned; record(0x2601, 1, true), // AFAreaMode
} records[] = { record(0x2602, 1, true), // AFNumPoints
{0x2600, 1, true}, // AFInfoSize record(0x2603, 1, true), // AFValidPoints
{0x2601, 1, true}, // AFAreaMode record(0x2604, 1, true), // AFCanonImageWidth
{0x2602, 1, true}, // AFNumPoints record(0x2605, 1, true), // AFCanonImageHeight
{0x2603, 1, true}, // AFValidPoints record(0x2606, 1, true), // AFImageWidth"
{0x2604, 1, true}, // AFCanonImageWidth record(0x2607, 1, true), // AFImageHeight
{0x2605, 1, true}, // AFCanonImageHeight record(0x2608, nPoints, true), // AFAreaWidths
{0x2606, 1, true}, // AFImageWidth" record(0x2609, nPoints, true), // AFAreaHeights
{0x2607, 1, true}, // AFImageHeight record(0x260a, nPoints, true), // AFXPositions
{0x2608, nPoints, true}, // AFAreaWidths record(0x260b, nPoints, true), // AFYPositions
{0x2609, nPoints, true}, // AFAreaHeights record(0x260c, nMasks, false), // AFPointsInFocus
{0x260a, nPoints, true}, // AFXPositions record(0x260d, nMasks, false), // AFPointsSelected
{0x260b, nPoints, true}, // AFYPositions record(0x260e, nMasks, false), // AFPointsUnusable
{0x260c, nMasks, false}, // AFPointsInFocus
{0x260d, nMasks, false}, // AFPointsSelected
{0x260e, nMasks, false}, // AFPointsUnusable
}; };
// check we have enough data! // check we have enough data!
uint16_t count = 0; uint16_t count = 0;
for (auto&& record : records) { for (auto&& [tag, size, bSigned] : records) {
count += record.size; count += size;
if (count > ints.size()) if (count > ints.size())
return; return;
} }
for (auto&& record : records) { for (auto&& [tag, size, bSigned] : records) {
const TagInfo* pTags = ExifTags::tagList("Canon"); const TagInfo* pTags = ExifTags::tagList("Canon");
const TagInfo* pTag = findTag(pTags, record.tag); const TagInfo* pTag = findTag(pTags, tag);
if (pTag) { if (pTag) {
auto v = Exiv2::Value::create(record.bSigned ? Exiv2::signedShort : Exiv2::unsignedShort); auto v = Exiv2::Value::create(bSigned ? Exiv2::signedShort : Exiv2::unsignedShort);
std::ostringstream s; std::ostringstream s;
if (record.bSigned) { if (bSigned) {
for (uint16_t k = 0; k < record.size; k++) for (uint16_t k = 0; k < size; k++)
s << " " << ints.at(nStart++); s << " " << ints.at(nStart++);
} else { } else {
for (uint16_t k = 0; k < record.size; k++) for (uint16_t k = 0; k < size; k++)
s << " " << uint.at(nStart++); s << " " << uint.at(nStart++);
} }

Loading…
Cancel
Save