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",
"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) {

@ -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
static const struct ZMntLens {
uint16_t lid;
const char *manuf, *lensname;
} zmountlens[] = {
{1, "Nikon", "Nikkor Z 24-70mm f/4 S"},
{2, "Nikon", "Nikkor Z 14-30mm f/4 S"},
{4, "Nikon", "Nikkor Z 35mm f/1.8 S"},
{8, "Nikon", "Nikkor Z 58mm f/0.95 S Noct"}, // IB
{9, "Nikon", "Nikkor Z 50mm f/1.8 S"},
{11, "Nikon", "Nikkor Z DX 16-50mm f/3.5-6.3 VR"},
{12, "Nikon", "Nikkor Z DX 50-250mm f/4.5-6.3 VR"},
{13, "Nikon", "Nikkor Z 24-70mm f/2.8 S"},
{14, "Nikon", "Nikkor Z 85mm f/1.8 S"},
{15, "Nikon", "Nikkor Z 24mm f/1.8 S"}, // IB
{16, "Nikon", "Nikkor Z 70-200mm f/2.8 VR S"}, // IB
{17, "Nikon", "Nikkor Z 20mm f/1.8 S"}, // IB
{18, "Nikon", "Nikkor Z 24-200mm f/4-6.3 VR"}, // IB
{21, "Nikon", "Nikkor Z 50mm f/1.2 S"}, // IB
{22, "Nikon", "Nikkor Z 24-50mm f/4-6.3"}, // IB
{23, "Nikon", "Nikkor Z 14-24mm f/2.8 S"}, // IB
using ZMntLens = std::tuple<uint16_t, const char*, const char*>;
static constexpr auto zmountlens = std::array{
ZMntLens(1, "Nikon", "Nikkor Z 24-70mm f/4 S"),
ZMntLens(2, "Nikon", "Nikkor Z 14-30mm f/4 S"),
ZMntLens(4, "Nikon", "Nikkor Z 35mm f/1.8 S"),
ZMntLens(8, "Nikon", "Nikkor Z 58mm f/0.95 S Noct"), // IB
ZMntLens(9, "Nikon", "Nikkor Z 50mm f/1.8 S"),
ZMntLens(11, "Nikon", "Nikkor Z DX 16-50mm f/3.5-6.3 VR"),
ZMntLens(12, "Nikon", "Nikkor Z DX 50-250mm f/4.5-6.3 VR"),
ZMntLens(13, "Nikon", "Nikkor Z 24-70mm f/2.8 S"),
ZMntLens(14, "Nikon", "Nikkor Z 85mm f/1.8 S"),
ZMntLens(15, "Nikon", "Nikkor Z 24mm f/1.8 S"), // IB
ZMntLens(16, "Nikon", "Nikkor Z 70-200mm f/2.8 VR S"), // IB
ZMntLens(17, "Nikon", "Nikkor Z 20mm f/1.8 S"), // IB
ZMntLens(18, "Nikon", "Nikkor Z 24-200mm f/4-6.3 VR"), // IB
ZMntLens(21, "Nikon", "Nikkor Z 50mm f/1.2 S"), // IB
ZMntLens(22, "Nikon", "Nikkor Z 24-50mm f/4-6.3"), // IB
ZMntLens(23, "Nikon", "Nikkor Z 14-24mm f/2.8 S"), // IB
};
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; });
if (it != std::end(zmountlens))
return os << it->manuf << " " << it->lensname;
for (auto&& [l, manuf, lensname] : zmountlens)
if (l == lid)
return os << manuf << " " << lensname;
return os << lid;
}

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

Loading…
Cancel
Save