 |
Exiv2
|
Go to the documentation of this file.
27 #ifndef CRWIMAGE_INT_HPP_
28 #define CRWIMAGE_INT_HPP_
94 typedef std::auto_ptr<CiffComponent>
AutoPtr;
102 : dir_(0), tag_(0), size_(0), offset_(0), pData_(0),
103 isAllocated_(false) {}
106 : dir_(
dir), tag_(
tag), size_(0), offset_(0), pData_(0),
107 isAllocated_(false) {}
206 void print(std::ostream& os,
216 uint16_t
dir()
const {
return dir_; }
219 uint16_t
tag()
const {
return tag_; }
232 uint32_t
size()
const {
return size_; }
235 uint32_t
offset()
const {
return offset_; }
238 const byte*
pData()
const {
return pData_; }
241 uint16_t
tagId()
const {
return tag_ & 0x3fff; }
286 virtual void doPrint(std::ostream& os,
293 uint16_t crwDir)
const;
331 virtual void doAdd(
AutoPtr component);
336 virtual uint32_t doWrite(
Blob& blob,
383 virtual void doAdd(
AutoPtr component);
387 virtual void doRemove(
CrwDirs& crwDirs, uint16_t crwTagId);
392 virtual uint32_t doWrite(
Blob& blob,
396 virtual void doRead(
const byte*
pData,
405 virtual void doDecode(
Image& image,
409 virtual void doPrint(std::ostream& os,
414 virtual bool doEmpty()
const;
418 uint16_t crwDir)
const;
445 byteOrder_ (littleEndian),
446 offset_ (0x0000001a),
465 void read(
const byte* pData, uint32_t size);
475 void add(uint16_t crwTagId, uint16_t crwDir,
DataBuf buf);
484 void remove(uint16_t crwTagId, uint16_t crwDir);
528 static const char signature_[];
627 static const CrwMapping* crwMapping(uint16_t crwDir, uint16_t crwTagId);
693 static void encodeBasic(
const Image& image,
698 static void encode0x0805(
const Image& image,
703 static void encode0x080a(
const Image& image,
708 static void encodeArray(
const Image& image,
713 static void encode0x180e(
const Image& image,
718 static void encode0x1810(
const Image& image,
723 static void encode0x2008(
const Image& image,
747 #endif // #ifndef CRWIMAGE_INT_HPP_
uint16_t crwDir_
Directory tag.
Definition: crwimage_int.hpp:540
void setValue(DataBuf buf)
Set the data value of the entry.
Definition: crwimage_int.cpp:544
CiffComponent(uint16_t tag, uint16_t dir)
Constructor taking a tag and directory.
Definition: crwimage_int.hpp:105
uint16_t tagId() const
Return the tag id of this component.
Definition: crwimage_int.hpp:241
CrwDecodeFct toExif_
Conversion function.
Definition: crwimage_int.hpp:576
float canonEv(long val)
Convert Canon hex-based EV (modulo 0x20) to real number Ported from Phil Harvey's Image::ExifTool::Ca...
Definition: canonmn_int.cpp:2154
byte * pData_
Pointer to the buffer, 0 if none has been allocated.
Definition: types.hpp:269
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:773
std::auto_ptr< CiffComponent > AutoPtr
CiffComponent auto_ptr type.
Definition: crwimage_int.hpp:94
uint16_t tag() const
Return the tag of this component.
Definition: crwimage_int.hpp:219
iterator findKey(const ExifKey &key)
Find the first Exifdatum with the given key, return an iterator to it.
Definition: exif.cpp:581
virtual CiffComponent * doFindComponent(uint16_t crwTagId, uint16_t crwDir) const
Implements findComponent(). The default implementation checks the entry.
Definition: crwimage_int.cpp:602
uint16_t crwDir_
CRW directory tag.
Definition: crwimage_int.hpp:572
void read(const byte *pData, uint32_t size, uint32_t start, ByteOrder byteOrder)
Read a component from a data buffer.
Definition: crwimage_int.cpp:225
URational exposureTime(float shutterSpeedValue)
Calculate the exposure time from an APEX shutter speed value.
Definition: tags_int.cpp:2172
CiffEntry()
Default constructor.
Definition: crwimage_int.hpp:316
void decode(Image &image, ByteOrder byteOrder) const
Decode metadata from the component and add it to image.
Definition: crwimage_int.cpp:319
void(* CrwDecodeFct)(const CiffComponent &, const CrwMapping *, Image &, ByteOrder)
Function pointer for functions to decode Exif tags from a CRW entry.
Definition: crwimage_int.hpp:62
std::vector< CiffComponent * > Components
Container type to hold all metadata.
Definition: crwimage_int.hpp:96
IfdId
Type to specify the IFD to which a metadata belongs.
Definition: tags_int.hpp:54
iterator begin()
Begin of the metadata.
Definition: exif.hpp:490
virtual uint32_t doWrite(Blob &blob, ByteOrder byteOrder, uint32_t offset)=0
Implements write()
ExifMetadata::const_iterator const_iterator
ExifMetadata const iterator type.
Definition: exif.hpp:439
@ undefined
Exif UNDEFINED type, an 8-bit byte that may contain anything.
Definition: types.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:596
uint16_t crwTagId_
CRW tag id.
Definition: crwimage_int.hpp:571
uint32_t size() const
Return the data size of this component.
Definition: crwimage_int.hpp:232
EXV_WARN_UNUSED_RESULT std::pair< byte *, long > release()
Release ownership of the buffer to the caller. Returns the buffer as a data pointer and size pair,...
Definition: types.cpp:172
This class models one directory entry of a CIFF directory of a CRW (Canon Raw data) image.
Definition: crwimage_int.hpp:311
void setDir(uint16_t dir)
Set the directory tag for this component.
Definition: crwimage_int.hpp:179
@ comment
Exiv2 type for the Exif user comment.
Definition: types.hpp:150
virtual void doAdd(AutoPtr component)=0
Implements add()
@ asciiString
Exif ASCII type, 8-bit byte.
Definition: types.hpp:132
static AutoPtr create(TypeId typeId)
A (simple) factory to create a Value type.
Definition: value.cpp:100
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:990
virtual void doRemove(CrwDirs &crwDirs, uint16_t crwTagId)
Implements remove(). The default implementation does nothing.
Definition: crwimage_int.cpp:721
iterator end()
End of the metadata.
Definition: exif.hpp:492
@ unsignedLong
Exif LONG type, 32-bit (4-byte) unsigned integer.
Definition: types.hpp:134
CrwMapping(uint16_t crwTagId, uint16_t crwDir, uint32_t size, uint16_t tag, Internal::IfdId ifdId, CrwDecodeFct toExif, CrwEncodeFct fromExif)
Default constructor.
Definition: crwimage_int.hpp:552
ValueType< uint32_t > ULongValue
Unsigned long value type.
Definition: value.hpp:1341
virtual ~CiffEntry()
Virtual destructor.
Definition: crwimage_int.cpp:169
const byte * pData() const
Return a pointer to the data area of this component.
Definition: crwimage_int.hpp:238
ValueType< URational > URationalValue
Unsigned rational value type.
Definition: value.hpp:1343
const char * groupName(IfdId ifdId)
Return the group name for a group id.
Definition: tags_int.cpp:2155
Canon makernote tags. References: [1] EXIF MakerNote of Canon by David Burren [2] Canon makernote t...
uint16_t tag_
Exif tag to map to.
Definition: crwimage_int.hpp:574
This class models a CIFF directory of a CRW (Canon Raw data) image.
Definition: crwimage_int.hpp:350
Port of D's enforce() to C++ & Exiv2.
IfdId ifdId_
Exif Ifd id to map to.
Definition: crwimage_int.hpp:575
void setSize(uint32_t size)
Set the size of the data area.
Definition: crwimage_int.hpp:275
uint16_t parent_
Parent directory tag.
Definition: crwimage_int.hpp:541
DataLocId dataLocation() const
Return the data location for this component.
Definition: crwimage_int.hpp:247
EXIV2API int exifTime(const char *buf, struct tm *tm)
Converts a string in the form "%Y:%m:%d %H:%M:%S", e.g., "2007:05:24 12:31:55" to broken down time fo...
Definition: types.cpp:556
@ invalidTypeId
Invalid type id.
Definition: types.hpp:157
EXIV2API void append(Exiv2::Blob &blob, const byte *buf, uint32_t len)
Append len bytes pointed to by buf to blob.
Definition: image.cpp:1004
void enforce(bool condition, const T &arg1)
Ensure that condition is true, otherwise throw an exception of the type exception_t.
Definition: enforce.hpp:43
EXIV2API ExifData::const_iterator orientation(const ExifData &ed)
Return the orientation of the image.
Definition: easyaccess.cpp:58
CiffDirectory(uint16_t tag, uint16_t dir)
Constructor taking a tag and directory.
Definition: crwimage_int.hpp:357
virtual bool doEmpty() const
Implements empty(). Default implementation returns true if size is 0.
Definition: crwimage_int.cpp:763
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:204
EXIV2API long l2Data(byte *buf, int32_t l, ByteOrder byteOrder)
Convert a signed long to data, write the data to the buffer, return number of bytes written.
Definition: types.cpp:445
@ unsignedByte
Exif BYTE type, 8-bit unsigned integer.
Definition: types.hpp:131
EXIV2API long us2Data(byte *buf, uint16_t s, ByteOrder byteOrder)
Convert an unsigned short to data, write the data to the buffer, return number of bytes written.
Definition: types.cpp:395
uint32_t writeValueData(Blob &blob, uint32_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:387
Static class providing mapping functionality from CRW entries to image metadata and vice versa.
Definition: crwimage_int.hpp:585
void print(std::ostream &os, ByteOrder byteOrder, const std::string &prefix="") const
Print debug info about a component to os.
Definition: crwimage_int.cpp:502
Concrete keys for Exif metadata and access to Exif tag reference data.
Definition: tags.hpp:148
long size_
The current size of the buffer.
Definition: types.hpp:271
EXIV2API int32_t getLong(const byte *buf, ByteOrder byteOrder)
Read a 4 byte signed long value from the data buffer.
Definition: types.cpp:328
virtual void doRead(const byte *pData, uint32_t size, uint32_t start, ByteOrder byteOrder)
Implements read(). The default implementation reads a directory entry.
Definition: crwimage_int.cpp:233
uint32_t write(Blob &blob, ByteOrder byteOrder, uint32_t offset)
Write the metadata from the raw metadata component to the binary image blob. This method may append t...
Definition: crwimage_int.cpp:373
void readDirectory(const byte *pData, uint32_t size, ByteOrder byteOrder)
Parse a CIFF directory from a memory buffer.
Definition: crwimage_int.cpp:281
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:453
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:509
@ unsignedShort
Exif SHORT type, 16-bit (2-byte) unsigned integer.
Definition: types.hpp:133
std::stack< CrwSubDir > CrwDirs
Stack to hold a path of CRW directories.
Definition: crwimage_int.hpp:73
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:1000
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
std::pair< int32_t, int32_t > Rational
8 byte signed rational type.
Definition: types.hpp:110
TypeId
Exiv2 value type identifiers.
Definition: types.hpp:130
ValueType< uint16_t > UShortValue
Unsigned short value type.
Definition: value.hpp:1339
EXIV2API long ul2Data(byte *buf, uint32_t l, ByteOrder byteOrder)
Convert an unsigned long to data, write the data to the buffer, return number of bytes written.
Definition: types.cpp:408
CrwEncodeFct fromExif_
Reverse conversion function.
Definition: crwimage_int.hpp:577
static const char * typeName(TypeId typeId)
Return the name of the type, 0 if unknown.
Definition: types.cpp:107
CiffDirectory()
Default constructor.
Definition: crwimage_int.hpp:355
uint32_t offset() const
Return the offset to the data from the start of the directory.
Definition: crwimage_int.hpp:235
virtual ~CiffDirectory()
Virtual destructor.
Definition: crwimage_int.cpp:173
EXIV2API uint16_t getUShort(const byte *buf, ByteOrder byteOrder)
Read a 2 byte unsigned short value from the data buffer.
Definition: types.cpp:278
ByteOrder
Type to express the byte order (little or big endian)
Definition: types.hpp:113
Structure for the CIFF directory hierarchy.
Definition: crwimage_int.hpp:539
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:716
virtual ~CiffComponent()
Virtual destructor.
Definition: crwimage_int.cpp:164
std::pair< uint32_t, uint32_t > URational
8 byte unsigned rational type.
Definition: types.hpp:108
BasicError< char > Error
Error class used for exceptions (std::string based)
Definition: error.hpp:324
CiffComponent()
Default constructor.
Definition: crwimage_int.hpp:101
uint32_t size_
Data size (overwrites the size from the entry)
Definition: crwimage_int.hpp:573
Interface class for components of the CIFF directory hierarchy of a CRW (Canon Raw data) image....
Definition: crwimage_int.hpp:91
bool empty() const
Return true if the component is empty, else false.
Definition: crwimage_int.cpp:758
void setOffset(uint32_t offset)
Set the offset for this component.
Definition: crwimage_int.hpp:277
@ string
IPTC string type.
Definition: types.hpp:147
void(* CrwEncodeFct)(const Image &, const CrwMapping *, CiffHeader *)
Function pointer for functions to encode CRW entries from Exif tags.
Definition: crwimage_int.hpp:68
@ directory
Exiv2 type for a CIFF directory.
Definition: types.hpp:151
virtual void doDecode(Image &image, ByteOrder byteOrder) const =0
Implements decode()
void add(AutoPtr component)
Add a component to the composition.
Definition: crwimage_int.cpp:182
TypeId typeId() const
Return the type id of thi component.
Definition: crwimage_int.hpp:244
#define EXV_ERROR
Shorthand for a temp error log message object and return its ostringstream.
Definition: error.hpp:150
EXIV2API Rational floatToRationalCast(float f)
Very simple conversion of a float to a Rational.
Definition: types.cpp:694
Structure for a mapping table for conversion of CIFF entries to image metadata and vice versa.
Definition: crwimage_int.hpp:548
Abstract base class defining the interface for an image. This is the top-level interface to the Exiv2...
Definition: image.hpp:81
CiffEntry(uint16_t tag, uint16_t dir)
Constructor taking a tag and directory.
Definition: crwimage_int.hpp:318
DataLocId
Type to identify where the data is stored in a directory.
Definition: crwimage_int.hpp:76
Internal classes to support CRW/CIFF format.
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:1217
std::auto_ptr< Value > AutoPtr
Shortcut for a Value auto pointer.
Definition: value.hpp:63
uint16_t dir() const
Return the tag of the directory containing this component.
Definition: crwimage_int.hpp:216
EXIV2API uint32_t getULong(const byte *buf, ByteOrder byteOrder)
Read a 4 byte unsigned long value from the data buffer.
Definition: types.cpp:283
Error class for exceptions, log message class.
virtual ExifData & exifData()
Returns an ExifData instance containing currently buffered Exif data.
Definition: image.cpp:571
std::vector< byte > Blob
Container for binary data.
Definition: types.hpp:162
A container for Exif data. This is a top-level class of the Exiv2 library. The container holds Exifda...
Definition: exif.hpp:434
float fnumber(float apertureValue)
Calculate F number from an APEX aperture value.
Definition: tags_int.cpp:2167