25 #include "ciffcontainer.hpp"
28 using namespace Debug;
38 auto file = container->file();
39 auto endian = container->endian();
40 file->seek(offset, SEEK_SET);
42 auto result_u32 = container->
readUInt32(file, endian);
43 if (result_u32.empty()) {
46 imageWidth = result_u32.value();
47 result_u32 = container->
readUInt32(file, endian);
48 if (result_u32.empty()) {
51 imageHeight = result_u32.value();
52 result_u32 = container->
readUInt32(file, endian);
53 if (result_u32.empty()) {
56 pixelAspectRatio = result_u32.value();
57 auto result_32 = container->
readInt32(file, endian);
58 if (result_32.empty()) {
61 rotationAngle = result_32.value();
62 result_u32 = container->
readUInt32(file, endian);
63 if (result_u32.empty()) {
66 componentBitDepth = result_u32.value();
67 result_u32 = container->
readUInt32(file, endian);
68 if (result_u32.empty()) {
71 colorBitDepth = result_u32.value();
72 result_u32 = container->
readUInt32(file, endian);
73 if (result_u32.empty()) {
76 colorBW = result_u32.value();
80 int32_t ImageSpec::exifOrientation()
const
82 int32_t orientation = 0;
83 switch(rotationAngle) {
111 : RawContainer(_file, 0),
114 m_hasImageSpec(false)
116 m_endian = _readHeader();
119 CIFFContainer::~CIFFContainer()
125 if (m_heap ==
nullptr) {
131 bool CIFFContainer::_loadHeap()
137 if (m_endian != ENDIAN_NULL) {
138 off_t heapLength = m_file->filesize() - m_hdr.headerLength;
140 LOGDBG1(
"heap len %lld\n", (
long long int)heapLength);
141 m_heap = std::make_shared<CIFF::Heap>(m_hdr.headerLength,
147 LOGDBG1(
"Unknown endian\n");
156 EndianType _endian = ENDIAN_NULL;
157 m_hdr.readFrom(
this);
158 if ((::strncmp(m_hdr.type,
"HEAP", 4) == 0)
159 && (::strncmp(m_hdr.subType,
"CCDR", 4) == 0)) {
160 _endian = m_hdr.endian;
172 auto & records = m_heap->records();
175 auto iter = records.find(CIFF::TAG_IMAGEPROPS);
176 if (iter == records.end()) {
177 LOGERR(
"Couldn't find the image properties.\n");
181 m_imageprops = std::make_shared<CIFF::Heap>(
182 iter->second.offset() + m_heap->offset(), iter->second.length(),
this);
187 const CIFF::ImageSpec * CIFFContainer::getImageSpec()
189 if(!m_hasImageSpec) {
195 auto & propsRecs = props->records();
196 auto iter = propsRecs.find(CIFF::TAG_IMAGEINFO);
197 if (iter == propsRecs.end()) {
198 LOGERR(
"Couldn't find the image info.\n");
201 m_imagespec.readFrom(iter->second.offset() + props->offset(),
this);
202 m_hasImageSpec =
true;
215 auto & propsRecs = props->records();
216 auto iter = propsRecs.find(CIFF::TAG_CAMERAOBJECT);
217 if (iter == propsRecs.end()) {
218 LOGERR(
"Couldn't find the camera props.\n");
221 m_cameraprops = std::make_shared<CIFF::Heap>(
222 iter->second.offset() + props->offset(), iter->second.length(),
this);
224 return m_cameraprops;
235 auto& propsRecs = props->records();
236 auto iter = propsRecs.find(CIFF::TAG_EXIFINFORMATION);
237 if (iter == propsRecs.end()) {
238 LOGERR(
"Couldn't find the Exif information.\n");
241 m_exifinfo = std::make_shared<CIFF::Heap>(
242 iter->second.offset() + props->offset(), iter->second.length(),
this);
250 auto exifInfo = getExifInfo();
251 auto& propsRecs = exifInfo->records();
252 auto iter = propsRecs.find(CIFF::TAG_CAMERASETTINGS);
253 if (iter == propsRecs.end()) {
254 LOGERR(
"Couldn't find the camera settings.\n");
257 auto count = iter->second.count();
259 file()->seek(exifInfo->offset() + iter->second.offset(), SEEK_SET);
260 size_t countRead = readUInt16Array(file(), settings, count);
261 if (count != countRead) {
262 LOGERR(
"Not enough data for camera settings\n");
268 const CIFF::RecordEntry * CIFFContainer::getRawDataRecord()
const
273 auto & records = m_heap->records();
275 auto iter = records.find(CIFF::TAG_RAWIMAGEDATA);
276 if (iter != records.end()) {
277 return &(iter->second);
std::shared_ptr< Stream > Ptr
A record entry from a CIFF Heap.
Option< uint32_t > readUInt32(const IO::Stream::Ptr &f, EndianType endian) const
Read an uint32 following the m_endian set.
EndianType
Define the endian of the container.
Option< int32_t > readInt32(const IO::Stream::Ptr &f, EndianType endian) const
Read an int32 following the m_endian set.
std::shared_ptr< Heap > HeapRef
Shared ptr to Heap.
std::vector< uint16_t > CameraSettings
Camera settings are stored as array of 16-bits int.
Global namespace for libopenraw.