diff --git a/src/exif.cpp b/src/exif.cpp index 0011ac6f..838d17ff 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -689,7 +689,8 @@ namespace Exiv2 { subImage3Id, subImage4Id, panaRawIfdId, - ifd2Id + ifd2Id, + ifd3Id }; for (unsigned int i = 0; i < EXV_COUNTOF(filteredIfds); ++i) { #ifdef DEBUG diff --git a/src/tags.cpp b/src/tags.cpp index 6dcad4a5..21ceacba 100644 --- a/src/tags.cpp +++ b/src/tags.cpp @@ -102,6 +102,7 @@ namespace Exiv2 { { iopIfdId, "Iop", "Iop", ExifTags::iopTagList }, { ifd1Id, "IFD1", "Thumbnail", ExifTags::ifdTagList }, { ifd2Id, "IFD2", "Image2", ExifTags::ifdTagList }, + { ifd3Id, "IFD3", "Image3", ExifTags::ifdTagList }, { subImage1Id, "SubImage1", "SubImage1", ExifTags::ifdTagList }, { subImage2Id, "SubImage2", "SubImage2", ExifTags::ifdTagList }, { subImage3Id, "SubImage3", "SubImage3", ExifTags::ifdTagList }, @@ -1720,6 +1721,7 @@ namespace Exiv2 { case iopIfdId: case ifd1Id: case ifd2Id: + case ifd3Id: case subImage1Id: case subImage2Id: case subImage3Id: diff --git a/src/tiffcomposite.cpp b/src/tiffcomposite.cpp index a65f3ab3..e4a173f1 100644 --- a/src/tiffcomposite.cpp +++ b/src/tiffcomposite.cpp @@ -78,13 +78,14 @@ namespace Exiv2 { { 1, "Image" }, { 2, "Thumbnail" }, { 3, "Image2" }, - { 4, "Photo" }, - { 5, "GPSInfo" }, - { 6, "Iop" }, - { 7, "SubImage1" }, - { 8, "SubImage2" }, - { 9, "SubImage3" }, - { 10, "SubImage4" }, + { 4, "Image3" }, + { 5, "Photo" }, + { 6, "GPSInfo" }, + { 7, "Iop" }, + { 8, "SubImage1" }, + { 9, "SubImage2" }, + { 10, "SubImage3" }, + { 11, "SubImage4" }, { 64, "PanasonicRaw" }, { 256, "MakerNote" }, // 257 not needed (olympmn) @@ -754,11 +755,14 @@ namespace Exiv2 { TiffComponent* TiffBinaryArray::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot) { - assert(tiffPath.size() > 1); + pRoot_ = pRoot; + if (tiffPath.size() == 1) { + // An unknown complex binary array has no children and acts like a standard TIFF entry + return this; + } tiffPath.pop(); const TiffPathItem tpi = tiffPath.top(); // Initialize the binary array (if it is a complex array) - pRoot_ = pRoot; initialize(tpi.group()); TiffComponent* tc = 0; // Todo: Duplicates are not allowed! @@ -1021,6 +1025,8 @@ namespace Exiv2 { uint32_t TiffBinaryArray::doCount() const { + if (cfg() == 0) return TiffEntryBase::doCount(); + if (elements_.empty()) return 0; TypeId typeId = toTypeId(tiffType(), tag(), group()); @@ -1347,6 +1353,12 @@ namespace Exiv2 { uint32_t dataIdx, uint32_t& imageIdx) { + if (cfg() == 0) return TiffEntryBase::doWrite(ioWrapper, + byteOrder, + offset, + valueIdx, + dataIdx, + imageIdx); if (cfg()->byteOrder_ != invalidByteOrder) byteOrder = cfg()->byteOrder_; // Tags must be sorted in ascending order std::sort(elements_.begin(), elements_.end(), cmpTagLt); @@ -1656,6 +1668,8 @@ namespace Exiv2 { uint32_t TiffBinaryArray::doSize() const { + if (cfg() == 0) return TiffEntryBase::doSize(); + if (elements_.empty()) return 0; uint32_t idx = 0; diff --git a/src/tiffcomposite_int.hpp b/src/tiffcomposite_int.hpp index 14eb0114..53b543a1 100644 --- a/src/tiffcomposite_int.hpp +++ b/src/tiffcomposite_int.hpp @@ -89,13 +89,14 @@ namespace Exiv2 { const uint16_t ifd0 = 1; //!< Exif IFD0 const uint16_t ifd1 = 2; //!< Thumbnail IFD const uint16_t ifd2 = 3; //!< IFD2 - const uint16_t exif = 4; //!< Exif IFD - const uint16_t gps = 5; //!< GPS IFD - const uint16_t iop = 6; //!< Interoperability IFD - const uint16_t subimg1 = 7; //!< 1st TIFF SubIFD in IFD0 - const uint16_t subimg2 = 8; //!< 2nd TIFF SubIFD in IFD0 - const uint16_t subimg3 = 9; //!< 3rd TIFF SubIFD in IFD0 - const uint16_t subimg4 = 10; //!< 4th TIFF SubIFD in IFD0 + const uint16_t ifd3 = 4; //!< IFD3 + const uint16_t exif = 5; //!< Exif IFD + const uint16_t gps = 6; //!< GPS IFD + const uint16_t iop = 7; //!< Interoperability IFD + const uint16_t subimg1 = 8; //!< 1st TIFF SubIFD in IFD0 + const uint16_t subimg2 = 9; //!< 2nd TIFF SubIFD in IFD0 + const uint16_t subimg3 = 10; //!< 3rd TIFF SubIFD in IFD0 + const uint16_t subimg4 = 11; //!< 4th TIFF SubIFD in IFD0 const uint16_t panaraw = 64; //!< IFD0 of Panasonic RAW images const uint16_t mn = 256; //!< Makernote const uint16_t ignr = 511; //!< Read but do not decode @@ -1383,7 +1384,7 @@ namespace Exiv2 { // DATA const CfgSelFct cfgSelFct_; //!< Pointer to a function to determine which cfg to use (may be 0) const ArraySet* arraySet_; //!< Pointer to the array set, if any (may be 0) - const ArrayCfg* arrayCfg_; //!< Pointer to the array configuration (must not be 0) + const ArrayCfg* arrayCfg_; //!< Pointer to the array configuration (must not be 0, except for unrecognized complex binary arrays) const ArrayDef* arrayDef_; //!< Pointer to the array definition (may be 0) int defSize_; //!< Size of the array definition array (may be 0) int setSize_; //!< Size of the array set (may be 0) diff --git a/src/tiffimage.cpp b/src/tiffimage.cpp index f5bb0ebf..7866aab5 100644 --- a/src/tiffimage.cpp +++ b/src/tiffimage.cpp @@ -772,6 +772,7 @@ namespace Exiv2 { { Tag::root, Group::iop, Group::exif, 0xa005 }, { Tag::root, Group::ifd1, Group::ifd0, Tag::next }, { Tag::root, Group::ifd2, Group::ifd1, Tag::next }, + { Tag::root, Group::ifd3, Group::ifd2, Tag::next }, { Tag::root, Group::olymp1mn, Group::exif, 0x927c }, { Tag::root, Group::olymp2mn, Group::exif, 0x927c }, { Tag::root, Group::olympeq, Group::olymp2mn, 0x2010 }, @@ -932,14 +933,22 @@ namespace Exiv2 { { Tag::next, Group::ifd1, newTiffDirectory }, { Tag::all, Group::ifd1, newTiffEntry }, - // IFD2 (eg, in Pentax PEF files) + // IFD2 (eg, in Pentax PEF and Canon CR2 files) { 0x0111, Group::ifd2, newTiffImageData<0x0117, Group::ifd2> }, { 0x0117, Group::ifd2, newTiffImageSize<0x0111, Group::ifd2> }, { 0x0201, Group::ifd2, newTiffImageData<0x0202, Group::ifd2> }, { 0x0202, Group::ifd2, newTiffImageSize<0x0201, Group::ifd2> }, - { Tag::next, Group::ifd2, newTiffDirectory }, + { Tag::next, Group::ifd2, newTiffDirectory }, { Tag::all, Group::ifd2, newTiffEntry }, + // IFD3 (eg, in Canon CR2 files) + { 0x0111, Group::ifd3, newTiffImageData<0x0117, Group::ifd3> }, + { 0x0117, Group::ifd3, newTiffImageSize<0x0111, Group::ifd3> }, + { 0x0201, Group::ifd3, newTiffImageData<0x0202, Group::ifd3> }, + { 0x0202, Group::ifd3, newTiffImageSize<0x0201, Group::ifd3> }, + { Tag::next, Group::ifd3, newTiffDirectory }, + { Tag::all, Group::ifd3, newTiffEntry }, + // Olympus makernote - some Olympus cameras use Minolta structures // Todo: Adding such tags will not work (maybe result in a Minolta makernote), need separate groups { 0x0001, Group::olymp1mn, EXV_SIMPLE_BINARY_ARRAY(minoCsoCfg) }, diff --git a/src/types.hpp b/src/types.hpp index dec4e846..f10e5f5e 100644 --- a/src/types.hpp +++ b/src/types.hpp @@ -147,6 +147,7 @@ namespace Exiv2 { iopIfdId, ifd1Id, ifd2Id, + ifd3Id, subImage1Id, subImage2Id, subImage3Id,