Skip to content

Feature: Add Canon CR3 raw file support and shared ISOBMFF box walker - #731

Open
purno998 wants to merge 3 commits into
drewnoakes:mainfrom
purno998:main
Open

Feature: Add Canon CR3 raw file support and shared ISOBMFF box walker#731
purno998 wants to merge 3 commits into
drewnoakes:mainfrom
purno998:main

Conversation

@purno998

Copy link
Copy Markdown

Summary

  • Introduces a shared ISO Base Media File Format (ISOBMFF) box-walker that handles standard/large-size boxes, EOF-terminated boxes, and uuid boxes with automatic usertype parsing. Designed so existing MP4/QuickTime/HEIF readers can migrate onto it in later, CR3 is the first consumer.

  • Adds Cr3MetadataReader and a three-tier handler hierarchy (Cr3HandlerCr3CanonUuidHandler / Cr3PreviewUuidHandler) that decodes all three Canon UUID blocks found in CR3 files:

    • CMT1–CMT4 — TIFF blobs fed into the existing ExifTiffHandler, populating ExifIFD0Directory, ExifSubIFDDirectory, CanonMakernoteDirectory, and GpsDirectory without any new TIFF parsing logic.
    • XMP UUID — raw XMP packet delegated to XmpReader.
    • Preview UUIDPRVW box header decoded for preview dimensions.
    • THMB / CNCV — thumbnail dimensions and compressor version string stored in the new Cr3Directory.
    • Routes FileType.Crx through ImageMetadataReader.
  • Extends CanonMakernoteDirectory and CanonMakernoteDescriptor with tags present on EOS R / RF-mount bodies: FocalType, FocusBracketing, Clarity, HDR-PQ, five additional 0x40xx array tags, and 30 RF lens entries. Fixes FlashDetails to use a proper bitmask. Updates Contrast, Saturation, and Sharpness descriptors to handle signed
    int16 adjustment values from newer bodies while preserving existing Low/Normal/High labels for older cameras.

Notable design decisions

  • No new TIFF parsing. CMT1–CMT4 are self-contained TIFF byte streams; reusing TiffReader + ExifTiffHandler. FixedRootExifTiffHandler overrides setTiffMarker to push the correct root directory class (ExifSubIFD, Canon makernote, GPS) before IFD traversal begins.

  • Existing readers untouched. Mp4Reader, QuickTimeReader, and HeifReader are not modified. The shared walker is user by CR3 first, migrating the three legacy readers is a deliberate follow-up to keep this PR reviewable.

  • Backward-compatible descriptor changes. The specific values that old Canon cameras write for Contrast/Saturation/Sharpness (0, 1, 0xFFFF) continue to return "Normal", "High", "Low". Only values outside that set use the new signed-integer path.

Sample output — Canon EOS R8

[CR3]
  Major Brand                 = crx
  Minor Version              = 1
  Compatible Brands     = crx , isom
  Compressor Version   = CanonCR3_001/00.11.00/00.00.00
  Thumbnail Width        = 160
  Thumbnail Height       = 120
  Preview Width             = 1620
  Preview Height            = 1080

[Exif IFD0]
  Make                           = Canon
  Model                         = Canon EOS R8
  Image Width              = 6000 pixels
  Image Height             = 4000 pixels
  Orientation                = Top, left side (Horizontal / normal)
  Date/Time                  = 2023:08:24 21:40:55
  X Resolution               = 350 dots per inch
  Y Resolution               = 350 dots per inch

[Exif SubIFD]
  Exposure Time           = 1/250 sec
  F-Number                   = f/10.0
  ISO Speed Ratings     = 25600
  Date/Time Original     = 2023:08:24 21:40:55
  Focal Length               = 240 mm
  Lens Model                 = RF24-240mm F4-6.3 IS USM
  Lens Serial Number    = 2682002230
  Body Serial Number    = 023021003574

[Canon Makernote]
  Record Mode              = CR3+JPEG
  Quality                         = RAW
  Focal Type                  = Zoom
  Lens Type                   = Canon RF 24-240mm F4-6.3 IS USM
  Short Focal Length    = 24 1
  Long Focal Length     = 240 1
  Max Aperture             = f/6.3
  Exposure Mode          = Auto exposure
  Metering Mode           = Evaluative
  Flash Mode                 = No flash fired
  Flash Details              = E-TTL
  Contrast                     = Normal
  Saturation                   = Normal
  Focus Bracketing       = Disable
  Clarity                          = 0
  HDR PQ                       = Off
  Firmware Version        = Firmware Version 1.0.0
  Image Type                 = Canon EOS R8

[GPS]
  GPS Version ID           = 2.300

[XMP]
  xmp:Rating                  = 0

[File Type]
  Detected File Type Name    = CRX

ashrafuzzamanpurno added 3 commits May 26, 2026 15:15
  infrastructure. Designed so other readers (MP4,
  QuickTime, HEIF) can migrate onto it; CR3 is the first consumer.
  IsoBoxWalker. Decodes the three Canon uuid blocks: CMT1-CMT4 (TIFF blobs
  feeding ExifTiffHandler for IFD0, ExifSubIFD, Canon makernote and GPS),
  the XMP uuid (delegated to XmpReader), and the preview uuid (PRVW
  dimensions). Thumbnail dimensions are read from the THMB box and the
  compressor version from CNCV.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant