|
73 | 73 | #define TAG_cmt2 0x434D5432 /**< "CMD2" exifID */
|
74 | 74 | #define TAG_cmt3 0x434D5433 /**< "CMT3" canonID */
|
75 | 75 | #define TAG_cmt4 0x434D5434 /**< "CMT4" gpsID */
|
76 |
| -#define TAG_colr 0x636f6c72 /**< "colr" */ |
| 76 | +#define TAG_colr 0x636f6c72 /**< "colr" Colour information */ |
77 | 77 | #define TAG_exif 0x45786966 /**< "Exif" Used by JXL*/
|
78 |
| -#define TAG_xml 0x786d6c20 /**< "xml " Used by JXL*/ |
| 78 | +#define TAG_xml 0x786d6c20 /**< "xml " Used by JXL*/ |
79 | 79 | #define TAG_thmb 0x54484d42 /**< "THMB" Canon thumbnail */
|
80 | 80 | #define TAG_prvw 0x50525657 /**< "PRVW" Canon preview image */
|
81 | 81 |
|
@@ -126,7 +126,7 @@ namespace Exiv2
|
126 | 126 |
|
127 | 127 | bool BmffImage::fullBox(uint32_t box)
|
128 | 128 | {
|
129 |
| - return box == TAG_meta || box == TAG_iinf || box == TAG_iloc; |
| 129 | + return box == TAG_meta || box == TAG_iinf || box == TAG_iloc || box == TAG_thmb || box == TAG_prvw; |
130 | 130 | }
|
131 | 131 |
|
132 | 132 | std::string BmffImage::mimeType() const
|
@@ -247,7 +247,7 @@ namespace Exiv2
|
247 | 247 | enforce(data.size_ - skip >= 4, Exiv2::kerCorruptedMetadata);
|
248 | 248 | flags = getLong(data.pData_ + skip, endian_); // version/flags
|
249 | 249 | version = static_cast<uint8_t>(flags >> 24);
|
250 |
| - version &= 0x00ffffff; |
| 250 | + flags &= 0x00ffffff; |
251 | 251 | skip += 4;
|
252 | 252 | }
|
253 | 253 |
|
@@ -468,10 +468,14 @@ namespace Exiv2
|
468 | 468 | parseXmp(box_length,io_->tell());
|
469 | 469 | break;
|
470 | 470 | case TAG_thmb:
|
471 |
| - parseCr3Preview(data, out, bTrace, 4, 6, 8, 16); |
| 471 | + if (version == 0) { |
| 472 | + parseCr3Preview(data, out, bTrace, skip, skip+2, skip+4, skip+12); |
| 473 | + } |
472 | 474 | break;
|
473 | 475 | case TAG_prvw:
|
474 |
| - parseCr3Preview(data, out, bTrace, 6, 8, 12, 16); |
| 476 | + if (version == 0) { |
| 477 | + parseCr3Preview(data, out, bTrace, skip+2, skip+4, skip+8, skip+12); |
| 478 | + } |
475 | 479 | break;
|
476 | 480 |
|
477 | 481 | default: break ; /* do nothing */
|
@@ -560,17 +564,19 @@ namespace Exiv2
|
560 | 564 | void BmffImage::parseCr3Preview(DataBuf &data,
|
561 | 565 | std::ostream& out,
|
562 | 566 | bool bTrace,
|
563 |
| - uint16_t width_offset, |
564 |
| - uint16_t height_offset, |
| 567 | + uint32_t width_offset, |
| 568 | + uint32_t height_offset, |
565 | 569 | uint32_t size_offset,
|
566 |
| - uint16_t relative_position) |
| 570 | + uint32_t relative_position) |
567 | 571 | {
|
568 | 572 | // Derived from https://github.com/lclevy/canon_cr3
|
569 |
| - NativePreview nativePreview; |
| 573 | + // Only JPEG (version 0) is currently supported |
| 574 | + // (relative_position is identical between versions) |
570 | 575 | long here = io_->tell();
|
571 | 576 | enforce(here >= 0 &&
|
572 |
| - here <= std::numeric_limits<long>::max() - relative_position, |
| 577 | + here <= std::numeric_limits<long>::max() - static_cast<long>(relative_position), |
573 | 578 | kerCorruptedMetadata);
|
| 579 | + NativePreview nativePreview; |
574 | 580 | nativePreview.position_ = here + relative_position;
|
575 | 581 | enforce(4 <= data.size_, kerCorruptedMetadata);
|
576 | 582 | enforce(width_offset <= static_cast<size_t>(data.size_ - 2), kerCorruptedMetadata);
|
|
0 commit comments