Use size_t for sizes and offsets.
This commit is contained in:
parent
c96bc47509
commit
abd817d181
@ -1228,7 +1228,7 @@ void Converter::cnvXmpValueToIptc(const char* from, const char* to) {
|
||||
size_t count = pos->count();
|
||||
bool added = false;
|
||||
for (size_t i = 0; i < 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,6 +9,7 @@
|
||||
|
||||
#include "ini.hpp"
|
||||
#include "makernote_int.hpp"
|
||||
#include "safe_op.hpp"
|
||||
#include "tiffcomposite_int.hpp"
|
||||
#include "tiffimage_int.hpp"
|
||||
#include "tiffvisitor_int.hpp"
|
||||
@ -160,7 +161,7 @@ ByteOrder MnHeader::byteOrder() const {
|
||||
return invalidByteOrder;
|
||||
}
|
||||
|
||||
uint32_t MnHeader::baseOffset(uint32_t /*mnOffset*/) const {
|
||||
size_t MnHeader::baseOffset(size_t /*mnOffset*/) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -213,7 +214,7 @@ size_t Olympus2MnHeader::ifdOffset() const {
|
||||
return sizeOfSignature();
|
||||
}
|
||||
|
||||
uint32_t Olympus2MnHeader::baseOffset(uint32_t mnOffset) const {
|
||||
size_t Olympus2MnHeader::baseOffset(size_t mnOffset) const {
|
||||
return mnOffset;
|
||||
}
|
||||
|
||||
@ -249,7 +250,7 @@ size_t OMSystemMnHeader::ifdOffset() const {
|
||||
return sizeOfSignature();
|
||||
}
|
||||
|
||||
uint32_t OMSystemMnHeader::baseOffset(uint32_t mnOffset) const {
|
||||
size_t OMSystemMnHeader::baseOffset(size_t mnOffset) const {
|
||||
return mnOffset;
|
||||
}
|
||||
|
||||
@ -289,7 +290,7 @@ ByteOrder FujiMnHeader::byteOrder() const {
|
||||
return byteOrder_;
|
||||
}
|
||||
|
||||
uint32_t FujiMnHeader::baseOffset(uint32_t mnOffset) const {
|
||||
size_t FujiMnHeader::baseOffset(size_t mnOffset) const {
|
||||
return mnOffset;
|
||||
}
|
||||
|
||||
@ -367,8 +368,8 @@ ByteOrder Nikon3MnHeader::byteOrder() const {
|
||||
return byteOrder_;
|
||||
}
|
||||
|
||||
uint32_t Nikon3MnHeader::baseOffset(uint32_t mnOffset) const {
|
||||
return mnOffset + 10;
|
||||
size_t Nikon3MnHeader::baseOffset(size_t mnOffset) const {
|
||||
return Safe::add<size_t>(mnOffset, 10);
|
||||
}
|
||||
|
||||
bool Nikon3MnHeader::read(const byte* pData, size_t size, ByteOrder /*byteOrder*/) {
|
||||
@ -447,7 +448,7 @@ size_t PentaxDngMnHeader::size() const {
|
||||
return header_.size();
|
||||
}
|
||||
|
||||
uint32_t PentaxDngMnHeader::baseOffset(uint32_t mnOffset) const {
|
||||
size_t PentaxDngMnHeader::baseOffset(size_t mnOffset) const {
|
||||
return mnOffset;
|
||||
}
|
||||
|
||||
@ -507,7 +508,7 @@ size_t SamsungMnHeader::size() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t SamsungMnHeader::baseOffset(uint32_t mnOffset) const {
|
||||
size_t SamsungMnHeader::baseOffset(size_t mnOffset) const {
|
||||
return mnOffset;
|
||||
}
|
||||
|
||||
|
||||
@ -127,7 +127,7 @@ class MnHeader {
|
||||
to the start of the TIFF header. \em mnOffset is the offset
|
||||
to the makernote from the start of the TIFF header.
|
||||
*/
|
||||
[[nodiscard]] virtual uint32_t baseOffset(uint32_t mnOffset) const;
|
||||
[[nodiscard]] virtual size_t baseOffset(size_t mnOffset) const;
|
||||
//@}
|
||||
|
||||
}; // class MnHeader
|
||||
@ -180,7 +180,7 @@ class Olympus2MnHeader : public MnHeader {
|
||||
[[nodiscard]] size_t size() const override;
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
[[nodiscard]] size_t ifdOffset() const override;
|
||||
[[nodiscard]] uint32_t baseOffset(uint32_t mnOffset) const override;
|
||||
[[nodiscard]] size_t baseOffset(size_t mnOffset) const override;
|
||||
//@}
|
||||
//! Return the size of the makernote header signature
|
||||
static size_t sizeOfSignature();
|
||||
@ -210,7 +210,7 @@ class OMSystemMnHeader : public MnHeader {
|
||||
[[nodiscard]] size_t size() const override;
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
[[nodiscard]] size_t ifdOffset() const override;
|
||||
[[nodiscard]] uint32_t baseOffset(uint32_t mnOffset) const override;
|
||||
[[nodiscard]] size_t baseOffset(size_t mnOffset) const override;
|
||||
//@}
|
||||
//! Return the size of the makernote header signature
|
||||
static size_t sizeOfSignature();
|
||||
@ -242,7 +242,7 @@ class FujiMnHeader : public MnHeader {
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
[[nodiscard]] size_t ifdOffset() const override;
|
||||
[[nodiscard]] ByteOrder byteOrder() const override;
|
||||
[[nodiscard]] uint32_t baseOffset(uint32_t mnOffset) const override;
|
||||
[[nodiscard]] size_t baseOffset(size_t mnOffset) const override;
|
||||
//@}
|
||||
//! Return the size of the makernote header signature
|
||||
static size_t sizeOfSignature();
|
||||
@ -251,7 +251,7 @@ class FujiMnHeader : public MnHeader {
|
||||
DataBuf header_; //!< Data buffer for the makernote header
|
||||
static const byte signature_[]; //!< Fujifilm makernote header signature
|
||||
static const ByteOrder byteOrder_; //!< Byteorder for makernote (always II)
|
||||
uint32_t start_{0}; //!< Start of the mn IFD rel. to mn start
|
||||
size_t start_{0}; //!< Start of the mn IFD rel. to mn start
|
||||
|
||||
}; // class FujiMnHeader
|
||||
|
||||
@ -306,7 +306,7 @@ class Nikon3MnHeader : public MnHeader {
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
[[nodiscard]] size_t ifdOffset() const override;
|
||||
[[nodiscard]] ByteOrder byteOrder() const override;
|
||||
[[nodiscard]] uint32_t baseOffset(uint32_t mnOffset) const override;
|
||||
[[nodiscard]] size_t baseOffset(size_t mnOffset) const override;
|
||||
//@}
|
||||
//! Return the size of the makernote header signature
|
||||
static size_t sizeOfSignature();
|
||||
@ -368,7 +368,7 @@ class PentaxDngMnHeader : public MnHeader {
|
||||
[[nodiscard]] size_t size() const override;
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
[[nodiscard]] size_t ifdOffset() const override;
|
||||
[[nodiscard]] uint32_t baseOffset(uint32_t mnOffset) const override;
|
||||
[[nodiscard]] size_t baseOffset(size_t mnOffset) const override;
|
||||
//@}
|
||||
//! Return the size of the makernote header signature
|
||||
static size_t sizeOfSignature();
|
||||
@ -424,7 +424,7 @@ class SamsungMnHeader : public MnHeader {
|
||||
//@{
|
||||
[[nodiscard]] size_t size() const override;
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
[[nodiscard]] uint32_t baseOffset(uint32_t mnOffset) const override;
|
||||
[[nodiscard]] size_t baseOffset(size_t mnOffset) const override;
|
||||
//@}
|
||||
|
||||
}; // class SamsungMnHeader
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
// *****************************************************************************
|
||||
namespace {
|
||||
//! Add \em tobe - \em curr 0x00 filler bytes if necessary
|
||||
uint32_t fillGap(Exiv2::Internal::IoWrapper& ioWrapper, uint32_t curr, uint32_t tobe);
|
||||
size_t fillGap(Exiv2::Internal::IoWrapper& ioWrapper, size_t curr, size_t tobe);
|
||||
} // namespace
|
||||
|
||||
// *****************************************************************************
|
||||
@ -79,11 +79,11 @@ TiffIfdMakernote::TiffIfdMakernote(uint16_t tag, IfdId group, IfdId mnGroup, MnH
|
||||
}
|
||||
|
||||
TiffBinaryArray::TiffBinaryArray(uint16_t tag, IfdId group, const ArrayCfg& arrayCfg, const ArrayDef* arrayDef,
|
||||
int defSize) :
|
||||
size_t defSize) :
|
||||
TiffEntryBase(tag, group, arrayCfg.elTiffType_), arrayCfg_(&arrayCfg), arrayDef_(arrayDef), defSize_(defSize) {
|
||||
}
|
||||
|
||||
TiffBinaryArray::TiffBinaryArray(uint16_t tag, IfdId group, const ArraySet* arraySet, int setSize,
|
||||
TiffBinaryArray::TiffBinaryArray(uint16_t tag, IfdId group, const ArraySet* arraySet, size_t setSize,
|
||||
CfgSelFct cfgSelFct) :
|
||||
TiffEntryBase(tag, group), // Todo: Does it make a difference that there is no type?
|
||||
cfgSelFct_(cfgSelFct),
|
||||
@ -249,7 +249,7 @@ void TiffEntryBase::setValue(Value::UniquePtr value) {
|
||||
pValue_ = value.release();
|
||||
}
|
||||
|
||||
void TiffDataEntry::setStrips(const Value* pSize, const byte* pData, size_t sizeData, uint32_t baseOffset) {
|
||||
void TiffDataEntry::setStrips(const Value* pSize, const byte* pData, size_t sizeData, size_t baseOffset) {
|
||||
if (!pValue() || !pSize) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
EXV_WARNING << "Directory " << groupName(group()) << ", entry 0x" << std::setw(4) << std::setfill('0') << std::hex
|
||||
@ -298,7 +298,7 @@ void TiffDataEntry::setStrips(const Value* pSize, const byte* pData, size_t size
|
||||
const_cast<Value*>(pValue())->setDataArea(pDataArea_, sizeDataArea_);
|
||||
} // TiffDataEntry::setStrips
|
||||
|
||||
void TiffImageEntry::setStrips(const Value* pSize, const byte* pData, size_t sizeData, uint32_t baseOffset) {
|
||||
void TiffImageEntry::setStrips(const Value* pSize, const byte* pData, size_t sizeData, size_t baseOffset) {
|
||||
if (!pValue() || !pSize) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
EXV_WARNING << "Directory " << groupName(group()) << ", entry 0x" << std::setw(4) << std::setfill('0') << std::hex
|
||||
@ -343,11 +343,11 @@ ByteOrder TiffIfdMakernote::byteOrder() const {
|
||||
return pHeader_->byteOrder();
|
||||
}
|
||||
|
||||
uint32_t TiffIfdMakernote::mnOffset() const {
|
||||
size_t TiffIfdMakernote::mnOffset() const {
|
||||
return mnOffset_;
|
||||
}
|
||||
|
||||
uint32_t TiffIfdMakernote::baseOffset() const {
|
||||
size_t TiffIfdMakernote::baseOffset() const {
|
||||
if (!pHeader_)
|
||||
return 0;
|
||||
return pHeader_->baseOffset(mnOffset_);
|
||||
@ -376,20 +376,20 @@ size_t TiffIfdMakernote::writeHeader(IoWrapper& ioWrapper, ByteOrder byteOrder)
|
||||
return pHeader_->write(ioWrapper, byteOrder);
|
||||
}
|
||||
|
||||
uint32_t ArrayDef::size(uint16_t tag, IfdId group) const {
|
||||
size_t ArrayDef::size(uint16_t tag, IfdId group) const {
|
||||
TypeId typeId = toTypeId(tiffType_, tag, group);
|
||||
return static_cast<uint32_t>(count_ * TypeInfo::typeSize(typeId));
|
||||
return count_ * TypeInfo::typeSize(typeId);
|
||||
}
|
||||
|
||||
bool TiffBinaryArray::initialize(IfdId group) {
|
||||
if (arrayCfg_)
|
||||
return true; // Not a complex array or already initialized
|
||||
|
||||
for (int idx = 0; idx < setSize_; ++idx) {
|
||||
for (size_t idx = 0; idx < setSize_; ++idx) {
|
||||
if (arraySet_[idx].cfg_.group_ == group) {
|
||||
arrayCfg_ = &arraySet_[idx].cfg_;
|
||||
arrayDef_ = arraySet_[idx].def_;
|
||||
defSize_ = static_cast<int>(arraySet_[idx].defSize_);
|
||||
defSize_ = arraySet_[idx].defSize_;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -404,7 +404,7 @@ bool TiffBinaryArray::initialize(TiffComponent* pRoot) {
|
||||
if (idx > -1) {
|
||||
arrayCfg_ = &arraySet_[idx].cfg_;
|
||||
arrayDef_ = arraySet_[idx].def_;
|
||||
defSize_ = static_cast<int>(arraySet_[idx].defSize_);
|
||||
defSize_ = arraySet_[idx].defSize_;
|
||||
}
|
||||
return idx > -1;
|
||||
}
|
||||
@ -423,9 +423,9 @@ bool TiffBinaryArray::updOrigDataBuf(const byte* pData, size_t size) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t TiffBinaryArray::addElement(uint32_t idx, const ArrayDef& def) {
|
||||
size_t TiffBinaryArray::addElement(size_t idx, const ArrayDef& def) {
|
||||
auto tag = static_cast<uint16_t>(idx / cfg()->tagStep());
|
||||
int32_t sz = std::min(def.size(tag, cfg()->group_), static_cast<uint32_t>(TiffEntryBase::doSize()) - idx);
|
||||
size_t sz = std::min(def.size(tag, cfg()->group_), 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
|
||||
@ -821,14 +821,14 @@ size_t TiffBinaryElement::doCount() const {
|
||||
return elDef_.count_;
|
||||
}
|
||||
|
||||
uint32_t TiffComponent::write(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t valueIdx,
|
||||
uint32_t dataIdx, uint32_t& imageIdx) {
|
||||
size_t TiffComponent::write(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t valueIdx, size_t dataIdx,
|
||||
size_t& imageIdx) {
|
||||
return doWrite(ioWrapper, byteOrder, offset, valueIdx, dataIdx, imageIdx);
|
||||
} // TiffComponent::write
|
||||
|
||||
uint32_t TiffDirectory::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t valueIdx,
|
||||
uint32_t dataIdx, uint32_t& imageIdx) {
|
||||
bool isRootDir = (imageIdx == static_cast<uint32_t>(-1));
|
||||
size_t TiffDirectory::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t valueIdx, size_t dataIdx,
|
||||
size_t& imageIdx) {
|
||||
bool isRootDir = (imageIdx == std::string::npos);
|
||||
|
||||
// Number of components to write
|
||||
const size_t compCount = count();
|
||||
@ -861,27 +861,27 @@ uint32_t TiffDirectory::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_
|
||||
std::sort(components_.begin(), components_.end(), cmpTagLt);
|
||||
}
|
||||
// Size of IFD values and additional data
|
||||
uint32_t sizeValue = 0;
|
||||
uint32_t sizeData = 0;
|
||||
size_t sizeValue = 0;
|
||||
size_t sizeData = 0;
|
||||
for (auto&& component : components_) {
|
||||
size_t sv = component->size();
|
||||
if (sv > 4) {
|
||||
sv += sv & 1; // Align value to word boundary
|
||||
sizeValue += static_cast<uint32_t>(sv);
|
||||
sizeValue += sv;
|
||||
}
|
||||
// Also add the size of data, but only if needed
|
||||
if (isRootDir) {
|
||||
auto sd = static_cast<uint32_t>(component->sizeData());
|
||||
auto sd = component->sizeData();
|
||||
sd += sd & 1; // Align data to word boundary
|
||||
sizeData += sd;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
size_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
|
||||
imageIdx = offset + dataIdx + sizeData + sizeNext;
|
||||
imageIdx += imageIdx & 1; // Align image data to word boundary
|
||||
}
|
||||
|
||||
@ -896,9 +896,9 @@ uint32_t TiffDirectory::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_
|
||||
size_t sv = component->size();
|
||||
if (sv > 4) {
|
||||
sv += sv & 1; // Align value to word boundary
|
||||
valueIdx += static_cast<uint32_t>(sv);
|
||||
valueIdx += sv;
|
||||
}
|
||||
auto sd = static_cast<uint32_t>(component->sizeData());
|
||||
auto sd = component->sizeData();
|
||||
sd += sd & 1; // Align data to word boundary
|
||||
dataIdx += sd;
|
||||
}
|
||||
@ -913,33 +913,32 @@ uint32_t TiffDirectory::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_
|
||||
}
|
||||
|
||||
// 2nd: Write IFD values - may contain pointers to additional data
|
||||
valueIdx = static_cast<uint32_t>(sizeDir);
|
||||
dataIdx = static_cast<uint32_t>(sizeDir + sizeValue);
|
||||
valueIdx = sizeDir;
|
||||
dataIdx = sizeDir + sizeValue;
|
||||
for (auto&& component : components_) {
|
||||
size_t sv = component->size();
|
||||
if (sv > 4) {
|
||||
uint32_t d = component->write(ioWrapper, byteOrder, offset, valueIdx, dataIdx, imageIdx);
|
||||
size_t d = component->write(ioWrapper, byteOrder, offset, valueIdx, dataIdx, imageIdx);
|
||||
enforce(sv == d, ErrorCode::kerImageWriteFailed);
|
||||
if ((sv & 1) == 1) {
|
||||
ioWrapper.putb(0x0); // Align value to word boundary
|
||||
sv += 1;
|
||||
}
|
||||
idx += sv;
|
||||
valueIdx += static_cast<uint32_t>(sv);
|
||||
valueIdx += sv;
|
||||
}
|
||||
auto sd = static_cast<uint32_t>(component->sizeData());
|
||||
auto sd = component->sizeData();
|
||||
sd += sd & 1; // Align data to word boundary
|
||||
dataIdx += sd;
|
||||
}
|
||||
|
||||
// 3rd: Write data - may contain offsets too (eg sub-IFD)
|
||||
dataIdx = static_cast<uint32_t>(sizeDir + sizeValue);
|
||||
dataIdx = sizeDir + sizeValue;
|
||||
idx += writeData(ioWrapper, byteOrder, offset, dataIdx, imageIdx);
|
||||
|
||||
// 4th: Write next-IFD
|
||||
if (pNext_ && sizeNext) {
|
||||
idx += pNext_->write(ioWrapper, byteOrder, offset + idx, static_cast<uint32_t>(-1), static_cast<uint32_t>(-1),
|
||||
imageIdx);
|
||||
idx += pNext_->write(ioWrapper, byteOrder, offset + idx, std::string::npos, std::string::npos, imageIdx);
|
||||
}
|
||||
|
||||
// 5th, at the root directory level only: write image data
|
||||
@ -947,12 +946,11 @@ uint32_t TiffDirectory::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_
|
||||
idx += writeImage(ioWrapper, byteOrder);
|
||||
}
|
||||
|
||||
return static_cast<uint32_t>(idx);
|
||||
return idx;
|
||||
}
|
||||
|
||||
uint32_t TiffDirectory::writeDirEntry(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset,
|
||||
TiffComponent* pTiffComponent, uint32_t valueIdx, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) {
|
||||
size_t TiffDirectory::writeDirEntry(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset,
|
||||
TiffComponent* pTiffComponent, size_t valueIdx, size_t dataIdx, size_t& imageIdx) {
|
||||
auto pDirEntry = dynamic_cast<TiffEntryBase*>(pTiffComponent);
|
||||
byte buf[8];
|
||||
us2Data(buf, pDirEntry->tag(), byteOrder);
|
||||
@ -964,7 +962,7 @@ uint32_t TiffDirectory::writeDirEntry(IoWrapper& ioWrapper, ByteOrder byteOrder,
|
||||
ul2Data(buf, static_cast<uint32_t>(pDirEntry->offset()), byteOrder);
|
||||
ioWrapper.write(buf, 4);
|
||||
} else {
|
||||
const uint32_t len = pDirEntry->write(ioWrapper, byteOrder, offset, valueIdx, dataIdx, imageIdx);
|
||||
const size_t len = pDirEntry->write(ioWrapper, byteOrder, offset, valueIdx, dataIdx, imageIdx);
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
if (len > 4) {
|
||||
EXV_ERROR << "Unexpected length in TiffDirectory::writeDirEntry(): len == " << len << ".\n";
|
||||
@ -978,29 +976,29 @@ uint32_t TiffDirectory::writeDirEntry(IoWrapper& ioWrapper, ByteOrder byteOrder,
|
||||
return 12;
|
||||
} // TiffDirectory::writeDirEntry
|
||||
|
||||
uint32_t TiffEntryBase::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t /*offset*/, uint32_t /*valueIdx*/,
|
||||
uint32_t /*dataIdx*/, uint32_t& /*imageIdx*/) {
|
||||
size_t TiffEntryBase::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t /*offset*/, size_t /*valueIdx*/,
|
||||
size_t /*dataIdx*/, size_t& /*imageIdx*/) {
|
||||
if (!pValue_ || pValue_->size() == 0)
|
||||
return 0;
|
||||
|
||||
DataBuf buf(pValue_->size());
|
||||
pValue_->copy(buf.data(), byteOrder);
|
||||
ioWrapper.write(buf.c_data(), buf.size());
|
||||
return static_cast<uint32_t>(buf.size());
|
||||
return buf.size();
|
||||
} // TiffEntryBase::doWrite
|
||||
|
||||
uint32_t TiffEntryBase::writeOffset(byte* buf, size_t offset, TiffType tiffType, ByteOrder byteOrder) {
|
||||
uint32_t rc = 0;
|
||||
size_t TiffEntryBase::writeOffset(byte* buf, size_t offset, TiffType tiffType, ByteOrder byteOrder) {
|
||||
size_t rc = 0;
|
||||
switch (tiffType) {
|
||||
case ttUnsignedShort:
|
||||
case ttSignedShort:
|
||||
if (offset > std::numeric_limits<uint16_t>::max())
|
||||
throw Error(ErrorCode::kerOffsetOutOfRange);
|
||||
rc = static_cast<uint32_t>(us2Data(buf, static_cast<uint16_t>(offset), byteOrder));
|
||||
rc = us2Data(buf, static_cast<uint16_t>(offset), byteOrder);
|
||||
break;
|
||||
case ttUnsignedLong:
|
||||
case ttSignedLong:
|
||||
rc = static_cast<uint32_t>(l2Data(buf, static_cast<uint32_t>(offset), byteOrder));
|
||||
rc = l2Data(buf, static_cast<uint32_t>(offset), byteOrder);
|
||||
break;
|
||||
default:
|
||||
throw Error(ErrorCode::kerUnsupportedDataAreaOffsetType);
|
||||
@ -1009,13 +1007,13 @@ uint32_t TiffEntryBase::writeOffset(byte* buf, size_t offset, TiffType tiffType,
|
||||
return rc;
|
||||
} // TiffEntryBase::writeOffset
|
||||
|
||||
uint32_t TiffDataEntry::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t /*valueIdx*/,
|
||||
uint32_t dataIdx, uint32_t& /*imageIdx*/) {
|
||||
size_t TiffDataEntry::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t /*valueIdx*/,
|
||||
size_t dataIdx, size_t& /*imageIdx*/) {
|
||||
if (!pValue() || pValue()->count() == 0)
|
||||
return 0;
|
||||
|
||||
DataBuf buf(pValue()->size());
|
||||
uint32_t idx = 0;
|
||||
size_t idx = 0;
|
||||
const size_t prevOffset = pValue()->toUint32(0);
|
||||
for (size_t i = 0; i < count(); ++i) {
|
||||
const size_t iOffset = pValue()->toUint32(i);
|
||||
@ -1024,11 +1022,11 @@ uint32_t TiffDataEntry::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_
|
||||
idx += writeOffset(buf.data(idx), Safe::add(offset, newDataIdx), tiffType(), byteOrder);
|
||||
}
|
||||
ioWrapper.write(buf.c_data(), buf.size());
|
||||
return static_cast<uint32_t>(buf.size());
|
||||
return buf.size();
|
||||
}
|
||||
|
||||
uint32_t TiffImageEntry::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t /*valueIdx*/,
|
||||
uint32_t dataIdx, uint32_t& imageIdx) {
|
||||
size_t TiffImageEntry::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t /*valueIdx*/,
|
||||
size_t dataIdx, size_t& imageIdx) {
|
||||
size_t o2 = imageIdx;
|
||||
// For makernotes, write TIFF image data to the data area
|
||||
if (group() > IfdId::mnId)
|
||||
@ -1038,61 +1036,60 @@ uint32_t TiffImageEntry::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size
|
||||
<< std::hex << tag() << std::dec << ": Writing offset " << o2 << "\n";
|
||||
#endif
|
||||
DataBuf buf(strips_.size() * 4);
|
||||
uint32_t idx = 0;
|
||||
size_t idx = 0;
|
||||
for (const auto& [_, off] : strips_) {
|
||||
idx += writeOffset(buf.data(idx), o2, tiffType(), byteOrder);
|
||||
// Align strip data to word boundary
|
||||
const auto sz = Safe::add(off, off & 1);
|
||||
o2 = Safe::add(o2, sz);
|
||||
if (group() <= IfdId::mnId)
|
||||
imageIdx = Safe::add(imageIdx, static_cast<uint32_t>(sz));
|
||||
imageIdx = Safe::add(imageIdx, sz);
|
||||
}
|
||||
ioWrapper.write(buf.c_data(), buf.size());
|
||||
return static_cast<uint32_t>(buf.size());
|
||||
return buf.size();
|
||||
} // TiffImageEntry::doWrite
|
||||
|
||||
uint32_t TiffSubIfd::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t /*valueIdx*/,
|
||||
uint32_t dataIdx, uint32_t& /*imageIdx*/) {
|
||||
size_t TiffSubIfd::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t /*valueIdx*/,
|
||||
size_t dataIdx, size_t& /*imageIdx*/) {
|
||||
DataBuf buf(ifds_.size() * 4);
|
||||
uint32_t idx = 0;
|
||||
size_t idx = 0;
|
||||
// Sort IFDs by group, needed if image data tags were copied first
|
||||
std::sort(ifds_.begin(), ifds_.end(), cmpGroupLt);
|
||||
for (auto&& ifd : ifds_) {
|
||||
idx += writeOffset(buf.data(idx), offset + dataIdx, tiffType(), byteOrder);
|
||||
dataIdx += static_cast<uint32_t>(ifd->size());
|
||||
dataIdx += ifd->size();
|
||||
}
|
||||
ioWrapper.write(buf.c_data(), buf.size());
|
||||
return static_cast<uint32_t>(buf.size());
|
||||
return buf.size();
|
||||
} // TiffSubIfd::doWrite
|
||||
|
||||
uint32_t TiffMnEntry::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t valueIdx,
|
||||
uint32_t dataIdx, uint32_t& imageIdx) {
|
||||
size_t TiffMnEntry::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t valueIdx, size_t dataIdx,
|
||||
size_t& imageIdx) {
|
||||
if (!mn_) {
|
||||
return TiffEntryBase::doWrite(ioWrapper, byteOrder, offset, valueIdx, dataIdx, imageIdx);
|
||||
}
|
||||
return mn_->write(ioWrapper, byteOrder, offset + valueIdx, static_cast<uint32_t>(-1), static_cast<uint32_t>(-1),
|
||||
imageIdx);
|
||||
return mn_->write(ioWrapper, byteOrder, offset + valueIdx, std::string::npos, std::string::npos, imageIdx);
|
||||
} // TiffMnEntry::doWrite
|
||||
|
||||
uint32_t TiffIfdMakernote::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t /*valueIdx*/,
|
||||
uint32_t /*dataIdx*/, uint32_t& imageIdx) {
|
||||
mnOffset_ = static_cast<uint32_t>(offset);
|
||||
size_t TiffIfdMakernote::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t /*valueIdx*/,
|
||||
size_t /*dataIdx*/, size_t& imageIdx) {
|
||||
mnOffset_ = offset;
|
||||
setImageByteOrder(byteOrder);
|
||||
auto len = static_cast<uint32_t>(writeHeader(ioWrapper, this->byteOrder()));
|
||||
len += ifd_.write(ioWrapper, this->byteOrder(), offset - baseOffset() + len, static_cast<uint32_t>(-1),
|
||||
static_cast<uint32_t>(-1), imageIdx);
|
||||
auto len = writeHeader(ioWrapper, this->byteOrder());
|
||||
len += ifd_.write(ioWrapper, this->byteOrder(), offset - baseOffset() + len, std::string::npos, std::string::npos,
|
||||
imageIdx);
|
||||
return len;
|
||||
} // TiffIfdMakernote::doWrite
|
||||
|
||||
uint32_t TiffBinaryArray::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t valueIdx,
|
||||
uint32_t dataIdx, uint32_t& imageIdx) {
|
||||
size_t TiffBinaryArray::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t valueIdx,
|
||||
size_t dataIdx, size_t& imageIdx) {
|
||||
if (!cfg() || !decoded())
|
||||
return TiffEntryBase::doWrite(ioWrapper, byteOrder, offset, valueIdx, dataIdx, imageIdx);
|
||||
if (cfg()->byteOrder_ != invalidByteOrder)
|
||||
byteOrder = cfg()->byteOrder_;
|
||||
// Tags must be sorted in ascending order
|
||||
std::sort(elements_.begin(), elements_.end(), cmpTagLt);
|
||||
uint32_t idx = 0;
|
||||
size_t idx = 0;
|
||||
MemIo mio; // memory stream in which to store data
|
||||
IoWrapper mioWrapper(mio, nullptr, 0, nullptr);
|
||||
// Some array entries need to have the size in the first element
|
||||
@ -1101,10 +1098,10 @@ uint32_t TiffBinaryArray::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, siz
|
||||
size_t elSize = TypeInfo::typeSize(toTypeId(cfg()->elTiffType_, 0, cfg()->group_));
|
||||
switch (elSize) {
|
||||
case 2:
|
||||
idx += static_cast<uint32_t>(us2Data(buf, static_cast<uint16_t>(size()), byteOrder));
|
||||
idx += us2Data(buf, static_cast<uint16_t>(size()), byteOrder);
|
||||
break;
|
||||
case 4:
|
||||
idx += static_cast<uint32_t>(ul2Data(buf, static_cast<uint32_t>(size()), byteOrder));
|
||||
idx += ul2Data(buf, static_cast<uint32_t>(size()), byteOrder);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -1116,7 +1113,7 @@ uint32_t TiffBinaryArray::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, siz
|
||||
// Skip the manufactured tag, if it exists
|
||||
if (cfg()->hasSize_ && element->tag() == 0)
|
||||
continue;
|
||||
uint32_t newIdx = element->tag() * cfg()->tagStep();
|
||||
size_t newIdx = element->tag() * cfg()->tagStep();
|
||||
idx += fillGap(mioWrapper, idx, newIdx);
|
||||
idx += element->write(mioWrapper, byteOrder, offset + newIdx, valueIdx, dataIdx, imageIdx);
|
||||
}
|
||||
@ -1132,7 +1129,7 @@ uint32_t TiffBinaryArray::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, siz
|
||||
if (cryptFct == &sonyTagDecipher) {
|
||||
cryptFct = sonyTagEncipher;
|
||||
}
|
||||
DataBuf buf = cryptFct(tag(), mio.mmap(), static_cast<uint32_t>(mio.size()), pRoot_);
|
||||
DataBuf buf = cryptFct(tag(), mio.mmap(), mio.size(), pRoot_);
|
||||
if (!buf.empty()) {
|
||||
mio.seek(0, Exiv2::FileIo::beg);
|
||||
mio.write(buf.c_data(), buf.size());
|
||||
@ -1143,39 +1140,39 @@ uint32_t TiffBinaryArray::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, siz
|
||||
return idx;
|
||||
} // TiffBinaryArray::doWrite
|
||||
|
||||
uint32_t TiffBinaryElement::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t /*offset*/, uint32_t /*valueIdx*/,
|
||||
uint32_t /*dataIdx*/, uint32_t& /*imageIdx*/) {
|
||||
size_t TiffBinaryElement::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t /*offset*/, size_t /*valueIdx*/,
|
||||
size_t /*dataIdx*/, size_t& /*imageIdx*/) {
|
||||
auto pv = pValue();
|
||||
if (!pv || pv->count() == 0)
|
||||
return 0;
|
||||
DataBuf buf(pv->size());
|
||||
pv->copy(buf.data(), byteOrder);
|
||||
ioWrapper.write(buf.c_data(), buf.size());
|
||||
return static_cast<uint32_t>(buf.size());
|
||||
return buf.size();
|
||||
} // TiffBinaryElement::doWrite
|
||||
|
||||
uint32_t TiffComponent::writeData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) const {
|
||||
size_t TiffComponent::writeData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t dataIdx,
|
||||
size_t& imageIdx) const {
|
||||
return doWriteData(ioWrapper, byteOrder, offset, dataIdx, imageIdx);
|
||||
} // TiffComponent::writeData
|
||||
|
||||
uint32_t TiffDirectory::doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) const {
|
||||
uint32_t len = 0;
|
||||
size_t TiffDirectory::doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t dataIdx,
|
||||
size_t& imageIdx) const {
|
||||
size_t len = 0;
|
||||
for (auto&& component : components_) {
|
||||
len += component->writeData(ioWrapper, byteOrder, offset, dataIdx + len, imageIdx);
|
||||
}
|
||||
return len;
|
||||
} // TiffDirectory::doWriteData
|
||||
|
||||
uint32_t TiffEntryBase::doWriteData(IoWrapper& /*ioWrapper*/, ByteOrder /*byteOrder*/, size_t /*offset*/,
|
||||
uint32_t /*dataIdx*/, uint32_t& /*imageIdx*/) const {
|
||||
size_t TiffEntryBase::doWriteData(IoWrapper& /*ioWrapper*/, ByteOrder /*byteOrder*/, size_t /*offset*/,
|
||||
size_t /*dataIdx*/, size_t& /*imageIdx*/) const {
|
||||
return 0;
|
||||
} // TiffEntryBase::doWriteData
|
||||
|
||||
uint32_t TiffImageEntry::doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t /*offset*/, uint32_t /*dataIdx*/,
|
||||
uint32_t& /*imageIdx*/) const {
|
||||
uint32_t len = 0;
|
||||
size_t TiffImageEntry::doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t /*offset*/, size_t /*dataIdx*/,
|
||||
size_t& /*imageIdx*/) const {
|
||||
size_t len = 0;
|
||||
// For makernotes, write TIFF image data to the data area
|
||||
if (group() > IfdId::mnId) { // Todo: FIX THIS HACK!!!
|
||||
len = writeImage(ioWrapper, byteOrder);
|
||||
@ -1183,8 +1180,8 @@ uint32_t TiffImageEntry::doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder,
|
||||
return len;
|
||||
} // TiffImageEntry::doWriteData
|
||||
|
||||
uint32_t TiffDataEntry::doWriteData(IoWrapper& ioWrapper, ByteOrder /*byteOrder*/, size_t /*offset*/,
|
||||
uint32_t /*dataIdx*/, uint32_t& /*imageIdx*/) const {
|
||||
size_t TiffDataEntry::doWriteData(IoWrapper& ioWrapper, ByteOrder /*byteOrder*/, size_t /*offset*/, size_t /*dataIdx*/,
|
||||
size_t& /*imageIdx*/) const {
|
||||
if (!pValue())
|
||||
return 0;
|
||||
|
||||
@ -1192,39 +1189,38 @@ uint32_t TiffDataEntry::doWriteData(IoWrapper& ioWrapper, ByteOrder /*byteOrder*
|
||||
if (!buf.empty())
|
||||
ioWrapper.write(buf.c_data(), buf.size());
|
||||
// Align data to word boundary
|
||||
uint32_t align = (buf.size() & 1);
|
||||
size_t align = (buf.size() & 1);
|
||||
if (align)
|
||||
ioWrapper.putb(0x0);
|
||||
|
||||
return static_cast<uint32_t>(buf.size() + align);
|
||||
return buf.size() + align;
|
||||
} // TiffDataEntry::doWriteData
|
||||
|
||||
uint32_t TiffSubIfd::doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) const {
|
||||
uint32_t len = 0;
|
||||
size_t TiffSubIfd::doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t dataIdx,
|
||||
size_t& imageIdx) const {
|
||||
size_t len = 0;
|
||||
for (auto&& ifd : ifds_) {
|
||||
len += ifd->write(ioWrapper, byteOrder, offset + dataIdx + len, static_cast<uint32_t>(-1),
|
||||
static_cast<uint32_t>(-1), imageIdx);
|
||||
len += ifd->write(ioWrapper, byteOrder, offset + dataIdx + len, std::string::npos, std::string::npos, imageIdx);
|
||||
}
|
||||
// Align data to word boundary
|
||||
uint32_t align = (len & 1);
|
||||
size_t align = (len & 1);
|
||||
if (align)
|
||||
ioWrapper.putb(0x0);
|
||||
|
||||
return len + align;
|
||||
} // TiffSubIfd::doWriteData
|
||||
|
||||
uint32_t TiffIfdMakernote::doWriteData(IoWrapper& /*ioWrapper*/, ByteOrder /*byteOrder*/, size_t /*offset*/,
|
||||
uint32_t /*dataIdx*/, uint32_t& /*imageIdx*/) const {
|
||||
size_t TiffIfdMakernote::doWriteData(IoWrapper& /*ioWrapper*/, ByteOrder /*byteOrder*/, size_t /*offset*/,
|
||||
size_t /*dataIdx*/, size_t& /*imageIdx*/) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t TiffComponent::writeImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const {
|
||||
size_t TiffComponent::writeImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const {
|
||||
return doWriteImage(ioWrapper, byteOrder);
|
||||
} // TiffComponent::writeImage
|
||||
|
||||
uint32_t TiffDirectory::doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const {
|
||||
uint32_t len = 0;
|
||||
size_t TiffDirectory::doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const {
|
||||
size_t len = 0;
|
||||
TiffComponent* pSubIfd = nullptr;
|
||||
for (auto component : components_) {
|
||||
if (component->tag() == 0x014a) {
|
||||
@ -1248,27 +1244,27 @@ uint32_t TiffDirectory::doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder)
|
||||
return len;
|
||||
} // TiffDirectory::doWriteImage
|
||||
|
||||
uint32_t TiffEntryBase::doWriteImage(IoWrapper& /*ioWrapper*/, ByteOrder /*byteOrder*/) const {
|
||||
size_t TiffEntryBase::doWriteImage(IoWrapper& /*ioWrapper*/, ByteOrder /*byteOrder*/) const {
|
||||
return 0;
|
||||
} // TiffEntryBase::doWriteImage
|
||||
|
||||
uint32_t TiffSubIfd::doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const {
|
||||
uint32_t len = 0;
|
||||
size_t TiffSubIfd::doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const {
|
||||
size_t len = 0;
|
||||
for (auto&& ifd : ifds_) {
|
||||
len += ifd->writeImage(ioWrapper, byteOrder);
|
||||
}
|
||||
return len;
|
||||
} // TiffSubIfd::doWriteImage
|
||||
|
||||
uint32_t TiffIfdMakernote::doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const {
|
||||
size_t TiffIfdMakernote::doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const {
|
||||
if (this->byteOrder() != invalidByteOrder) {
|
||||
byteOrder = this->byteOrder();
|
||||
}
|
||||
uint32_t len = ifd_.writeImage(ioWrapper, byteOrder);
|
||||
size_t len = ifd_.writeImage(ioWrapper, byteOrder);
|
||||
return len;
|
||||
} // TiffIfdMakernote::doWriteImage
|
||||
|
||||
uint32_t TiffImageEntry::doWriteImage(IoWrapper& ioWrapper, ByteOrder /*byteOrder*/) const {
|
||||
size_t TiffImageEntry::doWriteImage(IoWrapper& ioWrapper, ByteOrder /*byteOrder*/) const {
|
||||
if (!pValue())
|
||||
throw Error(ErrorCode::kerImageWriteFailed); // #1296
|
||||
|
||||
@ -1293,7 +1289,7 @@ uint32_t TiffImageEntry::doWriteImage(IoWrapper& ioWrapper, ByteOrder /*byteOrde
|
||||
for (auto&& [f, s] : strips_) {
|
||||
ioWrapper.write(f, s);
|
||||
len += s;
|
||||
uint32_t align = s & 1; // Align strip data to word boundary
|
||||
size_t align = s & 1; // Align strip data to word boundary
|
||||
if (align)
|
||||
ioWrapper.putb(0x0);
|
||||
len += align;
|
||||
@ -1302,7 +1298,7 @@ uint32_t TiffImageEntry::doWriteImage(IoWrapper& ioWrapper, ByteOrder /*byteOrde
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
std::cerr << ", len = " << len << " bytes\n";
|
||||
#endif
|
||||
return static_cast<uint32_t>(len);
|
||||
return len;
|
||||
} // TiffImageEntry::doWriteImage
|
||||
|
||||
size_t TiffComponent::size() const {
|
||||
@ -1320,7 +1316,7 @@ size_t TiffDirectory::doSize() const {
|
||||
sv += sv & 1; // Align value to word boundary
|
||||
len += sv;
|
||||
}
|
||||
auto sd = static_cast<uint32_t>(component->sizeData());
|
||||
auto sd = component->sizeData();
|
||||
sd += sd & 1; // Align data to word boundary
|
||||
len += sd;
|
||||
}
|
||||
@ -1382,7 +1378,7 @@ size_t TiffBinaryArray::doSize() const {
|
||||
if (cfg()->hasFillers_ && def()) {
|
||||
const ArrayDef* lastDef = def() + defSize() - 1;
|
||||
auto lastTag = static_cast<uint16_t>(lastDef->idx_ / cfg()->tagStep());
|
||||
idx = std::max(idx, static_cast<size_t>(lastDef->idx_ + lastDef->size(lastTag, cfg()->group_)));
|
||||
idx = std::max(idx, lastDef->idx_ + lastDef->size(lastTag, cfg()->group_));
|
||||
}
|
||||
return idx;
|
||||
|
||||
@ -1550,7 +1546,7 @@ TiffComponent::UniquePtr newTiffBinaryElement(uint16_t tag, IfdId group) {
|
||||
// *****************************************************************************
|
||||
// local definitions
|
||||
namespace {
|
||||
uint32_t fillGap(Exiv2::Internal::IoWrapper& ioWrapper, uint32_t curr, uint32_t tobe) {
|
||||
size_t fillGap(Exiv2::Internal::IoWrapper& ioWrapper, size_t curr, size_t tobe) {
|
||||
if (curr < tobe) {
|
||||
Exiv2::DataBuf buf(tobe - curr);
|
||||
ioWrapper.write(buf.c_data(), buf.size());
|
||||
|
||||
@ -223,8 +223,8 @@ class TiffComponent {
|
||||
nested components.
|
||||
@throw Error If the component cannot be written.
|
||||
*/
|
||||
uint32_t write(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t valueIdx, uint32_t dataIdx,
|
||||
uint32_t& imageIdx);
|
||||
size_t write(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t valueIdx, size_t dataIdx,
|
||||
size_t& imageIdx);
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
@ -252,14 +252,13 @@ class TiffComponent {
|
||||
Return the number of bytes written. Components derived from
|
||||
TiffEntryBase implement this method if needed.
|
||||
*/
|
||||
uint32_t writeData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) const;
|
||||
size_t writeData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t dataIdx, size_t& imageIdx) const;
|
||||
/*!
|
||||
@brief Write the image data of this component to a binary image.
|
||||
Return the number of bytes written. TIFF components implement
|
||||
this method if needed.
|
||||
*/
|
||||
uint32_t writeImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const;
|
||||
size_t writeImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const;
|
||||
/*!
|
||||
@brief Return the size in bytes of the IFD value of this component
|
||||
when written to a binary image.
|
||||
@ -304,8 +303,8 @@ class TiffComponent {
|
||||
//! Implements accept().
|
||||
virtual void doAccept(TiffVisitor& visitor) = 0;
|
||||
//! Implements write().
|
||||
virtual uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t valueIdx,
|
||||
uint32_t dataIdx, uint32_t& imageIdx) = 0;
|
||||
virtual size_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t valueIdx, size_t dataIdx,
|
||||
size_t& imageIdx) = 0;
|
||||
//@}
|
||||
|
||||
//! @name Protected Accessors
|
||||
@ -313,10 +312,10 @@ class TiffComponent {
|
||||
//! Internal virtual copy constructor, implements clone().
|
||||
[[nodiscard]] virtual TiffComponent* doClone() const = 0;
|
||||
//! Implements writeData().
|
||||
virtual uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) const = 0;
|
||||
virtual size_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t dataIdx,
|
||||
size_t& imageIdx) const = 0;
|
||||
//! Implements writeImage().
|
||||
virtual uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const = 0;
|
||||
virtual size_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const = 0;
|
||||
//! Implements size().
|
||||
[[nodiscard]] virtual size_t doSize() const = 0;
|
||||
//! Implements count().
|
||||
@ -504,8 +503,8 @@ class TiffEntryBase : public TiffComponent {
|
||||
the \em ioWrapper, return the number of bytes written. Only the
|
||||
\em ioWrapper and \em byteOrder arguments are used.
|
||||
*/
|
||||
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t valueIdx, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) override;
|
||||
size_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t valueIdx, size_t dataIdx,
|
||||
size_t& imageIdx) override;
|
||||
//@}
|
||||
|
||||
//! @name Protected Accessors
|
||||
@ -516,13 +515,13 @@ class TiffEntryBase : public TiffComponent {
|
||||
@brief Implements writeData(). Standard TIFF entries have no data:
|
||||
write nothing and return 0.
|
||||
*/
|
||||
uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) const override;
|
||||
size_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t dataIdx,
|
||||
size_t& imageIdx) const override;
|
||||
/*!
|
||||
@brief Implements writeImage(). Standard TIFF entries have no image data:
|
||||
write nothing and return 0.
|
||||
*/
|
||||
uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
size_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
//! Implements size(). Return the size of a standard TIFF entry
|
||||
[[nodiscard]] size_t doSize() const override;
|
||||
//! Implements sizeData(). Return 0.
|
||||
@ -532,7 +531,7 @@ class TiffEntryBase : public TiffComponent {
|
||||
//@}
|
||||
|
||||
//! Helper function to write an \em offset to a preallocated binary buffer
|
||||
static uint32_t writeOffset(byte* buf, size_t offset, TiffType tiffType, ByteOrder byteOrder);
|
||||
static size_t writeOffset(byte* buf, size_t offset, TiffType tiffType, ByteOrder byteOrder);
|
||||
|
||||
//! Used (internally) to create another reference to the DataBuf reference by storage_.
|
||||
[[nodiscard]] const std::shared_ptr<DataBuf>& storage() const {
|
||||
@ -622,7 +621,7 @@ class TiffDataEntryBase : public TiffEntryBase {
|
||||
@param sizeData Size of the data area.
|
||||
@param baseOffset Base offset into the data area.
|
||||
*/
|
||||
virtual void setStrips(const Value* pSize, const byte* pData, size_t sizeData, uint32_t baseOffset) = 0;
|
||||
virtual void setStrips(const Value* pSize, const byte* pData, size_t sizeData, size_t baseOffset) = 0;
|
||||
//@}
|
||||
|
||||
//! @name Accessors
|
||||
@ -663,7 +662,7 @@ class TiffDataEntry : public TiffDataEntryBase {
|
||||
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void setStrips(const Value* pSize, const byte* pData, size_t sizeData, uint32_t baseOffset) override;
|
||||
void setStrips(const Value* pSize, const byte* pData, size_t sizeData, size_t baseOffset) override;
|
||||
//@}
|
||||
|
||||
protected:
|
||||
@ -682,8 +681,8 @@ class TiffDataEntry : public TiffDataEntryBase {
|
||||
on write. The type of the value can only be signed or unsigned short or
|
||||
long.
|
||||
*/
|
||||
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t valueIdx, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) override;
|
||||
size_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t valueIdx, size_t dataIdx,
|
||||
size_t& imageIdx) override;
|
||||
//@}
|
||||
|
||||
//! @name Protected Accessors
|
||||
@ -693,8 +692,8 @@ class TiffDataEntry : public TiffDataEntryBase {
|
||||
@brief Implements writeData(). Write the data area to the \em ioWrapper.
|
||||
Return the number of bytes written.
|
||||
*/
|
||||
uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) const override;
|
||||
size_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t dataIdx,
|
||||
size_t& imageIdx) const override;
|
||||
// Using doWriteImage from base class
|
||||
// Using doSize() from base class
|
||||
//! Implements sizeData(). Return the size of the data area.
|
||||
@ -728,7 +727,7 @@ class TiffImageEntry : public TiffDataEntryBase {
|
||||
public:
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
void setStrips(const Value* pSize, const byte* pData, size_t sizeData, uint32_t baseOffset) override;
|
||||
void setStrips(const Value* pSize, const byte* pData, size_t sizeData, size_t baseOffset) override;
|
||||
//@}
|
||||
|
||||
protected:
|
||||
@ -741,8 +740,8 @@ class TiffImageEntry : public TiffDataEntryBase {
|
||||
\em ioWrapper. Return the number of bytes written. The \em valueIdx
|
||||
and \em dataIdx arguments are not used.
|
||||
*/
|
||||
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t valueIdx, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) override;
|
||||
size_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t valueIdx, size_t dataIdx,
|
||||
size_t& imageIdx) override;
|
||||
//@}
|
||||
|
||||
//! @name Protected Accessors
|
||||
@ -756,13 +755,13 @@ class TiffImageEntry : public TiffDataEntryBase {
|
||||
directory. It is used for TIFF image entries in the makernote (large
|
||||
preview images) so that the image data remains in the makernote IFD.
|
||||
*/
|
||||
uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) const override;
|
||||
size_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t dataIdx,
|
||||
size_t& imageIdx) const override;
|
||||
/*!
|
||||
@brief Implements writeImage(). Write the image data area to the \em ioWrapper.
|
||||
Return the number of bytes written.
|
||||
*/
|
||||
uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
size_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
//! Implements size(). Return the size of the strip pointers.
|
||||
[[nodiscard]] size_t doSize() const override;
|
||||
//! Implements sizeData(). Return the size of the image data area.
|
||||
@ -880,8 +879,8 @@ class TiffDirectory : public TiffComponent {
|
||||
additional data, including the next-IFD, if any, to the
|
||||
\em ioWrapper, return the number of bytes written.
|
||||
*/
|
||||
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t valueIdx, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) override;
|
||||
size_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t valueIdx, size_t dataIdx,
|
||||
size_t& imageIdx) override;
|
||||
//@}
|
||||
|
||||
//! @name Protected Accessors
|
||||
@ -891,15 +890,15 @@ class TiffDirectory : public TiffComponent {
|
||||
@brief This class does not really implement writeData(), it only has
|
||||
write(). This method must not be called; it commits suicide.
|
||||
*/
|
||||
uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) const override;
|
||||
size_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t dataIdx,
|
||||
size_t& imageIdx) const override;
|
||||
/*!
|
||||
@brief Implements writeImage(). Write the image data of the TIFF
|
||||
directory to the \em ioWrapper by forwarding the call to each
|
||||
component as well as the next-IFD, if there is any. Return the
|
||||
number of bytes written.
|
||||
*/
|
||||
uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
size_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
/*!
|
||||
@brief Implements size(). Return the size of the TIFF directory,
|
||||
values and additional data, including the next-IFD, if any.
|
||||
@ -926,8 +925,8 @@ class TiffDirectory : public TiffComponent {
|
||||
//! @name Private Accessors
|
||||
//@{
|
||||
//! Write a binary directory entry for a TIFF component.
|
||||
static uint32_t writeDirEntry(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, TiffComponent* pTiffComponent,
|
||||
uint32_t valueIdx, uint32_t dataIdx, uint32_t& imageIdx);
|
||||
static size_t writeDirEntry(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, TiffComponent* pTiffComponent,
|
||||
size_t valueIdx, size_t dataIdx, size_t& imageIdx);
|
||||
//@}
|
||||
|
||||
// DATA
|
||||
@ -976,8 +975,8 @@ class TiffSubIfd : public TiffEntryBase {
|
||||
return the number of bytes written. The \em valueIdx and
|
||||
\em imageIdx arguments are not used.
|
||||
*/
|
||||
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t valueIdx, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) override;
|
||||
size_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t valueIdx, size_t dataIdx,
|
||||
size_t& imageIdx) override;
|
||||
//@}
|
||||
|
||||
//! @name Protected Accessors
|
||||
@ -987,13 +986,13 @@ class TiffSubIfd : public TiffEntryBase {
|
||||
@brief Implements writeData(). Write the sub-IFDs to the \em ioWrapper.
|
||||
Return the number of bytes written.
|
||||
*/
|
||||
uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) const override;
|
||||
size_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t dataIdx,
|
||||
size_t& imageIdx) const override;
|
||||
/*!
|
||||
@brief Implements writeImage(). Write the image data of each sub-IFD to
|
||||
the \em ioWrapper. Return the number of bytes written.
|
||||
*/
|
||||
uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
size_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
//! Implements size(). Return the size of the sub-Ifd pointers.
|
||||
[[nodiscard]] size_t doSize() const override;
|
||||
//! Implements sizeData(). Return the sum of the sizes of all sub-IFDs.
|
||||
@ -1054,8 +1053,8 @@ class TiffMnEntry : public TiffEntryBase {
|
||||
@brief Implements write() by forwarding the call to the actual
|
||||
concrete Makernote, if there is one.
|
||||
*/
|
||||
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t valueIdx, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) override;
|
||||
size_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t valueIdx, size_t dataIdx,
|
||||
size_t& imageIdx) override;
|
||||
//@}
|
||||
|
||||
//! @name Protected Accessors
|
||||
@ -1146,7 +1145,7 @@ class TiffIfdMakernote : public TiffComponent {
|
||||
@brief Return the offset to the makernote from the start of the
|
||||
TIFF header.
|
||||
*/
|
||||
[[nodiscard]] uint32_t mnOffset() const;
|
||||
[[nodiscard]] size_t mnOffset() const;
|
||||
/*!
|
||||
@brief Return the offset to the start of the Makernote IFD from
|
||||
the start of the Makernote.
|
||||
@ -1166,7 +1165,7 @@ class TiffIfdMakernote : public TiffComponent {
|
||||
relative to the start of the TIFF header.
|
||||
Returns 0 if there is no header.
|
||||
*/
|
||||
[[nodiscard]] uint32_t baseOffset() const;
|
||||
[[nodiscard]] size_t baseOffset() const;
|
||||
//@}
|
||||
|
||||
protected:
|
||||
@ -1182,8 +1181,8 @@ class TiffIfdMakernote : public TiffComponent {
|
||||
values and additional data to the \em ioWrapper, return the
|
||||
number of bytes written.
|
||||
*/
|
||||
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t valueIdx, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) override;
|
||||
size_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t valueIdx, size_t dataIdx,
|
||||
size_t& imageIdx) override;
|
||||
//@}
|
||||
|
||||
//! @name Protected Accessors
|
||||
@ -1193,13 +1192,13 @@ class TiffIfdMakernote : public TiffComponent {
|
||||
@brief This class does not really implement writeData(), it only has
|
||||
write(). This method must not be called; it commits suicide.
|
||||
*/
|
||||
uint32_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) const override;
|
||||
size_t doWriteData(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t dataIdx,
|
||||
size_t& imageIdx) const override;
|
||||
/*!
|
||||
@brief Implements writeImage(). Write the image data of the IFD of
|
||||
the Makernote. Return the number of bytes written.
|
||||
*/
|
||||
uint32_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
size_t doWriteImage(IoWrapper& ioWrapper, ByteOrder byteOrder) const override;
|
||||
/*!
|
||||
@brief Implements size(). Return the size of the Makernote header,
|
||||
TIFF directory, values and additional data.
|
||||
@ -1227,7 +1226,7 @@ class TiffIfdMakernote : public TiffComponent {
|
||||
// DATA
|
||||
MnHeader* pHeader_; //!< Makernote header
|
||||
TiffDirectory ifd_; //!< Makernote IFD
|
||||
uint32_t mnOffset_{}; //!< Makernote offset
|
||||
size_t mnOffset_{}; //!< Makernote offset
|
||||
ByteOrder imageByteOrder_{invalidByteOrder}; //!< Byte order for the image
|
||||
|
||||
}; // class TiffIfdMakernote
|
||||
@ -1244,15 +1243,15 @@ using CryptFct = DataBuf (*)(uint16_t, const byte*, size_t, TiffComponent*);
|
||||
//! Defines one tag in a binary array
|
||||
struct ArrayDef {
|
||||
//! Comparison with idx
|
||||
bool operator==(uint32_t idx) const {
|
||||
bool operator==(size_t idx) const {
|
||||
return idx_ == idx;
|
||||
}
|
||||
//! Get the size in bytes of a tag.
|
||||
[[nodiscard]] uint32_t size(uint16_t tag, IfdId group) const;
|
||||
[[nodiscard]] size_t size(uint16_t tag, IfdId group) const;
|
||||
// DATA
|
||||
uint32_t idx_; //!< Index in bytes from the start
|
||||
size_t idx_; //!< Index in bytes from the start
|
||||
TiffType tiffType_; //!< TIFF type of the element
|
||||
uint32_t count_; //!< Number of components
|
||||
size_t count_; //!< Number of components
|
||||
};
|
||||
|
||||
//! Additional configuration for a binary array.
|
||||
@ -1261,7 +1260,7 @@ struct ArrayCfg {
|
||||
@brief Return the size of the default tag, which is used
|
||||
to calculate tag numbers as idx/tagStep
|
||||
*/
|
||||
[[nodiscard]] uint32_t tagStep() const {
|
||||
[[nodiscard]] size_t tagStep() const {
|
||||
return elDefaultDef_.size(0, group_);
|
||||
}
|
||||
// DATA
|
||||
@ -1292,9 +1291,9 @@ class TiffBinaryArray : public TiffEntryBase {
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Constructor
|
||||
TiffBinaryArray(uint16_t tag, IfdId group, const ArrayCfg& arrayCfg, const ArrayDef* arrayDef, int defSize);
|
||||
TiffBinaryArray(uint16_t tag, IfdId group, const ArrayCfg& arrayCfg, const ArrayDef* arrayDef, size_t defSize);
|
||||
//! Constructor for a complex binary array
|
||||
TiffBinaryArray(uint16_t tag, IfdId group, const ArraySet* arraySet, int setSize, CfgSelFct cfgSelFct);
|
||||
TiffBinaryArray(uint16_t tag, IfdId group, const ArraySet* arraySet, size_t setSize, CfgSelFct cfgSelFct);
|
||||
//! Virtual destructor
|
||||
~TiffBinaryArray() override;
|
||||
TiffBinaryArray& operator=(const TiffBinaryArray&) = delete;
|
||||
@ -1303,7 +1302,7 @@ class TiffBinaryArray : public TiffEntryBase {
|
||||
//! @name Manipulators
|
||||
//@{
|
||||
//! Add an element to the binary array, return the size of the element
|
||||
uint32_t addElement(uint32_t idx, const ArrayDef& def);
|
||||
size_t addElement(size_t idx, const ArrayDef& def);
|
||||
/*!
|
||||
@brief Setup cfg and def for the component, in case of a complex binary array.
|
||||
Else do nothing. Return true if the initialization succeeded, else false.
|
||||
@ -1348,7 +1347,7 @@ class TiffBinaryArray : public TiffEntryBase {
|
||||
return arrayDef_;
|
||||
}
|
||||
//! Return the number of elements in the definition
|
||||
[[nodiscard]] int defSize() const {
|
||||
[[nodiscard]] size_t defSize() const {
|
||||
return defSize_;
|
||||
}
|
||||
//! Return the flag which indicates if the array was decoded
|
||||
@ -1380,8 +1379,8 @@ class TiffBinaryArray : public TiffEntryBase {
|
||||
/*!
|
||||
@brief Implements write(). Todo: Document it!
|
||||
*/
|
||||
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t valueIdx, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) override;
|
||||
size_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t valueIdx, size_t dataIdx,
|
||||
size_t& imageIdx) override;
|
||||
//@}
|
||||
|
||||
//! @name Protected Accessors
|
||||
@ -1406,8 +1405,8 @@ class TiffBinaryArray : public TiffEntryBase {
|
||||
const ArrayCfg* arrayCfg_{}; //!< Pointer to the array configuration (must not be 0, except for
|
||||
//!< unrecognized complex binary arrays)
|
||||
const ArrayDef* arrayDef_{}; //!< Pointer to the array definition (may be 0)
|
||||
int defSize_{}; //!< Size of the array definition array (may be 0)
|
||||
int setSize_{}; //!< Size of the array set (may be 0)
|
||||
size_t defSize_{}; //!< Size of the array definition array (may be 0)
|
||||
size_t 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)
|
||||
size_t origSize_{}; //!< Size of the original data buffer
|
||||
@ -1468,8 +1467,8 @@ class TiffBinaryElement : public TiffEntryBase {
|
||||
/*!
|
||||
@brief Implements write(). Todo: Document it!
|
||||
*/
|
||||
uint32_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, uint32_t valueIdx, uint32_t dataIdx,
|
||||
uint32_t& imageIdx) override;
|
||||
size_t doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, size_t offset, size_t valueIdx, size_t dataIdx,
|
||||
size_t& imageIdx) override;
|
||||
//@}
|
||||
|
||||
//! @name Protected Accessors
|
||||
@ -1534,7 +1533,7 @@ TiffComponent::UniquePtr newTiffSubIfd(uint16_t tag, IfdId group) {
|
||||
}
|
||||
|
||||
//! Function to create and initialize a new binary array entry
|
||||
template <const ArrayCfg& arrayCfg, int N, const ArrayDef arrayDef[N]>
|
||||
template <const ArrayCfg& arrayCfg, size_t N, const ArrayDef arrayDef[N]>
|
||||
TiffComponent::UniquePtr newTiffBinaryArray0(uint16_t tag, IfdId group) {
|
||||
return std::make_unique<TiffBinaryArray>(tag, group, arrayCfg, &(*arrayDef), N);
|
||||
}
|
||||
@ -1546,7 +1545,7 @@ TiffComponent::UniquePtr newTiffBinaryArray1(uint16_t tag, IfdId group) {
|
||||
}
|
||||
|
||||
//! Function to create and initialize a new complex binary array entry
|
||||
template <const ArraySet* arraySet, int N, CfgSelFct cfgSelFct>
|
||||
template <const ArraySet* arraySet, size_t N, CfgSelFct cfgSelFct>
|
||||
TiffComponent::UniquePtr newTiffBinaryArray2(uint16_t tag, IfdId group) {
|
||||
return std::make_unique<TiffBinaryArray>(tag, group, &(*arraySet), N, cfgSelFct);
|
||||
}
|
||||
|
||||
@ -2076,9 +2076,8 @@ WriteMethod TiffParserWorker::encode(BasicIo& io, const byte* pData, size_t size
|
||||
DataBuf header = pHeader->write();
|
||||
auto tempIo = MemIo();
|
||||
IoWrapper ioWrapper(tempIo, header.c_data(), header.size(), pOffsetWriter);
|
||||
auto imageIdx(static_cast<uint32_t>(-1));
|
||||
createdTree->write(ioWrapper, pHeader->byteOrder(), header.size(), static_cast<uint32_t>(-1),
|
||||
static_cast<uint32_t>(-1), imageIdx);
|
||||
auto imageIdx(std::string::npos);
|
||||
createdTree->write(ioWrapper, pHeader->byteOrder(), header.size(), std::string::npos, std::string::npos, imageIdx);
|
||||
if (pOffsetWriter)
|
||||
pOffsetWriter->writeOffsets(tempIo);
|
||||
io.transfer(tempIo); // may throw
|
||||
|
||||
@ -233,7 +233,7 @@ void TiffDecoder::visitMnEntry(TiffMnEntry* object) {
|
||||
}
|
||||
|
||||
void TiffDecoder::visitIfdMakernote(TiffIfdMakernote* object) {
|
||||
exifData_["Exif.MakerNote.Offset"] = object->mnOffset();
|
||||
exifData_["Exif.MakerNote.Offset"] = static_cast<uint32_t>(object->mnOffset());
|
||||
switch (object->byteOrder()) {
|
||||
case littleEndian:
|
||||
exifData_["Exif.MakerNote.ByteOrder"] = "II";
|
||||
@ -764,7 +764,7 @@ void TiffEncoder::encodeDataEntry(TiffDataEntry* object, const Exifdatum* datum)
|
||||
encodeOffsetEntry(object, datum);
|
||||
|
||||
if (!dirty_ && writeMethod() == wmNonIntrusive) {
|
||||
if (object->sizeDataArea_ < static_cast<uint32_t>(object->pValue()->sizeDataArea())) {
|
||||
if (object->sizeDataArea_ < object->pValue()->sizeDataArea()) {
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
ExifKey key(object->tag(), groupName(object->group()));
|
||||
std::cerr << "DATAAREA GREW " << key << "\n";
|
||||
@ -779,7 +779,7 @@ void TiffEncoder::encodeDataEntry(TiffDataEntry* object, const Exifdatum* datum)
|
||||
DataBuf buf = object->pValue()->dataArea();
|
||||
if (!buf.empty()) {
|
||||
memcpy(object->pDataArea_, buf.c_data(), buf.size());
|
||||
if (object->sizeDataArea_ > static_cast<size_t>(buf.size())) {
|
||||
if (object->sizeDataArea_ > buf.size()) {
|
||||
memset(object->pDataArea_ + buf.size(), 0x0, object->sizeDataArea_ - buf.size());
|
||||
}
|
||||
}
|
||||
@ -817,9 +817,9 @@ void TiffEncoder::encodeImageEntry(TiffImageEntry* object, const Exifdatum* datu
|
||||
EXV_ERROR << "Size tag " << key << " not found. Writing only one strip.\n";
|
||||
#endif
|
||||
object->strips_.clear();
|
||||
object->strips_.emplace_back(zero, static_cast<uint32_t>(sizeDataArea));
|
||||
object->strips_.emplace_back(zero, sizeDataArea);
|
||||
} else {
|
||||
uint32_t sizeTotal = 0;
|
||||
size_t sizeTotal = 0;
|
||||
object->strips_.clear();
|
||||
for (size_t i = 0; i < pos->count(); ++i) {
|
||||
uint32_t len = pos->toUint32(i);
|
||||
@ -1006,7 +1006,7 @@ ByteOrder TiffReader::byteOrder() const {
|
||||
return pState_->byteOrder();
|
||||
}
|
||||
|
||||
uint32_t TiffReader::baseOffset() const {
|
||||
size_t TiffReader::baseOffset() const {
|
||||
return pState_->baseOffset();
|
||||
}
|
||||
|
||||
@ -1221,7 +1221,7 @@ void TiffReader::visitIfdMakernote(TiffIfdMakernote* object) {
|
||||
object->ifd_.setStart(object->start() + object->ifdOffset());
|
||||
|
||||
// Modify reader for Makernote peculiarities, byte order and offset
|
||||
object->mnOffset_ = static_cast<uint32_t>(object->start() - pData_);
|
||||
object->mnOffset_ = object->start() - pData_;
|
||||
TiffRwState state(object->byteOrder(), object->baseOffset());
|
||||
setMnState(&state);
|
||||
|
||||
@ -1269,11 +1269,11 @@ void TiffReader::readTiffEntry(TiffEntryBase* object) {
|
||||
}
|
||||
p += 4;
|
||||
|
||||
if (count > std::numeric_limits<uint32_t>::max() / typeSize) {
|
||||
if (count > std::numeric_limits<size_t>::max() / typeSize) {
|
||||
throw Error(ErrorCode::kerArithmeticOverflow);
|
||||
}
|
||||
size_t size = typeSize * count;
|
||||
uint32_t offset = getULong(p, byteOrder());
|
||||
size_t offset = getULong(p, byteOrder());
|
||||
byte* pData = p;
|
||||
if (size > 4 && Safe::add<size_t>(baseOffset(), offset) >= size_) {
|
||||
// #1143
|
||||
@ -1319,7 +1319,7 @@ void TiffReader::readTiffEntry(TiffEntryBase* object) {
|
||||
<< size
|
||||
<< ", exceeds buffer size by "
|
||||
// cast to make MSVC happy
|
||||
<< static_cast<uint32_t>(pData + size - pLast_) << " Bytes; truncating the entry\n";
|
||||
<< static_cast<size_t>(pData + size - pLast_) << " Bytes; truncating the entry\n";
|
||||
#endif
|
||||
size = 0;
|
||||
}
|
||||
@ -1382,7 +1382,7 @@ void TiffReader::visitBinaryArray(TiffBinaryArray* object) {
|
||||
const ArrayDef* def = &cfg->elDefaultDef_;
|
||||
ArrayDef gap = *def;
|
||||
|
||||
for (uint32_t idx = 0; idx < object->TiffEntryBase::doSize();) {
|
||||
for (size_t idx = 0; idx < object->TiffEntryBase::doSize();) {
|
||||
if (defs) {
|
||||
def = std::find(defs, defsEnd, idx);
|
||||
if (def == defsEnd) {
|
||||
@ -1391,11 +1391,11 @@ void TiffReader::visitBinaryArray(TiffBinaryArray* object) {
|
||||
const ArrayDef* xdef = defs;
|
||||
for (; xdef != defsEnd && xdef->idx_ <= idx; ++xdef) {
|
||||
}
|
||||
uint32_t gapSize = 0;
|
||||
size_t gapSize = 0;
|
||||
if (xdef != defsEnd && xdef->idx_ > idx) {
|
||||
gapSize = xdef->idx_ - idx;
|
||||
} else {
|
||||
gapSize = static_cast<uint32_t>(object->TiffEntryBase::doSize()) - idx;
|
||||
gapSize = object->TiffEntryBase::doSize() - idx;
|
||||
}
|
||||
gap.idx_ = idx;
|
||||
gap.tiffType_ = cfg->elDefaultDef_.tiffType_;
|
||||
|
||||
@ -538,7 +538,7 @@ class TiffRwState {
|
||||
//! @name Creators
|
||||
//@{
|
||||
//! Constructor.
|
||||
TiffRwState(ByteOrder byteOrder, uint32_t baseOffset) : byteOrder_(byteOrder), baseOffset_(baseOffset) {
|
||||
TiffRwState(ByteOrder byteOrder, size_t baseOffset) : byteOrder_(byteOrder), baseOffset_(baseOffset) {
|
||||
}
|
||||
//@}
|
||||
|
||||
@ -562,14 +562,14 @@ class TiffRwState {
|
||||
case, base offset added to the start of the TIFF image header points
|
||||
to the basis for such makernote offsets.
|
||||
*/
|
||||
[[nodiscard]] uint32_t baseOffset() const {
|
||||
[[nodiscard]] size_t baseOffset() const {
|
||||
return baseOffset_;
|
||||
}
|
||||
//@}
|
||||
|
||||
private:
|
||||
ByteOrder byteOrder_;
|
||||
uint32_t baseOffset_;
|
||||
size_t baseOffset_;
|
||||
}; // TiffRwState
|
||||
|
||||
/*!
|
||||
@ -658,7 +658,7 @@ class TiffReader : public TiffVisitor {
|
||||
//! Return the byte order.
|
||||
[[nodiscard]] ByteOrder byteOrder() const;
|
||||
//! Return the base offset. See class TiffRwState for details
|
||||
[[nodiscard]] uint32_t baseOffset() const;
|
||||
[[nodiscard]] size_t baseOffset() const;
|
||||
//@}
|
||||
|
||||
private:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user