66 |
66 |
std::ostream& printCsLensByFocalLength(std::ostream& os,
|
67 |
67 |
const Value& value,
|
68 |
68 |
const ExifData* metadata);
|
|
69 |
std::ostream& printCsLensByFocalLengthTC(std::ostream& os,
|
|
70 |
const Value& value,
|
|
71 |
const ExifData* metadata);
|
69 |
72 |
|
70 |
73 |
//! ModelId, tag 0x0010
|
71 |
74 |
extern const TagDetails canonModelId[] = {
|
... | ... | |
798 |
801 |
{ 173, "Canon EF 180mm Macro f/3.5L" }, // 0
|
799 |
802 |
{ 173, "Sigma 180mm EX HSM Macro f/3.5" }, // 1
|
800 |
803 |
{ 173, "Sigma APO Macro 150mm f/3.5 EX DG IF HSM" }, // 2
|
|
804 |
{ 173, "Sigma 150-500mm f/5-6.3 APO DG OS HSM + 2x" }, // 3
|
801 |
805 |
{ 174, "Canon EF 135mm f/2L" }, // 0
|
802 |
806 |
{ 174, "Sigma 70-200mm f/2.8 EX DG APO OS HSM" }, // 1
|
803 |
807 |
{ 174, "Sigma 50-500mm f/4.5-6.3 APO DG OS HSM" }, // 2
|
... | ... | |
949 |
953 |
{ 161, printCsLensByFocalLength },
|
950 |
954 |
{ 169, printCsLensByFocalLength },
|
951 |
955 |
{ 172, printCsLensByFocalLength }, // not tested
|
952 |
|
{ 173, printCsLensByFocalLength }, // works partly
|
|
956 |
{ 173, printCsLensByFocalLengthTC }, // works partly
|
953 |
957 |
{ 174, printCsLensByFocalLength }, // not tested
|
954 |
958 |
{ 180, printCsLensByFocalLength },
|
955 |
959 |
{ 183, printCsLensByFocalLength }, // not tested
|
... | ... | |
1546 |
1550 |
//! Helper structure
|
1547 |
1551 |
struct LensTypeAndFocalLengthAndMaxAperture {
|
1548 |
1552 |
long lensType_; //!< Lens type
|
1549 |
|
std::string focalLength_; //!< Focal length
|
|
1553 |
float focalLengthMin_; //!< Mininum focal length
|
|
1554 |
float focalLengthMax_; //!< Maximum focal length
|
|
1555 |
std::string focalLength_; //!< Focal length as a string
|
1550 |
1556 |
std::string maxAperture_; //!< Aperture
|
1551 |
1557 |
};
|
1552 |
1558 |
|
... | ... | |
1562 |
1568 |
{
|
1563 |
1569 |
ExifKey key("Exif.CanonCs.Lens");
|
1564 |
1570 |
ExifData::const_iterator pos = metadata->findKey(key);
|
|
1571 |
ltfl.focalLengthMin_ = 0.0;
|
|
1572 |
ltfl.focalLengthMax_ = 0.0;
|
1565 |
1573 |
if ( pos != metadata->end()
|
1566 |
1574 |
&& pos->value().count() >= 3
|
1567 |
1575 |
&& pos->value().typeId() == unsignedShort) {
|
1568 |
1576 |
float fu = pos->value().toFloat(2);
|
1569 |
1577 |
if (fu != 0.0) {
|
1570 |
|
float len1 = pos->value().toLong(0) / fu;
|
1571 |
|
float len2 = pos->value().toLong(1) / fu;
|
1572 |
|
std::ostringstream oss;
|
1573 |
|
oss << std::fixed << std::setprecision(0);
|
1574 |
|
if (len1 == len2) {
|
1575 |
|
oss << len1 << "mm";
|
1576 |
|
} else {
|
1577 |
|
oss << len2 << "-" << len1 << "mm";
|
1578 |
|
}
|
1579 |
|
ltfl.focalLength_ = oss.str();
|
|
1578 |
ltfl.focalLengthMin_ = pos->value().toLong(1) / fu;
|
|
1579 |
ltfl.focalLengthMax_ = pos->value().toLong(0) / fu;
|
1580 |
1580 |
}
|
1581 |
1581 |
}
|
1582 |
1582 |
}
|
1583 |
1583 |
|
|
1584 |
void convertFocalLength(LensTypeAndFocalLengthAndMaxAperture& ltfl,
|
|
1585 |
double divisor)
|
|
1586 |
{
|
|
1587 |
std::ostringstream oss;
|
|
1588 |
oss << std::fixed << std::setprecision(0);
|
|
1589 |
if (ltfl.focalLengthMin_ == ltfl.focalLengthMax_) {
|
|
1590 |
oss << (ltfl.focalLengthMin_ / divisor) << "mm";
|
|
1591 |
} else {
|
|
1592 |
oss << (ltfl.focalLengthMin_ / divisor) << "-" << (ltfl.focalLengthMax_ / divisor) << "mm";
|
|
1593 |
}
|
|
1594 |
ltfl.focalLength_ = oss.str();
|
|
1595 |
}
|
|
1596 |
|
1584 |
1597 |
std::ostream& printCsLensByFocalLengthAndMaxAperture(std::ostream& os,
|
1585 |
1598 |
const Value& value,
|
1586 |
1599 |
const ExifData* metadata)
|
... | ... | |
1592 |
1605 |
ltfl.lensType_ = value.toLong();
|
1593 |
1606 |
|
1594 |
1607 |
extractLensFocalLength(ltfl, metadata);
|
1595 |
|
if (ltfl.focalLength_.empty()) return os << value;
|
|
1608 |
if (ltfl.focalLengthMax_ == 0.0) return os << value;
|
|
1609 |
convertFocalLength(ltfl, 1.0);
|
1596 |
1610 |
|
1597 |
1611 |
ExifKey key("Exif.CanonCs.MaxAperture");
|
1598 |
1612 |
ExifData::const_iterator pos = metadata->findKey(key);
|
... | ... | |
1627 |
1641 |
ltfl.lensType_ = value.toLong();
|
1628 |
1642 |
|
1629 |
1643 |
extractLensFocalLength(ltfl, metadata);
|
|
1644 |
if (ltfl.focalLengthMax_ == 0.0) return os << value;
|
|
1645 |
convertFocalLength(ltfl, 1.0);
|
|
1646 |
|
1630 |
1647 |
if (ltfl.focalLength_.empty()) return os << value;
|
1631 |
1648 |
|
1632 |
1649 |
const TagDetails* td = find(canonCsLensType, ltfl);
|
... | ... | |
1634 |
1651 |
return os << td->label_;
|
1635 |
1652 |
}
|
1636 |
1653 |
|
|
1654 |
std::ostream& printCsLensByFocalLengthTC(std::ostream& os,
|
|
1655 |
const Value& value,
|
|
1656 |
const ExifData* metadata)
|
|
1657 |
{
|
|
1658 |
if ( !metadata || value.typeId() != unsignedShort
|
|
1659 |
|| value.count() == 0) return os << value;
|
|
1660 |
|
|
1661 |
LensTypeAndFocalLengthAndMaxAperture ltfl;
|
|
1662 |
ltfl.lensType_ = value.toLong();
|
|
1663 |
|
|
1664 |
extractLensFocalLength(ltfl, metadata);
|
|
1665 |
if (ltfl.focalLengthMax_ == 0.0) return os << value;
|
|
1666 |
convertFocalLength(ltfl, 1.0); // just lens
|
|
1667 |
const TagDetails* td = find(canonCsLensType, ltfl);
|
|
1668 |
if (!td) {
|
|
1669 |
convertFocalLength(ltfl, 1.4); // lens + 1.4x TC
|
|
1670 |
td = find(canonCsLensType, ltfl);
|
|
1671 |
if (!td) {
|
|
1672 |
convertFocalLength(ltfl, 2.0); // lens + 2x TC
|
|
1673 |
td = find(canonCsLensType, ltfl);
|
|
1674 |
if (!td) return os << value;
|
|
1675 |
}
|
|
1676 |
}
|
|
1677 |
return os << td->label_;
|
|
1678 |
}
|
|
1679 |
|
1637 |
1680 |
std::ostream& CanonMakerNote::printCsLensType(std::ostream& os,
|
1638 |
1681 |
const Value& value,
|
1639 |
1682 |
const ExifData* metadata)
|