Project

General

Profile

Patch #982 ยป 0001-Improve-detection-of-Canon-lenses-sharing-the-same-I.patch

Alexander Steffen, 15 Aug 2014 09:55

View differences:

src/canonmn.cpp
63 63
    std::ostream& printCsLensByFocalLengthAndMaxAperture(std::ostream& os,
64 64
                                           const Value& value,
65 65
                                           const ExifData* metadata);
66
    std::ostream& printCsLensByFocalLength(std::ostream& os,
67
                                           const Value& value,
68
                                           const ExifData* metadata);
66 69

  
67 70
    //! ModelId, tag 0x0010
68 71
    extern const TagDetails canonModelId[] = {
......
882 885

  
883 886
    //! List of lens ids which require special treatment with the medicine
884 887
    const LensIdFct lensIdFct[] = {
885
        {   4, printCsLensByFocalLengthAndMaxAperture }, // not tested
886
        {   6, printCsLensByFocalLengthAndMaxAperture },
887
        {   8, printCsLensByFocalLengthAndMaxAperture },
888
        {   9, printCsLensByFocalLengthAndMaxAperture },
888
        {   4, printCsLensByFocalLength }, // not tested
889
        {   6, printCsLensByFocalLength },
890
        {   8, printCsLensByFocalLength },
891
        {   9, printCsLensByFocalLength },
889 892
        {  10, printCsLensByFocalLengthAndMaxAperture }, // works partly
890
        {  22, printCsLensByFocalLengthAndMaxAperture },
893
        {  22, printCsLensByFocalLength },
891 894
        {  26, printCsLensByFocalLengthAndMaxAperture }, // works partly
892
        {  28, printCsLensByFocalLengthAndMaxAperture },
893
        {  31, printCsLensByFocalLengthAndMaxAperture },
894
        {  32, printCsLensByFocalLengthAndMaxAperture },
895
        {  33, printCsLensByFocalLengthAndMaxAperture }, // not tested
896
        {  37, printCsLensByFocalLengthAndMaxAperture },
897
        {  42, printCsLensByFocalLengthAndMaxAperture },
898
        { 131, printCsLensByFocalLengthAndMaxAperture },
899
        { 137, printCsLensByFocalLengthAndMaxAperture }, // not tested
900
        { 150, printCsLensByFocalLengthAndMaxAperture },
901
        { 152, printCsLensByFocalLengthAndMaxAperture },
902
        { 153, printCsLensByFocalLengthAndMaxAperture },
903
        { 156, printCsLensByFocalLengthAndMaxAperture },
904
        { 160, printCsLensByFocalLengthAndMaxAperture },
905
        { 161, printCsLensByFocalLengthAndMaxAperture },
906
        { 169, printCsLensByFocalLengthAndMaxAperture },
907
        { 173, printCsLensByFocalLengthAndMaxAperture }, // works partly
908
        { 174, printCsLensByFocalLengthAndMaxAperture }, // not tested
909
        { 180, printCsLensByFocalLengthAndMaxAperture },
910
        { 183, printCsLensByFocalLengthAndMaxAperture }, // not tested
911
        { 198, printCsLensByFocalLengthAndMaxAperture }, // not tested
912
        { 213, printCsLensByFocalLengthAndMaxAperture }  // not tested
895
        {  28, printCsLensByFocalLength },
896
        {  31, printCsLensByFocalLength },
897
        {  32, printCsLensByFocalLength },
898
        {  33, printCsLensByFocalLength }, // not tested
899
        {  37, printCsLensByFocalLength },
900
        {  42, printCsLensByFocalLength },
901
        { 131, printCsLensByFocalLength },
902
        { 137, printCsLensByFocalLength }, // not tested
903
        { 150, printCsLensByFocalLength },
904
        { 152, printCsLensByFocalLength },
905
        { 153, printCsLensByFocalLength },
906
        { 156, printCsLensByFocalLength },
907
        { 160, printCsLensByFocalLength },
908
        { 161, printCsLensByFocalLength },
909
        { 169, printCsLensByFocalLength },
910
        { 173, printCsLensByFocalLength }, // works partly
911
        { 174, printCsLensByFocalLength }, // not tested
912
        { 180, printCsLensByFocalLength },
913
        { 183, printCsLensByFocalLength }, // not tested
914
        { 198, printCsLensByFocalLength }, // not tested
915
        { 213, printCsLensByFocalLength }  // not tested
913 916
    };
914 917

  
915 918
    //! FlashActivity, tag 0x001c
......
1505 1508
                && std::string(td.label_).find(ltfl.maxAperture_) != std::string::npos);
1506 1509
    }
1507 1510

  
1508
    std::ostream& printCsLensByFocalLengthAndMaxAperture(std::ostream& os,
1509
                                           const Value& value,
1510
                                           const ExifData* metadata)
1511
    void extractLensFocalLength(LensTypeAndFocalLengthAndMaxAperture& ltfl,
1512
                                const ExifData* metadata)
1511 1513
    {
1512
        if (   !metadata || value.typeId() != unsignedShort
1513
            || value.count() == 0) return os << value;
1514

  
1515
        LensTypeAndFocalLengthAndMaxAperture ltfl;
1516
        ltfl.lensType_ = value.toLong();
1517

  
1518 1514
        ExifKey key("Exif.CanonCs.Lens");
1519 1515
        ExifData::const_iterator pos = metadata->findKey(key);
1520 1516
        if (   pos != metadata->end()
......
1534 1530
                ltfl.focalLength_ = oss.str();
1535 1531
            }
1536 1532
        }
1533
    }
1534

  
1535
    std::ostream& printCsLensByFocalLengthAndMaxAperture(std::ostream& os,
1536
                                           const Value& value,
1537
                                           const ExifData* metadata)
1538
    {
1539
        if (   !metadata || value.typeId() != unsignedShort
1540
            || value.count() == 0) return os << value;
1541

  
1542
        LensTypeAndFocalLengthAndMaxAperture ltfl;
1543
        ltfl.lensType_ = value.toLong();
1544

  
1545
        extractLensFocalLength(ltfl, metadata);
1537 1546
        if (ltfl.focalLength_.empty()) return os << value;
1538 1547

  
1539
        ExifKey key2("Exif.CanonCs.MaxAperture");
1540
        pos = metadata->findKey(key2);
1548
        ExifKey key("Exif.CanonCs.MaxAperture");
1549
        ExifData::const_iterator pos = metadata->findKey(key);
1541 1550
        if (   pos != metadata->end()
1542 1551
            && pos->value().count() == 1
1543 1552
            && pos->value().typeId() == unsignedShort) {
......
1558 1567
        return os << td->label_;
1559 1568
    }
1560 1569

  
1570
    std::ostream& printCsLensByFocalLength(std::ostream& os,
1571
                                           const Value& value,
1572
                                           const ExifData* metadata)
1573
    {
1574
        if (   !metadata || value.typeId() != unsignedShort
1575
            || value.count() == 0) return os << value;
1576

  
1577
        LensTypeAndFocalLengthAndMaxAperture ltfl;
1578
        ltfl.lensType_ = value.toLong();
1579

  
1580
        extractLensFocalLength(ltfl, metadata);
1581
        if (ltfl.focalLength_.empty()) return os << value;
1582

  
1583
        const TagDetails* td = find(canonCsLensType, ltfl);
1584
        if (!td) return os << value;
1585
        return os << td->label_;
1586
    }
1587

  
1561 1588
    std::ostream& CanonMakerNote::printCsLensType(std::ostream& os,
1562 1589
                                                  const Value& value,
1563 1590
                                                  const ExifData* metadata)
    (1-1/1)