Project

General

Profile

Bug #854 » bug854.patch

Patch for Bug #854 and #895 - Aakash Goenka, 26 Apr 2013 14:02

View differences:

canonmn.cpp (working copy)
60 60
    };
61 61

  
62 62
    //! Special treatment pretty-print function for non-unique lens ids.
63
    std::ostream& printCsLensByFocalLength(std::ostream& os,
63
    std::ostream& printCsLensByFocalLengthAndMaxAperture(std::ostream& os,
64 64
                                           const Value& value,
65 65
                                           const ExifData* metadata);
66 66

  
......
576 576
        { 154, "Canon EF 20mm f/2.8 USM"                                    },
577 577
        { 155, "Canon EF 85mm f/1.8 USM"                                    },
578 578
        { 156, "Canon EF 28-105mm f/3.5-4.5 USM or Tamron Lens"             }, // 0
579
        { 156, "Tamron SP AF 70-300mm F4-5.6 Di VC USD"                     }, // 1
579
        { 156, "Tamron SP AF 70-300mm f/4-5.6 Di VC USD"                     }, // 1
580 580
        { 160, "Canon EF 20-35mm f/3.5-4.5 USM or Tamron or Tokina Lens"    }, // 0
581 581
        { 160, "Tamron AF 19-35mm f/3.5-4.5"                                }, // 1
582 582
        { 160, "Tokina AT-X 124 AF 12-24mm f/4 DX"                          }, // 2
......
709 709
    //! List of lens ids which require special treatment with the medicine
710 710
    const LensIdFct lensIdFct[] = {
711 711
        {   4, 0                        }, // no known medicine
712
        {   6, printCsLensByFocalLength },
713
        {   8, printCsLensByFocalLength },
714
        {   9, printCsLensByFocalLength },
715
        {  10, printCsLensByFocalLength }, // works partly
716
        {  22, printCsLensByFocalLength },
717
        {  26, printCsLensByFocalLength }, // works partly
718
        {  28, printCsLensByFocalLength },
719
        {  31, printCsLensByFocalLength },
720
        {  32, printCsLensByFocalLength },
721
        {  33, printCsLensByFocalLength }, // not tested
722
        {  37, printCsLensByFocalLength },
723
        {  42, printCsLensByFocalLength },
724
        { 131, printCsLensByFocalLength },
725
        { 137, printCsLensByFocalLength }, // not tested
726
        { 150, printCsLensByFocalLength },
727
        { 152, printCsLensByFocalLength },
728
        { 153, printCsLensByFocalLength },
729
        { 156, printCsLensByFocalLength },
730
        { 160, printCsLensByFocalLength },
731
        { 161, printCsLensByFocalLength },
732
        { 169, printCsLensByFocalLength },
733
        { 173, printCsLensByFocalLength }, // works partly
734
        { 174, printCsLensByFocalLength }, // not tested
735
        { 183, printCsLensByFocalLength }  // not tested
712
        {   6, printCsLensByFocalLengthAndMaxAperture },
713
        {   8, printCsLensByFocalLengthAndMaxAperture },
714
        {   9, printCsLensByFocalLengthAndMaxAperture },
715
        {  10, printCsLensByFocalLengthAndMaxAperture }, // works partly
716
        {  22, printCsLensByFocalLengthAndMaxAperture },
717
        {  26, printCsLensByFocalLengthAndMaxAperture }, // works partly
718
        {  28, printCsLensByFocalLengthAndMaxAperture },
719
        {  31, printCsLensByFocalLengthAndMaxAperture },
720
        {  32, printCsLensByFocalLengthAndMaxAperture },
721
        {  33, printCsLensByFocalLengthAndMaxAperture }, // not tested
722
        {  37, printCsLensByFocalLengthAndMaxAperture },
723
        {  42, printCsLensByFocalLengthAndMaxAperture },
724
        { 131, printCsLensByFocalLengthAndMaxAperture },
725
        { 137, printCsLensByFocalLengthAndMaxAperture }, // not tested
726
        { 150, printCsLensByFocalLengthAndMaxAperture },
727
        { 152, printCsLensByFocalLengthAndMaxAperture },
728
        { 153, printCsLensByFocalLengthAndMaxAperture },
729
        { 156, printCsLensByFocalLengthAndMaxAperture },
730
        { 160, printCsLensByFocalLengthAndMaxAperture },
731
        { 161, printCsLensByFocalLengthAndMaxAperture },
732
        { 169, printCsLensByFocalLengthAndMaxAperture },
733
        { 173, printCsLensByFocalLengthAndMaxAperture }, // works partly
734
        { 174, printCsLensByFocalLengthAndMaxAperture }, // not tested
735
        { 183, printCsLensByFocalLengthAndMaxAperture }  // not tested
736 736
    };
737 737

  
738 738
    //! FlashActivity, tag 0x001c
......
1298 1298
    }
1299 1299

  
1300 1300
    //! Helper structure
1301
    struct LensTypeAndFocalLength {
1301
    struct LensTypeAndFocalLengthAndMaxAperture {
1302 1302
        long        lensType_;                  //!< Lens type
1303 1303
        std::string focalLength_;               //!< Focal length
1304
        std::string maxAperture_;               //!< Aperture
1304 1305
    };
1305 1306

  
1306 1307
    //! Compare tag details with a lens entry
1307
    bool operator==(const TagDetails& td, const LensTypeAndFocalLength& ltfl) {
1308
    bool operator==(const TagDetails& td, const LensTypeAndFocalLengthAndMaxAperture& ltfl) {
1308 1309
        return (   td.val_ == ltfl.lensType_
1309
                && std::string(td.label_).find(ltfl.focalLength_) != std::string::npos);
1310
                && std::string(td.label_).find(ltfl.focalLength_) != std::string::npos
1311
                && std::string(td.label_).find(ltfl.maxAperture_) != std::string::npos);
1310 1312
    }
1311 1313

  
1312
    std::ostream& printCsLensByFocalLength(std::ostream& os,
1314
    std::ostream& printCsLensByFocalLengthAndMaxAperture(std::ostream& os,
1313 1315
                                           const Value& value,
1314 1316
                                           const ExifData* metadata)
1315 1317
    {
1316 1318
        if (   !metadata || value.typeId() != unsignedShort
1317 1319
            || value.count() == 0) return os << value;
1318 1320

  
1319
        LensTypeAndFocalLength ltfl;
1321
        LensTypeAndFocalLengthAndMaxAperture ltfl;
1320 1322
        ltfl.lensType_ = value.toLong();
1321 1323

  
1322 1324
        ExifKey key("Exif.CanonCs.Lens");
......
1340 1342
        }
1341 1343
        if (ltfl.focalLength_.empty()) return os << value;
1342 1344

  
1345
        ExifKey key2("Exif.CanonCs.MaxAperture");
1346
        pos = metadata->findKey(key2);
1347
        if (   pos != metadata->end()
1348
            && pos->value().count() == 1
1349
            && pos->value().typeId() == unsignedShort) {
1350

  
1351
            long val = static_cast<int16_t>(pos->value().toLong(0));
1352
            if (val > 0)
1353
            {
1354
                std::ostringstream oss;
1355
                oss << std::setprecision(2);
1356
                oss << fnumber(canonEv(val));
1357
                ltfl.maxAperture_ = oss.str();
1358
            }
1359
        }
1360
        if (ltfl.maxAperture_.empty()) return os << value;
1361

  
1343 1362
        const TagDetails* td = find(canonCsLensType, ltfl);
1344 1363
        if (!td) return os << value;
1345 1364
        return os << td->label_;
(2-2/2)