commit
6438305234
@ -331,8 +331,8 @@ int Print::printTag(const Exiv2::ExifData& exifData, const std::string& key, con
|
||||
return rc;
|
||||
} // Print::printTag
|
||||
|
||||
int Print::printTag(const Exiv2::ExifData& exifData, EasyAccessFct easyAccessFct, const std::string& label,
|
||||
EasyAccessFct easyAccessFctFallback) const {
|
||||
int Print::printTag(const Exiv2::ExifData& exifData, const EasyAccessFct& easyAccessFct, const std::string& label,
|
||||
const EasyAccessFct& easyAccessFctFallback) const {
|
||||
int rc = 0;
|
||||
if (!label.empty()) {
|
||||
printLabel(label);
|
||||
|
||||
@ -155,14 +155,14 @@ class Print : public Task {
|
||||
*/
|
||||
int printTag(const Exiv2::ExifData& exifData, const std::string& key, const std::string& label = "") const;
|
||||
//! Type for an Exiv2 Easy access function
|
||||
using EasyAccessFct = Exiv2::ExifData::const_iterator (*)(const Exiv2::ExifData& ed);
|
||||
using EasyAccessFct = std::function<Exiv2::ExifData::const_iterator(const Exiv2::ExifData& ed)>;
|
||||
/*!
|
||||
@brief Print one summary line with a label (if provided) and requested
|
||||
data. A line break is printed only if a label is provided.
|
||||
@return 1 if a line was written, 0 if the information was not found.
|
||||
*/
|
||||
int printTag(const Exiv2::ExifData& exifData, EasyAccessFct easyAccessFct, const std::string& label = "",
|
||||
EasyAccessFct easyAccessFctFallback = nullptr) const;
|
||||
int printTag(const Exiv2::ExifData& exifData, const EasyAccessFct& easyAccessFct, const std::string& label = "",
|
||||
const EasyAccessFct& easyAccessFctFallback = nullptr) const;
|
||||
|
||||
private:
|
||||
std::string path_;
|
||||
|
||||
@ -122,7 +122,7 @@ class EXIV2API BmffImage : public Image {
|
||||
@return address of next box
|
||||
@warning This function should only be called by readMetadata()
|
||||
*/
|
||||
long boxHandler(std::ostream& out, Exiv2::PrintStructureOption option, const long pbox_end, int depth);
|
||||
long boxHandler(std::ostream& out, Exiv2::PrintStructureOption option, long pbox_end, int depth);
|
||||
[[nodiscard]] static std::string indent(int i) {
|
||||
return std::string(2 * i, ' ');
|
||||
}
|
||||
|
||||
@ -47,16 +47,16 @@ struct EXIV2API Photoshop {
|
||||
/// @return 0 if successful;<BR>
|
||||
/// 3 if no data for psTag was found in pPsData;<BR>
|
||||
/// -2 if the pPsData buffer does not contain valid data.
|
||||
static int locateIrb(const byte* pPsData, size_t sizePsData, uint16_t psTag, const byte** record,
|
||||
uint32_t* const sizeHdr, uint32_t* const sizeData);
|
||||
static int locateIrb(const byte* pPsData, size_t sizePsData, uint16_t psTag, const byte** record, uint32_t& sizeHdr,
|
||||
uint32_t& sizeData);
|
||||
|
||||
/// @brief Forwards to locateIrb() with \em psTag = \em iptc_
|
||||
static int locateIptcIrb(const byte* pPsData, size_t sizePsData, const byte** record, uint32_t* const sizeHdr,
|
||||
uint32_t* const sizeData);
|
||||
static int locateIptcIrb(const byte* pPsData, size_t sizePsData, const byte** record, uint32_t& sizeHdr,
|
||||
uint32_t& sizeData);
|
||||
|
||||
/// @brief Forwards to locatePreviewIrb() with \em psTag = \em preview_
|
||||
static int locatePreviewIrb(const byte* pPsData, size_t sizePsData, const byte** record, uint32_t* const sizeHdr,
|
||||
uint32_t* const sizeData);
|
||||
static int locatePreviewIrb(const byte* pPsData, size_t sizePsData, const byte** record, uint32_t& sizeHdr,
|
||||
uint32_t& sizeData);
|
||||
|
||||
/// @brief Set the new IPTC IRB, keeps existing IRBs but removes the IPTC block if there is no new IPTC data to write.
|
||||
/// @param pPsData Existing IRB buffer
|
||||
|
||||
@ -5,48 +5,46 @@
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
|
||||
using EasyAccessFct = Exiv2::ExifData::const_iterator (*)(const Exiv2::ExifData&);
|
||||
using EasyAccessFct = std::function<Exiv2::ExifData::const_iterator(const Exiv2::ExifData&)>;
|
||||
using EasyAccess = std::pair<const char*, EasyAccessFct>;
|
||||
|
||||
struct EasyAccess {
|
||||
const char* label_;
|
||||
EasyAccessFct findFct_;
|
||||
static const EasyAccess easyAccess[] = {
|
||||
{"Orientation", Exiv2::orientation},
|
||||
{"ISO speed", Exiv2::isoSpeed},
|
||||
{"Date & time original", Exiv2::dateTimeOriginal},
|
||||
{"Flash bias", Exiv2::flashBias},
|
||||
{"Exposure mode", Exiv2::exposureMode},
|
||||
{"Scene mode", Exiv2::sceneMode},
|
||||
{"Macro mode", Exiv2::macroMode},
|
||||
{"Image quality", Exiv2::imageQuality},
|
||||
{"White balance", Exiv2::whiteBalance},
|
||||
{"Lens name", Exiv2::lensName},
|
||||
{"Saturation", Exiv2::saturation},
|
||||
{"Sharpness", Exiv2::sharpness},
|
||||
{"Contrast", Exiv2::contrast},
|
||||
{"Scene capture type", Exiv2::sceneCaptureType},
|
||||
{"Metering mode", Exiv2::meteringMode},
|
||||
{"Camera make", Exiv2::make},
|
||||
{"Camera model", Exiv2::model},
|
||||
{"Exposure time", Exiv2::exposureTime},
|
||||
{"FNumber", Exiv2::fNumber},
|
||||
{"Shutter speed value", Exiv2::shutterSpeedValue},
|
||||
{"Aperture value", Exiv2::apertureValue},
|
||||
{"Brightness value", Exiv2::brightnessValue},
|
||||
{"Exposure bias", Exiv2::exposureBiasValue},
|
||||
{"Max aperture value", Exiv2::maxApertureValue},
|
||||
{"Subject distance", Exiv2::subjectDistance},
|
||||
{"Light source", Exiv2::lightSource},
|
||||
{"Flash", Exiv2::flash},
|
||||
{"Camera serial number", Exiv2::serialNumber},
|
||||
{"Focal length", Exiv2::focalLength},
|
||||
{"Subject location/area", Exiv2::subjectArea},
|
||||
{"Flash energy", Exiv2::flashEnergy},
|
||||
{"Exposure index", Exiv2::exposureIndex},
|
||||
{"Sensing method", Exiv2::sensingMethod},
|
||||
{"AF point", Exiv2::afPoint},
|
||||
};
|
||||
|
||||
static const EasyAccess easyAccess[] = {{"Orientation", Exiv2::orientation},
|
||||
{"ISO speed", Exiv2::isoSpeed},
|
||||
{"Date & time original", Exiv2::dateTimeOriginal},
|
||||
{"Flash bias", Exiv2::flashBias},
|
||||
{"Exposure mode", Exiv2::exposureMode},
|
||||
{"Scene mode", Exiv2::sceneMode},
|
||||
{"Macro mode", Exiv2::macroMode},
|
||||
{"Image quality", Exiv2::imageQuality},
|
||||
{"White balance", Exiv2::whiteBalance},
|
||||
{"Lens name", Exiv2::lensName},
|
||||
{"Saturation", Exiv2::saturation},
|
||||
{"Sharpness", Exiv2::sharpness},
|
||||
{"Contrast", Exiv2::contrast},
|
||||
{"Scene capture type", Exiv2::sceneCaptureType},
|
||||
{"Metering mode", Exiv2::meteringMode},
|
||||
{"Camera make", Exiv2::make},
|
||||
{"Camera model", Exiv2::model},
|
||||
{"Exposure time", Exiv2::exposureTime},
|
||||
{"FNumber", Exiv2::fNumber},
|
||||
{"Shutter speed value", Exiv2::shutterSpeedValue},
|
||||
{"Aperture value", Exiv2::apertureValue},
|
||||
{"Brightness value", Exiv2::brightnessValue},
|
||||
{"Exposure bias", Exiv2::exposureBiasValue},
|
||||
{"Max aperture value", Exiv2::maxApertureValue},
|
||||
{"Subject distance", Exiv2::subjectDistance},
|
||||
{"Light source", Exiv2::lightSource},
|
||||
{"Flash", Exiv2::flash},
|
||||
{"Camera serial number", Exiv2::serialNumber},
|
||||
{"Focal length", Exiv2::focalLength},
|
||||
{"Subject location/area", Exiv2::subjectArea},
|
||||
{"Flash energy", Exiv2::flashEnergy},
|
||||
{"Exposure index", Exiv2::exposureIndex},
|
||||
{"Sensing method", Exiv2::sensingMethod},
|
||||
{"AF point", Exiv2::afPoint}};
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
try {
|
||||
Exiv2::XmpParser::initialize();
|
||||
@ -64,9 +62,9 @@ int main(int argc, char** argv) {
|
||||
image->readMetadata();
|
||||
Exiv2::ExifData& ed = image->exifData();
|
||||
|
||||
for (auto&& ea : easyAccess) {
|
||||
auto pos = ea.findFct_(ed);
|
||||
std::cout << std::setw(21) << std::left << ea.label_;
|
||||
for (auto&& [label, fct] : easyAccess) {
|
||||
auto pos = fct(ed);
|
||||
std::cout << std::setw(21) << std::left << label;
|
||||
if (pos != ed.end()) {
|
||||
std::cout << " (" << std::setw(35) << pos->key() << ") : " << pos->print(&ed) << "\n";
|
||||
} else {
|
||||
|
||||
@ -52,7 +52,7 @@ int main(int argc, char* const argv[]) {
|
||||
const Exiv2::byte* record;
|
||||
uint32_t sizeHdr = 0;
|
||||
uint32_t sizeData = 0;
|
||||
Exiv2::Photoshop::locateIptcIrb(irb.data(), irb.size(), &record, &sizeHdr, &sizeData);
|
||||
Exiv2::Photoshop::locateIptcIrb(irb.data(), irb.size(), &record, sizeHdr, sizeData);
|
||||
Exiv2::DataBuf rawIptc = Exiv2::IptcParser::encode(iptcData);
|
||||
std::cout << "Comparing IPTC and IRB size... ";
|
||||
if (static_cast<uint32_t>(rawIptc.size()) != sizeData) {
|
||||
|
||||
@ -153,7 +153,7 @@ std::string BmffImage::uuidName(Exiv2::DataBuf& uuid) {
|
||||
}
|
||||
|
||||
long BmffImage::boxHandler(std::ostream& out /* = std::cout*/, Exiv2::PrintStructureOption option /* = kpsNone */,
|
||||
const long pbox_end, int depth) {
|
||||
long pbox_end, int depth) {
|
||||
long address = io_->tell();
|
||||
// never visit a box twice!
|
||||
if (depth == 0)
|
||||
|
||||
@ -363,8 +363,8 @@ int IptcParser::decode(IptcData& iptcData, const byte* pData, size_t size) {
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
std::cerr << "IptcParser::decode, size = " << size << "\n";
|
||||
#endif
|
||||
const byte* pRead = pData;
|
||||
const byte* const pEnd = pData + size;
|
||||
auto pRead = pData;
|
||||
const auto pEnd = pData + size;
|
||||
iptcData.clear();
|
||||
|
||||
uint16_t record = 0;
|
||||
|
||||
@ -264,7 +264,7 @@ void JpegBase::readMetadata() {
|
||||
uint32_t sizeHdr = 0;
|
||||
const byte* pCur = &psBlob[0];
|
||||
const byte* pEnd = pCur + psBlob.size();
|
||||
while (pCur < pEnd && 0 == Photoshop::locateIptcIrb(pCur, pEnd - pCur, &record, &sizeHdr, &sizeIptc)) {
|
||||
while (pCur < pEnd && 0 == Photoshop::locateIptcIrb(pCur, pEnd - pCur, &record, sizeHdr, sizeIptc)) {
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
std::cerr << "Found IPTC IRB, size = " << sizeIptc << "\n";
|
||||
#endif
|
||||
|
||||
@ -37,7 +37,7 @@ namespace fs = std::filesystem;
|
||||
namespace {
|
||||
// Todo: Can be generalized further - get any tag as a string/long/...
|
||||
//! Get the Value for a tag within a particular group
|
||||
const Exiv2::Value* getExifValue(Exiv2::Internal::TiffComponent* const pRoot, const uint16_t& tag,
|
||||
const Exiv2::Value* getExifValue(Exiv2::Internal::TiffComponent* pRoot, const uint16_t& tag,
|
||||
const Exiv2::Internal::IfdId& group);
|
||||
//! Get the model name from tag Exif.Image.Model
|
||||
std::string getExifModel(Exiv2::Internal::TiffComponent* pRoot);
|
||||
@ -884,7 +884,7 @@ constexpr auto nikonArrayIdx = std::array{
|
||||
NikonArrayIdx{0x00b7, "0101", 84, 1, NA}, // tag 0xb7 in sample image metadata for each version
|
||||
};
|
||||
|
||||
int nikonSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* const /*pRoot*/) {
|
||||
int nikonSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* /*pRoot*/) {
|
||||
if (size < 4)
|
||||
return -1;
|
||||
|
||||
@ -896,7 +896,7 @@ int nikonSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* c
|
||||
return it->idx_;
|
||||
}
|
||||
|
||||
DataBuf nikonCrypt(uint16_t tag, const byte* pData, size_t size, TiffComponent* const pRoot) {
|
||||
DataBuf nikonCrypt(uint16_t tag, const byte* pData, size_t size, TiffComponent* pRoot) {
|
||||
DataBuf buf;
|
||||
|
||||
if (size < 4)
|
||||
@ -938,7 +938,7 @@ DataBuf nikonCrypt(uint16_t tag, const byte* pData, size_t size, TiffComponent*
|
||||
return buf;
|
||||
}
|
||||
|
||||
int sonyCsSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* const pRoot) {
|
||||
int sonyCsSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* pRoot) {
|
||||
std::string model = getExifModel(pRoot);
|
||||
if (model.empty())
|
||||
return -1;
|
||||
@ -948,7 +948,7 @@ int sonyCsSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, Tif
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
int sony2010eSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* const pRoot) {
|
||||
int sony2010eSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* pRoot) {
|
||||
static constexpr auto models = std::array{
|
||||
"SLT-A58", "SLT-A99", "ILCE-3000", "ILCE-3500", "NEX-3N", "NEX-5R", "NEX-5T",
|
||||
"NEX-6", "VG30E", "VG900", "DSC-RX100", "DSC-RX1", "DSC-RX1R", "DSC-HX300",
|
||||
@ -957,14 +957,14 @@ int sony2010eSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/,
|
||||
return std::find(models.begin(), models.end(), getExifModel(pRoot)) != models.end() ? 0 : -1;
|
||||
}
|
||||
|
||||
int sony2FpSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* const pRoot) {
|
||||
int sony2FpSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* pRoot) {
|
||||
// Not valid for models beginning
|
||||
std::string model = getExifModel(pRoot);
|
||||
const std::array strs{"SLT-", "HV", "ILCA-"};
|
||||
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*/, size_t /*size*/, TiffComponent* const pRoot) {
|
||||
int sonyMisc2bSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* 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)
|
||||
|
||||
@ -991,7 +991,7 @@ int sonyMisc2bSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/,
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
int sonyMisc3cSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* const pRoot) {
|
||||
int sonyMisc3cSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/, TiffComponent* 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
|
||||
|
||||
@ -1023,7 +1023,7 @@ int sonyMisc3cSelector(uint16_t /*tag*/, const byte* /*pData*/, size_t /*size*/,
|
||||
// *****************************************************************************
|
||||
// local definitions
|
||||
namespace {
|
||||
const Exiv2::Value* getExifValue(Exiv2::Internal::TiffComponent* const pRoot, const uint16_t& tag,
|
||||
const Exiv2::Value* getExifValue(Exiv2::Internal::TiffComponent* pRoot, const uint16_t& tag,
|
||||
const Exiv2::Internal::IfdId& group) {
|
||||
Exiv2::Internal::TiffFinder finder(tag, group);
|
||||
if (!pRoot)
|
||||
@ -1033,7 +1033,7 @@ const Exiv2::Value* getExifValue(Exiv2::Internal::TiffComponent* const pRoot, co
|
||||
return (!te || !te->pValue()) ? nullptr : te->pValue();
|
||||
}
|
||||
|
||||
std::string getExifModel(Exiv2::Internal::TiffComponent* const pRoot) {
|
||||
std::string getExifModel(Exiv2::Internal::TiffComponent* pRoot) {
|
||||
// Lookup the Exif.Image.Model tag
|
||||
const auto value = getExifValue(pRoot, 0x0110, Exiv2::Internal::ifd0Id);
|
||||
return (!value || value->count() == 0) ? std::string("") : std::string(value->toString());
|
||||
|
||||
@ -8,6 +8,8 @@
|
||||
#include "tags_int.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
#include <functional>
|
||||
|
||||
// namespace extensions
|
||||
namespace Exiv2::Internal {
|
||||
class IoWrapper;
|
||||
@ -28,11 +30,10 @@ std::string readExiv2Config(const std::string& section, const std::string& value
|
||||
// class definitions
|
||||
|
||||
//! Type for a pointer to a function creating a makernote (image)
|
||||
using NewMnFct = TiffComponent* (*)(uint16_t tag, IfdId group, IfdId mnGroup, const byte* pData, size_t size,
|
||||
ByteOrder byteOrder);
|
||||
using NewMnFct = std::function<TiffComponent*(uint16_t, IfdId, IfdId, const byte*, size_t, ByteOrder)>;
|
||||
|
||||
//! Type for a pointer to a function creating a makernote (group)
|
||||
using NewMnFct2 = TiffComponent* (*)(uint16_t tag, IfdId group, IfdId mnGroup);
|
||||
using NewMnFct2 = std::function<TiffComponent*(uint16_t tag, IfdId group, IfdId mnGroup)>;
|
||||
|
||||
//! Makernote registry structure
|
||||
struct TiffMnRegistry {
|
||||
@ -622,7 +623,7 @@ TiffComponent* newCasio2Mn2(uint16_t tag, IfdId group, IfdId mnGroup);
|
||||
@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, size_t size, TiffComponent* const pRoot);
|
||||
int sonyCsSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* pRoot);
|
||||
|
||||
/*!
|
||||
@brief Function to select cfg + def of the Sony 2010 Miscellaneous Information complex binary array.
|
||||
@ -633,7 +634,7 @@ int sonyCsSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent*
|
||||
@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, size_t size, TiffComponent* const pRoot);
|
||||
int sony2010eSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* pRoot);
|
||||
|
||||
/*!
|
||||
@brief Function to select cfg + def of the Sony2Fp (tag 9402) complex binary array.
|
||||
@ -644,7 +645,7 @@ int sony2010eSelector(uint16_t tag, const byte* pData, size_t size, TiffComponen
|
||||
@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, size_t size, TiffComponent* const pRoot);
|
||||
int sony2FpSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* pRoot);
|
||||
|
||||
/*!
|
||||
@brief Function to select cfg + def of the SonyMisc2b (tag 9404b) complex binary array.
|
||||
@ -655,7 +656,7 @@ int sony2FpSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent*
|
||||
@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, size_t size, TiffComponent* const pRoot);
|
||||
int sonyMisc2bSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* pRoot);
|
||||
|
||||
/*!
|
||||
@brief Function to select cfg + def of the SonyMisc3c (tag 9400) complex binary array.
|
||||
@ -666,7 +667,7 @@ int sonyMisc2bSelector(uint16_t tag, const byte* pData, size_t size, TiffCompone
|
||||
@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, size_t size, TiffComponent* const pRoot);
|
||||
int sonyMisc3cSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* pRoot);
|
||||
|
||||
/*!
|
||||
@brief Function to select cfg + def of a Nikon complex binary array.
|
||||
@ -677,7 +678,7 @@ int sonyMisc3cSelector(uint16_t tag, const byte* pData, size_t size, TiffCompone
|
||||
@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, size_t size, TiffComponent* const pRoot);
|
||||
int nikonSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* pRoot);
|
||||
|
||||
/*!
|
||||
@brief Encrypt and decrypt Nikon data.
|
||||
@ -695,7 +696,7 @@ int nikonSelector(uint16_t tag, const byte* pData, size_t size, TiffComponent* c
|
||||
@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, size_t size, TiffComponent* const pRoot);
|
||||
DataBuf nikonCrypt(uint16_t tag, const byte* pData, size_t size, TiffComponent* pRoot);
|
||||
|
||||
} // namespace Exiv2::Internal
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ bool Photoshop::valid(const byte* pPsData, size_t sizePsData) {
|
||||
const byte* pCur = pPsData;
|
||||
const byte* pEnd = pPsData + sizePsData;
|
||||
int ret = 0;
|
||||
while (pCur < pEnd && 0 == (ret = Photoshop::locateIptcIrb(pCur, (pEnd - pCur), &record, &sizeHdr, &sizeIptc))) {
|
||||
while (pCur < pEnd && 0 == (ret = Photoshop::locateIptcIrb(pCur, (pEnd - pCur), &record, sizeHdr, sizeIptc))) {
|
||||
pCur = record + sizeHdr + sizeIptc + (sizeIptc & 1);
|
||||
}
|
||||
return ret >= 0;
|
||||
@ -31,8 +31,8 @@ bool Photoshop::valid(const byte* pPsData, size_t sizePsData) {
|
||||
// Todo: Generalised from JpegBase::locateIptcData without really understanding
|
||||
// the format (in particular the header). So it remains to be confirmed
|
||||
// if this also makes sense for psTag != Photoshop::iptc
|
||||
int Photoshop::locateIrb(const byte* pPsData, size_t sizePsData, uint16_t psTag, const byte** record,
|
||||
uint32_t* const sizeHdr, uint32_t* const sizeData) {
|
||||
int Photoshop::locateIrb(const byte* pPsData, size_t sizePsData, uint16_t psTag, const byte** record, uint32_t& sizeHdr,
|
||||
uint32_t& sizeData) {
|
||||
if (sizePsData < 12) {
|
||||
return 3;
|
||||
}
|
||||
@ -81,8 +81,8 @@ int Photoshop::locateIrb(const byte* pPsData, size_t sizePsData, uint16_t psTag,
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
std::cerr << "ok\n";
|
||||
#endif
|
||||
*sizeData = dataSize;
|
||||
*sizeHdr = psSize + 10;
|
||||
sizeData = dataSize;
|
||||
sizeHdr = psSize + 10;
|
||||
*record = hrd;
|
||||
return 0;
|
||||
}
|
||||
@ -102,13 +102,13 @@ int Photoshop::locateIrb(const byte* pPsData, size_t sizePsData, uint16_t psTag,
|
||||
return 3;
|
||||
}
|
||||
|
||||
int Photoshop::locateIptcIrb(const byte* pPsData, size_t sizePsData, const byte** record, uint32_t* const sizeHdr,
|
||||
uint32_t* const sizeData) {
|
||||
int Photoshop::locateIptcIrb(const byte* pPsData, size_t sizePsData, const byte** record, uint32_t& sizeHdr,
|
||||
uint32_t& sizeData) {
|
||||
return locateIrb(pPsData, sizePsData, iptc_, record, sizeHdr, sizeData);
|
||||
}
|
||||
|
||||
int Photoshop::locatePreviewIrb(const byte* pPsData, size_t sizePsData, const byte** record, uint32_t* const sizeHdr,
|
||||
uint32_t* const sizeData) {
|
||||
int Photoshop::locatePreviewIrb(const byte* pPsData, size_t sizePsData, const byte** record, uint32_t& sizeHdr,
|
||||
uint32_t& sizeData) {
|
||||
return locateIrb(pPsData, sizePsData, preview_, record, sizeHdr, sizeData);
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ DataBuf Photoshop::setIptcIrb(const byte* pPsData, size_t sizePsData, const Iptc
|
||||
uint32_t sizeIptc = 0;
|
||||
uint32_t sizeHdr = 0;
|
||||
DataBuf rc;
|
||||
if (0 > Photoshop::locateIptcIrb(pPsData, sizePsData, &record, &sizeHdr, &sizeIptc)) {
|
||||
if (0 > Photoshop::locateIptcIrb(pPsData, sizePsData, &record, sizeHdr, sizeIptc)) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -153,9 +153,9 @@ DataBuf Photoshop::setIptcIrb(const byte* pPsData, size_t sizePsData, const Iptc
|
||||
|
||||
// Write existing stuff after record, skip the current and all remaining IPTC blocks
|
||||
size_t pos = sizeFront;
|
||||
long nextSizeData = Safe::add<long>(static_cast<long>(sizePsData), -static_cast<long>(pos));
|
||||
auto nextSizeData = Safe::add<long>(static_cast<long>(sizePsData), -static_cast<long>(pos));
|
||||
enforce(nextSizeData >= 0, ErrorCode::kerCorruptedMetadata);
|
||||
while (0 == Photoshop::locateIptcIrb(pPsData + pos, nextSizeData, &record, &sizeHdr, &sizeIptc)) {
|
||||
while (0 == Photoshop::locateIptcIrb(pPsData + pos, nextSizeData, &record, sizeHdr, sizeIptc)) {
|
||||
const auto newPos = static_cast<size_t>(record - pPsData);
|
||||
if (newPos > pos) { // Copy data up to the IPTC IRB
|
||||
append(psBlob, pPsData + pos, newPos - pos);
|
||||
|
||||
@ -235,7 +235,7 @@ void PngChunk::parseChunkContent(Image* pImage, const byte* key, size_t keySize,
|
||||
|
||||
const byte* pEnd = psData.c_data(psData.size() - 1);
|
||||
const byte* pCur = psData.c_data();
|
||||
while (pCur < pEnd && 0 == Photoshop::locateIptcIrb(pCur, pEnd - pCur, &record, &sizeHdr, &sizeIptc)) {
|
||||
while (pCur < pEnd && 0 == Photoshop::locateIptcIrb(pCur, pEnd - pCur, &record, sizeHdr, sizeIptc)) {
|
||||
if (sizeIptc) {
|
||||
#ifdef EXIV2_DEBUG_MESSAGES
|
||||
std::cerr << "Found IPTC IRB, size = " << sizeIptc << "\n";
|
||||
|
||||
@ -419,7 +419,7 @@ DataBuf LoaderNative::getData() const {
|
||||
const byte* record;
|
||||
uint32_t sizeHdr = 0;
|
||||
uint32_t sizeData = 0;
|
||||
if (Photoshop::locatePreviewIrb(psData.c_data(), psData.size(), &record, &sizeHdr, &sizeData) != 0) {
|
||||
if (Photoshop::locatePreviewIrb(psData.c_data(), psData.size(), &record, sizeHdr, sizeData) != 0) {
|
||||
#ifndef SUPPRESS_WARNINGS
|
||||
EXV_WARNING << "Missing preview IRB in Photoshop EPS preview.\n";
|
||||
#endif
|
||||
|
||||
@ -1046,7 +1046,7 @@ const TagInfo* SonyMakerNote::tagList2010e() {
|
||||
}
|
||||
|
||||
// https://github.com/Exiv2/exiv2/pull/906#issuecomment-504338797
|
||||
static DataBuf sonyTagCipher(uint16_t /* tag */, const byte* bytes, size_t size, TiffComponent* const /*object*/,
|
||||
static DataBuf sonyTagCipher(uint16_t /* tag */, const byte* bytes, size_t size, TiffComponent* /*object*/,
|
||||
bool bDecipher) {
|
||||
DataBuf b(bytes, size); // copy the data
|
||||
|
||||
@ -1071,10 +1071,10 @@ static DataBuf sonyTagCipher(uint16_t /* tag */, const byte* bytes, size_t size,
|
||||
return b;
|
||||
}
|
||||
|
||||
DataBuf sonyTagDecipher(uint16_t tag, const byte* bytes, size_t size, TiffComponent* const object) {
|
||||
DataBuf sonyTagDecipher(uint16_t tag, const byte* bytes, size_t size, TiffComponent* object) {
|
||||
return sonyTagCipher(tag, bytes, size, object, true);
|
||||
}
|
||||
DataBuf sonyTagEncipher(uint16_t tag, const byte* bytes, size_t size, TiffComponent* const object) {
|
||||
DataBuf sonyTagEncipher(uint16_t tag, const byte* bytes, size_t size, TiffComponent* object) {
|
||||
return sonyTagCipher(tag, bytes, size, object, false);
|
||||
}
|
||||
|
||||
|
||||
@ -78,8 +78,8 @@ class SonyMakerNote {
|
||||
|
||||
}; // class SonyMakerNote
|
||||
|
||||
DataBuf sonyTagDecipher(uint16_t, const byte*, size_t, TiffComponent* const);
|
||||
DataBuf sonyTagEncipher(uint16_t, const byte*, size_t, TiffComponent* const);
|
||||
DataBuf sonyTagDecipher(uint16_t, const byte*, size_t, TiffComponent*);
|
||||
DataBuf sonyTagEncipher(uint16_t, const byte*, size_t, TiffComponent*);
|
||||
|
||||
} // namespace Exiv2::Internal
|
||||
|
||||
|
||||
@ -395,7 +395,7 @@ bool TiffBinaryArray::initialize(IfdId group) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TiffBinaryArray::initialize(TiffComponent* const pRoot) {
|
||||
bool TiffBinaryArray::initialize(TiffComponent* pRoot) {
|
||||
if (!cfgSelFct_)
|
||||
return true; // Not a complex array
|
||||
|
||||
@ -437,17 +437,17 @@ uint32_t TiffBinaryArray::addElement(uint32_t idx, const ArrayDef& def) {
|
||||
return sz;
|
||||
} // TiffBinaryArray::addElement
|
||||
|
||||
TiffComponent* TiffComponent::addPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
|
||||
TiffComponent* TiffComponent::addPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* pRoot,
|
||||
TiffComponent::UniquePtr object) {
|
||||
return doAddPath(tag, tiffPath, pRoot, std::move(object));
|
||||
} // TiffComponent::addPath
|
||||
|
||||
TiffComponent* TiffComponent::doAddPath(uint16_t /*tag*/, TiffPath& /*tiffPath*/, TiffComponent* const /*pRoot*/,
|
||||
TiffComponent* TiffComponent::doAddPath(uint16_t /*tag*/, TiffPath& /*tiffPath*/, TiffComponent* /*pRoot*/,
|
||||
TiffComponent::UniquePtr /*object*/) {
|
||||
return this;
|
||||
} // TiffComponent::doAddPath
|
||||
|
||||
TiffComponent* TiffDirectory::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
|
||||
TiffComponent* TiffDirectory::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* pRoot,
|
||||
TiffComponent::UniquePtr object) {
|
||||
tiffPath.pop();
|
||||
const TiffPathItem tpi = tiffPath.top();
|
||||
@ -491,7 +491,7 @@ TiffComponent* TiffDirectory::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffCo
|
||||
return tc->addPath(tag, tiffPath, pRoot, std::move(object));
|
||||
} // TiffDirectory::doAddPath
|
||||
|
||||
TiffComponent* TiffSubIfd::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
|
||||
TiffComponent* TiffSubIfd::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* pRoot,
|
||||
TiffComponent::UniquePtr object) {
|
||||
const TiffPathItem tpi1 = tiffPath.top();
|
||||
tiffPath.pop();
|
||||
@ -520,7 +520,7 @@ TiffComponent* TiffSubIfd::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffCompo
|
||||
return tc->addPath(tag, tiffPath, pRoot, std::move(object));
|
||||
} // TiffSubIfd::doAddPath
|
||||
|
||||
TiffComponent* TiffMnEntry::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
|
||||
TiffComponent* TiffMnEntry::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* pRoot,
|
||||
TiffComponent::UniquePtr object) {
|
||||
const TiffPathItem tpi1 = tiffPath.top();
|
||||
tiffPath.pop();
|
||||
@ -537,12 +537,12 @@ TiffComponent* TiffMnEntry::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComp
|
||||
return mn_->addPath(tag, tiffPath, pRoot, std::move(object));
|
||||
} // TiffMnEntry::doAddPath
|
||||
|
||||
TiffComponent* TiffIfdMakernote::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
|
||||
TiffComponent* TiffIfdMakernote::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* pRoot,
|
||||
TiffComponent::UniquePtr object) {
|
||||
return ifd_.addPath(tag, tiffPath, pRoot, std::move(object));
|
||||
}
|
||||
|
||||
TiffComponent* TiffBinaryArray::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
|
||||
TiffComponent* TiffBinaryArray::doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* pRoot,
|
||||
TiffComponent::UniquePtr object) {
|
||||
pRoot_ = pRoot;
|
||||
if (tiffPath.size() == 1) {
|
||||
@ -1138,7 +1138,7 @@ uint32_t TiffBinaryArray::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int
|
||||
|
||||
uint32_t TiffBinaryElement::doWrite(IoWrapper& ioWrapper, ByteOrder byteOrder, int64_t /*offset*/,
|
||||
uint32_t /*valueIdx*/, uint32_t /*dataIdx*/, uint32_t& /*imageIdx*/) {
|
||||
Value const* pv = pValue();
|
||||
auto pv = pValue();
|
||||
if (!pv || pv->count() == 0)
|
||||
return 0;
|
||||
DataBuf buf(pv->size());
|
||||
@ -1511,13 +1511,13 @@ TiffType toTiffType(TypeId typeId) {
|
||||
return static_cast<uint16_t>(typeId);
|
||||
}
|
||||
|
||||
bool cmpTagLt(TiffComponent const* lhs, TiffComponent const* rhs) {
|
||||
bool cmpTagLt(const TiffComponent* lhs, const TiffComponent* rhs) {
|
||||
if (lhs->tag() != rhs->tag())
|
||||
return lhs->tag() < rhs->tag();
|
||||
return lhs->idx() < rhs->idx();
|
||||
}
|
||||
|
||||
bool cmpGroupLt(TiffComponent const* lhs, TiffComponent const* rhs) {
|
||||
bool cmpGroupLt(const TiffComponent* lhs, const TiffComponent* rhs) {
|
||||
return lhs->group() < rhs->group();
|
||||
}
|
||||
|
||||
|
||||
@ -178,7 +178,7 @@ class TiffComponent {
|
||||
|
||||
@return A pointer to the newly added TIFF entry.
|
||||
*/
|
||||
TiffComponent* addPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot, UniquePtr object = nullptr);
|
||||
TiffComponent* addPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* pRoot, UniquePtr object = nullptr);
|
||||
/*!
|
||||
@brief Add a child to the component. Default is to do nothing.
|
||||
@param tiffComponent Auto pointer to the component to add.
|
||||
@ -293,7 +293,7 @@ class TiffComponent {
|
||||
//! @name Protected Manipulators
|
||||
//@{
|
||||
//! Implements addPath(). The default implementation does nothing.
|
||||
virtual TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
|
||||
virtual TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* pRoot,
|
||||
TiffComponent::UniquePtr object);
|
||||
//! Implements addChild(). The default implementation does nothing.
|
||||
virtual TiffComponent* doAddChild(UniquePtr tiffComponent);
|
||||
@ -382,7 +382,7 @@ struct TiffMappingInfo::Key {
|
||||
class TiffEntryBase : public TiffComponent {
|
||||
friend class TiffReader;
|
||||
friend class TiffEncoder;
|
||||
friend int selectNikonLd(TiffBinaryArray* const, TiffComponent* const);
|
||||
friend int selectNikonLd(TiffBinaryArray*, TiffComponent*);
|
||||
|
||||
public:
|
||||
//! @name Creators
|
||||
@ -869,7 +869,7 @@ class TiffDirectory : public TiffComponent {
|
||||
|
||||
//! @name Protected Manipulators
|
||||
//@{
|
||||
TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
|
||||
TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* pRoot,
|
||||
TiffComponent::UniquePtr object) override;
|
||||
TiffComponent* doAddChild(TiffComponent::UniquePtr tiffComponent) override;
|
||||
TiffComponent* doAddNext(TiffComponent::UniquePtr tiffComponent) override;
|
||||
@ -965,7 +965,7 @@ class TiffSubIfd : public TiffEntryBase {
|
||||
protected:
|
||||
//! @name Protected Manipulators
|
||||
//@{
|
||||
TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
|
||||
TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* pRoot,
|
||||
TiffComponent::UniquePtr object) override;
|
||||
TiffComponent* doAddChild(TiffComponent::UniquePtr tiffComponent) override;
|
||||
void doAccept(TiffVisitor& visitor) override;
|
||||
@ -1043,7 +1043,7 @@ class TiffMnEntry : public TiffEntryBase {
|
||||
protected:
|
||||
//! @name Protected Manipulators
|
||||
//@{
|
||||
TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
|
||||
TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* pRoot,
|
||||
TiffComponent::UniquePtr object) override;
|
||||
TiffComponent* doAddChild(TiffComponent::UniquePtr tiffComponent) override;
|
||||
TiffComponent* doAddNext(TiffComponent::UniquePtr tiffComponent) override;
|
||||
@ -1176,7 +1176,7 @@ class TiffIfdMakernote : public TiffComponent {
|
||||
protected:
|
||||
//! @name Protected Manipulators
|
||||
//@{
|
||||
TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
|
||||
TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* pRoot,
|
||||
TiffComponent::UniquePtr object) override;
|
||||
TiffComponent* doAddChild(TiffComponent::UniquePtr tiffComponent) override;
|
||||
TiffComponent* doAddNext(TiffComponent::UniquePtr tiffComponent) override;
|
||||
@ -1240,10 +1240,10 @@ class TiffIfdMakernote : public TiffComponent {
|
||||
@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*, size_t, TiffComponent* const);
|
||||
using CfgSelFct = int (*)(uint16_t, const byte*, size_t, TiffComponent*);
|
||||
|
||||
//! Function pointer type for a crypt function used for binary arrays.
|
||||
using CryptFct = DataBuf (*)(uint16_t, const byte*, size_t, TiffComponent* const);
|
||||
using CryptFct = DataBuf (*)(uint16_t, const byte*, size_t, TiffComponent*);
|
||||
|
||||
//! Defines one tag in a binary array
|
||||
struct ArrayDef {
|
||||
@ -1330,7 +1330,7 @@ class TiffBinaryArray : public TiffEntryBase {
|
||||
@param pRoot Pointer to the root component of the TIFF tree.
|
||||
@return true if the initialization succeeded, else false.
|
||||
*/
|
||||
bool initialize(TiffComponent* const pRoot);
|
||||
bool initialize(TiffComponent* pRoot);
|
||||
//! 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.
|
||||
@ -1373,7 +1373,7 @@ class TiffBinaryArray : public TiffEntryBase {
|
||||
/*!
|
||||
@brief Implements addPath(). Todo: Document it!
|
||||
*/
|
||||
TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* const pRoot,
|
||||
TiffComponent* doAddPath(uint16_t tag, TiffPath& tiffPath, TiffComponent* pRoot,
|
||||
TiffComponent::UniquePtr object) override;
|
||||
/*!
|
||||
@brief Implements addChild(). Todo: Document it!
|
||||
@ -1508,13 +1508,13 @@ class TiffBinaryElement : public TiffEntryBase {
|
||||
@brief Compare two TIFF component pointers by tag. Return true if the tag
|
||||
of component lhs is less than that of rhs.
|
||||
*/
|
||||
bool cmpTagLt(TiffComponent const* lhs, TiffComponent const* rhs);
|
||||
bool cmpTagLt(const TiffComponent* lhs, const TiffComponent* rhs);
|
||||
|
||||
/*!
|
||||
@brief Compare two TIFF component pointers by group. Return true if the
|
||||
group of component lhs is less than that of rhs.
|
||||
*/
|
||||
bool cmpGroupLt(TiffComponent const* lhs, TiffComponent const* rhs);
|
||||
bool cmpGroupLt(const TiffComponent* lhs, const TiffComponent* rhs);
|
||||
|
||||
//! Function to create and initialize a new TIFF entry
|
||||
TiffComponent::UniquePtr newTiffEntry(uint16_t tag, IfdId group);
|
||||
@ -1538,10 +1538,9 @@ 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, int N, const ArrayDef arrayDef[N]>
|
||||
TiffComponent::UniquePtr newTiffBinaryArray0(uint16_t tag, IfdId group) {
|
||||
// *& acrobatics is a workaround for a MSVC 7.1 bug
|
||||
return TiffComponent::UniquePtr(new TiffBinaryArray(tag, group, arrayCfg, *(&arrayDef), N));
|
||||
return TiffComponent::UniquePtr(new TiffBinaryArray(tag, group, arrayCfg, arrayDef, N));
|
||||
}
|
||||
|
||||
//! Function to create and initialize a new simple binary array entry
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#include "types.hpp"
|
||||
|
||||
// + standard includes
|
||||
#include <functional>
|
||||
#include <stack>
|
||||
|
||||
// *****************************************************************************
|
||||
@ -61,17 +62,17 @@ using EncoderFct = void (TiffEncoder::*)(TiffEntryBase*, const Exifdatum*);
|
||||
/*!
|
||||
@brief Type for a function pointer for a function to decode a TIFF component.
|
||||
*/
|
||||
using FindDecoderFct = DecoderFct (*)(const std::string& make, uint32_t extendedTag, IfdId group);
|
||||
using FindDecoderFct = std::function<DecoderFct(const std::string& make, uint32_t extendedTag, IfdId group)>;
|
||||
/*!
|
||||
@brief Type for a function pointer for a function to encode a TIFF component.
|
||||
*/
|
||||
using FindEncoderFct = EncoderFct (*)(const std::string& make, uint32_t extendedTag, IfdId group);
|
||||
using FindEncoderFct = std::function<EncoderFct(const std::string& make, uint32_t extendedTag, IfdId group)>;
|
||||
/*!
|
||||
@brief Type for a function pointer for a function to create a TIFF component.
|
||||
Use TiffComponent::UniquePtr, it is not used in this declaration only
|
||||
to reduce dependencies.
|
||||
*/
|
||||
using NewTiffCompFct = std::unique_ptr<TiffComponent> (*)(uint16_t tag, IfdId group);
|
||||
using NewTiffCompFct = std::function<std::unique_ptr<TiffComponent>(uint16_t tag, IfdId group)>;
|
||||
|
||||
//! Stack to hold a path from the TIFF root element to a TIFF entry
|
||||
using TiffPath = std::stack<TiffPathItem>;
|
||||
|
||||
@ -1848,7 +1848,7 @@ ByteOrder TiffParserWorker::decode(ExifData& exifData, IptcData& iptcData, XmpDa
|
||||
|
||||
auto rootDir = parse(pData, size, root, pHeader);
|
||||
if (rootDir) {
|
||||
TiffDecoder decoder(exifData, iptcData, xmpData, rootDir.get(), findDecoderFct);
|
||||
TiffDecoder decoder(exifData, iptcData, xmpData, rootDir.get(), std::move(findDecoderFct));
|
||||
rootDir->accept(decoder);
|
||||
}
|
||||
return pHeader->byteOrder();
|
||||
@ -1857,7 +1857,7 @@ ByteOrder TiffParserWorker::decode(ExifData& exifData, IptcData& iptcData, XmpDa
|
||||
|
||||
WriteMethod TiffParserWorker::encode(BasicIo& io, const byte* pData, size_t size, const ExifData& exifData,
|
||||
const IptcData& iptcData, const XmpData& xmpData, uint32_t root,
|
||||
FindEncoderFct findEncoderFct, TiffHeaderBase* pHeader,
|
||||
const FindEncoderFct& findEncoderFct, TiffHeaderBase* pHeader,
|
||||
OffsetWriter* pOffsetWriter) {
|
||||
/*
|
||||
1) parse the binary image, if one is provided, and
|
||||
|
||||
@ -263,7 +263,7 @@ class TiffParserWorker {
|
||||
*/
|
||||
static WriteMethod encode(BasicIo& io, const byte* pData, size_t size, const ExifData& exifData,
|
||||
const IptcData& iptcData, const XmpData& xmpData, uint32_t root,
|
||||
FindEncoderFct findEncoderFct, TiffHeaderBase* pHeader, OffsetWriter* pOffsetWriter);
|
||||
const FindEncoderFct& findEncoderFct, TiffHeaderBase* pHeader, OffsetWriter* pOffsetWriter);
|
||||
|
||||
private:
|
||||
/*!
|
||||
|
||||
@ -187,13 +187,13 @@ void TiffCopier::visitBinaryElement(TiffBinaryElement* object) {
|
||||
copyObject(object);
|
||||
}
|
||||
|
||||
TiffDecoder::TiffDecoder(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, TiffComponent* const pRoot,
|
||||
TiffDecoder::TiffDecoder(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, TiffComponent* pRoot,
|
||||
FindDecoderFct findDecoderFct) :
|
||||
exifData_(exifData),
|
||||
iptcData_(iptcData),
|
||||
xmpData_(xmpData),
|
||||
pRoot_(pRoot),
|
||||
findDecoderFct_(findDecoderFct),
|
||||
findDecoderFct_(std::move(findDecoderFct)),
|
||||
decodedIptc_(false) {
|
||||
// #1402 Fujifilm RAF. Search for the make
|
||||
// Find camera make in existing metadata (read from the JPEG)
|
||||
@ -254,7 +254,7 @@ void TiffDecoder::visitIfdMakernote(TiffIfdMakernote* object) {
|
||||
}
|
||||
}
|
||||
|
||||
void TiffDecoder::getObjData(byte const*& pData, size_t& size, uint16_t tag, IfdId group, const TiffEntryBase* object) {
|
||||
void TiffDecoder::getObjData(const byte*& pData, size_t& size, uint16_t tag, IfdId group, const TiffEntryBase* object) {
|
||||
if (object && object->tag() == tag && object->group() == group) {
|
||||
pData = object->pData();
|
||||
size = object->size();
|
||||
@ -262,7 +262,7 @@ void TiffDecoder::getObjData(byte const*& pData, size_t& size, uint16_t tag, Ifd
|
||||
}
|
||||
TiffFinder finder(tag, group);
|
||||
pRoot_->accept(finder);
|
||||
TiffEntryBase const* te = dynamic_cast<TiffEntryBase*>(finder.result());
|
||||
auto te = dynamic_cast<TiffEntryBase*>(finder.result());
|
||||
if (te) {
|
||||
pData = te->pData();
|
||||
size = te->size();
|
||||
@ -274,7 +274,7 @@ void TiffDecoder::decodeXmp(const TiffEntryBase* object) {
|
||||
// add Exif tag anyway
|
||||
decodeStdTiffEntry(object);
|
||||
|
||||
byte const* pData = nullptr;
|
||||
const byte* pData = nullptr;
|
||||
size_t size = 0;
|
||||
getObjData(pData, size, 0x02bc, ifd0Id, object);
|
||||
if (pData) {
|
||||
@ -307,7 +307,7 @@ void TiffDecoder::decodeIptc(const TiffEntryBase* object) {
|
||||
}
|
||||
decodedIptc_ = true;
|
||||
// 1st choice: IPTCNAA
|
||||
byte const* pData = nullptr;
|
||||
const byte* pData = nullptr;
|
||||
size_t size = 0;
|
||||
getObjData(pData, size, 0x83bb, ifd0Id, object);
|
||||
if (pData) {
|
||||
@ -327,10 +327,10 @@ void TiffDecoder::decodeIptc(const TiffEntryBase* object) {
|
||||
size = 0;
|
||||
getObjData(pData, size, 0x8649, ifd0Id, object);
|
||||
if (pData) {
|
||||
byte const* record = nullptr;
|
||||
const byte* record = nullptr;
|
||||
uint32_t sizeHdr = 0;
|
||||
uint32_t sizeData = 0;
|
||||
if (0 != Photoshop::locateIptcIrb(pData, size, &record, &sizeHdr, &sizeData)) {
|
||||
if (0 != Photoshop::locateIptcIrb(pData, size, &record, sizeHdr, sizeData)) {
|
||||
return;
|
||||
}
|
||||
if (0 == IptcParser::decode(iptcData_, record + sizeHdr, sizeData)) {
|
||||
@ -460,7 +460,7 @@ TiffEncoder::TiffEncoder(ExifData exifData, const IptcData& iptcData, const XmpD
|
||||
isNewImage_(isNewImage),
|
||||
pPrimaryGroups_(pPrimaryGroups),
|
||||
pSourceTree_(nullptr),
|
||||
findEncoderFct_(findEncoderFct),
|
||||
findEncoderFct_(std::move(findEncoderFct)),
|
||||
dirty_(false),
|
||||
writeMethod_(wmNonIntrusive) {
|
||||
byteOrder_ = pHeader->byteOrder();
|
||||
|
||||
@ -255,7 +255,7 @@ class TiffDecoder : public TiffVisitor {
|
||||
the root element of the composite to decode and a FindDecoderFct
|
||||
function to get the decoder function for each tag.
|
||||
*/
|
||||
TiffDecoder(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, TiffComponent* const pRoot,
|
||||
TiffDecoder(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, TiffComponent* pRoot,
|
||||
FindDecoderFct findDecoderFct);
|
||||
//! Virtual destructor
|
||||
~TiffDecoder() override = default;
|
||||
@ -307,17 +307,17 @@ class TiffDecoder : public TiffVisitor {
|
||||
Populates \em pData and \em size with the result. If no matching
|
||||
element is found the function leaves both of these parameters unchanged.
|
||||
*/
|
||||
void getObjData(byte const*& pData, size_t& size, uint16_t tag, IfdId group, const TiffEntryBase* object);
|
||||
void getObjData(const byte*& pData, size_t& size, uint16_t tag, IfdId group, const TiffEntryBase* object);
|
||||
//@}
|
||||
|
||||
// DATA
|
||||
ExifData& exifData_; //!< Exif metadata container
|
||||
IptcData& iptcData_; //!< IPTC metadata container
|
||||
XmpData& xmpData_; //!< XMP metadata container
|
||||
TiffComponent* const pRoot_; //!< Root element of the composite
|
||||
const FindDecoderFct findDecoderFct_; //!< Ptr to the function to find special decoding functions
|
||||
std::string make_; //!< Camera make, determined from the tags to decode
|
||||
bool decodedIptc_; //!< Indicates if IPTC has been decoded yet
|
||||
ExifData& exifData_; //!< Exif metadata container
|
||||
IptcData& iptcData_; //!< IPTC metadata container
|
||||
XmpData& xmpData_; //!< XMP metadata container
|
||||
TiffComponent* pRoot_; //!< Root element of the composite
|
||||
FindDecoderFct findDecoderFct_; //!< Ptr to the function to find special decoding functions
|
||||
std::string make_; //!< Camera make, determined from the tags to decode
|
||||
bool decodedIptc_; //!< Indicates if IPTC has been decoded yet
|
||||
|
||||
}; // class TiffDecoder
|
||||
|
||||
@ -346,7 +346,7 @@ class TiffEncoder : public TiffVisitor {
|
||||
find special encoders.
|
||||
*/
|
||||
TiffEncoder(ExifData exifData, const IptcData& iptcData, const XmpData& xmpData, TiffComponent* pRoot,
|
||||
const bool isNewImage, const PrimaryGroups* pPrimaryGroups, const TiffHeaderBase* pHeader,
|
||||
bool isNewImage, const PrimaryGroups* pPrimaryGroups, const TiffHeaderBase* pHeader,
|
||||
FindEncoderFct findEncoderFct);
|
||||
//! Virtual destructor
|
||||
~TiffEncoder() override = default;
|
||||
@ -659,18 +659,18 @@ class TiffReader : public TiffVisitor {
|
||||
using PostList = std::vector<TiffComponent*>;
|
||||
|
||||
// DATA
|
||||
const byte* pData_; //!< Pointer to the memory 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_)
|
||||
TiffRwState origState_; //!< State class as set in the c'tor
|
||||
TiffRwState mnState_; //!< State class as set in the c'tor or by setMnState()
|
||||
DirList dirList_; //!< List of IFD pointers and their groups
|
||||
IdxSeq idxSeq_; //!< Sequences for group, used for the entry's idx
|
||||
PostList postList_; //!< List of components with deferred reading
|
||||
bool postProc_; //!< True in postProcessList()
|
||||
}; // class TiffReader
|
||||
const byte* pData_; //!< Pointer to the memory buffer
|
||||
const size_t size_; //!< Size of the buffer
|
||||
const byte* pLast_; //!< Pointer to the last byte
|
||||
TiffComponent* pRoot_; //!< Root element of the composite
|
||||
TiffRwState* pState_; //!< Pointer to the state in effect (origState_ or mnState_)
|
||||
TiffRwState origState_; //!< State class as set in the c'tor
|
||||
TiffRwState mnState_; //!< State class as set in the c'tor or by setMnState()
|
||||
DirList dirList_; //!< List of IFD pointers and their groups
|
||||
IdxSeq idxSeq_; //!< Sequences for group, used for the entry's idx
|
||||
PostList postList_; //!< List of components with deferred reading
|
||||
bool postProc_; //!< True in postProcessList()
|
||||
}; // class TiffReader
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Exiv2
|
||||
|
||||
@ -41,7 +41,7 @@ TEST(Photoshop_locateIrb, returnsMinus2withInvalidPhotoshopIRB) {
|
||||
uint32_t sizeHdr = 0;
|
||||
uint32_t sizeData = 0;
|
||||
ASSERT_EQ(-2, Photoshop::locateIrb(reinterpret_cast<const byte*>(data.c_str()), data.size(), Photoshop::iptc_,
|
||||
&record, &sizeHdr, &sizeData));
|
||||
&record, sizeHdr, sizeData));
|
||||
}
|
||||
|
||||
TEST(Photoshop_locateIrb, returnsMinus2WithMarkerNotStartingWith8BIM) {
|
||||
@ -50,7 +50,7 @@ TEST(Photoshop_locateIrb, returnsMinus2WithMarkerNotStartingWith8BIM) {
|
||||
uint32_t sizeHdr = 0;
|
||||
uint32_t sizeData = 0;
|
||||
ASSERT_EQ(-2, Photoshop::locateIrb(reinterpret_cast<const byte*>(data.c_str()), data.size(), Photoshop::iptc_,
|
||||
&record, &sizeHdr, &sizeData));
|
||||
&record, sizeHdr, sizeData));
|
||||
}
|
||||
|
||||
TEST(Photoshop_locateIrb, returns3withNotLongEnoughData) {
|
||||
@ -59,7 +59,7 @@ TEST(Photoshop_locateIrb, returns3withNotLongEnoughData) {
|
||||
uint32_t sizeHdr = 0;
|
||||
uint32_t sizeData = 0;
|
||||
ASSERT_EQ(3, Photoshop::locateIrb(reinterpret_cast<const byte*>(data.c_str()), data.size(), Photoshop::iptc_, &record,
|
||||
&sizeHdr, &sizeData));
|
||||
sizeHdr, sizeData));
|
||||
}
|
||||
|
||||
TEST(Photoshop_locateIrb, returns0withGoodIptcIrb) {
|
||||
@ -75,7 +75,7 @@ TEST(Photoshop_locateIrb, returns0withGoodIptcIrb) {
|
||||
uint32_t sizeHdr = 0;
|
||||
uint32_t sizeData = 0;
|
||||
|
||||
ASSERT_EQ(0, Photoshop::locateIrb(data.data(), data.size(), Photoshop::iptc_, &record, &sizeHdr, &sizeData));
|
||||
ASSERT_EQ(0, Photoshop::locateIrb(data.data(), data.size(), Photoshop::iptc_, &record, sizeHdr, sizeData));
|
||||
ASSERT_EQ(12, sizeHdr);
|
||||
ASSERT_EQ(27, sizeData);
|
||||
}
|
||||
@ -93,7 +93,7 @@ TEST(Photoshop_locateIptcIrb, returns0withGoodIptcIrb) {
|
||||
uint32_t sizeHdr = 0;
|
||||
uint32_t sizeData = 0;
|
||||
|
||||
ASSERT_EQ(0, Photoshop::locateIptcIrb(data.data(), data.size(), &record, &sizeHdr, &sizeData));
|
||||
ASSERT_EQ(0, Photoshop::locateIptcIrb(data.data(), data.size(), &record, sizeHdr, sizeData));
|
||||
ASSERT_EQ(12, sizeHdr);
|
||||
ASSERT_EQ(27, sizeData);
|
||||
}
|
||||
@ -111,7 +111,7 @@ TEST(Photoshop_locateIptcIrb, returns3withoutIptcMarker) {
|
||||
uint32_t sizeHdr = 0;
|
||||
uint32_t sizeData = 0;
|
||||
|
||||
ASSERT_EQ(3, Photoshop::locateIptcIrb(data.data(), data.size(), &record, &sizeHdr, &sizeData));
|
||||
ASSERT_EQ(3, Photoshop::locateIptcIrb(data.data(), data.size(), &record, sizeHdr, sizeData));
|
||||
}
|
||||
|
||||
TEST(Photoshop_locatePreviewIrb, returns0withGoodPreviewIrb) {
|
||||
@ -127,7 +127,7 @@ TEST(Photoshop_locatePreviewIrb, returns0withGoodPreviewIrb) {
|
||||
uint32_t sizeHdr = 0;
|
||||
uint32_t sizeData = 0;
|
||||
|
||||
ASSERT_EQ(0, Photoshop::locatePreviewIrb(data.data(), data.size(), &record, &sizeHdr, &sizeData));
|
||||
ASSERT_EQ(0, Photoshop::locatePreviewIrb(data.data(), data.size(), &record, sizeHdr, sizeData));
|
||||
ASSERT_EQ(12, sizeHdr);
|
||||
ASSERT_EQ(27, sizeData);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user