diff --git a/src/minoltamn_int.cpp b/src/minoltamn_int.cpp index 406bcca8..9be804a6 100644 --- a/src/minoltamn_int.cpp +++ b/src/minoltamn_int.cpp @@ -1649,10 +1649,17 @@ static std::ostream& resolveLens0xffff(std::ostream& os, const Value& value, con } //! List of lens ids which require special treatment from printMinoltaSonyLensID -constexpr auto lensIdFct = std::array{ - std::pair(0x001cu, &resolveLens0x1c), std::pair(0x0029u, &resolveLens0x29), std::pair(0x0034u, &resolveLens0x34), - std::pair(0x0080u, &resolveLens0x80), std::pair(0x00ffu, &resolveLens0xff), std::pair(0xffffu, &resolveLens0xffff), - // std::pair(0x00ff, resolveLensTypeUsingExiftool), // was used for debugging +constexpr struct LensIdFct { + uint32_t idx; + PrintFct fct; + + bool operator==(uint32_t i) const { + return i == idx; + } +} lensIdFct[] = { + {0x001cu, &resolveLens0x1c}, {0x0029u, &resolveLens0x29}, {0x0034u, &resolveLens0x34}, + {0x0080u, &resolveLens0x80}, {0x00ffu, &resolveLens0xff}, {0xffffu, &resolveLens0xffff}, + //{0x00ffu, &resolveLensTypeUsingExiftool}, // was used for debugging }; // #1145 end - respect lenses with shared LensID // ---------------------------------------------------------------------- @@ -1671,9 +1678,9 @@ std::ostream& printMinoltaSonyLensID(std::ostream& os, const Value& value, const // #1145 - respect lenses with shared LensID uint32_t index = value.toUint32(); - for (auto&& [idx, fct] : lensIdFct) - if (metadata && idx == index && fct) - return fct(os, value, metadata); + auto f = Exiv2::find(lensIdFct, index); + if (f && metadata) + return f->fct(os, value, metadata); return EXV_PRINT_TAG(minoltaSonyLensID)(os, value, metadata); } diff --git a/src/sonymn_int.cpp b/src/sonymn_int.cpp index e8548c6c..2edd9d47 100644 --- a/src/sonymn_int.cpp +++ b/src/sonymn_int.cpp @@ -1165,21 +1165,20 @@ std::ostream& SonyMakerNote::printColorCompensationFilter(std::ostream& os, cons } static void findLensSpecFlags(const Value& value, std::string& flagsStart, std::string& flagsEnd) { - struct LensSpecFlags { - const int64_t mask; // Contains all the bits set in the flags.val_ array values - const std::array flags; + static constexpr struct LensSpecFlags { + int64_t mask; // Contains all the bits set in the flags.val_ array values + TagDetails flags[4]; bool prepend; + } lSFArray[] = { + {0x4000, {{0x4000, "PZ"}}, true}, + {0x0300, {{0x0100, "DT"}, {0x0200, "FE"}, {0x0300, "E"}}, true}, + {0x00e0, {{0x0020, "STF"}, {0x0040, N_("Reflex")}, {0x0060, N_("Macro")}, {0x0080, N_("Fisheye")}}, false}, + {0x000c, {{0x0004, "ZA"}, {0x0008, "G"}}, false}, + {0x0003, {{0x0001, "SSM"}, {0x0002, "SAM"}}, false}, + {0x8000, {{0x8000, "OSS"}}, false}, + {0x2000, {{0x2000, "LE"}}, false}, + {0x0800, {{0x0800, "II"}}, false}, }; - static constexpr std::array lSFArray = { - LensSpecFlags{0x4000, {{{0x4000, "PZ"}}}, true}, - LensSpecFlags{0x0300, {{{0x0100, "DT"}, {0x0200, "FE"}, {0x0300, "E"}}}, true}, - LensSpecFlags{ - 0x00e0, {{{0x0020, "STF"}, {0x0040, N_("Reflex")}, {0x0060, N_("Macro")}, {0x0080, N_("Fisheye")}}}, false}, - LensSpecFlags{0x000c, {{{0x0004, "ZA"}, {0x0008, "G"}}}, false}, - LensSpecFlags{0x0003, {{{0x0001, "SSM"}, {0x0002, "SAM"}}}, false}, - LensSpecFlags{0x8000, {{{0x8000, "OSS"}}}, false}, - LensSpecFlags{0x2000, {{{0x2000, "LE"}}}, false}, - LensSpecFlags{0x0800, {{{0x0800, "II"}}}, false}}; // When processing, a bitwise 'AND' selects a compatible LensSpecFlags entry, // then search inside the 'flags' array for one match. @@ -1192,17 +1191,17 @@ static void findLensSpecFlags(const Value& value, std::string& flagsStart, std:: for (const auto& i : lSFArray) { temp = i.mask & joinedV0V7; if (temp) { // Check if a flag matches in the current LensSpecFlags - const auto it = std::find(i.flags.begin(), i.flags.end(), temp); - if (it == i.flags.end()) { + auto f = Exiv2::find(i.flags, temp); + if (!f) { // Should never get in here. LensSpecFlags.mask should contain all the // bits in all the LensSpecFlags.flags.val_ entries throw Error(ErrorCode::kerErrorMessage, std::string("LensSpecFlags mask doesn't match the bits in the flags array")); } if (i.prepend) - flagsStart = (flagsStart.empty() ? it->label_ : it->label_ + std::string(" ") + flagsStart); + flagsStart = (flagsStart.empty() ? f->label_ : f->label_ + std::string(" ") + flagsStart); else - flagsEnd = (flagsEnd.empty() ? it->label_ : flagsEnd + std::string(" ") + it->label_); + flagsEnd = (flagsEnd.empty() ? f->label_ : flagsEnd + std::string(" ") + f->label_); } } } diff --git a/src/tiffimage.cpp b/src/tiffimage.cpp index 1dca602a..bcdb3282 100644 --- a/src/tiffimage.cpp +++ b/src/tiffimage.cpp @@ -43,10 +43,17 @@ TiffImage::TiffImage(BasicIo::UniquePtr io, bool /*create*/) : } // TiffImage::TiffImage //! List of TIFF compression to MIME type mappings -constexpr auto mimeTypeList = std::array{ - std::pair(32767, "image/x-sony-arw"), std::pair(32769, "image/x-epson-erf"), - std::pair(32770, "image/x-samsung-srw"), std::pair(34713, "image/x-nikon-nef"), - std::pair(65000, "image/x-kodak-dcr"), std::pair(65535, "image/x-pentax-pef"), + +constexpr struct mimeType { + int comp; + const char* type; + + bool operator==(int c) const { + return comp == c; + } +} mimeTypeList[] = { + {32767, "image/x-sony-arw"}, {32769, "image/x-epson-erf"}, {32770, "image/x-samsung-srw"}, + {34713, "image/x-nikon-nef"}, {65000, "image/x-kodak-dcr"}, {65535, "image/x-pentax-pef"}, }; std::string TiffImage::mimeType() const { @@ -57,10 +64,9 @@ std::string TiffImage::mimeType() const { std::string key = "Exif." + primaryGroup() + ".Compression"; auto md = exifData_.findKey(ExifKey(key)); if (md != exifData_.end() && md->count() > 0) { - for (const auto& [comp, type] : mimeTypeList) - if (comp == static_cast(md->toInt64())) { - mimeType_ = type; - } + auto mt = Exiv2::find(mimeTypeList, static_cast(md->toInt64())); + if (mt) + mimeType_ = mt->type; } return mimeType_; }