Merge pull request #2145 from Exiv2/mainSizeT_n
More migration to size_t
This commit is contained in:
+4
-4
@@ -926,7 +926,7 @@ namespace Action {
|
||||
if (num == 0) {
|
||||
// Write all previews
|
||||
for (num = 0; num < pvList.size(); ++num) {
|
||||
writePreviewFile(pvMgr.getPreviewImage(pvList[num]), static_cast<int>(num + 1));
|
||||
writePreviewFile(pvMgr.getPreviewImage(pvList[num]), num + 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -936,7 +936,7 @@ namespace Action {
|
||||
<< " " << num + 1 << "\n";
|
||||
continue;
|
||||
}
|
||||
writePreviewFile(pvMgr.getPreviewImage(pvList[num]), static_cast<int>(num + 1));
|
||||
writePreviewFile(pvMgr.getPreviewImage(pvList[num]), num + 1);
|
||||
}
|
||||
return 0;
|
||||
} // Extract::writePreviews
|
||||
@@ -977,7 +977,7 @@ namespace Action {
|
||||
} // Extract::writeIccProfile
|
||||
|
||||
|
||||
void Extract::writePreviewFile(const Exiv2::PreviewImage& pvImg, int num) const
|
||||
void Extract::writePreviewFile(const Exiv2::PreviewImage& pvImg, size_t num) const
|
||||
{
|
||||
std::string pvFile = newFilePath(path_, "-preview") + Exiv2::toString(num);
|
||||
std::string pvPath = pvFile + pvImg.extension();
|
||||
@@ -997,7 +997,7 @@ namespace Action {
|
||||
std::cerr << path_ << ": " << _("Image does not have preview")
|
||||
<< " " << num << "\n";
|
||||
}
|
||||
} // Extract::writePreviewFile
|
||||
}
|
||||
|
||||
Task::UniquePtr Extract::clone() const
|
||||
{
|
||||
|
||||
+2
-2
@@ -57,7 +57,7 @@ namespace Action {
|
||||
/// @param path Path of the file to process.
|
||||
/// @return 0 if successful.
|
||||
virtual int run(const std::string& path) =0;
|
||||
|
||||
|
||||
bool setBinary(bool b)
|
||||
{
|
||||
bool bResult = binary_;
|
||||
@@ -240,7 +240,7 @@ namespace Action {
|
||||
/// @brief Write one preview image to a file. The filename is composed by removing the suffix from the image
|
||||
/// filename and appending "-preview<num>" and the appropriate suffix (".jpg" or ".tif"), depending on the
|
||||
/// format of the Exif thumbnail image.
|
||||
void writePreviewFile(const Exiv2::PreviewImage& pvImg, int num) const;
|
||||
void writePreviewFile(const Exiv2::PreviewImage& pvImg, size_t num) const;
|
||||
|
||||
/// @brief Write embedded iccProfile files.
|
||||
int writeIccProfile(const std::string& target) const;
|
||||
|
||||
@@ -99,16 +99,15 @@ namespace Exiv2 {
|
||||
IptcData& iptcData,
|
||||
XmpData& xmpData,
|
||||
const byte* pData,
|
||||
uint32_t size
|
||||
size_t size
|
||||
);
|
||||
/*!
|
||||
@brief Encode metadata from the provided metadata to CR2 format.
|
||||
See TiffParser::encode().
|
||||
*/
|
||||
static WriteMethod encode(
|
||||
BasicIo& io,
|
||||
static WriteMethod encode(BasicIo& io,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder,
|
||||
const ExifData& exifData,
|
||||
const IptcData& iptcData,
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Exiv2 {
|
||||
|
||||
@throw Error If the data buffer cannot be parsed.
|
||||
*/
|
||||
static void decode(CrwImage* pCrwImage, const byte* pData, uint32_t size);
|
||||
static void decode(CrwImage* pCrwImage, const byte* pData, size_t size);
|
||||
/*!
|
||||
@brief Encode metadata from the CRW image into a data buffer (the
|
||||
binary CRW image).
|
||||
@@ -118,10 +118,9 @@ namespace Exiv2 {
|
||||
|
||||
@throw Error If the metadata from the CRW image cannot be encoded.
|
||||
*/
|
||||
static void encode(
|
||||
Blob& blob,
|
||||
static void encode(Blob& blob,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
const CrwImage* pCrwImage
|
||||
);
|
||||
|
||||
|
||||
@@ -157,24 +157,24 @@ namespace Exiv2 {
|
||||
@param byteOrder Applicable byte order (little or big endian).
|
||||
@return Number of characters written.
|
||||
*/
|
||||
long copy(byte* buf, ByteOrder byteOrder) const override;
|
||||
size_t copy(byte* buf, ByteOrder byteOrder) const override;
|
||||
std::ostream& write(std::ostream& os, const ExifData* pMetadata = nullptr) const override;
|
||||
//! Return the type id of the value
|
||||
TypeId typeId() const override;
|
||||
//! Return the name of the type
|
||||
const char* typeName() const override;
|
||||
//! Return the size in bytes of one component of this type
|
||||
long typeSize() const override;
|
||||
size_t typeSize() const override;
|
||||
//! Return the number of components in the value
|
||||
size_t count() const override;
|
||||
//! Return the size of the value in bytes
|
||||
long size() const override;
|
||||
size_t size() const override;
|
||||
//! Return the value as a string.
|
||||
std::string toString() const override;
|
||||
std::string toString(long n) const override;
|
||||
int64_t toInt64(long n = 0) const override;
|
||||
float toFloat(long n = 0) const override;
|
||||
Rational toRational(long n = 0) const override;
|
||||
std::string toString(size_t n) const override;
|
||||
int64_t toInt64(size_t n = 0) const override;
|
||||
float toFloat(size_t n = 0) const override;
|
||||
Rational toRational(size_t n = 0) const override;
|
||||
Value::UniquePtr getValue() const override;
|
||||
const Value& value() const override;
|
||||
//! Return the size of the data area.
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Exiv2
|
||||
|
||||
@note Source: https://github.com/davidgaleano/libwebsockets/blob/master/lib/base64-decode.c
|
||||
*/
|
||||
EXIV2API long base64decode(const char* in, char* out, size_t out_size);
|
||||
EXIV2API size_t base64decode(const char* in, char* out, size_t out_size);
|
||||
|
||||
/*!
|
||||
@brief Return the protocol of the path.
|
||||
|
||||
@@ -22,10 +22,10 @@ namespace Exiv2 {
|
||||
|
||||
//! Native preview information. This is meant to be used only by the PreviewManager.
|
||||
struct NativePreview {
|
||||
long position_; //!< Position
|
||||
uint32_t size_; //!< Size
|
||||
uint32_t width_; //!< Width
|
||||
uint32_t height_; //!< Height
|
||||
size_t position_; //!< Position
|
||||
size_t size_; //!< Size
|
||||
size_t width_; //!< Width
|
||||
size_t height_; //!< Height
|
||||
std::string filter_; //!< Filter
|
||||
std::string mimeType_; //!< MIME type
|
||||
};
|
||||
@@ -298,7 +298,7 @@ namespace Exiv2 {
|
||||
/*!
|
||||
@brief Print out the structure of a TIFF IFD
|
||||
*/
|
||||
void printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStructureOption option,uint32_t start,bool bSwap,char c,int depth);
|
||||
void printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStructureOption option, size_t start, bool bSwap, char c, int depth);
|
||||
|
||||
/*!
|
||||
@brief is the host platform bigEndian
|
||||
|
||||
+17
-19
@@ -87,7 +87,7 @@ namespace Exiv2 {
|
||||
|
||||
//! @name Accessors
|
||||
//@{
|
||||
long copy(byte* buf, ByteOrder byteOrder) const override;
|
||||
size_t copy(byte* buf, ByteOrder byteOrder) const override;
|
||||
std::ostream& write(std::ostream& os, const ExifData* pMetadata = nullptr) const override;
|
||||
/*!
|
||||
@brief Return the key of the Iptcdatum. The key is of the form
|
||||
@@ -118,14 +118,14 @@ namespace Exiv2 {
|
||||
uint16_t tag() const override;
|
||||
TypeId typeId() const override;
|
||||
const char* typeName() const override;
|
||||
long typeSize() const override;
|
||||
size_t typeSize() const override;
|
||||
size_t count() const override;
|
||||
long size() const override;
|
||||
size_t size() const override;
|
||||
std::string toString() const override;
|
||||
std::string toString(long n) const override;
|
||||
int64_t toInt64(long n = 0) const override;
|
||||
float toFloat(long n = 0) const override;
|
||||
Rational toRational(long n = 0) const override;
|
||||
std::string toString(size_t n) const override;
|
||||
int64_t toInt64(size_t n = 0) const override;
|
||||
float toFloat(size_t n = 0) const override;
|
||||
Rational toRational(size_t n = 0) const override;
|
||||
Value::UniquePtr getValue() const override;
|
||||
const Value& value() const override;
|
||||
//@}
|
||||
@@ -236,19 +236,17 @@ namespace Exiv2 {
|
||||
uint16_t record = IptcDataSets::application2) const;
|
||||
//! Return true if there is no IPTC metadata
|
||||
bool empty() const { return count() == 0; }
|
||||
|
||||
//! Get the number of metadata entries
|
||||
long count() const { return static_cast<long>(iptcMetadata_.size()); }
|
||||
/*!
|
||||
@brief Return the exact size of all contained IPTC metadata
|
||||
*/
|
||||
long size() const;
|
||||
/*!
|
||||
@brief Return the metadata charset name or 0
|
||||
*/
|
||||
size_t count() const { return iptcMetadata_.size(); }
|
||||
|
||||
//! @brief Return the exact size of all contained IPTC metadata
|
||||
size_t size() const;
|
||||
|
||||
//! @brief Return the metadata charset name or 0
|
||||
const char *detectCharset() const;
|
||||
/*!
|
||||
@brief dump iptc formatted binary data (used by printStructure kpsRecursive)
|
||||
*/
|
||||
|
||||
//! @brief dump iptc formatted binary data (used by printStructure kpsRecursive)
|
||||
static void printStructure(std::ostream& out, const Slice<byte*>& bytes,uint32_t depth);
|
||||
//@}
|
||||
|
||||
@@ -274,7 +272,7 @@ namespace Exiv2 {
|
||||
@return 0 if successful;<BR>
|
||||
5 if the binary IPTC data is invalid or corrupt
|
||||
*/
|
||||
static int decode(IptcData& iptcData, const byte* pData, uint32_t size);
|
||||
static int decode(IptcData& iptcData, const byte* pData, size_t size);
|
||||
|
||||
/*!
|
||||
@brief Encode the IPTC datasets from \em iptcData to a binary representation in IPTC IIM4 format.
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace Exiv2 {
|
||||
@param byteOrder Applicable byte order (little or big endian).
|
||||
@return Number of characters written.
|
||||
*/
|
||||
virtual long copy(byte* buf, ByteOrder byteOrder) const =0;
|
||||
virtual size_t copy(byte* buf, ByteOrder byteOrder) const =0;
|
||||
/*!
|
||||
@brief Write the interpreted value to an output stream, return
|
||||
the stream.
|
||||
@@ -187,11 +187,11 @@ namespace Exiv2 {
|
||||
//! Return the name of the type
|
||||
virtual const char* typeName() const =0;
|
||||
//! Return the size in bytes of one component of this type
|
||||
virtual long typeSize() const =0;
|
||||
virtual size_t typeSize() const =0;
|
||||
//! Return the number of components in the value
|
||||
virtual size_t count() const =0;
|
||||
//! Return the size of the value in bytes
|
||||
virtual long size() const =0;
|
||||
virtual size_t size() const =0;
|
||||
//! Return the value as a string.
|
||||
virtual std::string toString() const =0;
|
||||
/*!
|
||||
@@ -199,29 +199,29 @@ namespace Exiv2 {
|
||||
a string. The behaviour of the method is undefined if there
|
||||
is no <EM>n</EM>-th component.
|
||||
*/
|
||||
virtual std::string toString(long n) const =0;
|
||||
virtual std::string toString(size_t n) const =0;
|
||||
/*!
|
||||
@brief Return the <EM>n</EM>-th component of the value converted to int64_t.
|
||||
The return value is -1 if the value is not set and the behaviour
|
||||
of the method is undefined if there is no <EM>n</EM>-th component.
|
||||
*/
|
||||
virtual int64_t toInt64(long n =0) const =0;
|
||||
virtual int64_t toInt64(size_t n =0) const =0;
|
||||
/*!
|
||||
@brief Return the <EM>n</EM>-th component of the value converted to uint32_t.
|
||||
*/
|
||||
uint32_t toUint32(long n =0) const;
|
||||
uint32_t toUint32(size_t n =0) const;
|
||||
/*!
|
||||
@brief Return the <EM>n</EM>-th component of the value converted to float.
|
||||
The return value is -1 if the value is not set and the behaviour
|
||||
of the method is undefined if there is no <EM>n</EM>-th component.
|
||||
*/
|
||||
virtual float toFloat(long n =0) const =0;
|
||||
virtual float toFloat(size_t n =0) const =0;
|
||||
/*!
|
||||
@brief Return the <EM>n</EM>-th component of the value converted to Rational.
|
||||
The return value is -1/1 if the value is not set and the behaviour
|
||||
of the method is undefined if there is no <EM>n</EM>-th component.
|
||||
*/
|
||||
virtual Rational toRational(long n =0) const =0;
|
||||
virtual Rational toRational(size_t n =0) const =0;
|
||||
/*!
|
||||
@brief Return an auto-pointer to a copy (clone) of the value. The
|
||||
caller owns this copy and the auto-poiner ensures that it will
|
||||
|
||||
@@ -82,21 +82,15 @@ namespace Exiv2 {
|
||||
with data in ORF format to the provided metadata containers.
|
||||
See TiffParser::decode().
|
||||
*/
|
||||
static ByteOrder decode(
|
||||
ExifData& exifData,
|
||||
IptcData& iptcData,
|
||||
XmpData& xmpData,
|
||||
const byte* pData,
|
||||
uint32_t size
|
||||
);
|
||||
static ByteOrder decode(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, const byte* pData,
|
||||
size_t size);
|
||||
/*!
|
||||
@brief Encode metadata from the provided metadata to ORF format.
|
||||
See TiffParser::encode().
|
||||
*/
|
||||
static WriteMethod encode(
|
||||
BasicIo& io,
|
||||
static WriteMethod encode(BasicIo& io,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder,
|
||||
const ExifData& exifData,
|
||||
const IptcData& iptcData,
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace Exiv2
|
||||
//! Read Magick number. Only version >= 6 is supported.
|
||||
static byte readPgfMagicNumber(BasicIo& iIo);
|
||||
//! Read PGF Header size encoded in 32 bits integer.
|
||||
uint32_t readPgfHeaderSize(BasicIo& iIo) const;
|
||||
size_t readPgfHeaderSize(BasicIo& iIo) const;
|
||||
//! Read header structure.
|
||||
DataBuf readPgfHeaderStructure(BasicIo& iIo, uint32_t& width, uint32_t& height) const;
|
||||
//@}
|
||||
|
||||
+10
-15
@@ -21,19 +21,14 @@ namespace Exiv2 {
|
||||
/*!
|
||||
@brief Preview image properties.
|
||||
*/
|
||||
struct EXIV2API PreviewProperties {
|
||||
//! Preview image mime type.
|
||||
std::string mimeType_;
|
||||
//! Preview image extension.
|
||||
std::string extension_;
|
||||
//! Preview image size in bytes.
|
||||
size_t size_;
|
||||
//! Preview image width in pixels or 0 for unknown width.
|
||||
uint32_t width_;
|
||||
//! Preview image height in pixels or 0 for unknown height.
|
||||
uint32_t height_;
|
||||
//! Identifies type of preview image.
|
||||
PreviewId id_;
|
||||
struct EXIV2API PreviewProperties
|
||||
{
|
||||
std::string mimeType_; //!< Preview image mime type.
|
||||
std::string extension_; //!< Preview image extension.
|
||||
size_t size_; //!< Preview image size in bytes.
|
||||
size_t width_; //!< Preview image width in pixels or 0 for unknown width.
|
||||
size_t height_; //!< Preview image height in pixels or 0 for unknown height.
|
||||
PreviewId id_; //!< Identifies type of preview image.
|
||||
};
|
||||
|
||||
//! Container type to hold all preview images metadata.
|
||||
@@ -97,11 +92,11 @@ namespace Exiv2 {
|
||||
/*!
|
||||
@brief Return the width of the preview image in pixels.
|
||||
*/
|
||||
uint32_t width() const;
|
||||
size_t width() const;
|
||||
/*!
|
||||
@brief Return the height of the preview image in pixels.
|
||||
*/
|
||||
uint32_t height() const;
|
||||
size_t height() const;
|
||||
/*!
|
||||
@brief Return the preview image type identifier.
|
||||
*/
|
||||
|
||||
@@ -95,12 +95,11 @@ namespace Exiv2 {
|
||||
with data in RW2 format to the provided metadata containers.
|
||||
See TiffParser::decode().
|
||||
*/
|
||||
static ByteOrder decode(
|
||||
ExifData& exifData,
|
||||
static ByteOrder decode(ExifData& exifData,
|
||||
IptcData& iptcData,
|
||||
XmpData& xmpData,
|
||||
const byte* pData,
|
||||
uint32_t size
|
||||
size_t size
|
||||
);
|
||||
|
||||
}; // class Rw2Parser
|
||||
|
||||
@@ -152,10 +152,9 @@ namespace Exiv2 {
|
||||
|
||||
@return Write method used.
|
||||
*/
|
||||
static WriteMethod encode(
|
||||
BasicIo& io,
|
||||
static WriteMethod encode(BasicIo& io,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder,
|
||||
const ExifData& exifData,
|
||||
const IptcData& iptcData,
|
||||
|
||||
+14
-16
@@ -98,7 +98,7 @@ namespace Exiv2 {
|
||||
@param byteOrder Applicable byte order (little or big endian).
|
||||
@return Number of bytes written.
|
||||
*/
|
||||
virtual long copy(byte* buf, ByteOrder byteOrder) const =0;
|
||||
virtual size_t copy(byte* buf, ByteOrder byteOrder) const =0;
|
||||
//! Return the number of components of the value
|
||||
virtual size_t count() const =0;
|
||||
//! Return the size of the value in bytes
|
||||
@@ -244,9 +244,7 @@ namespace Exiv2 {
|
||||
|
||||
explicit DataValue(TypeId typeId =undefined);
|
||||
|
||||
DataValue(const byte* buf,
|
||||
long len, ByteOrder byteOrder =invalidByteOrder,
|
||||
TypeId typeId =undefined);
|
||||
DataValue(const byte* buf, size_t len, ByteOrder byteOrder =invalidByteOrder, TypeId typeId =undefined);
|
||||
|
||||
~DataValue() override = default;
|
||||
|
||||
@@ -273,7 +271,7 @@ namespace Exiv2 {
|
||||
@param byteOrder Byte order. Not needed.
|
||||
@return Number of characters written.
|
||||
*/
|
||||
long copy(byte* buf, ByteOrder byteOrder = invalidByteOrder) const override;
|
||||
size_t copy(byte* buf, ByteOrder byteOrder = invalidByteOrder) const override;
|
||||
size_t count() const override;
|
||||
size_t size() const override;
|
||||
std::ostream& write(std::ostream& os) const override;
|
||||
@@ -346,7 +344,7 @@ namespace Exiv2 {
|
||||
@param byteOrder Byte order. Not used.
|
||||
@return Number of characters written.
|
||||
*/
|
||||
long copy(byte* buf, ByteOrder byteOrder = invalidByteOrder) const override;
|
||||
size_t copy(byte* buf, ByteOrder byteOrder = invalidByteOrder) const override;
|
||||
size_t count() const override;
|
||||
size_t size() const override;
|
||||
int64_t toInt64(size_t n = 0) const override;
|
||||
@@ -531,7 +529,7 @@ namespace Exiv2 {
|
||||
//! @name Accessors
|
||||
//@{
|
||||
UniquePtr clone() const { return UniquePtr(clone_()); }
|
||||
long copy(byte* buf, ByteOrder byteOrder) const override;
|
||||
size_t copy(byte* buf, ByteOrder byteOrder) const override;
|
||||
/*!
|
||||
@brief Write the comment in a format which can be read by
|
||||
read(const std::string& comment).
|
||||
@@ -614,7 +612,7 @@ namespace Exiv2 {
|
||||
@param byteOrder Byte order. Not used.
|
||||
@return Number of characters written.
|
||||
*/
|
||||
long copy(byte* buf, ByteOrder byteOrder = invalidByteOrder) const override;
|
||||
size_t copy(byte* buf, ByteOrder byteOrder = invalidByteOrder) const override;
|
||||
//@}
|
||||
|
||||
//! @name Manipulators
|
||||
@@ -974,7 +972,7 @@ namespace Exiv2 {
|
||||
@param byteOrder Byte order. Not used.
|
||||
@return Number of characters written.
|
||||
*/
|
||||
long copy(byte* buf, ByteOrder byteOrder = invalidByteOrder) const override;
|
||||
size_t copy(byte* buf, ByteOrder byteOrder = invalidByteOrder) const override;
|
||||
|
||||
//! Return date struct containing date information
|
||||
virtual const Date& getDate() const;
|
||||
@@ -1072,7 +1070,7 @@ namespace Exiv2 {
|
||||
@param byteOrder Byte order. Not used.
|
||||
@return Number of characters written.
|
||||
*/
|
||||
long copy(byte* buf, ByteOrder byteOrder = invalidByteOrder) const override;
|
||||
size_t copy(byte* buf, ByteOrder byteOrder = invalidByteOrder) const override;
|
||||
//! Return time struct containing time information
|
||||
virtual const Time& getTime() const;
|
||||
size_t count() const override;
|
||||
@@ -1142,7 +1140,7 @@ namespace Exiv2 {
|
||||
// The default c'tor and this one can be combined, but that causes MSVC 7.1 to fall on its nose
|
||||
explicit ValueType(TypeId typeId);
|
||||
//! Constructor.
|
||||
ValueType(const byte* buf, long len, ByteOrder byteOrder, TypeId typeId =getType<T>());
|
||||
ValueType(const byte* buf, size_t len, ByteOrder byteOrder, TypeId typeId =getType<T>());
|
||||
//! Constructor.
|
||||
explicit ValueType(const T& val, TypeId typeId =getType<T>());
|
||||
//! Copy constructor
|
||||
@@ -1173,7 +1171,7 @@ namespace Exiv2 {
|
||||
//! @name Accessors
|
||||
//@{
|
||||
UniquePtr clone() const { return UniquePtr(clone_()); }
|
||||
long copy(byte* buf, ByteOrder byteOrder) const override;
|
||||
size_t copy(byte* buf, ByteOrder byteOrder) const override;
|
||||
size_t count() const override;
|
||||
size_t size() const override;
|
||||
std::ostream& write(std::ostream& os) const override;
|
||||
@@ -1457,7 +1455,7 @@ namespace Exiv2 {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
ValueType<T>::ValueType(const byte* buf, long len, ByteOrder byteOrder, TypeId typeId) : Value(typeId)
|
||||
ValueType<T>::ValueType(const byte* buf, size_t len, ByteOrder byteOrder, TypeId typeId) : Value(typeId)
|
||||
{
|
||||
read(buf, len, byteOrder);
|
||||
}
|
||||
@@ -1535,9 +1533,9 @@ namespace Exiv2 {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
long ValueType<T>::copy(byte* buf, ByteOrder byteOrder) const
|
||||
size_t ValueType<T>::copy(byte* buf, ByteOrder byteOrder) const
|
||||
{
|
||||
long offset = 0;
|
||||
size_t offset = 0;
|
||||
for (auto i = value_.begin(); i != value_.end(); ++i) {
|
||||
offset += toData(buf + offset, *i, byteOrder);
|
||||
}
|
||||
@@ -1553,7 +1551,7 @@ namespace Exiv2 {
|
||||
template<typename T>
|
||||
size_t ValueType<T>::size() const
|
||||
{
|
||||
return static_cast<long>(TypeInfo::typeSize(typeId()) * value_.size());
|
||||
return TypeInfo::typeSize(typeId()) * value_.size();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Exiv2 {
|
||||
//! @name Accessors
|
||||
//@{
|
||||
//! Not implemented. Calling this method will raise an exception.
|
||||
long copy(byte* buf, ByteOrder byteOrder) const override;
|
||||
size_t copy(byte* buf, ByteOrder byteOrder) const override;
|
||||
std::ostream& write(std::ostream& os, const ExifData* pMetadata = nullptr) const override;
|
||||
/*!
|
||||
@brief Return the key of the Xmpdatum. The key is of the form
|
||||
@@ -113,14 +113,14 @@ namespace Exiv2 {
|
||||
const char* typeName() const override;
|
||||
// Todo: Remove this method from the baseclass
|
||||
//! The Exif typeSize doesn't make sense here. Return 0.
|
||||
long typeSize() const override;
|
||||
size_t typeSize() const override;
|
||||
size_t count() const override;
|
||||
long size() const override;
|
||||
size_t size() const override;
|
||||
std::string toString() const override;
|
||||
std::string toString(long n) const override;
|
||||
int64_t toInt64(long n = 0) const override;
|
||||
float toFloat(long n = 0) const override;
|
||||
Rational toRational(long n = 0) const override;
|
||||
std::string toString(size_t n) const override;
|
||||
int64_t toInt64(size_t n = 0) const override;
|
||||
float toFloat(size_t n = 0) const override;
|
||||
Rational toRational(size_t n = 0) const override;
|
||||
Value::UniquePtr getValue() const override;
|
||||
const Value& value() const override;
|
||||
//@}
|
||||
|
||||
+31
-30
@@ -281,7 +281,7 @@ namespace Exiv2 {
|
||||
p_->pMappedArea_ = static_cast<byte*>(rc);
|
||||
#else
|
||||
// Workaround for platforms without mmap: Read the file into memory
|
||||
DataBuf buf(static_cast<long>(p_->mappedLength_));
|
||||
DataBuf buf(p_->mappedLength_);
|
||||
if (read(buf.data(), buf.size()) != buf.size()) {
|
||||
throw Error(ErrorCode::kerCallFailed, path(), strError(), "FileIo::read");
|
||||
}
|
||||
@@ -529,7 +529,7 @@ namespace Exiv2 {
|
||||
DataBuf FileIo::read(size_t rcount)
|
||||
{
|
||||
assert(p_->fp_);
|
||||
if (static_cast<size_t>(rcount) > size())
|
||||
if (rcount > size())
|
||||
throw Error(ErrorCode::kerInvalidMalloc);
|
||||
DataBuf buf(rcount);
|
||||
size_t readCount = read(buf.data(), buf.size());
|
||||
@@ -767,8 +767,10 @@ namespace Exiv2 {
|
||||
|
||||
size_t MemIo::write(BasicIo& src)
|
||||
{
|
||||
if (static_cast<BasicIo*>(this) == &src) return 0;
|
||||
if (!src.isopen()) return 0;
|
||||
if (static_cast<BasicIo*>(this) == &src)
|
||||
return 0;
|
||||
if (!src.isopen())
|
||||
return 0;
|
||||
|
||||
byte buf[4096];
|
||||
size_t readCount = 0;
|
||||
@@ -807,7 +809,7 @@ namespace Exiv2 {
|
||||
return 1;
|
||||
}
|
||||
|
||||
p_->idx_ = static_cast<long>(newIdx);
|
||||
p_->idx_ = static_cast<size_t>(newIdx);
|
||||
p_->eof_ = false;
|
||||
return 0;
|
||||
}
|
||||
@@ -936,7 +938,7 @@ namespace Exiv2 {
|
||||
|
||||
std::string data = path.substr(base64Pos+7);
|
||||
char* decodeData = new char[data.length()];
|
||||
long size = base64decode(data.c_str(), decodeData, data.length());
|
||||
auto size = base64decode(data.c_str(), decodeData, data.length());
|
||||
if (size > 0)
|
||||
write((byte*)decodeData, size);
|
||||
else
|
||||
@@ -1012,7 +1014,7 @@ namespace Exiv2 {
|
||||
|
||||
std::string data = orgPath.substr(base64Pos+7);
|
||||
std::vector<char> decodeData (data.length());
|
||||
long size = base64decode(data.c_str(), decodeData.data(), data.length());
|
||||
auto size = base64decode(data.c_str(), decodeData.data(), data.length());
|
||||
if (size > 0) {
|
||||
fs.write(decodeData.data(), size);
|
||||
fs.close();
|
||||
@@ -1065,7 +1067,7 @@ namespace Exiv2 {
|
||||
@throw Error if the server returns the error code.
|
||||
@note Set lowBlock = -1 and highBlock = -1 to get the whole file content.
|
||||
*/
|
||||
virtual void getDataByRange(long lowBlock, long highBlock, std::string& response) = 0;
|
||||
virtual void getDataByRange(size_t lowBlock, size_t highBlock, std::string& response) = 0;
|
||||
/*!
|
||||
@brief Submit the data to the remote machine. The data replace a part of the remote file.
|
||||
The replaced part of remote file is indicated by from and to parameters.
|
||||
@@ -1077,7 +1079,7 @@ namespace Exiv2 {
|
||||
on the remote machine to handle the data. SSH requires the permission to edit the file.
|
||||
@throw Error if it fails.
|
||||
*/
|
||||
virtual void writeRemote(const byte* data, size_t size, long from, long to) = 0;
|
||||
virtual void writeRemote(const byte* data, size_t size, size_t from, size_t to) = 0;
|
||||
/*!
|
||||
@brief Get the data from the remote machine and write them to the memory blocks.
|
||||
@param lowBlock The start block index.
|
||||
@@ -1114,7 +1116,7 @@ namespace Exiv2 {
|
||||
if (blocksMap_[highBlock].isNone())
|
||||
{
|
||||
std::string data;
|
||||
getDataByRange(static_cast<long>(lowBlock), static_cast<long>(highBlock), data);
|
||||
getDataByRange(lowBlock, highBlock, data);
|
||||
rcount = data.length();
|
||||
if (rcount == 0) {
|
||||
throw Error(ErrorCode::kerErrorMessage, "Data By Range is empty. Please check the permission.");
|
||||
@@ -1156,7 +1158,7 @@ namespace Exiv2 {
|
||||
long length = p_->getFileLength();
|
||||
if (length < 0) { // unable to get the length of remote file, get the whole file content.
|
||||
std::string data;
|
||||
p_->getDataByRange(-1, -1, data);
|
||||
p_->getDataByRange(std::numeric_limits<size_t>::max(), std::numeric_limits<size_t>::max(), data);
|
||||
p_->size_ = data.length();
|
||||
size_t nBlocks = (p_->size_ + p_->blockSize_ - 1) / p_->blockSize_;
|
||||
p_->blocksMap_ = new BlockMap[nBlocks];
|
||||
@@ -1206,7 +1208,8 @@ namespace Exiv2 {
|
||||
size_t RemoteIo::write(BasicIo& src)
|
||||
{
|
||||
assert(p_->isMalloced_);
|
||||
if (!src.isopen()) return 0;
|
||||
if (!src.isopen())
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* The idea is to compare the file content, find the different bytes and submit them to the remote machine.
|
||||
@@ -1262,16 +1265,14 @@ namespace Exiv2 {
|
||||
}
|
||||
|
||||
// submit to the remote machine.
|
||||
auto dataSize = static_cast<long>(src.size() - left - right);
|
||||
auto dataSize = src.size() - left - right;
|
||||
if (dataSize > 0) {
|
||||
auto data = static_cast<byte*>(std::malloc(dataSize));
|
||||
std::vector<byte> data(dataSize);
|
||||
src.seek(left, BasicIo::beg);
|
||||
src.read(data, dataSize);
|
||||
p_->writeRemote(data, dataSize, static_cast<long>(left), static_cast<long>(p_->size_ - right));
|
||||
if (data)
|
||||
std::free(data);
|
||||
src.read(data.data(), dataSize);
|
||||
p_->writeRemote(data.data(), dataSize, left, p_->size_ - right);
|
||||
}
|
||||
return static_cast<long>(src.size());
|
||||
return src.size();
|
||||
}
|
||||
|
||||
int RemoteIo::putb(byte /*unused data*/)
|
||||
@@ -1410,7 +1411,7 @@ namespace Exiv2 {
|
||||
|
||||
size_t RemoteIo::size() const
|
||||
{
|
||||
return static_cast<long>(p_->size_);
|
||||
return p_->size_;
|
||||
}
|
||||
|
||||
bool RemoteIo::isopen() const
|
||||
@@ -1468,7 +1469,7 @@ namespace Exiv2 {
|
||||
@throw Error if the server returns the error code.
|
||||
@note Set lowBlock = -1 and highBlock = -1 to get the whole file content.
|
||||
*/
|
||||
void getDataByRange(long lowBlock, long highBlock, std::string& response) override;
|
||||
void getDataByRange(size_t lowBlock, size_t highBlock, std::string& response) override;
|
||||
/*!
|
||||
@brief Submit the data to the remote machine. The data replace a part of the remote file.
|
||||
The replaced part of remote file is indicated by from and to parameters.
|
||||
@@ -1482,7 +1483,7 @@ namespace Exiv2 {
|
||||
"/exiv2.php". More info is available at http://dev.exiv2.org/wiki/exiv2
|
||||
@throw Error if it fails.
|
||||
*/
|
||||
void writeRemote(const byte* data, size_t size, long from, long to) override;
|
||||
void writeRemote(const byte* data, size_t size, size_t from, size_t to) override;
|
||||
|
||||
// NOT IMPLEMENTED
|
||||
HttpImpl(const HttpImpl& rhs) = delete; //!< Copy constructor
|
||||
@@ -1514,7 +1515,7 @@ namespace Exiv2 {
|
||||
return (lengthIter == response.end()) ? -1 : atol((lengthIter->second).c_str());
|
||||
}
|
||||
|
||||
void HttpIo::HttpImpl::getDataByRange(long lowBlock, long highBlock, std::string& response)
|
||||
void HttpIo::HttpImpl::getDataByRange(size_t lowBlock, size_t highBlock, std::string& response)
|
||||
{
|
||||
Exiv2::Dictionary responseDic;
|
||||
Exiv2::Dictionary request;
|
||||
@@ -1524,7 +1525,7 @@ namespace Exiv2 {
|
||||
request["port"] = hostInfo_.Port;
|
||||
request["verb"] = "GET";
|
||||
std::string errors;
|
||||
if (lowBlock > -1 && highBlock > -1) {
|
||||
if (lowBlock != std::numeric_limits<size_t>::max() && highBlock != std::numeric_limits<size_t>::max()) {
|
||||
std::stringstream ss;
|
||||
ss << "Range: bytes=" << lowBlock * blockSize_ << "-" << ((highBlock + 1) * blockSize_ - 1) << "\r\n";
|
||||
request["header"] = ss.str();
|
||||
@@ -1537,7 +1538,7 @@ namespace Exiv2 {
|
||||
response = responseDic["body"];
|
||||
}
|
||||
|
||||
void HttpIo::HttpImpl::writeRemote(const byte* data, size_t size, long from, long to)
|
||||
void HttpIo::HttpImpl::writeRemote(const byte* data, size_t size, size_t from, size_t to)
|
||||
{
|
||||
std::string scriptPath(getEnv(envHTTPPOST));
|
||||
if (scriptPath.empty()) {
|
||||
@@ -1619,7 +1620,7 @@ namespace Exiv2 {
|
||||
@throw Error if the server returns the error code.
|
||||
@note Set lowBlock = -1 and highBlock = -1 to get the whole file content.
|
||||
*/
|
||||
void getDataByRange(long lowBlock, long highBlock, std::string& response) override;
|
||||
void getDataByRange(size_t lowBlock, size_t highBlock, std::string& response) override;
|
||||
/*!
|
||||
@brief Submit the data to the remote machine. The data replace a part of the remote file.
|
||||
The replaced part of remote file is indicated by from and to parameters.
|
||||
@@ -1634,7 +1635,7 @@ namespace Exiv2 {
|
||||
string EXIV2_HTTP_POST. The default value is "/exiv2.php". More info is available at
|
||||
http://dev.exiv2.org/wiki/exiv2
|
||||
*/
|
||||
void writeRemote(const byte* data, size_t size, long from, long to) override;
|
||||
void writeRemote(const byte* data, size_t size, size_t from, size_t to) override;
|
||||
|
||||
// NOT IMPLEMENTED
|
||||
CurlImpl(const CurlImpl& rhs) = delete; //!< Copy constructor
|
||||
@@ -1693,7 +1694,7 @@ namespace Exiv2 {
|
||||
return static_cast<long>(temp);
|
||||
}
|
||||
|
||||
void CurlIo::CurlImpl::getDataByRange(long lowBlock, long highBlock, std::string& response)
|
||||
void CurlIo::CurlImpl::getDataByRange(size_t lowBlock, size_t highBlock, std::string& response)
|
||||
{
|
||||
curl_easy_reset(curl_); // reset all options
|
||||
curl_easy_setopt(curl_, CURLOPT_URL, path_.c_str());
|
||||
@@ -1706,7 +1707,7 @@ namespace Exiv2 {
|
||||
|
||||
//curl_easy_setopt(curl_, CURLOPT_VERBOSE, 1); // debugging mode
|
||||
|
||||
if (lowBlock > -1 && highBlock> -1) {
|
||||
if (lowBlock != std::numeric_limits<size_t>::max() && highBlock != std::numeric_limits<size_t>::max()) {
|
||||
std::stringstream ss;
|
||||
ss << lowBlock * blockSize_ << "-" << ((highBlock + 1) * blockSize_ - 1);
|
||||
std::string range = ss.str();
|
||||
@@ -1726,7 +1727,7 @@ namespace Exiv2 {
|
||||
}
|
||||
}
|
||||
|
||||
void CurlIo::CurlImpl::writeRemote(const byte* data, size_t size, long from, long to)
|
||||
void CurlIo::CurlImpl::writeRemote(const byte* data, size_t size, size_t from, size_t to)
|
||||
{
|
||||
std::string scriptPath(getEnv(envHTTPPOST));
|
||||
if (scriptPath.empty()) {
|
||||
|
||||
+6
-5
@@ -535,7 +535,7 @@ namespace Exiv2 {
|
||||
if (!prepareXmpTarget(to))
|
||||
return;
|
||||
for (size_t i = 0; i < pos->count(); ++i) {
|
||||
std::string value = pos->toString(static_cast<long>(i));
|
||||
std::string value = pos->toString(i);
|
||||
if (!pos->value().ok()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
@@ -687,7 +687,7 @@ namespace Exiv2 {
|
||||
return;
|
||||
std::ostringstream value;
|
||||
for (size_t i = 0; i < pos->count(); ++i) {
|
||||
value << static_cast<char>(pos->toInt64(static_cast<long>(i)));
|
||||
value << static_cast<char>(pos->toInt64(i));
|
||||
}
|
||||
(*xmpData_)[to] = value.str();
|
||||
if (erase_) exifData_->erase(pos);
|
||||
@@ -702,8 +702,9 @@ namespace Exiv2 {
|
||||
return;
|
||||
std::ostringstream value;
|
||||
for (size_t i = 0; i < pos->count(); ++i) {
|
||||
if (i > 0) value << '.';
|
||||
value << pos->toInt64(static_cast<long>(i));
|
||||
if (i > 0)
|
||||
value << '.';
|
||||
value << pos->toInt64(i);
|
||||
}
|
||||
(*xmpData_)[to] = value.str();
|
||||
if (erase_) exifData_->erase(pos);
|
||||
@@ -830,7 +831,7 @@ namespace Exiv2 {
|
||||
return;
|
||||
std::ostringstream array;
|
||||
for (size_t i = 0; i < pos->count(); ++i) {
|
||||
std::string value = pos->toString(static_cast<long>(i));
|
||||
std::string value = pos->toString(i);
|
||||
if (!pos->value().ok()) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Exiv2::Internal {
|
||||
{
|
||||
}
|
||||
|
||||
bool Cr2Header::read(const byte* pData, uint32_t size)
|
||||
bool Cr2Header::read(const byte* pData, size_t size)
|
||||
{
|
||||
if (!pData || size < 16) {
|
||||
return false;
|
||||
@@ -24,13 +24,15 @@ namespace Exiv2::Internal {
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
if (tag() != getUShort(pData + 2, byteOrder())) return false;
|
||||
if (tag() != getUShort(pData + 2, byteOrder()))
|
||||
return false;
|
||||
setOffset(getULong(pData + 4, byteOrder()));
|
||||
if (0 != memcmp(pData + 8, cr2sig_, 4)) return false;
|
||||
if (0 != memcmp(pData + 8, cr2sig_, 4))
|
||||
return false;
|
||||
offset2_ = getULong(pData + 12, byteOrder());
|
||||
|
||||
return true;
|
||||
} // Cr2Header::read
|
||||
}
|
||||
|
||||
DataBuf Cr2Header::write() const
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Exiv2::Internal {
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
bool read(const byte* pData, uint32_t size) override;
|
||||
bool read(const byte* pData, size_t size) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
|
||||
+6
-12
@@ -77,8 +77,7 @@ namespace Exiv2 {
|
||||
throw Error(ErrorCode::kerNotAnImage, "CR2");
|
||||
}
|
||||
clearMetadata();
|
||||
ByteOrder bo =
|
||||
Cr2Parser::decode(exifData_, iptcData_, xmpData_, io_->mmap(), static_cast<uint32_t>(io_->size()));
|
||||
ByteOrder bo = Cr2Parser::decode(exifData_, iptcData_, xmpData_, io_->mmap(), io_->size());
|
||||
setByteOrder(bo);
|
||||
} // Cr2Image::readMetadata
|
||||
|
||||
@@ -89,13 +88,13 @@ namespace Exiv2 {
|
||||
#endif
|
||||
ByteOrder bo = byteOrder();
|
||||
byte* pData = nullptr;
|
||||
long size = 0;
|
||||
size_t size = 0;
|
||||
IoCloser closer(*io_);
|
||||
if (io_->open() == 0) {
|
||||
// Ensure that this is the correct image type
|
||||
if (isCr2Type(*io_, false)) {
|
||||
pData = io_->mmap(true);
|
||||
size = static_cast<long>(io_->size());
|
||||
size = io_->size();
|
||||
Cr2Header cr2Header;
|
||||
if (0 == cr2Header.read(pData, 16)) {
|
||||
bo = cr2Header.byteOrder();
|
||||
@@ -109,13 +108,8 @@ namespace Exiv2 {
|
||||
Cr2Parser::encode(*io_, pData, size, bo, exifData_, iptcData_, xmpData_); // may throw
|
||||
} // Cr2Image::writeMetadata
|
||||
|
||||
ByteOrder Cr2Parser::decode(
|
||||
ExifData& exifData,
|
||||
IptcData& iptcData,
|
||||
XmpData& xmpData,
|
||||
const byte* pData,
|
||||
uint32_t size
|
||||
)
|
||||
ByteOrder Cr2Parser::decode(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, const byte* pData,
|
||||
size_t size)
|
||||
{
|
||||
Cr2Header cr2Header;
|
||||
return TiffParserWorker::decode(exifData,
|
||||
@@ -131,7 +125,7 @@ namespace Exiv2 {
|
||||
WriteMethod Cr2Parser::encode(
|
||||
BasicIo& io,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder,
|
||||
const ExifData& exifData,
|
||||
const IptcData& iptcData,
|
||||
|
||||
+5
-10
@@ -74,7 +74,7 @@ namespace Exiv2 {
|
||||
DataBuf file(io().size());
|
||||
io_->read(file.data(), file.size());
|
||||
|
||||
CrwParser::decode(this, io_->mmap(), static_cast<uint32_t>(io_->size()));
|
||||
CrwParser::decode(this, io_->mmap(), io_->size());
|
||||
|
||||
} // CrwImage::readMetadata
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace Exiv2 {
|
||||
}
|
||||
|
||||
Blob blob;
|
||||
CrwParser::encode(blob, buf.c_data(), static_cast<uint32_t>(buf.size()), this);
|
||||
CrwParser::encode(blob, buf.c_data(), buf.size(), this);
|
||||
|
||||
// Write new buffer to file
|
||||
auto tempIo = std::make_unique<MemIo>();
|
||||
@@ -109,7 +109,7 @@ namespace Exiv2 {
|
||||
|
||||
} // CrwImage::writeMetadata
|
||||
|
||||
void CrwParser::decode(CrwImage* pCrwImage, const byte* pData, uint32_t size)
|
||||
void CrwParser::decode(CrwImage* pCrwImage, const byte* pData, size_t size)
|
||||
{
|
||||
assert(pCrwImage);
|
||||
assert(pData);
|
||||
@@ -123,16 +123,11 @@ namespace Exiv2 {
|
||||
CiffComponent* preview = header.findComponent(0x2007, 0x0000);
|
||||
if (preview) {
|
||||
(pCrwImage->exifData())["Exif.Image2.JPEGInterchangeFormat"] = uint32_t(preview->pData() - pData);
|
||||
(pCrwImage->exifData())["Exif.Image2.JPEGInterchangeFormatLength"] = preview->size();
|
||||
(pCrwImage->exifData())["Exif.Image2.JPEGInterchangeFormatLength"] = static_cast<uint32_t>(preview->size());
|
||||
}
|
||||
} // CrwParser::decode
|
||||
|
||||
void CrwParser::encode(
|
||||
Blob& blob,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
const CrwImage* pCrwImage
|
||||
)
|
||||
void CrwParser::encode(Blob& blob, const byte* pData, size_t size, const CrwImage* pCrwImage)
|
||||
{
|
||||
// Parse image, starting with a CIFF header component
|
||||
CiffHeader header;
|
||||
|
||||
+36
-49
@@ -169,10 +169,10 @@ namespace Exiv2::Internal {
|
||||
components_.push_back(component.release());
|
||||
} // CiffDirectory::doAdd
|
||||
|
||||
void CiffHeader::read(const byte* pData, uint32_t size)
|
||||
void CiffHeader::read(const byte* pData, size_t size)
|
||||
{
|
||||
if (size < 14) throw
|
||||
Error(ErrorCode::kerNotACrwImage);
|
||||
if (size < 14)
|
||||
throw Error(ErrorCode::kerNotACrwImage);
|
||||
|
||||
if (pData[0] == 'I' && pData[0] == pData[1]) {
|
||||
byteOrder_ = littleEndian;
|
||||
@@ -199,18 +199,12 @@ namespace Exiv2::Internal {
|
||||
pRootDir_->readDirectory(pData + offset_, size - offset_, byteOrder_);
|
||||
} // CiffHeader::read
|
||||
|
||||
void CiffComponent::read(const byte* pData,
|
||||
uint32_t size,
|
||||
uint32_t start,
|
||||
ByteOrder byteOrder)
|
||||
void CiffComponent::read(const byte* pData, size_t size, uint32_t start, ByteOrder byteOrder)
|
||||
{
|
||||
doRead(pData, size, start, byteOrder);
|
||||
}
|
||||
|
||||
void CiffComponent::doRead(const byte* pData,
|
||||
uint32_t size,
|
||||
uint32_t start,
|
||||
ByteOrder byteOrder)
|
||||
void CiffComponent::doRead(const byte* pData, size_t size, uint32_t start, ByteOrder byteOrder)
|
||||
{
|
||||
// We're going read 10 bytes. Make sure they won't be out-of-bounds.
|
||||
enforce(size >= 10 && start <= size - 10, ErrorCode::kerNotACrwImage);
|
||||
@@ -253,7 +247,7 @@ namespace Exiv2::Internal {
|
||||
} // CiffComponent::doRead
|
||||
|
||||
void CiffDirectory::doRead(const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
uint32_t start,
|
||||
ByteOrder byteOrder)
|
||||
{
|
||||
@@ -270,9 +264,7 @@ namespace Exiv2::Internal {
|
||||
#endif
|
||||
} // CiffDirectory::doRead
|
||||
|
||||
void CiffDirectory::readDirectory(const byte* pData,
|
||||
uint32_t size,
|
||||
ByteOrder byteOrder)
|
||||
void CiffDirectory::readDirectory(const byte* pData, size_t size, ByteOrder byteOrder)
|
||||
{
|
||||
if (size < 4)
|
||||
throw Error(ErrorCode::kerCorruptedMetadata);
|
||||
@@ -360,21 +352,17 @@ namespace Exiv2::Internal {
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t CiffComponent::write(Blob& blob,
|
||||
ByteOrder byteOrder,
|
||||
uint32_t offset)
|
||||
size_t CiffComponent::write(Blob& blob, ByteOrder byteOrder, size_t offset)
|
||||
{
|
||||
return doWrite(blob, byteOrder, offset);
|
||||
}
|
||||
|
||||
uint32_t CiffEntry::doWrite(Blob& blob,
|
||||
ByteOrder /*byteOrder*/,
|
||||
uint32_t offset)
|
||||
size_t CiffEntry::doWrite(Blob& blob, ByteOrder /*byteOrder*/, size_t offset)
|
||||
{
|
||||
return writeValueData(blob, offset);
|
||||
} // CiffEntry::doWrite
|
||||
}
|
||||
|
||||
uint32_t CiffComponent::writeValueData(Blob& blob, uint32_t offset)
|
||||
size_t CiffComponent::writeValueData(Blob& blob, size_t offset)
|
||||
{
|
||||
if (dataLocation() == valueData) {
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
@@ -391,23 +379,21 @@ namespace Exiv2::Internal {
|
||||
}
|
||||
}
|
||||
return offset;
|
||||
} // CiffComponent::writeValueData
|
||||
}
|
||||
|
||||
uint32_t CiffDirectory::doWrite(Blob& blob,
|
||||
ByteOrder byteOrder,
|
||||
uint32_t offset)
|
||||
size_t CiffDirectory::doWrite(Blob& blob, ByteOrder byteOrder, size_t offset)
|
||||
{
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
std::cout << "Writing directory 0x" << std::hex << tag() << "---->\n";
|
||||
#endif
|
||||
// Ciff offsets are relative to the start of the directory
|
||||
uint32_t dirOffset = 0;
|
||||
size_t dirOffset = 0;
|
||||
|
||||
// Value data
|
||||
for (auto&& component : components_) {
|
||||
dirOffset = component->write(blob, byteOrder, dirOffset);
|
||||
}
|
||||
const uint32_t dirStart = dirOffset;
|
||||
const uint32_t dirStart = static_cast<uint32_t>(dirOffset);
|
||||
|
||||
// Number of directory entries
|
||||
byte buf[4];
|
||||
@@ -455,10 +441,10 @@ namespace Exiv2::Internal {
|
||||
us2Data(buf, tag_, byteOrder);
|
||||
append(blob, buf, 2);
|
||||
|
||||
ul2Data(buf, size_, byteOrder);
|
||||
ul2Data(buf, static_cast<uint32_t>(size_), byteOrder);
|
||||
append(blob, buf, 4);
|
||||
|
||||
ul2Data(buf, offset_, byteOrder);
|
||||
ul2Data(buf, static_cast<uint32_t>(offset_), byteOrder);
|
||||
append(blob, buf, 4);
|
||||
}
|
||||
|
||||
@@ -471,7 +457,7 @@ namespace Exiv2::Internal {
|
||||
// Copy value instead of size and offset
|
||||
append(blob, pData_, size_);
|
||||
// Pad with 0s
|
||||
for (uint32_t i = size_; i < 8; ++i) {
|
||||
for (size_t i = size_; i < 8; ++i) {
|
||||
blob.push_back(0);
|
||||
}
|
||||
}
|
||||
@@ -520,11 +506,11 @@ namespace Exiv2::Internal {
|
||||
{
|
||||
storage_ = std::move(buf);
|
||||
pData_ = storage_.c_data();
|
||||
size_ = static_cast<uint32_t>(storage_.size());
|
||||
size_ = storage_.size();
|
||||
if (size_ > 8 && dataLocation() == directoryData) {
|
||||
tag_ &= 0x3fff;
|
||||
}
|
||||
} // CiffComponent::setValue
|
||||
}
|
||||
|
||||
TypeId CiffComponent::typeId(uint16_t tag)
|
||||
{
|
||||
@@ -811,9 +797,9 @@ namespace Exiv2::Internal {
|
||||
assert(ifdId != ifdIdNotSet);
|
||||
|
||||
std::string groupName(Internal::groupName(ifdId));
|
||||
const uint32_t component_size = ciffComponent.size();
|
||||
const size_t component_size = ciffComponent.size();
|
||||
enforce(component_size % 2 == 0, ErrorCode::kerCorruptedMetadata);
|
||||
enforce(component_size/2 <= static_cast<uint32_t>(std::numeric_limits<uint16_t>::max()), ErrorCode::kerCorruptedMetadata);
|
||||
enforce(component_size/2 <= static_cast<size_t>(std::numeric_limits<uint16_t>::max()), ErrorCode::kerCorruptedMetadata);
|
||||
const auto num_components = static_cast<uint16_t>(component_size / 2);
|
||||
uint16_t c = 1;
|
||||
while (c < num_components) {
|
||||
@@ -915,10 +901,9 @@ namespace Exiv2::Internal {
|
||||
std::unique_ptr<Value> value;
|
||||
if (ciffComponent.typeId() != directory) {
|
||||
value = Value::create(ciffComponent.typeId());
|
||||
uint32_t size = 0;
|
||||
size_t size = 0;
|
||||
if (pCrwMapping->size_ != 0) {
|
||||
// size in the mapping table overrides all
|
||||
size = pCrwMapping->size_;
|
||||
size = pCrwMapping->size_; // size in the mapping table overrides all
|
||||
}
|
||||
else if (ciffComponent.typeId() == asciiString) {
|
||||
// determine size from the data, by looking for the first 0
|
||||
@@ -991,8 +976,9 @@ namespace Exiv2::Internal {
|
||||
CiffComponent* cc = pHead->findComponent(pCrwMapping->crwTagId_,
|
||||
pCrwMapping->crwDir_);
|
||||
if (!comment.empty()) {
|
||||
auto size = static_cast<uint32_t>(comment.size());
|
||||
if (cc && cc->size() > size) size = cc->size();
|
||||
auto size = comment.size();
|
||||
if (cc && cc->size() > size)
|
||||
size = cc->size();
|
||||
DataBuf buf(size);
|
||||
buf.copyBytes(0, comment.data(), comment.size());
|
||||
pHead->add(pCrwMapping->crwTagId_, pCrwMapping->crwDir_, std::move(buf));
|
||||
@@ -1019,12 +1005,14 @@ namespace Exiv2::Internal {
|
||||
const auto ed2 = image.exifData().findKey(k2);
|
||||
const auto edEnd = image.exifData().end();
|
||||
|
||||
long size = 0;
|
||||
if (ed1 != edEnd) size += ed1->size();
|
||||
if (ed2 != edEnd) size += ed2->size();
|
||||
size_t size{0};
|
||||
if (ed1 != edEnd)
|
||||
size += ed1->size();
|
||||
if (ed2 != edEnd)
|
||||
size += ed2->size();
|
||||
if (size != 0) {
|
||||
DataBuf buf(size);
|
||||
long pos = 0;
|
||||
size_t pos{0};
|
||||
if (ed1 != edEnd) {
|
||||
ed1->copy(buf.data(), pHead->byteOrder());
|
||||
pos += ed1->size();
|
||||
@@ -1039,7 +1027,7 @@ namespace Exiv2::Internal {
|
||||
else {
|
||||
pHead->remove(pCrwMapping->crwTagId_, pCrwMapping->crwDir_);
|
||||
}
|
||||
} // CrwMap::encode0x080a
|
||||
}
|
||||
|
||||
void CrwMap::encodeArray(const Image& image,
|
||||
const CrwMapping* pCrwMapping,
|
||||
@@ -1113,10 +1101,9 @@ namespace Exiv2::Internal {
|
||||
const auto edO = exivData.findKey(kO);
|
||||
const auto edEnd = exivData.end();
|
||||
|
||||
CiffComponent* cc = pHead->findComponent(pCrwMapping->crwTagId_,
|
||||
pCrwMapping->crwDir_);
|
||||
CiffComponent* cc = pHead->findComponent(pCrwMapping->crwTagId_, pCrwMapping->crwDir_);
|
||||
if (edX != edEnd || edY != edEnd || edO != edEnd) {
|
||||
uint32_t size = 28;
|
||||
size_t size = 28;
|
||||
if (cc) {
|
||||
if (cc->size() < size)
|
||||
throw Error(ErrorCode::kerCorruptedMetadata);
|
||||
|
||||
+18
-24
@@ -110,10 +110,7 @@ namespace Exiv2::Internal {
|
||||
|
||||
@throw Error If the component cannot be parsed.
|
||||
*/
|
||||
void read(const byte* pData,
|
||||
uint32_t size,
|
||||
uint32_t start,
|
||||
ByteOrder byteOrder);
|
||||
void read(const byte* pData, size_t size, uint32_t start, ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Write the metadata from the raw metadata component to the
|
||||
binary image \em blob. This method may append to the blob.
|
||||
@@ -124,7 +121,8 @@ namespace Exiv2::Internal {
|
||||
|
||||
@return New offset
|
||||
*/
|
||||
uint32_t write(Blob& blob, ByteOrder byteOrder, uint32_t offset);
|
||||
size_t write(Blob& blob, ByteOrder byteOrder, size_t offset);
|
||||
|
||||
/*!
|
||||
@brief Writes the entry's value if size is larger than eight bytes. If
|
||||
needed, the value is padded with one 0 byte to make the number
|
||||
@@ -135,7 +133,8 @@ namespace Exiv2::Internal {
|
||||
|
||||
@return New offset.
|
||||
*/
|
||||
uint32_t writeValueData(Blob& blob, uint32_t offset);
|
||||
size_t writeValueData(Blob& blob, size_t offset);
|
||||
|
||||
//! Set the directory tag for this component.
|
||||
void setDir(uint16_t dir) { dir_ = dir; }
|
||||
//! Set the data value of the entry.
|
||||
@@ -190,10 +189,10 @@ namespace Exiv2::Internal {
|
||||
of data bytes this component can have. The actual size,
|
||||
i.e., used data bytes, may be less than 8.
|
||||
*/
|
||||
uint32_t size() const { return size_; }
|
||||
size_t size() const { return size_; }
|
||||
|
||||
//! Return the offset to the data from the start of the directory
|
||||
uint32_t offset() const { return offset_; }
|
||||
size_t offset() const { return offset_; }
|
||||
|
||||
//! Return a pointer to the data area of this component
|
||||
const byte* pData() const { return pData_; }
|
||||
@@ -224,18 +223,13 @@ namespace Exiv2::Internal {
|
||||
//! Implements remove(). The default implementation does nothing.
|
||||
virtual void doRemove(CrwDirs& crwDirs, uint16_t crwTagId);
|
||||
//! Implements read(). The default implementation reads a directory entry.
|
||||
virtual void doRead(const byte* pData,
|
||||
uint32_t size,
|
||||
uint32_t start,
|
||||
ByteOrder byteOrder);
|
||||
virtual void doRead(const byte* pData, size_t size, uint32_t start, ByteOrder byteOrder);
|
||||
//! Implements write()
|
||||
virtual uint32_t doWrite(Blob& blob,
|
||||
ByteOrder byteOrder,
|
||||
uint32_t offset) =0;
|
||||
virtual size_t doWrite(Blob& blob, ByteOrder byteOrder, size_t offset) = 0;
|
||||
//! Set the size of the data area.
|
||||
void setSize(uint32_t size) { size_ = size; }
|
||||
void setSize(size_t size) { size_ = size; }
|
||||
//! Set the offset for this component.
|
||||
void setOffset(uint32_t offset) { offset_ = offset; }
|
||||
void setOffset(size_t offset) { offset_ = offset; }
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
@@ -258,8 +252,8 @@ namespace Exiv2::Internal {
|
||||
// DATA
|
||||
uint16_t dir_ = 0; //!< Tag of the directory containing this component
|
||||
uint16_t tag_ = 0; //!< Tag of the entry
|
||||
uint32_t size_ = 0; //!< Size of the data area
|
||||
uint32_t offset_ = 0; //!< Offset to the data area from start of dir
|
||||
size_t size_ = 0; //!< Size of the data area
|
||||
size_t offset_ = 0; //!< Offset to the data area from start of dir
|
||||
|
||||
// Notes on the ownership model of pData_: pData_ is a always a read-only
|
||||
// pointer to a buffer owned by somebody else. Usually it is a pointer
|
||||
@@ -299,7 +293,7 @@ namespace Exiv2::Internal {
|
||||
@brief Implements write(). Writes only the value data of the entry,
|
||||
using writeValueData().
|
||||
*/
|
||||
uint32_t doWrite(Blob& blob, ByteOrder byteOrder, uint32_t offset) override;
|
||||
size_t doWrite(Blob& blob, ByteOrder byteOrder, size_t offset) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
@@ -336,7 +330,7 @@ namespace Exiv2::Internal {
|
||||
@param byteOrder Applicable byte order (little or big endian)
|
||||
*/
|
||||
void readDirectory(const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder);
|
||||
//@}
|
||||
|
||||
@@ -353,9 +347,9 @@ namespace Exiv2::Internal {
|
||||
@brief Implements write(). Writes the complete Ciff directory to
|
||||
the blob.
|
||||
*/
|
||||
uint32_t doWrite(Blob& blob, ByteOrder byteOrder, uint32_t offset) override;
|
||||
size_t doWrite(Blob& blob, ByteOrder byteOrder, size_t offset) override;
|
||||
// See base class comment
|
||||
void doRead(const byte* pData, uint32_t size, uint32_t start, ByteOrder byteOrder) override;
|
||||
void doRead(const byte* pData, size_t size, uint32_t start, ByteOrder byteOrder) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
@@ -411,7 +405,7 @@ namespace Exiv2::Internal {
|
||||
|
||||
@throw Error If the image cannot be parsed.
|
||||
*/
|
||||
void read(const byte* pData, uint32_t size);
|
||||
void read(const byte* pData, size_t size);
|
||||
/*!
|
||||
@brief Set the value of entry \em crwTagId in directory \em crwDir to
|
||||
\em buf. If this tag doesn't exist, it is added along with all
|
||||
|
||||
+13
-13
@@ -302,7 +302,7 @@ namespace Exiv2 {
|
||||
|
||||
int Exifdatum::idx() const { return key_ ? key_->idx() : 0; }
|
||||
|
||||
long Exifdatum::copy(byte* buf, ByteOrder byteOrder) const { return value_ ? value_->copy(buf, byteOrder) : 0; }
|
||||
size_t Exifdatum::copy(byte* buf, ByteOrder byteOrder) const { return value_ ? value_->copy(buf, byteOrder) : 0; }
|
||||
|
||||
TypeId Exifdatum::typeId() const { return value_ ? value_->typeId() : invalidTypeId; }
|
||||
|
||||
@@ -311,24 +311,24 @@ namespace Exiv2 {
|
||||
return TypeInfo::typeName(typeId());
|
||||
}
|
||||
|
||||
long Exifdatum::typeSize() const
|
||||
size_t Exifdatum::typeSize() const
|
||||
{
|
||||
return static_cast<long>(TypeInfo::typeSize(typeId()));
|
||||
return TypeInfo::typeSize(typeId());
|
||||
}
|
||||
|
||||
size_t Exifdatum::count() const { return value_ ? value_->count() : 0; }
|
||||
|
||||
long Exifdatum::size() const { return value_ ? static_cast<long>(value_->size()) : 0; }
|
||||
size_t Exifdatum::size() const { return value_ ? value_->size() : 0; }
|
||||
|
||||
std::string Exifdatum::toString() const { return value_ ? value_->toString() : ""; }
|
||||
|
||||
std::string Exifdatum::toString(long n) const { return value_ ? value_->toString(n) : ""; }
|
||||
std::string Exifdatum::toString(size_t n) const { return value_ ? value_->toString(n) : ""; }
|
||||
|
||||
int64_t Exifdatum::toInt64(long n) const { return value_ ? value_->toInt64(n) : -1; }
|
||||
int64_t Exifdatum::toInt64(size_t n) const { return value_ ? value_->toInt64(n) : -1; }
|
||||
|
||||
float Exifdatum::toFloat(long n) const { return value_ ? value_->toFloat(n) : -1; }
|
||||
float Exifdatum::toFloat(size_t n) const { return value_ ? value_->toFloat(n) : -1; }
|
||||
|
||||
Rational Exifdatum::toRational(long n) const { return value_ ? value_->toRational(n) : Rational(-1, 1); }
|
||||
Rational Exifdatum::toRational(size_t n) const { return value_ ? value_->toRational(n) : Rational(-1, 1); }
|
||||
|
||||
Value::UniquePtr Exifdatum::getValue() const { return value_ ? value_->clone() : nullptr; }
|
||||
|
||||
@@ -574,10 +574,10 @@ namespace Exiv2 {
|
||||
// Encode and check if the result fits into a JPEG Exif APP1 segment
|
||||
MemIo mio1;
|
||||
TiffHeader header(byteOrder, 0x00000008, false);
|
||||
WriteMethod wm = TiffParserWorker::encode(mio1, pData, static_cast<uint32_t>(size), ed, emptyIptc, emptyXmp,
|
||||
WriteMethod wm = TiffParserWorker::encode(mio1, pData, size, ed, emptyIptc, emptyXmp,
|
||||
Tag::root, TiffMapping::findEncoder, &header, nullptr);
|
||||
if (mio1.size() <= 65527) {
|
||||
append(blob, mio1.mmap(), static_cast<uint32_t>(mio1.size()));
|
||||
append(blob, mio1.mmap(), mio1.size());
|
||||
return wm;
|
||||
}
|
||||
|
||||
@@ -672,9 +672,9 @@ namespace Exiv2 {
|
||||
|
||||
// Encode the remaining Exif tags again, don't care if it fits this time
|
||||
MemIo mio2;
|
||||
wm = TiffParserWorker::encode(mio2, pData, static_cast<uint32_t>(size), ed, emptyIptc, emptyXmp, Tag::root,
|
||||
wm = TiffParserWorker::encode(mio2, pData, size, ed, emptyIptc, emptyXmp, Tag::root,
|
||||
TiffMapping::findEncoder, &header, nullptr);
|
||||
append(blob, mio2.mmap(), static_cast<uint32_t>(mio2.size()));
|
||||
append(blob, mio2.mmap(), mio2.size());
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
if (wm == wmIntrusive) {
|
||||
std::cerr << "SIZE OF EXIF DATA IS " << std::dec << mio2.size() << " BYTES\n";
|
||||
@@ -771,7 +771,7 @@ namespace {
|
||||
{
|
||||
int64_t sum = 0;
|
||||
for (size_t i = 0; i < md.count(); ++i) {
|
||||
sum += md.toInt64(static_cast<long>(i));
|
||||
sum += md.toInt64(i);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
+9
-7
@@ -152,10 +152,12 @@ namespace Exiv2 {
|
||||
return rc;
|
||||
} // base64encode
|
||||
|
||||
long base64decode(const char* in,char* out,size_t out_size) {
|
||||
long result = 0;
|
||||
size_t base64decode(const char* in,char* out,size_t out_size)
|
||||
{
|
||||
size_t result = 0;
|
||||
size_t input_length = in ? ::strlen(in) : 0;
|
||||
if (!in || input_length % 4 != 0) return result;
|
||||
if (!in || input_length % 4 != 0)
|
||||
return result;
|
||||
|
||||
auto encoding_table = reinterpret_cast<const unsigned char*>(base64_encode);
|
||||
unsigned char decoding_table[256];
|
||||
@@ -186,11 +188,11 @@ namespace Exiv2 {
|
||||
if (j < output_length) out[j++] = (triple >> 0 * 8) & 0xFF;
|
||||
}
|
||||
out[output_length]=0;
|
||||
result = static_cast<long>(output_length);
|
||||
result = output_length;
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
} // base64decode
|
||||
}
|
||||
|
||||
Protocol fileProtocol(const std::string& path) {
|
||||
Protocol result = pFile ;
|
||||
@@ -380,7 +382,7 @@ namespace Exiv2 {
|
||||
if ( procs ) procstat_freeprocs(procstat, procs);
|
||||
if ( procstat ) procstat_close(procstat);
|
||||
#elif defined(__sun__)
|
||||
// https://stackoverflow.com/questions/47472762/on-solaris-how-to-get-the-full-path-of-executable-of-running-process-programatic
|
||||
// https://stackoverflow.com/questions/47472762/on-solaris-how-to-get-the-full-path-of-executable-of-running-process-programatic
|
||||
const char* proc = Internal::stringFormat("/proc/%d/path/a.out",getpid()).c_str();
|
||||
char path[500];
|
||||
ssize_t l = readlink (proc,path,sizeof(path)-1);
|
||||
|
||||
+15
-16
@@ -232,7 +232,7 @@ namespace Exiv2 {
|
||||
return bSwap ? result : value;
|
||||
}
|
||||
|
||||
uint16_t Image::byteSwap2(const DataBuf& buf,size_t offset,bool bSwap)
|
||||
uint16_t Image::byteSwap2(const DataBuf& buf,size_t offset,bool bSwap)
|
||||
{
|
||||
uint16_t v = 0;
|
||||
auto p = reinterpret_cast<char*>(&v);
|
||||
@@ -241,7 +241,7 @@ namespace Exiv2 {
|
||||
return Image::byteSwap(v,bSwap);
|
||||
}
|
||||
|
||||
uint32_t Image::byteSwap4(const DataBuf& buf,size_t offset,bool bSwap)
|
||||
uint32_t Image::byteSwap4(const DataBuf& buf,size_t offset,bool bSwap)
|
||||
{
|
||||
uint32_t v = 0;
|
||||
auto p = reinterpret_cast<char*>(&v);
|
||||
@@ -253,7 +253,7 @@ namespace Exiv2 {
|
||||
}
|
||||
|
||||
/// \todo not used internally. At least we should test it
|
||||
uint64_t Image::byteSwap8(const DataBuf& buf,size_t offset,bool bSwap)
|
||||
uint64_t Image::byteSwap8(const DataBuf& buf,size_t offset,bool bSwap)
|
||||
{
|
||||
uint64_t v = 0;
|
||||
auto p = reinterpret_cast<byte*>(&v);
|
||||
@@ -293,7 +293,8 @@ namespace Exiv2 {
|
||||
}
|
||||
|
||||
static std::set<long> visits; // #547
|
||||
void Image::printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStructureOption option,uint32_t start,bool bSwap,char c,int depth)
|
||||
|
||||
void Image::printIFDStructure(BasicIo& io, std::ostream& out, Exiv2::PrintStructureOption option,size_t start,bool bSwap,char c,int depth)
|
||||
{
|
||||
depth++;
|
||||
if ( depth == 1 ) visits.clear();
|
||||
@@ -325,7 +326,7 @@ namespace Exiv2 {
|
||||
throw Error(ErrorCode::kerCorruptedMetadata);
|
||||
}
|
||||
visits.insert(io.tell());
|
||||
|
||||
|
||||
if ( bFirst && bPrint ) {
|
||||
out << Internal::indent(depth)
|
||||
<< " address | tag | "
|
||||
@@ -355,7 +356,7 @@ namespace Exiv2 {
|
||||
: count
|
||||
;
|
||||
uint32_t pad = isStringType(type) ? 1 : 0;
|
||||
uint32_t size = isStringType(type) ? 1
|
||||
size_t size = isStringType(type) ? 1
|
||||
: is2ByteType(type) ? 2
|
||||
: is4ByteType(type) ? 4
|
||||
: is8ByteType(type) ? 8
|
||||
@@ -365,19 +366,17 @@ namespace Exiv2 {
|
||||
// if ( offset > io.size() ) offset = 0; // Denial of service?
|
||||
|
||||
// #55 and #56 memory allocation crash test/data/POC8
|
||||
const uint64_t allocate64 = static_cast<uint64_t>(size) * count + pad + 20;
|
||||
const size_t allocate64 = size * count + pad + 20;
|
||||
if ( allocate64 > io.size() ) {
|
||||
throw Error(ErrorCode::kerInvalidMalloc);
|
||||
}
|
||||
// Overflow check
|
||||
enforce(allocate64 <= static_cast<uint64_t>(std::numeric_limits<uint32_t>::max()), ErrorCode::kerCorruptedMetadata);
|
||||
enforce(allocate64 <= static_cast<uint64_t>(std::numeric_limits<long>::max()), ErrorCode::kerCorruptedMetadata);
|
||||
const auto allocate = static_cast<long>(allocate64);
|
||||
DataBuf buf(allocate); // allocate a buffer
|
||||
enforce(allocate64 <= std::numeric_limits<size_t>::max(), ErrorCode::kerCorruptedMetadata);
|
||||
DataBuf buf(allocate64); // allocate a buffer
|
||||
buf.copyBytes(0, dir.c_data(8), 4); // copy dir[8:11] into buffer (short strings)
|
||||
|
||||
// We have already checked that this multiplication cannot overflow.
|
||||
const uint32_t count_x_size = count*size;
|
||||
const size_t count_x_size = count*size;
|
||||
const bool bOffsetIsPointer = count_x_size > 4;
|
||||
|
||||
if ( bOffsetIsPointer ) { // read into buffer
|
||||
@@ -388,7 +387,7 @@ namespace Exiv2 {
|
||||
}
|
||||
|
||||
if ( bPrint ) {
|
||||
const uint32_t address = start + 2 + i*12 ;
|
||||
const size_t address = start + 2 + i*12 ;
|
||||
const std::string offsetString = bOffsetIsPointer?
|
||||
Internal::stringFormat("%10u", offset):
|
||||
"";
|
||||
@@ -503,12 +502,12 @@ namespace Exiv2 {
|
||||
|
||||
// read header (we already know for certain that we have a Tiff file)
|
||||
io.readOrThrow(dir.data(), 8, ErrorCode::kerCorruptedMetadata);
|
||||
auto c = static_cast<char>(dir.read_uint8(0));
|
||||
auto c = dir.read_uint8(0);
|
||||
bool bSwap = ( c == 'M' && isLittleEndianPlatform() )
|
||||
|| ( c == 'I' && isBigEndianPlatform() )
|
||||
;
|
||||
uint32_t start = byteSwap4(dir,4,bSwap);
|
||||
printIFDStructure(io, out, option, start + static_cast<uint32_t>(offset), bSwap, c, depth);
|
||||
size_t start = byteSwap4(dir,4,bSwap);
|
||||
printIFDStructure(io, out, option, start + offset, bSwap, c, depth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+17
-20
@@ -77,7 +77,7 @@ namespace Exiv2 {
|
||||
value_ = rhs.value_->clone(); // deep copy
|
||||
}
|
||||
|
||||
long Iptcdatum::copy(byte* buf, ByteOrder byteOrder) const { return value_ ? value_->copy(buf, byteOrder) : 0; }
|
||||
size_t Iptcdatum::copy(byte* buf, ByteOrder byteOrder) const { return value_ ? value_->copy(buf, byteOrder) : 0; }
|
||||
|
||||
std::ostream& Iptcdatum::write(std::ostream& os, const ExifData*) const
|
||||
{
|
||||
@@ -107,24 +107,24 @@ namespace Exiv2 {
|
||||
return TypeInfo::typeName(typeId());
|
||||
}
|
||||
|
||||
long Iptcdatum::typeSize() const
|
||||
size_t Iptcdatum::typeSize() const
|
||||
{
|
||||
return static_cast<long>(TypeInfo::typeSize(typeId()));
|
||||
return TypeInfo::typeSize(typeId());
|
||||
}
|
||||
|
||||
size_t Iptcdatum::count() const { return value_ ? value_->count() : 0; }
|
||||
|
||||
long Iptcdatum::size() const { return value_ ? static_cast<long>(value_->size()) : 0; }
|
||||
size_t Iptcdatum::size() const { return value_ ? value_->size() : 0; }
|
||||
|
||||
std::string Iptcdatum::toString() const { return value_ ? value_->toString() : ""; }
|
||||
|
||||
std::string Iptcdatum::toString(long n) const { return value_ ? value_->toString(n) : ""; }
|
||||
std::string Iptcdatum::toString(size_t n) const { return value_ ? value_->toString(n) : ""; }
|
||||
|
||||
int64_t Iptcdatum::toInt64(long n) const { return value_ ? value_->toInt64(n) : -1; }
|
||||
int64_t Iptcdatum::toInt64(size_t n) const { return value_ ? value_->toInt64(n) : -1; }
|
||||
|
||||
float Iptcdatum::toFloat(long n) const { return value_ ? value_->toFloat(n) : -1; }
|
||||
float Iptcdatum::toFloat(size_t n) const { return value_ ? value_->toFloat(n) : -1; }
|
||||
|
||||
Rational Iptcdatum::toRational(long n) const { return value_ ? value_->toRational(n) : Rational(-1, 1); }
|
||||
Rational Iptcdatum::toRational(size_t n) const { return value_ ? value_->toRational(n) : Rational(-1, 1); }
|
||||
|
||||
Value::UniquePtr Iptcdatum::getValue() const { return value_ ? value_->clone() : nullptr; }
|
||||
|
||||
@@ -197,13 +197,13 @@ namespace Exiv2 {
|
||||
return *pos;
|
||||
}
|
||||
|
||||
long IptcData::size() const
|
||||
size_t IptcData::size() const
|
||||
{
|
||||
long newSize = 0;
|
||||
size_t newSize = 0;
|
||||
for (auto&& iptc : iptcMetadata_) {
|
||||
// marker, record Id, dataset num, first 2 bytes of size
|
||||
newSize += 5;
|
||||
long dataSize = iptc.size();
|
||||
size_t dataSize = iptc.size();
|
||||
newSize += dataSize;
|
||||
if (dataSize > 32767) {
|
||||
// extended dataset (we always use 4 bytes)
|
||||
@@ -211,7 +211,7 @@ namespace Exiv2 {
|
||||
}
|
||||
}
|
||||
return newSize;
|
||||
} // IptcData::size
|
||||
}
|
||||
|
||||
int IptcData::add(const IptcKey& key, Value* value)
|
||||
{
|
||||
@@ -353,11 +353,7 @@ namespace Exiv2 {
|
||||
|
||||
const byte IptcParser::marker_ = 0x1C; // Dataset marker
|
||||
|
||||
int IptcParser::decode(
|
||||
IptcData& iptcData,
|
||||
const byte* pData,
|
||||
uint32_t size
|
||||
)
|
||||
int IptcParser::decode(IptcData& iptcData, const byte* pData, size_t size)
|
||||
{
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
std::cerr << "IptcParser::decode, size = " << size << "\n";
|
||||
@@ -385,7 +381,8 @@ namespace Exiv2 {
|
||||
uint16_t sizeOfSize = (getUShort(pRead, bigEndian) & 0x7FFF);
|
||||
if (sizeOfSize > 4) return 5;
|
||||
pRead += 2;
|
||||
if (sizeOfSize > static_cast<size_t>(pEnd - pRead)) return 6;
|
||||
if (sizeOfSize > pEnd - pRead)
|
||||
return 6;
|
||||
sizeData = 0;
|
||||
for (; sizeOfSize > 0; --sizeOfSize) {
|
||||
sizeData |= *pRead++ << (8 *(sizeOfSize-1));
|
||||
@@ -450,13 +447,13 @@ namespace Exiv2 {
|
||||
*pWrite++ = static_cast<byte>(iter.tag());
|
||||
|
||||
// extended or standard dataset?
|
||||
long dataSize = iter.size();
|
||||
size_t dataSize = iter.size();
|
||||
if (dataSize > 32767) {
|
||||
// always use 4 bytes for extended length
|
||||
uint16_t sizeOfSize = 4 | 0x8000;
|
||||
us2Data(pWrite, sizeOfSize, bigEndian);
|
||||
pWrite += 2;
|
||||
ul2Data(pWrite, dataSize, bigEndian);
|
||||
ul2Data(pWrite, static_cast<uint32_t>(dataSize), bigEndian);
|
||||
pWrite += 4;
|
||||
}
|
||||
else {
|
||||
|
||||
+13
-12
@@ -254,7 +254,7 @@ static void boxes_check(size_t b,size_t m)
|
||||
#endif
|
||||
|
||||
const long pad = 3 ; // 3 padding bytes 2 0 0
|
||||
const size_t data_length = Safe::add(subBox.length, static_cast<uint32_t>(8));
|
||||
const size_t data_length = Safe::add(subBox.length, 8u);
|
||||
// data_length makes no sense if it is larger than the rest of the file
|
||||
if (data_length > io_->size() - io_->tell()) {
|
||||
throw Error(ErrorCode::kerCorruptedMetadata);
|
||||
@@ -384,7 +384,7 @@ static void boxes_check(size_t b,size_t m)
|
||||
if (io_->error()) throw Error(ErrorCode::kerFailedToReadImageData);
|
||||
if (bufRead != rawData.size()) throw Error(ErrorCode::kerInputDataReadFailed);
|
||||
|
||||
if (IptcParser::decode(iptcData_, rawData.c_data(), static_cast<uint32_t>(rawData.size())))
|
||||
if (IptcParser::decode(iptcData_, rawData.c_data(), rawData.size()))
|
||||
{
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
EXV_WARNING << "Failed to decode IPTC metadata." << std::endl;
|
||||
@@ -399,7 +399,7 @@ static void boxes_check(size_t b,size_t m)
|
||||
std::cout << "Exiv2::Jp2Image::readMetadata: Xmp data found" << std::endl;
|
||||
#endif
|
||||
enforce(box.length >= sizeof(box) + sizeof(uuid), ErrorCode::kerCorruptedMetadata);
|
||||
rawData.alloc(box.length - static_cast<uint32_t>(sizeof(box) + sizeof(uuid)));
|
||||
rawData.alloc(box.length - (sizeof(box) + sizeof(uuid)));
|
||||
bufRead = io_->read(rawData.data(), rawData.size());
|
||||
if (io_->error())
|
||||
throw Error(ErrorCode::kerFailedToReadImageData);
|
||||
@@ -434,7 +434,8 @@ static void boxes_check(size_t b,size_t m)
|
||||
|
||||
// Move to the next box.
|
||||
io_->seek(static_cast<long>(position - sizeof(box) + box.length), BasicIo::beg);
|
||||
if (io_->error()) throw Error(ErrorCode::kerFailedToReadImageData);
|
||||
if (io_->error())
|
||||
throw Error(ErrorCode::kerFailedToReadImageData);
|
||||
}
|
||||
|
||||
} // Jp2Image::readMetadata
|
||||
@@ -628,7 +629,7 @@ static void boxes_check(size_t b,size_t m)
|
||||
void Jp2Image::encodeJp2Header(const DataBuf& boxBuf,DataBuf& outBuf)
|
||||
{
|
||||
DataBuf output(boxBuf.size() + iccProfile_.size() + 100); // allocate sufficient space
|
||||
long outlen = sizeof(Jp2BoxHeader) ; // now many bytes have we written to output?
|
||||
size_t outlen = sizeof(Jp2BoxHeader) ; // now many bytes have we written to output?
|
||||
long inlen = sizeof(Jp2BoxHeader) ; // how many bytes have we read from boxBuf?
|
||||
enforce(sizeof(Jp2BoxHeader) <= output.size(), Exiv2::ErrorCode::kerCorruptedMetadata);
|
||||
auto pBox = reinterpret_cast<const Jp2BoxHeader*>(boxBuf.c_data());
|
||||
@@ -662,7 +663,7 @@ static void boxes_check(size_t b,size_t m)
|
||||
count = length;
|
||||
}
|
||||
|
||||
uint32_t newlen = subBox.length;
|
||||
size_t newlen = subBox.length;
|
||||
if ( newBox.type == kJp2BoxTypeColorHeader ) {
|
||||
bWroteColor = true ;
|
||||
if ( ! iccProfileDefined() ) {
|
||||
@@ -677,9 +678,9 @@ static void boxes_check(size_t b,size_t m)
|
||||
} else {
|
||||
const char* pad = "\x02\x00\x00";
|
||||
uint32_t psize = 3;
|
||||
newlen = sizeof(newBox) + psize + static_cast<uint32_t>(iccProfile_.size());
|
||||
newlen = sizeof(newBox) + psize + iccProfile_.size();
|
||||
enforce(newlen <= static_cast<size_t>(output.size() - outlen), Exiv2::ErrorCode::kerCorruptedMetadata);
|
||||
ul2Data(reinterpret_cast<byte*>(&newBox.length), newlen, bigEndian);
|
||||
ul2Data(reinterpret_cast<byte*>(&newBox.length), static_cast<uint32_t>(newlen), bigEndian);
|
||||
ul2Data(reinterpret_cast<byte*>(&newBox.type), newBox.type, bigEndian);
|
||||
output.copyBytes(outlen ,&newBox ,sizeof(newBox) );
|
||||
output.copyBytes(outlen+sizeof(newBox) , pad ,psize );
|
||||
@@ -699,8 +700,8 @@ static void boxes_check(size_t b,size_t m)
|
||||
outBuf.copyBytes(0,output.c_data(),outlen);
|
||||
auto oBox = reinterpret_cast<Jp2BoxHeader*>(outBuf.data());
|
||||
ul2Data(reinterpret_cast<byte*>(&oBox->type), kJp2BoxTypeJp2Header, bigEndian);
|
||||
ul2Data(reinterpret_cast<byte*>(&oBox->length), outlen, bigEndian);
|
||||
} // Jp2Image::encodeJp2Header
|
||||
ul2Data(reinterpret_cast<byte*>(&oBox->length), static_cast<uint32_t>(outlen), bigEndian);
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
@@ -815,7 +816,7 @@ static void boxes_check(size_t b,size_t m)
|
||||
Blob blob;
|
||||
ExifParser::encode(blob, littleEndian, exifData_);
|
||||
if (!blob.empty()) {
|
||||
DataBuf rawExif(static_cast<long>(blob.size()));
|
||||
DataBuf rawExif(blob.size());
|
||||
rawExif.copyBytes(0, &blob[0], blob.size());
|
||||
|
||||
DataBuf boxData(8 + 16 + rawExif.size());
|
||||
@@ -869,7 +870,7 @@ static void boxes_check(size_t b,size_t m)
|
||||
if (!xmpPacket_.empty()) {
|
||||
// Update Xmp data to a new UUID box
|
||||
|
||||
DataBuf xmp(reinterpret_cast<const byte*>(xmpPacket_.data()), static_cast<long>(xmpPacket_.size()));
|
||||
DataBuf xmp(reinterpret_cast<const byte*>(xmpPacket_.data()), xmpPacket_.size());
|
||||
DataBuf boxData(8 + 16 + xmp.size());
|
||||
ul2Data(boxDataSize, static_cast<uint32_t>(boxData.size()), Exiv2::bigEndian);
|
||||
ul2Data(boxUUIDtype, kJp2BoxTypeUuid, Exiv2::bigEndian);
|
||||
|
||||
+8
-9
@@ -117,8 +117,7 @@ namespace Exiv2 {
|
||||
return -2;
|
||||
}
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
if ( (dataSize & 1)
|
||||
&& position + dataSize == static_cast<uint32_t>(sizePsData)) {
|
||||
if ( (dataSize & 1) && position + dataSize == sizePsData) {
|
||||
std::cerr << "Warning: "
|
||||
<< "Photoshop IRB data is not padded to even size\n";
|
||||
}
|
||||
@@ -174,7 +173,8 @@ namespace Exiv2 {
|
||||
assert(pPsData);
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
std::cerr << "IRB block at the beginning of Photoshop::setIptcIrb\n";
|
||||
if (sizePsData == 0) std::cerr << " None.\n";
|
||||
if (sizePsData == 0)
|
||||
std::cerr << " None.\n";
|
||||
else hexdump(std::cerr, pPsData, sizePsData);
|
||||
#endif
|
||||
const byte* record = pPsData;
|
||||
@@ -357,7 +357,6 @@ namespace Exiv2 {
|
||||
&& buf.cmpBytes(2, Photoshop::ps3Id_, 14) == 0) {
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
std::cerr << "Found app13 segment, size = " << size << "\n";
|
||||
//hexdump(std::cerr, psData.pData_, psData.size_);
|
||||
#endif
|
||||
// Append to psBlob
|
||||
append(psBlob, buf.c_data(16), size - 16);
|
||||
@@ -457,7 +456,7 @@ namespace Exiv2 {
|
||||
pCur = record + sizeHdr + sizeIptc + (sizeIptc & 1);
|
||||
}
|
||||
if (!iptcBlob.empty() &&
|
||||
IptcParser::decode(iptcData_, &iptcBlob[0], static_cast<uint32_t>(iptcBlob.size()))) {
|
||||
IptcParser::decode(iptcData_, &iptcBlob[0], iptcBlob.size())) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
EXV_WARNING << "Failed to decode IPTC metadata.\n";
|
||||
#endif
|
||||
@@ -732,7 +731,7 @@ namespace Exiv2 {
|
||||
size_t count = iptcDataSegs.size();
|
||||
|
||||
// figure out which blocks to copy
|
||||
std::vector<long> pos(count + 2);
|
||||
std::vector<size_t> pos(count + 2);
|
||||
pos[0] = 0;
|
||||
// copy the data that is not iptc
|
||||
auto it = iptcDataSegs.begin();
|
||||
@@ -742,7 +741,7 @@ namespace Exiv2 {
|
||||
pos[i + 1] = bEven ? *it : pos[i] + *it;
|
||||
++it;
|
||||
}
|
||||
pos[count + 1] = static_cast<long>(io_->size());
|
||||
pos[count + 1] = io_->size();
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
for (size_t i = 0; i < count + 2; i++)
|
||||
std::cout << pos[i] << " ";
|
||||
@@ -756,10 +755,10 @@ namespace Exiv2 {
|
||||
// binary copy io_ to a temporary file
|
||||
auto tempIo = std::make_unique<MemIo>();
|
||||
for (size_t i = 0; i < (count / 2) + 1; i++) {
|
||||
long start = pos[2 * i] + 2; // step JPG 2 byte marker
|
||||
size_t start = pos[2 * i] + 2; // step JPG 2 byte marker
|
||||
if (start == 2)
|
||||
start = 0; // read the file 2 byte SOI
|
||||
long length = pos[2 * i + 1] - start;
|
||||
size_t length = pos[2 * i + 1] - start;
|
||||
if (length) {
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
std::cout << start << ":" << length << std::endl;
|
||||
|
||||
+110
-124
@@ -138,7 +138,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
const std::string& make,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder)
|
||||
{
|
||||
TiffComponent* tc = nullptr;
|
||||
@@ -176,7 +176,7 @@ namespace Exiv2::Internal {
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t MnHeader::ifdOffset() const
|
||||
size_t MnHeader::ifdOffset() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -195,7 +195,7 @@ namespace Exiv2::Internal {
|
||||
'O', 'L', 'Y', 'M', 'P', 0x00, 0x01, 0x00
|
||||
};
|
||||
|
||||
uint32_t OlympusMnHeader::sizeOfSignature()
|
||||
size_t OlympusMnHeader::sizeOfSignature()
|
||||
{
|
||||
return sizeof(signature_);
|
||||
}
|
||||
@@ -205,39 +205,36 @@ namespace Exiv2::Internal {
|
||||
read(signature_, sizeOfSignature(), invalidByteOrder);
|
||||
}
|
||||
|
||||
uint32_t OlympusMnHeader::size() const
|
||||
size_t OlympusMnHeader::size() const
|
||||
{
|
||||
return static_cast<uint32_t>(header_.size());
|
||||
return header_.size();
|
||||
}
|
||||
|
||||
uint32_t OlympusMnHeader::ifdOffset() const
|
||||
size_t OlympusMnHeader::ifdOffset() const
|
||||
{
|
||||
return sizeOfSignature();
|
||||
}
|
||||
|
||||
bool OlympusMnHeader::read(const byte* pData,
|
||||
uint32_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
bool OlympusMnHeader::read(const byte* pData, size_t size, ByteOrder /*byteOrder*/)
|
||||
{
|
||||
if (!pData || size < sizeOfSignature()) return false;
|
||||
if (!pData || size < sizeOfSignature())
|
||||
return false;
|
||||
header_.alloc(sizeOfSignature());
|
||||
header_.copyBytes(0, pData, header_.size());
|
||||
return !(static_cast<uint32_t>(header_.size()) < sizeOfSignature() ||
|
||||
0 != header_.cmpBytes(0, signature_, 6));
|
||||
} // OlympusMnHeader::read
|
||||
return !(header_.size() < sizeOfSignature() || 0 != header_.cmpBytes(0, signature_, 6));
|
||||
}
|
||||
|
||||
uint32_t OlympusMnHeader::write(IoWrapper& ioWrapper,
|
||||
ByteOrder /*byteOrder*/) const
|
||||
size_t OlympusMnHeader::write(IoWrapper& ioWrapper, ByteOrder /*byteOrder*/) const
|
||||
{
|
||||
ioWrapper.write(signature_, sizeOfSignature());
|
||||
return sizeOfSignature();
|
||||
} // OlympusMnHeader::write
|
||||
} // OlympusMnHeader::write
|
||||
|
||||
const byte Olympus2MnHeader::signature_[] = {
|
||||
'O', 'L', 'Y', 'M', 'P', 'U', 'S', 0x00, 'I', 'I', 0x03, 0x00
|
||||
};
|
||||
|
||||
uint32_t Olympus2MnHeader::sizeOfSignature()
|
||||
size_t Olympus2MnHeader::sizeOfSignature()
|
||||
{
|
||||
return sizeof(signature_);
|
||||
}
|
||||
@@ -247,12 +244,12 @@ namespace Exiv2::Internal {
|
||||
read(signature_, sizeOfSignature(), invalidByteOrder);
|
||||
}
|
||||
|
||||
uint32_t Olympus2MnHeader::size() const
|
||||
size_t Olympus2MnHeader::size() const
|
||||
{
|
||||
return static_cast<uint32_t>(header_.size());
|
||||
return header_.size();
|
||||
}
|
||||
|
||||
uint32_t Olympus2MnHeader::ifdOffset() const
|
||||
size_t Olympus2MnHeader::ifdOffset() const
|
||||
{
|
||||
return sizeOfSignature();
|
||||
}
|
||||
@@ -262,18 +259,16 @@ namespace Exiv2::Internal {
|
||||
return mnOffset;
|
||||
}
|
||||
|
||||
bool Olympus2MnHeader::read(const byte* pData,
|
||||
uint32_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
bool Olympus2MnHeader::read(const byte* pData, size_t size, ByteOrder /*byteOrder*/)
|
||||
{
|
||||
if (!pData || size < sizeOfSignature()) return false;
|
||||
if (!pData || size < sizeOfSignature())
|
||||
return false;
|
||||
header_.alloc(sizeOfSignature());
|
||||
header_.copyBytes(0, pData, header_.size());
|
||||
return !(static_cast<uint32_t>(header_.size()) < sizeOfSignature() ||
|
||||
0 != header_.cmpBytes(0, signature_, 10));
|
||||
} // Olympus2MnHeader::read
|
||||
return !(header_.size() < sizeOfSignature() || 0 != header_.cmpBytes(0, signature_, 10));
|
||||
}
|
||||
|
||||
uint32_t Olympus2MnHeader::write(IoWrapper& ioWrapper,
|
||||
size_t Olympus2MnHeader::write(IoWrapper& ioWrapper,
|
||||
ByteOrder /*byteOrder*/) const
|
||||
{
|
||||
ioWrapper.write(signature_, sizeOfSignature());
|
||||
@@ -285,7 +280,7 @@ namespace Exiv2::Internal {
|
||||
};
|
||||
const ByteOrder FujiMnHeader::byteOrder_ = littleEndian;
|
||||
|
||||
uint32_t FujiMnHeader::sizeOfSignature()
|
||||
size_t FujiMnHeader::sizeOfSignature()
|
||||
{
|
||||
return sizeof(signature_);
|
||||
}
|
||||
@@ -295,12 +290,12 @@ namespace Exiv2::Internal {
|
||||
read(signature_, sizeOfSignature(), byteOrder_);
|
||||
}
|
||||
|
||||
uint32_t FujiMnHeader::size() const
|
||||
size_t FujiMnHeader::size() const
|
||||
{
|
||||
return static_cast<uint32_t>(header_.size());
|
||||
return header_.size();
|
||||
}
|
||||
|
||||
uint32_t FujiMnHeader::ifdOffset() const
|
||||
size_t FujiMnHeader::ifdOffset() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
@@ -315,21 +310,19 @@ namespace Exiv2::Internal {
|
||||
return mnOffset;
|
||||
}
|
||||
|
||||
bool FujiMnHeader::read(const byte* pData,
|
||||
uint32_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
bool FujiMnHeader::read(const byte* pData, size_t size, ByteOrder /*byteOrder*/)
|
||||
{
|
||||
if (!pData || size < sizeOfSignature()) return false;
|
||||
if (!pData || size < sizeOfSignature())
|
||||
return false;
|
||||
header_.alloc(sizeOfSignature());
|
||||
header_.copyBytes(0, pData, header_.size());
|
||||
// Read offset to the IFD relative to the start of the makernote
|
||||
// from the header. Note that we ignore the byteOrder argument
|
||||
start_ = header_.read_uint32(8, byteOrder_);
|
||||
return !(static_cast<uint32_t>(header_.size()) < sizeOfSignature() ||
|
||||
0 != header_.cmpBytes(0, signature_, 8));
|
||||
} // FujiMnHeader::read
|
||||
return !(header_.size() < sizeOfSignature() || 0 != header_.cmpBytes(0, signature_, 8));
|
||||
}
|
||||
|
||||
uint32_t FujiMnHeader::write(IoWrapper& ioWrapper,
|
||||
size_t FujiMnHeader::write(IoWrapper& ioWrapper,
|
||||
ByteOrder /*byteOrder*/) const
|
||||
{
|
||||
ioWrapper.write(signature_, sizeOfSignature());
|
||||
@@ -340,7 +333,7 @@ namespace Exiv2::Internal {
|
||||
'N', 'i', 'k', 'o', 'n', '\0', 0x01, 0x00
|
||||
};
|
||||
|
||||
uint32_t Nikon2MnHeader::sizeOfSignature()
|
||||
size_t Nikon2MnHeader::sizeOfSignature()
|
||||
{
|
||||
return sizeof(signature_);
|
||||
}
|
||||
@@ -350,18 +343,18 @@ namespace Exiv2::Internal {
|
||||
read(signature_, sizeOfSignature(), invalidByteOrder);
|
||||
}
|
||||
|
||||
uint32_t Nikon2MnHeader::size() const
|
||||
size_t Nikon2MnHeader::size() const
|
||||
{
|
||||
return sizeOfSignature();
|
||||
}
|
||||
|
||||
uint32_t Nikon2MnHeader::ifdOffset() const
|
||||
size_t Nikon2MnHeader::ifdOffset() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
bool Nikon2MnHeader::read(const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
{
|
||||
if (!pData || size < sizeOfSignature()) return false;
|
||||
@@ -372,7 +365,7 @@ namespace Exiv2::Internal {
|
||||
return true;
|
||||
} // Nikon2MnHeader::read
|
||||
|
||||
uint32_t Nikon2MnHeader::write(IoWrapper& ioWrapper,
|
||||
size_t Nikon2MnHeader::write(IoWrapper& ioWrapper,
|
||||
ByteOrder /*byteOrder*/) const
|
||||
{
|
||||
ioWrapper.write(signature_, sizeOfSignature());
|
||||
@@ -384,7 +377,7 @@ namespace Exiv2::Internal {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
uint32_t Nikon3MnHeader::sizeOfSignature()
|
||||
size_t Nikon3MnHeader::sizeOfSignature()
|
||||
{
|
||||
return sizeof(signature_);
|
||||
}
|
||||
@@ -395,12 +388,12 @@ namespace Exiv2::Internal {
|
||||
buf_.copyBytes(0, signature_, buf_.size());
|
||||
}
|
||||
|
||||
uint32_t Nikon3MnHeader::size() const
|
||||
size_t Nikon3MnHeader::size() const
|
||||
{
|
||||
return sizeOfSignature();
|
||||
}
|
||||
|
||||
uint32_t Nikon3MnHeader::ifdOffset() const
|
||||
size_t Nikon3MnHeader::ifdOffset() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
@@ -416,7 +409,7 @@ namespace Exiv2::Internal {
|
||||
}
|
||||
|
||||
bool Nikon3MnHeader::read(const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
{
|
||||
if (!pData || size < sizeOfSignature()) return false;
|
||||
@@ -430,8 +423,7 @@ namespace Exiv2::Internal {
|
||||
return true;
|
||||
} // Nikon3MnHeader::read
|
||||
|
||||
uint32_t Nikon3MnHeader::write(IoWrapper& ioWrapper,
|
||||
ByteOrder byteOrder) const
|
||||
size_t Nikon3MnHeader::write(IoWrapper& ioWrapper, ByteOrder byteOrder) const
|
||||
{
|
||||
assert(buf_.size() >= 10);
|
||||
|
||||
@@ -440,8 +432,8 @@ namespace Exiv2::Internal {
|
||||
TiffHeader th(byteOrder);
|
||||
DataBuf buf = th.write();
|
||||
ioWrapper.write(buf.c_data(), buf.size());
|
||||
return 10 + static_cast<uint32_t>(buf.size());
|
||||
} // Nikon3MnHeader::write
|
||||
return 10 + buf.size();
|
||||
}
|
||||
|
||||
void Nikon3MnHeader::setByteOrder(ByteOrder byteOrder)
|
||||
{
|
||||
@@ -452,7 +444,7 @@ namespace Exiv2::Internal {
|
||||
'P', 'a', 'n', 'a', 's', 'o', 'n', 'i', 'c', 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
uint32_t PanasonicMnHeader::sizeOfSignature()
|
||||
size_t PanasonicMnHeader::sizeOfSignature()
|
||||
{
|
||||
return sizeof(signature_);
|
||||
}
|
||||
@@ -462,19 +454,17 @@ namespace Exiv2::Internal {
|
||||
read(signature_, sizeOfSignature(), invalidByteOrder);
|
||||
}
|
||||
|
||||
uint32_t PanasonicMnHeader::size() const
|
||||
size_t PanasonicMnHeader::size() const
|
||||
{
|
||||
return sizeOfSignature();
|
||||
}
|
||||
|
||||
uint32_t PanasonicMnHeader::ifdOffset() const
|
||||
size_t PanasonicMnHeader::ifdOffset() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
bool PanasonicMnHeader::read(const byte* pData,
|
||||
uint32_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
bool PanasonicMnHeader::read(const byte* pData, size_t size, ByteOrder /*byteOrder*/)
|
||||
{
|
||||
if (!pData || size < sizeOfSignature()) return false;
|
||||
if (0 != memcmp(pData, signature_, 9)) return false;
|
||||
@@ -484,7 +474,7 @@ namespace Exiv2::Internal {
|
||||
return true;
|
||||
} // PanasonicMnHeader::read
|
||||
|
||||
uint32_t PanasonicMnHeader::write(IoWrapper& ioWrapper,
|
||||
size_t PanasonicMnHeader::write(IoWrapper& ioWrapper,
|
||||
ByteOrder /*byteOrder*/) const
|
||||
{
|
||||
ioWrapper.write(signature_, sizeOfSignature());
|
||||
@@ -495,7 +485,7 @@ namespace Exiv2::Internal {
|
||||
'P', 'E', 'N', 'T', 'A', 'X', ' ', 0x00, 'M', 'M'
|
||||
};
|
||||
|
||||
uint32_t PentaxDngMnHeader::sizeOfSignature()
|
||||
size_t PentaxDngMnHeader::sizeOfSignature()
|
||||
{
|
||||
return sizeof(signature_);
|
||||
}
|
||||
@@ -505,9 +495,9 @@ namespace Exiv2::Internal {
|
||||
read(signature_, sizeOfSignature(), invalidByteOrder);
|
||||
}
|
||||
|
||||
uint32_t PentaxDngMnHeader::size() const
|
||||
size_t PentaxDngMnHeader::size() const
|
||||
{
|
||||
return static_cast<uint32_t>(header_.size());
|
||||
return header_.size();
|
||||
}
|
||||
|
||||
uint32_t PentaxDngMnHeader::baseOffset(uint32_t mnOffset) const
|
||||
@@ -515,23 +505,21 @@ namespace Exiv2::Internal {
|
||||
return mnOffset;
|
||||
}
|
||||
|
||||
uint32_t PentaxDngMnHeader::ifdOffset() const
|
||||
size_t PentaxDngMnHeader::ifdOffset() const
|
||||
{
|
||||
return sizeOfSignature();
|
||||
}
|
||||
|
||||
bool PentaxDngMnHeader::read(const byte* pData,
|
||||
uint32_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
bool PentaxDngMnHeader::read(const byte* pData, size_t size, ByteOrder /*byteOrder*/)
|
||||
{
|
||||
if (!pData || size < sizeOfSignature()) return false;
|
||||
if (!pData || size < sizeOfSignature())
|
||||
return false;
|
||||
header_.alloc(sizeOfSignature());
|
||||
header_.copyBytes(0, pData, header_.size());
|
||||
return !(static_cast<uint32_t>(header_.size()) < sizeOfSignature() ||
|
||||
0 != header_.cmpBytes(0, signature_, 7));
|
||||
} // PentaxDngMnHeader::read
|
||||
return !(header_.size() < sizeOfSignature() || 0 != header_.cmpBytes(0, signature_, 7));
|
||||
}
|
||||
|
||||
uint32_t PentaxDngMnHeader::write(IoWrapper& ioWrapper,
|
||||
size_t PentaxDngMnHeader::write(IoWrapper& ioWrapper,
|
||||
ByteOrder /*byteOrder*/) const
|
||||
{
|
||||
ioWrapper.write(signature_, sizeOfSignature());
|
||||
@@ -542,7 +530,7 @@ namespace Exiv2::Internal {
|
||||
'A', 'O', 'C', 0x00, 'M', 'M'
|
||||
};
|
||||
|
||||
uint32_t PentaxMnHeader::sizeOfSignature()
|
||||
size_t PentaxMnHeader::sizeOfSignature()
|
||||
{
|
||||
return sizeof(signature_);
|
||||
}
|
||||
@@ -552,40 +540,37 @@ namespace Exiv2::Internal {
|
||||
read(signature_, sizeOfSignature(), invalidByteOrder);
|
||||
}
|
||||
|
||||
uint32_t PentaxMnHeader::size() const
|
||||
size_t PentaxMnHeader::size() const
|
||||
{
|
||||
return static_cast<uint32_t>(header_.size());
|
||||
return header_.size();
|
||||
}
|
||||
|
||||
uint32_t PentaxMnHeader::ifdOffset() const
|
||||
size_t PentaxMnHeader::ifdOffset() const
|
||||
{
|
||||
return sizeOfSignature();
|
||||
}
|
||||
|
||||
bool PentaxMnHeader::read(const byte* pData,
|
||||
uint32_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
bool PentaxMnHeader::read(const byte* pData, size_t size, ByteOrder /*byteOrder*/)
|
||||
{
|
||||
if (!pData || size < sizeOfSignature()) return false;
|
||||
if (!pData || size < sizeOfSignature())
|
||||
return false;
|
||||
header_.alloc(sizeOfSignature());
|
||||
header_.copyBytes(0, pData, header_.size());
|
||||
return !(static_cast<uint32_t>(header_.size()) < sizeOfSignature() ||
|
||||
0 != header_.cmpBytes(0, signature_, 3));
|
||||
} // PentaxMnHeader::read
|
||||
return !(header_.size() < sizeOfSignature() || 0 != header_.cmpBytes(0, signature_, 3));
|
||||
}
|
||||
|
||||
uint32_t PentaxMnHeader::write(IoWrapper& ioWrapper,
|
||||
ByteOrder /*byteOrder*/) const
|
||||
size_t PentaxMnHeader::write(IoWrapper& ioWrapper, ByteOrder /*byteOrder*/) const
|
||||
{
|
||||
ioWrapper.write(signature_, sizeOfSignature());
|
||||
return sizeOfSignature();
|
||||
} // PentaxMnHeader::write
|
||||
}
|
||||
|
||||
SamsungMnHeader::SamsungMnHeader()
|
||||
{
|
||||
read(nullptr, 0, invalidByteOrder);
|
||||
}
|
||||
|
||||
uint32_t SamsungMnHeader::size() const
|
||||
size_t SamsungMnHeader::size() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -596,13 +581,13 @@ namespace Exiv2::Internal {
|
||||
}
|
||||
|
||||
bool SamsungMnHeader::read(const byte* /*pData*/,
|
||||
uint32_t /*size*/,
|
||||
size_t /*size*/,
|
||||
ByteOrder /*byteOrder*/)
|
||||
{
|
||||
return true;
|
||||
} // SamsungMnHeader::read
|
||||
|
||||
uint32_t SamsungMnHeader::write(IoWrapper& /*ioWrapper*/,
|
||||
size_t SamsungMnHeader::write(IoWrapper& /*ioWrapper*/,
|
||||
ByteOrder /*byteOrder*/) const
|
||||
{
|
||||
return 0;
|
||||
@@ -615,7 +600,7 @@ namespace Exiv2::Internal {
|
||||
'F', 'O', 'V', 'E', 'O', 'N', '\0', '\0', 0x01, 0x00
|
||||
};
|
||||
|
||||
uint32_t SigmaMnHeader::sizeOfSignature()
|
||||
size_t SigmaMnHeader::sizeOfSignature()
|
||||
{
|
||||
assert(sizeof(signature1_) == sizeof(signature2_));
|
||||
return sizeof(signature1_);
|
||||
@@ -626,18 +611,18 @@ namespace Exiv2::Internal {
|
||||
read(signature1_, sizeOfSignature(), invalidByteOrder);
|
||||
}
|
||||
|
||||
uint32_t SigmaMnHeader::size() const
|
||||
size_t SigmaMnHeader::size() const
|
||||
{
|
||||
return sizeOfSignature();
|
||||
}
|
||||
|
||||
uint32_t SigmaMnHeader::ifdOffset() const
|
||||
size_t SigmaMnHeader::ifdOffset() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
bool SigmaMnHeader::read(const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
{
|
||||
if (!pData || size < sizeOfSignature()) return false;
|
||||
@@ -649,7 +634,7 @@ namespace Exiv2::Internal {
|
||||
return true;
|
||||
} // SigmaMnHeader::read
|
||||
|
||||
uint32_t SigmaMnHeader::write(IoWrapper& ioWrapper,
|
||||
size_t SigmaMnHeader::write(IoWrapper& ioWrapper,
|
||||
ByteOrder /*byteOrder*/) const
|
||||
{
|
||||
ioWrapper.write(signature1_, sizeOfSignature());
|
||||
@@ -660,7 +645,7 @@ namespace Exiv2::Internal {
|
||||
'S', 'O', 'N', 'Y', ' ', 'D', 'S', 'C', ' ', '\0', '\0', '\0'
|
||||
};
|
||||
|
||||
uint32_t SonyMnHeader::sizeOfSignature()
|
||||
size_t SonyMnHeader::sizeOfSignature()
|
||||
{
|
||||
return sizeof(signature_);
|
||||
}
|
||||
@@ -670,18 +655,18 @@ namespace Exiv2::Internal {
|
||||
read(signature_, sizeOfSignature(), invalidByteOrder);
|
||||
}
|
||||
|
||||
uint32_t SonyMnHeader::size() const
|
||||
size_t SonyMnHeader::size() const
|
||||
{
|
||||
return sizeOfSignature();
|
||||
}
|
||||
|
||||
uint32_t SonyMnHeader::ifdOffset() const
|
||||
size_t SonyMnHeader::ifdOffset() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
|
||||
bool SonyMnHeader::read(const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
{
|
||||
if (!pData || size < sizeOfSignature()) return false;
|
||||
@@ -692,7 +677,7 @@ namespace Exiv2::Internal {
|
||||
return true;
|
||||
} // SonyMnHeader::read
|
||||
|
||||
uint32_t SonyMnHeader::write(IoWrapper& ioWrapper,
|
||||
size_t SonyMnHeader::write(IoWrapper& ioWrapper,
|
||||
ByteOrder /*byteOrder*/) const
|
||||
{
|
||||
ioWrapper.write(signature_, sizeOfSignature());
|
||||
@@ -704,7 +689,7 @@ namespace Exiv2::Internal {
|
||||
};
|
||||
const ByteOrder Casio2MnHeader::byteOrder_ = bigEndian;
|
||||
|
||||
uint32_t Casio2MnHeader::sizeOfSignature()
|
||||
size_t Casio2MnHeader::sizeOfSignature()
|
||||
{
|
||||
return sizeof(signature_);
|
||||
}
|
||||
@@ -714,12 +699,12 @@ namespace Exiv2::Internal {
|
||||
read(signature_, sizeOfSignature(), invalidByteOrder );
|
||||
}
|
||||
|
||||
uint32_t Casio2MnHeader::size() const
|
||||
size_t Casio2MnHeader::size() const
|
||||
{
|
||||
return sizeOfSignature();
|
||||
}
|
||||
|
||||
uint32_t Casio2MnHeader::ifdOffset() const
|
||||
size_t Casio2MnHeader::ifdOffset() const
|
||||
{
|
||||
return start_;
|
||||
}
|
||||
@@ -730,7 +715,7 @@ namespace Exiv2::Internal {
|
||||
}
|
||||
|
||||
bool Casio2MnHeader::read(const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
{
|
||||
if (!pData || size < sizeOfSignature()) return false;
|
||||
@@ -741,7 +726,7 @@ namespace Exiv2::Internal {
|
||||
return true;
|
||||
} // Casio2MnHeader::read
|
||||
|
||||
uint32_t Casio2MnHeader::write(IoWrapper& ioWrapper,
|
||||
size_t Casio2MnHeader::write(IoWrapper& ioWrapper,
|
||||
ByteOrder /*byteOrder*/) const
|
||||
{
|
||||
ioWrapper.write(signature_, sizeOfSignature());
|
||||
@@ -755,7 +740,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId mnGroup,
|
||||
const byte* /*pData*/,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
{
|
||||
// Require at least an IFD with 1 entry, but not necessarily a next pointer
|
||||
@@ -774,7 +759,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId /*mnGroup*/,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
{
|
||||
if (size < 10 || std::string(reinterpret_cast<const char*>(pData), 10)
|
||||
@@ -806,7 +791,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId mnGroup,
|
||||
const byte* /*pData*/,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
{
|
||||
// Require at least the header and an IFD with 1 entry
|
||||
@@ -825,7 +810,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId /*mnGroup*/,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
{
|
||||
// If there is no "Nikon" string it must be Nikon1 format
|
||||
@@ -869,7 +854,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId mnGroup,
|
||||
const byte* /*pData*/,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
{
|
||||
// Require at least the header and an IFD with 1 entry, but without a next pointer
|
||||
@@ -884,7 +869,7 @@ namespace Exiv2::Internal {
|
||||
return new TiffIfdMakernote(tag, group, mnGroup, new PanasonicMnHeader, false);
|
||||
}
|
||||
|
||||
TiffComponent* newPentaxMn(uint16_t tag, IfdId group, IfdId /*mnGroup*/, const byte* pData, uint32_t size,
|
||||
TiffComponent* newPentaxMn(uint16_t tag, IfdId group, IfdId /*mnGroup*/, const byte* pData, size_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
{
|
||||
if (size > 8 && std::string(reinterpret_cast<const char*>(pData), 8) == std::string("PENTAX \0", 8)) {
|
||||
@@ -920,7 +905,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId mnGroup,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
{
|
||||
if ( size > 4
|
||||
@@ -948,7 +933,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId mnGroup,
|
||||
const byte* /*pData*/,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
{
|
||||
// Require at least the header and an IFD with 1 entry
|
||||
@@ -967,7 +952,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId /*mnGroup*/,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder /*byteOrder*/)
|
||||
{
|
||||
// If there is no "SONY DSC " string we assume it's a simple IFD Makernote
|
||||
@@ -1000,7 +985,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId /* mnGroup*/,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder/* byteOrder */ )
|
||||
{
|
||||
if (size > 6 && std::string(reinterpret_cast<const char*>(pData), 6)
|
||||
@@ -1024,10 +1009,10 @@ namespace Exiv2::Internal {
|
||||
//! Key for comparisons
|
||||
struct Key {
|
||||
//! Constructor
|
||||
Key(uint16_t tag, const char* ver, uint32_t size) : tag_(tag), ver_(ver), size_(size) {}
|
||||
Key(uint16_t tag, const char* ver, size_t size) : tag_(tag), ver_(ver), size_(size) {}
|
||||
uint16_t tag_; //!< Tag number
|
||||
const char* ver_; //!< Version string
|
||||
uint32_t size_; //!< Size of the data (not the version string)
|
||||
size_t size_; //!< Size of the data (not the version string)
|
||||
};
|
||||
//! Comparison operator for a key
|
||||
bool operator==(const Key& key) const
|
||||
@@ -1087,14 +1072,15 @@ namespace Exiv2::Internal {
|
||||
{ 0x00b7, "0101", 84, 1, NA }, // tag 0xb7 in sample image metadata for each version
|
||||
};
|
||||
|
||||
int nikonSelector(uint16_t tag, const byte* pData, uint32_t size, TiffComponent* const /*pRoot*/)
|
||||
int nikonSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* const /*pRoot*/)
|
||||
{
|
||||
if (size < 4) return -1;
|
||||
if (size < 4)
|
||||
return -1;
|
||||
const NikonArrayIdx* aix = find(nikonArrayIdx, NikonArrayIdx::Key(tag, reinterpret_cast<const char*>(pData), size));
|
||||
return aix ? aix->idx_ : -1;
|
||||
}
|
||||
|
||||
DataBuf nikonCrypt(uint16_t tag, const byte* pData, uint32_t size, TiffComponent* const pRoot)
|
||||
DataBuf nikonCrypt(uint16_t tag, const byte* pData, size_t size, TiffComponent* const pRoot)
|
||||
{
|
||||
DataBuf buf;
|
||||
|
||||
@@ -1133,7 +1119,7 @@ namespace Exiv2::Internal {
|
||||
return buf;
|
||||
}
|
||||
|
||||
int sonyCsSelector(uint16_t /*tag*/, const byte* /*pData*/, uint32_t /*size*/, TiffComponent* const pRoot)
|
||||
int sonyCsSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* const pRoot)
|
||||
{
|
||||
std::string model = getExifModel(pRoot);
|
||||
if (model.empty()) return -1;
|
||||
@@ -1144,7 +1130,7 @@ namespace Exiv2::Internal {
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
int sony2010eSelector(uint16_t /*tag*/, const byte* /*pData*/, uint32_t /*size*/, TiffComponent* const pRoot)
|
||||
int sony2010eSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* const pRoot)
|
||||
{
|
||||
static constexpr const char* models[] = {
|
||||
"SLT-A58", "SLT-A99", "ILCE-3000", "ILCE-3500", "NEX-3N", "NEX-5R", "NEX-5T",
|
||||
@@ -1154,7 +1140,7 @@ namespace Exiv2::Internal {
|
||||
return std::find(std::begin(models), std::end(models), getExifModel(pRoot)) != std::end(models) ? 0 : -1;
|
||||
}
|
||||
|
||||
int sony2FpSelector(uint16_t /*tag*/, const byte* /*pData*/, uint32_t /*size*/, TiffComponent* const pRoot)
|
||||
int sony2FpSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* const pRoot)
|
||||
{
|
||||
// Not valid for models beginning
|
||||
std::string model = getExifModel(pRoot);
|
||||
@@ -1162,7 +1148,7 @@ namespace Exiv2::Internal {
|
||||
return std::any_of(strs.begin(), strs.end(), [&model](auto& m){return startsWith(model, m);}) ? -1 : 0;
|
||||
}
|
||||
|
||||
int sonyMisc2bSelector(uint16_t /*tag*/, const byte* /*pData*/, uint32_t /*size*/, TiffComponent* const pRoot)
|
||||
int sonyMisc2bSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* const pRoot)
|
||||
{
|
||||
// From Exiftool: https://github.com/exiftool/exiftool/blob/master/lib/Image/ExifTool/Sony.pm
|
||||
// > First byte must be 9 or 12 or 13 or 15 or 16 and 4th byte must be 2 (deciphered)
|
||||
@@ -1190,7 +1176,7 @@ namespace Exiv2::Internal {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
int sonyMisc3cSelector(uint16_t /*tag*/, const byte* /*pData*/, uint32_t /*size*/, TiffComponent* const pRoot)
|
||||
int sonyMisc3cSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* const pRoot)
|
||||
{
|
||||
// From Exiftool (Tag 9400c): https://github.com/exiftool/exiftool/blob/master/lib/Image/ExifTool/Sony.pm
|
||||
// > first byte decoded: 62, 48, 215, 28, 106 respectively
|
||||
|
||||
+88
-91
@@ -33,7 +33,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId mnGroup,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder);
|
||||
|
||||
//! Type for a pointer to a function creating a makernote (group)
|
||||
@@ -83,7 +83,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
const std::string& make,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder);
|
||||
/*!
|
||||
@brief Create the Makernote for a given group. This method is used
|
||||
@@ -111,9 +111,7 @@ namespace Exiv2::Internal {
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
//! Read the header from a data buffer, return true if ok
|
||||
virtual bool read(const byte* pData,
|
||||
uint32_t size,
|
||||
ByteOrder byteOrder) =0;
|
||||
virtual bool read(const byte* pData, size_t size, ByteOrder byteOrder) = 0;
|
||||
/*!
|
||||
@brief Set the byte order for the makernote.
|
||||
*/
|
||||
@@ -122,15 +120,14 @@ namespace Exiv2::Internal {
|
||||
//! @name Accessors
|
||||
//@{
|
||||
//! Return the size of the header (in bytes).
|
||||
virtual uint32_t size() const =0;
|
||||
virtual size_t size() const =0;
|
||||
//! Write the header to a data buffer, return the number of bytes written.
|
||||
virtual uint32_t write(IoWrapper& ioWrapper,
|
||||
ByteOrder byteOrder) const =0;
|
||||
virtual size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const = 0;
|
||||
/*!
|
||||
@brief Return the offset to the start of the Makernote IFD from
|
||||
the start of the Makernote (= the start of the header).
|
||||
*/
|
||||
virtual uint32_t ifdOffset() const;
|
||||
virtual size_t ifdOffset() const;
|
||||
/*!
|
||||
@brief Return the byte order for the makernote. If the return value is
|
||||
invalidByteOrder, this means that the byte order of the the
|
||||
@@ -159,16 +156,16 @@ namespace Exiv2::Internal {
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
bool read(const byte* pData, uint32_t size, ByteOrder byteOrder) override;
|
||||
bool read(const byte* pData, size_t size, ByteOrder byteOrder) override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
uint32_t size() const override;
|
||||
uint32_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
uint32_t ifdOffset() const override;
|
||||
size_t size() const override;
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
size_t ifdOffset() const override;
|
||||
//@}
|
||||
//! Return the size of the makernote header signature
|
||||
static uint32_t sizeOfSignature();
|
||||
static size_t sizeOfSignature();
|
||||
|
||||
private:
|
||||
DataBuf header_; //!< Data buffer for the makernote header
|
||||
@@ -188,17 +185,17 @@ namespace Exiv2::Internal {
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
bool read(const byte* pData, uint32_t size, ByteOrder byteOrder) override;
|
||||
bool read(const byte* pData, size_t size, ByteOrder byteOrder) override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
uint32_t size() const override;
|
||||
uint32_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
uint32_t ifdOffset() const override;
|
||||
size_t size() const override;
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
size_t ifdOffset() const override;
|
||||
uint32_t baseOffset(uint32_t mnOffset) const override;
|
||||
//@}
|
||||
//! Return the size of the makernote header signature
|
||||
static uint32_t sizeOfSignature();
|
||||
static size_t sizeOfSignature();
|
||||
|
||||
private:
|
||||
DataBuf header_; //!< Data buffer for the makernote header
|
||||
@@ -218,19 +215,19 @@ namespace Exiv2::Internal {
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
bool read(const byte* pData, uint32_t size, ByteOrder byteOrder) override;
|
||||
bool read(const byte* pData, size_t size, ByteOrder byteOrder) override;
|
||||
// setByteOrder not implemented
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
uint32_t size() const override;
|
||||
uint32_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
uint32_t ifdOffset() const override;
|
||||
size_t size() const override;
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
size_t ifdOffset() const override;
|
||||
ByteOrder byteOrder() const override;
|
||||
uint32_t baseOffset(uint32_t mnOffset) const override;
|
||||
//@}
|
||||
//! Return the size of the makernote header signature
|
||||
static uint32_t sizeOfSignature();
|
||||
static size_t sizeOfSignature();
|
||||
|
||||
private:
|
||||
DataBuf header_; //!< Data buffer for the makernote header
|
||||
@@ -252,20 +249,20 @@ namespace Exiv2::Internal {
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
bool read(const byte* pData, uint32_t size, ByteOrder byteOrder) override;
|
||||
bool read(const byte* pData, size_t size, ByteOrder byteOrder) override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
uint32_t size() const override;
|
||||
uint32_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
uint32_t ifdOffset() const override;
|
||||
size_t size() const override;
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
size_t ifdOffset() const override;
|
||||
//@}
|
||||
//! Return the size of the makernote header signature
|
||||
static uint32_t sizeOfSignature();
|
||||
static size_t sizeOfSignature();
|
||||
|
||||
private:
|
||||
DataBuf buf_; //!< Raw header data
|
||||
uint32_t start_; //!< Start of the mn IFD rel. to mn start
|
||||
size_t start_; //!< Start of the mn IFD rel. to mn start
|
||||
static const byte signature_[]; //!< Nikon 2 makernote header signature
|
||||
|
||||
}; // class Nikon2MnHeader
|
||||
@@ -282,24 +279,24 @@ namespace Exiv2::Internal {
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
bool read(const byte* pData, uint32_t size, ByteOrder byteOrder) override;
|
||||
bool read(const byte* pData, size_t size, ByteOrder byteOrder) override;
|
||||
void setByteOrder(ByteOrder byteOrder) override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
uint32_t size() const override;
|
||||
uint32_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
uint32_t ifdOffset() const override;
|
||||
size_t size() const override;
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
size_t ifdOffset() const override;
|
||||
ByteOrder byteOrder() const override;
|
||||
uint32_t baseOffset(uint32_t mnOffset) const override;
|
||||
//@}
|
||||
//! Return the size of the makernote header signature
|
||||
static uint32_t sizeOfSignature();
|
||||
static size_t sizeOfSignature();
|
||||
|
||||
private:
|
||||
DataBuf buf_; //!< Raw header data
|
||||
ByteOrder byteOrder_; //!< Byteorder for makernote
|
||||
uint32_t start_; //!< Start of the mn IFD rel. to mn start
|
||||
size_t start_; //!< Start of the mn IFD rel. to mn start
|
||||
static const byte signature_[]; //!< Nikon 3 makernote header signature
|
||||
|
||||
}; // class Nikon3MnHeader
|
||||
@@ -316,20 +313,20 @@ namespace Exiv2::Internal {
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
bool read(const byte* pData, uint32_t size, ByteOrder byteOrder) override;
|
||||
bool read(const byte* pData, size_t size, ByteOrder byteOrder) override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
uint32_t size() const override;
|
||||
uint32_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
uint32_t ifdOffset() const override;
|
||||
size_t size() const override;
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
size_t ifdOffset() const override;
|
||||
//@}
|
||||
//! Return the size of the makernote header signature
|
||||
static uint32_t sizeOfSignature();
|
||||
static size_t sizeOfSignature();
|
||||
|
||||
private:
|
||||
DataBuf buf_; //!< Raw header data
|
||||
uint32_t start_; //!< Start of the mn IFD rel. to mn start
|
||||
size_t start_; //!< Start of the mn IFD rel. to mn start
|
||||
static const byte signature_[]; //!< Panasonic makernote header signature
|
||||
|
||||
}; // class PanasonicMnHeader
|
||||
@@ -346,17 +343,17 @@ namespace Exiv2::Internal {
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
bool read(const byte* pData, uint32_t size, ByteOrder byteOrder) override;
|
||||
bool read(const byte* pData, size_t size, ByteOrder byteOrder) override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
uint32_t size() const override;
|
||||
uint32_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
uint32_t ifdOffset() const override;
|
||||
size_t size() const override;
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
size_t ifdOffset() const override;
|
||||
uint32_t baseOffset(uint32_t mnOffset) const override;
|
||||
//@}
|
||||
//! Return the size of the makernote header signature
|
||||
static uint32_t sizeOfSignature();
|
||||
static size_t sizeOfSignature();
|
||||
|
||||
private:
|
||||
DataBuf header_; //!< Data buffer for the makernote header
|
||||
@@ -376,16 +373,16 @@ namespace Exiv2::Internal {
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
bool read(const byte* pData, uint32_t size, ByteOrder byteOrder) override;
|
||||
bool read(const byte* pData, size_t size, ByteOrder byteOrder) override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
uint32_t size() const override;
|
||||
uint32_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
uint32_t ifdOffset() const override;
|
||||
size_t size() const override;
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
size_t ifdOffset() const override;
|
||||
//@}
|
||||
//! Return the size of the makernote header signature
|
||||
static uint32_t sizeOfSignature();
|
||||
static size_t sizeOfSignature();
|
||||
|
||||
private:
|
||||
DataBuf header_; //!< Data buffer for the makernote header
|
||||
@@ -403,12 +400,12 @@ namespace Exiv2::Internal {
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
bool read(const byte* pData, uint32_t size, ByteOrder byteOrder) override;
|
||||
bool read(const byte* pData, size_t size, ByteOrder byteOrder) override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
uint32_t size() const override;
|
||||
uint32_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
size_t size() const override;
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
uint32_t baseOffset(uint32_t mnOffset) const override;
|
||||
//@}
|
||||
|
||||
@@ -426,20 +423,20 @@ namespace Exiv2::Internal {
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
bool read(const byte* pData, uint32_t size, ByteOrder byteOrder) override;
|
||||
bool read(const byte* pData, size_t size, ByteOrder byteOrder) override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
uint32_t size() const override;
|
||||
uint32_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
uint32_t ifdOffset() const override;
|
||||
size_t size() const override;
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
size_t ifdOffset() const override;
|
||||
//@}
|
||||
//! Return the size of the makernote header signature
|
||||
static uint32_t sizeOfSignature();
|
||||
static size_t sizeOfSignature();
|
||||
|
||||
private:
|
||||
DataBuf buf_; //!< Raw header data
|
||||
uint32_t start_; //!< Start of the mn IFD rel. to mn start
|
||||
size_t start_; //!< Start of the mn IFD rel. to mn start
|
||||
static const byte signature1_[]; //!< Sigma makernote header signature 1
|
||||
static const byte signature2_[]; //!< Sigma makernote header signature 2
|
||||
|
||||
@@ -457,20 +454,20 @@ namespace Exiv2::Internal {
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
bool read(const byte* pData, uint32_t size, ByteOrder byteOrder) override;
|
||||
bool read(const byte* pData, size_t size, ByteOrder byteOrder) override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
uint32_t size() const override;
|
||||
uint32_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
uint32_t ifdOffset() const override;
|
||||
size_t size() const override;
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
size_t ifdOffset() const override;
|
||||
//@}
|
||||
//! Return the size of the makernote header signature
|
||||
static uint32_t sizeOfSignature();
|
||||
static size_t sizeOfSignature();
|
||||
|
||||
private:
|
||||
DataBuf buf_; //!< Raw header data
|
||||
uint32_t start_; //!< Start of the mn IFD rel. to mn start
|
||||
size_t start_; //!< Start of the mn IFD rel. to mn start
|
||||
static const byte signature_[]; //!< Sony makernote header signature
|
||||
|
||||
}; // class SonyMnHeader
|
||||
@@ -487,21 +484,21 @@ namespace Exiv2::Internal {
|
||||
//@}
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
bool read(const byte* pData, uint32_t size, ByteOrder byteOrder) override;
|
||||
bool read(const byte* pData, size_t size, ByteOrder byteOrder) override;
|
||||
//@}
|
||||
//! @name Accessors
|
||||
//@{
|
||||
uint32_t size() const override;
|
||||
uint32_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
uint32_t ifdOffset() const override;
|
||||
size_t size() const override;
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
size_t ifdOffset() const override;
|
||||
ByteOrder byteOrder() const override;
|
||||
//@}
|
||||
//! Return the size of the makernote header signature
|
||||
static uint32_t sizeOfSignature();
|
||||
static size_t sizeOfSignature();
|
||||
|
||||
private:
|
||||
DataBuf buf_; //!< Raw header data
|
||||
uint32_t start_; //!< Start of the mn IFD rel. to mn start
|
||||
size_t start_; //!< Start of the mn IFD rel. to mn start
|
||||
static const byte signature_[]; //!< Casio makernote header signature
|
||||
static const ByteOrder byteOrder_; //!< Byteorder for makernote (always big endian)
|
||||
|
||||
@@ -515,7 +512,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId mnGroup,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder);
|
||||
|
||||
//! Function to create a simple IFD makernote (Canon, Minolta, Nikon1)
|
||||
@@ -528,7 +525,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId mnGroup,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder);
|
||||
|
||||
//! Function to create an Olympus makernote
|
||||
@@ -546,7 +543,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId mnGroup,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder);
|
||||
|
||||
//! Function to create a Fujifilm makernote
|
||||
@@ -562,7 +559,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId mnGroup,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder);
|
||||
|
||||
//! Function to create a Nikon2 makernote
|
||||
@@ -580,7 +577,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId mnGroup,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder);
|
||||
|
||||
//! Function to create a Panasonic makernote
|
||||
@@ -593,7 +590,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId mnGroup,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder);
|
||||
|
||||
//! Function to create an Pentax makernote
|
||||
@@ -611,7 +608,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId mnGroup,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder);
|
||||
|
||||
//! Function to create a Samsung makernote
|
||||
@@ -624,7 +621,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId mnGroup,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder);
|
||||
|
||||
//! Function to create a Sigma makernote
|
||||
@@ -637,7 +634,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId mnGroup,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder);
|
||||
|
||||
//! Function to create a Sony1 makernote
|
||||
@@ -655,7 +652,7 @@ namespace Exiv2::Internal {
|
||||
IfdId group,
|
||||
IfdId mnGroup,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder);
|
||||
|
||||
//! Function to create a Casio2 makernote
|
||||
@@ -672,7 +669,7 @@ namespace Exiv2::Internal {
|
||||
@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);
|
||||
int sonyCsSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* const pRoot);
|
||||
|
||||
/*!
|
||||
@brief Function to select cfg + def of the Sony 2010 Miscellaneous Information complex binary array.
|
||||
@@ -683,8 +680,8 @@ namespace Exiv2::Internal {
|
||||
@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 sony2010eSelector(uint16_t tag, const byte* pData, uint32_t size, TiffComponent* const pRoot);
|
||||
|
||||
int sony2010eSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* const pRoot);
|
||||
|
||||
/*!
|
||||
@brief Function to select cfg + def of the Sony2Fp (tag 9402) complex binary array.
|
||||
|
||||
@@ -694,7 +691,7 @@ namespace Exiv2::Internal {
|
||||
@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 sony2FpSelector(uint16_t tag, const byte* pData, uint32_t size, TiffComponent* const pRoot);
|
||||
int sony2FpSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* const pRoot);
|
||||
|
||||
/*!
|
||||
@brief Function to select cfg + def of the SonyMisc2b (tag 9404b) complex binary array.
|
||||
@@ -705,7 +702,7 @@ namespace Exiv2::Internal {
|
||||
@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 sonyMisc2bSelector(uint16_t tag, const byte* pData, uint32_t size, TiffComponent* const pRoot);
|
||||
int sonyMisc2bSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* const pRoot);
|
||||
|
||||
/*!
|
||||
@brief Function to select cfg + def of the SonyMisc3c (tag 9400) complex binary array.
|
||||
@@ -716,7 +713,7 @@ namespace Exiv2::Internal {
|
||||
@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 sonyMisc3cSelector(uint16_t tag, const byte* pData, uint32_t size, TiffComponent* const pRoot);
|
||||
int sonyMisc3cSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* const pRoot);
|
||||
|
||||
/*!
|
||||
@brief Function to select cfg + def of a Nikon complex binary array.
|
||||
@@ -727,7 +724,7 @@ namespace Exiv2::Internal {
|
||||
@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 nikonSelector(uint16_t tag, const byte* pData, uint32_t size, TiffComponent* const pRoot);
|
||||
int nikonSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* const pRoot);
|
||||
|
||||
/*!
|
||||
@brief Encrypt and decrypt Nikon data.
|
||||
@@ -745,7 +742,7 @@ namespace Exiv2::Internal {
|
||||
@return En/decrypted data. Ownership of the memory is passed to the caller.
|
||||
The buffer may be empty in case no decryption was needed.
|
||||
*/
|
||||
DataBuf nikonCrypt(uint16_t tag, const byte* pData, uint32_t size, TiffComponent* const pRoot);
|
||||
DataBuf nikonCrypt(uint16_t tag, const byte* pData, size_t size, TiffComponent* const pRoot);
|
||||
|
||||
} // namespace Exiv2::Internal
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ namespace Exiv2 {
|
||||
return os.str();
|
||||
}
|
||||
|
||||
uint32_t Metadatum::toUint32(long n) const {
|
||||
uint32_t Metadatum::toUint32(size_t n) const {
|
||||
return static_cast<uint32_t>(toInt64(n));
|
||||
}
|
||||
|
||||
|
||||
@@ -1173,7 +1173,7 @@ namespace Exiv2::Internal {
|
||||
return os << value;
|
||||
}
|
||||
if (value.count() == 1) {
|
||||
auto l0 = static_cast<short>(value.toInt64(0));
|
||||
auto l0 = value.toInt64(0);
|
||||
if (l0 == 1) {
|
||||
os << _("Auto");
|
||||
}
|
||||
@@ -1182,8 +1182,8 @@ namespace Exiv2::Internal {
|
||||
}
|
||||
}
|
||||
else if (value.count() == 2) {
|
||||
auto l0 = static_cast<short>(value.toInt64(0));
|
||||
auto l1 = static_cast<short>(value.toInt64(1));
|
||||
auto l0 = value.toInt64(0);
|
||||
auto l1 = value.toInt64(1);
|
||||
if (l0 == 1) {
|
||||
switch (l1) {
|
||||
case 0: os << _("Auto"); break;
|
||||
|
||||
+7
-13
@@ -86,10 +86,9 @@ namespace Exiv2 {
|
||||
throw Error(ErrorCode::kerNotAnImage, "ORF");
|
||||
}
|
||||
clearMetadata();
|
||||
ByteOrder bo =
|
||||
OrfParser::decode(exifData_, iptcData_, xmpData_, io_->mmap(), static_cast<uint32_t>(io_->size()));
|
||||
ByteOrder bo = OrfParser::decode(exifData_, iptcData_, xmpData_, io_->mmap(), io_->size());
|
||||
setByteOrder(bo);
|
||||
} // OrfImage::readMetadata
|
||||
}
|
||||
|
||||
void OrfImage::writeMetadata()
|
||||
{
|
||||
@@ -98,13 +97,13 @@ namespace Exiv2 {
|
||||
#endif
|
||||
ByteOrder bo = byteOrder();
|
||||
byte* pData = nullptr;
|
||||
long size = 0;
|
||||
size_t size = 0;
|
||||
IoCloser closer(*io_);
|
||||
if (io_->open() == 0) {
|
||||
// Ensure that this is the correct image type
|
||||
if (isOrfType(*io_, false)) {
|
||||
pData = io_->mmap(true);
|
||||
size = static_cast<long>(io_->size());
|
||||
size = io_->size();
|
||||
OrfHeader orfHeader;
|
||||
if (0 == orfHeader.read(pData, 8)) {
|
||||
bo = orfHeader.byteOrder();
|
||||
@@ -118,13 +117,8 @@ namespace Exiv2 {
|
||||
OrfParser::encode(*io_, pData, size, bo, exifData_, iptcData_, xmpData_); // may throw
|
||||
} // OrfImage::writeMetadata
|
||||
|
||||
ByteOrder OrfParser::decode(
|
||||
ExifData& exifData,
|
||||
IptcData& iptcData,
|
||||
XmpData& xmpData,
|
||||
const byte* pData,
|
||||
uint32_t size
|
||||
)
|
||||
ByteOrder OrfParser::decode(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, const byte* pData,
|
||||
size_t size)
|
||||
{
|
||||
OrfHeader orfHeader;
|
||||
return TiffParserWorker::decode(exifData,
|
||||
@@ -140,7 +134,7 @@ namespace Exiv2 {
|
||||
WriteMethod OrfParser::encode(
|
||||
BasicIo& io,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
ByteOrder byteOrder,
|
||||
const ExifData& exifData,
|
||||
const IptcData& iptcData,
|
||||
|
||||
@@ -10,9 +10,10 @@ namespace Exiv2::Internal {
|
||||
{
|
||||
}
|
||||
|
||||
bool OrfHeader::read(const byte* pData, uint32_t size)
|
||||
bool OrfHeader::read(const byte* pData, size_t size)
|
||||
{
|
||||
if (size < 8) return false;
|
||||
if (size < 8)
|
||||
return false;
|
||||
|
||||
if (pData[0] == 'I' && pData[0] == pData[1]) {
|
||||
setByteOrder(littleEndian);
|
||||
@@ -25,11 +26,12 @@ namespace Exiv2::Internal {
|
||||
}
|
||||
|
||||
uint16_t sig = getUShort(pData + 2, byteOrder());
|
||||
if (tag() != sig && 0x5352 != sig) return false; // #658: Added 0x5352 "SR" for SP-560UZ
|
||||
if (tag() != sig && 0x5352 != sig)
|
||||
return false; // #658: Added 0x5352 "SR" for SP-560UZ
|
||||
sig_ = sig;
|
||||
setOffset(getULong(pData + 4, byteOrder()));
|
||||
return true;
|
||||
} // OrfHeader::read
|
||||
}
|
||||
|
||||
DataBuf OrfHeader::write() const
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Exiv2::Internal {
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
bool read(const byte* pData, uint32_t size) override;
|
||||
bool read(const byte* pData, size_t size) override;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
|
||||
+13
-14
@@ -94,16 +94,12 @@ namespace Exiv2 {
|
||||
|
||||
readPgfMagicNumber(*io_);
|
||||
|
||||
uint32_t headerSize = readPgfHeaderSize(*io_);
|
||||
size_t headerSize = readPgfHeaderSize(*io_);
|
||||
readPgfHeaderStructure(*io_, pixelWidth_, pixelHeight_);
|
||||
|
||||
// And now, the most interesting, the user data byte array where metadata are stored as small image.
|
||||
|
||||
enforce(headerSize <= std::numeric_limits<uint32_t>::max() - 8, ErrorCode::kerCorruptedMetadata);
|
||||
#if LONG_MAX < UINT_MAX
|
||||
enforce(headerSize + 8 <= static_cast<uint32_t>(std::numeric_limits<long>::max()),
|
||||
ErrorCode::kerCorruptedMetadata);
|
||||
#endif
|
||||
enforce(headerSize <= std::numeric_limits<size_t>::max() - 8, ErrorCode::kerCorruptedMetadata);
|
||||
long size = static_cast<long>(headerSize) + 8 - io_->tell();
|
||||
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
@@ -175,7 +171,7 @@ namespace Exiv2 {
|
||||
img->setIptcData(iptcData_);
|
||||
img->setXmpData(xmpData_);
|
||||
img->writeMetadata();
|
||||
auto imgSize = static_cast<long>(img->io().size());
|
||||
size_t imgSize = img->io().size();
|
||||
DataBuf imgBuf = img->io().read(imgSize);
|
||||
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
@@ -185,13 +181,15 @@ namespace Exiv2 {
|
||||
//---------------------------------------------------------------
|
||||
|
||||
// Write PGF Signature.
|
||||
if (outIo.write(pgfSignature, 3) != 3) throw Error(ErrorCode::kerImageWriteFailed);
|
||||
if (outIo.write(pgfSignature, 3) != 3)
|
||||
throw Error(ErrorCode::kerImageWriteFailed);
|
||||
|
||||
// Write Magic number.
|
||||
if (outIo.putb(mnb) == EOF) throw Error(ErrorCode::kerImageWriteFailed);
|
||||
if (outIo.putb(mnb) == EOF)
|
||||
throw Error(ErrorCode::kerImageWriteFailed);
|
||||
|
||||
// Write new Header size.
|
||||
uint32_t newHeaderSize = static_cast<uint32_t>(header.size()) + imgSize;
|
||||
uint32_t newHeaderSize = static_cast<uint32_t>(header.size() + imgSize);
|
||||
DataBuf buffer(4);
|
||||
buffer.copyBytes(0, &newHeaderSize, 4);
|
||||
byteSwap_(buffer,0,bSwap_);
|
||||
@@ -242,7 +240,7 @@ namespace Exiv2 {
|
||||
return b;
|
||||
} // PgfImage::readPgfMagicNumber
|
||||
|
||||
uint32_t PgfImage::readPgfHeaderSize(BasicIo& iIo) const
|
||||
size_t PgfImage::readPgfHeaderSize(BasicIo& iIo) const
|
||||
{
|
||||
DataBuf buffer(4);
|
||||
const size_t bufRead = iIo.read(buffer.data(), buffer.size());
|
||||
@@ -251,15 +249,16 @@ namespace Exiv2 {
|
||||
if (bufRead != buffer.size())
|
||||
throw Error(ErrorCode::kerInputDataReadFailed);
|
||||
|
||||
auto headerSize = static_cast<int>(byteSwap_(buffer, 0, bSwap_));
|
||||
if (headerSize <= 0 ) throw Error(ErrorCode::kerNoImageInInputData);
|
||||
auto headerSize = static_cast<size_t>(byteSwap_(buffer, 0, bSwap_));
|
||||
if (headerSize == 0 )
|
||||
throw Error(ErrorCode::kerNoImageInInputData);
|
||||
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
std::cout << "Exiv2::PgfImage: PGF header size : " << headerSize << " bytes\n";
|
||||
#endif
|
||||
|
||||
return headerSize;
|
||||
} // PgfImage::readPgfHeaderSize
|
||||
}
|
||||
|
||||
DataBuf PgfImage::readPgfHeaderStructure(BasicIo& iIo, uint32_t& width, uint32_t& height) const
|
||||
{
|
||||
|
||||
@@ -224,7 +224,7 @@ namespace Exiv2::Internal {
|
||||
#endif
|
||||
pos = pos + sizeof(exifHeader);
|
||||
ByteOrder bo = TiffParser::decode(pImage->exifData(), pImage->iptcData(), pImage->xmpData(),
|
||||
exifData.c_data(pos), static_cast<uint32_t>(length - pos));
|
||||
exifData.c_data(pos), length - pos);
|
||||
pImage->setByteOrder(bo);
|
||||
} else {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
@@ -258,15 +258,14 @@ namespace Exiv2::Internal {
|
||||
pCur += (sizeIptc & 1);
|
||||
}
|
||||
if (!iptcBlob.empty() &&
|
||||
IptcParser::decode(pImage->iptcData(), &iptcBlob[0], static_cast<uint32_t>(iptcBlob.size()))) {
|
||||
IptcParser::decode(pImage->iptcData(), &iptcBlob[0], iptcBlob.size())) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
EXV_WARNING << "Failed to decode IPTC metadata.\n";
|
||||
#endif
|
||||
pImage->clearIptcData();
|
||||
}
|
||||
// If there is no IRB, try to decode the complete chunk data
|
||||
if (iptcBlob.empty() && IptcParser::decode(pImage->iptcData(), psData.c_data(),
|
||||
static_cast<uint32_t>(psData.size()))) {
|
||||
if (iptcBlob.empty() && IptcParser::decode(pImage->iptcData(), psData.c_data(), psData.size())) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
EXV_WARNING << "Failed to decode IPTC metadata.\n";
|
||||
#endif
|
||||
|
||||
+3
-6
@@ -457,11 +457,8 @@ namespace Exiv2 {
|
||||
} else if (chunkType == "iTXt") {
|
||||
PngChunk::decodeTXTChunk(this, chunkData, PngChunk::iTXt_Chunk);
|
||||
} else if (chunkType == "eXIf") {
|
||||
ByteOrder bo = TiffParser::decode(exifData(),
|
||||
iptcData(),
|
||||
xmpData(),
|
||||
chunkData.c_data(),
|
||||
static_cast<uint32_t>(chunkData.size()));
|
||||
ByteOrder bo =
|
||||
TiffParser::decode(exifData(), iptcData(), xmpData(), chunkData.c_data(), chunkData.size());
|
||||
setByteOrder(bo);
|
||||
} else if (chunkType == "iCCP") {
|
||||
// The ICC profile name can vary from 1-79 characters.
|
||||
@@ -559,7 +556,7 @@ namespace Exiv2 {
|
||||
bufRead = io_->read(chunkBuf.data(8), dataOffset + 4); // Extract chunk data + CRC
|
||||
if (io_->error())
|
||||
throw Error(ErrorCode::kerFailedToReadImageData);
|
||||
if (bufRead != static_cast<size_t>(dataOffset) + 4)
|
||||
if (bufRead != dataOffset + 4)
|
||||
throw Error(ErrorCode::kerInputDataReadFailed);
|
||||
|
||||
char szChunk[5];
|
||||
|
||||
+17
-28
@@ -24,36 +24,24 @@ namespace {
|
||||
of both lhs and rhs are available or else by size.
|
||||
Return true if lhs is smaller than rhs.
|
||||
*/
|
||||
bool cmpPreviewProperties(
|
||||
const PreviewProperties& lhs,
|
||||
const PreviewProperties& rhs
|
||||
)
|
||||
bool cmpPreviewProperties(const PreviewProperties &lhs, const PreviewProperties &rhs)
|
||||
{
|
||||
uint32_t l = lhs.width_ * lhs.height_;
|
||||
uint32_t r = rhs.width_ * rhs.height_;
|
||||
|
||||
auto l = lhs.width_ * lhs.height_;
|
||||
auto r = rhs.width_ * rhs.height_;
|
||||
return l < r;
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief Decode a Hex string.
|
||||
*/
|
||||
/// @brief Decode a Hex string.
|
||||
DataBuf decodeHex(const byte *src, long srcSize);
|
||||
|
||||
/*!
|
||||
@brief Decode a Base64 string.
|
||||
*/
|
||||
/// @brief Decode a Base64 string.
|
||||
DataBuf decodeBase64(const std::string &src);
|
||||
|
||||
/*!
|
||||
@brief Decode an Illustrator thumbnail that follows after %AI7_Thumbnail.
|
||||
*/
|
||||
/// @brief Decode an Illustrator thumbnail that follows after %AI7_Thumbnail.
|
||||
DataBuf decodeAi7Thumbnail(const DataBuf &src);
|
||||
|
||||
/*!
|
||||
@brief Create a PNM image from raw RGB data.
|
||||
*/
|
||||
DataBuf makePnm(uint32_t width, uint32_t height, const DataBuf &rgb);
|
||||
/// @brief Create a PNM image from raw RGB data.
|
||||
DataBuf makePnm(size_t width, size_t height, const DataBuf &rgb);
|
||||
|
||||
/*!
|
||||
Base class for image loaders. Provides virtual methods for reading properties
|
||||
@@ -109,10 +97,10 @@ namespace {
|
||||
const Image &image_;
|
||||
|
||||
//! Preview image width
|
||||
uint32_t width_;
|
||||
size_t width_;
|
||||
|
||||
//! Preview image length
|
||||
uint32_t height_;
|
||||
size_t height_;
|
||||
|
||||
//! Preview image size in bytes
|
||||
size_t size_;
|
||||
@@ -388,7 +376,8 @@ namespace {
|
||||
LoaderNative::LoaderNative(PreviewId id, const Image &image, int parIdx)
|
||||
: Loader(id, image)
|
||||
{
|
||||
if (!(0 <= parIdx && static_cast<size_t>(parIdx) < image.nativePreviews().size())) return;
|
||||
if (!(0 <= parIdx && static_cast<size_t>(parIdx) < image.nativePreviews().size()))
|
||||
return;
|
||||
nativePreview_ = image.nativePreviews()[parIdx];
|
||||
width_ = nativePreview_.width_;
|
||||
height_ = nativePreview_.height_;
|
||||
@@ -396,7 +385,7 @@ namespace {
|
||||
if (nativePreview_.filter_.empty()) {
|
||||
size_ = nativePreview_.size_;
|
||||
} else {
|
||||
size_ = static_cast<uint32_t>(getData().size());
|
||||
size_ = getData().size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,7 +426,7 @@ namespace {
|
||||
}
|
||||
IoCloser closer(io);
|
||||
const byte* data = io.mmap();
|
||||
if (static_cast<long>(io.size()) < nativePreview_.position_ + static_cast<long>(nativePreview_.size_)) {
|
||||
if (io.size() < nativePreview_.position_ + nativePreview_.size_) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
EXV_WARNING << "Invalid native preview position or size.\n";
|
||||
#endif
|
||||
@@ -1000,7 +989,7 @@ namespace {
|
||||
return {reinterpret_cast<const byte *>(dest.data()), dest.size()};
|
||||
}
|
||||
|
||||
DataBuf makePnm(uint32_t width, uint32_t height, const DataBuf &rgb)
|
||||
DataBuf makePnm(size_t width, size_t height, const DataBuf &rgb)
|
||||
{
|
||||
const size_t expectedSize = width * height * 3UL;
|
||||
if (rgb.size() != expectedSize) {
|
||||
@@ -1074,12 +1063,12 @@ namespace Exiv2 {
|
||||
return properties_.extension_;
|
||||
}
|
||||
|
||||
uint32_t PreviewImage::width() const
|
||||
size_t PreviewImage::width() const
|
||||
{
|
||||
return properties_.width_;
|
||||
}
|
||||
|
||||
uint32_t PreviewImage::height() const
|
||||
size_t PreviewImage::height() const
|
||||
{
|
||||
return properties_.height_;
|
||||
}
|
||||
|
||||
+1
-1
@@ -299,7 +299,7 @@ namespace Exiv2 {
|
||||
nativePreview.height_ = getLong(buf + 8, bigEndian);
|
||||
const uint32_t format = getLong(buf + 0, bigEndian);
|
||||
|
||||
if (nativePreview.size_ > 0 && nativePreview.position_ >= 0) {
|
||||
if (nativePreview.size_ > 0 && nativePreview.position_ > 0) {
|
||||
io_->seek(static_cast<long>(nativePreview.size_), BasicIo::cur);
|
||||
if (io_->error() || io_->eof())
|
||||
throw Error(ErrorCode::kerFailedToReadImageData);
|
||||
|
||||
+6
-15
@@ -291,10 +291,8 @@ namespace Exiv2 {
|
||||
enforce(Safe::add(jpg_img_off_u32, jpg_img_len_u32) <= io_->size(), ErrorCode::kerCorruptedMetadata);
|
||||
|
||||
#if LONG_MAX < UINT_MAX
|
||||
enforce(jpg_img_off_u32 <= static_cast<uint32_t>(std::numeric_limits<long>::max()),
|
||||
ErrorCode::kerCorruptedMetadata);
|
||||
enforce(jpg_img_len_u32 <= static_cast<uint32_t>(std::numeric_limits<long>::max()),
|
||||
ErrorCode::kerCorruptedMetadata);
|
||||
enforce(jpg_img_off_u32 <= std::numeric_limits<uint32_t>::max(), ErrorCode::kerCorruptedMetadata);
|
||||
enforce(jpg_img_len_u32 <= std::numeric_limits<uint32_t>::max(), ErrorCode::kerCorruptedMetadata);
|
||||
#endif
|
||||
|
||||
auto jpg_img_off = static_cast<long>(jpg_img_off_u32);
|
||||
@@ -312,11 +310,8 @@ namespace Exiv2 {
|
||||
|
||||
io_->seek(0,BasicIo::beg); // rewind
|
||||
|
||||
ByteOrder bo = TiffParser::decode(exifData_,
|
||||
iptcData_,
|
||||
xmpData_,
|
||||
buf.c_data(),
|
||||
static_cast<uint32_t>(buf.size()));
|
||||
ByteOrder bo =
|
||||
TiffParser::decode(exifData_, iptcData_, xmpData_, buf.c_data(), buf.size());
|
||||
|
||||
exifData_["Exif.Image2.JPEGInterchangeFormat"] = getULong(jpg_img_offset, bigEndian);
|
||||
exifData_["Exif.Image2.JPEGInterchangeFormatLength"] = getULong(jpg_img_length, bigEndian);
|
||||
@@ -355,14 +350,10 @@ namespace Exiv2 {
|
||||
|
||||
if (!io_->error() && !io_->eof())
|
||||
{
|
||||
TiffParser::decode(exifData_,
|
||||
iptcData_,
|
||||
xmpData_,
|
||||
tiff.c_data(),
|
||||
static_cast<uint32_t>(tiff.size()));
|
||||
TiffParser::decode(exifData_, iptcData_, xmpData_, tiff.c_data(), tiff.size());
|
||||
}
|
||||
}
|
||||
} // RafImage::readMetadata
|
||||
}
|
||||
|
||||
void RafImage::writeMetadata()
|
||||
{
|
||||
|
||||
+3
-9
@@ -101,8 +101,7 @@ namespace Exiv2 {
|
||||
throw Error(ErrorCode::kerNotAnImage, "RW2");
|
||||
}
|
||||
clearMetadata();
|
||||
ByteOrder bo =
|
||||
Rw2Parser::decode(exifData_, iptcData_, xmpData_, io_->mmap(), static_cast<uint32_t>(io_->size()));
|
||||
ByteOrder bo = Rw2Parser::decode(exifData_, iptcData_, xmpData_, io_->mmap(), io_->size());
|
||||
setByteOrder(bo);
|
||||
|
||||
// A lot more metadata is hidden in the embedded preview image
|
||||
@@ -197,13 +196,8 @@ namespace Exiv2 {
|
||||
throw(Error(ErrorCode::kerWritingImageFormatUnsupported, "RW2"));
|
||||
} // Rw2Image::writeMetadata
|
||||
|
||||
ByteOrder Rw2Parser::decode(
|
||||
ExifData& exifData,
|
||||
IptcData& iptcData,
|
||||
XmpData& xmpData,
|
||||
const byte* pData,
|
||||
uint32_t size
|
||||
)
|
||||
ByteOrder Rw2Parser::decode(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, const byte* pData,
|
||||
size_t size)
|
||||
{
|
||||
Rw2Header rw2Header;
|
||||
return TiffParserWorker::decode(exifData,
|
||||
|
||||
+7
-7
@@ -898,12 +898,12 @@ namespace Exiv2::Internal {
|
||||
//! Sony Tag 9403 SonyMisc1
|
||||
constexpr TagInfo SonyMakerNote::tagInfoSonyMisc1_[] = {
|
||||
{0x05, "CameraTemperature", N_("Camera temperature"),
|
||||
N_("Internal camera temperature (in degrees Celsius)"),
|
||||
sonyMisc1Id, makerTags, signedByte, -1, printSonyMisc1CameraTemperature},
|
||||
N_("Internal camera temperature (in degrees Celsius)"),
|
||||
sonyMisc1Id, makerTags, signedByte, -1, printSonyMisc1CameraTemperature},
|
||||
// End of list marker
|
||||
{0xffff, "(UnknownSonyMisc1Tag)", "(UnknownSonyMisc1Tag)",
|
||||
"(UnknownSonyMisc1Tag)",
|
||||
sonyMisc1Id, makerTags, unsignedByte, -1, printValue}
|
||||
"(UnknownSonyMisc1Tag)",
|
||||
sonyMisc1Id, makerTags, unsignedByte, -1, printValue}
|
||||
};
|
||||
|
||||
const TagInfo* SonyMakerNote::tagListSonyMisc1()
|
||||
@@ -1316,7 +1316,7 @@ namespace Exiv2::Internal {
|
||||
}
|
||||
|
||||
// https://github.com/Exiv2/exiv2/pull/906#issuecomment-504338797
|
||||
static DataBuf sonyTagCipher(uint16_t /* tag */, const byte* bytes, uint32_t size, TiffComponent* const /*object*/, bool bDecipher)
|
||||
static DataBuf sonyTagCipher(uint16_t /* tag */, const byte* bytes, size_t size, TiffComponent* const /*object*/, bool bDecipher)
|
||||
{
|
||||
DataBuf b(bytes,size); // copy the data
|
||||
|
||||
@@ -1341,11 +1341,11 @@ namespace Exiv2::Internal {
|
||||
return b;
|
||||
}
|
||||
|
||||
DataBuf sonyTagDecipher(uint16_t tag, const byte* bytes, uint32_t size, TiffComponent* const object)
|
||||
DataBuf sonyTagDecipher(uint16_t tag, const byte* bytes, size_t size, TiffComponent* const object)
|
||||
{
|
||||
return sonyTagCipher(tag,bytes,size,object,true);
|
||||
}
|
||||
DataBuf sonyTagEncipher(uint16_t tag, const byte* bytes, uint32_t size, TiffComponent* const object)
|
||||
DataBuf sonyTagEncipher(uint16_t tag, const byte* bytes, size_t size, TiffComponent* const object)
|
||||
{
|
||||
return sonyTagCipher(tag,bytes,size,object,false);
|
||||
}
|
||||
|
||||
+2
-2
@@ -79,8 +79,8 @@ namespace Exiv2::Internal {
|
||||
|
||||
}; // class SonyMakerNote
|
||||
|
||||
DataBuf sonyTagDecipher(uint16_t, const byte*, uint32_t, TiffComponent* const);
|
||||
DataBuf sonyTagEncipher(uint16_t, const byte*, uint32_t, TiffComponent* const);
|
||||
DataBuf sonyTagDecipher(uint16_t, const byte*, size_t, TiffComponent* const);
|
||||
DataBuf sonyTagEncipher(uint16_t, const byte*, size_t, TiffComponent* const);
|
||||
|
||||
} // namespace Exiv2::Internal
|
||||
|
||||
|
||||
+102
-98
@@ -61,7 +61,8 @@ namespace Exiv2::Internal {
|
||||
if (target < 0 || target > std::numeric_limits<uint32_t>::max()) {
|
||||
throw Error(ErrorCode::kerOffsetOutOfRange);
|
||||
}
|
||||
if (pow_) pow_->setTarget(OffsetWriter::OffsetId(id), static_cast<uint32_t>(target));
|
||||
if (pow_)
|
||||
pow_->setTarget(OffsetWriter::OffsetId(id), static_cast<uint32_t>(target));
|
||||
}
|
||||
|
||||
TiffComponent::TiffComponent(uint16_t tag, IfdId group) : tag_(tag), group_(group) {}
|
||||
@@ -259,7 +260,7 @@ namespace Exiv2::Internal {
|
||||
{
|
||||
storage_ = buf;
|
||||
pData_ = buf->data();
|
||||
size_ = static_cast<uint32_t>(buf->size());
|
||||
size_ = buf->size();
|
||||
}
|
||||
|
||||
void TiffEntryBase::setData(byte* pData, uint32_t size,
|
||||
@@ -299,7 +300,7 @@ namespace Exiv2::Internal {
|
||||
|
||||
void TiffDataEntry::setStrips(const Value* pSize,
|
||||
const byte* pData,
|
||||
uint32_t sizeData,
|
||||
size_t sizeData,
|
||||
uint32_t baseOffset)
|
||||
{
|
||||
if (!pValue() || !pSize) {
|
||||
@@ -337,9 +338,7 @@ namespace Exiv2::Internal {
|
||||
auto offset = pValue()->toUint32(0);
|
||||
// Todo: Remove limitation of JPEG writer: strips must be contiguous
|
||||
// Until then we check: last offset + last size - first offset == size?
|
||||
if ( pValue()->toUint32(static_cast<long>(pValue()->count())-1)
|
||||
+ pSize->toUint32(static_cast<long>(pSize->count())-1)
|
||||
- offset != size) {
|
||||
if (pValue()->toUint32(pValue()->count()-1) + pSize->toUint32(pSize->count()-1) - offset != size) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
EXV_WARNING << "Directory " << groupName(group())
|
||||
<< ", entry 0x" << std::setw(4)
|
||||
@@ -366,7 +365,7 @@ namespace Exiv2::Internal {
|
||||
|
||||
void TiffImageEntry::setStrips(const Value* pSize,
|
||||
const byte* pData,
|
||||
uint32_t sizeData,
|
||||
size_t sizeData,
|
||||
uint32_t baseOffset)
|
||||
{
|
||||
if (!pValue() || !pSize) {
|
||||
@@ -410,7 +409,7 @@ namespace Exiv2::Internal {
|
||||
}
|
||||
} // TiffImageEntry::setStrips
|
||||
|
||||
uint32_t TiffIfdMakernote::ifdOffset() const
|
||||
size_t TiffIfdMakernote::ifdOffset() const
|
||||
{
|
||||
if (!pHeader_) return 0;
|
||||
return pHeader_->ifdOffset();
|
||||
@@ -449,15 +448,17 @@ namespace Exiv2::Internal {
|
||||
if (pHeader_) pHeader_->setByteOrder(byteOrder);
|
||||
}
|
||||
|
||||
uint32_t TiffIfdMakernote::sizeHeader() const
|
||||
size_t TiffIfdMakernote::sizeHeader() const
|
||||
{
|
||||
if (!pHeader_) return 0;
|
||||
if (!pHeader_)
|
||||
return 0;
|
||||
return pHeader_->size();
|
||||
}
|
||||
|
||||
uint32_t TiffIfdMakernote::writeHeader(IoWrapper& ioWrapper, ByteOrder byteOrder) const
|
||||
size_t TiffIfdMakernote::writeHeader(IoWrapper& ioWrapper, ByteOrder byteOrder) const
|
||||
{
|
||||
if (!pHeader_) return 0;
|
||||
if (!pHeader_)
|
||||
return 0;
|
||||
return pHeader_->write(ioWrapper, byteOrder);
|
||||
}
|
||||
|
||||
@@ -503,12 +504,14 @@ namespace Exiv2::Internal {
|
||||
origSize_ = TiffEntryBase::doSize();
|
||||
}
|
||||
|
||||
bool TiffBinaryArray::updOrigDataBuf(const byte* pData, uint32_t size)
|
||||
bool TiffBinaryArray::updOrigDataBuf(const byte* pData, size_t size)
|
||||
{
|
||||
assert(pData);
|
||||
|
||||
if (origSize_ != size) return false;
|
||||
if (origData_ == pData) return true;
|
||||
if (origSize_ != size)
|
||||
return false;
|
||||
if (origData_ == pData)
|
||||
return true;
|
||||
memcpy(origData_, pData, origSize_);
|
||||
return true;
|
||||
}
|
||||
@@ -516,7 +519,7 @@ namespace Exiv2::Internal {
|
||||
uint32_t TiffBinaryArray::addElement(uint32_t idx, const ArrayDef& def)
|
||||
{
|
||||
auto tag = static_cast<uint16_t>(idx / cfg()->tagStep());
|
||||
int32_t sz = std::min(def.size(tag, cfg()->group_), TiffEntryBase::doSize() - idx);
|
||||
int32_t sz = std::min(def.size(tag, cfg()->group_), static_cast<uint32_t>(TiffEntryBase::doSize()) - idx);
|
||||
auto tc = TiffCreator::create(tag, cfg()->group_);
|
||||
auto tp = dynamic_cast<TiffBinaryElement*>(tc.get());
|
||||
// The assertion typically fails if a component is not configured in
|
||||
@@ -627,7 +630,7 @@ namespace Exiv2::Internal {
|
||||
auto atc = std::make_unique<TiffDirectory>(tpi1.tag(), tpi2.group());
|
||||
tc = addChild(std::move(atc));
|
||||
}
|
||||
setCount(static_cast<uint32_t>(ifds_.size()));
|
||||
setCount(ifds_.size());
|
||||
}
|
||||
return tc->addPath(tag, tiffPath, pRoot, std::move(object));
|
||||
} // TiffSubIfd::doAddPath
|
||||
@@ -698,7 +701,7 @@ namespace Exiv2::Internal {
|
||||
assert(atc);
|
||||
assert(tpi.extendedTag() != Tag::next);
|
||||
tc = addChild(std::move(atc));
|
||||
setCount(static_cast<uint32_t>(elements_.size()));
|
||||
setCount(elements_.size());
|
||||
}
|
||||
return tc->addPath(tag, tiffPath, pRoot, std::move(object));
|
||||
} // TiffBinaryArray::doAddPath
|
||||
@@ -860,74 +863,74 @@ namespace Exiv2::Internal {
|
||||
element->accept(visitor);
|
||||
}
|
||||
if (visitor.go(TiffVisitor::geTraverse)) visitor.visitBinaryArrayEnd(this);
|
||||
} // TiffBinaryArray::doAccept
|
||||
}
|
||||
|
||||
void TiffBinaryElement::doAccept(TiffVisitor& visitor)
|
||||
{
|
||||
visitor.visitBinaryElement(this);
|
||||
} // TiffBinaryElement::doAccept
|
||||
}
|
||||
|
||||
void TiffEntryBase::encode(TiffEncoder& encoder, const Exifdatum* datum)
|
||||
{
|
||||
doEncode(encoder, datum);
|
||||
} // TiffComponent::encode
|
||||
}
|
||||
|
||||
void TiffBinaryElement::doEncode(TiffEncoder& encoder, const Exifdatum* datum)
|
||||
{
|
||||
encoder.encodeBinaryElement(this, datum);
|
||||
} // TiffBinaryElement::doEncode
|
||||
}
|
||||
|
||||
void TiffBinaryArray::doEncode(TiffEncoder& encoder, const Exifdatum* datum)
|
||||
{
|
||||
encoder.encodeBinaryArray(this, datum);
|
||||
} // TiffBinaryArray::doEncode
|
||||
}
|
||||
|
||||
void TiffDataEntry::doEncode(TiffEncoder& encoder, const Exifdatum* datum)
|
||||
{
|
||||
encoder.encodeDataEntry(this, datum);
|
||||
} // TiffDataEntry::doEncode
|
||||
}
|
||||
|
||||
void TiffEntry::doEncode(TiffEncoder& encoder, const Exifdatum* datum)
|
||||
{
|
||||
encoder.encodeTiffEntry(this, datum);
|
||||
} // TiffEntry::doEncode
|
||||
}
|
||||
|
||||
void TiffImageEntry::doEncode(TiffEncoder& encoder, const Exifdatum* datum)
|
||||
{
|
||||
encoder.encodeImageEntry(this, datum);
|
||||
} // TiffImageEntry::doEncode
|
||||
}
|
||||
|
||||
void TiffMnEntry::doEncode(TiffEncoder& encoder, const Exifdatum* datum)
|
||||
{
|
||||
encoder.encodeMnEntry(this, datum);
|
||||
} // TiffMnEntry::doEncode
|
||||
}
|
||||
|
||||
void TiffSizeEntry::doEncode(TiffEncoder& encoder, const Exifdatum* datum)
|
||||
{
|
||||
encoder.encodeSizeEntry(this, datum);
|
||||
} // TiffSizeEntry::doEncode
|
||||
}
|
||||
|
||||
void TiffSubIfd::doEncode(TiffEncoder& encoder, const Exifdatum* datum)
|
||||
{
|
||||
encoder.encodeSubIfd(this, datum);
|
||||
} // TiffSubIfd::doEncode
|
||||
}
|
||||
|
||||
uint32_t TiffComponent::count() const
|
||||
size_t TiffComponent::count() const
|
||||
{
|
||||
return doCount();
|
||||
}
|
||||
|
||||
uint32_t TiffDirectory::doCount() const
|
||||
size_t TiffDirectory::doCount() const
|
||||
{
|
||||
return static_cast<uint32_t>(components_.size());
|
||||
return components_.size();
|
||||
}
|
||||
|
||||
uint32_t TiffEntryBase::doCount() const
|
||||
size_t TiffEntryBase::doCount() const
|
||||
{
|
||||
return static_cast<uint32_t>(count_);
|
||||
return count_;
|
||||
}
|
||||
|
||||
uint32_t TiffMnEntry::doCount() const
|
||||
size_t TiffMnEntry::doCount() const
|
||||
{
|
||||
if (!mn_) {
|
||||
return TiffEntryBase::doCount();
|
||||
@@ -945,12 +948,12 @@ namespace Exiv2::Internal {
|
||||
return mn_->size();
|
||||
}
|
||||
|
||||
uint32_t TiffIfdMakernote::doCount() const
|
||||
size_t TiffIfdMakernote::doCount() const
|
||||
{
|
||||
return ifd_.count();
|
||||
} // TiffIfdMakernote::doCount
|
||||
|
||||
uint32_t TiffBinaryArray::doCount() const
|
||||
size_t TiffBinaryArray::doCount() const
|
||||
{
|
||||
if (!cfg() || !decoded())
|
||||
return TiffEntryBase::doCount();
|
||||
@@ -970,10 +973,10 @@ namespace Exiv2::Internal {
|
||||
typeSize = 1;
|
||||
}
|
||||
|
||||
return static_cast<uint32_t>(static_cast<double>(size()) / typeSize + 0.5);
|
||||
return static_cast<size_t>(static_cast<double>(size()) / typeSize + 0.5);
|
||||
}
|
||||
|
||||
uint32_t TiffBinaryElement::doCount() const
|
||||
size_t TiffBinaryElement::doCount() const
|
||||
{
|
||||
return elDef_.count_;
|
||||
}
|
||||
@@ -998,16 +1001,18 @@ namespace Exiv2::Internal {
|
||||
bool isRootDir = (imageIdx == uint32_t(-1));
|
||||
|
||||
// Number of components to write
|
||||
const uint32_t compCount = count();
|
||||
const size_t compCount = count();
|
||||
if (compCount > 0xffff)
|
||||
throw Error(ErrorCode::kerTooManyTiffDirectoryEntries, groupName(group()));
|
||||
|
||||
// Size of next IFD, if any
|
||||
uint32_t sizeNext = 0;
|
||||
if (pNext_) sizeNext = pNext_->size();
|
||||
size_t sizeNext = 0;
|
||||
if (pNext_)
|
||||
sizeNext = pNext_->size();
|
||||
|
||||
// Nothing to do if there are no entries and the size of the next IFD is 0
|
||||
if (compCount == 0 && sizeNext == 0) return 0;
|
||||
if (compCount == 0 && sizeNext == 0)
|
||||
return 0;
|
||||
|
||||
// Remember the offset of the CR2 RAW IFD
|
||||
if (group() == ifd3Id) {
|
||||
@@ -1019,7 +1024,7 @@ namespace Exiv2::Internal {
|
||||
ioWrapper.setTarget(OffsetWriter::cr2RawIfdOffset, offset);
|
||||
}
|
||||
// Size of all directory entries, without values and additional data
|
||||
const uint32_t sizeDir = 2 + 12 * compCount + (hasNext_ ? 4 : 0);
|
||||
const size_t sizeDir = 2 + 12 * compCount + (hasNext_ ? 4 : 0);
|
||||
|
||||
// TIFF standard requires IFD entries to be sorted in ascending order by tag.
|
||||
// Not sorting makernote directories sometimes preserves them better.
|
||||
@@ -1030,10 +1035,10 @@ namespace Exiv2::Internal {
|
||||
uint32_t sizeValue = 0;
|
||||
uint32_t sizeData = 0;
|
||||
for (auto&& component : components_) {
|
||||
uint32_t sv = component->size();
|
||||
size_t sv = component->size();
|
||||
if (sv > 4) {
|
||||
sv += sv & 1; // Align value to word boundary
|
||||
sizeValue += sv;
|
||||
sizeValue += static_cast<uint32_t>(sv);
|
||||
}
|
||||
// Also add the size of data, but only if needed
|
||||
if (isRootDir) {
|
||||
@@ -1043,10 +1048,10 @@ namespace Exiv2::Internal {
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t idx = 0; // Current IFD index / bytes written
|
||||
valueIdx = sizeDir; // Offset to the current IFD value
|
||||
dataIdx = sizeDir + sizeValue; // Offset to the entry's data area
|
||||
if (isRootDir) { // Absolute offset to the image data
|
||||
size_t idx = 0; // Current IFD index / bytes written
|
||||
valueIdx = static_cast<uint32_t>(sizeDir); // Offset to the current IFD value
|
||||
dataIdx = static_cast<uint32_t>(sizeDir + sizeValue); // Offset to the entry's data area
|
||||
if (isRootDir) { // Absolute offset to the image data
|
||||
imageIdx = static_cast<uint32_t>(offset + dataIdx + sizeData + sizeNext);
|
||||
imageIdx += imageIdx & 1; // Align image data to word boundary
|
||||
}
|
||||
@@ -1059,10 +1064,10 @@ namespace Exiv2::Internal {
|
||||
// b) Directory entries - may contain pointers to the value or data
|
||||
for (auto&& component : components_) {
|
||||
idx += writeDirEntry(ioWrapper, byteOrder, offset, component, valueIdx, dataIdx, imageIdx);
|
||||
uint32_t sv = component->size();
|
||||
size_t sv = component->size();
|
||||
if (sv > 4) {
|
||||
sv += sv & 1; // Align value to word boundary
|
||||
valueIdx += sv;
|
||||
valueIdx += static_cast<uint32_t>(sv);
|
||||
}
|
||||
auto sd = static_cast<uint32_t>(component->sizeData());
|
||||
sd += sd & 1; // Align data to word boundary
|
||||
@@ -1080,10 +1085,10 @@ namespace Exiv2::Internal {
|
||||
assert(idx == sizeDir);
|
||||
|
||||
// 2nd: Write IFD values - may contain pointers to additional data
|
||||
valueIdx = sizeDir;
|
||||
dataIdx = sizeDir + sizeValue;
|
||||
valueIdx = static_cast<uint32_t>(sizeDir);
|
||||
dataIdx = static_cast<uint32_t>(sizeDir + sizeValue);
|
||||
for (auto&& component : components_) {
|
||||
uint32_t sv = component->size();
|
||||
size_t sv = component->size();
|
||||
if (sv > 4) {
|
||||
uint32_t d = component->write(ioWrapper, byteOrder, offset, valueIdx, dataIdx, imageIdx);
|
||||
enforce(sv == d, ErrorCode::kerImageWriteFailed);
|
||||
@@ -1092,7 +1097,7 @@ namespace Exiv2::Internal {
|
||||
sv += 1;
|
||||
}
|
||||
idx += sv;
|
||||
valueIdx += sv;
|
||||
valueIdx += static_cast<uint32_t>(sv);
|
||||
}
|
||||
auto sd = static_cast<uint32_t>(component->sizeData());
|
||||
sd += sd & 1; // Align data to word boundary
|
||||
@@ -1101,7 +1106,7 @@ namespace Exiv2::Internal {
|
||||
assert(idx == sizeDir + sizeValue);
|
||||
|
||||
// 3rd: Write data - may contain offsets too (eg sub-IFD)
|
||||
dataIdx = sizeDir + sizeValue;
|
||||
dataIdx = static_cast<uint32_t>(sizeDir + sizeValue);
|
||||
idx += writeData(ioWrapper, byteOrder, offset, dataIdx, imageIdx);
|
||||
|
||||
// 4th: Write next-IFD
|
||||
@@ -1114,8 +1119,8 @@ namespace Exiv2::Internal {
|
||||
idx += writeImage(ioWrapper, byteOrder);
|
||||
}
|
||||
|
||||
return idx;
|
||||
} // TiffDirectory::doWrite
|
||||
return static_cast<uint32_t>(idx);
|
||||
}
|
||||
|
||||
uint32_t TiffDirectory::writeDirEntry(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t offset,
|
||||
TiffComponent* pTiffComponent, uint32_t valueIdx, uint32_t dataIdx,
|
||||
@@ -1127,7 +1132,7 @@ namespace Exiv2::Internal {
|
||||
byte buf[8];
|
||||
us2Data(buf, pDirEntry->tag(), byteOrder);
|
||||
us2Data(buf + 2, pDirEntry->tiffType(), byteOrder);
|
||||
ul2Data(buf + 4, pDirEntry->count(), byteOrder);
|
||||
ul2Data(buf + 4, static_cast<uint32_t>(pDirEntry->count()), byteOrder);
|
||||
ioWrapper.write(buf, 8);
|
||||
if (pDirEntry->size() > 4) {
|
||||
pDirEntry->setOffset(offset + static_cast<int32_t>(valueIdx));
|
||||
@@ -1162,7 +1167,8 @@ namespace Exiv2::Internal {
|
||||
uint32_t /*dataIdx*/,
|
||||
uint32_t& /*imageIdx*/)
|
||||
{
|
||||
if (!pValue_) return 0;
|
||||
if (!pValue_)
|
||||
return 0;
|
||||
|
||||
DataBuf buf(pValue_->size());
|
||||
pValue_->copy(buf.data(), byteOrder);
|
||||
@@ -1210,14 +1216,11 @@ namespace Exiv2::Internal {
|
||||
for (uint32_t i = 0; i < count(); ++i) {
|
||||
const int64_t newDataIdx = pValue()->toInt64(i) - prevOffset
|
||||
+ static_cast<int64_t>(dataIdx);
|
||||
idx += writeOffset(buf.data(idx),
|
||||
offset + newDataIdx,
|
||||
tiffType(),
|
||||
byteOrder);
|
||||
idx += writeOffset(buf.data(idx), offset + newDataIdx, tiffType(), byteOrder);
|
||||
}
|
||||
ioWrapper.write(buf.c_data(), buf.size());
|
||||
return static_cast<uint32_t>(buf.size());
|
||||
} // TiffDataEntry::doWrite
|
||||
}
|
||||
|
||||
uint32_t TiffImageEntry::doWrite(IoWrapper& ioWrapper,
|
||||
ByteOrder byteOrder,
|
||||
@@ -1263,7 +1266,7 @@ namespace Exiv2::Internal {
|
||||
std::sort(ifds_.begin(), ifds_.end(), cmpGroupLt);
|
||||
for (auto&& ifd : ifds_) {
|
||||
idx += writeOffset(buf.data(idx), offset + dataIdx, tiffType(), byteOrder);
|
||||
dataIdx += ifd->size();
|
||||
dataIdx += static_cast<uint32_t>(ifd->size());
|
||||
}
|
||||
ioWrapper.write(buf.c_data(), buf.size());
|
||||
return static_cast<uint32_t>(buf.size());
|
||||
@@ -1291,7 +1294,7 @@ namespace Exiv2::Internal {
|
||||
{
|
||||
mnOffset_ = static_cast<uint32_t>(offset);
|
||||
setImageByteOrder(byteOrder);
|
||||
uint32_t len = writeHeader(ioWrapper, this->byteOrder());
|
||||
uint32_t len = static_cast<uint32_t>(writeHeader(ioWrapper, this->byteOrder()));
|
||||
len += ifd_.write(ioWrapper, this->byteOrder(),
|
||||
offset - baseOffset() + len,
|
||||
uint32_t(-1), uint32_t(-1),
|
||||
@@ -1320,10 +1323,10 @@ namespace Exiv2::Internal {
|
||||
size_t elSize = TypeInfo::typeSize(toTypeId(cfg()->elTiffType_, 0, cfg()->group_));
|
||||
switch (elSize) {
|
||||
case 2:
|
||||
idx += us2Data(buf, size(), byteOrder);
|
||||
idx += us2Data(buf, static_cast<uint16_t>(size()), byteOrder);
|
||||
break;
|
||||
case 4:
|
||||
idx += ul2Data(buf, size(), byteOrder);
|
||||
idx += ul2Data(buf, static_cast<uint32_t>(size()), byteOrder);
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
@@ -1570,19 +1573,19 @@ namespace Exiv2::Internal {
|
||||
return static_cast<uint32_t>(len);
|
||||
} // TiffImageEntry::doWriteImage
|
||||
|
||||
uint32_t TiffComponent::size() const
|
||||
size_t TiffComponent::size() const
|
||||
{
|
||||
return doSize();
|
||||
} // TiffComponent::size
|
||||
}
|
||||
|
||||
uint32_t TiffDirectory::doSize() const
|
||||
size_t TiffDirectory::doSize() const
|
||||
{
|
||||
uint32_t compCount = count();
|
||||
size_t compCount = count();
|
||||
// Size of the directory, without values and additional data
|
||||
uint32_t len = 2 + 12 * compCount + (hasNext_ ? 4 : 0);
|
||||
size_t len = 2 + 12 * compCount + (hasNext_ ? 4 : 0);
|
||||
// Size of IFD values and data
|
||||
for (auto&& component : components_) {
|
||||
uint32_t sv = component->size();
|
||||
size_t sv = component->size();
|
||||
if (sv > 4) {
|
||||
sv += sv & 1; // Align value to word boundary
|
||||
len += sv;
|
||||
@@ -1592,45 +1595,46 @@ namespace Exiv2::Internal {
|
||||
len += sd;
|
||||
}
|
||||
// Size of next-IFD, if any
|
||||
uint32_t sizeNext = 0;
|
||||
size_t sizeNext = 0;
|
||||
if (pNext_) {
|
||||
sizeNext = pNext_->size();
|
||||
len += sizeNext;
|
||||
}
|
||||
// Reset size of IFD if it has no entries and no or empty next IFD.
|
||||
if (compCount == 0 && sizeNext == 0) len = 0;
|
||||
if (compCount == 0 && sizeNext == 0)
|
||||
len = 0;
|
||||
return len;
|
||||
} // TiffDirectory::doSize
|
||||
}
|
||||
|
||||
uint32_t TiffEntryBase::doSize() const
|
||||
size_t TiffEntryBase::doSize() const
|
||||
{
|
||||
return size_;
|
||||
} // TiffEntryBase::doSize
|
||||
}
|
||||
|
||||
uint32_t TiffImageEntry::doSize() const
|
||||
size_t TiffImageEntry::doSize() const
|
||||
{
|
||||
return static_cast<uint32_t>(strips_.size()) * 4;
|
||||
} // TiffImageEntry::doSize
|
||||
return strips_.size() * 4;
|
||||
}
|
||||
|
||||
uint32_t TiffSubIfd::doSize() const
|
||||
size_t TiffSubIfd::doSize() const
|
||||
{
|
||||
return static_cast<uint32_t>(ifds_.size()) * 4;
|
||||
} // TiffSubIfd::doSize
|
||||
return ifds_.size() * 4;
|
||||
}
|
||||
|
||||
uint32_t TiffMnEntry::doSize() const
|
||||
size_t TiffMnEntry::doSize() const
|
||||
{
|
||||
if (!mn_) {
|
||||
return TiffEntryBase::doSize();
|
||||
}
|
||||
return mn_->size();
|
||||
} // TiffMnEntry::doSize
|
||||
}
|
||||
|
||||
uint32_t TiffIfdMakernote::doSize() const
|
||||
size_t TiffIfdMakernote::doSize() const
|
||||
{
|
||||
return sizeHeader() + ifd_.size();
|
||||
} // TiffIfdMakernote::doSize
|
||||
}
|
||||
|
||||
uint32_t TiffBinaryArray::doSize() const
|
||||
size_t TiffBinaryArray::doSize() const
|
||||
{
|
||||
if (!cfg() || !decoded())
|
||||
return TiffEntryBase::doSize();
|
||||
@@ -1640,8 +1644,8 @@ namespace Exiv2::Internal {
|
||||
// Remaining assumptions:
|
||||
// - array elements don't "overlap"
|
||||
// - no duplicate tags in the array
|
||||
uint32_t idx = 0;
|
||||
uint32_t sz = cfg()->tagStep();
|
||||
size_t idx = 0;
|
||||
size_t sz = cfg()->tagStep();
|
||||
for (auto&& element : elements_) {
|
||||
if (element->tag() > idx) {
|
||||
idx = element->tag();
|
||||
@@ -1653,17 +1657,17 @@ namespace Exiv2::Internal {
|
||||
if (cfg()->hasFillers_ && def()) {
|
||||
const ArrayDef* lastDef = def() + defSize() - 1;
|
||||
auto lastTag = static_cast<uint16_t>(lastDef->idx_ / cfg()->tagStep());
|
||||
idx = std::max(idx, lastDef->idx_ + lastDef->size(lastTag, cfg()->group_));
|
||||
idx = std::max(idx, static_cast<size_t>(lastDef->idx_ + lastDef->size(lastTag, cfg()->group_)));
|
||||
}
|
||||
return idx;
|
||||
|
||||
} // TiffBinaryArray::doSize
|
||||
|
||||
uint32_t TiffBinaryElement::doSize() const
|
||||
size_t TiffBinaryElement::doSize() const
|
||||
{
|
||||
if (!pValue())
|
||||
return 0;
|
||||
return static_cast<uint32_t>(pValue()->size());
|
||||
return pValue()->size();
|
||||
}
|
||||
|
||||
size_t TiffComponent::sizeData() const
|
||||
@@ -1701,7 +1705,7 @@ namespace Exiv2::Internal {
|
||||
|
||||
size_t TiffSubIfd::doSizeData() const
|
||||
{
|
||||
uint32_t len = 0;
|
||||
size_t len = 0;
|
||||
for (auto&& ifd : ifds_) {
|
||||
len += ifd->size();
|
||||
}
|
||||
|
||||
+32
-36
@@ -261,11 +261,11 @@ namespace Exiv2 {
|
||||
@brief Return the size in bytes of the IFD value of this component
|
||||
when written to a binary image.
|
||||
*/
|
||||
uint32_t size() const;
|
||||
size_t size() const;
|
||||
/*!
|
||||
@brief Return the number of components in this component.
|
||||
*/
|
||||
uint32_t count() const;
|
||||
size_t count() const;
|
||||
/*!
|
||||
@brief Return the size in bytes of the IFD data of this component when
|
||||
written to a binary image. This is a support function for
|
||||
@@ -325,9 +325,9 @@ namespace Exiv2 {
|
||||
virtual uint32_t doWriteImage(IoWrapper& ioWrapper,
|
||||
ByteOrder byteOrder) const =0;
|
||||
//! Implements size().
|
||||
virtual uint32_t doSize() const =0;
|
||||
virtual size_t doSize() const =0;
|
||||
//! Implements count().
|
||||
virtual uint32_t doCount() const =0;
|
||||
virtual size_t doCount() const =0;
|
||||
//! Implements sizeData().
|
||||
virtual size_t doSizeData() const =0;
|
||||
//! Implements sizeImage().
|
||||
@@ -482,7 +482,7 @@ namespace Exiv2 {
|
||||
//! Implements encode().
|
||||
virtual void doEncode(TiffEncoder& encoder, const Exifdatum* datum) =0;
|
||||
//! Set the number of components in this entry
|
||||
void setCount(uint32_t count) { count_ = count; }
|
||||
void setCount(size_t count) { count_ = count; }
|
||||
//! Set the unique id of the entry in the image
|
||||
void setIdx(int idx) { idx_ = idx; }
|
||||
/*!
|
||||
@@ -497,7 +497,7 @@ namespace Exiv2 {
|
||||
//! @name Protected Accessors
|
||||
//@{
|
||||
//! Implements count().
|
||||
uint32_t doCount() const override;
|
||||
size_t doCount() const override;
|
||||
/*!
|
||||
@brief Implements writeData(). Standard TIFF entries have no data:
|
||||
write nothing and return 0.
|
||||
@@ -510,7 +510,7 @@ namespace Exiv2 {
|
||||
*/
|
||||
uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
//! Implements size(). Return the size of a standard TIFF entry
|
||||
uint32_t doSize() const override;
|
||||
size_t doSize() const override;
|
||||
//! Implements sizeData(). Return 0.
|
||||
size_t doSizeData() const override;
|
||||
//! Implements sizeImage(). Return 0.
|
||||
@@ -537,11 +537,7 @@ namespace Exiv2 {
|
||||
TiffType tiffType_; //!< Field TIFF type
|
||||
size_t count_{}; //!< The number of values of the indicated type
|
||||
int64_t offset_{}; //!< Offset to the data area
|
||||
/*!
|
||||
Size of the data buffer holding the value in bytes, there is no
|
||||
minimum size.
|
||||
*/
|
||||
uint32_t size_{};
|
||||
size_t size_{}; //!< Size of the data buffer holding the value in bytes, there is no minimum size.
|
||||
|
||||
// Notes on the ownership model of pData_: pData_ is a always a
|
||||
// pointer to a buffer owned by somebody else. Usually it is a
|
||||
@@ -620,7 +616,7 @@ namespace Exiv2 {
|
||||
*/
|
||||
virtual void setStrips(const Value* pSize,
|
||||
const byte* pData,
|
||||
uint32_t sizeData,
|
||||
size_t sizeData,
|
||||
uint32_t baseOffset) =0;
|
||||
//@}
|
||||
|
||||
@@ -657,7 +653,7 @@ namespace Exiv2 {
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void setStrips(const Value* pSize, const byte* pData, uint32_t sizeData, uint32_t baseOffset) override;
|
||||
void setStrips(const Value* pSize, const byte* pData, size_t sizeData, uint32_t baseOffset) override;
|
||||
//@}
|
||||
|
||||
protected:
|
||||
@@ -722,7 +718,7 @@ namespace Exiv2 {
|
||||
public:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void setStrips(const Value* pSize, const byte* pData, uint32_t sizeData, uint32_t baseOffset) override;
|
||||
void setStrips(const Value* pSize, const byte* pData, size_t sizeData, uint32_t baseOffset) override;
|
||||
//@}
|
||||
|
||||
protected:
|
||||
@@ -758,7 +754,7 @@ namespace Exiv2 {
|
||||
*/
|
||||
uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
//! Implements size(). Return the size of the strip pointers.
|
||||
uint32_t doSize() const override;
|
||||
size_t doSize() const override;
|
||||
//! Implements sizeData(). Return the size of the image data area.
|
||||
size_t doSizeData() const override;
|
||||
//! Implements sizeImage(). Return the size of the image data area.
|
||||
@@ -883,12 +879,12 @@ namespace Exiv2 {
|
||||
@brief Implements size(). Return the size of the TIFF directory,
|
||||
values and additional data, including the next-IFD, if any.
|
||||
*/
|
||||
uint32_t doSize() const override;
|
||||
size_t doSize() const override;
|
||||
/*!
|
||||
@brief Implements count(). Return the number of entries in the TIFF
|
||||
directory. Does not count entries which are marked as deleted.
|
||||
*/
|
||||
uint32_t doCount() const override;
|
||||
size_t doCount() const override;
|
||||
/*!
|
||||
@brief This class does not really implement sizeData(), it only has
|
||||
size(). This method must not be called; it commits suicide.
|
||||
@@ -979,7 +975,7 @@ namespace Exiv2 {
|
||||
*/
|
||||
uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
//! Implements size(). Return the size of the sub-Ifd pointers.
|
||||
uint32_t doSize() const override;
|
||||
size_t doSize() const override;
|
||||
//! Implements sizeData(). Return the sum of the sizes of all sub-IFDs.
|
||||
size_t doSizeData() const override;
|
||||
//! Implements sizeImage(). Return the sum of the image sizes of all sub-IFDs.
|
||||
@@ -1043,14 +1039,14 @@ namespace Exiv2 {
|
||||
//@{
|
||||
TiffMnEntry* doClone() const override;
|
||||
//! Implements count(). Return number of components in the entry.
|
||||
uint32_t doCount() const override;
|
||||
size_t doCount() const override;
|
||||
// Using doWriteData from base class
|
||||
// Using doWriteImage from base class
|
||||
/*!
|
||||
@brief Implements size() by forwarding the call to the actual
|
||||
concrete Makernote, if there is one.
|
||||
*/
|
||||
uint32_t doSize() const override;
|
||||
size_t doSize() const override;
|
||||
// Using doSizeData from base class
|
||||
// Using doSizeImage from base class
|
||||
//@}
|
||||
@@ -1115,9 +1111,9 @@ namespace Exiv2 {
|
||||
//! @name Accessors
|
||||
//@{
|
||||
//! Return the size of the header in bytes.
|
||||
uint32_t sizeHeader() const;
|
||||
size_t sizeHeader() const;
|
||||
//! Write the header to a data buffer, return the number of bytes written.
|
||||
uint32_t writeHeader(IoWrapper& ioWrapper, ByteOrder byteOrder) const;
|
||||
size_t writeHeader(IoWrapper& ioWrapper, ByteOrder byteOrder) const;
|
||||
/*!
|
||||
@brief Return the offset to the makernote from the start of the
|
||||
TIFF header.
|
||||
@@ -1128,7 +1124,7 @@ namespace Exiv2 {
|
||||
the start of the Makernote.
|
||||
Returns 0 if there is no header.
|
||||
*/
|
||||
uint32_t ifdOffset() const;
|
||||
size_t ifdOffset() const;
|
||||
/*!
|
||||
@brief Return the byte order for the makernote. Requires the image
|
||||
byte order to be set (setImageByteOrder()). Returns the byte
|
||||
@@ -1183,13 +1179,13 @@ namespace Exiv2 {
|
||||
@brief Implements size(). Return the size of the Makernote header,
|
||||
TIFF directory, values and additional data.
|
||||
*/
|
||||
uint32_t doSize() const override;
|
||||
size_t doSize() const override;
|
||||
/*!
|
||||
@brief Implements count(). Return the number of entries in the IFD
|
||||
of the Makernote. Does not count entries which are marked as
|
||||
deleted.
|
||||
*/
|
||||
uint32_t doCount() const override;
|
||||
size_t doCount() const override;
|
||||
/*!
|
||||
@brief This class does not really implement sizeData(), it only has
|
||||
size(). This method must not be called; it commits suicide.
|
||||
@@ -1229,10 +1225,10 @@ namespace Exiv2 {
|
||||
@brief Function pointer type for a function to determine which cfg + def
|
||||
of a corresponding array set to use.
|
||||
*/
|
||||
using CfgSelFct = int (*)(uint16_t, const byte*, uint32_t, TiffComponent* const);
|
||||
using CfgSelFct = int (*)(uint16_t, const byte*, size_t, TiffComponent* const);
|
||||
|
||||
//! Function pointer type for a crypt function used for binary arrays.
|
||||
using CryptFct = DataBuf (*)(uint16_t, const byte*, uint32_t, TiffComponent* const);
|
||||
using CryptFct = DataBuf (*)(uint16_t, const byte*, size_t, TiffComponent* const);
|
||||
|
||||
//! Defines one tag in a binary array
|
||||
struct ArrayDef {
|
||||
@@ -1326,7 +1322,7 @@ namespace Exiv2 {
|
||||
//! Initialize the original data buffer and its size from the base entry.
|
||||
void iniOrigDataBuf();
|
||||
//! Update the original data buffer and its size, return true if successful.
|
||||
bool updOrigDataBuf(const byte* pData, uint32_t size);
|
||||
bool updOrigDataBuf(const byte* pData, size_t size);
|
||||
//! Set a flag to indicate if the array was decoded
|
||||
void setDecoded(bool decoded) { decoded_ = decoded; }
|
||||
//@}
|
||||
@@ -1376,13 +1372,13 @@ namespace Exiv2 {
|
||||
//@{
|
||||
TiffBinaryArray* doClone() const override;
|
||||
//! Implements count(). Todo: Document it!
|
||||
uint32_t doCount() const override;
|
||||
size_t doCount() const override;
|
||||
// Using doWriteData from base class
|
||||
// Using doWriteImage from base class
|
||||
/*!
|
||||
@brief Implements size(). Todo: Document it!
|
||||
*/
|
||||
uint32_t doSize() const override;
|
||||
size_t doSize() const override;
|
||||
// Using doSizeData from base class
|
||||
// Using doSizeImage from base class
|
||||
//@}
|
||||
@@ -1396,9 +1392,9 @@ namespace Exiv2 {
|
||||
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)
|
||||
Components elements_; //!< List of elements in this composite
|
||||
byte* origData_{}; //!< Pointer to the original data buffer (unencrypted)
|
||||
uint32_t origSize_{}; //!< Size of the original data buffer
|
||||
Components elements_; //!< List of elements in this composite
|
||||
byte* origData_{}; //!< Pointer to the original data buffer (unencrypted)
|
||||
size_t origSize_{}; //!< Size of the original data buffer
|
||||
TiffComponent*
|
||||
pRoot_{}; //!< Pointer to the root component of the TIFF tree. (Only used for intrusive writing.)
|
||||
bool decoded_{}; //!< Flag to indicate if the array was decoded
|
||||
@@ -1459,14 +1455,14 @@ namespace Exiv2 {
|
||||
/*!
|
||||
@brief Implements count(). Returns the count from the element definition.
|
||||
*/
|
||||
uint32_t doCount() const override;
|
||||
size_t doCount() const override;
|
||||
// Using doWriteData from base class
|
||||
// Using doWriteImage from base class
|
||||
/*!
|
||||
@brief Implements size(). Returns count * type-size, both taken from
|
||||
the element definition.
|
||||
*/
|
||||
uint32_t doSize() const override;
|
||||
size_t doSize() const override;
|
||||
// Using doSizeData from base class
|
||||
// Using doSizeImage from base class
|
||||
//@}
|
||||
|
||||
+6
-14
@@ -157,8 +157,7 @@ namespace Exiv2 {
|
||||
}
|
||||
clearMetadata();
|
||||
|
||||
ByteOrder bo =
|
||||
TiffParser::decode(exifData_, iptcData_, xmpData_, io_->mmap(), static_cast<uint32_t>(io_->size()));
|
||||
ByteOrder bo = TiffParser::decode(exifData_, iptcData_, xmpData_, io_->mmap(), io_->size());
|
||||
setByteOrder(bo);
|
||||
|
||||
// read profile from the metadata
|
||||
@@ -182,13 +181,13 @@ namespace Exiv2 {
|
||||
#endif
|
||||
ByteOrder bo = byteOrder();
|
||||
byte* pData = nullptr;
|
||||
long size = 0;
|
||||
size_t size = 0;
|
||||
IoCloser closer(*io_);
|
||||
if (io_->open() == 0) {
|
||||
// Ensure that this is the correct image type
|
||||
if (isTiffType(*io_, false)) {
|
||||
pData = io_->mmap(true);
|
||||
size = static_cast<long>(io_->size());
|
||||
size = io_->size();
|
||||
TiffHeader tiffHeader;
|
||||
if (0 == tiffHeader.read(pData, 8)) {
|
||||
bo = tiffHeader.byteOrder();
|
||||
@@ -205,7 +204,7 @@ namespace Exiv2 {
|
||||
auto pos = exifData_.findKey(key);
|
||||
bool found = pos != exifData_.end();
|
||||
if ( iccProfileDefined() ) {
|
||||
Exiv2::DataValue value(iccProfile_.c_data(), static_cast<long>(iccProfile_.size()));
|
||||
Exiv2::DataValue value(iccProfile_.c_data(), iccProfile_.size());
|
||||
if ( found ) pos->setValue(&value);
|
||||
else exifData_.add(key,&value);
|
||||
} else {
|
||||
@@ -244,15 +243,8 @@ namespace Exiv2 {
|
||||
TiffMapping::findDecoder);
|
||||
} // TiffParser::decode
|
||||
|
||||
WriteMethod TiffParser::encode(
|
||||
BasicIo& io,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
ByteOrder byteOrder,
|
||||
const ExifData& exifData,
|
||||
const IptcData& iptcData,
|
||||
const XmpData& xmpData
|
||||
)
|
||||
WriteMethod TiffParser::encode(BasicIo& io, const byte* pData, size_t size, ByteOrder byteOrder,
|
||||
const ExifData& exifData, const IptcData& iptcData, const XmpData& xmpData)
|
||||
{
|
||||
// Copy to be able to modify the Exif data
|
||||
ExifData ed = exifData;
|
||||
|
||||
@@ -2029,7 +2029,7 @@ namespace Exiv2::Internal {
|
||||
IptcData& iptcData,
|
||||
XmpData& xmpData,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
uint32_t root,
|
||||
FindDecoderFct findDecoderFct,
|
||||
TiffHeaderBase* pHeader
|
||||
@@ -2058,7 +2058,7 @@ namespace Exiv2::Internal {
|
||||
WriteMethod TiffParserWorker::encode(
|
||||
BasicIo& io,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
const ExifData& exifData,
|
||||
const IptcData& iptcData,
|
||||
const XmpData& xmpData,
|
||||
@@ -2132,7 +2132,7 @@ namespace Exiv2::Internal {
|
||||
|
||||
TiffComponent::UniquePtr TiffParserWorker::parse(
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
uint32_t root,
|
||||
TiffHeaderBase* pHeader
|
||||
)
|
||||
@@ -2198,9 +2198,10 @@ namespace Exiv2::Internal {
|
||||
{
|
||||
}
|
||||
|
||||
bool TiffHeaderBase::read(const byte* pData, uint32_t size)
|
||||
bool TiffHeaderBase::read(const byte* pData, size_t size)
|
||||
{
|
||||
if (!pData || size < 8) return false;
|
||||
if (!pData || size < 8)
|
||||
return false;
|
||||
|
||||
if (pData[0] == 'I' && pData[0] == pData[1]) {
|
||||
byteOrder_ = littleEndian;
|
||||
@@ -2216,7 +2217,7 @@ namespace Exiv2::Internal {
|
||||
offset_ = getULong(pData + 4, byteOrder_);
|
||||
|
||||
return true;
|
||||
} // TiffHeaderBase::read
|
||||
}
|
||||
|
||||
DataBuf TiffHeaderBase::write() const
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Exiv2::Internal {
|
||||
@return True if the TIFF header was read successfully. False if the
|
||||
data buffer does not contain a valid TIFF header.
|
||||
*/
|
||||
virtual bool read(const byte* pData, uint32_t size);
|
||||
virtual bool read(const byte* pData, size_t size);
|
||||
//! Set the byte order.
|
||||
virtual void setByteOrder(ByteOrder byteOrder);
|
||||
//! Set the offset to the start of the root directory.
|
||||
@@ -270,7 +270,7 @@ namespace Exiv2::Internal {
|
||||
decoding failed.
|
||||
*/
|
||||
static ByteOrder decode(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, const byte* pData,
|
||||
uint32_t size, uint32_t root, FindDecoderFct findDecoderFct,
|
||||
size_t size, uint32_t root, FindDecoderFct findDecoderFct,
|
||||
TiffHeaderBase* pHeader = nullptr);
|
||||
/*!
|
||||
@brief Encode TIFF metadata from the metadata containers into a
|
||||
@@ -282,10 +282,9 @@ namespace Exiv2::Internal {
|
||||
writing"). If there is a parsed tree, it is only used to access the
|
||||
image data in this case.
|
||||
*/
|
||||
static WriteMethod encode(
|
||||
BasicIo& io,
|
||||
static WriteMethod encode(BasicIo& io,
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
const ExifData& exifData,
|
||||
const IptcData& iptcData,
|
||||
const XmpData& xmpData,
|
||||
@@ -311,7 +310,7 @@ namespace Exiv2::Internal {
|
||||
*/
|
||||
static std::unique_ptr<TiffComponent> parse(
|
||||
const byte* pData,
|
||||
uint32_t size,
|
||||
size_t size,
|
||||
uint32_t root,
|
||||
TiffHeaderBase* pHeader
|
||||
);
|
||||
|
||||
+17
-21
@@ -317,7 +317,7 @@ namespace Exiv2::Internal {
|
||||
}
|
||||
|
||||
void TiffDecoder::getObjData(byte const*& pData,
|
||||
long& size,
|
||||
size_t &size,
|
||||
uint16_t tag,
|
||||
IfdId group,
|
||||
const TiffEntryBase* object)
|
||||
@@ -343,7 +343,7 @@ namespace Exiv2::Internal {
|
||||
decodeStdTiffEntry(object);
|
||||
|
||||
byte const* pData = nullptr;
|
||||
long size = 0;
|
||||
size_t size = 0;
|
||||
getObjData(pData, size, 0x02bc, ifd0Id, object);
|
||||
if (pData) {
|
||||
std::string xmpPacket;
|
||||
@@ -377,10 +377,10 @@ namespace Exiv2::Internal {
|
||||
decodedIptc_ = true;
|
||||
// 1st choice: IPTCNAA
|
||||
byte const* pData = nullptr;
|
||||
long size = 0;
|
||||
size_t size = 0;
|
||||
getObjData(pData, size, 0x83bb, ifd0Id, object);
|
||||
if (pData) {
|
||||
if (0 == IptcParser::decode(iptcData_, pData, size)) {
|
||||
if (0 == IptcParser::decode(iptcData_, pData, static_cast<uint32_t>(size))) {
|
||||
return;
|
||||
}
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
@@ -705,7 +705,7 @@ namespace Exiv2::Internal {
|
||||
auto pTiffEntry = dynamic_cast<TiffEntryBase*>(pTiffComponent);
|
||||
assert(pTiffEntry);
|
||||
us2Data(buf + 2, pTiffEntry->tiffType(), byteOrder);
|
||||
ul2Data(buf + 4, pTiffEntry->count(), byteOrder);
|
||||
ul2Data(buf + 4, static_cast<uint32_t>(pTiffEntry->count()), byteOrder);
|
||||
// Move data to offset field, if it fits and is not yet there.
|
||||
if (pTiffEntry->size() <= 4 && buf + 8 != pTiffEntry->pData()) {
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
@@ -789,7 +789,7 @@ namespace Exiv2::Internal {
|
||||
|
||||
if (!object->cfg() || !object->decoded())
|
||||
return;
|
||||
int32_t size = object->TiffEntryBase::doSize();
|
||||
size_t size = object->TiffEntryBase::doSize();
|
||||
if (size == 0)
|
||||
return;
|
||||
if (!object->initialize(pRoot_))
|
||||
@@ -1031,7 +1031,7 @@ namespace Exiv2::Internal {
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
bool tooLarge = false;
|
||||
#endif
|
||||
uint32_t newSize = datum->size();
|
||||
size_t newSize = datum->size();
|
||||
if (newSize > object->size_) { // value doesn't fit, encode for intrusive writing
|
||||
setDirty();
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
@@ -1046,14 +1046,14 @@ namespace Exiv2::Internal {
|
||||
std::cerr << "\t\t\t ALLOCATED " << std::dec << object->size_ << " BYTES";
|
||||
}
|
||||
#endif
|
||||
} // TiffEncoder::encodeTiffEntryBase
|
||||
}
|
||||
|
||||
void TiffEncoder::encodeOffsetEntry(TiffEntryBase* object, const Exifdatum* datum)
|
||||
{
|
||||
assert(object);
|
||||
assert(datum);
|
||||
|
||||
uint32_t newSize = datum->size();
|
||||
size_t newSize = datum->size();
|
||||
if (newSize > object->size_) { // value doesn't fit, encode for intrusive writing
|
||||
setDirty();
|
||||
object->updateValue(datum->getValue(), byteOrder()); // clones the value
|
||||
@@ -1071,8 +1071,7 @@ namespace Exiv2::Internal {
|
||||
std::cerr << "\t\t\t PRESERVE VALUE DATA";
|
||||
#endif
|
||||
}
|
||||
|
||||
} // TiffEncoder::encodeOffsetEntry
|
||||
}
|
||||
|
||||
void TiffEncoder::add(
|
||||
TiffComponent* pRootDir,
|
||||
@@ -1147,10 +1146,7 @@ namespace Exiv2::Internal {
|
||||
|
||||
} // TiffEncoder::add
|
||||
|
||||
TiffReader::TiffReader(const byte* pData,
|
||||
uint32_t size,
|
||||
TiffComponent* pRoot,
|
||||
TiffRwState state)
|
||||
TiffReader::TiffReader(const byte* pData, size_t size, TiffComponent* pRoot, TiffRwState state)
|
||||
: pData_(pData),
|
||||
size_(size),
|
||||
pLast_(pData + size),
|
||||
@@ -1623,7 +1619,7 @@ namespace Exiv2::Internal {
|
||||
const CryptFct cryptFct = cfg->cryptFct_;
|
||||
if (cryptFct) {
|
||||
const byte* pData = object->pData();
|
||||
int32_t size = object->TiffEntryBase::doSize();
|
||||
size_t size = object->TiffEntryBase::doSize();
|
||||
auto buf = std::make_shared<DataBuf>(cryptFct(object->tag(), pData, size, pRoot_));
|
||||
if (!buf->empty())
|
||||
object->setData(buf);
|
||||
@@ -1647,7 +1643,7 @@ namespace Exiv2::Internal {
|
||||
gapSize = xdef->idx_ - idx;
|
||||
}
|
||||
else {
|
||||
gapSize = object->TiffEntryBase::doSize() - idx;
|
||||
gapSize = static_cast<uint32_t>(object->TiffEntryBase::doSize()) - idx;
|
||||
}
|
||||
gap.idx_ = idx;
|
||||
gap.tiffType_ = cfg->elDefaultDef_.tiffType_;
|
||||
@@ -1671,9 +1667,10 @@ namespace Exiv2::Internal {
|
||||
void TiffReader::visitBinaryElement(TiffBinaryElement* object)
|
||||
{
|
||||
byte* pData = object->start();
|
||||
uint32_t size = object->TiffEntryBase::doSize();
|
||||
size_t size = object->TiffEntryBase::doSize();
|
||||
ByteOrder bo = object->elByteOrder();
|
||||
if (bo == invalidByteOrder) bo = byteOrder();
|
||||
if (bo == invalidByteOrder)
|
||||
bo = byteOrder();
|
||||
TypeId typeId = toTypeId(object->elDef()->tiffType_, object->tag(), object->group());
|
||||
auto v = Value::create(typeId);
|
||||
enforce(v != nullptr, ErrorCode::kerCorruptedMetadata);
|
||||
@@ -1682,7 +1679,6 @@ namespace Exiv2::Internal {
|
||||
object->setValue(std::move(v));
|
||||
object->setOffset(0);
|
||||
object->setIdx(nextIdx(object->group()));
|
||||
|
||||
} // TiffReader::visitBinaryElement
|
||||
}
|
||||
|
||||
} // namespace Exiv2::Internal
|
||||
|
||||
@@ -317,7 +317,7 @@ namespace Exiv2 {
|
||||
element is found the function leaves both of these parameters unchanged.
|
||||
*/
|
||||
void getObjData(byte const*& pData,
|
||||
long& size,
|
||||
size_t& size,
|
||||
uint16_t tag,
|
||||
IfdId group,
|
||||
const TiffEntryBase* object);
|
||||
@@ -595,10 +595,7 @@ namespace Exiv2 {
|
||||
@param state State object for creation function, byte order and
|
||||
base offset.
|
||||
*/
|
||||
TiffReader(const byte* pData,
|
||||
uint32_t size,
|
||||
TiffComponent* pRoot,
|
||||
TiffRwState state);
|
||||
TiffReader(const byte* pData, size_t size, TiffComponent* pRoot, TiffRwState state);
|
||||
|
||||
//! Virtual destructor
|
||||
~TiffReader() override = default;
|
||||
@@ -674,7 +671,7 @@ namespace Exiv2 {
|
||||
|
||||
// DATA
|
||||
const byte* pData_; //!< Pointer to the memory buffer
|
||||
const uint32_t size_; //!< Size of the buffer
|
||||
const size_t size_; //!< Size of the buffer
|
||||
const byte* pLast_; //!< Pointer to the last byte
|
||||
TiffComponent* const pRoot_; //!< Root element of the composite
|
||||
TiffRwState* pState_; //!< Pointer to the state in effect (origState_ or mnState_)
|
||||
|
||||
+1
-3
@@ -544,9 +544,7 @@ namespace Exiv2 {
|
||||
|
||||
size_t i = 0;
|
||||
while (i < len) {
|
||||
os << " "
|
||||
<< std::setw(4) << std::setfill('0') << std::hex
|
||||
<< i + offset << " ";
|
||||
os << " " << std::setw(4) << std::setfill('0') << std::hex << i + offset << " ";
|
||||
std::ostringstream ss;
|
||||
do {
|
||||
byte c = buf[i];
|
||||
|
||||
+19
-22
@@ -125,8 +125,7 @@ namespace Exiv2 {
|
||||
{
|
||||
}
|
||||
|
||||
DataValue::DataValue(const byte* buf,
|
||||
long len, ByteOrder byteOrder,TypeId typeId)
|
||||
DataValue::DataValue(const byte* buf, size_t len, ByteOrder byteOrder, TypeId typeId)
|
||||
: Value(typeId)
|
||||
{
|
||||
read(buf, len, byteOrder);
|
||||
@@ -158,10 +157,10 @@ namespace Exiv2 {
|
||||
return 0;
|
||||
}
|
||||
|
||||
long DataValue::copy(byte* buf, ByteOrder /*byteOrder*/) const
|
||||
size_t DataValue::copy(byte* buf, ByteOrder /*byteOrder*/) const
|
||||
{
|
||||
// byteOrder not needed
|
||||
return static_cast<long>(std::copy(value_.begin(), value_.end(), buf) - buf);
|
||||
return std::copy(value_.begin(), value_.end(), buf) - buf;
|
||||
}
|
||||
|
||||
size_t DataValue::size() const
|
||||
@@ -248,15 +247,13 @@ namespace Exiv2 {
|
||||
return 0;
|
||||
}
|
||||
|
||||
long StringValueBase::copy(byte* buf, ByteOrder /*byteOrder*/) const
|
||||
size_t StringValueBase::copy(byte* buf, ByteOrder /*byteOrder*/) const
|
||||
{
|
||||
if (value_.empty())
|
||||
return 0;
|
||||
// byteOrder not needed
|
||||
assert(buf);
|
||||
return static_cast<long>(
|
||||
value_.copy(reinterpret_cast<char*>(buf), value_.size())
|
||||
);
|
||||
return value_.copy(reinterpret_cast<char*>(buf), value_.size());
|
||||
}
|
||||
|
||||
size_t StringValueBase::count() const
|
||||
@@ -438,7 +435,7 @@ namespace Exiv2 {
|
||||
return StringValueBase::read(buf, len, byteOrder);
|
||||
}
|
||||
|
||||
long CommentValue::copy(byte* buf, ByteOrder byteOrder) const
|
||||
size_t CommentValue::copy(byte* buf, ByteOrder byteOrder) const
|
||||
{
|
||||
std::string c = value_;
|
||||
if (charsetId() == unicode) {
|
||||
@@ -457,7 +454,7 @@ namespace Exiv2 {
|
||||
if (c.empty())
|
||||
return 0;
|
||||
assert(buf);
|
||||
return static_cast<long>(c.copy(reinterpret_cast<char*>(buf), c.size()));
|
||||
return c.copy(reinterpret_cast<char*>(buf), c.size());
|
||||
}
|
||||
|
||||
std::ostream& CommentValue::write(std::ostream& os) const
|
||||
@@ -563,15 +560,14 @@ namespace Exiv2 {
|
||||
return xmpStruct_;
|
||||
}
|
||||
|
||||
long XmpValue::copy(byte* buf,
|
||||
ByteOrder /*byteOrder*/) const
|
||||
size_t XmpValue::copy(byte* buf, ByteOrder /*byteOrder*/) const
|
||||
{
|
||||
std::ostringstream os;
|
||||
write(os);
|
||||
std::string s = os.str();
|
||||
if (!s.empty())
|
||||
std::memcpy(buf, &s[0], s.size());
|
||||
return static_cast<long>(s.size());
|
||||
return s.size();
|
||||
}
|
||||
|
||||
int XmpValue::read(const byte* buf, size_t len, ByteOrder /*byteOrder*/)
|
||||
@@ -953,14 +949,15 @@ namespace Exiv2 {
|
||||
date_.day = src.day;
|
||||
}
|
||||
|
||||
long DateValue::copy(byte* buf, ByteOrder /*byteOrder*/) const
|
||||
size_t DateValue::copy(byte* buf, ByteOrder /*byteOrder*/) const
|
||||
{
|
||||
// \note Here the date is copied in the Basic format YYYYMMDD, as the IPTC key Iptc.Application2.DateCreated
|
||||
// wants it. Check https://exiv2.org/iptc.html
|
||||
|
||||
// sprintf wants to add the null terminator, so use oversized buffer
|
||||
char temp[9];
|
||||
int wrote = snprintf(temp, sizeof(temp), "%04d%02d%02d", date_.year, date_.month, date_.day);
|
||||
size_t wrote =
|
||||
static_cast<size_t>(snprintf(temp, sizeof(temp), "%04d%02d%02d", date_.year, date_.month, date_.day));
|
||||
assert(wrote == 8);
|
||||
std::memcpy(buf, temp, wrote);
|
||||
return wrote;
|
||||
@@ -1101,19 +1098,19 @@ namespace Exiv2 {
|
||||
std::memcpy(&time_, &src, sizeof(time_));
|
||||
}
|
||||
|
||||
long TimeValue::copy(byte* buf, ByteOrder /*byteOrder*/) const
|
||||
size_t TimeValue::copy(byte* buf, ByteOrder /*byteOrder*/) const
|
||||
{
|
||||
// NOTE: Here the time is copied in the Basic format HHMMSS:HHMM, as the IPTC key Iptc.Application2.TimeCreated
|
||||
// wants it. Check https://exiv2.org/iptc.html
|
||||
// NOTE: Here the time is copied in the Basic format HHMMSS:HHMM, as the IPTC key
|
||||
// Iptc.Application2.TimeCreated wants it. Check https://exiv2.org/iptc.html
|
||||
char temp[12];
|
||||
char plusMinus = '+';
|
||||
if (time_.tzHour < 0 || time_.tzMinute < 0)
|
||||
plusMinus = '-';
|
||||
|
||||
const int wrote = snprintf(temp, sizeof(temp), // 11 bytes are written + \0
|
||||
"%02d%02d%02d%1c%02d%02d",
|
||||
time_.hour, time_.minute, time_.second,
|
||||
plusMinus, abs(time_.tzHour), abs(time_.tzMinute));
|
||||
const auto wrote =
|
||||
static_cast<size_t>(snprintf(temp, sizeof(temp), // 11 bytes are written + \0
|
||||
"%02d%02d%02d%1c%02d%02d", time_.hour, time_.minute, time_.second, plusMinus,
|
||||
abs(time_.tzHour), abs(time_.tzMinute)));
|
||||
|
||||
enforce(wrote == 11, Exiv2::ErrorCode::kerUnsupportedTimeFormat);
|
||||
std::memcpy(buf, temp, wrote);
|
||||
|
||||
+7
-7
@@ -345,24 +345,24 @@ namespace Exiv2 {
|
||||
return TypeInfo::typeName(typeId());
|
||||
}
|
||||
|
||||
long Xmpdatum::typeSize() const
|
||||
size_t Xmpdatum::typeSize() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t Xmpdatum::count() const { return p_->value_ ? p_->value_->count() : 0; }
|
||||
|
||||
long Xmpdatum::size() const { return p_->value_ ? static_cast<long>(p_->value_->size()) : 0; }
|
||||
size_t Xmpdatum::size() const { return p_->value_ ? p_->value_->size() : 0; }
|
||||
|
||||
std::string Xmpdatum::toString() const { return p_->value_ ? p_->value_->toString() : ""; }
|
||||
|
||||
std::string Xmpdatum::toString(long n) const { return p_->value_ ? p_->value_->toString(n) : ""; }
|
||||
std::string Xmpdatum::toString(size_t n) const { return p_->value_ ? p_->value_->toString(n) : ""; }
|
||||
|
||||
int64_t Xmpdatum::toInt64(long n) const { return p_->value_ ? p_->value_->toInt64(n) : -1; }
|
||||
int64_t Xmpdatum::toInt64(size_t n) const { return p_->value_ ? p_->value_->toInt64(n) : -1; }
|
||||
|
||||
float Xmpdatum::toFloat(long n) const { return p_->value_ ? p_->value_->toFloat(n) : -1; }
|
||||
float Xmpdatum::toFloat(size_t n) const { return p_->value_ ? p_->value_->toFloat(n) : -1; }
|
||||
|
||||
Rational Xmpdatum::toRational(long n) const { return p_->value_ ? p_->value_->toRational(n) : Rational(-1, 1); }
|
||||
Rational Xmpdatum::toRational(size_t n) const { return p_->value_ ? p_->value_->toRational(n) : Rational(-1, 1); }
|
||||
|
||||
Value::UniquePtr Xmpdatum::getValue() const { return p_->value_ ? p_->value_->clone() : nullptr; }
|
||||
|
||||
@@ -373,7 +373,7 @@ namespace Exiv2 {
|
||||
return *p_->value_;
|
||||
}
|
||||
|
||||
long Xmpdatum::copy(byte* /*buf*/, ByteOrder /*byteOrder*/) const
|
||||
size_t Xmpdatum::copy(byte* /*buf*/, ByteOrder /*byteOrder*/) const
|
||||
{
|
||||
throw Error(ErrorCode::kerFunctionNotSupported, "Xmpdatum::copy");
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user