[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a
Maximiliano Curia
maxy at moszumanska.debian.org
Thu Jul 13 17:37:06 UTC 2017
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=c99597c
The following commit has been merged in the master branch:
commit c99597ccd7b8479e2723672849ce4a50703d5579
Author: Andreas Huggel <ahuggel at gmx.net>
Date: Wed Apr 20 18:16:29 2005 +0000
Added basic Sony makernote, decoded Exif.CanonCs2.ISOSpeed (from Exiftool) and Exif.Nikon3.LensFStops (from Robert Rottmerhusen)
---
config/config.mk.in | 2 +-
src/Makefile | 4 +-
src/canonmn.cpp | 58 ++++++++++++++++-
src/canonmn.hpp | 2 +
src/ifd.cpp | 79 ++++++++++++----------
src/ifd.hpp | 12 ++--
src/makernote.cpp | 11 +++-
src/makernote.hpp | 5 +-
src/nikonmn.cpp | 14 +++-
src/nikonmn.hpp | 9 ++-
src/sonymn.cpp | 141 ++++++++++++++++++++++++++++++++++++++++
src/{sigmamn.hpp => sonymn.hpp} | 57 +++++++---------
src/tags.cpp | 1 +
src/types.hpp | 2 +-
test/data/exifdata-test.out | 16 ++---
test/data/exiv2-test.out | 6 +-
test/data/write2-test.out | 4 +-
17 files changed, 324 insertions(+), 99 deletions(-)
diff --git a/config/config.mk.in b/config/config.mk.in
index b4732fd..0ed5cbe 100644
--- a/config/config.mk.in
+++ b/config/config.mk.in
@@ -63,7 +63,7 @@ CPPFLAGS = @CPPFLAGS@
CXXDEP = $(CXX) -MM
# Linker flags
-LDFLAGS = @LDFLAGS@
+LDFLAGS = @LDFLAGS@ -lm
# Suffix of executables
EXEEXT := @EXEEXT@
diff --git a/src/Makefile b/src/Makefile
index bd49430..ccec948 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -53,8 +53,8 @@ CCHDR = exv_conf.h exv_msvc.h rcsid.hpp
# Add library C++ source files to this list
CCSRC = basicio.cpp canonmn.cpp datasets.cpp error.cpp exif.cpp futils.cpp \
fujimn.cpp ifd.cpp image.cpp iptc.cpp jpgimage.cpp makernote.cpp \
- metadatum.cpp nikonmn.cpp olympusmn.cpp sigmamn.cpp tags.cpp types.cpp \
- value.cpp
+ metadatum.cpp nikonmn.cpp olympusmn.cpp sigmamn.cpp sonymn.cpp \
+ tags.cpp types.cpp value.cpp
# Add source files of simple applications to this list
BINSRC = addmoddel.cpp dataarea-test.cpp exifcomment.cpp exifdata-test.cpp \
diff --git a/src/canonmn.cpp b/src/canonmn.cpp
index 9c4aa60..7d2ee9c 100644
--- a/src/canonmn.cpp
+++ b/src/canonmn.cpp
@@ -47,11 +47,33 @@ EXIV2_RCSID("@(#) $Id$");
#include <algorithm>
#include <cassert>
#include <cstring>
+#include <cmath>
// Define DEBUG_MAKERNOTE to output debug information to std::cerr
#undef DEBUG_MAKERNOTE
// *****************************************************************************
+// local declarations
+namespace {
+ /*
+ @brief Convert Canon hex-based EV (modulo 0x20) to real number
+ Ported from Phil Harvey's Image::ExifTool::Canon::CanonEv
+ by Will Stokes
+
+ 0x00 -> 0
+ 0x0c -> 0.33333
+ 0x10 -> 0.5
+ 0x14 -> 0.66666
+ 0x20 -> 1
+ ..
+ 160 -> 5
+ 128 -> 4
+ 143 -> 4.46875
+ */
+ float canonEv(long val);
+}
+
+// *****************************************************************************
// class member definitions
namespace Exiv2 {
@@ -123,7 +145,7 @@ namespace Exiv2 {
// Canon Camera Settings 2 Tag Info
const TagInfo CanonMakerNote::tagInfoCs2_[] = {
TagInfo(0x0001, "0x0001", "Unknown", canonCs2IfdId, makerTags, unsignedShort, printValue),
- TagInfo(0x0002, "0x0002", "Unknown", canonCs2IfdId, makerTags, unsignedShort, printValue),
+ TagInfo(0x0002, "ISOSpeed", "ISO speed used", canonCs2IfdId, makerTags, unsignedShort, printCs20x0002),
TagInfo(0x0003, "0x0003", "Unknown", canonCs2IfdId, makerTags, unsignedShort, printValue),
TagInfo(0x0004, "0x0004", "Unknown", canonCs2IfdId, makerTags, unsignedShort, printValue),
TagInfo(0x0005, "0x0005", "Unknown", canonCs2IfdId, makerTags, unsignedShort, printValue),
@@ -741,6 +763,13 @@ namespace Exiv2 {
return os;
}
+ std::ostream& CanonMakerNote::printCs20x0002(std::ostream& os,
+ const Value& value)
+ {
+ // Ported from Exiftool by Will Stokes
+ return os << exp(canonEv(value.toLong()) * log(2.0)) * 100.0 / 32.0;
+ }
+
std::ostream& CanonMakerNote::printCs20x0007(std::ostream& os,
const Value& value)
{
@@ -857,3 +886,30 @@ namespace Exiv2 {
}
} // namespace Exiv2
+
+// *****************************************************************************
+// local definitions
+namespace {
+
+ float canonEv(long val)
+ {
+ // temporarily remove sign
+ int sign = 1;
+ if (val < 0) {
+ sign = -1;
+ val = -val;
+ }
+ // remove fraction
+ float frac = val & 0x1f;
+ val -= long(frac);
+ // convert 1/3 (0x0c) and 2/3 (0x14) codes
+ if (frac == 0x0c) {
+ frac = 32.0 / 3;
+ }
+ else if (frac == 0x14) {
+ frac = 64.0 / 3;
+ }
+ return sign * (val + frac) / 32.0;
+ }
+
+}
diff --git a/src/canonmn.hpp b/src/canonmn.hpp
index 8cd5624..54188fb 100644
--- a/src/canonmn.hpp
+++ b/src/canonmn.hpp
@@ -175,6 +175,8 @@ namespace Exiv2 {
static std::ostream& printCs1Lnh(std::ostream& os, const Value& value);
//! Camera lens information
static std::ostream& printCs1Lens(std::ostream& os, const Value& value);
+ //! ISO speed used
+ static std::ostream& printCs20x0002(std::ostream& os, const Value& value);
//! White balance
static std::ostream& printCs20x0007(std::ostream& os, const Value& value);
//! Sequence number
diff --git a/src/ifd.cpp b/src/ifd.cpp
index a3d36fe..72ec0ed 100644
--- a/src/ifd.cpp
+++ b/src/ifd.cpp
@@ -254,7 +254,7 @@ namespace Exiv2 {
Ifd::Ifd(IfdId ifdId)
: alloc_(true), ifdId_(ifdId), pBase_(0), offset_(0),
- dataOffset_(0), pNext_(0), next_(0)
+ dataOffset_(0), hasNext_(true), pNext_(0), next_(0)
{
pNext_ = new byte[4];
memset(pNext_, 0x0, 4);
@@ -262,17 +262,17 @@ namespace Exiv2 {
Ifd::Ifd(IfdId ifdId, long offset)
: alloc_(true), ifdId_(ifdId), pBase_(0), offset_(offset),
- dataOffset_(0), pNext_(0), next_(0)
+ dataOffset_(0), hasNext_(true), pNext_(0), next_(0)
{
pNext_ = new byte[4];
memset(pNext_, 0x0, 4);
}
- Ifd::Ifd(IfdId ifdId, long offset, bool alloc)
+ Ifd::Ifd(IfdId ifdId, long offset, bool alloc, bool hasNext)
: alloc_(alloc), ifdId_(ifdId), pBase_(0), offset_(offset),
- dataOffset_(0), pNext_(0), next_(0)
+ dataOffset_(0), hasNext_(hasNext), pNext_(0), next_(0)
{
- if (alloc_) {
+ if (alloc_ && hasNext_) {
pNext_ = new byte[4];
memset(pNext_, 0x0, 4);
}
@@ -281,15 +281,15 @@ namespace Exiv2 {
Ifd::~Ifd()
{
// do not delete pBase_
- if (alloc_) delete[] pNext_;
+ if (alloc_ && hasNext_) delete[] pNext_;
}
Ifd::Ifd(const Ifd& rhs)
: alloc_(rhs.alloc_), entries_(rhs.entries_), ifdId_(rhs.ifdId_),
- pBase_(rhs.pBase_), offset_(rhs.offset_),
- dataOffset_(rhs.dataOffset_), pNext_(rhs.pNext_), next_(rhs.next_)
+ pBase_(rhs.pBase_), offset_(rhs.offset_), dataOffset_(rhs.dataOffset_),
+ hasNext_(rhs.hasNext_), pNext_(rhs.pNext_), next_(rhs.next_)
{
- if (alloc_) {
+ if (alloc_ && hasNext_) {
pNext_ = new byte[4];
memset(pNext_, 0x0, 4);
if (rhs.pNext_) memcpy(pNext_, rhs.pNext_, 4);
@@ -331,7 +331,7 @@ namespace Exiv2 {
o += 12;
}
}
- if (rc == 0) {
+ if (rc == 0 && hasNext_) {
if (len < o + 4) {
// Todo: How to handle debug output like this
std::cerr << "Error: " << ExifTags::ifdName(ifdId_)
@@ -364,7 +364,8 @@ namespace Exiv2 {
if (offset_ == 0) {
// Set the 'guessed' IFD offset
offset_ = i->offset_
- - (2 + 12 * static_cast<long>(preEntries.size()) + 4);
+ - (2 + 12 * static_cast<long>(preEntries.size())
+ + (hasNext_ ? 4 : 0));
}
// Set the offset of the first data entry outside of the IFD
if (i->offset_ - offset_ >= len) {
@@ -523,14 +524,16 @@ namespace Exiv2 {
o += 12;
}
- // Add the offset to the next IFD to the data buffer
- if (pNext_) {
- memcpy(buf + o, pNext_, 4);
- }
- else {
- memset(buf + o, 0x0, 4);
+ if (hasNext_) {
+ // Add the offset to the next IFD to the data buffer
+ if (pNext_) {
+ memcpy(buf + o, pNext_, 4);
+ }
+ else {
+ memset(buf + o, 0x0, 4);
+ }
+ o += 4;
}
- o += 4;
// Add the data of all IFD entries to the data buffer
for (i = b; i != e; ++i) {
@@ -554,23 +557,27 @@ namespace Exiv2 {
void Ifd::clear()
{
entries_.clear();
- if (alloc_) {
- memset(pNext_, 0x0, 4);
- }
- else {
- pBase_ = 0;
- pNext_ = 0;
- }
- next_ = 0;
offset_ = 0;
dataOffset_ = 0;
+ if (hasNext_) {
+ if (alloc_) {
+ memset(pNext_, 0x0, 4);
+ }
+ else {
+ pBase_ = 0;
+ pNext_ = 0;
+ }
+ next_ = 0;
+ }
} // Ifd::clear
void Ifd::setNext(uint32_t next, ByteOrder byteOrder)
{
- assert(pNext_);
- ul2Data(pNext_, next, byteOrder);
- next_ = next;
+ if (hasNext_) {
+ assert(pNext_);
+ ul2Data(pNext_, next, byteOrder);
+ next_ = next;
+ }
}
void Ifd::add(const Entry& entry)
@@ -605,7 +612,9 @@ namespace Exiv2 {
for (iterator pos = begin(); pos != end; ++pos) {
pos->updateBase(pBase_, pNewBase);
}
- pNext_ = pNext_ - pBase_ + pNewBase;
+ if (hasNext_) {
+ pNext_ = pNext_ - pBase_ + pNewBase;
+ }
pOld = pBase_;
pBase_ = pNewBase;
}
@@ -615,7 +624,7 @@ namespace Exiv2 {
long Ifd::size() const
{
if (entries_.size() == 0 && next_ == 0) return 0;
- return static_cast<long>(2 + 12 * entries_.size() + 4);
+ return static_cast<long>(2 + 12 * entries_.size() + (hasNext_ ? 4 : 0));
}
long Ifd::dataSize() const
@@ -670,9 +679,11 @@ namespace Exiv2 {
<< " " << offset.str()
<< "
";
}
- os << prefix << "Next IFD: 0x"
- << std::setw(8) << std::setfill('0') << std::hex
- << std::right << next() << "
";
+ if (hasNext_) {
+ os << prefix << "Next IFD: 0x"
+ << std::setw(8) << std::setfill('0') << std::hex
+ << std::right << next() << "
";
+ }
// Print data of IFD entries
for (i = b; i != e; ++i) {
if (i->size() > 4) {
diff --git a/src/ifd.hpp b/src/ifd.hpp
index f0c5174..6204c37 100644
--- a/src/ifd.hpp
+++ b/src/ifd.hpp
@@ -359,10 +359,11 @@ namespace Exiv2 {
Ifd(IfdId ifdId, long offset);
/*!
@brief Constructor. Allows to set the IFD identifier, offset of the
- IFD from the start of TIFF header and choose whether or not
- memory management is required for the Entries.
+ IFD from the start of TIFF header, choose whether or not
+ memory management is required for the Entries, and decide
+ whether this IFD has a next pointer.
*/
- Ifd(IfdId ifdId, long offset, bool alloc);
+ Ifd(IfdId ifdId, long offset, bool alloc, bool hasNext =true);
//! Copy constructor
Ifd(const Ifd& rhs);
//! Destructor
@@ -424,7 +425,8 @@ namespace Exiv2 {
void clear();
/*!
@brief Set the offset of the next IFD. Byte order is needed to update
- the underlying data buffer in non-alloc mode.
+ the underlying data buffer in non-alloc mode. This method only
+ has an effect if the IFD was instantiated with hasNext = true.
*/
void setNext(uint32_t next, ByteOrder byteOrder);
/*!
@@ -567,6 +569,8 @@ namespace Exiv2 {
long offset_;
//! Offset of the first data entry outside of the IFD directory
long dataOffset_;
+ //! Indicates whether the IFD has a next pointer
+ bool hasNext_;
//! Pointer to the offset of next IFD from the start of the TIFF header
byte* pNext_;
//! The offset of the next IFD as data value (always in sync with *pNext_)
diff --git a/src/makernote.cpp b/src/makernote.cpp
index 1f710f7..8886fb3 100644
--- a/src/makernote.cpp
+++ b/src/makernote.cpp
@@ -66,9 +66,9 @@ namespace Exiv2 {
return AutoPtr(clone_());
}
- IfdMakerNote::IfdMakerNote(IfdId ifdId, bool alloc)
+ IfdMakerNote::IfdMakerNote(IfdId ifdId, bool alloc, bool hasNext)
: MakerNote(alloc),
- absOffset_(true), adjOffset_(0), ifd_(ifdId, 0, alloc)
+ absOffset_(true), adjOffset_(0), ifd_(ifdId, 0, alloc, hasNext)
{
}
@@ -104,7 +104,12 @@ namespace Exiv2 {
}
if (rc == 0) {
// IfdMakerNote currently does not support multiple IFDs
- if (ifd_.next() != 0) rc = 3;
+ if (ifd_.next() != 0) {
+#ifdef DEBUG_MAKERNOTE
+ std::cerr << "Makernote IFD has a next pointer != 0 (rc = 3)
";
+#endif
+ rc = 3;
+ }
}
#ifdef DEBUG_MAKERNOTE
hexdump(std::cerr, buf, len, offset);
diff --git a/src/makernote.hpp b/src/makernote.hpp
index 6dd0b89..fde5975 100644
--- a/src/makernote.hpp
+++ b/src/makernote.hpp
@@ -242,9 +242,10 @@ namespace Exiv2 {
//@{
/*!
@brief Constructor. Requires an %Ifd id and allows to choose whether
- or not memory management is needed for the Entries.
+ or not memory management is needed for the Entries and whether
+ the IFD has a next pointer.
*/
- explicit IfdMakerNote(IfdId ifdId, bool alloc =true);
+ explicit IfdMakerNote(IfdId ifdId, bool alloc =true, bool hasNext =true);
//! Copy constructor
IfdMakerNote(const IfdMakerNote& rhs);
//! Virtual destructor
diff --git a/src/nikonmn.cpp b/src/nikonmn.cpp
index 61e7a83..4f8d460 100644
--- a/src/nikonmn.cpp
+++ b/src/nikonmn.cpp
@@ -401,7 +401,7 @@ namespace Exiv2 {
TagInfo(0x0088, "AFFocusPos", "AF focus position", nikon3IfdId, makerTags, undefined, print0x0088),
TagInfo(0x0089, "Bracketing", "Bracketing", nikon3IfdId, makerTags, unsignedShort, print0x0089),
TagInfo(0x008a, "0x008a", "Unknown", nikon3IfdId, makerTags, unsignedShort, printValue),
- TagInfo(0x008b, "0x008b", "Unknown", nikon3IfdId, makerTags, undefined, printValue),
+ TagInfo(0x008b, "LensFStops", "Number of lens stops", nikon3IfdId, makerTags, undefined, print0x008b),
// TagInfo(0x008c, "NEFCurve1", "NEF curve 1", nikon3IfdId, makerTags, xxx, printValue),
TagInfo(0x008d, "ColorMode", "Color mode", nikon3IfdId, makerTags, asciiString, printValue),
TagInfo(0x008f, "SceneMode", "Scene mode", nikon3IfdId, makerTags, asciiString, printValue),
@@ -630,6 +630,18 @@ namespace Exiv2 {
return os;
}
+ std::ostream& Nikon3MakerNote::print0x008b(std::ostream& os,
+ const Value& value)
+ {
+ // Decoded by Robert Rottmerhusen <email at rottmerhusen.com>
+ if (value.size() != 4) return os << "(" << value << ")";
+ float a = value.toLong(0);
+ long b = value.toLong(1);
+ long c = value.toLong(2);
+ if (c == 0) return os << "(" << value << ")";
+ return os << a * b / c;
+ }
+
// *****************************************************************************
// free functions
diff --git a/src/nikonmn.hpp b/src/nikonmn.hpp
index 6ac8a62..18ce60b 100644
--- a/src/nikonmn.hpp
+++ b/src/nikonmn.hpp
@@ -24,7 +24,8 @@
The Nikon MakerNote formats are implemented according to the following references<BR>
Format 1:
- <ul><li><a href="http://www.tawbaware.com/990exif.htm">MakerNote EXIF Tag of the Nikon 990</a> by Max Lyons</li></ul>
+ <ul>
+ <li><a href="http://www.tawbaware.com/990exif.htm">MakerNote EXIF Tag of the Nikon 990</a> by Max Lyons</li></ul>
Format 2:
<ul><li>"Appendix 2: Makernote of Nikon" of the document
<a href="http://park2.wakwak.com/%7Etsuruzoh/Computer/Digicams/exif-e.html">
@@ -33,7 +34,9 @@
<ul><li>"EXIFutils Field Reference Guide"</li>
<li><a href="http://www.ozhiker.com/electronics/pjmt/jpeg_info/nikon_mn.html#Nikon_Type_3_Tags">Nikon Type 3 Makernote Tags Definition</a>
of the PHP JPEG Metadata Toolkit by Evan Hunter</li>
- <li>Nikon specification of <a href="http://www.sno.phy.queensu.ca/~phil/exiftool/">ExifTool</a> by Phil Harvey</li></ul>
+ <li>Nikon tag information from <a href="http://www.sno.phy.queensu.ca/~phil/exiftool/">ExifTool</a> by Phil Harvey</li>
+ <li>Email communication with Robert Rottmerhusen</li>
+ </ul>
@version $Rev$
@author Andreas Huggel (ahu)
@@ -310,6 +313,8 @@ namespace Exiv2 {
static std::ostream& print0x0088(std::ostream& os, const Value& value);
//! Print bracketing information
static std::ostream& print0x0089(std::ostream& os, const Value& value);
+ //! Print number of lens stops
+ static std::ostream& print0x008b(std::ostream& os, const Value& value);
//@}
private:
diff --git a/src/sonymn.cpp b/src/sonymn.cpp
new file mode 100644
index 0000000..aac1e5b
--- /dev/null
+++ b/src/sonymn.cpp
@@ -0,0 +1,141 @@
+// ***************************************************************** -*- C++ -*-
+/*
+ * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel at gmx.net>
+ *
+ * This program is part of the Exiv2 distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+/*
+ File: sonymn.cpp
+ Version: $Rev$
+ Author(s): Andreas Huggel (ahu) <ahuggel at gmx.net>
+ History: 18-Apr-05, ahu: created
+ */
+// *****************************************************************************
+#include "rcsid.hpp"
+EXIV2_RCSID("@(#) $Id$");
+
+// *****************************************************************************
+// included header files
+#include "types.hpp"
+#include "sonymn.hpp"
+#include "makernote.hpp"
+#include "value.hpp"
+
+// + standard includes
+#include <string>
+#include <sstream>
+#include <iomanip>
+#include <cassert>
+
+// Define DEBUG_MAKERNOTE to output debug information to std::cerr
+#undef DEBUG_MAKERNOTE
+
+// *****************************************************************************
+// class member definitions
+namespace Exiv2 {
+
+ const SonyMakerNote::RegisterMakerNote SonyMakerNote::register_;
+
+ // Sony MakerNote Tag Info
+ const TagInfo SonyMakerNote::tagInfo_[] = {
+ TagInfo(0x2000, "0x2000", "Unknown", sonyIfdId, makerTags, undefined, printValue),
+ TagInfo(0x9001, "0x9001", "Unknown", sonyIfdId, makerTags, undefined, printValue),
+ TagInfo(0x9002, "0x9002", "Unknown", sonyIfdId, makerTags, undefined, printValue),
+ TagInfo(0x9003, "0x9003", "Unknown", sonyIfdId, makerTags, undefined, printValue),
+ TagInfo(0x9004, "0x9004", "Unknown", sonyIfdId, makerTags, undefined, printValue),
+ TagInfo(0x9005, "0x9005", "Unknown", sonyIfdId, makerTags, undefined, printValue),
+ TagInfo(0x9006, "0x9006", "Unknown", sonyIfdId, makerTags, undefined, printValue),
+ TagInfo(0x9007, "0x9007", "Unknown", sonyIfdId, makerTags, undefined, printValue),
+ TagInfo(0x9008, "0x9008", "Unknown", sonyIfdId, makerTags, undefined, printValue),
+ // End of list marker
+ TagInfo(0xffff, "(UnknownSonyMakerNoteTag)", "Unknown SonyMakerNote tag", sonyIfdId, makerTags, invalidTypeId, printValue)
+ };
+
+ SonyMakerNote::SonyMakerNote(bool alloc)
+ : IfdMakerNote(sonyIfdId, alloc, false)
+ {
+ byte buf[] = {
+ 'S', 'O', 'N', 'Y', ' ', 'D', 'S', 'C', ' ', '
--
exiv2 packaging
More information about the pkg-kde-commits
mailing list