3#ifndef EXIV2_CRWIMAGE_INT_HPP
4#define EXIV2_CRWIMAGE_INT_HPP
41enum class DataLocId { valueData, directoryData, lastDataLocId };
166 void print(std::ostream& os,
ByteOrder byteOrder,
const std::string& prefix =
"")
const;
174 [[nodiscard]] uint16_t
dir()
const {
179 [[nodiscard]] uint16_t
tag()
const {
184 [[nodiscard]]
bool empty()
const;
194 [[nodiscard]]
size_t size()
const {
204 [[nodiscard]]
const byte*
pData()
const {
209 [[nodiscard]] uint16_t
tagId()
const {
210 return tag_ & 0x3fff;
258 virtual void doPrint(std::ostream& os,
ByteOrder byteOrder,
const std::string& prefix)
const;
260 [[nodiscard]]
virtual bool doEmpty()
const;
277 const byte* pData_ =
nullptr;
294 void doAdd(
UniquePtr component)
override;
342 void doAdd(
UniquePtr component)
override;
346 void doRemove(
CrwDirs& crwDirs, uint16_t crwTagId)
override;
353 void doRead(
const byte*
pData,
size_t size, uint32_t start,
ByteOrder byteOrder)
override;
362 void doPrint(std::ostream& os,
ByteOrder byteOrder,
const std::string& prefix)
const override;
365 [[nodiscard]]
bool doEmpty()
const override;
368 [[nodiscard]]
CiffComponent* doFindComponent(uint16_t crwTagId, uint16_t crwDir)
const override;
407 void read(
const byte* pData,
size_t size);
417 void add(uint16_t crwTagId, uint16_t crwDir,
DataBuf&& buf);
426 void remove(uint16_t crwTagId, uint16_t crwDir)
const;
468 static constexpr auto signature_ =
"HEAPCCDR";
470 std::unique_ptr<CiffDirectory> pRootDir_;
472 uint32_t offset_ = 0;
473 std::vector<byte> pPadding_;
474 uint32_t padded_ = 0;
530 static const CrwMapping* crwMapping(uint16_t crwDir, uint16_t crwTagId);
A container for Exif data. This is a top-level class of the Exiv2 library. The container holds Exifda...
Definition exif.hpp:379
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition image.hpp:50
Interface class for components of the CIFF directory hierarchy of a CRW (Canon Raw data) image....
Definition crwimage_int.hpp:52
void writeDirEntry(Blob &blob, ByteOrder byteOrder) const
Write a directory entry for the component to the blob. If the size of the data is not larger than 8 b...
Definition crwimage_int.cpp:380
void read(const byte *pData, size_t size, uint32_t start, ByteOrder byteOrder)
Read a component from a data buffer.
Definition crwimage_int.cpp:181
const byte * pData() const
Return a pointer to the data area of this component.
Definition crwimage_int.hpp:204
void setSize(size_t size)
Set the size of the data area.
Definition crwimage_int.hpp:244
virtual CiffComponent * doFindComponent(uint16_t crwTagId, uint16_t crwDir) const
Implements findComponent(). The default implementation checks the entry.
Definition crwimage_int.cpp:494
virtual void doPrint(std::ostream &os, ByteOrder byteOrder, const std::string &prefix) const
Implements print(). The default implementation prints the entry.
Definition crwimage_int.cpp:418
TypeId typeId() const
Return the type id of this component.
Definition crwimage_int.hpp:214
void add(UniquePtr component)
Add a component to the composition.
Definition crwimage_int.cpp:142
bool empty() const
Return true if the component is empty, else false.
Definition crwimage_int.cpp:619
virtual size_t doWrite(Blob &blob, ByteOrder byteOrder, size_t offset)=0
Implements write()
size_t size() const
Return the data size of this component.
Definition crwimage_int.hpp:194
size_t write(Blob &blob, ByteOrder byteOrder, size_t offset)
Write the metadata from the raw metadata component to the binary image blob. This method may append t...
Definition crwimage_int.cpp:314
virtual void doRemove(CrwDirs &crwDirs, uint16_t crwTagId)
Implements remove(). The default implementation does nothing.
Definition crwimage_int.cpp:593
CiffComponent()=default
Default constructor.
virtual void doAdd(UniquePtr component)=0
Implements add()
DataLocId dataLocation() const
Return the data location for this component.
Definition crwimage_int.hpp:219
std::unique_ptr< CiffComponent > UniquePtr
CiffComponent auto_ptr type.
Definition crwimage_int.hpp:55
std::vector< CiffComponent * > Components
Container type to hold all metadata.
Definition crwimage_int.hpp:57
void setOffset(size_t offset)
Set the offset for this component.
Definition crwimage_int.hpp:248
virtual bool doEmpty() const
Implements empty(). Default implementation returns true if size is 0.
Definition crwimage_int.cpp:623
virtual void doDecode(Image &image, ByteOrder byteOrder) const =0
Implements decode()
void remove(CrwDirs &crwDirs, uint16_t crwTagId)
Remove crwTagId from the parse tree, if it exists yet. crwDirs contains the path of subdirectories,...
Definition crwimage_int.cpp:589
void setDir(uint16_t dir)
Set the directory tag for this component.
Definition crwimage_int.hpp:137
CiffComponent * findComponent(uint16_t crwTagId, uint16_t crwDir) const
Finds crwTagId in directory crwDir, returning a pointer to the component or 0 if not found.
Definition crwimage_int.cpp:490
void decode(Image &image, ByteOrder byteOrder) const
Decode metadata from the component and add it to image.
Definition crwimage_int.cpp:271
uint16_t tagId() const
Return the tag id of this component.
Definition crwimage_int.hpp:209
uint16_t tag() const
Return the tag of this component.
Definition crwimage_int.hpp:179
void print(std::ostream &os, ByteOrder byteOrder, const std::string &prefix="") const
Print debug info about a component to os.
Definition crwimage_int.cpp:414
virtual ~CiffComponent()=default
Virtual destructor.
uint16_t dir() const
Return the tag of the directory containing this component.
Definition crwimage_int.hpp:174
size_t offset() const
Return the offset to the data from the start of the directory.
Definition crwimage_int.hpp:199
virtual void doRead(const byte *pData, size_t size, uint32_t start, ByteOrder byteOrder)
Implements read(). The default implementation reads a directory entry.
Definition crwimage_int.cpp:185
void setValue(DataBuf &&buf)
Set the data value of the entry.
Definition crwimage_int.cpp:440
size_t writeValueData(Blob &blob, size_t offset)
Writes the entry's value if size is larger than eight bytes. If needed, the value is padded with one ...
Definition crwimage_int.cpp:322
This class models a CIFF directory of a CRW (Canon Raw data) image.
Definition crwimage_int.hpp:311
~CiffDirectory() override
Virtual destructor.
Definition crwimage_int.cpp:136
void readDirectory(const byte *pData, size_t size, ByteOrder byteOrder)
Parse a CIFF directory from a memory buffer.
Definition crwimage_int.cpp:237
This class models one directory entry of a CIFF directory of a CRW (Canon Raw data) image.
Definition crwimage_int.hpp:288
Static class providing mapping functionality from CRW entries to image metadata and vice versa.
Definition crwimage_int.hpp:496
static void decode(const CiffComponent &ciffComponent, Image &image, ByteOrder byteOrder)
Decode image metadata from a CRW entry, convert and add it to the image metadata. This function conve...
Definition crwimage_int.cpp:631
static void encode(CiffHeader *pHead, const Image &image)
Encode image metadata from image into the CRW parse tree. This function converts all Exif metadata th...
Definition crwimage_int.cpp:834
static void loadStack(CrwDirs &crwDirs, uint16_t crwDir)
Load the stack: loop through the CRW subdirs hierarchy and push all directories on the path from crwD...
Definition crwimage_int.cpp:824
Helper structure for the Matroska tags lookup table.
Definition matroskavideo.hpp:39
DataBuf packIfdId(const ExifData &exifData, IfdId ifdId, ByteOrder byteOrder)
Pack the tag values of all ifdId tags in exifData into a data buffer. This function is used to pack C...
Definition crwimage_int.cpp:1002
void(*)(const Image &, const CrwMapping *, CiffHeader *) CrwEncodeFct
Function pointer for functions to encode CRW entries from Exif tags.
Definition crwimage_int.hpp:35
void(*)(const CiffComponent &, const CrwMapping *, Image &, ByteOrder) CrwDecodeFct
Function pointer for functions to decode Exif tags from a CRW entry.
Definition crwimage_int.hpp:32
DataLocId
Type to identify where the data is stored in a directory.
Definition crwimage_int.hpp:41
std::stack< CrwSubDir > CrwDirs
Stack to hold a path of CRW directories.
Definition crwimage_int.hpp:38
IfdId
Type to specify the IFD to which a metadata belongs.
Definition tags.hpp:34
TypeId
Exiv2 value type identifiers.
Definition types.hpp:70
ByteOrder
Type to express the byte order (little or big endian)
Definition types.hpp:34
std::vector< byte > Blob
Container for binary data.
Definition types.hpp:102
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition types.hpp:124
Structure for a mapping table for conversion of CIFF entries to image metadata and vice versa.
Definition crwimage_int.hpp:482
CrwDecodeFct toExif_
Conversion function.
Definition crwimage_int.hpp:488
IfdId ifdId_
Exif Ifd id to map to.
Definition crwimage_int.hpp:487
uint16_t tag_
Exif tag to map to.
Definition crwimage_int.hpp:486
uint32_t size_
Data size (overwrites the size from the entry)
Definition crwimage_int.hpp:485
uint16_t crwDir_
CRW directory tag.
Definition crwimage_int.hpp:484
CrwEncodeFct fromExif_
Reverse conversion function.
Definition crwimage_int.hpp:489
uint16_t crwTagId_
CRW tag id.
Definition crwimage_int.hpp:483
Definition crwimage_int.hpp:23