Improve lens identification for Sony ARWs
Let Exiv2 get the lens name if the lens spec is present. Otherwise, use the lens ID.
This commit is contained in:
parent
98752a2433
commit
79d402c820
@ -65,6 +65,34 @@ auto to_long(const Iterator &iter, Integer n = Integer{0}) -> decltype(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if the values at the iterator are equal to the given values.
|
||||||
|
*
|
||||||
|
* @param iter The iterator.
|
||||||
|
* @param compare_to The values to compare to.
|
||||||
|
* @param get_value A function that accepts the iterator and an index and
|
||||||
|
* returns the value at the index.
|
||||||
|
* @return If the values are equal.
|
||||||
|
*/
|
||||||
|
template <typename Iterator, typename T>
|
||||||
|
bool tag_values_equal(
|
||||||
|
const Iterator &iter,
|
||||||
|
const std::initializer_list<T> compare_to,
|
||||||
|
std::function<T (const Iterator &, std::size_t)> get_value)
|
||||||
|
{
|
||||||
|
const auto size = compare_to.size();
|
||||||
|
if (size != iter->count()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
std::size_t i = 0;
|
||||||
|
for (const auto value : compare_to) {
|
||||||
|
if (get_value(iter, i++) != value) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience class for reading data from a metadata tag's bytes value.
|
* Convenience class for reading data from a metadata tag's bytes value.
|
||||||
*
|
*
|
||||||
@ -604,14 +632,18 @@ FramesData::FramesData(const Glib::ustring &fname, time_t ts) :
|
|||||||
} else if (!make.compare(0, 4, "SONY")) {
|
} else if (!make.compare(0, 4, "SONY")) {
|
||||||
// ExifTool prefers LensType2 over LensType (called
|
// ExifTool prefers LensType2 over LensType (called
|
||||||
// Exif.Sony2.LensID by Exiv2). Exiv2 doesn't support LensType2 yet,
|
// Exif.Sony2.LensID by Exiv2). Exiv2 doesn't support LensType2 yet,
|
||||||
// so we let Exiv2 try it's best. For non ILCE/NEX cameras which
|
// so we let Exiv2 try it's best. If the LensSpec is unknown, the
|
||||||
// likely don't have LensType2, we use Exif.Sony2.LensID because
|
// lens information may be incorrect, so we use Exif.Sony2.LensID
|
||||||
// Exif.Photo.LensModel may be incorrect (see
|
// which lists all possible lenses.
|
||||||
// https://discuss.pixls.us/t/call-for-testing-rawtherapee-metadata-handling-with-exiv2-includes-cr3-support/36240/36).
|
|
||||||
if (
|
if (
|
||||||
// Camera model is neither a ILCE, ILME, nor NEX.
|
// LensSpec is unknown.
|
||||||
(!find_exif_tag("Exif.Image.Model") ||
|
(find_exif_tag("Exif.Sony2.LensSpec") &&
|
||||||
(pos->toString().compare(0, 4, "ILCE") && pos->toString().compare(0, 4, "ILME") && pos->toString().compare(0, 3, "NEX"))) &&
|
tag_values_equal<decltype(pos), long>(
|
||||||
|
pos,
|
||||||
|
{0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L},
|
||||||
|
[](const decltype(pos) &iter, std::size_t n) {
|
||||||
|
return to_long(iter, n);
|
||||||
|
})) &&
|
||||||
// LensID exists. 0xFFFF could be one of many lenses.
|
// LensID exists. 0xFFFF could be one of many lenses.
|
||||||
find_exif_tag("Exif.Sony2.LensID") && to_long(pos) && to_long(pos) != 0xFFFF) {
|
find_exif_tag("Exif.Sony2.LensID") && to_long(pos) && to_long(pos) != 0xFFFF) {
|
||||||
lens = pos->print(&exif);
|
lens = pos->print(&exif);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user