Skip to content

Commit

Permalink
Print compression in RAF header structure
Browse files Browse the repository at this point in the history
  • Loading branch information
kmilos committed Jun 19, 2024
1 parent 2469369 commit e843bc4
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/rafimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ void RafImage::printStructure(std::ostream& out, PrintStructureOption option, si
throw Error(ErrorCode::kerNotAnImage, "RAF");
}

// The following is based on https://libopenraw.freedesktop.org/formats/raf/ and
// https://exiftool.org/TagNames/FujiFilm.html#RAFHeader

const bool bPrint = option == kpsBasic || option == kpsRecursive;
if (bPrint) {
io_->seek(0, BasicIo::beg); // rewind
Expand Down Expand Up @@ -159,7 +162,7 @@ void RafImage::printStructure(std::ostream& out, PrintStructureOption option, si

// RAFs can carry the payload in one or two parts
uint32_t meta_off[2], meta_len[2];
uint32_t cfa_off[2], cfa_len[2], cfa_skip[2], cfa_size[2], cfa_stride[2];
uint32_t cfa_off[2], cfa_len[2], comp[2], cfa_size[2], cfa_data[2];
for (size_t i = 0; i < 2; i++) {
address = io_->tell();
byte data[4];
Expand Down Expand Up @@ -187,34 +190,34 @@ void RafImage::printStructure(std::ostream& out, PrintStructureOption option, si
cfa_len[i] = Exiv2::getULong(data, bigEndian);
size_t address3 = io_->tell();
io_->readOrThrow(data, 4);
cfa_skip[i] = Exiv2::getULong(data, bigEndian);
comp[i] = Exiv2::getULong(data, bigEndian);
size_t address4 = io_->tell();
io_->readOrThrow(data, 4);
cfa_size[i] = Exiv2::getULong(data, bigEndian);
size_t address5 = io_->tell();
io_->readOrThrow(data, 4);
cfa_stride[i] = Exiv2::getULong(data, bigEndian);
cfa_data[i] = Exiv2::getULong(data, bigEndian);
{
std::stringstream c_off;
std::stringstream c_len;
std::stringstream c_skip;
std::stringstream c_comp;
std::stringstream c_size;
std::stringstream c_stride;
std::stringstream c_data;
c_off << cfa_off[i];
c_len << cfa_len[i];
c_skip << cfa_skip[i];
c_comp << comp[i];
c_size << cfa_size[i];
c_stride << cfa_stride[i];
c_data << cfa_data[i];
out << Internal::indent(depth) << Internal::stringFormat(format, address, 4U) << " CFA offset" << i + 1 << " : "
<< c_off.str() << std::endl;
out << Internal::indent(depth) << Internal::stringFormat(format, address2, 4U) << " CFA length" << i + 1
<< " : " << c_len.str() << std::endl;
out << Internal::indent(depth) << Internal::stringFormat(format, address3, 4U) << " CFA skip" << i + 1
<< " : " << c_skip.str() << std::endl;
out << Internal::indent(depth) << Internal::stringFormat(format, address3, 4U) << "compression" << i + 1
<< " : " << c_comp.str() << std::endl;
out << Internal::indent(depth) << Internal::stringFormat(format, address4, 4U) << " CFA chunk" << i + 1
<< " : " << c_size.str() << std::endl;
out << Internal::indent(depth) << Internal::stringFormat(format, address5, 4U) << " CFA stride" << i + 1
<< " : " << c_stride.str() << std::endl;
out << Internal::indent(depth) << Internal::stringFormat(format, address5, 4U) << " unknown" << i + 1
<< " : " << c_data.str() << std::endl;
}
}

Expand Down

0 comments on commit e843bc4

Please sign in to comment.