27 #include <libopenraw/debug.h>
30 #include "ifdfilecontainer.hpp"
31 #include "ifdentry.hpp"
34 using namespace Debug;
40 IfdEntry::IfdEntry(uint16_t _id, int16_t _type,
41 int32_t _count, uint32_t _data,
42 const IfdDir& _dir,
bool synthetic)
43 : m_id(_id), m_type(_type),
44 m_count(_count), m_data(_data),
45 m_loaded(false), m_dataptr(NULL),
49 auto container_size = m_dir.container().size();
51 if ((m_count * unit_size) >
static_cast<size_t>(container_size)) {
52 LOGERR(
"Trying to have %u items in a container of %lld bytes\n",
53 m_count, (
long long int)container_size);
54 m_count = container_size / unit_size;
70 case IFD::EXIF_FORMAT_BYTE:
71 case IFD::EXIF_FORMAT_SBYTE:
72 case IFD::EXIF_FORMAT_ASCII:
73 case IFD::EXIF_FORMAT_UNDEFINED:
75 case IFD::EXIF_FORMAT_SHORT:
76 case IFD::EXIF_FORMAT_SSHORT:
78 case IFD::EXIF_FORMAT_LONG:
79 case IFD::EXIF_FORMAT_SLONG:
80 case IFD::EXIF_FORMAT_FLOAT:
82 case IFD::EXIF_FORMAT_RATIONAL:
83 case IFD::EXIF_FORMAT_SRATIONAL:
84 case IFD::EXIF_FORMAT_DOUBLE:
93 return m_dir.endian();
96 size_t IfdEntry::loadDataInto(uint8_t* dataptr,
size_t data_size, off_t offset)
const
99 if (endian() == RawContainer::ENDIAN_LITTLE) {
104 _offset += m_dir.container().exifOffsetCorrection() + offset;
105 LOGDBG1(
"loadData: offset %lld\n", (LOFFSET)_offset);
106 return m_dir.container().fetchData(dataptr, _offset, data_size);
109 bool IfdEntry::loadData(
size_t unit_size, off_t offset)
112 size_t data_size = unit_size * m_count;
113 if (data_size <= 4) {
117 m_dataptr = (uint8_t*)realloc(m_dataptr, data_size);
118 m_loaded = loadDataInto(m_dataptr, data_size, offset) == data_size;
124 void IfdEntry::setData(
const uint8_t* dataptr,
size_t data_size)
127 m_dataptr = (uint8_t*)realloc(m_dataptr, data_size);
128 memcpy(m_dataptr, dataptr, data_size);
EndianType
Define the endian of the container.
Global namespace for libopenraw.