[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:41:35 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=395b5b3
The following commit has been merged in the master branch:
commit 395b5b3a6ac0a221a5d0088d9eaaa69754e4d6a0
Author: Andreas Huggel <ahuggel at gmx.net>
Date: Sat May 1 04:57:44 2010 +0000
#611: Support for SonySR2 private data and encrypted sub-IFD, part 1, still experimental and incomplete.
---
src/makernote.cpp | 43 ++++++++++++++++++++++++++++++-
src/makernote_int.hpp | 12 +++++++++
src/sonymn.cpp | 30 ++++++++++++++++++++++
src/sonymn.hpp | 3 +++
src/tags.cpp | 42 +++++++++++++++++-------------
src/tiffcomposite.cpp | 3 ++-
src/tiffcomposite_int.hpp | 13 +++++++++-
src/tiffimage.cpp | 6 +++++
src/tiffvisitor.cpp | 65 +++++++++++++++++++++++++++++++++++++++++++++--
src/tiffvisitor_int.hpp | 2 ++
src/types.hpp | 1 +
11 files changed, 198 insertions(+), 22 deletions(-)
diff --git a/src/makernote.cpp b/src/makernote.cpp
index c373f6e..37457e5 100644
--- a/src/makernote.cpp
+++ b/src/makernote.cpp
@@ -46,13 +46,17 @@ EXIV2_RCSID("@(#) $Id$")
#include <string>
#include <cstring>
+#include <arpa/inet.h> // htonl (sony_decrypt)
+
// *****************************************************************************
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
+ //! Nikon en/decryption function (from dcraw)
void ncrypt(Exiv2::byte* pData, uint32_t size, uint32_t count, uint32_t serial);
+ //! Sony decryption function (from dcraw)
+ void sony_decrypt(uint32_t* data, long len, int start, int32_t key);
}
// *****************************************************************************
@@ -891,6 +895,26 @@ namespace Exiv2 {
}
return idx;
}
+
+ DataBuf sonyDecrypt(const byte* pData, uint32_t size, TiffComponent* const pRoot, ByteOrder byteOrder)
+ {
+ DataBuf buf;
+ // Find Exif.SonySR2.SR2SubIFDKey
+ TiffFinder finder(0x7221, Group::sonysr2);
+ pRoot->accept(finder);
+ TiffEntryBase* te = dynamic_cast<TiffEntryBase*>(finder.result());
+ if (!(te && te->pValue() && te->pValue()->size() == 4)) return buf;
+ int32_t key = getLong(te->pData(), byteOrder);
+
+ // Todo: remove debug output
+ std::cout << "key = " << key << "
";
+
+ buf.alloc(size);
+ memcpy(buf.pData_, pData, buf.size_);
+ sony_decrypt((uint32_t*)buf.pData_, buf.size_/4, 1, key);
+ return buf;
+ }
+
}} // namespace Internal, Exiv2
// *****************************************************************************
@@ -905,6 +929,23 @@ namespace {
return te->pValue()->toString();
}
+ void sony_decrypt(uint32_t* data, long len, int start, int32_t key)
+ {
+ static uint32_t pad[128], p;
+
+ if (start) {
+ for (p=0; p < 4; p++)
+ pad[p] = key = key * 48828125 + 1;
+ pad[3] = pad[3] << 1 | (pad[0]^pad[2]) >> 31;
+ for (p=4; p < 127; p++)
+ pad[p] = (pad[p-4]^pad[p-2]) << 1 | (pad[p-3]^pad[p-1]) >> 31;
+ for (p=0; p < 127; p++)
+ pad[p] = htonl(pad[p]);
+ }
+ while (len--)
+ *data++ ^= pad[p++ & 127] = pad[(p+1) & 127] ^ pad[(p+65) & 127];
+ }
+
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 f333e09..6a87f12 100644
--- a/src/makernote_int.hpp
+++ b/src/makernote_int.hpp
@@ -118,6 +118,7 @@ namespace Exiv2 {
const uint16_t sony1mcs7 = 336; //!< Minolta D7 Camera Settings (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)
+ const uint16_t sonysr2 = 339; //!< Sony SR2 private tags (in a sub-IFD of Exif.Image.DNGPrivateData)
}
// *****************************************************************************
@@ -665,6 +666,17 @@ namespace Exiv2 {
int sonyCsSelector(uint16_t tag, const byte* pData, uint32_t size, TiffComponent* const pRoot);
/*!
+ @brief Decrypt Sony data.
+
+ @param pData Pointer to the start of the data to decrypt.
+ @param size Size of the data buffer.
+ @param pRoot Pointer to the root element of the composite.
+ @return Decrypted data. Ownership of the memory is passed to the caller.
+ The buffer may be empty in case no decryption key was found.
+ */
+ DataBuf sonyDecrypt(const byte* pData, uint32_t size, TiffComponent* const pRoot, ByteOrder byteOrder);
+
+ /*!
@brief Function to select cfg + def of a Nikon complex binary array.
@param tag Tag number of the binary array
diff --git a/src/sonymn.cpp b/src/sonymn.cpp
index 13d015f..bb2dbe3 100644
--- a/src/sonymn.cpp
+++ b/src/sonymn.cpp
@@ -664,4 +664,34 @@ namespace Exiv2 {
{
return tagInfoCs2_;
}
+
+ const TagInfo SonyMakerNote::tagInfoSr2_[] = {
+ TagInfo(0x7200, "SR2SubIFDOffset", N_("SR2 Sub-IFD Offset"),
+ N_("SR2 sub-IFD offset"),
+ sonySr2IfdId, makerTags, unsignedShort, printValue),
+ TagInfo(0x7201, "SR2SubIFDLength", N_("SR2 Sub-IFD Length"),
+ N_("SR2 sub-IFD length"),
+ sonySr2IfdId, makerTags, unsignedShort, printValue),
+ TagInfo(0x7221, "SR2SubIFDKey", N_("SR2 Sub-IFD Key"),
+ N_("SR2 sub-IFD key"),
+ sonySr2IfdId, makerTags, unsignedShort, printValue),
+ TagInfo(0x7240, "IDC_IFD", N_("IDC IFD"),
+ N_("IDC IFD"),
+ sonySr2IfdId, makerTags, unsignedShort, printValue),
+ TagInfo(0x7241, "IDC2_IFD", N_("IDC2 IFD"),
+ N_("IDC2 IFD"),
+ sonySr2IfdId, makerTags, unsignedShort, printValue),
+ TagInfo(0x7250, "MRWInfo", N_("MRW Info"),
+ N_("MRW info"),
+ sonySr2IfdId, makerTags, unsignedShort, printValue),
+ // End of list marker
+ TagInfo(0xffff, "(UnknownSonySr2Tag)", "(UnknownSonySr2Tag)",
+ N_("Unknown Sony SR2 Private tag"),
+ sonySr2IfdId, makerTags, invalidTypeId, printValue)
+ };
+
+ const TagInfo* SonyMakerNote::tagListSr2()
+ {
+ return tagInfoSr2_;
+ }
} // namespace Exiv2
diff --git a/src/sonymn.hpp b/src/sonymn.hpp
index ecf8675..cac4890 100644
--- a/src/sonymn.hpp
+++ b/src/sonymn.hpp
@@ -59,6 +59,8 @@ namespace Exiv2 {
static const TagInfo* tagListCs();
//! Return read-only list of built-in Sony Standard Camera Settings version 2 tags
static const TagInfo* tagListCs2();
+ //! Return read-only list of built-in Sony SR2 private tags (found in a sub-IFD of Exif.Image.DNGPrivateData)
+ static const TagInfo* tagListSr2();
//! @name Print functions for Sony %MakerNote tags
//@{
@@ -72,6 +74,7 @@ namespace Exiv2 {
static const TagInfo tagInfo_[];
static const TagInfo tagInfoCs_[];
static const TagInfo tagInfoCs2_[];
+ static const TagInfo tagInfoSr2_[];
}; // class SonyMakerNote
} // namespace Exiv2
diff --git a/src/tags.cpp b/src/tags.cpp
index 6455821..c740168 100644
--- a/src/tags.cpp
+++ b/src/tags.cpp
@@ -181,6 +181,7 @@ namespace Exiv2 {
{ sony1MltCsA100IfdId,"Makernote","Sony1MltCsA100",MinoltaMakerNote::tagListCsA100},
{ sony2CsIfdId, "Makernote", "Sony2Cs", SonyMakerNote::tagListCs },
{ sony2Cs2IfdId, "Makernote", "Sony2Cs2", SonyMakerNote::tagListCs2 },
+ { sonySr2IfdId, "Makernote", "SonySR2", SonyMakerNote::tagListSr2 },
{ lastIfdId, "(Last IFD info)", "(Last IFD item)", 0 }
};
@@ -252,7 +253,7 @@ namespace Exiv2 {
//! Compression, tag 0x0103
extern const TagDetails exifCompression[] = {
{ 1, N_("Uncompressed") },
- { 2, N_("CCITT RLE") },
+ { 2, N_("CCITT 1D") },
{ 3, N_("T4/Group 3 Fax") },
{ 4, N_("T6/Group 4 Fax") },
{ 5, N_("LZW") },
@@ -261,24 +262,31 @@ namespace Exiv2 {
{ 8, N_("Adobe Deflate") },
{ 9, N_("JBIG B&W") },
{ 10, N_("JBIG Color") },
- { 32766, N_("Next 2-bits RLE") },
+ { 99, N_("JPEG") },
+ { 262, N_("Kodak 262") },
+ { 32766, N_("Next") },
+ { 32767, N_("Sony ARW Compressed") },
{ 32769, N_("Epson ERF Compressed") },
- { 32771, N_("CCITT RLE 1-word") },
- { 32773, N_("PackBits (Macintosh RLE)") },
- { 32809, N_("Thunderscan RLE") },
- { 32895, N_("IT8 CT Padding") },
- { 32896, N_("IT8 Linework RLE") },
- { 32897, N_("IT8 Monochrome Picture") },
- { 32898, N_("IT8 Binary Lineart") },
- { 32908, N_("Pixar Film (10-bits LZW)") },
- { 32909, N_("Pixar Log (11-bits ZIP)") },
- { 32946, N_("Pixar Deflate") },
- { 32947, N_("Kodak DCS Encoding") },
- { 34661, N_("ISO JBIG") },
- { 34676, N_("SGI Log Luminance RLE") },
- { 34677, N_("SGI Log 24-bits packed") },
- { 34712, N_("Leadtools JPEG 2000") },
+ { 32771, N_("CCIRLEW") },
+ { 32773, N_("PackBits") },
+ { 32809, N_("Thunderscan") },
+ { 32867, N_("Kodak KDC Compressed") },
+ { 32895, N_("IT8CTPAD") },
+ { 32896, N_("IT8LW") },
+ { 32897, N_("IT8MP") },
+ { 32898, N_("IT8BL") },
+ { 32908, N_("PixarFilm") },
+ { 32909, N_("PixarLog") },
+ { 32946, N_("Deflate") },
+ { 32947, N_("DCS") },
+ { 34661, N_("JBIG") },
+ { 34676, N_("SGILog") },
+ { 34677, N_("SGILog24") },
+ { 34712, N_("JPEG 2000") },
{ 34713, N_("Nikon NEF Compressed") },
+ { 34718, N_("Microsoft Document Imaging (MDI) Binary Level Codec") },
+ { 34719, N_("Microsoft Document Imaging (MDI) Progressive Transform Codec") },
+ { 34720, N_("Microsoft Document Imaging (MDI) Vector") },
{ 65000, N_("Kodak DCR Compressed") },
{ 65535, N_("Pentax PEF Compressed") }
};
diff --git a/src/tiffcomposite.cpp b/src/tiffcomposite.cpp
index 15c8871..0839060 100644
--- a/src/tiffcomposite.cpp
+++ b/src/tiffcomposite.cpp
@@ -166,7 +166,8 @@ namespace Exiv2 {
{ 335, "Sony1MltCsA100" },
{ 336, "Sony1MltCs7D" },
{ 337, "Sony2Cs" },
- { 338, "Sony2Cs2" }
+ { 338, "Sony2Cs2" },
+ { 339, "SonySR2" }
};
bool TiffGroupInfo::operator==(const uint16_t& group) const
diff --git a/src/tiffcomposite_int.hpp b/src/tiffcomposite_int.hpp
index 19fc4f1..208c87e 100644
--- a/src/tiffcomposite_int.hpp
+++ b/src/tiffcomposite_int.hpp
@@ -894,7 +894,6 @@ namespace Exiv2 {
component of the TIFF tree.
*/
class TiffDirectory : public TiffComponent {
- friend class TiffEncoder;
public:
//! @name Creators
//@{
@@ -905,10 +904,22 @@ namespace Exiv2 {
virtual ~TiffDirectory();
//@}
+ //! @name Manipulators
+ //@{
+ //! Begin of the components
+ Components::iterator begin() { return components_.begin(); }
+ //! End of the components
+ Components::iterator end() { return components_.end(); }
+ //@}
+
//! @name Accessors
//@{
//! Return true if the directory has a next pointer
bool hasNext() const { return hasNext_; }
+ //! Begin of the components
+ Components::const_iterator begin() const { return components_.begin(); }
+ //! End of the components
+ Components::const_iterator end() const { return components_.end(); }
//@}
protected:
diff --git a/src/tiffimage.cpp b/src/tiffimage.cpp
index 1630f8c..619b3c9 100644
--- a/src/tiffimage.cpp
+++ b/src/tiffimage.cpp
@@ -941,6 +941,7 @@ namespace Exiv2 {
{ Tag::root, Group::subimg9, Group::ifd0, 0x014a },
{ Tag::root, Group::exif, Group::ifd0, 0x8769 },
{ Tag::root, Group::gps, Group::ifd0, 0x8825 },
+ { Tag::root, Group::sonysr2, Group::ifd0, 0xc634 },
{ Tag::root, Group::iop, Group::exif, 0xa005 },
{ Tag::root, Group::ifd1, Group::ifd0, Tag::next },
{ Tag::root, Group::ifd2, Group::ifd1, Tag::next },
@@ -1049,6 +1050,7 @@ namespace Exiv2 {
{ 0x0201, Group::ifd0, newTiffImageData<0x0202, Group::ifd0> },
{ 0x0202, Group::ifd0, newTiffImageSize<0x0201, Group::ifd0> },
{ 0x014a, Group::ifd0, newTiffSubIfd<Group::subimg1> },
+ { 0xc634, Group::ifd0, newTiffSubIfd<Group::sonysr2> }, // Todo: Should be a new TIFF component
{ Tag::next, Group::ifd0, newTiffDirectory<Group::ifd1> },
{ Tag::all, Group::ifd0, newTiffEntry },
@@ -1364,6 +1366,10 @@ namespace Exiv2 {
{ Tag::next, Group::sigmamn, newTiffDirectory<Group::ignr> },
{ Tag::all, Group::sigmamn, newTiffEntry },
+ // Sony SR2 Private tags
+ { Tag::next, Group::sonysr2, newTiffDirectory<Group::ignr> },
+ { Tag::all, Group::sonysr2, newTiffEntry },
+
// Sony1 makernote
{ 0x0114, Group::sony1mn, EXV_COMPLEX_BINARY_ARRAY(sony1CsSet, sonyCsSelector) },
{ 0xb028, Group::sony1mn, newTiffSubIfd<Group::sonymltmn> },
diff --git a/src/tiffvisitor.cpp b/src/tiffvisitor.cpp
index 14368bd..1aae237 100644
--- a/src/tiffvisitor.cpp
+++ b/src/tiffvisitor.cpp
@@ -683,8 +683,7 @@ namespace Exiv2 {
assert(object != 0);
byte* p = object->start() + 2;
- for (TiffDirectory::Components::iterator i = object->components_.begin();
- i != object->components_.end(); ++i) {
+ for (TiffDirectory::Components::iterator i = object->begin(); i != object->end(); ++i) {
p += updateDirEntry(p, byteOrder(), *i);
}
}
@@ -1338,11 +1337,73 @@ namespace Exiv2 {
} // TiffReader::visitDirectory
+ void TiffReader::visitDirectoryEnd(TiffDirectory* object)
+ {
+ assert(object != 0);
+
+ if (!(object->tag() == 0xc634 && object->group() == Group::sonysr2)) return;
+ TiffEntryBase* te = 0;
+ int32_t offset = 0;
+ uint32_t size = 0;
+ for (TiffComponent::Components::const_iterator i = object->begin(); i != object->end(); ++i) {
+ switch ((*i)->tag()) {
+ case 0x7200:
+ te = dynamic_cast<TiffEntryBase*>(*i);
+ if (te && te->pValue()) offset = te->pValue()->toLong();
+ break;
+ case 0x7201:
+ te = dynamic_cast<TiffEntryBase*>(*i);
+ if (te && te->pValue()) size = te->pValue()->toLong();
+ break;
+ }
+ }
+ if (!(offset && size)) return;
+
+ // Todo: remove debug output
+ std::cout << "offset = " << offset << "
"
+ << "size = " << size << "
";
+
+ DataBuf buf = sonyDecrypt(pData_ + baseOffset() + offset, size, object, byteOrder());
+
+ // Todo: remove debug output
+ hexdump(std::cout, buf.pData_, EXV_MIN(100, buf.size_));
+
+ } // TiffReader::visitDirectoryEnd
+
void TiffReader::visitSubIfd(TiffSubIfd* object)
{
assert(object != 0);
readTiffEntry(object);
+
+// <hack>
+// Todo: Merge with the original section
+ if (object->tiffType() == ttUnsignedByte && object->count() == 4) {
+ int32_t offset = getLong(object->pData(), byteOrder());
+
+ // Todo: remove debug output
+ std::cout << "baseOffset = " << baseOffset() << ", offset = " << offset << "
";
+
+ if ( baseOffset() + offset > size_
+ || static_cast<int32_t>(baseOffset()) + offset < 0) {
+#ifndef SUPPRESS_WARNINGS
+ std::cerr << "Error: "
+ << "Directory " << tiffGroupName(object->group())
+ << ", entry 0x" << std::setw(4)
+ << std::setfill('0') << std::hex << object->tag()
+ << " Sub-IFD pointer " << 1
+ << " is out of bounds; ignoring it.
";
+#endif
+ return;
+ }
+ TiffComponent::AutoPtr td(new TiffDirectory(object->tag(),
+ object->newGroup_));
+ td->setStart(pData_ + baseOffset() + offset);
+ object->addChild(td);
+ return;
+ }
+// </hack>
+
if ( (object->tiffType() == ttUnsignedLong || object->tiffType() == ttSignedLong
|| object->tiffType() == ttTiffIfd)
&& object->count() >= 1) {
diff --git a/src/tiffvisitor_int.hpp b/src/tiffvisitor_int.hpp
index 8b3c55b..e313415 100644
--- a/src/tiffvisitor_int.hpp
+++ b/src/tiffvisitor_int.hpp
@@ -665,6 +665,8 @@ namespace Exiv2 {
virtual void visitSizeEntry(TiffSizeEntry* object);
//! Read a TIFF directory from the data buffer
virtual void visitDirectory(TiffDirectory* object);
+ //! Additional read operations for a TIFF directory after the directory is read
+ virtual void visitDirectoryEnd(TiffDirectory* object);
//! Read a TIFF sub-IFD from the data buffer
virtual void visitSubIfd(TiffSubIfd* object);
//! Read a TIFF makernote entry from the data buffer
diff --git a/src/types.hpp b/src/types.hpp
index 18652ba..7b88bdb 100644
--- a/src/types.hpp
+++ b/src/types.hpp
@@ -234,6 +234,7 @@ namespace Exiv2 {
sony1MltCsOldIfdId,
sony1MltCsNewIfdId,
sony1MltCsA100IfdId,
+ sonySr2IfdId,
lastIfdId
};
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list