diff --git a/include/exiv2/bmffimage.hpp b/include/exiv2/bmffimage.hpp index a502f1f368..9db10652ea 100644 --- a/include/exiv2/bmffimage.hpp +++ b/include/exiv2/bmffimage.hpp @@ -121,6 +121,7 @@ namespace Exiv2 void parseCr3Preview(DataBuf &data, std::ostream &out, bool bTrace, + uint8_t version, uint32_t width_offset, uint32_t height_offset, uint32_t size_offset, diff --git a/src/bmffimage.cpp b/src/bmffimage.cpp index 87fec4dbec..44874036e6 100644 --- a/src/bmffimage.cpp +++ b/src/bmffimage.cpp @@ -488,13 +488,25 @@ namespace Exiv2 parseXmp(box_length,io_->tell()); break; case TAG_thmb: - if (version == 0) { - parseCr3Preview(data, out, bTrace, skip, skip+2, skip+4, skip+12); + switch (version) { + case 0: // JPEG + parseCr3Preview(data, out, bTrace, version, skip, skip+2, skip+4, skip+12); + break; + case 1: // HDR + parseCr3Preview(data, out, bTrace, version, skip+2, skip+4, skip+8, skip+12); + break; + default: + break; } break; case TAG_prvw: - if (version == 0) { - parseCr3Preview(data, out, bTrace, skip+2, skip+4, skip+8, skip+12); + switch (version) { + case 0: // JPEG + case 1: // HDR + parseCr3Preview(data, out, bTrace, version, skip+2, skip+4, skip+8, skip+12); + break; + default: + break; } break; @@ -584,14 +596,13 @@ namespace Exiv2 void BmffImage::parseCr3Preview(DataBuf &data, std::ostream& out, bool bTrace, + uint8_t version, uint32_t width_offset, uint32_t height_offset, uint32_t size_offset, uint32_t relative_position) { // Derived from https://github.com/lclevy/canon_cr3 - // Only JPEG (version 0) is currently supported - // (relative_position is identical between versions) long here = io_->tell(); enforce(here >= 0 && here <= std::numeric_limits::max() - static_cast(relative_position), @@ -606,7 +617,14 @@ namespace Exiv2 enforce(size_offset <= static_cast(data.size_ - 4), kerCorruptedMetadata); nativePreview.size_ = getLong(data.pData_ + size_offset, endian_); nativePreview.filter_ = ""; - nativePreview.mimeType_ = "image/jpeg"; + switch (version) { + case 0: + nativePreview.mimeType_ = "image/jpeg"; + break; + default: + nativePreview.mimeType_ = "application/octet-stream"; + break; + } nativePreviews_.push_back(nativePreview); if (bTrace) {