Expose unsupported CR3 previews as binary

main
Miloš Komarčević 4 years ago
parent 40e5021577
commit 8b7d8729b7

@ -122,6 +122,7 @@ namespace Exiv2
void parseCr3Preview(DataBuf &data, void parseCr3Preview(DataBuf &data,
std::ostream &out, std::ostream &out,
bool bTrace, bool bTrace,
uint8_t version,
uint32_t width_offset, uint32_t width_offset,
uint32_t height_offset, uint32_t height_offset,
uint32_t size_offset, uint32_t size_offset,

@ -484,13 +484,25 @@ namespace Exiv2
parseXmp(box_length,io_->tell()); parseXmp(box_length,io_->tell());
break; break;
case TAG_thmb: case TAG_thmb:
if (version == 0) { switch (version) {
parseCr3Preview(data, out, bTrace, skip, skip+2, skip+4, skip+12); 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; break;
case TAG_prvw: case TAG_prvw:
if (version == 0) { switch (version) {
parseCr3Preview(data, out, bTrace, skip+2, skip+4, skip+8, skip+12); case 0: // JPEG
case 1: // HDR
parseCr3Preview(data, out, bTrace, version, skip+2, skip+4, skip+8, skip+12);
break;
default:
break;
} }
break; break;
@ -580,14 +592,13 @@ namespace Exiv2
void BmffImage::parseCr3Preview(DataBuf &data, void BmffImage::parseCr3Preview(DataBuf &data,
std::ostream& out, std::ostream& out,
bool bTrace, bool bTrace,
uint8_t version,
uint32_t width_offset, uint32_t width_offset,
uint32_t height_offset, uint32_t height_offset,
uint32_t size_offset, uint32_t size_offset,
uint32_t relative_position) uint32_t relative_position)
{ {
// Derived from https://github.com/lclevy/canon_cr3 // 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(); long here = io_->tell();
enforce(here >= 0 && enforce(here >= 0 &&
here <= std::numeric_limits<long>::max() - static_cast<long>(relative_position), here <= std::numeric_limits<long>::max() - static_cast<long>(relative_position),
@ -598,7 +609,14 @@ namespace Exiv2
nativePreview.height_ = data.read_uint16(height_offset, endian_); nativePreview.height_ = data.read_uint16(height_offset, endian_);
nativePreview.size_ = data.read_uint32(size_offset, endian_); nativePreview.size_ = data.read_uint32(size_offset, endian_);
nativePreview.filter_ = ""; nativePreview.filter_ = "";
switch (version) {
case 0:
nativePreview.mimeType_ = "image/jpeg"; nativePreview.mimeType_ = "image/jpeg";
break;
default:
nativePreview.mimeType_ = "application/octet-stream";
break;
}
nativePreviews_.push_back(nativePreview); nativePreviews_.push_back(nativePreview);
if (bTrace) { if (bTrace) {

Loading…
Cancel
Save