25 #include <libopenraw/debug.h> 28 #include "mrwcontainer.hpp" 30 using namespace Debug;
38 : m_start(start), m_container(_container), m_loaded(false)
40 Trace(DEBUG2) <<
"> DataBlock start == " << start <<
"\n";
41 if (m_container->
fetchData(m_name, m_start, 4) != 4) {
43 Trace(WARNING) <<
" Error reading block name " << start <<
"\n";
46 if (!m_container->
readInt32(m_container->file(), m_length)) {
48 Trace(WARNING) <<
" Error reading block length " << start <<
"\n";
51 Trace(DEBUG1) <<
" DataBlock " <<
name() <<
", length " << m_length
52 <<
" at " << m_start <<
"\n";
53 Trace(DEBUG2) <<
"< DataBlock\n";
61 mc->file()->seek(m_start + DataBlockHeaderLength + off, SEEK_SET);
62 mc->readInt8(mc->file(), ret);
70 mc->file()->seek(m_start + DataBlockHeaderLength + off, SEEK_SET);
71 mc->readUInt8(mc->file(), ret);
79 mc->file()->seek(m_start + DataBlockHeaderLength + off, SEEK_SET);
84 std::string DataBlock::string_val(off_t off)
89 s = mc->
fetchData(buf, m_start + DataBlockHeaderLength + off, 8);
99 MRWContainer::MRWContainer(
const IO::Stream::Ptr &_file, off_t _offset)
115 if ((p[0] == 0x00) && (p[1] ==
'M') && (p[2] ==
'R') && (p[3] ==
'M')) {
117 Trace(DEBUG1) <<
"Identified MRW file\n";
122 Trace(DEBUG1) <<
"Unidentified MRW file\n";
132 Trace(DEBUG1) <<
"> MRWContainer::locateDirsPreHook()\n";
133 m_endian = ENDIAN_BIG;
136 mrm = std::make_shared<MRW::DataBlock>(m_offset,
this);
137 if (mrm->name() !=
"MRM") {
138 Trace(WARNING) <<
"MRW file begins not with MRM block, " 139 "but with unrecognized DataBlock :: name == " 140 << mrm->name() <<
"\n";
147 position = mrm->offset() + MRW::DataBlockHeaderLength;
148 while (position < pixelDataOffset()) {
149 MRW::DataBlock::Ref ref(
150 std::make_shared<MRW::DataBlock>(position,
this));
151 Trace(DEBUG1) <<
"Loaded DataBlock :: name == " << ref->name() <<
"\n";
152 if (!ref || !ref->loaded()) {
155 if (ref->name() ==
"PRD") {
158 <<
"File contains duplicate DataBlock :: name == " 159 << ref->name() <<
"\n";
162 }
else if (ref->name() ==
"TTW") {
165 <<
"File contains duplicate DataBlock :: name == " 166 << ref->name() <<
"\n";
169 }
else if (ref->name() ==
"WBG") {
172 <<
"File contains duplicate DataBlock :: name == " 173 << ref->name() <<
"\n";
176 }
else if (ref->name() ==
"RIF") {
179 <<
"File contains duplicate DataBlock :: name == " 180 << ref->name() <<
"\n";
183 }
else if (ref->name() !=
"PAD") {
184 Trace(WARNING) <<
"File contains unrecognized DataBlock :: name == " 185 << ref->name() <<
"\n";
187 position = ref->offset() + MRW::DataBlockHeaderLength + ref->length();
193 <<
"File does NOT contain expected DataBlock :: name == PRD\n";
198 <<
"File does NOT contain expected DataBlock :: name == TTW\n";
203 <<
"File does NOT contain expected DataBlock :: name == WBG\n";
208 <<
"File does NOT contain expected DataBlock :: name == RIF\n";
213 if (fetchData(version,
214 prd->offset() + MRW::DataBlockHeaderLength + MRW::PRD_VERSION,
217 Debug::Trace(DEBUG1) <<
" Error reading version string\n";
220 m_version = std::string(version);
221 Trace(DEBUG1) <<
" MRW file version == " << m_version <<
"\n";
227 m_offset = ttw->offset() + MRW::DataBlockHeaderLength;
232 setExifOffsetCorrection(m_offset);
233 Trace(DEBUG1) <<
"setting correction to " << m_offset <<
"\n";
236 m_file->seek(m_offset, SEEK_SET);
237 Trace(DEBUG1) <<
"< MRWContainer\n";
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.
virtual IfdFileContainer::EndianType isMagicHeader(const char *p, int len) override
int8_t int8_val(off_t offset)
uint16_t uint16_val(off_t offset)
bool readUInt16(const IO::Stream::Ptr &f, uint16_t &v)
bool readInt32(const IO::Stream::Ptr &f, int32_t &v)
virtual bool locateDirsPreHook() override
uint8_t uint8_val(off_t offset)