@@ -65,6 +65,34 @@ auto to_long(const Iterator &iter, Integer n = Integer{0}) -> decltype(
65
65
#endif
66
66
}
67
67
68
+ /* *
69
+ * Returns if the values at the iterator are equal to the given values.
70
+ *
71
+ * @param iter The iterator.
72
+ * @param compare_to The values to compare to.
73
+ * @param get_value A function that accepts the iterator and an index and
74
+ * returns the value at the index.
75
+ * @return If the values are equal.
76
+ */
77
+ template <typename Iterator, typename T>
78
+ bool tag_values_equal (
79
+ const Iterator &iter,
80
+ const std::initializer_list<T> compare_to,
81
+ std::function<T (const Iterator &, std::size_t )> get_value)
82
+ {
83
+ const auto size = compare_to.size ();
84
+ if (size != iter->count ()) {
85
+ return false ;
86
+ }
87
+ std::size_t i = 0 ;
88
+ for (const auto value : compare_to) {
89
+ if (get_value (iter, i++) != value) {
90
+ return false ;
91
+ }
92
+ }
93
+ return true ;
94
+ }
95
+
68
96
/* *
69
97
* Convenience class for reading data from a metadata tag's bytes value.
70
98
*
@@ -604,14 +632,18 @@ FramesData::FramesData(const Glib::ustring &fname, time_t ts) :
604
632
} else if (!make.compare (0 , 4 , " SONY" )) {
605
633
// ExifTool prefers LensType2 over LensType (called
606
634
// Exif.Sony2.LensID by Exiv2). Exiv2 doesn't support LensType2 yet,
607
- // so we let Exiv2 try it's best. For non ILCE/NEX cameras which
608
- // likely don't have LensType2, we use Exif.Sony2.LensID because
609
- // Exif.Photo.LensModel may be incorrect (see
610
- // https://discuss.pixls.us/t/call-for-testing-rawtherapee-metadata-handling-with-exiv2-includes-cr3-support/36240/36).
635
+ // so we let Exiv2 try it's best. If the LensSpec is unknown, the
636
+ // lens information may be incorrect, so we use Exif.Sony2.LensID
637
+ // which lists all possible lenses.
611
638
if (
612
- // Camera model is neither a ILCE, ILME, nor NEX.
613
- (!find_exif_tag (" Exif.Image.Model" ) ||
614
- (pos->toString ().compare (0 , 4 , " ILCE" ) && pos->toString ().compare (0 , 4 , " ILME" ) && pos->toString ().compare (0 , 3 , " NEX" ))) &&
639
+ // LensSpec is unknown.
640
+ (find_exif_tag (" Exif.Sony2.LensSpec" ) &&
641
+ tag_values_equal<decltype (pos), long >(
642
+ pos,
643
+ {0L , 0L , 0L , 0L , 0L , 0L , 0L , 0L },
644
+ [](const decltype (pos) &iter, std::size_t n) {
645
+ return to_long (iter, n);
646
+ })) &&
615
647
// LensID exists. 0xFFFF could be one of many lenses.
616
648
find_exif_tag (" Exif.Sony2.LensID" ) && to_long (pos) && to_long (pos) != 0xFFFF ) {
617
649
lens = pos->print (&exif);
0 commit comments