mirror of
https://github.com/Evolution-X/external_piex
synced 2026-02-01 07:35:29 +00:00
Enables warnings for unused parameters. Adds cfa_repeat_pattern_dim to identify non bayer patterns e.g. Fuji X-Trans in DNG.
This commit is contained in:
@@ -52,12 +52,10 @@ size_t MemoryPagedByteArray::length() const { return len_; }
|
||||
|
||||
size_t MemoryPagedByteArray::pageSize() const { return len_; }
|
||||
|
||||
void MemoryPagedByteArray::getPage(size_t page_index,
|
||||
void MemoryPagedByteArray::getPage(size_t /* page_index */,
|
||||
const unsigned char **begin,
|
||||
const unsigned char **end,
|
||||
PagePtr *page) const {
|
||||
assert(page_index == 0);
|
||||
|
||||
*begin = buffer_;
|
||||
*end = buffer_ + len_;
|
||||
*page = PagePtr();
|
||||
@@ -68,7 +66,7 @@ void MemoryPagedByteArray::getPage(size_t page_index,
|
||||
class NullFunctor {
|
||||
public:
|
||||
void operator()() {}
|
||||
void operator()(PagedByteArray *p) const {}
|
||||
void operator()(PagedByteArray * /* p */) const {}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
79
src/piex.cc
79
src/piex.cc
@@ -43,8 +43,9 @@ Error GetPreviewData(const TagSet& extended_tags,
|
||||
kExifTagExposureTime, kExifTagFnumber,
|
||||
kExifTagFocalLength, kExifTagGps,
|
||||
kExifTagIsoSpeed, kTiffTagDateTime,
|
||||
kTiffTagExifIfd, kTiffTagMake,
|
||||
kTiffTagModel, kTiffTagOrientation};
|
||||
kTiffTagExifIfd, kTiffTagCfaPatternDim,
|
||||
kTiffTagMake, kTiffTagModel,
|
||||
kTiffTagOrientation};
|
||||
desired_tags.insert(extended_tags.cbegin(), extended_tags.cend());
|
||||
|
||||
TiffParser tiff_parser(stream, tiff_offset);
|
||||
@@ -120,6 +121,28 @@ Error GetExifIfd(const Endian endian, StreamInterface* stream,
|
||||
stream, exif_ifd, &next_ifd_offset);
|
||||
}
|
||||
|
||||
bool GetImageFromIfd(const TiffDirectory& ifd, std::uint32_t* offset,
|
||||
std::uint32_t* length) {
|
||||
std::uint32_t compression;
|
||||
std::uint32_t photometric_interpretation;
|
||||
if (ifd.Get(kTiffTagPhotometric, &photometric_interpretation) &&
|
||||
ifd.Get(kTiffTagCompression, &compression)) {
|
||||
if (photometric_interpretation == 6 /* YCbCr */ &&
|
||||
(compression == 6 /* JPEG(old) */ || compression == 7 /* JPEG */)) {
|
||||
std::vector<std::uint32_t> strip_offsets;
|
||||
std::vector<std::uint32_t> byte_counts;
|
||||
if (ifd.Get(kTiffTagStripOffsets, &strip_offsets) &&
|
||||
ifd.Get(kTiffTagStripByteCounts, &byte_counts) &&
|
||||
strip_offsets.size() == 1 && byte_counts.size() == 1) {
|
||||
*length = byte_counts[0];
|
||||
*offset = strip_offsets[0];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Error GetMakernoteIfd(const TiffDirectory& exif_ifd, const Endian endian,
|
||||
const std::uint32_t skip_offset, StreamInterface* stream,
|
||||
std::uint32_t* makernote_offset,
|
||||
@@ -377,28 +400,25 @@ Error DngGetPreviewData(StreamInterface* stream,
|
||||
std::uint32_t preview_offset = 0;
|
||||
std::uint32_t thumbnail_length = std::numeric_limits<std::uint32_t>::max();
|
||||
std::uint32_t thumbnail_offset = std::numeric_limits<std::uint32_t>::max();
|
||||
|
||||
std::uint32_t length = 0;
|
||||
std::uint32_t offset = 0;
|
||||
if (GetImageFromIfd(tiff_content.tiff_directory[0], &offset, &length)) {
|
||||
preview_length = length;
|
||||
preview_offset = offset;
|
||||
thumbnail_length = length;
|
||||
thumbnail_offset = offset;
|
||||
}
|
||||
|
||||
for (const auto& ifd : tiff_content.tiff_directory[0].GetSubDirectories()) {
|
||||
std::uint32_t compression;
|
||||
std::uint32_t photometric_interpretation;
|
||||
if (!ifd.Get(kTiffTagPhotometric, &photometric_interpretation) ||
|
||||
!ifd.Get(kTiffTagCompression, &compression)) {
|
||||
continue;
|
||||
}
|
||||
if (photometric_interpretation == 6 /* YCbCr */ &&
|
||||
(compression == 6 /* JPEG(old) */ || compression == 7 /* JPEG */)) {
|
||||
std::vector<std::uint32_t> strip_offsets;
|
||||
std::vector<std::uint32_t> byte_counts;
|
||||
if (ifd.Get(kTiffTagStripOffsets, &strip_offsets) &&
|
||||
ifd.Get(kTiffTagStripByteCounts, &byte_counts) &&
|
||||
strip_offsets.size() == 1 && byte_counts.size() == 1) {
|
||||
if (byte_counts[0] > preview_length) {
|
||||
preview_length = byte_counts[0];
|
||||
preview_offset = strip_offsets[0];
|
||||
}
|
||||
if (byte_counts[0] < thumbnail_length) {
|
||||
thumbnail_length = byte_counts[0];
|
||||
thumbnail_offset = strip_offsets[0];
|
||||
}
|
||||
if (GetImageFromIfd(ifd, &offset, &length)) {
|
||||
if (length > preview_length) {
|
||||
preview_length = length;
|
||||
preview_offset = offset;
|
||||
}
|
||||
if (length < thumbnail_length) {
|
||||
thumbnail_length = length;
|
||||
thumbnail_offset = offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -649,18 +669,7 @@ Error GetPreviewImageData(StreamInterface* data,
|
||||
}
|
||||
|
||||
std::vector<std::string> SupportedExtensions() {
|
||||
std::vector<std::string> extensions;
|
||||
extensions.push_back("ARW");
|
||||
extensions.push_back("CR2");
|
||||
extensions.push_back("DNG");
|
||||
extensions.push_back("NEF");
|
||||
extensions.push_back("NRW");
|
||||
extensions.push_back("ORF");
|
||||
extensions.push_back("PEF");
|
||||
extensions.push_back("RAF");
|
||||
extensions.push_back("RW2");
|
||||
extensions.push_back("SRW");
|
||||
return extensions;
|
||||
return {"ARW", "CR2", "DNG", "NEF", "NRW", "ORF", "PEF", "RAF", "RW2", "SRW"};
|
||||
}
|
||||
|
||||
} // namespace piex
|
||||
|
||||
@@ -78,6 +78,10 @@ struct PreviewImageData {
|
||||
Rational fnumber;
|
||||
Rational focal_length;
|
||||
Gps gps;
|
||||
|
||||
// Hint for the mosaic pattern dimension of the RAW image data. (0, 0) implies
|
||||
// that no mosaic info found. It is valid for DNG, NEF and NRW files.
|
||||
std::uint32_t cfa_pattern_dim[2] = {0, 0};
|
||||
};
|
||||
|
||||
// Defines the StreamInterface that needs to be implemented by the client.
|
||||
|
||||
@@ -92,7 +92,8 @@ bool GetFullDimension(const TiffDirectory& tiff_directory, std::uint32_t* width,
|
||||
bool GetRational(const TiffDirectory::Tag& tag, const TiffDirectory& directory,
|
||||
const int data_size, PreviewImageData::Rational* data) {
|
||||
std::vector<Rational> value;
|
||||
if (directory.Get(tag, &value)) {
|
||||
if (directory.Get(tag, &value) &&
|
||||
value.size() == static_cast<size_t>(data_size)) {
|
||||
for (size_t i = 0; i < value.size(); ++i) {
|
||||
data[i].numerator = value[i].numerator;
|
||||
data[i].denominator = value[i].denominator;
|
||||
@@ -219,6 +220,15 @@ Error FillPreviewImageData(const TiffDirectory& tiff_directory,
|
||||
success &= tiff_directory.Get(kTiffTagModel, &preview_image_data->model);
|
||||
}
|
||||
|
||||
if (tiff_directory.Has(kTiffTagCfaPatternDim)) {
|
||||
std::vector<std::uint32_t> cfa_pattern_dim;
|
||||
if (tiff_directory.Get(kTiffTagCfaPatternDim, &cfa_pattern_dim) &&
|
||||
cfa_pattern_dim.size() == 2) {
|
||||
preview_image_data->cfa_pattern_dim[0] = cfa_pattern_dim[0];
|
||||
preview_image_data->cfa_pattern_dim[1] = cfa_pattern_dim[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (tiff_directory.Has(kExifTagDateTimeOriginal)) {
|
||||
success &= tiff_directory.Get(kExifTagDateTimeOriginal,
|
||||
&preview_image_data->date_time);
|
||||
|
||||
@@ -63,6 +63,7 @@ enum TiffTags {
|
||||
kPentaxTagColorSpace = 0x0037,
|
||||
kTiffTagArtist = 0x013B,
|
||||
kTiffTagBitsPerSample = 0x0102,
|
||||
kTiffTagCfaPatternDim = 0x828D,
|
||||
kTiffTagCompression = 0x0103,
|
||||
kTiffTagDateTime = 0x0132,
|
||||
kTiffTagExifIfd = 0x8769,
|
||||
|
||||
Reference in New Issue
Block a user