diff --git a/src/makernote.cpp b/src/makernote.cpp index 56ffafa0..c373f6e0 100644 --- a/src/makernote.cpp +++ b/src/makernote.cpp @@ -48,6 +48,9 @@ EXIV2_RCSID("@(#) $Id$") // ***************************************************************************** namespace { + // Todo: Can be generalized further - get any tag as a string/long/... + //! Get the model name from tag Exif.Image.Model + std::string getExifModel(Exiv2::Internal::TiffComponent* const pRoot); //! Nikon en/decryption function void ncrypt(Exiv2::byte* pData, uint32_t size, uint32_t count, uint32_t serial); } @@ -862,12 +865,8 @@ namespace Exiv2 { bool ok(false); uint32_t serial = stringTo(te->pValue()->toString(), ok); if (!ok) { - // Find Exif.Image.Model - finder.init(0x0110, Group::ifd0); - pRoot->accept(finder); - te = dynamic_cast(finder.result()); - if (!te || !te->pValue() || te->pValue()->count() == 0) return buf; - std::string model = te->pValue()->toString(); + std::string model = getExifModel(pRoot); + if (model.empty()) return buf; if (model.find("D50") != std::string::npos) { serial = 0x22; } @@ -881,11 +880,31 @@ namespace Exiv2 { return buf; } + int sonyCsSelector(uint16_t /*tag*/, const byte* /*pData*/, uint32_t /*size*/, TiffComponent* const pRoot) + { + std::string model = getExifModel(pRoot); + if (model.empty()) return -1; + int idx = 0; + if ( model.find("DSLR-A330") != std::string::npos + || model.find("DSLR-A380") != std::string::npos) { + idx = 1; + } + return idx; + } }} // namespace Internal, Exiv2 // ***************************************************************************** // local definitions namespace { + std::string getExifModel(Exiv2::Internal::TiffComponent* const pRoot) + { + Exiv2::Internal::TiffFinder finder(0x0110, Exiv2::Internal::Group::ifd0); // Exif.Image.Model + pRoot->accept(finder); + Exiv2::Internal::TiffEntryBase* te = dynamic_cast(finder.result()); + if (!te || !te->pValue() || te->pValue()->count() == 0) return std::string(); + return te->pValue()->toString(); + } + void ncrypt(Exiv2::byte* pData, uint32_t size, uint32_t count, uint32_t serial) { static const Exiv2::byte xlat[2][256] = { diff --git a/src/makernote_int.hpp b/src/makernote_int.hpp index bfc7ea57..a2f26251 100644 --- a/src/makernote_int.hpp +++ b/src/makernote_int.hpp @@ -111,12 +111,13 @@ namespace Exiv2 { const uint16_t canonfi = 320; //!< Canon File Info const uint16_t sonymltmn = 330; //!< Sony Minolta Makernotes const uint16_t sony1cs = 331; //!< Sony Camera Settings (in Sony1 makernote) - const uint16_t sony2cs = 332; //!< Sony Camera Settings (in Sony2 makernote) + const uint16_t sony1cs2 = 332; //!< Sony Camera Settings 2 (in Sony1 makernote) const uint16_t sony1mcso = 333; //!< Minolta (old) Camera Settings (in Sony1 makernote) const uint16_t sony1mcsn = 334; //!< Minolta (new) Camera Settings (in Sony1 makernote) const uint16_t sony1mcs5 = 335; //!< Minolta D5 Camera Settings (in Sony1 makernote) const uint16_t sony1mcs7 = 336; //!< Minolta D7 Camera Settings (in Sony1 makernote) - const uint16_t sony1cs2 = 337; //!< Sony Camera Settings 2 (in Sony1 makernote) + const uint16_t sony2cs = 337; //!< Sony Camera Settings (in Sony2 makernote) + const uint16_t sony2cs2 = 338; //!< Sony Camera Settings 2 (in Sony2 makernote) } // ***************************************************************************** @@ -652,6 +653,17 @@ namespace Exiv2 { uint16_t group, uint16_t mnGroup); + /*! + @brief Function to select cfg + def of the Sony Camera Settings complex binary array. + + @param tag Tag number of the binary array + @param pData Pointer to the raw array data. + @param size Size of the array data. + @param pRoot Pointer to the root component of the TIFF tree. + @return An index into the array set, -1 if no match was found. + */ + int sonyCsSelector(uint16_t tag, const byte* pData, uint32_t size, TiffComponent* const pRoot); + /*! @brief Function to select cfg + def of a Nikon complex binary array. diff --git a/src/tags.cpp b/src/tags.cpp index c4290e87..c424ef20 100644 --- a/src/tags.cpp +++ b/src/tags.cpp @@ -180,6 +180,7 @@ namespace Exiv2 { { sony1MltCsOldIfdId,"Makernote", "Sony1MltCsOld",MinoltaMakerNote::tagListCsStd }, { sony1MltCsNewIfdId,"Makernote", "Sony1MltCsNew",MinoltaMakerNote::tagListCsStd }, { sony2CsIfdId, "Makernote", "Sony2Cs", SonyMakerNote::tagListCs }, + { sony2Cs2IfdId, "Makernote", "Sony2Cs2", SonyMakerNote::tagListCs2 }, { lastIfdId, "(Last IFD info)", "(Last IFD item)", 0 } }; diff --git a/src/tiffcomposite.cpp b/src/tiffcomposite.cpp index dce30e84..10c5f952 100644 --- a/src/tiffcomposite.cpp +++ b/src/tiffcomposite.cpp @@ -160,12 +160,13 @@ namespace Exiv2 { { 320, "CanonFi" }, { 330, "SonyMinolta" }, { 331, "Sony1Cs" }, - { 332, "Sony2Cs" }, + { 332, "Sony1Cs2" }, { 333, "Sony1MltCsOld"}, { 334, "Sony1MltCsNew"}, { 335, "Sony1MltCs5D" }, { 336, "Sony1MltCs7D" }, - { 337, "Sony1Cs2" } + { 337, "Sony2Cs" }, + { 338, "Sony2Cs2" }, }; bool TiffGroupInfo::operator==(const uint16_t& group) const diff --git a/src/tiffimage.cpp b/src/tiffimage.cpp index f69671b8..3002d69c 100644 --- a/src/tiffimage.cpp +++ b/src/tiffimage.cpp @@ -794,6 +794,11 @@ namespace Exiv2 { { 146, ttSignedShort, 1 } // Exif.MinoltaCs5D.ColorTemperature }; + // Todo: Performance of the handling of Sony Camera Settings can be + // improved by defining all known array elements in the definitions + // sonyCsDef and sonyCs2Def below and enabling the 'concatenate gaps' + // setting in all four configurations. + //! Sony1 Camera Settings binary array - configuration extern const ArrayCfg sony1CsCfg = { Group::sony1cs, // Group for the elements @@ -805,6 +810,21 @@ namespace Exiv2 { false, // Don't concatenate gaps { 0, ttUnsignedShort, 1 } }; + //! Sony1 Camera Settings 2 binary array - configuration + extern const ArrayCfg sony1Cs2Cfg = { + Group::sony1cs2, // Group for the elements + bigEndian, // Big endian + ttUndefined, // Type for array entry and size element + notEncrypted, // Not encrypted + false, // No size element + false, // No fillers + false, // Don't concatenate gaps + { 0, ttUnsignedShort, 1 } + }; + //! Sony[12] Camera Settings binary array - definition + extern const ArrayDef sonyCsDef[] = { + { 12, ttSignedShort, 1 } // Exif.Sony[12]Cs.WhiteBalanceFineTune + }; //! Sony2 Camera Settings binary array - configuration extern const ArrayCfg sony2CsCfg = { Group::sony2cs, // Group for the elements @@ -816,27 +836,30 @@ namespace Exiv2 { false, // Don't concatenate gaps { 0, ttUnsignedShort, 1 } }; - //! Sony Camera Settings binary array - definition - extern const ArrayDef sonyCsDef[] = { - { 6, ttUnsignedShort, 1 }, // Exif.Sony1Cs.DriveMode - { 10, ttSignedShort, 1 } // Exif.Sony1Cs.WhiteBalanceFineTune - }; - - //! Sony1 Camera Settings 2 binary array - configuration - extern const ArrayCfg sony1Cs2Cfg = { - Group::sony1cs2, // Group for the elements - bigEndian, // Big endian - ttUndefined, // Type for array entry and size element - notEncrypted, // Not encrypted - false, // No size element - false, // No fillers - false, // Don't concatenate gaps + //! Sony2 Camera Settings 2 binary array - configuration + extern const ArrayCfg sony2Cs2Cfg = { + Group::sony2cs2, // Group for the elements + bigEndian, // Big endian + ttUndefined, // Type for array entry and size element + notEncrypted, // Not encrypted + false, // No size element + false, // No fillers + false, // Don't concatenate gaps { 0, ttUnsignedShort, 1 } }; - //! Sony Camera Settings 2 binary array - definition + //! Sony[12] Camera Settings 2 binary array - definition extern const ArrayDef sonyCs2Def[] = { - { 6, ttUnsignedShort, 1 }, // Exif.Sony1Cs2.DriveMode - { 10, ttSignedShort, 1 } // Exif.Sony1Cs2.WhiteBalanceFineTune + { 44, ttUnsignedShort, 1 } // Exif.Sony[12]Cs2.FocusMode + }; + //! Sony1 Camera Settings configurations and definitions + extern const ArraySet sony1CsSet[] = { + { sony1CsCfg, sonyCsDef, EXV_COUNTOF(sonyCsDef) }, + { sony1Cs2Cfg, sonyCs2Def, EXV_COUNTOF(sonyCs2Def) } + }; + //! Sony2 Camera Settings configurations and definitions + extern const ArraySet sony2CsSet[] = { + { sony2CsCfg, sonyCsDef, EXV_COUNTOF(sonyCsDef) }, + { sony2Cs2Cfg, sonyCs2Def, EXV_COUNTOF(sonyCs2Def) } }; //! Sony Minolta Camera Settings (old) binary array - configuration @@ -979,6 +1002,7 @@ namespace Exiv2 { { Tag::root, Group::sony1mcs5, Group::sonymltmn, 0x0114 }, { Tag::root, Group::sony2mn, Group::exif, 0x927c }, { Tag::root, Group::sony2cs, Group::sony2mn, 0x0114 }, + { Tag::root, Group::sony2cs2, Group::sony2mn, 0x0114 }, { Tag::root, Group::minoltamn, Group::exif, 0x927c }, { Tag::root, Group::minocso, Group::minoltamn, 0x0001 }, { Tag::root, Group::minocsn, Group::minoltamn, 0x0003 }, @@ -1335,7 +1359,7 @@ namespace Exiv2 { { Tag::all, Group::sigmamn, newTiffEntry }, // Sony1 makernote - { 0x0114, Group::sony1mn, EXV_BINARY_ARRAY(sony1CsCfg, sonyCsDef) }, + { 0x0114, Group::sony1mn, EXV_COMPLEX_BINARY_ARRAY(sony1CsSet, sonyCsSelector) }, { 0xb028, Group::sony1mn, newTiffSubIfd }, { Tag::next, Group::sony1mn, newTiffDirectory }, { Tag::all, Group::sony1mn, newTiffEntry }, @@ -1345,12 +1369,13 @@ namespace Exiv2 { { Tag::all, Group::sony1cs2, newTiffBinaryElement }, // Sony2 makernote - { 0x0114, Group::sony2mn, EXV_BINARY_ARRAY(sony2CsCfg, sonyCsDef) }, + { 0x0114, Group::sony1mn, EXV_COMPLEX_BINARY_ARRAY(sony2CsSet, sonyCsSelector) }, { Tag::next, Group::sony2mn, newTiffDirectory }, { Tag::all, Group::sony2mn, newTiffEntry }, // Sony2 camera settings { Tag::all, Group::sony2cs, newTiffBinaryElement }, + { Tag::all, Group::sony2cs2, newTiffBinaryElement }, // Sony1 Minolta makernote { 0x0001, Group::sonymltmn, EXV_SIMPLE_BINARY_ARRAY(sony1MCsoCfg) }, diff --git a/src/types.hpp b/src/types.hpp index 73bdd04b..d8f574d9 100644 --- a/src/types.hpp +++ b/src/types.hpp @@ -229,6 +229,7 @@ namespace Exiv2 { sony1CsIfdId, sony1Cs2IfdId, sony2CsIfdId, + sony2Cs2IfdId, sony1MltCs5DIfdId, sony1MltCs7DIfdId, sony1MltCsOldIfdId,