28 #include <libopenraw/debug.h> 30 #include "metavalue.hpp" 32 #include "ifdfilecontainer.hpp" 33 #include "ifdentry.hpp" 36 using namespace Debug;
42 IfdEntry::IfdEntry(uint16_t _id, int16_t _type,
43 int32_t _count, uint32_t _data,
44 IfdFileContainer &_container)
45 : m_id(_id), m_type(_type),
46 m_count(_count), m_data(_data),
47 m_loaded(false), m_dataptr(NULL),
48 m_container(_container)
63 void convert(Internals::IfdEntry* e, std::vector<MetaValue::value_t> & values)
67 values.insert(values.end(), v.cbegin(), v.cend());
71 template <
class T,
class T2>
72 void convert(Internals::IfdEntry* e, std::vector<MetaValue::value_t> & values)
76 for(
const auto & elem : v) {
77 values.push_back(T2(elem));
83 MetaValue* IfdEntry::make_meta_value()
85 std::vector<MetaValue::value_t> values;
88 case Internals::IFD::EXIF_FORMAT_BYTE:
90 convert<uint8_t, uint32_t>(
this, values);
93 case Internals::IFD::EXIF_FORMAT_ASCII:
95 convert<std::string>(
this, values);
98 case Internals::IFD::EXIF_FORMAT_SHORT:
100 convert<uint16_t, uint32_t>(
this, values);
103 case Internals::IFD::EXIF_FORMAT_LONG:
105 convert<uint32_t>(
this, values);
108 case Internals::IFD::EXIF_FORMAT_SRATIONAL:
110 convert<Internals::IFD::SRational, double>(
this, values);
114 Trace(DEBUG1) <<
"unhandled type " << type() <<
"\n";
117 return new MetaValue(values);
122 return m_container.endian();
128 bool success =
false;
129 size_t data_size = unit_size * m_count;
130 if (data_size <= 4) {
143 m_dataptr = (uint8_t*)realloc(m_dataptr, data_size);
144 success = (m_container.
fetchData(m_dataptr,
146 data_size) == data_size);
151 uint32_t IfdEntry::getIntegerArrayItem(
int idx)
158 case IFD::EXIF_FORMAT_LONG:
161 case IFD::EXIF_FORMAT_SHORT:
164 case IFD::EXIF_FORMAT_RATIONAL:
179 catch(
const std::exception & ex) {
181 <<
" fetch integer value for " << m_id <<
"\n";
190 Rational::operator double()
const 195 return (
double)num / (double)denom;
198 SRational::operator double()
const 203 return (
double)num / (double)denom;
229 #if defined(__APPLE_CC__) size_t fetchData(void *buf, off_t offset, size_t buf_size)
CIFF is the container for CRW files. It is an attempt from Canon to make this a standard. I guess it failed.
static T get(IfdEntry &e, uint32_t idx=0, bool ignore_type=false) noexcept(false)
int exifOffsetCorrection() const
bool loadData(size_t unit_size)